|
@@ -89,7 +89,7 @@ func GetCustomerData() {
|
|
|
cus.GetTagRules() //获取客户打标签规则
|
|
|
cus.GetDepartments("") //获取客户信息
|
|
|
//PrintLog(cus) //打印查看初始化的信息
|
|
|
- //qu.Debug("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.Departments))
|
|
|
+ qu.Debug("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsTagRule2, cus.IsTagRule3, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.TagRules2), len(cus.TagRules3), len(cus.Departments))
|
|
|
cus.GetData("") //获取数据
|
|
|
cus.RemoveRepeatData() //数据去重
|
|
|
cus.AssembelAndSaveData() //组装、保存数据
|
|
@@ -106,8 +106,36 @@ func (c *Customer) GetTagRules() {
|
|
|
defer qu.Catch()
|
|
|
tagRules, _ := MgoTag.Find("eusertagrule", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false}, nil, nil)
|
|
|
if len(tagRules) > 0 {
|
|
|
- c.IsTagRule = true //查到打标签规则,表示打标签
|
|
|
for _, tr := range tagRules {
|
|
|
+ tagType := qu.ObjToString(tr["tagType"])
|
|
|
+ if tagType == "" || tagType == "1" {
|
|
|
+ c.IsTagRule = true //查到打标签规则,表示打标签
|
|
|
+ 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.TagRules = append(c.TagRules, TR)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tagRules2, _ := MgoTag.Find("eusertagrule", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false, "tagType": "2"}, nil, nil)
|
|
|
+ if len(tagRules2) > 0 {
|
|
|
+ c.IsTagRule2 = true //查到打标签规则,表示打标签
|
|
|
+ for _, tr := range tagRules2 {
|
|
|
TR := &TagRule{}
|
|
|
TR.Fields = make(map[string]interface{})
|
|
|
TR.DepartRuleIds = make(map[string]bool)
|
|
@@ -126,7 +154,32 @@ func (c *Customer) GetTagRules() {
|
|
|
if o_list, ok := tr["o_list"].(primitive.A); ok && len(o_list) > 0 {
|
|
|
TR.GetKeyAddNotKeyWord(o_list)
|
|
|
}
|
|
|
- c.TagRules = append(c.TagRules, TR)
|
|
|
+ c.TagRules2 = append(c.TagRules2, TR)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tagRules3, _ := MgoTag.Find("eusertagrule", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false, "tagType": "3"}, nil, nil)
|
|
|
+ if len(tagRules3) > 0 {
|
|
|
+ c.IsTagRule3 = true //查到打标签规则,表示打标签
|
|
|
+ for _, tr := range tagRules3 {
|
|
|
+ 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.TagRules3 = append(c.TagRules3, TR)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -476,6 +529,154 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
|
|
|
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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //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 {
|
|
|
+ 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, ",")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ } 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["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:
|