|
@@ -4,6 +4,8 @@ import (
|
|
|
"context"
|
|
|
"data_ent_wuye/ent_contact"
|
|
|
"data_ent_wuye/ent_util"
|
|
|
+ "database/sql"
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
@@ -25,13 +27,14 @@ var (
|
|
|
|
|
|
func LegalFull() {
|
|
|
//从现有主题库...直接获取
|
|
|
- // getZhuTi()
|
|
|
+ // InjectTidbFull()
|
|
|
+
|
|
|
+ //马克信息···
|
|
|
+ // getMK()
|
|
|
+ //特企
|
|
|
+ // getTQ()
|
|
|
//凭安全量企业···查到数据告知通讯录
|
|
|
getPingAn()
|
|
|
- //特企
|
|
|
- getTQ()
|
|
|
- //马克信息···
|
|
|
- getMK()
|
|
|
}
|
|
|
|
|
|
func getZhuTi() {
|
|
@@ -49,7 +52,7 @@ L:
|
|
|
if len(*dataArr) == 0 {
|
|
|
break
|
|
|
}
|
|
|
- pool := make(chan bool, 10)
|
|
|
+ pool := make(chan bool, 20)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
for _, v := range *dataArr {
|
|
|
pool <- true
|
|
@@ -69,11 +72,15 @@ L:
|
|
|
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)}, ""
|
|
|
+ company_label := []uint64{uint64(0)}
|
|
|
+ // company_label_str := ""
|
|
|
qyxy_info := GetQyxyInfo(company_name)
|
|
|
+ log.Println("111", company_name)
|
|
|
if qyxy_info != nil {
|
|
|
- company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
+ // company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
+ company_label, _ = getCompanyLabel(company_name)
|
|
|
}
|
|
|
+ log.Println("222", 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"])
|
|
@@ -109,47 +116,48 @@ L:
|
|
|
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(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
|
+ query := `INSERT INTO information.ent_info_copy (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_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)
|
|
|
+ log.Println("333", company_name)
|
|
|
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_dates,
|
|
|
- "legal_person": legal_person,
|
|
|
- "legal_person_caption": legal_person_caption,
|
|
|
- "company_status": company_status,
|
|
|
- "company_type": company_type,
|
|
|
- "authority": authority,
|
|
|
- "issue_date": issue_dates,
|
|
|
- "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,
|
|
|
- }
|
|
|
- Ch <- data
|
|
|
+ // 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_dates,
|
|
|
+ // "legal_person": legal_person,
|
|
|
+ // "legal_person_caption": legal_person_caption,
|
|
|
+ // "company_status": company_status,
|
|
|
+ // "company_type": company_type,
|
|
|
+ // "authority": authority,
|
|
|
+ // "issue_date": issue_dates,
|
|
|
+ // "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,
|
|
|
+ // }
|
|
|
+ // Ch <- data
|
|
|
}
|
|
|
}(v)
|
|
|
}
|
|
@@ -166,21 +174,144 @@ L:
|
|
|
log.Println("主体库全量任务结束")
|
|
|
}
|
|
|
|
|
|
+func InjectTidbFull() {
|
|
|
+ log.Println("主体库全量任务开始")
|
|
|
+ pool := make(chan bool, 10) //控制线程数
|
|
|
+ wg := &sync.WaitGroup{}
|
|
|
+ finalId := 0
|
|
|
+ lastInfo := ent_util.MysqlGlobalTool.SelectBySql(fmt.Sprintf(`SELECT id FROM %s where createtime < "2024-04-19 00:00:00" ORDER BY id DESC LIMIT 1`, "dws_f_ent_baseinfo"))
|
|
|
+ if len(*lastInfo) > 0 {
|
|
|
+ finalId = qu.IntAll((*lastInfo)[0]["id"])
|
|
|
+ }
|
|
|
+ log.Println("last id", finalId)
|
|
|
+ lastid, count := 0, 0
|
|
|
+ for {
|
|
|
+ log.Println("重新查询,lastid---", lastid)
|
|
|
+ q := fmt.Sprintf(`SELECT id,name_id,name,company_id,address,area_code,city_code,district_code FROM %s WHERE id > %d and createtime < "2024-04-19 00:00:00" ORDER BY id ASC limit 10000`, "dws_f_ent_baseinfo", lastid)
|
|
|
+ var stmtOut *sql.Stmt
|
|
|
+ var tx *sql.Tx
|
|
|
+ var err error
|
|
|
+ if tx == nil {
|
|
|
+ stmtOut, err = ent_util.MysqlGlobalTool.DB.Prepare(q)
|
|
|
+ } else {
|
|
|
+ stmtOut, err = tx.Prepare(q)
|
|
|
+ }
|
|
|
+ rows, err := stmtOut.Query()
|
|
|
+ if err != nil {
|
|
|
+ log.Println("err : ", err)
|
|
|
+ }
|
|
|
+ columns, err := rows.Columns()
|
|
|
+ if lastid >= finalId {
|
|
|
+ log.Println("is over ...", count)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ for rows.Next() {
|
|
|
+ scanArgs := make([]interface{}, len(columns))
|
|
|
+ values := make([]interface{}, len(columns))
|
|
|
+ ret := make(map[string]interface{})
|
|
|
+ for k := range values {
|
|
|
+ scanArgs[k] = &values[k]
|
|
|
+ }
|
|
|
+ err = rows.Scan(scanArgs...)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("---", err)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ for i, col := range values {
|
|
|
+ if v, ok := col.([]uint8); ok {
|
|
|
+ ret[columns[i]] = string(v)
|
|
|
+ } else {
|
|
|
+ ret[columns[i]] = col
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lastid = qu.IntAll(ret["id"])
|
|
|
+ count++
|
|
|
+ if count%5000 == 0 {
|
|
|
+ log.Println("cur index", count, lastid)
|
|
|
+ }
|
|
|
+ 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 := []uint64{uint64(0)}
|
|
|
+ // company_label_str := ""
|
|
|
+ qyxy_info := GetQyxyInfo(company_name)
|
|
|
+ if qyxy_info != nil {
|
|
|
+ // company_label, company_label_str = getCompanyLabel(company_name)
|
|
|
+ company_label, _ = 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.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_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"])
|
|
|
+ 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_copy (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_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 {
|
|
|
+ log.Println(err, "clickhouse存入失败", company_name)
|
|
|
+ }
|
|
|
+ }(ret)
|
|
|
+ ret = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ _ = rows.Close()
|
|
|
+ stmtOut.Close()
|
|
|
+ wg.Wait()
|
|
|
+ }
|
|
|
+ log.Println("is over ...")
|
|
|
+}
|
|
|
+
|
|
|
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).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)
|
|
|
+ it := sess.DB("mixdata").C("qyxy_std").Find(&q).Sort("-_id").Iter()
|
|
|
+ pool := make(chan bool, 20)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
total := 0
|
|
|
+ ctx := context.Background()
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
if total%1000 == 0 {
|
|
|
log.Println("cur index ", total)
|
|
@@ -200,7 +331,7 @@ func getPingAn() {
|
|
|
return
|
|
|
}
|
|
|
query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
- rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(ctx, query, company_name)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
}
|
|
@@ -305,17 +436,11 @@ func getTQ() {
|
|
|
sess := ent_util.SpiMgo.GetMgoConn()
|
|
|
defer ent_util.SpiMgo.DestoryMongoConn(sess)
|
|
|
q := map[string]interface{}{}
|
|
|
- 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()
|
|
|
+ it := sess.DB("mixdata").C(db).Find(&q).Iter()
|
|
|
pool := make(chan bool, 10)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
total := 0
|
|
|
+ ctx := context.Background()
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
if total%1000 == 0 {
|
|
|
log.Println("cur index ", total)
|
|
@@ -333,7 +458,7 @@ func getTQ() {
|
|
|
return
|
|
|
}
|
|
|
query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
- rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(ctx, query, company_name)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
}
|
|
@@ -438,8 +563,9 @@ 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()
|
|
|
+ it := sess.DB("mixdata").C("qyxy_xzh").Find(&q).Iter()
|
|
|
pool := make(chan bool, 10)
|
|
|
+ ctx := context.Background()
|
|
|
wg := &sync.WaitGroup{}
|
|
|
total := 0
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
@@ -458,7 +584,7 @@ func getMK() {
|
|
|
return
|
|
|
}
|
|
|
query := `SELECT id FROM information.ent_info WHERE company_name = ?`
|
|
|
- rows, err := ent_util.ClickHouseConn.Query(context.Background(), query, company_name)
|
|
|
+ rows, err := ent_util.ClickHouseConn.Query(ctx, query, company_name)
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
}
|
|
@@ -548,18 +674,16 @@ func getMK() {
|
|
|
"company_email": company_email,
|
|
|
}
|
|
|
Ch <- data
|
|
|
- ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
|
+ go ent_contact.InjectContactPingAnInfo(id, tmp)
|
|
|
}
|
|
|
}
|
|
|
}(tmp)
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
- wg.Wait()
|
|
|
log.Println("make is over ~ ", total)
|
|
|
}
|
|
|
|
|
|
func getCompanyLabel(name string) ([]uint64, string) {
|
|
|
- name = strings.TrimSpace(RegClean.ReplaceAllString(name, ""))
|
|
|
buyerclassArr, tag_subinformationArr, property_formArr := []string{}, []string{}, []string{}
|
|
|
bitMapCodeArr, bitMapStrArr := []uint64{}, []string{}
|
|
|
data := ent_util.ExtMgo.FindOne("label", map[string]interface{}{"name": name})
|
|
@@ -649,3 +773,26 @@ L:
|
|
|
}(&arr)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func gettime() []map[string]int64 {
|
|
|
+ startTime := int64(1630914780)
|
|
|
+ endTime := int64(1714348067)
|
|
|
+ numSegments := 200
|
|
|
+
|
|
|
+ duration := endTime - startTime
|
|
|
+ segmentDuration := duration / int64(numSegments)
|
|
|
+
|
|
|
+ result := make([]map[string]int64, numSegments)
|
|
|
+
|
|
|
+ for i := 0; i < numSegments; i++ {
|
|
|
+ segmentStart := startTime + (int64(i) * segmentDuration)
|
|
|
+ segmentEnd := segmentStart + segmentDuration
|
|
|
+
|
|
|
+ segment := make(map[string]int64)
|
|
|
+ segment["start"] = segmentStart
|
|
|
+ segment["end"] = segmentEnd
|
|
|
+
|
|
|
+ result[i] = segment
|
|
|
+ }
|
|
|
+ return result
|
|
|
+}
|