main.go 2.2 KB

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