|
@@ -2,7 +2,6 @@ package main
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
- "github.com/gogf/gf/v2/util/gconv"
|
|
|
"github.com/robfig/cron"
|
|
|
"sync"
|
|
|
)
|
|
@@ -34,20 +33,26 @@ func main() {
|
|
|
func tmp() {
|
|
|
sess := MgoPro.GetMgoConn()
|
|
|
defer MgoPro.DestoryMongoConn(sess)
|
|
|
- ch := make(chan bool, 20)
|
|
|
+ ch := make(chan bool, 1)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
- lock := &sync.Mutex{}
|
|
|
+ //lock := &sync.Mutex{}
|
|
|
query := map[string]interface{}{
|
|
|
//"project_bidstatus": 4,
|
|
|
//"_id": map[string]interface{}{
|
|
|
// "$gte": mongodb.StringTOBsonId("66213b290f6ba3eb160617ad"),
|
|
|
//},
|
|
|
+ //"update_time": map[string]interface{}{
|
|
|
+ // "$lt": 1714959573,
|
|
|
+ //},
|
|
|
+ //"_id": mongodb.StringTOBsonId("6630eae76f6c86a3962f3a07"),
|
|
|
+ "repeat": true,
|
|
|
}
|
|
|
- count := MgoPro.Count("projectset_wy", query)
|
|
|
+ repeat := map[string]bool{}
|
|
|
+ count := MgoPro.Count("projectset_wy_back", query)
|
|
|
fmt.Println("count:", count)
|
|
|
- it := sess.DB(MgoPro.DbName).C("projectset_wy").Find(&query).Iter()
|
|
|
+ it := sess.DB(MgoPro.DbName).C("projectset_wy_back").Find(&query).Iter()
|
|
|
n := 0
|
|
|
- arr := [][]map[string]interface{}{}
|
|
|
+ //arr := []map[string]interface{}{}
|
|
|
for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
|
|
|
ch <- true
|
|
|
wg.Add(1)
|
|
@@ -56,41 +61,50 @@ func tmp() {
|
|
|
<-ch
|
|
|
wg.Done()
|
|
|
}()
|
|
|
- project_id := gconv.String(tmp["project_id"])
|
|
|
- data, _ := MgoB.FindById("bidding", project_id, map[string]interface{}{"buyerclass": 1})
|
|
|
- buyerclass := gconv.String((*data)["buyerclass"])
|
|
|
- update := []map[string]interface{}{
|
|
|
- {"_id": tmp["_id"]},
|
|
|
- }
|
|
|
- set := map[string]interface{}{
|
|
|
- "buyerclass": buyerclass,
|
|
|
- }
|
|
|
- //info_id := gconv.String(tmp["info_id"])
|
|
|
- //data, _ := MgoPro.FindById("projectset", info_id, map[string]interface{}{"bidstatus": 1})
|
|
|
- //if gconv.String((*data)["bidstatus"]) == "拟建" {
|
|
|
- // set["project_bidstatus"] = 4
|
|
|
+ //update := []map[string]interface{}{}
|
|
|
+ //project_id := gconv.String(tmp["project_id"])
|
|
|
+ //lock.Lock()
|
|
|
+ //if !repeat[project_id] {
|
|
|
+ // Es.DelById(Config.Es.Index, project_id)
|
|
|
+ // CkhTool.Exec(context.Background(), "ALTER TABLE information.transaction_info_copy DELETE WHERE project_id = ?", project_id)
|
|
|
+ // repeat[project_id] = true
|
|
|
+ //}
|
|
|
+ //lock.Unlock()
|
|
|
+ //err, result := Es.GetById(Config.Es.Index, project_id)
|
|
|
+ //Es.DelById()
|
|
|
+ //if err != nil || len(result) == 0 {
|
|
|
+ // fmt.Println(project_id)
|
|
|
+ // update = append(update, map[string]interface{}{"_id": tmp["_id"]})
|
|
|
+ // update = append(update, map[string]interface{}{"$set": map[string]interface{}{"es": false}})
|
|
|
//} else {
|
|
|
- // return
|
|
|
+ // if gconv.Int(result["project_bidstatus"]) != 0 {
|
|
|
+ // fmt.Println("11", project_id)
|
|
|
+ // }
|
|
|
//}
|
|
|
- update = append(update, map[string]interface{}{"$set": set})
|
|
|
- //
|
|
|
- lock.Lock()
|
|
|
- arr = append(arr, update)
|
|
|
- if len(arr) > 500 {
|
|
|
- MgoPro.UpdateBulk("projectset_wy", arr...)
|
|
|
- arr = [][]map[string]interface{}{}
|
|
|
+ if MgoPro.Count("projectset_wy_back", map[string]interface{}{"project_id": tmp["project_id"]}) > 1 {
|
|
|
+ fmt.Println("project_id")
|
|
|
+ //update = append(update, map[string]interface{}{"_id": tmp["_id"]})
|
|
|
+ //update = append(update, map[string]interface{}{"$set": map[string]interface{}{"repeat": true}})
|
|
|
}
|
|
|
- lock.Unlock()
|
|
|
+ //if len(update) > 0 {
|
|
|
+ // lock.Lock()
|
|
|
+ // arr = append(arr, update)
|
|
|
+ // if len(arr) > 500 {
|
|
|
+ // MgoPro.UpdateBulk("projectset_wy_back", arr...)
|
|
|
+ // arr = [][]map[string]interface{}{}
|
|
|
+ // }
|
|
|
+ // lock.Unlock()
|
|
|
+ //}
|
|
|
}(tmp)
|
|
|
- if n%10000 == 0 {
|
|
|
+ if n%1000 == 0 {
|
|
|
fmt.Println("current:", n)
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|
|
|
}
|
|
|
wg.Wait()
|
|
|
- if len(arr) > 0 {
|
|
|
- MgoPro.UpdateBulk("projectset_wy", arr...)
|
|
|
- arr = [][]map[string]interface{}{}
|
|
|
- }
|
|
|
- fmt.Println("迁移结束...")
|
|
|
+ //if len(arr) > 0 {
|
|
|
+ // MgoPro.SaveBulk("projectset_wy_tmp2", arr...)
|
|
|
+ // arr = []map[string]interface{}{}
|
|
|
+ //}
|
|
|
+ fmt.Println("迁移结束...", len(repeat))
|
|
|
}
|