|
@@ -315,35 +315,56 @@ func syncJyData(source, tid, pid string) int {
|
|
wg := &sync.WaitGroup{}
|
|
wg := &sync.WaitGroup{}
|
|
|
|
|
|
var q bson.M
|
|
var q bson.M
|
|
|
|
+ count := 0
|
|
if pid == "650c310bc88c29b90a54b1c4" {
|
|
if pid == "650c310bc88c29b90a54b1c4" {
|
|
// 联通中标数据 特殊处理
|
|
// 联通中标数据 特殊处理
|
|
q = bson.M{"s_grouptaskid": tid, "is_push": 1}
|
|
q = bson.M{"s_grouptaskid": tid, "is_push": 1}
|
|
|
|
+ query := sess.DB(util.Mgo.DbName).C(source).Find(q).Select(nil).Iter()
|
|
|
|
+ for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
|
|
+ ch <- true
|
|
|
|
+ wg.Add(1)
|
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
|
+ defer func() {
|
|
|
|
+ <-ch
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
+ info := tmp["v_baseinfo"].(map[string]interface{})
|
|
|
|
+ info["createtime"] = time.Now().Unix()
|
|
|
|
+ if qu.ObjToString(info["id"]) == "" {
|
|
|
|
+ info["id"] = tmp["id"]
|
|
|
|
+ }
|
|
|
|
+ info["isOptimization"] = 1
|
|
|
|
+ util.MgoJy.Save(util.JYPushColl, info)
|
|
|
|
+ util.Mgo.UpdateById(source, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
+
|
|
|
|
+ }(tmp)
|
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
|
+ }
|
|
|
|
+ wg.Wait()
|
|
} else {
|
|
} else {
|
|
q = bson.M{"s_grouptaskid": tid, "sendflag": nil}
|
|
q = bson.M{"s_grouptaskid": tid, "sendflag": nil}
|
|
- }
|
|
|
|
- query := sess.DB(util.Mgo.DbName).C(source).Find(q).Select(nil).Iter()
|
|
|
|
- count := 0
|
|
|
|
- for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
|
|
- ch <- true
|
|
|
|
- wg.Add(1)
|
|
|
|
- go func(tmp map[string]interface{}) {
|
|
|
|
- defer func() {
|
|
|
|
- <-ch
|
|
|
|
- wg.Done()
|
|
|
|
- }()
|
|
|
|
- info := tmp["v_baseinfo"].(map[string]interface{})
|
|
|
|
- info["createtime"] = time.Now().Unix()
|
|
|
|
- if qu.ObjToString(info["id"]) == "" {
|
|
|
|
- info["id"] = tmp["id"]
|
|
|
|
- }
|
|
|
|
- info["isOptimization"] = 1
|
|
|
|
- util.MgoJy.Save(util.JYPushColl, info)
|
|
|
|
- util.Mgo.UpdateById(source, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
|
|
+ query := sess.DB(util.Mgo.DbName).C(source).Find(q).Select(nil).Iter()
|
|
|
|
+ for tmp := make(map[string]interface{}); query.Next(&tmp); count++ {
|
|
|
|
+ ch <- true
|
|
|
|
+ wg.Add(1)
|
|
|
|
+ go func(tmp map[string]interface{}) {
|
|
|
|
+ defer func() {
|
|
|
|
+ <-ch
|
|
|
|
+ wg.Done()
|
|
|
|
+ }()
|
|
|
|
+ info := tmp["v_baseinfo"].(map[string]interface{})
|
|
|
|
+ info["createtime"] = time.Now().Unix()
|
|
|
|
+ if qu.ObjToString(info["id"]) == "" {
|
|
|
|
+ info["id"] = tmp["id"]
|
|
|
|
+ }
|
|
|
|
+ util.MgoJy.Save(util.JYPushColl, info)
|
|
|
|
+ util.Mgo.UpdateById(source, tmp["_id"], bson.M{"$set": bson.M{"sendflag": true}})
|
|
|
|
|
|
- }(tmp)
|
|
|
|
- tmp = make(map[string]interface{})
|
|
|
|
|
|
+ }(tmp)
|
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
|
+ }
|
|
|
|
+ wg.Wait()
|
|
}
|
|
}
|
|
- wg.Wait()
|
|
|
|
qu.Debug(fmt.Sprintf("推送数据成功,推送成功: %d条", count))
|
|
qu.Debug(fmt.Sprintf("推送数据成功,推送成功: %d条", count))
|
|
return count
|
|
return count
|
|
}
|
|
}
|