Просмотр исходного кода

Merge branch 'master' into feature/v1.0.3

* master:
  xg
  规则程序匹配

# Conflicts:
#	CMPlatform/history/task.go
Jianghan 6 месяцев назад
Родитель
Сommit
1115a2e72a

+ 10 - 7
CMPlatform/client/client.go

@@ -274,17 +274,20 @@ func (c *Client) SynEuser() {
 	departMap, _ := util.Mgo.Find("cuserdepart", bson.M{"s_userid": _id}, nil, nil, false, -1, -1)
 	//util.Mgo.SaveBulk("euserdepart", *departMap...)
 	for _, v := range *departMap {
-		id := v["_id"]
-		delete(v, "_id")
-		util.Mgo.Update("euserdepart", bson.M{"_id": id}, v, true, false)
+		if count := util.Mgo.Count("euserdepart", map[string]interface{}{"_id": v["_id"]}); count > 0 {
+			util.Mgo.Update("euserdepart", map[string]interface{}{"_id": v["_id"]}, map[string]interface{}{"$set": v}, false, false)
+		} else {
+			util.Mgo.SaveByOriID("euserdepart", v)
+		}
 	}
 
 	ruleMap, _ := util.Mgo.Find("cuserdepartrule", bson.M{"s_userid": _id}, nil, nil, false, -1, -1)
-	//b = util.Mgo.SaveBulk("euserdepartrule", *ruleMap...)
 	for _, v := range *ruleMap {
-		id := v["_id"]
-		delete(v, "_id")
-		util.Mgo.Update("euserdepartrule", bson.M{"_id": id}, v, true, false)
+		if count := util.Mgo.Count("euserdepartrule", map[string]interface{}{"_id": v["_id"]}); count > 0 {
+			util.Mgo.Update("euserdepartrule", map[string]interface{}{"_id": v["_id"]}, map[string]interface{}{"$set": v}, false, false)
+		} else {
+			util.Mgo.SaveByOriID("euserdepartrule", v)
+		}
 	}
 
 	c.ServeJson(map[string]interface{}{

+ 0 - 2
CMPlatform/history/task.go

@@ -383,8 +383,6 @@ func processedData_A(c *Customer, data *tempData) {
 			fieldText[cwm] = text
 		}
 	}
-
-	//
 	/*
 		因为要记录所有匹配上的关键词,所有优先匹配附加词,在匹配关键词
 	*/

+ 3 - 2
CMPlatform/history/util_history.go

@@ -424,7 +424,7 @@ func RegMatch(fieldText map[string]interface{}, matchType []string, matchReg *Re
 				for n, arc := range ar.AndRegKid { //ar.AndRegKid若有值必不小于2
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else {                                                         //匹配成功,判断字母
+					} else { //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}
@@ -583,6 +583,7 @@ func AssembelSave(tmp map[string]interface{}, IsSearchHosp, IsSearchEnps bool, h
 	if IsSearchEnps { //企业信息
 		SearchEnterpriseInfo(tmp)
 	}
+	tmp["datasource"] = "历史数据"
 	tmp["createtime"] = time.Now().Unix()
 	tmp["historyId"] = historyId
 	id := common.ObjToString(tmp["id"])
@@ -1433,7 +1434,7 @@ func RegMatchTest(fieldText map[string]interface{}, matchType []string, matchReg
 					log.Debug("nnnn---", zap.Int("n", n), zap.Any("arc.CrVal", arc.CrVal), zap.Any("arc.IsLetter", arc.IsLetter))
 					if indexArr := arc.CrVal.FindAllStringIndex(text, -1); len(indexArr) < 1 { //匹配失败(ar.AndRegKid中任意一个未匹配则失败)
 						break
-					} else {                                                         //匹配成功,判断字母
+					} else { //匹配成功,判断字母
 						if arc.IsLetter && !CheckLetter(text, arc.CrVal, indexArr) { //reg有字母,判断是否是包含关系(AAAIBBB or AI)
 							break
 						}

+ 0 - 1
CMPlatform/web/templates/client/index.html

@@ -859,7 +859,6 @@
                 success: function (r) {
                     if (r.rep) {
                         showTip("同步成功", 1000);
-                        ttable.ajax.reload()
                     } else {
                         showTip("同步失败", 1000);
                     }

+ 6 - 20
CMPlatform/web/templates/private/euser_rule_edit.html

@@ -656,7 +656,7 @@
             "data": dataMap.o_rules,
             "columns": [
                 {"data": null, width: "2%"},
-                {"data": "s_matchkey", width: "8%"},
+                {"data": "s_matchkey", width: "4%"},
                 {
                     "data": function (row) {
                         var str = row.s_keymatch;
@@ -676,14 +676,7 @@
                         return ""
                     }, width: "5%"
                 },
-                {
-                    "data": "s_addkey", width: "8%", render: function (val) {
-                        if (val == undefined) {
-                            val = ""
-                        }
-                        return val
-                    }
-                },
+                {"data": "s_addkey", width: "8%"},
                 {
                     "data": function (row) {
                         var str = row.s_addkeymatch;
@@ -703,14 +696,7 @@
                         return ""
                     }, width: "5%"
                 },
-                {
-                    "data": "s_notkey", width: "8%", render: function (val) {
-                        if (val == undefined) {
-                            val = ""
-                        }
-                        return val
-                    }
-                },
+                {"data": "s_notkey", width: "8%"},
                 {
                     "data": function (row) {
                         var str = row.s_notkeymatch;
@@ -767,7 +753,7 @@
                 }
             ],
             "columnDefs": [{
-                "targets": [2],
+                "targets": [1],
                 "render": function (data, type, full, meta) {
                     if (data && data.length > 24) {
                         return "<a title='" + data + "' href='#' style='text-decoration: none;'>" + data.trim().substr(0, 24) + "..." + "</a>";
@@ -778,7 +764,7 @@
                     }
                 }
             }, {
-                "targets": [4],
+                "targets": [3],
                 "render": function (data, type, full, meta) {
                     if (data && data.length > 24) {
                         return "<a title='" + data + "' href='#' style='text-decoration: none;'>" + data.trim().substr(0, 24) + "..." + "</a>";
@@ -789,7 +775,7 @@
                     }
                 }
             }, {
-                "targets": [6],
+                "targets": [5],
                 "render": function (data, type, full, meta) {
                     if (data && data.length > 24) {
                         return "<a title='" + data + "' href='#' style='text-decoration: none;'>" + data.trim().substr(0, 24) + "..." + "</a>";

+ 8 - 2
JySEPlatform/client/client.go

@@ -159,6 +159,12 @@ func (c *Client) CuserRuleCreate() {
 		i_createtime := time.Now().Unix()
 		data["i_updatetime"] = i_createtime
 		data["s_updateuser"] = sessVal["entUserName"]
+		query := bson.M{
+			"phone":    sessVal["phone"],
+			"username": sessVal["name"],
+		}
+		entMgoInfo, _ := MgoCus.FindOne("user", query)
+		appid := qu.ObjToString((*entMgoInfo)["appid"])
 		var rep = false
 		if id == "" { //新建
 			if entUserId == 0 {
@@ -167,7 +173,7 @@ func (c *Client) CuserRuleCreate() {
 				data["entUserId"] = entUserId
 			}
 			data["entId"] = qu.IntAll(sessVal["entId"])
-			data["appid"] = qu.ObjToString(sessVal["qyxyAppid"])
+			data["appid"] = appid
 			data["i_createtime"] = i_createtime
 			data["s_createuser"] = sessVal["entUserName"]
 			s_namekey := gopinyin.Convert(qu.ObjToString(data["s_name"]), false)
@@ -186,7 +192,7 @@ func (c *Client) CuserRuleCreate() {
 			} else {
 				data["entUserId"] = entUserId
 			}
-			data["appid"] = qu.ObjToString(sessVal["qyxyAppid"])
+			data["appid"] = appid
 			data["entId"] = qu.IntAll(sessVal["entId"])
 			query := bson.M{
 				"_id": mongodb.StringTOBsonId(id),

+ 2 - 1
JySEPlatform/config.json

@@ -243,5 +243,6 @@
     "jyFzZXQQIECAZYQERAPD93"
   ],
   "isNewSql": 1,
-  "cookiedomain":".jydev.jianyu360.com"
+  "cookiedomain":".jydev.jianyu360.com",
+  "export_file_path": "/nas/shareFile/customizedexport/"
 }

+ 0 - 4
JySEPlatform/go.mod

@@ -22,9 +22,6 @@ require (
 	github.com/andybalholm/cascadia v1.3.2 // indirect
 	github.com/garyburd/redigo v1.6.2 // indirect
 	github.com/go-sql-driver/mysql v1.6.0 // indirect
-	github.com/go-xweb/httpsession v0.0.0-20141220075701-356d3b4d38d6 // indirect
-	github.com/go-xweb/log v0.0.0-20140701090824-270d183ad77e // indirect
-	github.com/go-xweb/uuid v0.0.0-20140604020037-d7dce341f851 // indirect
 	github.com/golang/snappy v0.0.4 // indirect
 	github.com/gomodule/redigo v1.8.9 // indirect
 	github.com/gorilla/securecookie v1.1.2 // indirect
@@ -35,7 +32,6 @@ require (
 	github.com/klauspost/compress v1.13.6 // indirect
 	github.com/lunny/csession v0.0.0-20130910075847-fe53c5de3dfd // indirect
 	github.com/mailru/easyjson v0.7.7 // indirect
-	github.com/mattn/go-sqlite3 v1.14.24 // indirect
 	github.com/montanaflynn/stats v0.7.1 // indirect
 	github.com/olivere/elastic v6.2.37+incompatible // indirect
 	github.com/pkg/errors v0.9.1 // indirect

+ 3 - 1
JySEPlatform/service/private_service.go

@@ -218,6 +218,7 @@ func (f *Private) Keydataoption(world string) {
 						newIdArr = append(newIdArr, infoid)
 					}
 					v["datasource"] = "自助导出"
+					v["chargtime"] = time.Now().Unix()
 					infoArr = append(infoArr, v)
 				}
 			}
@@ -428,7 +429,8 @@ func GetXlsxfile(mMap []map[string]interface{}, dataType int, fn string, fields
 	//生文件
 	//t := strconv.FormatInt(time.Now().Unix(), 10)
 	t := time.Now().Format("20060102")
-	dir := "./web/res/xlsx/" + t + "/"
+	//dir := "./web/res/xlsx/" + t + "/"
+	dir := qu.ObjToString(Sysconfig["export_file_path"]) + t + "/"
 	if b, _ := PathExists(dir); !b {
 		err1 := os.MkdirAll(dir, os.ModePerm)
 		if err1 != nil {

+ 57 - 5
JySEPlatform/util/utiltag.go

@@ -265,10 +265,10 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 						log.Println("id", item["info_id"], "bidding为空")
 					}
 					//项目id
-					projectId := GetProjectId(info_id)
-					if projectId != "" {
-						item["projectId"] = SE2.EncodeString(projectId)
-					}
+					//projectId := GetProjectId(info_id)
+					//if projectId != "" {
+					//	item["projectId"] = SE2.EncodeString(projectId)
+					//}
 					datas = append(datas, item)
 				} else {
 					log.Println("id", item["_id"], "信息为空")
@@ -276,6 +276,9 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 			}(v)
 		}
 		wg.Wait()
+
+		GetProjectId(&datas)
+
 		count := Es.Count(EsIndex, EsType, esquery)
 		Mgo.Update("entniche_rule", bson.M{"_id": tags["_id"]}, bson.M{
 			"$set": bson.M{
@@ -951,7 +954,7 @@ func KeyWordToData(types, item, key string, keyWord []string) []string {
 	return keyWord
 }
 
-func GetProjectId(id string) string {
+func GetProjectId_1(id string) string {
 	query := `{"query": {"bool": {"must": [{"term": {"ids": "%s"}}],"must_not": [],"should": []}}}`
 	querys := fmt.Sprintf(query, id)
 	projectId := ""
@@ -968,3 +971,52 @@ func GetProjectId(id string) string {
 	}
 	return projectId
 }
+
+func chunkArray(arr []string, size int) [][]string {
+	var chunks [][]string
+	for i := 0; i < len(arr); i += size {
+		end := i + size
+		if end > len(arr) {
+			end = len(arr)
+		}
+		chunks = append(chunks, arr[i:end])
+	}
+	return chunks
+}
+
+func GetProjectId(datas *[]map[string]interface{}) (pidMap map[string]interface{}) {
+	var ids []string
+	for _, d1 := range *datas {
+		id := qu.ObjToString(d1["info_id"])
+		ids = append(ids, id)
+		pidMap[id] = ""
+	}
+	query := `{"query": {"bool": {"must": [{"terms": {"ids": ["%s"]}}]}},"_source": ["ids","id"]}`
+	for _, array := range chunkArray(ids, 200) {
+		query = fmt.Sprintf(query, strings.Join(array, "\",\""))
+		data := Es.Get("projectset", "projectset", query)
+		if data != nil && *data != nil && len(*data) > 0 {
+			for _, v := range *data {
+				pid := qu.ObjToString(v["id"])
+				for _, id := range strings.Split(qu.ObjToString(v["ids"]), ",") {
+					if pidMap[id] != nil {
+						pidMap[id] = pid
+					}
+				}
+			}
+		} else {
+			log.Println("ES未查到项目id", query)
+		}
+	}
+
+	for _, m := range *datas {
+		id := qu.ObjToString(m["info_id"])
+		if pid := qu.ObjToString(pidMap[id]); pid != "" {
+			log.Println("id: ", id, "pid: ", pid)
+			m["projectId"] = SE2.EncodeString(pid)
+		} else {
+			log.Println("id: ", id, "pid: -")
+		}
+	}
+	return
+}