|
@@ -256,6 +256,56 @@ func (c *Customer) GetTagRules() {
|
|
|
c.TagRules3 = append(c.TagRules3, TR)
|
|
|
}
|
|
|
}
|
|
|
+ tagRules4, _ := MgoTag.Find("eusertagrule", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false, "tagType": "4"}, nil, nil)
|
|
|
+ if len(tagRules4) > 0 {
|
|
|
+ c.IsTagRule4 = true //查到打标签规则,表示打标签
|
|
|
+ for _, tr := range tagRules4 {
|
|
|
+ TR := &TagRule{}
|
|
|
+ TR.Fields = make(map[string]interface{})
|
|
|
+ TR.DepartRuleIds = make(map[string]bool)
|
|
|
+ id := mgoutil.BsonTOStringId(tr["_id"])
|
|
|
+ name := qu.ObjToString(tr["s_name"])
|
|
|
+ TR.ID = id
|
|
|
+ TR.Name = name
|
|
|
+ TR.CustomerId = c.ID
|
|
|
+ //部门规则id组
|
|
|
+ if departRuleIds := qu.ObjToString(tr["o_departruleids"]); departRuleIds != "" {
|
|
|
+ for _, drid := range strings.Split(departRuleIds, ",") {
|
|
|
+ TR.DepartRuleIds[drid] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //规则
|
|
|
+ if o_list, ok := tr["o_list"].(primitive.A); ok && len(o_list) > 0 {
|
|
|
+ TR.GetKeyAddNotKeyWord(o_list)
|
|
|
+ }
|
|
|
+ c.TagRules4 = append(c.TagRules4, TR)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tagRules5, _ := MgoTag.Find("eusertagrule", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false, "tagType": "5"}, nil, nil)
|
|
|
+ if len(tagRules5) > 0 {
|
|
|
+ c.IsTagRule5 = true //查到打标签规则,表示打标签
|
|
|
+ for _, tr := range tagRules5 {
|
|
|
+ TR := &TagRule{}
|
|
|
+ TR.Fields = make(map[string]interface{})
|
|
|
+ TR.DepartRuleIds = make(map[string]bool)
|
|
|
+ id := mgoutil.BsonTOStringId(tr["_id"])
|
|
|
+ name := qu.ObjToString(tr["s_name"])
|
|
|
+ TR.ID = id
|
|
|
+ TR.Name = name
|
|
|
+ TR.CustomerId = c.ID
|
|
|
+ //部门规则id组
|
|
|
+ if departRuleIds := qu.ObjToString(tr["o_departruleids"]); departRuleIds != "" {
|
|
|
+ for _, drid := range strings.Split(departRuleIds, ",") {
|
|
|
+ TR.DepartRuleIds[drid] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //规则
|
|
|
+ if o_list, ok := tr["o_list"].(primitive.A); ok && len(o_list) > 0 {
|
|
|
+ TR.GetKeyAddNotKeyWord(o_list)
|
|
|
+ }
|
|
|
+ c.TagRules5 = append(c.TagRules5, TR)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取部门信息
|
|
@@ -290,7 +340,7 @@ func (c *Customer) GetData(stype string) {
|
|
|
if esversion == "v1" {
|
|
|
} else {
|
|
|
if stype == "high" {
|
|
|
- esCon := Es2.(*esv.EsV7)
|
|
|
+ esCon := Es.(*esv.EsV7)
|
|
|
c.EsConGetDataV7(stype, esCon)
|
|
|
} else {
|
|
|
esCon := Es.(*esv.EsV7)
|
|
@@ -335,8 +385,8 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
|
esindex := Index
|
|
|
escount := int64(0)
|
|
|
if stype == "high" {
|
|
|
- esindex = "bidding_ai"
|
|
|
- escount = Es2.Count(esindex, Itype, sr.EsQuery)
|
|
|
+ // esindex = "bidding"
|
|
|
+ escount = Es.Count(esindex, Itype, sr.EsQuery)
|
|
|
} else {
|
|
|
escount = Es.Count(esindex, Itype, sr.EsQuery)
|
|
|
}
|
|
@@ -473,7 +523,9 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
|
fieldText[field] = text
|
|
|
}
|
|
|
//清理词清理
|
|
|
+ isClear := false
|
|
|
for _, cwm := range sr.GCW.MatchType {
|
|
|
+ isClear = true
|
|
|
if text := qu.ObjToString(fieldText[cwm]); text != "" {
|
|
|
for _, gcw_reg := range sr.GCW.KeyReg {
|
|
|
text = gcw_reg.ReplaceAllString(text, "")
|
|
@@ -496,7 +548,12 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
- tmp["matchkey"], tmp["matchtype"] = GetMactchKeys(sr.Maths, tmp)
|
|
|
+ matchkey, matchtype := GetMactchKeys(sr.Maths, fieldText)
|
|
|
+ if matchkey == "" && isClear {
|
|
|
+ qu.Debug("-------------------二次匹配失败", id)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ tmp["matchkey"], tmp["matchtype"] = matchkey, matchtype
|
|
|
tmp["ruleid"] = sr.ID
|
|
|
tmp["rulename"] = sr.Name
|
|
|
tmpBuyerClass := qu.ObjToString(tmp["buyerclass"])
|
|
@@ -723,6 +780,154 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
|
tmp["tagid3"] = strings.Join(tagIdArr, ",")
|
|
|
}
|
|
|
}
|
|
|
+ if c.IsTagRule4 {
|
|
|
+ tagNameMap := map[string]bool{}
|
|
|
+ tagIdMap := map[string]bool{}
|
|
|
+ //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
+ //log.Println(c.TagRules,"=========",)
|
|
|
+ for _, tr := range c.TagRules4 {
|
|
|
+ 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) {
|
|
|
+ tempList := []string{}
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
+ tempList = append(tempList, k)
|
|
|
+ }
|
|
|
+ if tagname == "" {
|
|
|
+ tagname = strings.Join(tempList, ",")
|
|
|
+ log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
+ }
|
|
|
+ tmp["tagkey4"] = strings.Join(tempList, ",")
|
|
|
+ tagNameMap[tagname] = 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["tagkey4"] = strings.Join(tempList, ",")
|
|
|
+ tagNameMap[tagname] = true
|
|
|
+ tagIdMap[tr.ID] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //tagname
|
|
|
+ tagNameArr := MapDataToArr(tagNameMap)
|
|
|
+ tagIdArr := MapDataToArr(tagIdMap)
|
|
|
+ if len(tagNameArr) > 0 {
|
|
|
+ tmp["tagname4"] = strings.Join(tagNameArr, ",")
|
|
|
+ if DisPackageAppidMap[c.AppId] {
|
|
|
+ tmp["buyer_type4"] = strings.Join(tagNameArr, ",")
|
|
|
+ }
|
|
|
+ if c.PushModel == 2 {
|
|
|
+ tmp["item4"] = strings.Join(tagNameArr, ",")
|
|
|
+ }
|
|
|
+ tmp["tagid4"] = strings.Join(tagIdArr, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if c.IsTagRule5 {
|
|
|
+ tagNameMap := map[string]bool{}
|
|
|
+ tagIdMap := map[string]bool{}
|
|
|
+ //qu.Debug("c.TagRules---", len(c.TagRules))
|
|
|
+ //log.Println(c.TagRules,"=========",)
|
|
|
+ for _, tr := range c.TagRules5 {
|
|
|
+ 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) {
|
|
|
+ tempList := []string{}
|
|
|
+ for k, _ := range matchKeyTag {
|
|
|
+ tempList = append(tempList, k)
|
|
|
+ }
|
|
|
+ if tagname == "" {
|
|
|
+ tagname = strings.Join(tempList, ",")
|
|
|
+ log.Println("=====tagname为空取匹配词为标签名称", tagname)
|
|
|
+ }
|
|
|
+ tmp["tagkey5"] = strings.Join(tempList, ",")
|
|
|
+ tagNameMap[tagname] = 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["tagkey5"] = strings.Join(tempList, ",")
|
|
|
+ tagNameMap[tagname] = true
|
|
|
+ tagIdMap[tr.ID] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //tagname
|
|
|
+ tagNameArr := MapDataToArr(tagNameMap)
|
|
|
+ tagIdArr := MapDataToArr(tagIdMap)
|
|
|
+ if len(tagNameArr) > 0 {
|
|
|
+ tmp["tagname5"] = strings.Join(tagNameArr, ",")
|
|
|
+ if DisPackageAppidMap[c.AppId] {
|
|
|
+ tmp["buyer_type5"] = strings.Join(tagNameArr, ",")
|
|
|
+ }
|
|
|
+ if c.PushModel == 2 {
|
|
|
+ tmp["item5"] = strings.Join(tagNameArr, ",")
|
|
|
+ }
|
|
|
+ tmp["tagid5"] = strings.Join(tagIdArr, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
//item
|
|
|
switch c.PushModel {
|
|
|
case 0:
|