bidding.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/wcc4869/common_utils/log"
  5. util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  6. "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
  7. )
  8. // dealBiddingNiJian 更新bidding ,owner 不为空的赋值给buyer
  9. //if toptype == "拟建"
  10. // if tmp["owner"] != nil
  11. // tmp["buyer"] = tmp["owner"]
  12. func dealBiddingNiJian() {
  13. defer util.Catch()
  14. sess := MgoB.GetMgoConn()
  15. defer MgoB.DestoryMongoConn(sess)
  16. where := map[string]interface{}{
  17. "comeintime": map[string]interface{}{
  18. "$lt": 1735228800,
  19. },
  20. "toptype": "拟建",
  21. }
  22. it := sess.DB("qfw").C("bidding").Find(where).Select(nil).Iter()
  23. fmt.Println("taskRun 开始")
  24. count := 0
  25. for tmp := make(map[string]interface{}); it.Next(&tmp); count++ {
  26. if count%10000 == 0 {
  27. log.Info("current", log.Int("count", count), log.Any("_id", tmp["_id"]))
  28. }
  29. if util.ObjToString(tmp["toptype"]) == "拟建" {
  30. update := map[string]interface{}{}
  31. esUpdate := map[string]interface{}{}
  32. biddingID := mongodb.BsonIdToSId(tmp["_id"])
  33. if tmp["owner"] != nil {
  34. update["buyer"] = tmp["owner"]
  35. esUpdate["buyer"] = tmp["owner"]
  36. }
  37. if len(update) > 0 {
  38. //更新mongo
  39. //MgoT.UpdateById("bidding", biddingID, map[string]interface{}{"$set": update})
  40. //更新MongoDB
  41. updatePool <- []map[string]interface{}{
  42. {"_id": tmp["_id"]},
  43. {"$set": update},
  44. }
  45. //2.es 项目 更新字段
  46. //err := Es.UpdateDocument("bidding", biddingID, update)
  47. //if err != nil && err.Error() != "Document not updated: noop" {
  48. // log.Info("bidding es update err", err, biddingID)
  49. //}
  50. //// 更新es
  51. //updateEsPool <- []map[string]interface{}{
  52. // {"_id": biddingID},
  53. // update,
  54. //}
  55. }
  56. // 更新Es 数据
  57. if len(esUpdate) > 0 {
  58. // 更新es
  59. updateEsPool <- []map[string]interface{}{
  60. {"_id": biddingID},
  61. esUpdate,
  62. }
  63. }
  64. }
  65. }
  66. log.Info("Run Over...Count:", log.Int("count", count))
  67. }