xuzhiheng 1 년 전
부모
커밋
22c3c5536d

+ 16 - 12
customerdata/src/datamodel.go

@@ -7,7 +7,7 @@ import (
 	"gopkg.in/mgo.v2/bson"
 )
 
-//客户模型
+// 客户模型
 type Customer struct {
 	ID           string                            //客户ID
 	Name         string                            //客户名称
@@ -15,9 +15,13 @@ type Customer struct {
 	PushModel    int                               //推送模式 0:全局模式;1:部门模式;2:标签模式;3:部门+标签模式;4:规则模式
 	Departments  []*Department                     //所有部门
 	IsTagRule    bool                              //是否打标签
+	IsTagRule2   bool                              //是否打标签
+	IsTagRule3   bool                              //是否打标签
 	IsSearchHosp bool                              //是否查询第三方医院信息
 	IsSearchEnps bool                              //是否查询第三方企业信息
 	TagRules     []*TagRule                        //打标签规则集合
+	TagRules2    []*TagRule                        //打标签规则集合
+	TagRules3    []*TagRule                        //打标签规则集合
 	SaveDataMap  map[string]map[string]interface{} //最终入库数据(全局模式)
 	SaveDataArr  map[string]map[string]interface{} //最终入库数据(规则模式)
 	IdRange      bson.M                            //由当前时间生成是id查询区间
@@ -26,7 +30,7 @@ type Customer struct {
 	Exact        int
 }
 
-//部门模型
+// 部门模型
 type Department struct {
 	ID             string                              //部门ID
 	Name           string                              //部门名称
@@ -37,7 +41,7 @@ type Department struct {
 	SaveDataMap    map[string]map[string]interface{}   //最终入库数据(部门内部去重)
 }
 
-//查询规则模型
+// 查询规则模型
 type SearchRule struct {
 	//一条查询规则
 	ID           string
@@ -54,7 +58,7 @@ type SearchRule struct {
 	ExactRule    string
 }
 
-//打标签规则模型
+// 打标签规则模型
 type TagRule struct {
 	//一条打标签规则
 	ID            string
@@ -71,13 +75,13 @@ type TagRule struct {
 	BuyerClass []string      //采购单位行业限制,每组关键词都有一个采购单位行业限制
 }
 
-//全局清理词类型
+// 全局清理词类型
 type ClearWord struct {
 	KeyReg    []*regexp.Regexp
 	MatchType []string //清理词匹配方式
 }
 
-//关键词类型
+// 关键词类型
 type KeyWord struct {
 	KeyReg    *Reg     //匹配规则(0:逗号分隔 1:&&分隔)      例如:[[智能,5G],[智慧交通,智慧城市]]
 	MatchType []string //关键词的匹配方式
@@ -87,7 +91,7 @@ type KeyWord struct {
 	//KeyWordMap []map[int]map[string]string //记录KeyReg中字母规则(0:逗号分隔 1:&&分隔)
 }
 
-//附加词类型
+// 附加词类型
 type AddWord struct {
 	KeyReg    *Reg     //匹配规则(0:逗号分隔 1:&&分隔)
 	MatchType []string //附加词的匹配方式
@@ -97,34 +101,34 @@ type AddWord struct {
 	//AddWordMap []map[int]map[string]string //记录KeyReg中字母规则(0:逗号分隔 1:&&分隔)
 }
 
-//排除词
+// 排除词
 type NotKeyWord struct {
 	KeyReg    *Reg     //例如:排除1&&排除2,排除3,KeyReg[0]存 排除3;KeyReg[1]存 排除1 排除2
 	MatchType []string //排除词的匹配方式
 	//NotWordMap []map[int]bool //记录KeyReg中字母规则
 }
 
-//匹配正则
+// 匹配正则
 type Reg struct {
 	CReg []*CommonReg //逗号分隔
 	AReg []*AndRegPre //&&分隔
 	//KeyStr []string     //原始值(用于含字母时取原值)
 }
 
-//逗号分隔正则
+// 逗号分隔正则
 type CommonReg struct {
 	CrVal    *regexp.Regexp //正则类型
 	CsVal    string         //原始值
 	IsLetter bool           //是否含字母
 }
 
-//&&分隔正则
+// &&分隔正则
 type AndRegPre struct {
 	AndRegKid []*AndReg
 	CsVal     string //原始值
 }
 
-//&&分隔正则
+// &&分隔正则
 type AndReg struct {
 	CrVal    *regexp.Regexp
 	IsLetter bool //是否含字母

+ 204 - 3
customerdata/src/task.go

@@ -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:

+ 1 - 1
src/history/historytask.go

@@ -154,7 +154,7 @@ func (this *HistoryData) HistoryTask(history_id string) {
 		dep_rules := qu.ObjArrToMapArr(dep_rule)
 		cus.GetTagRules(tag_rules, tag_rules2, tag_rules3) //获取客户打标签规则
 		cus.GetDepartments("history", dep_rules)           //获取客户信息
-		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("history", i_dataSource)                                                              //获取数据
 		cus.RemoveRepeatData()                                                                            //数据去重
 		cus.AssembelAndSaveData(history_id, isFilter, noticeFilter, dataTable, entId, iContact, xlsxData) //组装、保存数据

+ 1 - 0
src/history/task.go

@@ -471,6 +471,7 @@ func (c *Customer) EsConGetDataV7(stype string, dataSource int, esCon *esv.EsV7)
 												matchKeyTypeTag := map[string]bool{} //记录标签里的关键词对应的匹配方式
 												//qu.Debug("-------------------------开始排除词匹配--------------------------")
 												for j, tag_nw := range tr.NW { //排除词匹配
+													log.Println("打标签2222tag_nw ", tag_nw, fieldText)
 													IsMatchNotKey := RegMatch(fieldText, tag_nw.MatchType, tag_nw.KeyReg, nil, nil, false, false)
 													if !IsMatchNotKey { //排除词未匹配,匹配附加词关键词
 														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) {

+ 9 - 2
src/service/customer_service.go

@@ -1405,13 +1405,20 @@ func (c *Customer) HistoryTagAssociated() {
 	rule_id := c.GetString("_id")
 	tags := c.GetString("ids")
 	hid := c.GetString("hid")
+	tagtype := c.GetString("tagtype")
+	tagtypes := ""
+	if tagtype == "2" {
+		tagtypes = "2"
+	} else if tagtype == "3" {
+		tagtypes = "3"
+	}
 
 	if userid != "" {
 		user_info, _ := Mgo.FindOne("historylog", map[string]interface{}{
 			"_id": mongoutil.StringTOBsonId(hid),
 		})
 		if user_info != nil && *user_info != nil {
-			tagrules := (*user_info)["tag_rules"]
+			tagrules := (*user_info)["tag_rules"+tagtypes]
 			if tagrules != nil {
 				tagrulesArr := qu.ObjArrToMapArr(tagrules.([]interface{}))
 				for _, m := range tagrulesArr {
@@ -1421,7 +1428,7 @@ func (c *Customer) HistoryTagAssociated() {
 				}
 				set := bson.M{
 					"$set": bson.M{
-						"tag_rules": tagrulesArr,
+						"tag_rules" + tagtypes: tagrulesArr,
 					},
 				}
 				is_updata := Mgo.Update("historylog", map[string]interface{}{

+ 4 - 4
src/util/utiltag.go

@@ -216,9 +216,9 @@ func searchData(index, esquery, sdataid string, i_maxnum int64, tags map[string]
 			item := make(map[string]interface{})
 			if json.Unmarshal(v.Source, &item) == nil {
 				delete(item, "_id")
-				item["info_id"] = v.Id
+				item["info_id"] = util.ObjToString(item["id"])
 				item["s_dataid"] = sdataid
-				item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", v.Id))
+				item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", util.ObjToString(item["id"])))
 				item["i_createtime"] = time.Now().Unix()
 				var d *DFA = &DFA{}
 				var analyKeys []string //找到的关键词
@@ -485,9 +485,9 @@ func UtilEsFind2(tags map[string]interface{}, n int) (error, int64) {
 				item := make(map[string]interface{})
 				if json.Unmarshal(v.Source, &item) == nil {
 					delete(item, "_id")
-					item["info_id"] = v.Id
+					item["info_id"] = util.ObjToString(item["id"])
 					item["s_dataid"] = sdataid
-					item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", v.Id))
+					item["s_jyhref"] = fmt.Sprintf(Url, util.CommonEncodeArticle("content", util.ObjToString(item["id"])))
 					item["i_createtime"] = time.Now().Unix()
 					var d *DFA = &DFA{}
 					var analyKeys []string //找到的关键词

+ 6 - 4
src/web/templates/private/customer_edit.html

@@ -514,7 +514,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.s_userid]
+                        var s = [val, row.s_userid,"1"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -571,7 +571,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.s_userid]
+                        var s = [val, row.s_userid,"2"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -628,7 +628,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.s_userid]
+                        var s = [val, row.s_userid,"3"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\',\'' + row.o_departruleids + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -926,10 +926,12 @@
     }
 
     var tagid = ""
+    var tagType = ""
 
     //关联规则
     function associated(val, o_departruleids) {
         tagid = val.split(",")[0]
+        tagType = val.split(",")[2]
         var departRuleIds = o_departruleids.split(",")
         // console.log(departRuleIds)
         $('#cuserRule').DataTable({
@@ -991,7 +993,7 @@
         $.ajax({
             url: "/service/euser/tag/associated",
             type: "post",
-            data: {"_id": tagid, "ids": ids.join(",")},
+            data: {"_id": tagid, "ids": ids.join(","), "tagType": tagType},
             success: function (r) {
                 if (r.rep) {
                     // window.location.reload()

+ 5 - 4
src/web/templates/private/customer_history.html

@@ -783,7 +783,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.hid]
+                        var s = [val, row.hid, "1"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -841,7 +841,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.hid]
+                        var s = [val, row.hid, "2"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -899,7 +899,7 @@
                 },
                 {
                     "data": "_id", width: "11%", render: function (val, a, row, pos) {
-                        var s = [val, row.hid]
+                        var s = [val, row.hid, "3"]
                         tmp = '<div>' +
                             '<a class="btn btn-sm btn-primary" onclick="associated(\'' + s + '\')">关联数据范围</a>&nbsp&nbsp' +
                             '</div>';
@@ -1177,6 +1177,7 @@
     function saveTagrule() {
         var tag_rulesids = new Array()
         _id = tagid.split(",")[0];
+        var tagtype = tagid.split(",")[2];
         $(".associated_rule tr").each(function () {
             var tagchk = $(this).find('td').eq(1).find("#tag_id");
             if (tagchk.hasClass('checked')) {
@@ -1187,7 +1188,7 @@
         $.ajax({
             url: "/service/euser/historytag/associated",
             type: "post",
-            data: {"_id": _id, "ids": tag_rulesids.join(","), "userid": c_id, "hid": history_id},
+            data: {"_id": _id, "ids": tag_rulesids.join(","), "userid": c_id, "hid": history_id, "tagtype":tagtype},
             success: function (r) {
                 if (r.rep) {
                     // window.location.reload()