main.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package main
  2. import (
  3. "context"
  4. "data_ent_wuye/ent_contact"
  5. "data_ent_wuye/ent_legal"
  6. "data_ent_wuye/ent_util"
  7. "flag"
  8. "strings"
  9. "log"
  10. _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
  11. "github.com/google/uuid"
  12. "github.com/robfig/cron"
  13. )
  14. func init() {
  15. ent_util.InitGlobalVar()
  16. }
  17. func main() {
  18. mode := flag.Int("m", 2, "")
  19. flag.Parse()
  20. go ent_legal.Save()
  21. if *mode == 1 {
  22. //全量
  23. log.Println("全量任务")
  24. // ent_contact.InjectContactTidbInfo()
  25. ent_legal.LegalFull()
  26. // projectT()
  27. select {}
  28. } else {
  29. //增量
  30. // ent_legal.LegalAdd()
  31. a := cron.New()
  32. a.AddFunc("0 0 20 * * ?", func() {
  33. ent_legal.LegalAdd()
  34. })
  35. a.Start()
  36. select {}
  37. }
  38. }
  39. // 以下测试...
  40. func test() {
  41. //tidb全量
  42. ent_contact.InjectContactTidbInfo()
  43. //凭安全量
  44. info := ent_util.GetOneQyxyInfo("湖南德成大药房连锁有限公司鼎城淮阳店")
  45. name_id := uuid.New().String()
  46. name_id = strings.ReplaceAll(name_id, "-", "")
  47. ent_contact.InjectContactPingAnInfo(name_id, info)
  48. //马克全量
  49. ent_contact.InjectContactMaKeInfo(name_id, map[string]interface{}{"phone": "手机号"})
  50. }
  51. func test1() {
  52. query := `SELECT id,title FROM information.information WHERE id = '000fcf377e334bcc9380b921df93c268'`
  53. rows, err := ent_util.ClickHouseConn.Query(context.Background(), query)
  54. if err != nil {
  55. log.Println(err)
  56. }
  57. isok := 0
  58. type TTT struct {
  59. title string
  60. id string
  61. }
  62. for rows.Next() {
  63. var T TTT
  64. if err := rows.Scan(
  65. &T.id,
  66. &T.title,
  67. ); err != nil {
  68. log.Fatal(err)
  69. }
  70. log.Println(T)
  71. //err := ent_util.ClickHouseConn.Exec(context.Background(), "alter table information.information UPDATE endtime = 1738252800 where id = ?", id)
  72. //if err != nil {
  73. // log.Debug("update err:", err)
  74. //}
  75. isok++
  76. }
  77. log.Println("总计数量", isok)
  78. }
  79. func test2() {
  80. query := `ALTER TABLE information.information DELETE WHERE id='676470119ae64a18bab5d1fdb5f06bb3' `
  81. query = `-- TRUNCATE TABLE information.information_copy;`
  82. err := ent_util.ClickHouseConn.Exec(context.Background(), query)
  83. if err != nil {
  84. log.Println(err)
  85. }
  86. rows, err := ent_util.ClickHouseConn.Query(context.Background(), "select bitmapToArray(tag_bitmap) tag_bitmap from information.information limit 10")
  87. if err != nil {
  88. log.Println(err)
  89. }
  90. for rows.Next() {
  91. var (
  92. tag_bitmap []uint64
  93. )
  94. if err := rows.Scan(
  95. &tag_bitmap,
  96. ); err != nil {
  97. log.Println(err)
  98. }
  99. }
  100. }