project.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package main
  2. import (
  3. "fmt"
  4. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  5. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
  6. "log"
  7. )
  8. func updateProject() {
  9. defer util.Catch()
  10. // 项目数据
  11. MgoP := &mongodb.MongodbSim{
  12. MongodbAddr: "172.17.4.85:27080",
  13. //MongodbAddr: "127.0.0.1:27080",
  14. Size: 10,
  15. DbName: "qfw",
  16. //Direct: true,
  17. }
  18. MgoP.InitPool()
  19. sess := MgoP.GetMgoConn()
  20. defer MgoP.DestoryMongoConn(sess)
  21. selected := map[string]interface{}{"projectname": 1, "tag_topinformation": 1, "pici": 1}
  22. it := sess.DB("qfw").C("projectset_20230904").Find(nil).Select(selected).Sort("pici").Iter()
  23. fmt.Println("updateProject 开始")
  24. count := 0
  25. for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
  26. if count%10000 == 0 {
  27. log.Println("current", count, tmp["projectname"])
  28. }
  29. if _, ok := tmp["tag_topinformation"]; ok {
  30. update := map[string]interface{}{
  31. "tag_topinformation": tmp["tag_topinformation"],
  32. }
  33. projectID := mongodb.BsonIdToSId(tmp["_id"])
  34. // 更新es
  35. updateEsPool <- []map[string]interface{}{
  36. {"_id": projectID},
  37. //{"_id": mongodb.BsonIdToSId(tmp["_id"])},
  38. update,
  39. }
  40. log.Println("aaaaaaaaaaaa", projectID, tmp["projectname"])
  41. //err := Es.UpdateDocument("projectset", projectID, update)
  42. //if err != nil {
  43. // log.Println(projectID, tmp["projectname"], "更新es 失败")
  44. //}
  45. }
  46. }
  47. log.Println("结束~~~~~~~~~~~~~")
  48. }