package main import ( "context" "data_ent_wuye/ent_contact" "data_ent_wuye/ent_legal" "data_ent_wuye/ent_util" "flag" "strings" "log" _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2" "github.com/google/uuid" "github.com/robfig/cron" ) func init() { ent_util.InitGlobalVar() } func main() { mode := flag.Int("m", 1, "") flag.Parse() if *mode == 1 { //全量 log.Println("全量任务") ent_legal.LegalFull() // projectT() } else { //增量 a := cron.New() a.AddFunc("0 0 20 * * ?", func() { ent_legal.LegalAdd() }) a.Start() select {} } } // 以下测试... func test() { //tidb全量 ent_contact.InjectContactTidbInfo() //凭安全量 info := ent_util.GetOneQyxyInfo("湖南德成大药房连锁有限公司鼎城淮阳店") name_id := uuid.New().String() name_id = strings.ReplaceAll(name_id, "-", "") ent_contact.InjectContactPingAnInfo(name_id, info) //马克全量 ent_contact.InjectContactMaKeInfo(name_id, map[string]interface{}{"phone": "手机号"}) } func test1() { query := `SELECT id,title FROM information.information WHERE id = '000fcf377e334bcc9380b921df93c268'` rows, err := ent_util.ClickHouseConn.Query(context.Background(), query) if err != nil { log.Println(err) } isok := 0 type TTT struct { title string id string } for rows.Next() { var T TTT if err := rows.Scan( &T.id, &T.title, ); err != nil { log.Fatal(err) } log.Println(T) //err := ent_util.ClickHouseConn.Exec(context.Background(), "alter table information.information UPDATE endtime = 1738252800 where id = ?", id) //if err != nil { // log.Debug("update err:", err) //} isok++ } log.Println("总计数量", isok) } func test2() { query := `ALTER TABLE information.information DELETE WHERE id='676470119ae64a18bab5d1fdb5f06bb3' ` query = `-- TRUNCATE TABLE information.information_copy;` err := ent_util.ClickHouseConn.Exec(context.Background(), query) if err != nil { log.Println(err) } rows, err := ent_util.ClickHouseConn.Query(context.Background(), "select bitmapToArray(tag_bitmap) tag_bitmap from information.information limit 10") if err != nil { log.Println(err) } for rows.Next() { var ( tag_bitmap []uint64 ) if err := rows.Scan( &tag_bitmap, ); err != nil { log.Println(err) } } } func projectT() { query := `SELECT project_id,project_name,business_type,property_form,subclass,area,city,district,buyer,create_time FROM information.transaction_info` rows, err := ent_util.ClickHouseConn.Query(context.Background(), query) if err != nil { log.Println(err) } count := 0 var ( project_id string project_name string business_type string property_form []string subclass []string area string city string district string create_time int64 buyer string ) for rows.Next() { if err := rows.Scan( &project_id, &project_name, &business_type, &property_form, &subclass, &area, &city, &district, &buyer, &create_time, ); err != nil { log.Println(err) } else { ent_util.EsClinet.UpdateNewDoc("transaction_info", "", map[string]interface{}{ "_id": project_id, "project_name": project_name, "business_type": business_type, "property_form": property_form, "subclass": subclass, "area": area, "city": city, "district": district, "create_time": create_time, "buyer": buyer, "winner": buyer, "agency": buyer, }) } count++ log.Println("count ", count) } }