Pārlūkot izejas kodu

规则模式组合

xuzhiheng 4 gadi atpakaļ
vecāks
revīzija
99e7c57f1c
3 mainītis faili ar 22 papildinājumiem un 9 dzēšanām
  1. 3 3
      src/history/datamodel.go
  2. 9 1
      src/history/task.go
  3. 10 5
      src/history/util_history.go

+ 3 - 3
src/history/datamodel.go

@@ -96,7 +96,7 @@ type Customer struct {
 	IsSearchEnps bool                              //是否查询第三方企业信息
 	TagRules     []*TagRule                        //打标签规则集合
 	SaveDataMap  map[string]map[string]interface{} //最终入库数据(全局模式)
-	SaveDataArr  []map[string]interface{}          //最终入库数据(规则模式)
+	SaveDataArr  map[string]map[string]interface{} //最终入库数据(规则模式)
 	IdRange      bson.M                            //由当前时间生成是id查询区间
 }
 
@@ -107,8 +107,8 @@ type Department struct {
 	CustomerID     string                              //所属客户id
 	Rules          []*SearchRule                       //客户的多个规则
 	DepartmentData map[string][]map[string]interface{} //部门所有数据 key:ruleid value:[{k:dataid v:data},{k:dataid v:data}]
-	DataLock    *sync.Mutex                            //数据锁
-	SaveDataMap map[string]map[string]interface{}      //最终入库数据(部门内部去重)
+	DataLock       *sync.Mutex                         //数据锁
+	SaveDataMap    map[string]map[string]interface{}   //最终入库数据(部门内部去重)
 }
 
 //查询规则模型

+ 9 - 1
src/history/task.go

@@ -392,7 +392,15 @@ func (c *Customer) RemoveRepeatData() {
 							//dm.SaveDataMap[dataId] = dm_history
 						}
 					} else if c.PushModel == 4 { //规则模式不去重
-						c.SaveDataArr = append(c.SaveDataArr, tmp)
+						// c.SaveDataArr = append(c.SaveDataArr, tmp)
+						if dm.SaveDataArr[dataId] == nil {
+							tmp["itemdist"] = map[string]interface{}{qu.ObjToString(tmp["item"]): qu.ObjToString(tmp["matchkey"])}
+							dm.SaveDataArr[dataId] = tmp
+						} else { //数据重复
+							dm_history := dm.SaveDataArr[dataId]
+							MergeDatas(dm_history, tmp, c.IsTagRule, false) //合并字段
+							//dm.SaveDataMap[dataId] = dm_history
+						}
 					}
 				}
 			}

+ 10 - 5
src/history/util_history.go

@@ -68,7 +68,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                 //含字母
@@ -120,7 +120,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               //含字母
@@ -406,6 +406,11 @@ func MergeData(history, tmp map[string]interface{}, isTagRule, isDepartRmvRep bo
 	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
+
 	if isTagRule { //标签模式 tagname、tagid合并
 		tagname1 := qu.ObjToString(history["tagname"])
 		tagname2 := qu.ObjToString(tmp["tagname"])
@@ -632,7 +637,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 		if dataTable == 0 { //存到usermail_history
 			MgoSaveCache <- tmp
 		} else if dataTable == 1 { //存到usermail
-			redis.Put("datag", appid+"_"+id, 1, 3*24*60*60)
+			redis.Put("datag", appid+"_"+id, 1, -1)
 			MgoSaveUsermailCache <- tmp
 		} else if dataTable == 2 {
 			//存入mysql,并存到redis
@@ -1279,7 +1284,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()
@@ -1470,7 +1475,7 @@ func GetWinnerType(s_winner string, v map[string]interface{}) {
 }
 
 //历史数据存到mysql pushentniche推送表中
-func saveMysqlPush(tmp map[string]interface{}, entId int, ) bool {
+func saveMysqlPush(tmp map[string]interface{}, entId int) bool {
 	saveMap := map[string]interface{}{}
 	saveMap["entid"] = entId
 	infoid := qu.ObjToString(tmp["id"])