|
@@ -0,0 +1,127 @@
|
|
|
+package ent_legal
|
|
|
+
|
|
|
+import (
|
|
|
+ ul "data_ent_wuye/ent_util"
|
|
|
+ log "github.com/donnie4w/go-logger/logger"
|
|
|
+ "github.com/google/uuid"
|
|
|
+ qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
|
|
|
+ "strings"
|
|
|
+ "sync"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+var BidFields = map[string]interface{}{
|
|
|
+ "extracttype": 1, "buyerclass": 1, "publishtime": 1,
|
|
|
+ "buyer": 1, "agency": 1, "winner": 1, "s_winner": 1,
|
|
|
+ "agencytel": 1, "winnertel": 1, "buyertel": 1,
|
|
|
+ "agencyperson": 1, "winnerperson": 1, "buyerperson": 1,
|
|
|
+ "owner": 1, "project_person": 1, "project_phone": 1,
|
|
|
+}
|
|
|
+
|
|
|
+// 正常标讯增量信息····
|
|
|
+func RunLegalInfo(gtid string, lteid string) {
|
|
|
+ log.Debug("增量~~~")
|
|
|
+ sess := ul.SourceMgo.GetMgoConn()
|
|
|
+ defer ul.SourceMgo.DestoryMongoConn(sess)
|
|
|
+ q := map[string]interface{}{
|
|
|
+ "_id": map[string]interface{}{
|
|
|
+ "$gt": ul.StringTOBsonId(gtid),
|
|
|
+ "$lte": ul.StringTOBsonId(lteid),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ log.Debug("查询语句 ~ ", q)
|
|
|
+ it := sess.DB(ul.SourceMgo.DbName).C(ul.S_Coll_Name).Find(&q).Sort("_id").Select(BidFields).Iter()
|
|
|
+ pool := make(chan bool, 10)
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
+ total := 0
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
+ if total%1000 == 0 {
|
|
|
+ log.Debug("cur index ", total)
|
|
|
+ }
|
|
|
+ pool <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ if qu.IntAll(tmp["extracttype"]) != 1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if qu.ObjToString(tmp["buyer"]) == "" &&
|
|
|
+ qu.ObjToString(tmp["agency"]) == "" &&
|
|
|
+ qu.ObjToString(tmp["winner"]) == "" &&
|
|
|
+ qu.ObjToString(tmp["owner"]) == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //处理构建法人信息
|
|
|
+ CreateLegalInfo(tmp)
|
|
|
+ }(tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ log.Debug("is over ~ ", total)
|
|
|
+}
|
|
|
+
|
|
|
+func CreateLegalInfo(tmp map[string]interface{}) {
|
|
|
+ //构建法人信息...
|
|
|
+ 方法名字ABC("徐氏企业")
|
|
|
+ //winner_arr, winner_bool := ul.SegmentationEntName(winner, s_winner)
|
|
|
+}
|
|
|
+
|
|
|
+func 方法名字ABC(name string) {
|
|
|
+ //法人是否存在更新?
|
|
|
+ //......
|
|
|
+ info := map[string]interface{}{}
|
|
|
+ if info == nil { //新增法人信息
|
|
|
+ base_info := map[string]interface{}{}
|
|
|
+ //法人信息所需要的大部分企业信息
|
|
|
+ qyxy_info := GetQyxyInfo(name)
|
|
|
+ base_info["name"] = name
|
|
|
+ area := qu.ObjToString(qyxy_info["company_area"])
|
|
|
+ city := qu.ObjToString(qyxy_info["company_city"])
|
|
|
+ district := qu.ObjToString(qyxy_info["company_district"])
|
|
|
+ base_info["area_code"], base_info["city_code"], base_info["district_code"] = ul.CalculateRegionCode(area, city, district)
|
|
|
+ name_id := uuid.New().String()
|
|
|
+ name_id = strings.ReplaceAll(name_id, "-", "")
|
|
|
+ base_info["name_id"] = name_id
|
|
|
+ base_info["createtime"] = time.Unix(time.Now().Unix(), 0).Format(ul.TimeLayout)
|
|
|
+ /*
|
|
|
+ ···
|
|
|
+ ···
|
|
|
+ */
|
|
|
+ //告知通讯录...
|
|
|
+ } else {
|
|
|
+ //告知通讯录...
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 创建企业信息
|
|
|
+func GetQyxyInfo(name string) map[string]interface{} {
|
|
|
+ qyxy_info := map[string]interface{}{}
|
|
|
+ dataArr, _ := ul.QyxyMgo.Find("qyxy_std", map[string]interface{}{"company_name": name}, map[string]interface{}{"updatetime": -1}, map[string]interface{}{
|
|
|
+ "_id": 1,
|
|
|
+ "company_name": 1,
|
|
|
+ "company_address": 1,
|
|
|
+ "company_area": 1,
|
|
|
+ "company_city": 1,
|
|
|
+ "company_district": 1,
|
|
|
+ "legal_person": 1,
|
|
|
+ "company_phone": 1,
|
|
|
+ "company_email": 1,
|
|
|
+ "company_type_old": 1,
|
|
|
+ "字段很多": 1,
|
|
|
+ })
|
|
|
+ if len(dataArr) > 0 {
|
|
|
+ qyxy_info = dataArr[0] //补充企业信息
|
|
|
+ } else {
|
|
|
+ data := ul.SpiMgo.FindOne("company_history_name", map[string]interface{}{
|
|
|
+ "history_name": name,
|
|
|
+ })
|
|
|
+ if len(data) > 0 {
|
|
|
+ company_id := qu.ObjToString(data["company_id"])
|
|
|
+ qyxy_info = ul.QyxyMgo.FindOne("qyxy_std", map[string]interface{}{"_id": company_id})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return qyxy_info
|
|
|
+}
|