|
@@ -230,7 +230,11 @@ func SaveErrorData(modifyuser string, pd map[string]interface{}, err interface{}
|
|
|
set := map[string]interface{}{
|
|
|
"$set": pd,
|
|
|
}
|
|
|
- Mgo.Update("regatherdata", "spider", "spider", query, set, true, false)
|
|
|
+ update := []map[string]interface{}{}
|
|
|
+ update = append(update, query)
|
|
|
+ update = append(update, set)
|
|
|
+ UpdataMgoCache <- update
|
|
|
+ //Mgo.Update("regatherdata", "spider", "spider", query, set, true, false)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -430,3 +434,40 @@ func UpdateHighListDataByCode(code string) {
|
|
|
}
|
|
|
Mgo.Update("spider_highlistdata", query, set, false, true)
|
|
|
}
|
|
|
+
|
|
|
+//批量更新错误数据
|
|
|
+func UpdataErrDataMgo() {
|
|
|
+ fmt.Println("Save...")
|
|
|
+ arru := make([][]map[string]interface{}, 50)
|
|
|
+ indexu := 0
|
|
|
+ for {
|
|
|
+ select {
|
|
|
+ case v := <-UpdataMgoCache:
|
|
|
+ arru[indexu] = v
|
|
|
+ indexu++
|
|
|
+ if indexu == 50 {
|
|
|
+ SP <- true
|
|
|
+ go func(arru [][]map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-SP
|
|
|
+ }()
|
|
|
+ Mgo.UpSertBulk("regatherdata", arru...)
|
|
|
+ }(arru)
|
|
|
+ arru = make([][]map[string]interface{}, 50)
|
|
|
+ indexu = 0
|
|
|
+ }
|
|
|
+ case <-time.After(5 * time.Second):
|
|
|
+ if indexu > 0 {
|
|
|
+ SP <- true
|
|
|
+ go func(arru [][]map[string]interface{}) {
|
|
|
+ defer func() {
|
|
|
+ <-SP
|
|
|
+ }()
|
|
|
+ Mgo.UpSertBulk("regatherdata", arru...)
|
|
|
+ }(arru[:indexu])
|
|
|
+ arru = make([][]map[string]interface{}, 200)
|
|
|
+ indexu = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|