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", 2, "") flag.Parse() go ent_legal.Save() if *mode == 1 { //全量 log.Println("全量任务") // ent_contact.InjectContactTidbInfo() ent_legal.LegalFull() // projectT() select {} } else { //增量 // ent_legal.LegalAdd() 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) } } }