|
@@ -462,23 +462,9 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
if phone := qu.ObjToString(finddata["company_phone"]); phone != "" {
|
|
if phone := qu.ObjToString(finddata["company_phone"]); phone != "" {
|
|
tmp["company_phone"] = phone
|
|
tmp["company_phone"] = phone
|
|
}
|
|
}
|
|
- //从最新年报中获取 中标单位联系电话、中标单位邮箱
|
|
|
|
- // if annual_reports, ok := finddata["annual_reports"].(primitive.A); ok && len(annual_reports) > 0 {
|
|
|
|
- // anreport := Sort_year_report(annual_reports)
|
|
|
|
- // if len(anreport) > 0 {
|
|
|
|
- // if email := qu.ObjToString(anreport["company_email"]); email != "" {
|
|
|
|
- // tmp["company_email"] = email
|
|
|
|
- // }
|
|
|
|
- // if phone := qu.ObjToString(anreport["company_phone"]); phone != "" {
|
|
|
|
- // tmp["company_phone"] = phone
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- matchKey := map[string]bool{} //记录所有匹配上的关键词
|
|
|
|
- matchKeyType := map[string]bool{} //记录关键词对应的匹配方式
|
|
|
|
//先获取用到的所有字段值
|
|
//先获取用到的所有字段值
|
|
fieldText := map[string]interface{}{}
|
|
fieldText := map[string]interface{}{}
|
|
for field, _ := range sr.Fields {
|
|
for field, _ := range sr.Fields {
|
|
@@ -510,89 +496,41 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- 因为要记录所有匹配上的关键词,所有优先匹配附加词,在匹配关键词
|
|
|
|
- */
|
|
|
|
- //1.附加词匹配
|
|
|
|
- IsMatch := false
|
|
|
|
- //qu.Debug("sr.AW---", len(sr.AW))
|
|
|
|
- for i, aw := range sr.AW {
|
|
|
|
- //qu.Debug("-------------------------开始附加词匹配--------------------------")
|
|
|
|
- IsMatchAddKey := RegMatch(fieldText, aw.MatchType, aw.KeyReg, nil, nil, false, true)
|
|
|
|
- //qu.Debug(IsMatchAddKey, "------------------------------------------------------------")
|
|
|
|
-
|
|
|
|
- //2.关键词匹配
|
|
|
|
- if IsMatchAddKey {
|
|
|
|
- kw := sr.KW[i]
|
|
|
|
- //qu.Debug("-------------------------开始关键词匹配--------------------------")
|
|
|
|
- IsMatchKey := RegMatch(fieldText, kw.MatchType, kw.KeyReg, matchKey, matchKeyType, true, false)
|
|
|
|
- //qu.Debug(IsMatchKey, "------------------------------------------------------------")
|
|
|
|
- if IsMatchKey {
|
|
|
|
- IsMatch = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if len(sr.AW) == 0 {
|
|
|
|
- IsMatch = true
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- 到此已经匹配完数据
|
|
|
|
- */
|
|
|
|
- qu.Debug("---------------------", id, IsMatch, matchKey)
|
|
|
|
- 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
|
|
|
|
- tmpBuyerClass := qu.ObjToString(tmp["buyerclass"])
|
|
|
|
-
|
|
|
|
- //开始打标签
|
|
|
|
- //qu.Debug("c.IsTagRule+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
|
|
|
- if c.IsTagRule {
|
|
|
|
- tagNameMap := map[string]bool{}
|
|
|
|
- tagIdMap := map[string]bool{}
|
|
|
|
- //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
- //log.Println(c.TagRules,"=========",)
|
|
|
|
- for _, tr := range c.TagRules {
|
|
|
|
- if tr.DepartRuleIds[sr.ID] {
|
|
|
|
- // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
- //先获取用到的所有字段值
|
|
|
|
- for field, _ := range tr.Fields {
|
|
|
|
- if fieldText[field] == nil { //补充fieldText
|
|
|
|
- text := qu.ObjToString(tmp[field])
|
|
|
|
- text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
- fieldText[field] = text
|
|
|
|
- }
|
|
|
|
|
|
+ tmp["matchkey"], tmp["matchtype"] = GetMactchKeys(sr.Maths, tmp)
|
|
|
|
+ tmp["ruleid"] = sr.ID
|
|
|
|
+ tmp["rulename"] = sr.Name
|
|
|
|
+ tmpBuyerClass := qu.ObjToString(tmp["buyerclass"])
|
|
|
|
+ //开始打标签
|
|
|
|
+ if c.IsTagRule {
|
|
|
|
+ tagNameMap := map[string]bool{}
|
|
|
|
+ tagIdMap := map[string]bool{}
|
|
|
|
+ //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
+ //log.Println(c.TagRules,"=========",)
|
|
|
|
+ for _, tr := range c.TagRules {
|
|
|
|
+ if tr.DepartRuleIds[sr.ID] {
|
|
|
|
+ // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
+ //先获取用到的所有字段值
|
|
|
|
+ for field, _ := range tr.Fields {
|
|
|
|
+ if fieldText[field] == nil { //补充fieldText
|
|
|
|
+ text := qu.ObjToString(tmp[field])
|
|
|
|
+ text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
+ fieldText[field] = text
|
|
}
|
|
}
|
|
- //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
- //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
- matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
- matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
- for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
- IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
- //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
- if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
- // log.Println(j, tr.TagNames[j])
|
|
|
|
- if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
- tagname := tr.TagNames[j]
|
|
|
|
- tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
- if tagBuyerClass != "" {
|
|
|
|
- if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
|
|
- if tagname == "" {
|
|
|
|
- tempList := []string{}
|
|
|
|
- for k, _ := range matchKeyTag {
|
|
|
|
- tempList = append(tempList, k)
|
|
|
|
- }
|
|
|
|
- tagname = strings.Join(tempList, ",")
|
|
|
|
- log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
- }
|
|
|
|
- //qu.Debug("tagname-----", tagname)
|
|
|
|
- tagNameMap[tagname] = true
|
|
|
|
- tagIdMap[tr.ID] = true
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
+ //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
+ matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
+ matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
+ for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
+ IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
+ //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
+ if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
+ // log.Println(j, tr.TagNames[j])
|
|
|
|
+ if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
+ tagname := tr.TagNames[j]
|
|
|
|
+ tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
+ if tagBuyerClass != "" {
|
|
|
|
+ if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
if tagname == "" {
|
|
if tagname == "" {
|
|
tempList := []string{}
|
|
tempList := []string{}
|
|
for k, _ := range matchKeyTag {
|
|
for k, _ := range matchKeyTag {
|
|
@@ -605,68 +543,68 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
tagNameMap[tagname] = true
|
|
tagNameMap[tagname] = true
|
|
tagIdMap[tr.ID] = true
|
|
tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ if tagname == "" {
|
|
|
|
+ tempList := []string{}
|
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
|
+ tempList = append(tempList, k)
|
|
|
|
+ }
|
|
|
|
+ tagname = strings.Join(tempList, ",")
|
|
|
|
+ log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("tagname-----", tagname)
|
|
|
|
+ tagNameMap[tagname] = true
|
|
|
|
+ tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //tagname
|
|
|
|
- tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
- tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
- if len(tagNameArr) > 0 {
|
|
|
|
- tmp["tagname"] = strings.Join(tagNameArr, ",")
|
|
|
|
- if DisPackageAppidMap[c.AppId] {
|
|
|
|
- tmp["buyer_type"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- if c.PushModel == 2 {
|
|
|
|
- tmp["item"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- tmp["tagid"] = strings.Join(tagIdArr, ",")
|
|
|
|
|
|
+ }
|
|
|
|
+ //tagname
|
|
|
|
+ tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
+ tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
+ if len(tagNameArr) > 0 {
|
|
|
|
+ tmp["tagname"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ if DisPackageAppidMap[c.AppId] {
|
|
|
|
+ tmp["buyer_type"] = strings.Join(tagNameArr, ",")
|
|
}
|
|
}
|
|
|
|
+ if c.PushModel == 2 {
|
|
|
|
+ tmp["item"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ }
|
|
|
|
+ tmp["tagid"] = strings.Join(tagIdArr, ",")
|
|
}
|
|
}
|
|
- if c.IsTagRule2 {
|
|
|
|
- tagNameMap := map[string]bool{}
|
|
|
|
- tagIdMap := map[string]bool{}
|
|
|
|
- //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
- //log.Println(c.TagRules,"=========",)
|
|
|
|
- for _, tr := range c.TagRules2 {
|
|
|
|
- if tr.DepartRuleIds[sr.ID] {
|
|
|
|
- // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
- //先获取用到的所有字段值
|
|
|
|
- for field, _ := range tr.Fields {
|
|
|
|
- if fieldText[field] == nil { //补充fieldText
|
|
|
|
- text := qu.ObjToString(tmp[field])
|
|
|
|
- text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
- fieldText[field] = text
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ if c.IsTagRule2 {
|
|
|
|
+ tagNameMap := map[string]bool{}
|
|
|
|
+ tagIdMap := map[string]bool{}
|
|
|
|
+ //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
+ //log.Println(c.TagRules,"=========",)
|
|
|
|
+ for _, tr := range c.TagRules2 {
|
|
|
|
+ if tr.DepartRuleIds[sr.ID] {
|
|
|
|
+ // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
+ //先获取用到的所有字段值
|
|
|
|
+ for field, _ := range tr.Fields {
|
|
|
|
+ if fieldText[field] == nil { //补充fieldText
|
|
|
|
+ text := qu.ObjToString(tmp[field])
|
|
|
|
+ text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
+ fieldText[field] = text
|
|
}
|
|
}
|
|
- //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
- //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
- matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
- matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
- for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
- IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
- //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
- if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
- // log.Println(j, tr.TagNames[j])
|
|
|
|
- if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
- tagname := tr.TagNames[j]
|
|
|
|
- tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
- if tagBuyerClass != "" {
|
|
|
|
- if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
|
|
- if tagname == "" {
|
|
|
|
- tempList := []string{}
|
|
|
|
- for k, _ := range matchKeyTag {
|
|
|
|
- tempList = append(tempList, k)
|
|
|
|
- }
|
|
|
|
- tagname = strings.Join(tempList, ",")
|
|
|
|
- log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
- }
|
|
|
|
- //qu.Debug("tagname-----", tagname)
|
|
|
|
- tagNameMap[tagname] = true
|
|
|
|
- tagIdMap[tr.ID] = true
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
+ //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
+ matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
+ matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
+ for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
+ IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
+ //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
+ if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
+ // log.Println(j, tr.TagNames[j])
|
|
|
|
+ if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
+ tagname := tr.TagNames[j]
|
|
|
|
+ tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
+ if tagBuyerClass != "" {
|
|
|
|
+ if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
if tagname == "" {
|
|
if tagname == "" {
|
|
tempList := []string{}
|
|
tempList := []string{}
|
|
for k, _ := range matchKeyTag {
|
|
for k, _ := range matchKeyTag {
|
|
@@ -679,126 +617,136 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
tagNameMap[tagname] = true
|
|
tagNameMap[tagname] = true
|
|
tagIdMap[tr.ID] = true
|
|
tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ if tagname == "" {
|
|
|
|
+ tempList := []string{}
|
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
|
+ tempList = append(tempList, k)
|
|
|
|
+ }
|
|
|
|
+ tagname = strings.Join(tempList, ",")
|
|
|
|
+ log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("tagname-----", tagname)
|
|
|
|
+ tagNameMap[tagname] = true
|
|
|
|
+ tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //tagname
|
|
|
|
- tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
- tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
- if len(tagNameArr) > 0 {
|
|
|
|
- tmp["tagname2"] = strings.Join(tagNameArr, ",")
|
|
|
|
- if DisPackageAppidMap[c.AppId] {
|
|
|
|
- tmp["buyer_type2"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- if c.PushModel == 2 {
|
|
|
|
- tmp["item2"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- tmp["tagid2"] = strings.Join(tagIdArr, ",")
|
|
|
|
|
|
+ }
|
|
|
|
+ //tagname
|
|
|
|
+ tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
+ tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
+ if len(tagNameArr) > 0 {
|
|
|
|
+ tmp["tagname2"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ if DisPackageAppidMap[c.AppId] {
|
|
|
|
+ tmp["buyer_type2"] = strings.Join(tagNameArr, ",")
|
|
}
|
|
}
|
|
|
|
+ if c.PushModel == 2 {
|
|
|
|
+ tmp["item2"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ }
|
|
|
|
+ tmp["tagid2"] = strings.Join(tagIdArr, ",")
|
|
}
|
|
}
|
|
- if c.IsTagRule3 {
|
|
|
|
- tagNameMap := map[string]bool{}
|
|
|
|
- tagIdMap := map[string]bool{}
|
|
|
|
- //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
- //log.Println(c.TagRules,"=========",)
|
|
|
|
- for _, tr := range c.TagRules3 {
|
|
|
|
- if tr.DepartRuleIds[sr.ID] {
|
|
|
|
- // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
- //先获取用到的所有字段值
|
|
|
|
- for field, _ := range tr.Fields {
|
|
|
|
- if fieldText[field] == nil { //补充fieldText
|
|
|
|
- text := qu.ObjToString(tmp[field])
|
|
|
|
- text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
- fieldText[field] = text
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ if c.IsTagRule3 {
|
|
|
|
+ tagNameMap := map[string]bool{}
|
|
|
|
+ tagIdMap := map[string]bool{}
|
|
|
|
+ //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
|
+ //log.Println(c.TagRules,"=========",)
|
|
|
|
+ for _, tr := range c.TagRules3 {
|
|
|
|
+ if tr.DepartRuleIds[sr.ID] {
|
|
|
|
+ // log.Println(tr.TagNames, "===========打标签")
|
|
|
|
+ //先获取用到的所有字段值
|
|
|
|
+ for field, _ := range tr.Fields {
|
|
|
|
+ if fieldText[field] == nil { //补充fieldText
|
|
|
|
+ text := qu.ObjToString(tmp[field])
|
|
|
|
+ text = ProcessData(text) //处理文本(字母转大写,删除一些符号)
|
|
|
|
+ fieldText[field] = text
|
|
}
|
|
}
|
|
- //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
- //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
- matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
- matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
- for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
- IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
- //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
- if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
- // log.Println(j, tr.TagNames[j])
|
|
|
|
- if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
- tagname := tr.TagNames[j]
|
|
|
|
- tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
- if tagBuyerClass != "" {
|
|
|
|
- if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
|
|
- if tagname == "" {
|
|
|
|
- tempList := []string{}
|
|
|
|
- for k, _ := range matchKeyTag {
|
|
|
|
- tempList = append(tempList, k)
|
|
|
|
- }
|
|
|
|
- tagname = strings.Join(tempList, ",")
|
|
|
|
- log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
- }
|
|
|
|
- //qu.Debug("tagname-----", tagname)
|
|
|
|
- tagNameMap[tagname] = true
|
|
|
|
- tagIdMap[tr.ID] = true
|
|
|
|
|
|
+ }
|
|
|
|
+ //qu.Debug("-------------------------开始排除词匹配--------------------------")
|
|
|
|
+ //qu.Debug("tr.NW---", len(tr.NW))
|
|
|
|
+ matchKeyTag := map[string]bool{} //记录所有标签里的匹配上的关键词
|
|
|
|
+ matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
|
|
|
|
+ for j, tag_nw := range tr.NW { //排除词匹配
|
|
|
|
+ IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
|
|
|
|
+ //qu.Debug(IsMatchNotKey, "------------------------------------------------------------")
|
|
|
|
+ if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
|
|
|
|
+ // log.Println(j, tr.TagNames[j])
|
|
|
|
+ if RegMatch(fieldText, tr.AW[j].MatchType, tr.AW[j].KeyReg, nil, nil, false, true) && RegMatch(fieldText, tr.KW[j].MatchType, tr.KW[j].KeyReg, matchKeyTag, matchKeyTypeTag, true, false) {
|
|
|
|
+ tagname := tr.TagNames[j]
|
|
|
|
+ tagBuyerClass := tr.BuyerClass[j]
|
|
|
|
+ if tagBuyerClass != "" {
|
|
|
|
+ if strings.Contains(tagBuyerClass, tmpBuyerClass) {
|
|
|
|
+ tempList := []string{}
|
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
|
+ tempList = append(tempList, k)
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
if tagname == "" {
|
|
if tagname == "" {
|
|
- tempList := []string{}
|
|
|
|
- for k, _ := range matchKeyTag {
|
|
|
|
- tempList = append(tempList, k)
|
|
|
|
- }
|
|
|
|
tagname = strings.Join(tempList, ",")
|
|
tagname = strings.Join(tempList, ",")
|
|
log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
}
|
|
}
|
|
- //qu.Debug("tagname-----", tagname)
|
|
|
|
|
|
+ tmp["tagkey3"] = strings.Join(tempList, ",")
|
|
tagNameMap[tagname] = true
|
|
tagNameMap[tagname] = true
|
|
tagIdMap[tr.ID] = true
|
|
tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ tempList := []string{}
|
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
|
+ tempList = append(tempList, k)
|
|
|
|
+ }
|
|
|
|
+ if tagname == "" {
|
|
|
|
+ tagname = strings.Join(tempList, ",")
|
|
|
|
+ log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
|
+ }
|
|
|
|
+ tmp["tagkey3"] = strings.Join(tempList, ",")
|
|
|
|
+ tagNameMap[tagname] = true
|
|
|
|
+ tagIdMap[tr.ID] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //tagname
|
|
|
|
- tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
- tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
- if len(tagNameArr) > 0 {
|
|
|
|
- tmp["tagname3"] = strings.Join(tagNameArr, ",")
|
|
|
|
- if DisPackageAppidMap[c.AppId] {
|
|
|
|
- tmp["buyer_type3"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- if c.PushModel == 2 {
|
|
|
|
- tmp["item3"] = strings.Join(tagNameArr, ",")
|
|
|
|
- }
|
|
|
|
- tmp["tagid3"] = strings.Join(tagIdArr, ",")
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- //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
|
|
|
|
|
|
+ //tagname
|
|
|
|
+ tagNameArr := MapDataToArr(tagNameMap)
|
|
|
|
+ tagIdArr := MapDataToArr(tagIdMap)
|
|
|
|
+ if len(tagNameArr) > 0 {
|
|
|
|
+ tmp["tagname3"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ if DisPackageAppidMap[c.AppId] {
|
|
|
|
+ tmp["buyer_type3"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ }
|
|
|
|
+ if c.PushModel == 2 {
|
|
|
|
+ tmp["item3"] = strings.Join(tagNameArr, ",")
|
|
|
|
+ }
|
|
|
|
+ tmp["tagid3"] = strings.Join(tagIdArr, ",")
|
|
}
|
|
}
|
|
- //appid
|
|
|
|
- tmp["appid"] = c.AppId
|
|
|
|
- //部门名称
|
|
|
|
- tmp["departname"] = dm.Name
|
|
|
|
- tmp["departid"] = dm.ID
|
|
|
|
- //存储数据
|
|
|
|
- dm.DataLock.Lock()
|
|
|
|
- //qu.Debug("tmp---", tmp)
|
|
|
|
- tmpMap := map[string]interface{}{id: tmp}
|
|
|
|
- dm.DepartmentData[sr.ID] = append(dm.DepartmentData[sr.ID], tmpMap)
|
|
|
|
- dm.DataLock.Unlock()
|
|
|
|
- } else {
|
|
|
|
- qu.Debug("------------", id, IsMatch)
|
|
|
|
}
|
|
}
|
|
|
|
+ //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()
|
|
|
|
+ //qu.Debug("tmp---", tmp)
|
|
|
|
+ tmpMap := map[string]interface{}{id: tmp}
|
|
|
|
+ dm.DepartmentData[sr.ID] = append(dm.DepartmentData[sr.ID], tmpMap)
|
|
|
|
+ dm.DataLock.Unlock()
|
|
}
|
|
}
|
|
numDocs += 1
|
|
numDocs += 1
|
|
if numDocs%500 == 0 {
|
|
if numDocs%500 == 0 {
|
|
@@ -1092,38 +1040,39 @@ func (tr *TagRule) GetKeyAddNotKeyWord(o_list primitive.A) {
|
|
tr.BuyerClass = buyerclass
|
|
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{}
|
|
keyWord := []string{}
|
|
|
|
+ keyType := []string{}
|
|
for _, keys := range match {
|
|
for _, keys := range match {
|
|
types := keys["s_keymatch"]
|
|
types := keys["s_keymatch"]
|
|
key := keys["s_matchkey"]
|
|
key := keys["s_matchkey"]
|
|
if strings.Contains(types, "1") {
|
|
if strings.Contains(types, "1") {
|
|
title := qu.ObjToString(data["title"])
|
|
title := qu.ObjToString(data["title"])
|
|
- keyWord = KeyWordToDatas(types, title, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, title, key, keyWord, keyType, "title")
|
|
}
|
|
}
|
|
if strings.Contains(types, "2") {
|
|
if strings.Contains(types, "2") {
|
|
detail := qu.ObjToString(data["detail"])
|
|
detail := qu.ObjToString(data["detail"])
|
|
- keyWord = KeyWordToDatas(types, detail, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, detail, key, keyWord, keyType, "detail")
|
|
}
|
|
}
|
|
if strings.Contains(types, "3") {
|
|
if strings.Contains(types, "3") {
|
|
purchasing := qu.ObjToString(data["purchasing"])
|
|
purchasing := qu.ObjToString(data["purchasing"])
|
|
- keyWord = KeyWordToDatas(types, purchasing, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, purchasing, key, keyWord, keyType, "purchasing")
|
|
}
|
|
}
|
|
if strings.Contains(types, "4") {
|
|
if strings.Contains(types, "4") {
|
|
filetext := qu.ObjToString(data["filetext"])
|
|
filetext := qu.ObjToString(data["filetext"])
|
|
- keyWord = KeyWordToDatas(types, filetext, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, filetext, key, keyWord, keyType, "filetext")
|
|
}
|
|
}
|
|
if strings.Contains(types, "5") {
|
|
if strings.Contains(types, "5") {
|
|
projectname := qu.ObjToString(data["projectname"])
|
|
projectname := qu.ObjToString(data["projectname"])
|
|
- keyWord = KeyWordToDatas(types, projectname, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, projectname, key, keyWord, keyType, "projectname")
|
|
}
|
|
}
|
|
if strings.Contains(types, "6") || strings.Contains(types, "8") {
|
|
if strings.Contains(types, "6") || strings.Contains(types, "8") {
|
|
buyer := qu.ObjToString(data["buyer"])
|
|
buyer := qu.ObjToString(data["buyer"])
|
|
- keyWord = KeyWordToDatas(types, buyer, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, buyer, key, keyWord, keyType, "buyer")
|
|
}
|
|
}
|
|
if strings.Contains(types, "7") || strings.Contains(types, "9") {
|
|
if strings.Contains(types, "7") || strings.Contains(types, "9") {
|
|
winner := qu.ObjToString(data["s_winner"])
|
|
winner := qu.ObjToString(data["s_winner"])
|
|
- keyWord = KeyWordToDatas(types, winner, key, keyWord)
|
|
|
|
|
|
+ keyWord, keyType = KeyWordToDatas(types, winner, key, keyWord, keyType, "s_winner")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
keyMap := map[string]bool{}
|
|
keyMap := map[string]bool{}
|
|
@@ -1134,10 +1083,10 @@ func GetMactchKeys(match []map[string]string, data map[string]interface{}) strin
|
|
for k, _ := range keyMap {
|
|
for k, _ := range keyMap {
|
|
keyArr = append(keyArr, k)
|
|
keyArr = append(keyArr, k)
|
|
}
|
|
}
|
|
- return strings.Join(keyArr, ",")
|
|
|
|
|
|
+ return strings.Join(keyArr, ","), strings.Join(keyType, ",")
|
|
}
|
|
}
|
|
|
|
|
|
-func KeyWordToDatas(types, item, key string, keyWord []string) []string {
|
|
|
|
|
|
+func KeyWordToDatas(types, item, key string, keyWord []string, keyType []string, tag string) ([]string, []string) {
|
|
for _, mk := range strings.Split(key, ",") {
|
|
for _, mk := range strings.Split(key, ",") {
|
|
if strings.Contains(mk, "&&") {
|
|
if strings.Contains(mk, "&&") {
|
|
arr := strings.Split(mk, "&&")
|
|
arr := strings.Split(mk, "&&")
|
|
@@ -1151,14 +1100,16 @@ func KeyWordToDatas(types, item, key string, keyWord []string) []string {
|
|
}
|
|
}
|
|
if isok {
|
|
if isok {
|
|
keyWord = append(keyWord, mk)
|
|
keyWord = append(keyWord, mk)
|
|
|
|
+ keyType = append(keyWord, tag)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if strings.Contains(strings.ToUpper(item), strings.ToUpper(mk)) {
|
|
if strings.Contains(strings.ToUpper(item), strings.ToUpper(mk)) {
|
|
keyWord = append(keyWord, mk)
|
|
keyWord = append(keyWord, mk)
|
|
|
|
+ keyType = append(keyWord, tag)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return keyWord
|
|
|
|
|
|
+ return keyWord, keyType
|
|
}
|
|
}
|
|
|
|
|
|
func exactMatchs(rule, title, detail string, match []map[string]string, nameArr []string) bool {
|
|
func exactMatchs(rule, title, detail string, match []map[string]string, nameArr []string) bool {
|