main.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package main
  2. import (
  3. "data_ai/extract"
  4. "data_ai/udp"
  5. "data_ai/ul"
  6. log "github.com/donnie4w/go-logger/logger"
  7. qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  8. "sync"
  9. "unicode/utf8"
  10. )
  11. func init() {
  12. ul.IsTool = false //是否工具
  13. ul.IsLocal = true //是否本地
  14. ul.IsFull = false //是否全量
  15. if ul.IsTool {
  16. ul.InitToolVar()
  17. } else {
  18. ul.InitGlobalVar()
  19. if !ul.IsFull {
  20. udp.InitProcessVar()
  21. }
  22. }
  23. ul.InitOss(ul.IsLocal)
  24. }
  25. func main() {
  26. if ul.IsTool {
  27. //tool.StartToolUpdateInfo()
  28. return
  29. }
  30. extract.TestSingleFieldInfo("bidding", "664a2a4066cf0db42a39fb02")
  31. lock := make(chan bool)
  32. <-lock
  33. }
  34. func test() {
  35. log.Debug("开始大模型验证内存数据···")
  36. q := map[string]interface{}{}
  37. pool_mgo := make(chan bool, 500)
  38. wg_mgo := &sync.WaitGroup{}
  39. sess := ul.SourceMgo.GetMgoConn()
  40. defer ul.SourceMgo.DestoryMongoConn(sess)
  41. total, isok := 0, 0
  42. it := sess.DB(ul.SourceMgo.DbName).C(ul.Bid_Name).Find(&q).Sort("-_id").Iter()
  43. for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
  44. if total%1000 == 0 {
  45. log.Debug("cur index ", total)
  46. }
  47. isok++
  48. pool_mgo <- true
  49. wg_mgo.Add(1)
  50. go func(tmp map[string]interface{}) {
  51. defer func() {
  52. <-pool_mgo
  53. wg_mgo.Done()
  54. }()
  55. detail := qu.ObjToString(tmp["detail"])
  56. if utf8.RuneCountInString(detail) < 100 {
  57. data := extract.ResolveInfo(tmp)
  58. if len(data) > 0 {
  59. tmp["ai_zhipu"] = data
  60. ul.SourceMgo.Save("zktest_1031", tmp)
  61. }
  62. }
  63. }(tmp)
  64. tmp = make(map[string]interface{})
  65. }
  66. wg_mgo.Wait()
  67. log.Debug("ai is over ...")
  68. }