main.go 2.3 KB

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