123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package main
- import (
- . "app.yhyue.com/moapp/jybase/mongodb"
- "dataPrefer/db"
- . "dataPrefer/service"
- "encoding/json"
- "github.com/gogf/gf/v2/util/gconv"
- mu "jygit.jydev.jianyu360.cn/data_processing/common_utils/udp"
- "log"
- "net"
- "testing"
- )
- func TestSendNextNode(t *testing.T) {
- uc := mu.UdpClient{Local: ":880", BufSize: 1024}
- uc.Listen(ProcessUdpMsg)
- by, _ := json.Marshal(map[string]interface{}{
- "gtid": "1",
- "lteid": "2",
- "stype": "bidding",
- "key": "1-2-bidding",
- })
- addr := &net.UDPAddr{
- IP: net.ParseIP("127.0.0.1"),
- Port: 889,
- }
- log.Println(uc.WriteUdp(by, mu.OP_TYPE_DATA, addr)) //发送下节点
- }
- // 370435 201782
- func Tj() {
- sess := db.Mgo_Main.GetMgoConn()
- defer db.Mgo_Main.DestoryMongoConn(sess)
- it := sess.DB("qfw").C(Bidding_master).Find(nil).Select(map[string]interface{}{
- "old_id": 1,
- "id": 1,
- "site_toptype": 1,
- "old_site_toptype": 1,
- }).Iter()
- oldMap := map[string]int{}
- ooldMap := map[string]int{}
- newMap := map[string]int{}
- nnewMap := map[string]int{}
- update := 0
- index := 0
- for m := make(map[string]interface{}); it.Next(&m); {
- index++
- if index%5000 == 0 {
- log.Println("index", index)
- }
- if m["old_site_toptype"] == nil {
- m["old_site_toptype"] = m["site_toptype"]
- }
- if m["old_id"] == nil {
- m["old_id"] = m["id"]
- }
- oldMap[gconv.String(m["old_site_toptype"])] = oldMap[gconv.String(m["old_site_toptype"])] + 1
- newMap[gconv.String(m["site_toptype"])] = newMap[gconv.String(m["site_toptype"])] + 1
- if gconv.String(m["id"]) != gconv.String(m["old_id"]) {
- update++
- ooldMap[gconv.String(m["old_site_toptype"])] = ooldMap[gconv.String(m["old_site_toptype"])] + 1
- nnewMap[gconv.String(m["site_toptype"])] = nnewMap[gconv.String(m["site_toptype"])] + 1
- }
- m = make(map[string]interface{})
- }
- log.Println(oldMap)
- log.Println(newMap)
- log.Println(update)
- log.Println(ooldMap)
- log.Println(nnewMap)
- log.Println("over...", index)
- }
- func Hz() {
- sess := db.Mgo_Main.GetMgoConn()
- defer db.Mgo_Main.DestoryMongoConn(sess)
- it := sess.DB("qfw").C(Bidding_master).Find(map[string]interface{}{"mark": 1}).Select(map[string]interface{}{"id": 1}).Iter()
- index := 0
- for m := make(map[string]interface{}); it.Next(&m); {
- index++
- id := m["id"].(string)
- ids := []interface{}{StringTOBsonId(id)}
- data, _ := db.Mgo_Main.FindById(Bidding, id, `{"_id":1,"repeat_id":1}`)
- if repeatId, _ := (*data)["repeat_id"].(string); repeatId != "" && repeatId != id {
- ids = append(ids, StringTOBsonId(repeatId))
- datas, _ := db.Mgo_Extract.Find(Result_20220219, map[string]interface{}{
- "repeat_id": repeatId,
- }, nil, map[string]interface{}{
- "_id": 1,
- }, false, -1, -1)
- if datas != nil {
- for _, v := range *datas {
- ids = append(ids, v["_id"])
- }
- }
- datas, _ = db.Mgo_Extract.Find(Result_20220218, map[string]interface{}{
- "repeat_id": repeatId,
- }, nil, map[string]interface{}{
- "_id": 1,
- }, false, -1, -1)
- if datas != nil {
- for _, v := range *datas {
- ids = append(ids, v["_id"])
- }
- }
- }
- mp := map[string]bool{}
- newIds := []interface{}{}
- for _, v := range ids {
- if mp[BsonIdToSId(v)] {
- continue
- }
- mp[BsonIdToSId(v)] = true
- newIds = append(newIds, v)
- }
- newDatas, _ := db.Mgo_Main.Find(Bidding, map[string]interface{}{
- "_id": map[string]interface{}{"$in": newIds},
- }, nil, nil, false, -1, -1)
- for _, v := range *newDatas {
- v["bestid"] = id
- if BsonIdToSId(v["_id"]) == id {
- v["isbest"] = 1
- } else {
- v["isbest"] = 0
- }
- }
- db.Mgo_Main.SaveBulk("bidding_master_verify", *newDatas...)
- m = make(map[string]interface{})
- log.Println("index...", index)
- }
- }
|