|
@@ -20,6 +20,7 @@ type HistoryData struct {
|
|
|
historyClone xweb.Mapper `xweb:"/service/historyClone/(.*)"`
|
|
|
historyRuleEdit xweb.Mapper `xweb:"/service/historyRule/edit"`
|
|
|
productData xweb.Mapper `xweb:"/service/history/produce"` //历史数据生成预览数据
|
|
|
+ dataTest xweb.Mapper `xweb:"/service/dataTest/(.*)"`
|
|
|
}
|
|
|
|
|
|
func (this *HistoryData) HistoryTask(history_id string) {
|
|
@@ -238,3 +239,117 @@ func (this *HistoryData) ProductData() {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func (this *HistoryData) DataTest(id string) {
|
|
|
+ log.Println("测试数据是否匹配开始...")
|
|
|
+ dataId := this.GetString("id")
|
|
|
+ log.Println("id", id)
|
|
|
+ log.Println("dataId", dataId)
|
|
|
+ //加载一个客户
|
|
|
+ customer, _ := Mgo.Find("cuserdepartrule", map[string]interface{}{"_id": mongoutil.StringTOBsonId(id)}, nil, nil, false, -1, -1)
|
|
|
+ if len(*customer) == 1 {
|
|
|
+ c := (*customer)[0]
|
|
|
+ tmps := Es.GetByIdField(Index, Itype, dataId, "")
|
|
|
+ tmp := map[string]interface{}{}
|
|
|
+ if tmps != nil {
|
|
|
+ tmp = *tmps
|
|
|
+ }
|
|
|
+ if len(tmp) == 0 {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "info": "没有查到此数据",
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ s_globaladdkey := qu.ObjToString(c["s_globaladdkey"])
|
|
|
+ s_globaladdkeymatch := qu.ObjToString(c["s_globaladdkeymatch"])
|
|
|
+ s_globalnotkey := qu.ObjToString(c["s_globalnotkey"])
|
|
|
+ s_globalnotkeymatch := qu.ObjToString(c["s_globalnotkeymatch"])
|
|
|
+ // s_globalclearkey := qu.ObjToString(c["s_globalclearkey"])
|
|
|
+ // s_globalclearkeymatch := qu.ObjToString(c["s_globalclearkeymatch"])
|
|
|
+ o_rule, ok := c["o_rules"].([]interface{})
|
|
|
+ if !ok {
|
|
|
+ o_rule = []interface{}{}
|
|
|
+ }
|
|
|
+ o_rules := qu.ObjArrToMapArr(o_rule)
|
|
|
+ matchKey := ""
|
|
|
+ //
|
|
|
+ if s_globaladdkey != "" {
|
|
|
+ gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, tmp)
|
|
|
+ if gKey == "" {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "info": "全局附加词没有匹配成功",
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ matchKey = gKey
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if s_globalnotkey != "" {
|
|
|
+ gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, tmp)
|
|
|
+ if gNKey != "" {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "allexcluedKey": gNKey,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range o_rules {
|
|
|
+ key := qu.ObjToString(v["s_matchkey"])
|
|
|
+ keymatch := qu.ObjToString(v["s_keymatch"])
|
|
|
+ addkey := qu.ObjToString(v["s_addkey"])
|
|
|
+ addkeymatch := qu.ObjToString(v["s_addkeymatch"])
|
|
|
+ notkey := qu.ObjToString(v["s_notkey"])
|
|
|
+ notkeymatch := qu.ObjToString(v["s_notkeymatch"])
|
|
|
+ if notkey != "" {
|
|
|
+ nKey := TestMactchKeys(notkeymatch, notkey, tmp)
|
|
|
+ if nKey != "" {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "excluedKey": nKey,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if key != "" {
|
|
|
+ sKey := TestMactchKeys(keymatch, key, tmp)
|
|
|
+ aKey := ""
|
|
|
+ if addkey != "" {
|
|
|
+ aKey = TestMactchKeys(addkeymatch, addkey, tmp)
|
|
|
+ if aKey != "" && sKey != "" {
|
|
|
+ if matchKey != "" {
|
|
|
+ matchKey += ","
|
|
|
+ }
|
|
|
+ matchKey = aKey + "," + sKey
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if sKey != "" {
|
|
|
+ if matchKey != "" {
|
|
|
+ matchKey += ","
|
|
|
+ }
|
|
|
+ matchKey = sKey
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if matchKey == "" {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "info": "没有匹配成功",
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.ServeJson(map[string]interface{}{
|
|
|
+ "result": true,
|
|
|
+ "matchKey": matchKey,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ log.Println("初始化客户信息失败")
|
|
|
+ }
|
|
|
+ log.Println("测试数据是否匹配结束...")
|
|
|
+}
|