|
@@ -365,8 +365,8 @@ func processedData_A(c *Customer, data *tempData) {
|
|
|
EntInfo(findwinner, tmp)
|
|
|
}
|
|
|
}
|
|
|
- matchKey := map[string]bool{} //记录所有匹配上的关键词
|
|
|
- matchKeyType := map[string]bool{} //记录关键词对应的匹配方式
|
|
|
+ //matchKey := map[string]bool{} //记录所有匹配上的关键词
|
|
|
+ //matchKeyType := map[string]bool{} //记录关键词对应的匹配方式
|
|
|
//先获取用到的所有字段值
|
|
|
fieldText := map[string]interface{}{}
|
|
|
for field, _ := range sr.Fields {
|
|
@@ -389,99 +389,99 @@ func processedData_A(c *Customer, data *tempData) {
|
|
|
因为要记录所有匹配上的关键词,所有优先匹配附加词,在匹配关键词
|
|
|
*/
|
|
|
//1.附加词匹配
|
|
|
- IsMatch := false
|
|
|
- // common.Debug("sr.AW---", len(sr.AW))
|
|
|
- for i, aw := range sr.AW {
|
|
|
- // common.Debug("-------------------------开始附加词匹配--------------------------")
|
|
|
- IsMatchAddKey := RegMatch(fieldText, aw.MatchType, aw.KeyReg, nil, nil, false, true)
|
|
|
- // common.Debug(IsMatchAddKey, "------------------------------------------------------------")
|
|
|
+ //IsMatch := false
|
|
|
+ //// common.Debug("sr.AW---", len(sr.AW))
|
|
|
+ //for i, aw := range sr.AW {
|
|
|
+ // // common.Debug("-------------------------开始附加词匹配--------------------------")
|
|
|
+ // IsMatchAddKey := RegMatch(fieldText, aw.MatchType, aw.KeyReg, nil, nil, false, true)
|
|
|
+ // // common.Debug(IsMatchAddKey, "------------------------------------------------------------")
|
|
|
+ //
|
|
|
+ // //2.关键词匹配
|
|
|
+ // if IsMatchAddKey {
|
|
|
+ // kw := sr.KW[i]
|
|
|
+ // // common.Debug("-------------------------开始关键词匹配--------------------------")
|
|
|
+ // IsMatchKey := RegMatch(fieldText, kw.MatchType, kw.KeyReg, matchKey, matchKeyType, true, false)
|
|
|
+ // // common.Debug(IsMatchKey, "------------------------------------------------------------")
|
|
|
+ // if IsMatchKey {
|
|
|
+ // IsMatch = true
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //if len(sr.AW) == 0 {
|
|
|
+ // IsMatch = true
|
|
|
+ //}
|
|
|
+ ///*
|
|
|
+ // 到此已经匹配完数据
|
|
|
+ //*/
|
|
|
+ //if !IsMatch {
|
|
|
+ // log.Debug("---------------------", zap.String("id", id), zap.Any("IsMatch", IsMatch))
|
|
|
+ //}
|
|
|
+ //if IsMatch {
|
|
|
+ //匹配成功,数据上新增规则id,matchKey,item并临时保存数据
|
|
|
+ // tmpMatchKey := MapDataToArr(matchKey)
|
|
|
+ //tmpMatchKeyType := MapDataToArr(matchKeyType)
|
|
|
+ tmp["matchkey"], tmp["matchtype"] = GetMactchKeys(sr.Maths, tmp)
|
|
|
+ //tmp["matchtype"] = strings.Join(tmpMatchKeyType, ",")
|
|
|
+ tmp["ruleid"] = sr.ID
|
|
|
+ tmp["rulename"] = sr.Name
|
|
|
|
|
|
- //2.关键词匹配
|
|
|
- if IsMatchAddKey {
|
|
|
- kw := sr.KW[i]
|
|
|
- // common.Debug("-------------------------开始关键词匹配--------------------------")
|
|
|
- IsMatchKey := RegMatch(fieldText, kw.MatchType, kw.KeyReg, matchKey, matchKeyType, true, false)
|
|
|
- // common.Debug(IsMatchKey, "------------------------------------------------------------")
|
|
|
- if IsMatchKey {
|
|
|
- IsMatch = true
|
|
|
- }
|
|
|
- }
|
|
|
+ //开始打标签
|
|
|
+ //common.Debug("c.IsTagRule+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
|
|
+ if c.IsTagRule {
|
|
|
+ TagRuleFuc(c.AppId, c.PushModel, 1, c.TagRules, sr, tmp, fieldText)
|
|
|
}
|
|
|
- if len(sr.AW) == 0 {
|
|
|
- IsMatch = true
|
|
|
+ if c.IsTagRule2 {
|
|
|
+ TagRuleFuc(c.AppId, c.PushModel, 2, c.TagRules2, sr, tmp, fieldText)
|
|
|
}
|
|
|
- /*
|
|
|
- 到此已经匹配完数据
|
|
|
- */
|
|
|
- if !IsMatch {
|
|
|
- log.Debug("---------------------", zap.String("id", id), zap.Any("IsMatch", IsMatch))
|
|
|
+ if c.IsTagRule3 {
|
|
|
+ TagRuleFuc(c.AppId, c.PushModel, 3, c.TagRules3, sr, tmp, fieldText)
|
|
|
}
|
|
|
- if IsMatch {
|
|
|
- //匹配成功,数据上新增规则id,matchKey,item并临时保存数据
|
|
|
- // tmpMatchKey := MapDataToArr(matchKey)
|
|
|
- tmpMatchKeyType := MapDataToArr(matchKeyType)
|
|
|
- tmp["matchkey"] = GetMactchKeys(sr.Maths, tmp)
|
|
|
- tmp["matchtype"] = strings.Join(tmpMatchKeyType, ",")
|
|
|
- tmp["ruleid"] = sr.ID
|
|
|
- tmp["rulename"] = sr.Name
|
|
|
-
|
|
|
- //开始打标签
|
|
|
- //common.Debug("c.IsTagRule+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
|
|
- if c.IsTagRule {
|
|
|
- TagRuleFuc(c.AppId, c.PushModel, 1, c.TagRules, sr, tmp, fieldText)
|
|
|
- }
|
|
|
- if c.IsTagRule2 {
|
|
|
- TagRuleFuc(c.AppId, c.PushModel, 2, c.TagRules2, sr, tmp, fieldText)
|
|
|
- }
|
|
|
- if c.IsTagRule3 {
|
|
|
- TagRuleFuc(c.AppId, c.PushModel, 3, c.TagRules3, sr, tmp, fieldText)
|
|
|
- }
|
|
|
- //item
|
|
|
- switch c.PushModel {
|
|
|
- case 0:
|
|
|
- tmp["item"] = "数据"
|
|
|
- case 1:
|
|
|
- tmp["item"] = dm.Name
|
|
|
- case 2:
|
|
|
- //tmp["item"] = sr.Name
|
|
|
- case 3:
|
|
|
- tmp["item"] = dm.Name + "_" + sr.Name
|
|
|
- case 4:
|
|
|
- tmp["item"] = sr.Name
|
|
|
- }
|
|
|
- //appid
|
|
|
- tmp["appid"] = c.AppId
|
|
|
- //部门名称
|
|
|
- tmp["departname"] = dm.Name
|
|
|
- tmp["departid"] = dm.ID
|
|
|
- //存储数据
|
|
|
- //dm.DataLock.Lock()
|
|
|
- //tmpMap := map[string]interface{}{id: tmp}
|
|
|
- //dm.SaveDataMap[sr.ID] = append(dm.SaveDataMap[sr.ID], tmpMap)
|
|
|
- //dm.DataLock.Unlock()
|
|
|
- //c.saveBeforeChan <- &tempData{dm: dm, rule: sr, data: tmp}
|
|
|
+ //item
|
|
|
+ switch c.PushModel {
|
|
|
+ case 0:
|
|
|
+ tmp["item"] = "数据"
|
|
|
+ case 1:
|
|
|
+ tmp["item"] = dm.Name
|
|
|
+ case 2:
|
|
|
+ //tmp["item"] = sr.Name
|
|
|
+ case 3:
|
|
|
+ tmp["item"] = dm.Name + "_" + sr.Name
|
|
|
+ case 4:
|
|
|
+ tmp["item"] = sr.Name
|
|
|
+ }
|
|
|
+ //appid
|
|
|
+ tmp["appid"] = c.AppId
|
|
|
+ //部门名称
|
|
|
+ tmp["departname"] = dm.Name
|
|
|
+ tmp["departid"] = dm.ID
|
|
|
+ //存储数据
|
|
|
+ //dm.DataLock.Lock()
|
|
|
+ //tmpMap := map[string]interface{}{id: tmp}
|
|
|
+ //dm.SaveDataMap[sr.ID] = append(dm.SaveDataMap[sr.ID], tmpMap)
|
|
|
+ //dm.DataLock.Unlock()
|
|
|
+ //c.saveBeforeChan <- &tempData{dm: dm, rule: sr, data: tmp}
|
|
|
|
|
|
- m1 := c.RemoveRepeatData(tmp)
|
|
|
- c.saveTempLock.Lock()
|
|
|
- if m1 != nil {
|
|
|
- c.saveTempArr = append(c.saveTempArr, []map[string]interface{}{
|
|
|
- {"_id": mongodb.StringTOBsonId(id)},
|
|
|
- {"$set": m1},
|
|
|
- })
|
|
|
- } else {
|
|
|
- c.saveTempArr = append(c.saveTempArr, []map[string]interface{}{
|
|
|
- {"_id": mongodb.StringTOBsonId(id)},
|
|
|
- {"$set": tmp},
|
|
|
- })
|
|
|
- }
|
|
|
- if len(c.saveTempArr) > 200 {
|
|
|
- util.MgoSave.UpSertBulk(c.saveTempColl, c.saveTempArr...)
|
|
|
- c.saveTempArr = [][]map[string]interface{}{}
|
|
|
- }
|
|
|
- c.saveTempLock.Unlock()
|
|
|
+ m1 := c.RemoveRepeatData(tmp)
|
|
|
+ c.saveTempLock.Lock()
|
|
|
+ if m1 != nil {
|
|
|
+ c.saveTempArr = append(c.saveTempArr, []map[string]interface{}{
|
|
|
+ {"_id": mongodb.StringTOBsonId(id)},
|
|
|
+ {"$set": m1},
|
|
|
+ })
|
|
|
} else {
|
|
|
- // common.Debug("------------", id, IsMatch)
|
|
|
+ c.saveTempArr = append(c.saveTempArr, []map[string]interface{}{
|
|
|
+ {"_id": mongodb.StringTOBsonId(id)},
|
|
|
+ {"$set": tmp},
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if len(c.saveTempArr) > 200 {
|
|
|
+ util.MgoSave.UpSertBulk(c.saveTempColl, c.saveTempArr...)
|
|
|
+ c.saveTempArr = [][]map[string]interface{}{}
|
|
|
}
|
|
|
+ c.saveTempLock.Unlock()
|
|
|
+ //} else {
|
|
|
+ // common.Debug("------------", id, IsMatch)
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
// legal_person,company_email,company_phone
|
|
@@ -998,38 +998,60 @@ func (tr *TagRule) GetKeyAddNotKeyWord(o_list []map[string]interface{}) {
|
|
|
tr.BuyerClass = buyerclass
|
|
|
}
|
|
|
|
|
|
-func GetMactchKeys(match []map[string]string, data map[string]interface{}) string {
|
|
|
+func GetMactchKeys(match []map[string]string, data map[string]interface{}) (string, string) {
|
|
|
keyWord := []string{}
|
|
|
+ keyType := []string{}
|
|
|
for _, keys := range match {
|
|
|
types := keys["s_keymatch"] // 1,2,3
|
|
|
key := keys["s_matchkey"] //软件,工程
|
|
|
if strings.Contains(types, "1") {
|
|
|
title := common.ObjToString(data["title"])
|
|
|
keyWord = KeyWordToDatas(types, title, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "title")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "2") {
|
|
|
detail := common.ObjToString(data["detail"])
|
|
|
keyWord = KeyWordToDatas(types, detail, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "detail")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "3") {
|
|
|
purchasing := common.ObjToString(data["purchasing"])
|
|
|
keyWord = KeyWordToDatas(types, purchasing, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "purchasing")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "4") {
|
|
|
filetext := common.ObjToString(data["filetext"])
|
|
|
keyWord = KeyWordToDatas(types, filetext, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "filetext")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "5") {
|
|
|
projectname := common.ObjToString(data["projectname"])
|
|
|
keyWord = KeyWordToDatas(types, projectname, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "projectname")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "6") || strings.Contains(types, "8") {
|
|
|
buyer := common.ObjToString(data["buyer"])
|
|
|
keyWord = KeyWordToDatas(types, buyer, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "buyer")
|
|
|
+ }
|
|
|
}
|
|
|
if strings.Contains(types, "7") || strings.Contains(types, "9") {
|
|
|
winner := common.ObjToString(data["s_winner"])
|
|
|
keyWord = KeyWordToDatas(types, winner, key, keyWord)
|
|
|
+ if len(keyType) == 0 && len(keyWord) > 0 {
|
|
|
+ keyType = append(keyType, "winner")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
keyMap := map[string]bool{}
|
|
@@ -1040,7 +1062,7 @@ func GetMactchKeys(match []map[string]string, data map[string]interface{}) strin
|
|
|
for k, _ := range keyMap {
|
|
|
keyArr = append(keyArr, k)
|
|
|
}
|
|
|
- return strings.Join(keyArr, ",")
|
|
|
+ return strings.Join(keyArr, ","), strings.Join(keyType, ",")
|
|
|
}
|
|
|
|
|
|
func KeyWordToDatas(types, item, key string, keyWord []string) []string {
|