Explorar el Código

Merge branch 'dev1.4' of http://192.168.3.207:10080/qmx/datatag into dev1.4

fuwencai hace 4 años
padre
commit
bf90bcdf9c
Se han modificado 2 ficheros con 80 adiciones y 11 borrados
  1. 21 5
      src/history/task.go
  2. 59 6
      src/history/util_history.go

+ 21 - 5
src/history/task.go

@@ -380,19 +380,35 @@ func (c *Customer) RemoveRepeatData() {
 							c.SaveDataMap[dataId] = tmp
 						} else { //数据重复
 							cus_history := c.SaveDataMap[dataId]
-							MergeData(cus_history, tmp, c.IsTagRule, true) //合并字段
+							MergeData(cus_history, tmp, c.IsTagRule, true, c.PushModel) //合并字段
 							//c.SaveDataMap[dataId] = cus_history
 						}
-					} else if c.PushModel == 1 || c.PushModel == 2 || c.PushModel == 3 { //部门内部去重
+					} else if c.PushModel == 2 || c.PushModel == 3 { //部门内部去重
 						if dm.SaveDataMap[dataId] == nil {
 							dm.SaveDataMap[dataId] = tmp
 						} else { //数据重复
 							dm_history := dm.SaveDataMap[dataId]
-							MergeData(dm_history, tmp, c.IsTagRule, false) //合并字段
+							MergeData(dm_history, tmp, c.IsTagRule, false, c.PushModel) //合并字段
 							//dm.SaveDataMap[dataId] = dm_history
 						}
-					} else if c.PushModel == 4 { //规则模式不去重
-						c.SaveDataArr = append(c.SaveDataArr, tmp)
+					} else if c.PushModel == 4 { //规则模式数据合并
+						//c.SaveDataArr = append(c.SaveDataArr, tmp)
+						if c.SaveDataMap[dataId] == nil {
+							tmp["itemdist"] = map[string]interface{}{qu.ObjToString(tmp["item"]): qu.ObjToString(tmp["matchkey"])}
+							c.SaveDataMap[dataId] = tmp
+						} else { //数据重复
+							dm_history := c.SaveDataMap[dataId]
+							MergeDatas(dm_history, tmp, c.IsTagRule, false) //合并字段
+							//dm.SaveDataMap[dataId] = dm_history
+						}
+					} else if c.PushModel == 1 { // 部门模式数据合并
+						if c.SaveDataMap[dataId] == nil {
+							tmp["itemdist"] = map[string]interface{}{qu.ObjToString(tmp["item"]): qu.ObjToString(tmp["matchkey"])}
+							c.SaveDataMap[dataId] = tmp
+						} else { //数据重复
+							dm_history := c.SaveDataMap[dataId]
+							MergeData(dm_history, tmp, c.IsTagRule, true, c.PushModel) //合并字段
+						}
 					}
 				}
 			}

+ 59 - 6
src/history/util_history.go

