|
@@ -1,10 +1,684 @@
|
|
|
package ent_legal
|
|
|
|
|
|
-func 全量方法ABC() {
|
|
|
- //从现有主题库...直接获取
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "data_ent_wuye/ent_contact"
|
|
|
+ "data_ent_wuye/ent_util"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "log"
|
|
|
+ "regexp"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "sync"
|
|
|
|
|
|
- //凭安全量企业···查到数据告知通讯录
|
|
|
+ "github.com/google/uuid"
|
|
|
+ qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
|
|
|
+)
|
|
|
|
|
|
+var RegClean = regexp.MustCompile("[^ -~\u2E80-\u2FDF\u3040-\u318F\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7FF\u3002\u00a5\uff1f\uff01\uff0c\u3001\uff1b\uff1a\u201c\u201d\u2018\u2019\uff08\uff09\u300a\u300b\u3008\u3009\u3010\u3011\u300e\u300f\u300c\u300d\ufe43\ufe44\u3014\u3015\u2026\u2014\uff5e\ufe4f\uffe5\u00a5]+")
|
|
|
+
|
|
|
+func LegalFull() {
|
|
|
+ //从现有主题库...直接获取
|
|
|
+ getZhuTi()
|
|
|
+ //凭安全量企业···查到数据告知通讯录
|
|
|
+ // getPingAn()
|
|
|
+ //特企
|
|
|
+ // getTQ()
|
|
|
//马克信息···
|
|
|
+ // getMK()
|
|
|
+}
|
|
|
+
|
|
|
+func getZhuTi() {
|
|
|
+ log.Println("主体库全量任务开始")
|
|
|
+ index, total := 0, 0
|
|
|
+ q := map[string]interface{}{
|
|
|
+ "createtime": map[string]interface{}{
|
|
|
+ "lt": "2024-04-19 00:00:00",
|
|
|
+ },
|
|
|
+ }
|
|
|
+L:
|
|
|
+ for {
|
|
|
+ dataArr := ent_util.MysqlGlobalTool.Find("dws_f_ent_baseinfo", q, "name_id,name,company_id,address,area_code,city_code,district_code", "id", index*50000, 50000)
|
|
|
+ if dataArr != nil {
|
|
|
+ if len(*dataArr) == 0 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ pool := make(chan bool, 10)
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
+ for _, v := range *dataArr {
|
|
|
+ pool <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(v map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ id := qu.ObjToString(v["name_id"])
|
|
|
+ company_name := qu.ObjToString(v["name"])
|
|
|
+ if company_name == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ company_id := qu.ObjToString(v["company_id"])
|
|
|
+ company_address := qu.ObjToString(v["address"])
|
|
|
+ area_code := qu.ObjToString(v["area_code"])
|
|
|
+ city_code := qu.ObjToString(v["city_code"])
|
|
|
+ district_code := qu.ObjToString(v["district_code"])
|
|
|
+ company_label, company_label_str := []uint64{uint64(0)}, ""
|
|
|
+ qyxy_info := GetQyxyInfo(company_name)
|
|
|
+ // if qyxy_info != nil {
|
|
|
+ // company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
+ // }
|
|
|
+ company_code := qu.ObjToString(qyxy_info["company_code"])
|
|
|
+ credit_no := qu.ObjToString(qyxy_info["credit_no"])
|
|
|
+ org_code := qu.ObjToString(qyxy_info["org_code"])
|
|
|
+ tax_code := qu.ObjToString(qyxy_info["tax_code"])
|
|
|
+ establish_date := qu.Int64All(qyxy_info["establish_date"])
|
|
|
+ legal_person := qu.ObjToString(qyxy_info["legal_person"])
|
|
|
+ legal_person_caption := qu.ObjToString(qyxy_info["legal_person_caption"])
|
|
|
+ company_status := qu.ObjToString(qyxy_info["company_status"])
|
|
|
+ company_type := qu.ObjToString(qyxy_info["company_type"])
|
|
|
+ authority := qu.ObjToString(qyxy_info["authority"])
|
|
|
+ issue_date := qu.Int64All(qyxy_info["issue_date"])
|
|
|
+ operation_startdate := qu.ObjToString(qyxy_info["operation_startdate"])
|
|
|
+ operation_enddate := qu.ObjToString(qyxy_info["operation_enddate"])
|
|
|
+ capital := qu.ObjToString(qyxy_info["capital"])
|
|
|
+ business_scope := qu.ObjToString(qyxy_info["business_scope"])
|
|
|
+ comeintime := qu.Int64All(qyxy_info["comeintime"])
|
|
|
+ updatetime := qu.Int64All(qyxy_info["updatetime"])
|
|
|
+ legal_person_type := qu.IntAll(qyxy_info["legal_person_type"])
|
|
|
+ real_capital := qu.ObjToString(qyxy_info["real_capital"])
|
|
|
+ en_name := qu.ObjToString(qyxy_info["en_name"])
|
|
|
+ list_code := qu.ObjToString(qyxy_info["list_code"])
|
|
|
+ employee_no := qu.IntAll(qyxy_info["employee_no"])
|
|
|
+ website := qu.ObjToString(qyxy_info["website"])
|
|
|
+ company_phone := qu.ObjToString(qyxy_info["company_phone"])
|
|
|
+ company_email := qu.ObjToString(qyxy_info["company_email"])
|
|
|
+ query := `INSERT INTO information.ent_info (id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email) VALUES(?, ?, ?, bitmapBuild(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
|
+ err := ent_util.ClickHouseConn.Exec(context.Background(), query, id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err, "clickhouse存入失败", company_name)
|
|
|
+ } else {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "_id": id,
|
|
|
+ "company_name": company_name,
|
|
|
+ "company_id": company_id,
|
|
|
+ "company_address": company_address,
|
|
|
+ "area_code": area_code,
|
|
|
+ "city_code": city_code,
|
|
|
+ "district_code": district_code,
|
|
|
+ "company_label": company_label_str,
|
|
|
+ "company_code": company_code,
|
|
|
+ "credit_no": credit_no,
|
|
|
+ "org_code": org_code,
|
|
|
+ "tax_code": tax_code,
|
|
|
+ "establish_date": establish_date,
|
|
|
+ "legal_person": legal_person,
|
|
|
+ "legal_person_caption": legal_person_caption,
|
|
|
+ "company_status": company_status,
|
|
|
+ "company_type": company_type,
|
|
|
+ "authority": authority,
|
|
|
+ "issue_date": issue_date,
|
|
|
+ "operation_startdate": operation_startdate,
|
|
|
+ "operation_enddate": operation_enddate,
|
|
|
+ "capital": capital,
|
|
|
+ "business_scope": business_scope,
|
|
|
+ "comeintime": comeintime,
|
|
|
+ "updatetime": updatetime,
|
|
|
+ "legal_person_type": legal_person_type,
|
|
|
+ "real_capital": real_capital,
|
|
|
+ "en_name": en_name,
|
|
|
+ "list_code": list_code,
|
|
|
+ "employee_no": employee_no,
|
|
|
+ "website": website,
|
|
|
+ "company_phone": company_phone,
|
|
|
+ "company_email": company_email,
|
|
|
+ }
|
|
|
+ ok := ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
+ if ok {
|
|
|
+ log.Println("es存入成功")
|
|
|
+ } else {
|
|
|
+ log.Println("es存入失败!!!!", company_name)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(v)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ break L
|
|
|
+ }
|
|
|
+ index++
|
|
|
+ total += len(*dataArr)
|
|
|
+ if index%5 == 0 {
|
|
|
+ log.Println("cur idx ", total)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.Println("主体库全量任务结束")
|
|
|
+}
|
|
|
+
|
|
|
+func getPingAn() {
|
|
|
+ sess := ent_util.QyxyMgo.GetMgoConn()
|
|
|
+ defer ent_util.QyxyMgo.DestoryMongoConn(sess)
|
|
|
+ q := map[string]interface{}{}
|
|
|
+ it := sess.DB("mixdata").C("qyxy_std").Find(&q).Sort("_id").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.Println("cur index ", total)
|
|
|
+ }
|
|
|
+ pool <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ use_flag := qu.IntAll(tmp["use_flag"])
|
|
|
+ is_history := qu.IntAll(tmp["is_history"])
|
|
|
+ company_type := qu.ObjToString(tmp["company_type"])
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ if use_flag > 5 || is_history != 0 || company_name == "" || company_type == "个体工商户" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ query := fmt.Sprintf(`SELECT id FROM information.ent_info WHERE company_name = '%s'`, qu.ObjToString(tmp["company_name"]))
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count := 0
|
|
|
+ var id string
|
|
|
+ for rows.Next() {
|
|
|
+ if err := rows.Scan(
|
|
|
+ &id,
|
|
|
+ ); err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count++
|
|
|
+ }
|
|
|
+ if count == 0 {
|
|
|
+ id = uuid.New().String()
|
|
|
+ id = strings.ReplaceAll(id, "-", "")
|
|
|
+ area := qu.ObjToString(tmp["company_area"])
|
|
|
+ city := qu.ObjToString(tmp["company_city"])
|
|
|
+ district := qu.ObjToString(tmp["company_district"])
|
|
|
+ area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, district)
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ company_id := ent_util.BsonTOStringId(tmp["_id"])
|
|
|
+ company_address := qu.ObjToString(tmp["company_address"])
|
|
|
+ company_label, company_label_str := getCompanyLabel(company_name)
|
|
|
+ company_code := qu.ObjToString(tmp["company_code"])
|
|
|
+ credit_no := qu.ObjToString(tmp["credit_no"])
|
|
|
+ org_code := qu.ObjToString(tmp["org_code"])
|
|
|
+ tax_code := qu.ObjToString(tmp["tax_code"])
|
|
|
+ establish_date := qu.Int64All(tmp["establish_date"])
|
|
|
+ legal_person := qu.ObjToString(tmp["legal_person"])
|
|
|
+ legal_person_caption := qu.ObjToString(tmp["legal_person_caption"])
|
|
|
+ company_status := qu.ObjToString(tmp["company_status"])
|
|
|
+ company_type := qu.ObjToString(tmp["company_type"])
|
|
|
+ authority := qu.ObjToString(tmp["authority"])
|
|
|
+ issue_date := qu.Int64All(tmp["issue_date"])
|
|
|
+ operation_startdate := qu.ObjToString(tmp["operation_startdate"])
|
|
|
+ operation_enddate := qu.ObjToString(tmp["operation_enddate"])
|
|
|
+ capital := qu.ObjToString(tmp["capital"])
|
|
|
+ business_scope := qu.ObjToString(tmp["business_scope"])
|
|
|
+ comeintime := qu.Int64All(tmp["comeintime"])
|
|
|
+ updatetime := qu.Int64All(tmp["updatetime"])
|
|
|
+ legal_person_type := qu.IntAll(tmp["legal_person_type"])
|
|
|
+ real_capital := qu.ObjToString(tmp["real_capital"])
|
|
|
+ en_name := qu.ObjToString(tmp["en_name"])
|
|
|
+ list_code := qu.ObjToString(tmp["list_code"])
|
|
|
+ employee_no := qu.IntAll(tmp["employee_no"])
|
|
|
+ website := qu.ObjToString(tmp["website"])
|
|
|
+ company_phone := qu.ObjToString(tmp["company_phone"])
|
|
|
+ company_email := qu.ObjToString(tmp["company_email"])
|
|
|
+ query := `INSERT INTO information.ent_info (id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email) VALUES(?, ?, ?, bitmapBuild(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
|
+ err := ent_util.ClickHouseConn.Exec(context.Background(), query, id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err, "clickhouse存入失败", company_name)
|
|
|
+ } else {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "_id": id,
|
|
|
+ "company_name": company_name,
|
|
|
+ "company_id": company_id,
|
|
|
+ "company_address": company_address,
|
|
|
+ "area_code": area_code,
|
|
|
+ "city_code": city_code,
|
|
|
+ "district_code": district_code,
|
|
|
+ "company_label": company_label_str,
|
|
|
+ "company_code": company_code,
|
|
|
+ "credit_no": credit_no,
|
|
|
+ "org_code": org_code,
|
|
|
+ "tax_code": tax_code,
|
|
|
+ "establish_date": establish_date,
|
|
|
+ "legal_person": legal_person,
|
|
|
+ "legal_person_caption": legal_person_caption,
|
|
|
+ "company_status": company_status,
|
|
|
+ "company_type": company_type,
|
|
|
+ "authority": authority,
|
|
|
+ "issue_date": issue_date,
|
|
|
+ "operation_startdate": operation_startdate,
|
|
|
+ "operation_enddate": operation_enddate,
|
|
|
+ "capital": capital,
|
|
|
+ "business_scope": business_scope,
|
|
|
+ "comeintime": comeintime,
|
|
|
+ "updatetime": updatetime,
|
|
|
+ "legal_person_type": legal_person_type,
|
|
|
+ "real_capital": real_capital,
|
|
|
+ "en_name": en_name,
|
|
|
+ "list_code": list_code,
|
|
|
+ "employee_no": employee_no,
|
|
|
+ "website": website,
|
|
|
+ "company_phone": company_phone,
|
|
|
+ "company_email": company_email,
|
|
|
+ }
|
|
|
+ ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
+ ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ log.Println("is over ~ ", total)
|
|
|
+}
|
|
|
+
|
|
|
+func getTQ() {
|
|
|
+ tqarr := []string{"special_enterprise", "special_foundation", "special_gov_unit", "special_hongkong_company", "special_hongkong_company_history", "special_law_office", "special_social_organ", "special_trade_union"}
|
|
|
+ for _, db := range tqarr {
|
|
|
+ sess := ent_util.SpiMgo.GetMgoConn()
|
|
|
+ defer ent_util.SpiMgo.DestoryMongoConn(sess)
|
|
|
+ q := map[string]interface{}{}
|
|
|
+ it := sess.DB("mixdata").C(db).Find(&q).Sort("_id").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.Println("cur index ", total)
|
|
|
+ }
|
|
|
+ pool <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ use_flag := qu.IntAll(tmp["use_flag"])
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ if use_flag > 5 || company_name == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ query := fmt.Sprintf(`SELECT id FROM information.ent_info WHERE company_name = '%s'`, qu.ObjToString(tmp["company_name"]))
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count := 0
|
|
|
+ var id string
|
|
|
+ for rows.Next() {
|
|
|
+ if err := rows.Scan(
|
|
|
+ &id,
|
|
|
+ ); err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count++
|
|
|
+ }
|
|
|
+ if count == 0 {
|
|
|
+ id = uuid.New().String()
|
|
|
+ id = strings.ReplaceAll(id, "-", "")
|
|
|
+ area := qu.ObjToString(tmp["company_area"])
|
|
|
+ city := qu.ObjToString(tmp["company_city"])
|
|
|
+ district := qu.ObjToString(tmp["company_district"])
|
|
|
+ area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, district)
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ company_id := ent_util.BsonTOStringId(tmp["_id"])
|
|
|
+ company_address := qu.ObjToString(tmp["company_address"])
|
|
|
+ company_label, company_label_str := getCompanyLabel(company_name)
|
|
|
+ company_code := qu.ObjToString(tmp["company_code"])
|
|
|
+ credit_no := qu.ObjToString(tmp["credit_no"])
|
|
|
+ org_code := qu.ObjToString(tmp["org_code"])
|
|
|
+ tax_code := qu.ObjToString(tmp["tax_code"])
|
|
|
+ establish_date := qu.Int64All(tmp["establish_date"])
|
|
|
+ legal_person := qu.ObjToString(tmp["legal_person"])
|
|
|
+ legal_person_caption := qu.ObjToString(tmp["legal_person_caption"])
|
|
|
+ company_status := qu.ObjToString(tmp["company_status"])
|
|
|
+ company_type := qu.ObjToString(tmp["company_type"])
|
|
|
+ authority := qu.ObjToString(tmp["authority"])
|
|
|
+ issue_date := qu.Int64All(tmp["issue_date"])
|
|
|
+ operation_startdate := qu.ObjToString(tmp["operation_startdate"])
|
|
|
+ operation_enddate := qu.ObjToString(tmp["operation_enddate"])
|
|
|
+ capital := qu.ObjToString(tmp["capital"])
|
|
|
+ business_scope := qu.ObjToString(tmp["business_scope"])
|
|
|
+ comeintime := qu.Int64All(tmp["comeintime"])
|
|
|
+ updatetime := qu.Int64All(tmp["updatetime"])
|
|
|
+ legal_person_type := qu.IntAll(tmp["legal_person_type"])
|
|
|
+ real_capital := qu.ObjToString(tmp["real_capital"])
|
|
|
+ en_name := qu.ObjToString(tmp["en_name"])
|
|
|
+ list_code := qu.ObjToString(tmp["list_code"])
|
|
|
+ employee_no := qu.IntAll(tmp["employee_no"])
|
|
|
+ website := qu.ObjToString(tmp["website"])
|
|
|
+ company_phone := qu.ObjToString(tmp["company_phone"])
|
|
|
+ company_email := qu.ObjToString(tmp["company_email"])
|
|
|
+ query := `INSERT INTO information.ent_info (id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email) VALUES(?, ?, ?, bitmapBuild(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
|
+ err := ent_util.ClickHouseConn.Exec(context.Background(), query, id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err, "clickhouse存入失败", company_name)
|
|
|
+ } else {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "_id": id,
|
|
|
+ "company_name": company_name,
|
|
|
+ "company_id": company_id,
|
|
|
+ "company_address": company_address,
|
|
|
+ "area_code": area_code,
|
|
|
+ "city_code": city_code,
|
|
|
+ "district_code": district_code,
|
|
|
+ "company_label": company_label_str,
|
|
|
+ "company_code": company_code,
|
|
|
+ "credit_no": credit_no,
|
|
|
+ "org_code": org_code,
|
|
|
+ "tax_code": tax_code,
|
|
|
+ "establish_date": establish_date,
|
|
|
+ "legal_person": legal_person,
|
|
|
+ "legal_person_caption": legal_person_caption,
|
|
|
+ "company_status": company_status,
|
|
|
+ "company_type": company_type,
|
|
|
+ "authority": authority,
|
|
|
+ "issue_date": issue_date,
|
|
|
+ "operation_startdate": operation_startdate,
|
|
|
+ "operation_enddate": operation_enddate,
|
|
|
+ "capital": capital,
|
|
|
+ "business_scope": business_scope,
|
|
|
+ "comeintime": comeintime,
|
|
|
+ "updatetime": updatetime,
|
|
|
+ "legal_person_type": legal_person_type,
|
|
|
+ "real_capital": real_capital,
|
|
|
+ "en_name": en_name,
|
|
|
+ "list_code": list_code,
|
|
|
+ "employee_no": employee_no,
|
|
|
+ "website": website,
|
|
|
+ "company_phone": company_phone,
|
|
|
+ "company_email": company_email,
|
|
|
+ }
|
|
|
+ ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
+ ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ log.Println("is over ~ ", total)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func getMK() {
|
|
|
+ sess := ent_util.QyxyMgo.GetMgoConn()
|
|
|
+ defer ent_util.QyxyMgo.DestoryMongoConn(sess)
|
|
|
+ q := map[string]interface{}{}
|
|
|
+ it := sess.DB("mixdata").C("qyxy_xzh").Find(&q).Sort("_id").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.Println("cur index ", total)
|
|
|
+ }
|
|
|
+ pool <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-pool
|
|
|
+ wg.Done()
|
|
|
+ }()
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ if company_name == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ query := fmt.Sprintf(`SELECT id FROM information.ent_info WHERE company_name = '%s'`, qu.ObjToString(tmp["company_name"]))
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count := 0
|
|
|
+ var id string
|
|
|
+ for rows.Next() {
|
|
|
+ if err := rows.Scan(
|
|
|
+ &id,
|
|
|
+ ); err != nil {
|
|
|
+ log.Println(err)
|
|
|
+ }
|
|
|
+ count++
|
|
|
+ }
|
|
|
+ if count == 0 {
|
|
|
+ id = uuid.New().String()
|
|
|
+ id = strings.ReplaceAll(id, "-", "")
|
|
|
+ area := qu.ObjToString(tmp["company_area"])
|
|
|
+ city := qu.ObjToString(tmp["company_city"])
|
|
|
+ district := qu.ObjToString(tmp["company_district"])
|
|
|
+ area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, district)
|
|
|
+ company_name := qu.ObjToString(tmp["company_name"])
|
|
|
+ if company_name == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ company_id := ent_util.BsonTOStringId(tmp["_id"])
|
|
|
+ company_address := qu.ObjToString(tmp["company_address"])
|
|
|
+ company_label, company_label_str := getCompanyLabel(company_name)
|
|
|
+ company_code := qu.ObjToString(tmp["company_code"])
|
|
|
+ credit_no := qu.ObjToString(tmp["credit_no"])
|
|
|
+ org_code := qu.ObjToString(tmp["org_code"])
|
|
|
+ tax_code := qu.ObjToString(tmp["tax_code"])
|
|
|
+ establish_date := qu.Int64All(tmp["establish_date"])
|
|
|
+ legal_person := qu.ObjToString(tmp["legal_person"])
|
|
|
+ legal_person_caption := qu.ObjToString(tmp["legal_person_caption"])
|
|
|
+ company_status := qu.ObjToString(tmp["company_status"])
|
|
|
+ company_type := qu.ObjToString(tmp["company_type"])
|
|
|
+ authority := qu.ObjToString(tmp["authority"])
|
|
|
+ issue_date := qu.Int64All(tmp["issue_date"])
|
|
|
+ operation_startdate := qu.ObjToString(tmp["operation_startdate"])
|
|
|
+ operation_enddate := qu.ObjToString(tmp["operation_enddate"])
|
|
|
+ capital := qu.ObjToString(tmp["capital"])
|
|
|
+ business_scope := qu.ObjToString(tmp["business_scope"])
|
|
|
+ comeintime := qu.Int64All(tmp["comeintime"])
|
|
|
+ updatetime := qu.Int64All(tmp["updatetime"])
|
|
|
+ legal_person_type := qu.IntAll(tmp["legal_person_type"])
|
|
|
+ real_capital := qu.ObjToString(tmp["real_capital"])
|
|
|
+ en_name := qu.ObjToString(tmp["en_name"])
|
|
|
+ list_code := qu.ObjToString(tmp["list_code"])
|
|
|
+ employee_no := qu.IntAll(tmp["employee_no"])
|
|
|
+ website := qu.ObjToString(tmp["website"])
|
|
|
+ company_phone := qu.ObjToString(tmp["company_phone"])
|
|
|
+ company_email := qu.ObjToString(tmp["company_email"])
|
|
|
+ query := `INSERT INTO information.ent_info (id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email) VALUES(?, ?, ?, bitmapBuild(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
|
+ err := ent_util.ClickHouseConn.Exec(context.Background(), query, id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_date, legal_person, legal_person_caption, company_status, company_type, authority, issue_date, operation_startdate, operation_enddate, capital, company_address, business_scope, comeintime, updatetime, legal_person_type, real_capital, en_name, area_code, city_code, district_code, list_code, employee_no, website, company_phone, company_email)
|
|
|
+ if err != nil {
|
|
|
+ log.Println(err, "clickhouse存入失败", company_name)
|
|
|
+ } else {
|
|
|
+ data := map[string]interface{}{
|
|
|
+ "_id": id,
|
|
|
+ "company_name": company_name,
|
|
|
+ "company_id": company_id,
|
|
|
+ "company_address": company_address,
|
|
|
+ "area_code": area_code,
|
|
|
+ "city_code": city_code,
|
|
|
+ "district_code": district_code,
|
|
|
+ "company_label": company_label_str,
|
|
|
+ "company_code": company_code,
|
|
|
+ "credit_no": credit_no,
|
|
|
+ "org_code": org_code,
|
|
|
+ "tax_code": tax_code,
|
|
|
+ "establish_date": establish_date,
|
|
|
+ "legal_person": legal_person,
|
|
|
+ "legal_person_caption": legal_person_caption,
|
|
|
+ "company_status": company_status,
|
|
|
+ "company_type": company_type,
|
|
|
+ "authority": authority,
|
|
|
+ "issue_date": issue_date,
|
|
|
+ "operation_startdate": operation_startdate,
|
|
|
+ "operation_enddate": operation_enddate,
|
|
|
+ "capital": capital,
|
|
|
+ "business_scope": business_scope,
|
|
|
+ "comeintime": comeintime,
|
|
|
+ "updatetime": updatetime,
|
|
|
+ "legal_person_type": legal_person_type,
|
|
|
+ "real_capital": real_capital,
|
|
|
+ "en_name": en_name,
|
|
|
+ "list_code": list_code,
|
|
|
+ "employee_no": employee_no,
|
|
|
+ "website": website,
|
|
|
+ "company_phone": company_phone,
|
|
|
+ "company_email": company_email,
|
|
|
+ }
|
|
|
+ ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
+ ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }(tmp)
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ wg.Wait()
|
|
|
+ log.Println("is over ~ ", total)
|
|
|
+}
|
|
|
|
|
|
+func getCompanyLabel(name string) ([]uint64, string) {
|
|
|
+ name = strings.TrimSpace(RegClean.ReplaceAllString(name, ""))
|
|
|
+ sql := `{
|
|
|
+ "query": {
|
|
|
+ "bool": {
|
|
|
+ "should": [
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ "buyer": "` + name + `"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ "s_winner": "` + name + `"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ "agency": "` + name + `"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "aggs": {
|
|
|
+ "total_sum_a": {
|
|
|
+ "terms": {
|
|
|
+ "field": "tag_subinformation"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "total_sum_b": {
|
|
|
+ "terms": {
|
|
|
+ "field": "tag_subinformation_ai"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "total_sum_c": {
|
|
|
+ "terms": {
|
|
|
+ "field": "property_form"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "size": 0
|
|
|
+ }`
|
|
|
+ sql2 := `{
|
|
|
+ "query": {
|
|
|
+ "bool": {
|
|
|
+ "must": [
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ "buyer": "` + name + `"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "aggs": {
|
|
|
+ "total_sum_a": {
|
|
|
+ "terms": {
|
|
|
+ "field": "buyerclass"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "size": 0
|
|
|
+ }`
|
|
|
+ subMap, propertyFormArr, buyerClassArr, bitMapCodeArr, bitMapStrArr := map[string]bool{}, []string{}, []string{}, []uint64{}, []string{}
|
|
|
+ res, _, _ := ent_util.Es.GetAggs("bidding", "bidding", sql)
|
|
|
+ if res != nil {
|
|
|
+ ass, _ := res.Children("total_sum_a")
|
|
|
+ as, _ := ass.Aggregations["buckets"].MarshalJSON()
|
|
|
+ if len(as) > 0 {
|
|
|
+ buckets := []map[string]interface{}{}
|
|
|
+ json.Unmarshal(as, &buckets)
|
|
|
+ if len(buckets) > 0 {
|
|
|
+ for _, v := range buckets {
|
|
|
+ subMap[qu.ObjToString(v["key"])] = true //tag_subinformation
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bss, _ := res.Children("total_sum_b")
|
|
|
+ bs, _ := bss.Aggregations["buckets"].MarshalJSON()
|
|
|
+ if len(bs) > 0 {
|
|
|
+ buckets := []map[string]interface{}{}
|
|
|
+ json.Unmarshal(bs, &buckets)
|
|
|
+ if len(buckets) > 0 {
|
|
|
+ for _, v := range buckets {
|
|
|
+ subMap[qu.ObjToString(v["key"])] = true //tag_subinformation_ai
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ css, _ := res.Children("total_sum_c")
|
|
|
+ cs, _ := css.Aggregations["buckets"].MarshalJSON()
|
|
|
+ if len(cs) > 0 {
|
|
|
+ buckets := []map[string]interface{}{}
|
|
|
+ json.Unmarshal(cs, &buckets)
|
|
|
+ if len(buckets) > 0 {
|
|
|
+ for _, v := range buckets {
|
|
|
+ propertyFormArr = append(propertyFormArr, qu.ObjToString(v["key"])) //property_form
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.Println("sql", sql)
|
|
|
+ }
|
|
|
+ ress, _, _ := ent_util.Es.GetAggs("bidding", "bidding", sql2)
|
|
|
+ if ress != nil {
|
|
|
+ css, _ := res.Children("total_sum_a")
|
|
|
+ cs, _ := css.Aggregations["buckets"].MarshalJSON()
|
|
|
+ if len(cs) > 0 {
|
|
|
+ buckets := []map[string]interface{}{}
|
|
|
+ json.Unmarshal(cs, &buckets)
|
|
|
+ if len(buckets) > 0 {
|
|
|
+ for _, v := range buckets {
|
|
|
+ buyerClassArr = append(buyerClassArr, qu.ObjToString(v["key"])) //buyerclass
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.Println("sql2", sql2)
|
|
|
+ }
|
|
|
+ if len(subMap) > 0 {
|
|
|
+ for s, _ := range subMap {
|
|
|
+ bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode2[s]))
|
|
|
+ bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode2[s]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(propertyFormArr) > 0 {
|
|
|
+ for _, p := range propertyFormArr {
|
|
|
+ bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode3[p]))
|
|
|
+ bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode3[p]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(buyerClassArr) > 0 {
|
|
|
+ for _, b := range propertyFormArr {
|
|
|
+ bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode1[b]))
|
|
|
+ bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode1[b]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(bitMapCodeArr) == 0 {
|
|
|
+ bitMapCodeArr = []uint64{uint64(0)}
|
|
|
+ }
|
|
|
+ return bitMapCodeArr, strings.Join(bitMapStrArr, ",")
|
|
|
}
|