|
@@ -8,16 +8,37 @@ import (
|
|
mu "mfw/util"
|
|
mu "mfw/util"
|
|
"net"
|
|
"net"
|
|
"os"
|
|
"os"
|
|
- qu "qfw/common/src/qfw/util"
|
|
|
|
- "qfw/util"
|
|
|
|
|
|
+ qutil "qfw/util"
|
|
"strconv"
|
|
"strconv"
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+func getHistoryInfoId(keystatus string) bool {
|
|
|
|
+ //查询表最后一个id
|
|
|
|
+ qfw_sess := qfw_mgo.GetMgoConn()
|
|
|
|
+ defer qfw_mgo.DestoryMongoConn(qfw_sess)
|
|
|
|
+ q := map[string]interface{}{}
|
|
|
|
+ it_last := qfw_sess.DB(qfw_mgo.DbName).C(qfw_coll).Find(&q).Sort("-_id").Iter()
|
|
|
|
+ isRepeatStatus := false
|
|
|
|
+ for tmp := make(map[string]interface{}); it_last.Next(&tmp); {
|
|
|
|
+ is_repeat_status := qutil.IntAll(tmp[keystatus])
|
|
|
|
+ if is_repeat_status == 1 {
|
|
|
|
+ lteid = qutil.ObjToString(tmp["lteid"])
|
|
|
|
+ log.Println("查询的最后一个已标记的任务lteid:", lteid)
|
|
|
|
+ isRepeatStatus = true
|
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
|
+ break
|
|
|
|
+ } else {
|
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return isRepeatStatus
|
|
|
|
+}
|
|
|
|
+
|
|
// 历史判重
|
|
// 历史判重
|
|
func historyRepeat() {
|
|
func historyRepeat() {
|
|
- defer util.Catch()
|
|
|
|
|
|
+ defer qutil.Catch()
|
|
for {
|
|
for {
|
|
start := time.Now().Unix()
|
|
start := time.Now().Unix()
|
|
if gtid == "" {
|
|
if gtid == "" {
|
|
@@ -30,23 +51,12 @@ func historyRepeat() {
|
|
moveHistoryData(gtid, lteid)
|
|
moveHistoryData(gtid, lteid)
|
|
gtid = lteid //替换数据
|
|
gtid = lteid //替换数据
|
|
}
|
|
}
|
|
- //查询表最后一个id
|
|
|
|
- task_sess := task_mgo.GetMgoConn()
|
|
|
|
- defer task_mgo.DestoryMongoConn(task_sess)
|
|
|
|
- q := map[string]interface{}{}
|
|
|
|
- it_last := task_sess.DB(task_mgo.DbName).C(task_coll).Find(&q).Sort("-_id").Iter()
|
|
|
|
|
|
+ //查询历史数据id
|
|
isRepeatStatus := false
|
|
isRepeatStatus := false
|
|
- for tmp := make(map[string]interface{}); it_last.Next(&tmp); {
|
|
|
|
- is_repeat_status := util.IntAll(tmp["repeat_status"])
|
|
|
|
- if is_repeat_status == 1 {
|
|
|
|
- lteid = util.ObjToString(tmp["lteid"])
|
|
|
|
- log.Println("查询的最后一个已标记的任务lteid:", lteid)
|
|
|
|
- isRepeatStatus = true
|
|
|
|
- tmp = make(map[string]interface{})
|
|
|
|
- break
|
|
|
|
- } else {
|
|
|
|
- tmp = make(map[string]interface{})
|
|
|
|
- }
|
|
|
|
|
|
+ if !update_ai {
|
|
|
|
+ isRepeatStatus = getHistoryInfoId("repeat_status")
|
|
|
|
+ } else {
|
|
|
|
+ isRepeatStatus = getHistoryInfoId("repeat_status_ai")
|
|
}
|
|
}
|
|
if !isRepeatStatus {
|
|
if !isRepeatStatus {
|
|
log.Println("查询不到有标记的lteid数据......睡眠......")
|
|
log.Println("查询不到有标记的lteid数据......睡眠......")
|
|
@@ -64,8 +74,12 @@ func historyRepeat() {
|
|
defer data_mgo.DestoryMongoConn(sess)
|
|
defer data_mgo.DestoryMongoConn(sess)
|
|
between_time := time.Now().Unix() - (86400 * timingPubScope) //两年周期
|
|
between_time := time.Now().Unix() - (86400 * timingPubScope) //两年周期
|
|
|
|
|
|
|
|
+ ////临时-补齐差额
|
|
|
|
+ //log.Println("临时···66c58769b25c3e1deb79107c,66f617bdb25c3e1deb3ee999")
|
|
|
|
+ //gtid = "66c58769b25c3e1deb79107c"
|
|
|
|
+ //lteid = "66f617bdb25c3e1deb3ee999"
|
|
//开始判重
|
|
//开始判重
|
|
- q = map[string]interface{}{
|
|
|
|
|
|
+ q := map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"$gt": StringTOBsonId(gtid),
|
|
"$gt": StringTOBsonId(gtid),
|
|
"$lte": StringTOBsonId(lteid),
|
|
"$lte": StringTOBsonId(lteid),
|
|
@@ -78,24 +92,27 @@ func historyRepeat() {
|
|
dayArr := []map[string]interface{}{}
|
|
dayArr := []map[string]interface{}{}
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); num++ {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); num++ {
|
|
if num%10000 == 0 {
|
|
if num%10000 == 0 {
|
|
- log.Println("正序遍历:", num)
|
|
|
|
|
|
+ log.Println("正序遍历:", num, "~", oknum)
|
|
}
|
|
}
|
|
|
|
+ delete(tmp, "field_source")
|
|
|
|
+ delete(tmp, "regions_log")
|
|
|
|
+ delete(tmp, "kvtext")
|
|
//取-符合-发布时间X年内的数据
|
|
//取-符合-发布时间X年内的数据
|
|
- if util.IntAll(tmp["dataging"]) == 1 {
|
|
|
|
- pubtime := util.Int64All(tmp["publishtime"])
|
|
|
|
- if pubtime > 0 && pubtime >= between_time && qu.ObjToString(tmp["subtype"]) != "拟建" && qu.ObjToString(tmp["subtype"]) != "产权" &&
|
|
|
|
- qu.ObjToString(tmp["spidercode"]) != "sdxzbiddingsjzypc" {
|
|
|
|
|
|
+ if qutil.IntAll(tmp["dataging"]) == 1 {
|
|
|
|
+ pubtime := qutil.Int64All(tmp["publishtime"])
|
|
|
|
+ if pubtime > 0 && pubtime >= between_time && qutil.ObjToString(tmp["subtype"]) != "拟建" && qutil.ObjToString(tmp["subtype"]) != "产权" &&
|
|
|
|
+ qutil.ObjToString(tmp["spidercode"]) != "sdxzbiddingsjzypc" {
|
|
oknum++
|
|
oknum++
|
|
if deterTime == 0 {
|
|
if deterTime == 0 {
|
|
log.Println("找到第一条符合条件的数据")
|
|
log.Println("找到第一条符合条件的数据")
|
|
- deterTime = util.Int64All(tmp["publishtime"])
|
|
|
|
|
|
+ deterTime = qutil.Int64All(tmp["publishtime"])
|
|
dayArr = append(dayArr, tmp)
|
|
dayArr = append(dayArr, tmp)
|
|
} else {
|
|
} else {
|
|
if pubtime-deterTime > timingSpanDay*86400 {
|
|
if pubtime-deterTime > timingSpanDay*86400 {
|
|
//新数组重新构建,当前组数据加到全部组数据
|
|
//新数组重新构建,当前组数据加到全部组数据
|
|
pendAllArr = append(pendAllArr, dayArr)
|
|
pendAllArr = append(pendAllArr, dayArr)
|
|
dayArr = []map[string]interface{}{}
|
|
dayArr = []map[string]interface{}{}
|
|
- deterTime = util.Int64All(tmp["publishtime"])
|
|
|
|
|
|
+ deterTime = qutil.Int64All(tmp["publishtime"])
|
|
dayArr = append(dayArr, tmp)
|
|
dayArr = append(dayArr, tmp)
|
|
} else {
|
|
} else {
|
|
dayArr = append(dayArr, tmp)
|
|
dayArr = append(dayArr, tmp)
|
|
@@ -111,7 +128,7 @@ func historyRepeat() {
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"dataging": 0,
|
|
"dataging": 0,
|
|
- "history_updatetime": util.Int64All(time.Now().Unix()),
|
|
|
|
|
|
+ "history_updatetime": qutil.Int64All(time.Now().Unix()),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -153,7 +170,7 @@ func historyRepeat() {
|
|
}()
|
|
}()
|
|
log.Println("构建第", k, "组---(数据池)")
|
|
log.Println("构建第", k, "组---(数据池)")
|
|
//当前组的第一个发布时间
|
|
//当前组的第一个发布时间
|
|
- first_pt := util.Int64All(v[len(v)-1]["publishtime"])
|
|
|
|
|
|
+ first_pt := qutil.Int64All(v[len(v)-1]["publishtime"])
|
|
curTM := TimedTaskDatamap(dupdays+int(timingSpanDay)+1, first_pt+86400, int(k))
|
|
curTM := TimedTaskDatamap(dupdays+int(timingSpanDay)+1, first_pt+86400, int(k))
|
|
log.Println("开始遍历判重第", k, "组 共计数量:", len(v))
|
|
log.Println("开始遍历判重第", k, "组 共计数量:", len(v))
|
|
n = n + len(v)
|
|
n = n + len(v)
|
|
@@ -173,80 +190,10 @@ func historyRepeat() {
|
|
"repeat_reason": reason,
|
|
"repeat_reason": reason,
|
|
"repeat_id": source.id,
|
|
"repeat_id": source.id,
|
|
"dataging": 0,
|
|
"dataging": 0,
|
|
- "history_updatetime": util.Int64All(time.Now().Unix()),
|
|
|
|
|
|
+ "history_updatetime": qutil.Int64All(time.Now().Unix()),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
- //关闭数据替换功能
|
|
|
|
- //if judgeIsReplaceInfo(source.href, info.href) && !IsFull {
|
|
|
|
- // datalock.Lock()
|
|
|
|
- // temp_source_id := source.id
|
|
|
|
- // temp_info_id := info.id
|
|
|
|
- // temp_source := info
|
|
|
|
- // temp_source.id = temp_source_id
|
|
|
|
- // curTM.replacePoolData(temp_source)
|
|
|
|
- // //替换抽取表数据
|
|
|
|
- // is_log, is_exists, ext_s_data, ext_i_data := confrimHistoryExtractData(temp_source_id, temp_info_id)
|
|
|
|
- // is_bid, bid_s_data, bid_i_data := confrimBiddingData(temp_source_id, temp_info_id)
|
|
|
|
- //
|
|
|
|
- // if is_log && is_bid {
|
|
|
|
- // data_mgo.Save(extract_log, map[string]interface{}{
|
|
|
|
- // "_id": StringTOBsonId(temp_info_id),
|
|
|
|
- // "replace_id": temp_source_id,
|
|
|
|
- // "is_history": 1,
|
|
|
|
- // })
|
|
|
|
- // ext_s_data["repeat"] = 0
|
|
|
|
- // ext_s_data["dataging"] = 0
|
|
|
|
- // ext_i_data["repeat"] = 1
|
|
|
|
- // ext_i_data["repeat_id"] = temp_source_id
|
|
|
|
- // ext_i_data["repeat_reason"] = reason
|
|
|
|
- // ext_i_data["dataging"] = 0
|
|
|
|
- // ext_i_data["history_updatetime"] = qu.Int64All(time.Now().Unix())
|
|
|
|
- // if is_exists {
|
|
|
|
- // data_mgo.DeleteById(extract, temp_source_id)
|
|
|
|
- // data_mgo.Save(extract, ext_s_data)
|
|
|
|
- // } else {
|
|
|
|
- // data_mgo.DeleteById(extract_back, temp_source_id)
|
|
|
|
- // data_mgo.Save(extract_back, ext_s_data)
|
|
|
|
- // is_del := data_mgo.DeleteById(extract, temp_source_id)
|
|
|
|
- // if is_del > 0 {
|
|
|
|
- // data_mgo.Save(extract, ext_s_data)
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // data_mgo.DeleteById(extract, temp_info_id)
|
|
|
|
- // data_mgo.Save(extract, ext_i_data)
|
|
|
|
- //
|
|
|
|
- // task_mgo.DeleteById(task_bidding, temp_source_id)
|
|
|
|
- // task_mgo.Save(task_bidding, bid_s_data)
|
|
|
|
- // task_mgo.DeleteById(task_bidding, temp_info_id)
|
|
|
|
- // task_mgo.Save(task_bidding, bid_i_data)
|
|
|
|
- //
|
|
|
|
- // //通道填充数据
|
|
|
|
- // msg := "id=" + temp_source_id
|
|
|
|
- // _ = nspdata_1.Publish(msg)
|
|
|
|
- // _ = nspdata_2.Publish(msg)
|
|
|
|
- //
|
|
|
|
- // } else {
|
|
|
|
- // log.Println("替换~相关表~未查询到数据~", temp_source_id, "~", temp_info_id)
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
- // datalock.Unlock()
|
|
|
|
- //} else {
|
|
|
|
- // Update.updatePool <- []map[string]interface{}{ //重复数据打标签
|
|
|
|
- // map[string]interface{}{
|
|
|
|
- // "_id": tmp["_id"],
|
|
|
|
- // },
|
|
|
|
- // map[string]interface{}{
|
|
|
|
- // "$set": map[string]interface{}{
|
|
|
|
- // "repeat": 1,
|
|
|
|
- // "repeat_reason": reason,
|
|
|
|
- // "repeat_id": source.id,
|
|
|
|
- // "dataging": 0,
|
|
|
|
- // "history_updatetime": util.Int64All(time.Now().Unix()),
|
|
|
|
- // },
|
|
|
|
- // },
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
} else {
|
|
} else {
|
|
Update.updatePool <- []map[string]interface{}{ //重复数据打标签
|
|
Update.updatePool <- []map[string]interface{}{ //重复数据打标签
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
@@ -255,7 +202,7 @@ func historyRepeat() {
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"$set": map[string]interface{}{
|
|
"dataging": 0, //符合条件的都为dataging==0
|
|
"dataging": 0, //符合条件的都为dataging==0
|
|
- "history_updatetime": util.Int64All(time.Now().Unix()),
|
|
|
|
|
|
+ "history_updatetime": qutil.Int64All(time.Now().Unix()),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -271,18 +218,18 @@ func historyRepeat() {
|
|
//任务完成,开始发送广播通知下面节点 发udp 去升索引待定 + 合并
|
|
//任务完成,开始发送广播通知下面节点 发udp 去升索引待定 + 合并
|
|
if gtid != lteid {
|
|
if gtid != lteid {
|
|
for _, to := range nextNode {
|
|
for _, to := range nextNode {
|
|
- next_sid := util.BsonIdToSId(gtid)
|
|
|
|
- next_eid := util.BsonIdToSId(lteid)
|
|
|
|
- key := next_sid + "-" + next_eid + "-" + util.ObjToString(to["stype"])
|
|
|
|
|
|
+ next_sid := qutil.BsonIdToSId(gtid)
|
|
|
|
+ next_eid := qutil.BsonIdToSId(lteid)
|
|
|
|
+ key := next_sid + "-" + next_eid + "-" + qutil.ObjToString(to["stype"])
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
by, _ := json.Marshal(map[string]interface{}{
|
|
"gtid": next_sid,
|
|
"gtid": next_sid,
|
|
"lteid": next_eid,
|
|
"lteid": next_eid,
|
|
- "stype": util.ObjToString(to["stype"]),
|
|
|
|
|
|
+ "stype": qutil.ObjToString(to["stype"]),
|
|
"key": key,
|
|
"key": key,
|
|
})
|
|
})
|
|
addr := &net.UDPAddr{
|
|
addr := &net.UDPAddr{
|
|
IP: net.ParseIP(to["addr"].(string)),
|
|
IP: net.ParseIP(to["addr"].(string)),
|
|
- Port: util.IntAll(to["port"]),
|
|
|
|
|
|
+ Port: qutil.IntAll(to["port"]),
|
|
}
|
|
}
|
|
node := &udpNode{by, addr, time.Now().Unix(), 0}
|
|
node := &udpNode{by, addr, time.Now().Unix(), 0}
|
|
udptaskmap.Store(key, node)
|
|
udptaskmap.Store(key, node)
|
|
@@ -361,7 +308,7 @@ func moveOnceTimeOut() {
|
|
now := time.Now()
|
|
now := time.Now()
|
|
|
|
|
|
move_time := time.Date(now.Year()-2, now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
|
move_time := time.Date(now.Year()-2, now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
|
- task_id := util.BsonIdToSId(bson.NewObjectIdWithTime(move_time))
|
|
|
|
|
|
+ task_id := qutil.BsonIdToSId(bson.NewObjectIdWithTime(move_time))
|
|
q := map[string]interface{}{
|
|
q := map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"_id": map[string]interface{}{
|
|
"$lt": StringTOBsonId(task_id),
|
|
"$lt": StringTOBsonId(task_id),
|