@@ -67,7 +67,7 @@ func GetNotkeyAndKeyAddWord(list []map[string]interface{}, fieldMap map[string]i
 					tmp_nkw := nkw_addArr[0]
 					if tmp_nkw != "" {
 						cr := &CommonReg{}
-						cr.CsVal = tmp_nkw                   //记录原值
+						cr.CsVal = tmp_nkw //记录原值
 						if LetterCase.MatchString(tmp_nkw) { //判断附加词中是否有英文
 							tmp_nkw = strings.ToUpper(tmp_nkw) //附加词中有英文全部转为大写
 							cr.IsLetter = true                 //含字母
@@ -119,7 +119,7 @@ func GetNotkeyAndKeyAddWord(list []map[string]interface{}, fieldMap map[string]i
 				tmp_aw := aw_addArr[0]
 				if tmp_aw != "" {
 					cr := &CommonReg{}
-					cr.CsVal = tmp_aw                   //记录原值
+					cr.CsVal = tmp_aw //记录原值
 					if LetterCase.MatchString(tmp_aw) { //判断附加词中是否有英文
 						tmp_aw = strings.ToUpper(tmp_aw) //附加词中有英文全部转为大写
 						cr.IsLetter = true               //含字母
@@ -353,7 +353,7 @@ func RegMatch(fieldText map[string]interface{}, matchType []string, matchReg *Re
 				for n, arc := range ar.AndRegKid { //ar.AndRegKid若有值必不小于2
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else {                                                         //匹配成功,判断字母
+					} else { //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}
@@ -387,7 +387,7 @@ func MapDataToArr(tmpMap map[string]bool) (tmpArr []string) {
 }
 
 //合并数据
-func MergeData(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep bool) {
+func MergeData(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep bool, pushModel int) {
 	//matchkey、matchtype、ruleid均非空
 	matchkey1 := qu.ObjToString(history["matchkey"])
 	matchkey2 := qu.ObjToString(tmp["matchkey"])
@@ -425,7 +425,60 @@ func MergeData(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep bo
 		departid1 := qu.ObjToString(history["departid"])
 		departid2 := qu.ObjToString(tmp["departid"])
 		history["departid"] = MergeField(departid1, departid2)
+		if pushModel == 1 {
+			item1 := qu.ObjToString(history["item"])
+			item2 := qu.ObjToString(tmp["item"])
+			history["item"] = MergeField(item1, item2)
+			history["itemdist"].(map[string]interface{})[departname2] = matchkey2
+		}
+	}
+}
+
+func MergeDatas(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep bool) {
+	//matchkey、matchtype、ruleid均非空
+	matchkey1 := qu.ObjToString(history["matchkey"])
+	matchkey2 := qu.ObjToString(tmp["matchkey"])
+	history["matchkey"] = MergeField(matchkey1, matchkey2)
+
+	matchkeytype1 := qu.ObjToString(history["matchtype"])
+	matchkeytype2 := qu.ObjToString(tmp["matchtype"])
+	history["matchtype"] = MergeField(matchkeytype1, matchkeytype2)
+
+	ruleid1 := qu.ObjToString(history["ruleid"])
+	ruleid2 := qu.ObjToString(tmp["ruleid"])
+	history["ruleid"] = MergeField(ruleid1, ruleid2)
+
+	rulename1 := qu.ObjToString(history["rulename"])
+	rulename2 := qu.ObjToString(tmp["rulename"])
+	history["rulename"] = MergeField(rulename1, rulename2)
+
+	item1 := qu.ObjToString(history["item"])
+	item2 := qu.ObjToString(tmp["item"])
+	history["item"] = MergeField(item1, item2)
+	history["itemdist"].(map[string]interface{})[item2] = matchkey2
+	qu.Debug("组装后的item:", history["item"], history["itemdist"])
+
+	if isTagRule { //标签模式 tagname、tagid合并
+		tagname1 := qu.ObjToString(history["tagname"])
+		tagname2 := qu.ObjToString(tmp["tagname"])
+		if tagNameResult := MergeField(tagname1, tagname2); tagNameResult != "" {
+			history["tagname"] = tagNameResult
+		}
+
+		tagid1 := qu.ObjToString(history["tagid"])
+		tagid2 := qu.ObjToString(tmp["tagid"])
+		if tagIdResult := MergeField(tagid1, tagid2); tagIdResult != "" {
+			history["tagid"] = tagIdResult
+		}
 	}
+	//if isDepartRmvRep { //全局模式 部门合并
+	departname1 := qu.ObjToString(history["departname"])
+	departname2 := qu.ObjToString(tmp["departname"])
+	history["departname"] = MergeField(departname1, departname2)
+	departid1 := qu.ObjToString(history["departid"])
+	departid2 := qu.ObjToString(tmp["departid"])
+	history["departid"] = MergeField(departid1, departid2)
+	//}
 }
 
 //合并字段
@@ -1011,7 +1064,7 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 					qu.Debug("nnnn---", n, arc.CrVal, arc.IsLetter)
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else {                                                         //匹配成功,判断字母
+					} else { //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}
@@ -1280,7 +1333,7 @@ func GetXlsxs(mMap []map[string]interface{}, fn, email, id string, isfile, isHen
 					row.AddCell().SetValue(v["projectname"]) //项目名称
 					row.AddCell().SetValue(v["buyer"])       //采购单位
 					row.AddCell().SetValue(v["buyer_type"])  //采购单位类别---私有标签tagname
-					if v["bidamount"] != nil {               //中标金额
+					if v["bidamount"] != nil { //中标金额
 						row.AddCell().SetFloat(qu.Float64All(v["bidamount"]))
 					} else {
 						row.AddCell()