|
@@ -73,6 +73,9 @@ func startProjectMerge(thisinfo *Info, tmp map[string]interface{}) {
|
|
|
}
|
|
|
//合并流程
|
|
|
if bNormalScore {
|
|
|
+ PNKeyMap.Store(thisinfo.PNKey, true)
|
|
|
+ PBKeyMap.Store(thisinfo.PBKey, true)
|
|
|
+ PCKeyMap.Store(thisinfo.PCKey, true)
|
|
|
if pcbv.Buyer { //有采购单位
|
|
|
hasBuyer(pcbv, thisinfo, tmp)
|
|
|
} else { //无采购单位
|
|
@@ -99,11 +102,15 @@ func checkInfoAlter(tmp map[string]interface{} /*新信息*/) bool {
|
|
|
|
|
|
//有采购单位
|
|
|
func hasBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
|
|
|
+ var pncb []*CompareInfo
|
|
|
+ var res []interface{}
|
|
|
sflag := ""
|
|
|
pici := time.Now().Unix()
|
|
|
if p.Pname || p.Pcode { //有项目名称或项目编号
|
|
|
+ //获取对比项目数组
|
|
|
+ res, pncb = getComeperProjects(p, thisinfo)
|
|
|
//三选二打分
|
|
|
- scores, pncb := score3Select2(p, thisinfo, tmp)
|
|
|
+ scores := score3Select2(p, thisinfo, tmp, res, pncb)
|
|
|
//项目合并
|
|
|
sflag = mergeProject(tmp, thisinfo, scores, pncb)
|
|
|
} else {
|
|
@@ -121,18 +128,22 @@ func hasBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
|
|
|
|
|
|
//无采购单位
|
|
|
func noBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
|
|
|
+ var pncb []*CompareInfo
|
|
|
+ var res []interface{}
|
|
|
sflag := ""
|
|
|
pici := time.Now().Unix()
|
|
|
if p.Pname { //有项目名称
|
|
|
+ //获取对比项目数组
|
|
|
+ res, pncb = getComeperProjects(p, thisinfo)
|
|
|
if p.Pcode { //有项目编号
|
|
|
//三选二打分
|
|
|
- scores, pncb := score3Select2(p, thisinfo, tmp)
|
|
|
+ scores := score3Select2(p, thisinfo, tmp, res, pncb)
|
|
|
//项目合并
|
|
|
sflag = mergeProject(tmp, thisinfo, scores, pncb)
|
|
|
} else { //无项目编号
|
|
|
if p.PnameLen > MegerFieldsLen.ProjectNamelen {
|
|
|
//三选一打分
|
|
|
- scores, pncb := score3Select1(p, thisinfo, tmp)
|
|
|
+ scores := score3Select1(p, thisinfo, tmp, res, pncb)
|
|
|
//项目合并
|
|
|
sflag = mergeProject(tmp, thisinfo, scores, pncb)
|
|
|
} else {
|
|
@@ -147,10 +158,12 @@ func noBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
|
|
|
}
|
|
|
} else { //无项目名称
|
|
|
if p.Pcode {
|
|
|
+ //获取对比项目数组
|
|
|
+ res, pncb = getComeperProjects(p, thisinfo)
|
|
|
if p.PcodeLen > MegerFieldsLen.ProjectCodelen {
|
|
|
if p.Area && p.City && p.Agency { //有省市代理机构
|
|
|
//三选一打分
|
|
|
- scores, pncb := score3Select1(p, thisinfo, tmp)
|
|
|
+ scores := score3Select1(p, thisinfo, tmp, res, pncb)
|
|
|
//项目合并
|
|
|
sflag = mergeProject(tmp, thisinfo, scores, pncb)
|
|
|
} else {
|
|
@@ -181,12 +194,10 @@ func noBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
|
|
|
}
|
|
|
|
|
|
//3选2打分
|
|
|
-func score3Select2(p PCBV, thisinfo *Info, tmp map[string]interface{}) (scores []*CompareOne, pncb []*CompareInfo) {
|
|
|
+func score3Select2(p PCBV, thisinfo *Info, tmp map[string]interface{}, res []interface{}, pncb []*CompareInfo) (scores []*CompareOne) {
|
|
|
defer qu.Catch()
|
|
|
- res := []interface{}{}
|
|
|
- res, pncb = getComeperProjects(p, thisinfo) //获取对比项目数组
|
|
|
- //对比打分
|
|
|
- if len(res) > 0 { //找到项目名称、项目编号或采购单位相同时
|
|
|
+ if len(res) > 0 {
|
|
|
+ //对比打分
|
|
|
for k, tmps := range res { //遍历对象数组
|
|
|
if tmp, ok := tmps.([]interface{}); ok {
|
|
|
for _, b1 := range tmp {
|
|
@@ -256,10 +267,8 @@ func score3Select2(p PCBV, thisinfo *Info, tmp map[string]interface{}) (scores [
|
|
|
}
|
|
|
|
|
|
//3选1打分
|
|
|
-func score3Select1(p PCBV, thisinfo *Info, tmp map[string]interface{}) (scores []*CompareOne, pncb []*CompareInfo) {
|
|
|
+func score3Select1(p PCBV, thisinfo *Info, tmp map[string]interface{}, res []interface{}, pncb []*CompareInfo) (scores []*CompareOne) {
|
|
|
defer qu.Catch()
|
|
|
- res := []interface{}{}
|
|
|
- res, pncb = getComeperProjects(p, thisinfo) //获取对比项目数组
|
|
|
//对比打分
|
|
|
if len(res) > 0 { //找到项目名称、项目编号或采购单位相同时
|
|
|
for k, tmps := range res { //遍历对象数组
|
|
@@ -399,8 +408,12 @@ func getComeperProjects(p PCBV, thisinfo *Info) (res []interface{}, pncb []*Comp
|
|
|
}
|
|
|
|
|
|
//合并项目
|
|
|
-func mergeProject(tmp map[string]interface{}, thisinfo *Info, scores []*CompareOne, pncb []*CompareInfo) string {
|
|
|
- id, sflag := "", ""
|
|
|
+func mergeProject(tmp map[string]interface{}, thisinfo *Info, scores []*CompareOne, pncb []*CompareInfo) (sflag string) {
|
|
|
+ var id = ""
|
|
|
+ //分值排序
|
|
|
+ sort.Slice(scores, func(i, j int) bool {
|
|
|
+ return scores[i].Score > scores[j].Score
|
|
|
+ })
|
|
|
if len(scores) > 0 {
|
|
|
//分值排序
|
|
|
sort.Slice(scores, func(i, j int) bool {
|
|
@@ -429,19 +442,18 @@ func mergeProject(tmp map[string]interface{}, thisinfo *Info, scores []*CompareO
|
|
|
}
|
|
|
id = newProject(tmp, mess, time.Now().Unix(), thisinfo)
|
|
|
}
|
|
|
- if id != "" {
|
|
|
- //更新REDISKEYS redis
|
|
|
- PUT := []interface{}{}
|
|
|
+ if id != "" { //更新REDISKEYS redis
|
|
|
+ put := []interface{}{}
|
|
|
for _, pv := range pncb {
|
|
|
if pv != nil && !pv.Bfind {
|
|
|
if BinarySearch(*pv.K.Arr, id) == -1 {
|
|
|
*(pv.K.Arr) = append(*(pv.K.Arr), id)
|
|
|
- PUT = append(PUT, []interface{}{pv.Key, *(pv.K.Arr)})
|
|
|
+ put = append(put, []interface{}{pv.Key, *(pv.K.Arr)})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if len(PUT) > 0 {
|
|
|
- redis.BulkPut(REDISKEYS, 0, PUT...)
|
|
|
+ if len(put) > 0 {
|
|
|
+ redis.BulkPut(REDISKEYS, 0, put...)
|
|
|
}
|
|
|
}
|
|
|
return sflag
|
|
@@ -449,8 +461,7 @@ func mergeProject(tmp map[string]interface{}, thisinfo *Info, scores []*CompareO
|
|
|
|
|
|
//新增项目
|
|
|
func newProject(tmp, mess map[string]interface{}, pipc int64, thisinfo *Info) (id string) {
|
|
|
- new_pn, _ := handleprojectname(thisinfo.ProjectName, thisinfo.Buyer, thisinfo.TopType)
|
|
|
- id = InsertProject(new_pn, tmp, mess, pipc, thisinfo)
|
|
|
+ id = InsertProject(thisinfo.NewPNKey, tmp, mess, pipc, thisinfo)
|
|
|
sflag := qu.ObjToString(mess["meger_sflag"])
|
|
|
if sflag != "alone" {
|
|
|
p1 := NewPinfo(id, thisinfo)
|
|
@@ -550,7 +561,6 @@ func fieldPCBScore(this, info, ctype string, score int) (string, int) {
|
|
|
|
|
|
//pncbMap加锁
|
|
|
func lockPNCBMap(thisinfo *Info) {
|
|
|
- PncbMayLock.Lock()
|
|
|
for { //等待其他任务完成
|
|
|
ok := true
|
|
|
if len(thisinfo.PNKey) > 3 {
|
|
@@ -572,7 +582,6 @@ func lockPNCBMap(thisinfo *Info) {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- PncbMayLock.Unlock()
|
|
|
}
|
|
|
|
|
|
//pncbMap解锁
|