|
@@ -18,13 +18,10 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
var (
|
|
|
- Sysconfig map[string]interface{} //配置文件
|
|
|
- mconf map[string]interface{} //mongodb配置信息
|
|
|
- mgo *mongodb.MongodbSim //mongodb操作对象
|
|
|
+ Sysconfig map[string]interface{} //配置文件
|
|
|
+ mconf map[string]interface{} //mongodb配置信息
|
|
|
+ mgo *mongodb.MongodbSim //mongodb操作对象
|
|
|
//siteMgo *mongodb.MongodbSim
|
|
|
extract string
|
|
|
extract_copy string
|
|
@@ -33,17 +30,17 @@ var (
|
|
|
nextNode []map[string]interface{} //下节点数组
|
|
|
dupdays = 5 //初始化判重范围
|
|
|
DM *datamap //
|
|
|
- HM *historymap //判重数据
|
|
|
+ HM *historymap //判重数据
|
|
|
lastid = ""
|
|
|
/*
|
|
|
- 5da3f2c5a5cb26b9b79847fc
|
|
|
+ 5da3f2c5a5cb26b9b79847fc
|
|
|
*/
|
|
|
//正则筛选相关
|
|
|
- FilterRegTitle = regexp.MustCompile("^_$")
|
|
|
+ FilterRegTitle = regexp.MustCompile("^_$")
|
|
|
FilterRegTitle_1 = regexp.MustCompile("^_$")
|
|
|
FilterRegTitle_2 = regexp.MustCompile("^_$")
|
|
|
|
|
|
- isMerger bool //是否合并
|
|
|
+ isMerger bool //是否合并
|
|
|
SiteMap map[string]map[string]interface{} //站点map
|
|
|
)
|
|
|
|
|
@@ -63,7 +60,6 @@ func init() {
|
|
|
extract_copy = mconf["extract_copy"].(string)
|
|
|
mgo.InitPool()
|
|
|
|
|
|
-
|
|
|
//测试可以临时注释
|
|
|
dupdays = util.IntAllDef(Sysconfig["dupdays"], 3)
|
|
|
//加载数据
|
|
@@ -73,37 +69,36 @@ func init() {
|
|
|
FilterRegTitle_2 = regexp.MustCompile(util.ObjToString(Sysconfig["specialtitle_2"]))
|
|
|
isMerger = Sysconfig["isMerger"].(bool)
|
|
|
|
|
|
-
|
|
|
//配置站点Map
|
|
|
- SiteMap = make(map[string]map[string]interface{},0)
|
|
|
+ SiteMap = make(map[string]map[string]interface{}, 0)
|
|
|
start := int(time.Now().Unix())
|
|
|
//站点配置
|
|
|
sess_site := mgo.GetMgoConn()
|
|
|
defer sess_site.Close()
|
|
|
res_site := sess_site.DB("zhaolongyue").C("site").Find(nil).Sort("_id").Iter()
|
|
|
for site_dict := make(map[string]interface{}); res_site.Next(&site_dict); {
|
|
|
- data_map := map[string]interface{}{
|
|
|
- "area":util.ObjToString(site_dict["area"]),
|
|
|
- "city":util.ObjToString(site_dict["city"]),
|
|
|
- "district":util.ObjToString(site_dict["district"]),
|
|
|
- "sitetype":util.ObjToString(site_dict["sitetype"]),
|
|
|
- "level":util.ObjToString(site_dict["level"]),
|
|
|
- }
|
|
|
- SiteMap[util.ObjToString(site_dict["site"])]= data_map
|
|
|
+ data_map := map[string]interface{}{
|
|
|
+ "area": util.ObjToString(site_dict["area"]),
|
|
|
+ "city": util.ObjToString(site_dict["city"]),
|
|
|
+ "district": util.ObjToString(site_dict["district"]),
|
|
|
+ "sitetype": util.ObjToString(site_dict["sitetype"]),
|
|
|
+ "level": util.ObjToString(site_dict["level"]),
|
|
|
+ }
|
|
|
+ SiteMap[util.ObjToString(site_dict["site"])] = data_map
|
|
|
}
|
|
|
- fmt.Printf("用时:%d秒,%d个",int(time.Now().Unix())-start,len(SiteMap))
|
|
|
-
|
|
|
+ fmt.Printf("用时:%d秒,%d个", int(time.Now().Unix())-start, len(SiteMap))
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func main() {
|
|
|
+
|
|
|
go checkMapJob()
|
|
|
|
|
|
updport := Sysconfig["udpport"].(string)
|
|
|
udpclient = mu.UdpClient{Local: updport, BufSize: 1024}
|
|
|
udpclient.Listen(processUdpMsg)
|
|
|
log.Println("Udp服务监听", updport)
|
|
|
+
|
|
|
time.Sleep(99999 * time.Hour)
|
|
|
}
|
|
|
|
|
@@ -120,14 +115,14 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
|
|
|
udpclient.WriteUdp([]byte("err:"+err.Error()), mu.OP_NOOP, ra)
|
|
|
} else if mapInfo != nil {
|
|
|
|
|
|
- taskType:= util.ObjToString(mapInfo["stype"])
|
|
|
+ taskType := util.ObjToString(mapInfo["stype"])
|
|
|
if taskType == "historyTask" {
|
|
|
//更新流程
|
|
|
- go historyTask(data,mapInfo)
|
|
|
- }else if taskType == "normalTask" {
|
|
|
+ go historyTask(data, mapInfo)
|
|
|
+ } else if taskType == "normalTask" {
|
|
|
//判重流程
|
|
|
go task(data, mapInfo)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//其他
|
|
|
go task(data, mapInfo)
|
|
|
}
|
|
@@ -161,17 +156,16 @@ func task(data []byte, mapInfo map[string]interface{}) {
|
|
|
"$lte": util.StringTOBsonId(mapInfo["lteid"].(string)),
|
|
|
},
|
|
|
}
|
|
|
+
|
|
|
it := sess.DB(mgo.DbName).C(extract).Find(&q).Sort("publishtime").Iter()
|
|
|
updateExtract := [][]map[string]interface{}{}
|
|
|
pool := make(chan bool, 16)
|
|
|
wg := &sync.WaitGroup{}
|
|
|
mapLock := &sync.Mutex{}
|
|
|
n, repeateN := 0, 0
|
|
|
-
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); n++ {
|
|
|
-
|
|
|
if n%10000 == 0 {
|
|
|
- log.Println("current:", n, tmp["_id"],"repeateN:",repeateN)
|
|
|
+ log.Println("current:", n, tmp["_id"], "repeateN:", repeateN)
|
|
|
}
|
|
|
pool <- true
|
|
|
wg.Add(1)
|
|
@@ -183,7 +177,7 @@ func task(data []byte, mapInfo map[string]interface{}) {
|
|
|
info := NewInfo(tmp)
|
|
|
|
|
|
//是否为无效数据
|
|
|
- if invalidData(info.buyer,info.projectname,info.projectcode) {
|
|
|
+ if invalidData(info.buyer, info.projectname, info.projectcode) {
|
|
|
mapLock.Lock()
|
|
|
updateExtract = append(updateExtract, []map[string]interface{}{
|
|
|
map[string]interface{}{
|
|
@@ -191,7 +185,7 @@ func task(data []byte, mapInfo map[string]interface{}) {
|
|
|
},
|
|
|
map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "repeat":-1,
|
|
|
+ "repeat": -1,
|
|
|
},
|
|
|
},
|
|
|
})
|
|
@@ -201,96 +195,88 @@ func task(data []byte, mapInfo map[string]interface{}) {
|
|
|
updateExtract = [][]map[string]interface{}{}
|
|
|
}
|
|
|
mapLock.Unlock()
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//判重原因 reason tmp["_id"] 对比id id原始id
|
|
|
- mapLock.Lock()
|
|
|
- b, source,reason := DM.check(info)
|
|
|
+ //mapLock.Lock()
|
|
|
+ b, source, reason := DM.check(info)
|
|
|
if b { //有重复,生成更新语句,更新抽取和更新招标
|
|
|
repeateN++
|
|
|
- var mergeArr = []int64{} //更改合并数组记录
|
|
|
- var newData = &Info{} //更换新的数据池数据
|
|
|
- var id_map = map[string]interface{}{}
|
|
|
+ var mergeArr = []int64{} //更改合并数组记录
|
|
|
+ var newData = &Info{} //更换新的数据池数据
|
|
|
+ var id_map = map[string]interface{}{}
|
|
|
repeat_id := source.id
|
|
|
- id_map["_id"]= util.StringTOBsonId(info.id)
|
|
|
-
|
|
|
- if isMerger{
|
|
|
+ id_map["_id"] = util.StringTOBsonId(info.id)
|
|
|
+ if isMerger {
|
|
|
//需要合并相关操作
|
|
|
//合并操作--评功权重打分-合并完替换原始数据池
|
|
|
- basic_bool := basicDataScore(source,info)
|
|
|
+ basic_bool := basicDataScore(source, info)
|
|
|
if basic_bool {
|
|
|
//已原始数据为标准-对比数据打判重标签
|
|
|
- newData,mergeArr= mergeDataFields(source,info)
|
|
|
- DM.replaceSourceData(newData,source.id) //替换
|
|
|
- id_map["_id"]= util.StringTOBsonId(source.id)
|
|
|
+ newData, mergeArr = mergeDataFields(source, info)
|
|
|
+ DM.replaceSourceData(newData, source.id) //替换
|
|
|
+ id_map["_id"] = util.StringTOBsonId(source.id)
|
|
|
repeat_id = source.id
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//已对比数据为标准 ,数据池的数据打判重标签
|
|
|
- newData,mergeArr= mergeDataFields(info,source)
|
|
|
- DM.replaceSourceData(newData,source.id)//替换
|
|
|
- id_map["_id"]= util.StringTOBsonId(info.id)
|
|
|
+ newData, mergeArr = mergeDataFields(info, source)
|
|
|
+ DM.replaceSourceData(newData, source.id) //替换
|
|
|
+ id_map["_id"] = util.StringTOBsonId(info.id)
|
|
|
repeat_id = info.id
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- var update_map = map[string]interface{}{
|
|
|
+ var update_map = map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "repeat_reason":reason,
|
|
|
- "repeat":1,
|
|
|
- "repeatid":repeat_id,
|
|
|
+ "repeat_reason": reason,
|
|
|
+ "repeat": 1,
|
|
|
+ "repeatid": repeat_id,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
if isMerger {
|
|
|
//合并记录
|
|
|
- if len(newData.mergemap)>0 {
|
|
|
+ if len(newData.mergemap) > 0 {
|
|
|
update_map["$set"].(map[string]interface{})["merge"] = newData.mergemap
|
|
|
//fmt.Println("合并长度:",len(newData.mergemap))
|
|
|
}
|
|
|
|
|
|
//更新合并后的数据
|
|
|
- for _,value :=range mergeArr {
|
|
|
- if value==1 {
|
|
|
+ for _, value := range mergeArr {
|
|
|
+ if value == 1 {
|
|
|
update_map["$set"].(map[string]interface{})["area"] = newData.area
|
|
|
update_map["$set"].(map[string]interface{})["city"] = newData.city
|
|
|
- }else if value==2 {
|
|
|
+ } else if value == 2 {
|
|
|
update_map["$set"].(map[string]interface{})["projectname"] = newData.projectname
|
|
|
- }else if value==3 {
|
|
|
+ } else if value == 3 {
|
|
|
update_map["$set"].(map[string]interface{})["projectcode"] = newData.projectcode
|
|
|
- }else if value==4 {
|
|
|
+ } else if value == 4 {
|
|
|
update_map["$set"].(map[string]interface{})["buyer"] = newData.buyer
|
|
|
- }else if value==5 {
|
|
|
+ } else if value == 5 {
|
|
|
update_map["$set"].(map[string]interface{})["budget"] = newData.budget
|
|
|
- }else if value==6 {
|
|
|
+ } else if value == 6 {
|
|
|
update_map["$set"].(map[string]interface{})["winner"] = newData.winner
|
|
|
- }else if value==7 {
|
|
|
+ } else if value == 7 {
|
|
|
update_map["$set"].(map[string]interface{})["bidamount"] = newData.bidamount
|
|
|
- }else if value==8 {
|
|
|
+ } else if value == 8 {
|
|
|
update_map["$set"].(map[string]interface{})["bidopentime"] = newData.bidopentime
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
//构建数据库更新用到的
|
|
|
updateExtract = append(updateExtract, []map[string]interface{}{
|
|
|
id_map,
|
|
|
update_map,
|
|
|
})
|
|
|
- if len(updateExtract) > 500 {
|
|
|
- mgo.UpdateBulk(extract, updateExtract...)
|
|
|
- updateExtract = [][]map[string]interface{}{}
|
|
|
- }
|
|
|
- mapLock.Unlock()
|
|
|
-
|
|
|
- } else {
|
|
|
- mapLock.Unlock()
|
|
|
}
|
|
|
}
|
|
|
}(tmp)
|
|
|
+ if len(updateExtract) > 500 {
|
|
|
+ mgo.UpdateBulk(extract, updateExtract...)
|
|
|
+ updateExtract = [][]map[string]interface{}{}
|
|
|
+ }
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
wg.Wait()
|
|
@@ -338,26 +324,26 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
|
|
|
it := sess.DB(mgo.DbName).C(extract).Find(&q).Iter()
|
|
|
- minTime,maxTime:=int64(0),int64(0)
|
|
|
- for tmp := make(map[string]interface{}); it.Next(&tmp);{
|
|
|
+ minTime, maxTime := int64(0), int64(0)
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); {
|
|
|
//取出最大最小时间
|
|
|
- if minTime==0||maxTime ==0 {
|
|
|
+ if minTime == 0 || maxTime == 0 {
|
|
|
minTime = util.Int64All(tmp["comeintime"])
|
|
|
maxTime = util.Int64All(tmp["comeintime"])
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
t := util.Int64All(tmp["comeintime"])
|
|
|
- if t<minTime&&t!=0 {
|
|
|
+ if t < minTime && t != 0 {
|
|
|
minTime = t
|
|
|
}
|
|
|
- if t>maxTime&&t!=0 {
|
|
|
+ if t > maxTime && t != 0 {
|
|
|
maxTime = t
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- fmt.Println("最小时间==",minTime,"最大时间==",maxTime)
|
|
|
+ fmt.Println("最小时间==", minTime, "最大时间==", maxTime)
|
|
|
//最小时间== 1568087634 最大时间== 1568103381
|
|
|
HM = NewHistorymap(util.ObjToString(mapInfo["gtid"]),
|
|
|
- util.ObjToString(mapInfo["lteid"]),minTime,maxTime)
|
|
|
+ util.ObjToString(mapInfo["lteid"]), minTime, maxTime)
|
|
|
|
|
|
//return
|
|
|
//开始判重...
|
|
@@ -380,7 +366,7 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
for tmp := make(map[string]interface{}); it_task.Next(&tmp); n++ {
|
|
|
|
|
|
if n%10000 == 0 {
|
|
|
- log.Println("current:", n, tmp["_id"],"repeateN:",repeateN)
|
|
|
+ log.Println("current:", n, tmp["_id"], "repeateN:", repeateN)
|
|
|
}
|
|
|
pool <- true
|
|
|
wg.Add(1)
|
|
@@ -391,7 +377,7 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}()
|
|
|
info := NewInfo(tmp)
|
|
|
//是否为无效数据
|
|
|
- if invalidData(info.buyer,info.projectname,info.projectcode) {
|
|
|
+ if invalidData(info.buyer, info.projectname, info.projectcode) {
|
|
|
mapLock.Lock()
|
|
|
updateExtract = append(updateExtract, []map[string]interface{}{
|
|
|
map[string]interface{}{
|
|
@@ -399,7 +385,7 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
},
|
|
|
map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "repeat": -1,
|
|
|
+ "repeat": -1,
|
|
|
},
|
|
|
},
|
|
|
})
|
|
@@ -408,9 +394,8 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
updateExtract = [][]map[string]interface{}{}
|
|
|
}
|
|
|
mapLock.Unlock()
|
|
|
- }else {
|
|
|
- mapLock.Lock()
|
|
|
- b, source,reason := HM.checkHistory(info)
|
|
|
+ } else {
|
|
|
+ b, source, reason := HM.checkHistory(info)
|
|
|
if b { //有重复,生成更新语句,更新抽取和更新招标
|
|
|
if reason == "未判重记录" {
|
|
|
fmt.Println("未判重记录")
|
|
@@ -427,97 +412,86 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
},
|
|
|
},
|
|
|
})
|
|
|
- if len(updateExtract) > 500 {
|
|
|
- mgo.UpdateBulk(extract, updateExtract...)
|
|
|
- updateExtract = [][]map[string]interface{}{}
|
|
|
- }
|
|
|
- mapLock.Unlock()
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
repeateN++
|
|
|
- var mergeArr = []int64{} //更改合并数组记录
|
|
|
- var newData = &Info{} //更换新的数据池数据
|
|
|
- var id_map = map[string]interface{}{}
|
|
|
+ var mergeArr = []int64{} //更改合并数组记录
|
|
|
+ var newData = &Info{} //更换新的数据池数据
|
|
|
+ var id_map = map[string]interface{}{}
|
|
|
repeat_id := source.id
|
|
|
- id_map["_id"]= util.StringTOBsonId(info.id)
|
|
|
+ id_map["_id"] = util.StringTOBsonId(info.id)
|
|
|
|
|
|
- if isMerger{
|
|
|
+ if isMerger {
|
|
|
//需要合并相关操作
|
|
|
//合并操作--评功权重打分-合并完替换原始数据池
|
|
|
- basic_bool := basicDataScore(source,info)
|
|
|
+ basic_bool := basicDataScore(source, info)
|
|
|
if basic_bool {
|
|
|
//已原始数据为标准-对比数据打判重标签
|
|
|
- newData,mergeArr= mergeDataFields(source,info)
|
|
|
- DM.replaceSourceData(newData,source.id) //替换
|
|
|
- id_map["_id"]= util.StringTOBsonId(source.id)
|
|
|
+ newData, mergeArr = mergeDataFields(source, info)
|
|
|
+ DM.replaceSourceData(newData, source.id) //替换
|
|
|
+ id_map["_id"] = util.StringTOBsonId(source.id)
|
|
|
repeat_id = source.id
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//已对比数据为标准 ,数据池的数据打判重标签
|
|
|
- newData,mergeArr= mergeDataFields(info,source)
|
|
|
- DM.replaceSourceData(newData,source.id)//替换
|
|
|
- id_map["_id"]= util.StringTOBsonId(info.id)
|
|
|
+ newData, mergeArr = mergeDataFields(info, source)
|
|
|
+ DM.replaceSourceData(newData, source.id) //替换
|
|
|
+ id_map["_id"] = util.StringTOBsonId(info.id)
|
|
|
repeat_id = info.id
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- var update_map = map[string]interface{}{
|
|
|
+ var update_map = map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
|
- "repeat_reason":reason,
|
|
|
- "repeat":1,
|
|
|
- "repeatid":repeat_id,
|
|
|
+ "repeat_reason": reason,
|
|
|
+ "repeat": 1,
|
|
|
+ "repeatid": repeat_id,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
if isMerger {
|
|
|
//合并记录
|
|
|
- if len(newData.mergemap)>0 {
|
|
|
+ if len(newData.mergemap) > 0 {
|
|
|
update_map["$set"].(map[string]interface{})["merge"] = newData.mergemap
|
|
|
//fmt.Println("合并长度:",len(newData.mergemap))
|
|
|
}
|
|
|
|
|
|
//更新合并后的数据
|
|
|
- for _,value :=range mergeArr {
|
|
|
- if value==1 {
|
|
|
+ for _, value := range mergeArr {
|
|
|
+ if value == 1 {
|
|
|
update_map["$set"].(map[string]interface{})["area"] = newData.area
|
|
|
update_map["$set"].(map[string]interface{})["city"] = newData.city
|
|
|
- }else if value==2 {
|
|
|
+ } else if value == 2 {
|
|
|
update_map["$set"].(map[string]interface{})["projectname"] = newData.projectname
|
|
|
- }else if value==3 {
|
|
|
+ } else if value == 3 {
|
|
|
update_map["$set"].(map[string]interface{})["projectcode"] = newData.projectcode
|
|
|
- }else if value==4 {
|
|
|
+ } else if value == 4 {
|
|
|
update_map["$set"].(map[string]interface{})["buyer"] = newData.buyer
|
|
|
- }else if value==5 {
|
|
|
+ } else if value == 5 {
|
|
|
update_map["$set"].(map[string]interface{})["budget"] = newData.budget
|
|
|
- }else if value==6 {
|
|
|
+ } else if value == 6 {
|
|
|
update_map["$set"].(map[string]interface{})["winner"] = newData.winner
|
|
|
- }else if value==7 {
|
|
|
+ } else if value == 7 {
|
|
|
update_map["$set"].(map[string]interface{})["bidamount"] = newData.bidamount
|
|
|
- }else if value==8 {
|
|
|
+ } else if value == 8 {
|
|
|
update_map["$set"].(map[string]interface{})["bidopentime"] = newData.bidopentime
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
//构建数据库更新用到的
|
|
|
updateExtract = append(updateExtract, []map[string]interface{}{
|
|
|
id_map,
|
|
|
update_map,
|
|
|
})
|
|
|
- if len(updateExtract) > 500 {
|
|
|
- mgo.UpdateBulk(extract, updateExtract...)
|
|
|
- updateExtract = [][]map[string]interface{}{}
|
|
|
- }
|
|
|
- mapLock.Unlock()
|
|
|
}
|
|
|
- }else {
|
|
|
- mapLock.Unlock()
|
|
|
}
|
|
|
}
|
|
|
}(tmp)
|
|
|
+ if len(updateExtract) > 500 {
|
|
|
+ mgo.UpdateBulk(extract, updateExtract...)
|
|
|
+ updateExtract = [][]map[string]interface{}{}
|
|
|
+ }
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
|
wg.Wait()
|
|
@@ -527,10 +501,8 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
log.Println("this task over.", n, "repeateN:", repeateN, mapInfo["stop"])
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//任务完成,开始发送广播通知下面节点
|
|
|
- if n > repeateN &&mapInfo["stop"] == nil {
|
|
|
+ if n > repeateN && mapInfo["stop"] == nil {
|
|
|
for _, to := range nextNode {
|
|
|
sid, _ := mapInfo["gtid"].(string)
|
|
|
eid, _ := mapInfo["lteid"].(string)
|
|
@@ -552,293 +524,320 @@ func historyTask(data []byte, mapInfo map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//合并字段
|
|
|
-func mergeDataFields(source *Info, info *Info) (*Info,[]int64){
|
|
|
+func mergeDataFields(source *Info, info *Info) (*Info, []int64) {
|
|
|
|
|
|
var mergeArr []int64
|
|
|
- mergeArr = make([]int64,0)
|
|
|
+ mergeArr = make([]int64, 0)
|
|
|
//1、城市
|
|
|
- if (source.area==""||source.area=="全国")&&info.area!="全国"&&info.area!=""{
|
|
|
+ if (source.area == "" || source.area == "全国") && info.area != "全国" && info.area != "" {
|
|
|
var arrA []string
|
|
|
- if source.mergemap["area"]==nil {
|
|
|
+ if source.mergemap["area"] == nil {
|
|
|
arrA = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arrA = source.mergemap["area"].([]string)
|
|
|
}
|
|
|
- arrA = append(arrA,source.area)
|
|
|
+ arrA = append(arrA, source.area)
|
|
|
source.mergemap["area"] = arrA
|
|
|
|
|
|
var arrC []string
|
|
|
- if source.mergemap["city"]==nil {
|
|
|
+ if source.mergemap["city"] == nil {
|
|
|
arrC = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arrC = source.mergemap["city"].([]string)
|
|
|
}
|
|
|
- arrC = append(arrC,source.city)
|
|
|
+ arrC = append(arrC, source.city)
|
|
|
source.mergemap["city"] = arrC
|
|
|
|
|
|
source.area = info.area
|
|
|
source.city = info.city
|
|
|
- mergeArr = append(mergeArr,1)
|
|
|
+ mergeArr = append(mergeArr, 1)
|
|
|
|
|
|
//fmt.Println("合并-城市")
|
|
|
}
|
|
|
//2、项目名称
|
|
|
- if source.projectname==""&&info.projectname!=""{
|
|
|
+ if source.projectname == "" && info.projectname != "" {
|
|
|
var arr []string
|
|
|
- if source.mergemap["projectname"]==nil {
|
|
|
+ if source.mergemap["projectname"] == nil {
|
|
|
arr = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["projectname"].([]string)
|
|
|
}
|
|
|
- arr = append(arr,source.projectname)
|
|
|
+ arr = append(arr, source.projectname)
|
|
|
source.mergemap["projectname"] = arr
|
|
|
|
|
|
source.projectname = info.projectname
|
|
|
- mergeArr = append(mergeArr,2)
|
|
|
+ mergeArr = append(mergeArr, 2)
|
|
|
//fmt.Println("合并-项目名称")
|
|
|
}
|
|
|
//3、项目编号
|
|
|
- if source.projectcode==""&&info.projectcode!=""{
|
|
|
+ if source.projectcode == "" && info.projectcode != "" {
|
|
|
var arr []string
|
|
|
- if source.mergemap["projectcode"]==nil {
|
|
|
+ if source.mergemap["projectcode"] == nil {
|
|
|
arr = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["projectcode"].([]string)
|
|
|
}
|
|
|
- arr = append(arr,source.projectcode)
|
|
|
+ arr = append(arr, source.projectcode)
|
|
|
source.mergemap["projectcode"] = arr
|
|
|
|
|
|
source.projectcode = info.projectcode
|
|
|
- mergeArr = append(mergeArr,3)
|
|
|
+ mergeArr = append(mergeArr, 3)
|
|
|
//fmt.Println("合并-项目标号")
|
|
|
}
|
|
|
//4、采购单位
|
|
|
- if source.buyer==""&&info.buyer!=""{
|
|
|
+ if source.buyer == "" && info.buyer != "" {
|
|
|
var arr []string
|
|
|
- if source.mergemap["buyer"]==nil {
|
|
|
+ if source.mergemap["buyer"] == nil {
|
|
|
arr = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["buyer"].([]string)
|
|
|
}
|
|
|
- arr = append(arr,source.buyer)
|
|
|
+ arr = append(arr, source.buyer)
|
|
|
source.mergemap["buyer"] = arr
|
|
|
|
|
|
source.buyer = info.buyer
|
|
|
- mergeArr = append(mergeArr,4)
|
|
|
+ mergeArr = append(mergeArr, 4)
|
|
|
//fmt.Println("合并-采购单位")
|
|
|
}
|
|
|
//5、预算
|
|
|
- if source.budget==0&&info.budget!=0{
|
|
|
+ if source.budget == 0 && info.budget != 0 {
|
|
|
var arr []float64
|
|
|
- if source.mergemap["budget"]==nil {
|
|
|
+ if source.mergemap["budget"] == nil {
|
|
|
arr = make([]float64, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["budget"].([]float64)
|
|
|
}
|
|
|
- arr = append(arr,source.budget)
|
|
|
+ arr = append(arr, source.budget)
|
|
|
source.mergemap["budget"] = arr
|
|
|
|
|
|
source.budget = info.budget
|
|
|
- mergeArr = append(mergeArr,5)
|
|
|
+ mergeArr = append(mergeArr, 5)
|
|
|
//fmt.Println("合并-预算")
|
|
|
}
|
|
|
//6、中标单位
|
|
|
- if source.winner==""&&info.winner!=""{
|
|
|
+ if source.winner == "" && info.winner != "" {
|
|
|
var arr []string
|
|
|
- if source.mergemap["winner"]==nil {
|
|
|
+ if source.mergemap["winner"] == nil {
|
|
|
arr = make([]string, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["winner"].([]string)
|
|
|
}
|
|
|
- arr = append(arr,source.winner)
|
|
|
+ arr = append(arr, source.winner)
|
|
|
source.mergemap["winner"] = arr
|
|
|
|
|
|
source.winner = info.winner
|
|
|
- mergeArr = append(mergeArr,6)
|
|
|
+ mergeArr = append(mergeArr, 6)
|
|
|
//fmt.Println("合并-中标单位")
|
|
|
}
|
|
|
//7、中标金额
|
|
|
- if source.bidamount==0&&info.bidamount!=0{
|
|
|
+ if source.bidamount == 0 && info.bidamount != 0 {
|
|
|
var arr []float64
|
|
|
- if source.mergemap["bidamount"]==nil {
|
|
|
+ if source.mergemap["bidamount"] == nil {
|
|
|
arr = make([]float64, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["bidamount"].([]float64)
|
|
|
}
|
|
|
- arr = append(arr,source.bidamount)
|
|
|
+ arr = append(arr, source.bidamount)
|
|
|
source.mergemap["bidamount"] = arr
|
|
|
|
|
|
source.bidamount = info.bidamount
|
|
|
- mergeArr = append(mergeArr,7)
|
|
|
+ mergeArr = append(mergeArr, 7)
|
|
|
//fmt.Println("合并-中标金额")
|
|
|
}
|
|
|
//8、开天时间-地点
|
|
|
- if source.bidopentime==0&&info.bidopentime!=0{
|
|
|
+ if source.bidopentime == 0 && info.bidopentime != 0 {
|
|
|
var arr []int64
|
|
|
- if source.mergemap["bidopentime"]==nil {
|
|
|
+ if source.mergemap["bidopentime"] == nil {
|
|
|
arr = make([]int64, 0)
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
arr = source.mergemap["bidopentime"].([]int64)
|
|
|
}
|
|
|
- arr = append(arr,source.bidopentime)
|
|
|
+ arr = append(arr, source.bidopentime)
|
|
|
source.mergemap["bidopentime"] = arr
|
|
|
|
|
|
source.bidopentime = info.bidopentime
|
|
|
- mergeArr = append(mergeArr,8)
|
|
|
+ mergeArr = append(mergeArr, 8)
|
|
|
//fmt.Println("合并-开标时间")
|
|
|
}
|
|
|
|
|
|
//以上合并过于简单,待进一步优化
|
|
|
- return source,mergeArr
|
|
|
+ return source, mergeArr
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//权重评估
|
|
|
-func basicDataScore(v *Info, info *Info) bool {
|
|
|
+func basicDataScore(v *Info, info *Info) bool {
|
|
|
|
|
|
//权重评估
|
|
|
/*
|
|
|
- 网站优先级判定规则:
|
|
|
- 1、中央>省>市>县区
|
|
|
- 2、政府采购>公共资源>采购单位官网>招标代理公司/平台
|
|
|
+ 网站优先级判定规则:
|
|
|
+ 1、中央>省>市>县区
|
|
|
+ 2、政府采购>公共资源>采购单位官网>招标代理公司/平台
|
|
|
*/
|
|
|
|
|
|
-
|
|
|
- v_score,info_score :=-1,-1
|
|
|
+ v_score, info_score := -1, -1
|
|
|
dict_v := SiteMap[v.site]
|
|
|
dict_info := SiteMap[info.site]
|
|
|
//先判断level
|
|
|
- if dict_v !=nil {
|
|
|
+ if dict_v != nil {
|
|
|
v_level := util.ObjToString(dict_v["level"])
|
|
|
- if v_level =="中央" {
|
|
|
+ if v_level == "中央" {
|
|
|
v_score = 4
|
|
|
- }else if v_level =="省级" {
|
|
|
+ } else if v_level == "省级" {
|
|
|
v_score = 3
|
|
|
- }else if v_level =="市级" {
|
|
|
+ } else if v_level == "市级" {
|
|
|
v_score = 2
|
|
|
- }else if v_level =="县区" {
|
|
|
+ } else if v_level == "县区" {
|
|
|
v_score = 1
|
|
|
- }else if v_level =="" {
|
|
|
- }else {
|
|
|
+ } else if v_level == "" {
|
|
|
+ } else {
|
|
|
v_score = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if dict_info !=nil {
|
|
|
+ if dict_info != nil {
|
|
|
info_level := util.ObjToString(dict_info["level"])
|
|
|
- if info_level =="中央" {
|
|
|
+ if info_level == "中央" {
|
|
|
info_score = 4
|
|
|
- }else if info_level =="省级" {
|
|
|
+ } else if info_level == "省级" {
|
|
|
info_score = 3
|
|
|
- }else if info_level =="市级" {
|
|
|
+ } else if info_level == "市级" {
|
|
|
info_score = 2
|
|
|
- }else if info_level =="县区" {
|
|
|
+ } else if info_level == "县区" {
|
|
|
info_score = 1
|
|
|
- }else if info_level == ""{
|
|
|
+ } else if info_level == "" {
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
v_score = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if v_score>info_score{
|
|
|
+ if v_score > info_score {
|
|
|
return true
|
|
|
}
|
|
|
- if v_score<info_score{
|
|
|
+ if v_score < info_score {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
//判断sitetype
|
|
|
- if dict_v !=nil {
|
|
|
+ if dict_v != nil {
|
|
|
v_sitetype := util.ObjToString(dict_v["sitetype"])
|
|
|
- if v_sitetype =="政府采购"||v_sitetype=="政府门户" {
|
|
|
+ if v_sitetype == "政府采购" || v_sitetype == "政府门户" {
|
|
|
v_score = 4
|
|
|
- }else if v_sitetype =="公共资源" {
|
|
|
+ } else if v_sitetype == "公共资源" {
|
|
|
v_score = 3
|
|
|
- }else if v_sitetype =="官方网站" {
|
|
|
+ } else if v_sitetype == "官方网站" {
|
|
|
v_score = 2
|
|
|
- }else if v_sitetype =="社会公共招标平台"||v_sitetype =="企业招标平台" {
|
|
|
+ } else if v_sitetype == "社会公共招标平台" || v_sitetype == "企业招标平台" {
|
|
|
v_score = 1
|
|
|
- }else if v_sitetype =="" {
|
|
|
- }else {
|
|
|
+ } else if v_sitetype == "" {
|
|
|
+ } else {
|
|
|
v_score = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if dict_info !=nil {
|
|
|
+ if dict_info != nil {
|
|
|
info_sitetype := util.ObjToString(dict_info["sitetype"])
|
|
|
- if info_sitetype =="政府采购"||info_sitetype=="政府门户" {
|
|
|
+ if info_sitetype == "政府采购" || info_sitetype == "政府门户" {
|
|
|
info_score = 4
|
|
|
- }else if info_sitetype =="公共资源" {
|
|
|
+ } else if info_sitetype == "公共资源" {
|
|
|
info_score = 3
|
|
|
- }else if info_sitetype =="官方网站" {
|
|
|
+ } else if info_sitetype == "官方网站" {
|
|
|
info_score = 2
|
|
|
- }else if info_sitetype =="社会公共招标平台"||info_sitetype =="企业招标平台" {
|
|
|
+ } else if info_sitetype == "社会公共招标平台" || info_sitetype == "企业招标平台" {
|
|
|
info_score = 1
|
|
|
- }else if info_sitetype =="" {
|
|
|
- }else {
|
|
|
+ } else if info_sitetype == "" {
|
|
|
+ } else {
|
|
|
info_score = 0
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if v_score>info_score{
|
|
|
+ if v_score > info_score {
|
|
|
return true
|
|
|
}
|
|
|
- if v_score<info_score{
|
|
|
+ if v_score < info_score {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+ //网站评估
|
|
|
+ m, n := 0, 0
|
|
|
+ if v.projectname != "" {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.buyer != "" {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.projectcode != "" {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.budget != 0 {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.bidamount != 0 {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.winner != "" {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.bidopentime != 0 {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.agencyaddr != "" {
|
|
|
+ m++
|
|
|
+ }
|
|
|
+ if v.agency != "" {
|
|
|
+ m = m + 2
|
|
|
+ }
|
|
|
+ if v.city != "" {
|
|
|
+ m = m + 2
|
|
|
+ }
|
|
|
|
|
|
+ if info.projectname != "" {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.buyer != "" {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.projectcode != "" {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.budget != 0 {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.bidamount != 0 {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.winner != "" {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.bidopentime != 0 {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.agencyaddr != "" {
|
|
|
+ n++
|
|
|
+ }
|
|
|
+ if info.agency != "" {
|
|
|
+ n = m + 2
|
|
|
+ }
|
|
|
+ if info.city != "" {
|
|
|
+ n = m + 2
|
|
|
+ }
|
|
|
|
|
|
- //网站评估
|
|
|
- m,n:=0,0
|
|
|
- if v.projectname!="" {m++}
|
|
|
- if v.buyer!="" {m++}
|
|
|
- if v.projectcode!="" {m++}
|
|
|
- if v.budget!=0 {m++}
|
|
|
- if v.bidamount!=0 {m++}
|
|
|
- if v.winner!="" {m++}
|
|
|
- if v.bidopentime!=0 {m++}
|
|
|
- if v.agencyaddr!="" {m++}
|
|
|
- if v.agency!="" {m=m+2}
|
|
|
- if v.city!="" {m=m+2}
|
|
|
-
|
|
|
- if info.projectname!="" {n++}
|
|
|
- if info.buyer!="" {n++}
|
|
|
- if info.projectcode!="" {n++}
|
|
|
- if info.budget!=0 {n++}
|
|
|
- if info.bidamount!=0 {n++}
|
|
|
- if info.winner!="" {n++}
|
|
|
- if info.bidopentime!=0 {n++}
|
|
|
- if info.agencyaddr!="" {n++}
|
|
|
- if info.agency!="" {n=m+2}
|
|
|
- if info.city!="" {n=m+2}
|
|
|
-
|
|
|
- if m>n {
|
|
|
+ if m > n {
|
|
|
return true
|
|
|
- }else if m==n {
|
|
|
- if v.comeintime>=info.comeintime {
|
|
|
+ } else if m == n {
|
|
|
+ if v.comeintime >= info.comeintime {
|
|
|
return true
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return false
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//无效数据
|
|
|
-func invalidData(d1 string,d2 string,d3 string) bool{
|
|
|
+func invalidData(d1 string, d2 string, d3 string) bool {
|
|
|
var n int
|
|
|
if d1 != "" {
|
|
|
n++
|
|
@@ -849,8 +848,8 @@ func invalidData(d1 string,d2 string,d3 string) bool{
|
|
|
if d3 != "" {
|
|
|
n++
|
|
|
}
|
|
|
- if n==0 {
|
|
|
+ if n == 0 {
|
|
|
return true
|
|
|
}
|
|
|
return false
|
|
|
-}
|
|
|
+}
|