|
@@ -4,29 +4,34 @@ import (
|
|
"context"
|
|
"context"
|
|
"data_ent_wuye/ent_contact"
|
|
"data_ent_wuye/ent_contact"
|
|
"data_ent_wuye/ent_util"
|
|
"data_ent_wuye/ent_util"
|
|
- "encoding/json"
|
|
|
|
- "fmt"
|
|
|
|
"log"
|
|
"log"
|
|
"regexp"
|
|
"regexp"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"sync"
|
|
"sync"
|
|
|
|
+ "time"
|
|
|
|
+
|
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/google/uuid"
|
|
qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
|
|
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]+")
|
|
|
|
|
|
+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]+")
|
|
|
|
+ Ch = make(chan map[string]any, 500)
|
|
|
|
+ ChEnd = make(chan bool)
|
|
|
|
+)
|
|
|
|
|
|
func LegalFull() {
|
|
func LegalFull() {
|
|
//从现有主题库...直接获取
|
|
//从现有主题库...直接获取
|
|
- getZhuTi()
|
|
|
|
|
|
+ // getZhuTi()
|
|
//凭安全量企业···查到数据告知通讯录
|
|
//凭安全量企业···查到数据告知通讯录
|
|
- // getPingAn()
|
|
|
|
|
|
+ getPingAn()
|
|
//特企
|
|
//特企
|
|
- // getTQ()
|
|
|
|
|
|
+ getTQ()
|
|
//马克信息···
|
|
//马克信息···
|
|
- // getMK()
|
|
|
|
|
|
+ getMK()
|
|
}
|
|
}
|
|
|
|
|
|
func getZhuTi() {
|
|
func getZhuTi() {
|
|
@@ -66,20 +71,30 @@ L:
|
|
district_code := qu.ObjToString(v["district_code"])
|
|
district_code := qu.ObjToString(v["district_code"])
|
|
company_label, company_label_str := []uint64{uint64(0)}, ""
|
|
company_label, company_label_str := []uint64{uint64(0)}, ""
|
|
qyxy_info := GetQyxyInfo(company_name)
|
|
qyxy_info := GetQyxyInfo(company_name)
|
|
- // if qyxy_info != nil {
|
|
|
|
- // company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
|
- // }
|
|
|
|
|
|
+ if qyxy_info != nil {
|
|
|
|
+ company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
|
+ }
|
|
company_code := qu.ObjToString(qyxy_info["company_code"])
|
|
company_code := qu.ObjToString(qyxy_info["company_code"])
|
|
credit_no := qu.ObjToString(qyxy_info["credit_no"])
|
|
credit_no := qu.ObjToString(qyxy_info["credit_no"])
|
|
org_code := qu.ObjToString(qyxy_info["org_code"])
|
|
org_code := qu.ObjToString(qyxy_info["org_code"])
|
|
tax_code := qu.ObjToString(qyxy_info["tax_code"])
|
|
tax_code := qu.ObjToString(qyxy_info["tax_code"])
|
|
- establish_date := qu.Int64All(qyxy_info["establish_date"])
|
|
|
|
|
|
+ establish_date := qu.ObjToString(qyxy_info["establish_date"])
|
|
|
|
+ establish_dates := int64(0)
|
|
|
|
+ if establish_date != "" {
|
|
|
|
+ establish_date1, _ := time.ParseInLocation(date.Date_Short_Layout, establish_date, time.Local)
|
|
|
|
+ establish_dates = establish_date1.Unix()
|
|
|
|
+ }
|
|
|
|
+ issue_date := qu.ObjToString(qyxy_info["issue_date"])
|
|
|
|
+ issue_dates := int64(0)
|
|
|
|
+ if issue_date != "" {
|
|
|
|
+ issue_date1, _ := time.ParseInLocation(date.Date_Short_Layout, issue_date, time.Local)
|
|
|
|
+ issue_dates = issue_date1.Unix()
|
|
|
|
+ }
|
|
legal_person := qu.ObjToString(qyxy_info["legal_person"])
|
|
legal_person := qu.ObjToString(qyxy_info["legal_person"])
|
|
legal_person_caption := qu.ObjToString(qyxy_info["legal_person_caption"])
|
|
legal_person_caption := qu.ObjToString(qyxy_info["legal_person_caption"])
|
|
company_status := qu.ObjToString(qyxy_info["company_status"])
|
|
company_status := qu.ObjToString(qyxy_info["company_status"])
|
|
company_type := qu.ObjToString(qyxy_info["company_type"])
|
|
company_type := qu.ObjToString(qyxy_info["company_type"])
|
|
authority := qu.ObjToString(qyxy_info["authority"])
|
|
authority := qu.ObjToString(qyxy_info["authority"])
|
|
- issue_date := qu.Int64All(qyxy_info["issue_date"])
|
|
|
|
operation_startdate := qu.ObjToString(qyxy_info["operation_startdate"])
|
|
operation_startdate := qu.ObjToString(qyxy_info["operation_startdate"])
|
|
operation_enddate := qu.ObjToString(qyxy_info["operation_enddate"])
|
|
operation_enddate := qu.ObjToString(qyxy_info["operation_enddate"])
|
|
capital := qu.ObjToString(qyxy_info["capital"])
|
|
capital := qu.ObjToString(qyxy_info["capital"])
|
|
@@ -95,7 +110,7 @@ L:
|
|
company_phone := qu.ObjToString(qyxy_info["company_phone"])
|
|
company_phone := qu.ObjToString(qyxy_info["company_phone"])
|
|
company_email := qu.ObjToString(qyxy_info["company_email"])
|
|
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(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
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)
|
|
|
|
|
|
+ err := ent_util.ClickHouseConn.Exec(context.Background(), query, id, company_id, company_name, company_label, company_code, credit_no, org_code, tax_code, establish_dates, legal_person, legal_person_caption, company_status, company_type, authority, issue_dates, 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 {
|
|
if err != nil {
|
|
log.Println(err, "clickhouse存入失败", company_name)
|
|
log.Println(err, "clickhouse存入失败", company_name)
|
|
} else {
|
|
} else {
|
|
@@ -112,13 +127,13 @@ L:
|
|
"credit_no": credit_no,
|
|
"credit_no": credit_no,
|
|
"org_code": org_code,
|
|
"org_code": org_code,
|
|
"tax_code": tax_code,
|
|
"tax_code": tax_code,
|
|
- "establish_date": establish_date,
|
|
|
|
|
|
+ "establish_date": establish_dates,
|
|
"legal_person": legal_person,
|
|
"legal_person": legal_person,
|
|
"legal_person_caption": legal_person_caption,
|
|
"legal_person_caption": legal_person_caption,
|
|
"company_status": company_status,
|
|
"company_status": company_status,
|
|
"company_type": company_type,
|
|
"company_type": company_type,
|
|
"authority": authority,
|
|
"authority": authority,
|
|
- "issue_date": issue_date,
|
|
|
|
|
|
+ "issue_date": issue_dates,
|
|
"operation_startdate": operation_startdate,
|
|
"operation_startdate": operation_startdate,
|
|
"operation_enddate": operation_enddate,
|
|
"operation_enddate": operation_enddate,
|
|
"capital": capital,
|
|
"capital": capital,
|
|
@@ -134,12 +149,7 @@ L:
|
|
"company_phone": company_phone,
|
|
"company_phone": company_phone,
|
|
"company_email": company_email,
|
|
"company_email": company_email,
|
|
}
|
|
}
|
|
- ok := ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
|
- if ok {
|
|
|
|
- log.Println("es存入成功")
|
|
|
|
- } else {
|
|
|
|
- log.Println("es存入失败!!!!", company_name)
|
|
|
|
- }
|
|
|
|
|
|
+ Ch <- data
|
|
}
|
|
}
|
|
}(v)
|
|
}(v)
|
|
}
|
|
}
|
|
@@ -152,6 +162,7 @@ L:
|
|
log.Println("cur idx ", total)
|
|
log.Println("cur idx ", total)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ ChEnd <- true
|
|
log.Println("主体库全量任务结束")
|
|
log.Println("主体库全量任务结束")
|
|
}
|
|
}
|
|
|
|
|
|
@@ -159,7 +170,14 @@ func getPingAn() {
|
|
sess := ent_util.QyxyMgo.GetMgoConn()
|
|
sess := ent_util.QyxyMgo.GetMgoConn()
|
|
defer ent_util.QyxyMgo.DestoryMongoConn(sess)
|
|
defer ent_util.QyxyMgo.DestoryMongoConn(sess)
|
|
q := map[string]interface{}{}
|
|
q := map[string]interface{}{}
|
|
- it := sess.DB("mixdata").C("qyxy_std").Find(&q).Sort("_id").Iter()
|
|
|
|
|
|
+ it := sess.DB("mixdata").C("qyxy_std").Find(&q).Select(map[string]interface{}{
|
|
|
|
+ "_id": 1, "use_flag": 1, "is_history": 1, "company_type": 1, "company_name": 1, "company_area": 1,
|
|
|
|
+ "company_city": 1, "company_district": 1, "company_address": 1, "company_code": 1, "credit_no": 1,
|
|
|
|
+ "org_code": 1, "tax_code": 1, "establish_date": 1, "legal_person": 1, "legal_person_caption": 1, "company_status": 1,
|
|
|
|
+ "authority": 1, "issue_date": 1, "operation_startdate": 1, "operation_enddate": 1, "capital": 1, "business_scope": 1,
|
|
|
|
+ "comeintime": 1, "updatetime": 1, "legal_person_type": 1, "real_capital": 1, "en_name": 1, "list_code": 1,
|
|
|
|
+ "employee_no": 1, "website": 1, "company_phone": 1, "company_email": 1,
|
|
|
|
+ }).Iter()
|
|
pool := make(chan bool, 10)
|
|
pool := make(chan bool, 10)
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
total := 0
|
|
total := 0
|
|
@@ -181,8 +199,8 @@ func getPingAn() {
|
|
if use_flag > 5 || is_history != 0 || company_name == "" || company_type == "个体工商户" {
|
|
if use_flag > 5 || is_history != 0 || company_name == "" || company_type == "个体工商户" {
|
|
return
|
|
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)
|
|
|
|
|
|
+ query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println(err)
|
|
log.Println(err)
|
|
}
|
|
}
|
|
@@ -203,8 +221,7 @@ func getPingAn() {
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, 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_id := qu.ObjToString(tmp["_id"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
@@ -215,7 +232,6 @@ func getPingAn() {
|
|
legal_person := qu.ObjToString(tmp["legal_person"])
|
|
legal_person := qu.ObjToString(tmp["legal_person"])
|
|
legal_person_caption := qu.ObjToString(tmp["legal_person_caption"])
|
|
legal_person_caption := qu.ObjToString(tmp["legal_person_caption"])
|
|
company_status := qu.ObjToString(tmp["company_status"])
|
|
company_status := qu.ObjToString(tmp["company_status"])
|
|
- company_type := qu.ObjToString(tmp["company_type"])
|
|
|
|
authority := qu.ObjToString(tmp["authority"])
|
|
authority := qu.ObjToString(tmp["authority"])
|
|
issue_date := qu.Int64All(tmp["issue_date"])
|
|
issue_date := qu.Int64All(tmp["issue_date"])
|
|
operation_startdate := qu.ObjToString(tmp["operation_startdate"])
|
|
operation_startdate := qu.ObjToString(tmp["operation_startdate"])
|
|
@@ -272,7 +288,7 @@ func getPingAn() {
|
|
"company_phone": company_phone,
|
|
"company_phone": company_phone,
|
|
"company_email": company_email,
|
|
"company_email": company_email,
|
|
}
|
|
}
|
|
- ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
|
|
|
+ Ch <- data
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -280,7 +296,7 @@ func getPingAn() {
|
|
tmp = make(map[string]interface{})
|
|
tmp = make(map[string]interface{})
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- log.Println("is over ~ ", total)
|
|
|
|
|
|
+ log.Println("pingan is over ~ ", total)
|
|
}
|
|
}
|
|
|
|
|
|
func getTQ() {
|
|
func getTQ() {
|
|
@@ -289,7 +305,14 @@ func getTQ() {
|
|
sess := ent_util.SpiMgo.GetMgoConn()
|
|
sess := ent_util.SpiMgo.GetMgoConn()
|
|
defer ent_util.SpiMgo.DestoryMongoConn(sess)
|
|
defer ent_util.SpiMgo.DestoryMongoConn(sess)
|
|
q := map[string]interface{}{}
|
|
q := map[string]interface{}{}
|
|
- it := sess.DB("mixdata").C(db).Find(&q).Sort("_id").Iter()
|
|
|
|
|
|
+ it := sess.DB("mixdata").C(db).Find(&q).Select(map[string]interface{}{
|
|
|
|
+ "_id": 1, "use_flag": 1, "is_history": 1, "company_type": 1, "company_name": 1, "company_area": 1,
|
|
|
|
+ "company_city": 1, "company_district": 1, "company_address": 1, "company_code": 1, "credit_no": 1,
|
|
|
|
+ "org_code": 1, "tax_code": 1, "establish_date": 1, "legal_person": 1, "legal_person_caption": 1, "company_status": 1,
|
|
|
|
+ "authority": 1, "issue_date": 1, "operation_startdate": 1, "operation_enddate": 1, "capital": 1, "business_scope": 1,
|
|
|
|
+ "comeintime": 1, "updatetime": 1, "legal_person_type": 1, "real_capital": 1, "en_name": 1, "list_code": 1,
|
|
|
|
+ "employee_no": 1, "website": 1, "company_phone": 1, "company_email": 1,
|
|
|
|
+ }).Iter()
|
|
pool := make(chan bool, 10)
|
|
pool := make(chan bool, 10)
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
total := 0
|
|
total := 0
|
|
@@ -309,8 +332,8 @@ func getTQ() {
|
|
if use_flag > 5 || company_name == "" {
|
|
if use_flag > 5 || company_name == "" {
|
|
return
|
|
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)
|
|
|
|
|
|
+ query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println(err)
|
|
log.Println(err)
|
|
}
|
|
}
|
|
@@ -331,8 +354,7 @@ func getTQ() {
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, 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_id := qu.ObjToString(tmp["_id"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
@@ -400,7 +422,7 @@ func getTQ() {
|
|
"company_phone": company_phone,
|
|
"company_phone": company_phone,
|
|
"company_email": company_email,
|
|
"company_email": company_email,
|
|
}
|
|
}
|
|
- ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
|
|
|
+ Ch <- data
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -408,7 +430,7 @@ func getTQ() {
|
|
tmp = make(map[string]interface{})
|
|
tmp = make(map[string]interface{})
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- log.Println("is over ~ ", total)
|
|
|
|
|
|
+ log.Println("teqi is over ~ ", total)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -435,8 +457,8 @@ func getMK() {
|
|
if company_name == "" {
|
|
if company_name == "" {
|
|
return
|
|
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)
|
|
|
|
|
|
+ query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Println(err)
|
|
log.Println(err)
|
|
}
|
|
}
|
|
@@ -457,11 +479,7 @@ func getMK() {
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
city := qu.ObjToString(tmp["company_city"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
district := qu.ObjToString(tmp["company_district"])
|
|
area_code, city_code, district_code := ent_util.CalculateRegionCode(area, city, 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_id := qu.ObjToString(tmp["_id"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_address := qu.ObjToString(tmp["company_address"])
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_label, company_label_str := getCompanyLabel(company_name)
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
company_code := qu.ObjToString(tmp["company_code"])
|
|
@@ -529,7 +547,7 @@ func getMK() {
|
|
"company_phone": company_phone,
|
|
"company_phone": company_phone,
|
|
"company_email": company_email,
|
|
"company_email": company_email,
|
|
}
|
|
}
|
|
- ent_util.EsClinet.Save("ent_info", "", data)
|
|
|
|
|
|
+ Ch <- data
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -537,142 +555,63 @@ func getMK() {
|
|
tmp = make(map[string]interface{})
|
|
tmp = make(map[string]interface{})
|
|
}
|
|
}
|
|
wg.Wait()
|
|
wg.Wait()
|
|
- log.Println("is over ~ ", total)
|
|
|
|
|
|
+ log.Println("make is over ~ ", total)
|
|
}
|
|
}
|
|
|
|
|
|
func getCompanyLabel(name string) ([]uint64, string) {
|
|
func getCompanyLabel(name string) ([]uint64, string) {
|
|
name = strings.TrimSpace(RegClean.ReplaceAllString(name, ""))
|
|
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
|
|
|
|
|
|
+ buyerclassArr, tag_subinformationArr, property_formArr := []string{}, []string{}, []string{}
|
|
|
|
+ bitMapCodeArr, bitMapStrArr := []uint64{}, []string{}
|
|
|
|
+ data := ent_util.ExtMgo.FindOne("label", map[string]interface{}{"name": name})
|
|
|
|
+ if data != nil && len(data) > 0 {
|
|
|
|
+ if data["buyerclass"] != nil {
|
|
|
|
+ if buyerclass1, oks := data["buyerclass"].(map[string]string); oks {
|
|
|
|
+ for k, _ := range buyerclass1 {
|
|
|
|
+ buyerclassArr = append(buyerclassArr, k)
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
- 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
|
|
|
|
|
|
+ } else if buyerclass1, oks := data["buyerclass"].(map[string]interface{}); oks {
|
|
|
|
+ for k, _ := range buyerclass1 {
|
|
|
|
+ buyerclassArr = append(buyerclassArr, k)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- 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
|
|
|
|
|
|
+ if data["tag_subinformation"] != nil {
|
|
|
|
+ if tag_subinformation1, oks := data["tag_subinformation"].(map[string]string); oks {
|
|
|
|
+ for k, _ := range tag_subinformation1 {
|
|
|
|
+ tag_subinformationArr = append(tag_subinformationArr, k)
|
|
|
|
+ }
|
|
|
|
+ } else if tag_subinformation1, oks := data["tag_subinformation"].(map[string]interface{}); oks {
|
|
|
|
+ for k, _ := range tag_subinformation1 {
|
|
|
|
+ tag_subinformationArr = append(tag_subinformationArr, k)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } 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
|
|
|
|
|
|
+ if data["property_form"] != nil {
|
|
|
|
+ if property_form1, oks := data["property_form"].(map[string]string); oks {
|
|
|
|
+ for k, _ := range property_form1 {
|
|
|
|
+ property_formArr = append(property_formArr, k)
|
|
|
|
+ }
|
|
|
|
+ } else if property_form1, oks := data["property_form"].(map[string]interface{}); oks {
|
|
|
|
+ for k, _ := range property_form1 {
|
|
|
|
+ property_formArr = append(property_formArr, k)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- log.Println("sql2", sql2)
|
|
|
|
}
|
|
}
|
|
- if len(subMap) > 0 {
|
|
|
|
- for s, _ := range subMap {
|
|
|
|
|
|
+ if len(tag_subinformationArr) > 0 {
|
|
|
|
+ for _, s := range tag_subinformationArr {
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode2[s]))
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode2[s]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode2[s]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode2[s]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if len(propertyFormArr) > 0 {
|
|
|
|
- for _, p := range propertyFormArr {
|
|
|
|
|
|
+ if len(property_formArr) > 0 {
|
|
|
|
+ for _, p := range property_formArr {
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode3[p]))
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode3[p]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode3[p]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode3[p]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if len(buyerClassArr) > 0 {
|
|
|
|
- for _, b := range propertyFormArr {
|
|
|
|
|
|
+ if len(buyerclassArr) > 0 {
|
|
|
|
+ for _, b := range buyerclassArr {
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode1[b]))
|
|
bitMapStrArr = append(bitMapStrArr, strconv.Itoa(ent_util.BitMapCode1[b]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode1[b]))
|
|
bitMapCodeArr = append(bitMapCodeArr, uint64(ent_util.BitMapCode1[b]))
|
|
}
|
|
}
|
|
@@ -682,3 +621,31 @@ func getCompanyLabel(name string) ([]uint64, string) {
|
|
}
|
|
}
|
|
return bitMapCodeArr, strings.Join(bitMapStrArr, ",")
|
|
return bitMapCodeArr, strings.Join(bitMapStrArr, ",")
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func Save() {
|
|
|
|
+ arr := []map[string]interface{}{}
|
|
|
|
+L:
|
|
|
|
+ for {
|
|
|
|
+ select {
|
|
|
|
+ case data := <-Ch:
|
|
|
|
+ arr = append(arr, data)
|
|
|
|
+ if len(arr) > 99 {
|
|
|
|
+ func(ao *[]map[string]interface{}) {
|
|
|
|
+ ent_util.EsClinet.BulkSave("ent_info", "", ao, false)
|
|
|
|
+ }(&arr)
|
|
|
|
+ arr = []map[string]interface{}{}
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ select {
|
|
|
|
+ case <-ChEnd:
|
|
|
|
+ break L
|
|
|
|
+ case <-time.After(time.Millisecond * 10):
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(arr) > 0 {
|
|
|
|
+ func(ao *[]map[string]interface{}) {
|
|
|
|
+ ent_util.EsClinet.BulkSave("ent_info", "", ao, false)
|
|
|
|
+ }(&arr)
|
|
|
|
+ }
|
|
|
|
+}
|