Browse Source

no message

Jianghan 5 years ago
parent
commit
c193cc8a65

+ 2 - 2
customerdata/src/historytask.go

@@ -6,7 +6,7 @@ import (
 	"strings"
 	mgoutil "util/mgodb"
 
-	bson "gopkg.in/mgo.v2/bson"
+	"gopkg.in/mgo.v2/bson"
 )
 
 func HistoryTask(sid, eid, name string) {
@@ -47,7 +47,7 @@ func HistoryTask(sid, eid, name string) {
 		}
 
 		cus.GetTagRules()    //获取客户打标签规则
-		cus.GetDepartments() //获取客户信息
+		cus.GetDepartments("history") //获取客户信息
 		//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))
 		cus.GetData()             //获取数据

+ 2 - 2
customerdata/src/main.go

@@ -93,13 +93,13 @@ func init() {
 }
 func main() {
 	go SaveMgo()
-	go TimeTask() //定时任务
+	//go TimeTask() //定时任务
 	flag.StringVar(&SId, "sid", "", "起始id")
 	flag.StringVar(&EId, "eid", "", "结束id")
 	flag.StringVar(&CustomerName, "customer", "", "客户名称")
 	flag.Parse()
 	if SId != "" && EId != "" && CustomerName != "" {
-		go HistoryTask(SId, EId, CustomerName)
+		go HistoryTask(SId, EId, CustomerName,)
 	}
 	ch := make(chan bool, 1)
 	<-ch

+ 10 - 8
customerdata/src/task.go

@@ -67,7 +67,7 @@ func GetCustomerData() {
 		}
 
 		cus.GetTagRules()    //获取客户打标签规则
-		cus.GetDepartments() //获取客户信息
+		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))
 		cus.GetData()             //获取数据
@@ -108,7 +108,7 @@ func (c *Customer) GetTagRules() {
 }
 
 //获取部门信息
-func (c *Customer) GetDepartments() {
+func (c *Customer) GetDepartments(stype string) {
 	log.Println("开始获取部门信息...")
 	defer qu.Catch()
 	departments, _ := MgoTag.Find("euserdepart", map[string]interface{}{"s_userid": c.ID, "i_isuse": 1, "b_delete": false}, nil, nil)
@@ -123,7 +123,7 @@ func (c *Customer) GetDepartments() {
 			DM.ID = id
 			DM.Name = name
 			DM.CustomerID = c.ID
-			DM.GetSearchRules(c.ID, c.IdRange) //获取某个部门的所有规则
+			DM.GetSearchRules(c.ID, stype, c.IdRange) //获取某个部门的所有规则
 			c.Departments = append(c.Departments, DM)
 			//qu.Debug("Departments---", DM.ID, DM.Name, DM.CustomerID, len(DM.Rules))
 		}
@@ -146,9 +146,7 @@ func (c *Customer) GetData() {
 			ch := make(chan bool, 10)
 			wg := &sync.WaitGroup{}
 			escount := Es.Count(Index, Itype, sr.EsQuery)
-			qu.Debug("---------", sr.EsQuery)
-			return
-			log.Println("查询总数:", escount, "规则ID:", sr.ID)
+			log.Println("查询总数:", escount, "规则ID:", sr.ID, "EsQuery:", sr.EsQuery)
 			if escount == 0 {
 				continue
 			}
@@ -428,7 +426,7 @@ func (c *Customer) AssembelAndSaveData() {
 }
 
 //获取用户所有规则
-func (d *Department) GetSearchRules(cid string, idRange bson.M) {
+func (d *Department) GetSearchRules(cid, stype string, idRange bson.M) {
 
 	defer qu.Catch()
 	searchRules, _ := MgoTag.Find("euserdepartrule", map[string]interface{}{"s_userid": cid, "s_departid": d.ID, "b_delete": false}, nil, nil)
@@ -449,7 +447,11 @@ func (d *Department) GetSearchRules(cid string, idRange bson.M) {
 			clearKeyMatch := qu.ObjToString(sr["s_globalclearkeymatch"])
 
 			//获取es
-			SR.GetEs(d.Name, esquery, idRange)
+			if stype == "history" {
+				SR.EsQuery = esquery
+			}else {
+				SR.GetEs(d.Name, esquery, idRange)
+			}
 			//获取关键词和附加词
 			if o_rules, ok := sr["o_rules"].(primitive.A); ok && len(o_rules) > 0 {
 				SR.GetKeyAddWord(o_rules)

+ 12 - 10
customerdata/src/util.go

@@ -508,19 +508,21 @@ func SearchEnterpriseInfo(tmp map[string]interface{}) {
 				tmp["company_address"] = company_address
 			}
 			//注册资金"capital" : "324 万","capital" : 124.8,
-			if data["capital"] != nil {
-				if capitalStr, ok := data["capital"].(string); ok && capitalStr != "" {
-					if capital := ObjToMoney(capitalStr); capital != 0 { //金额转换
-						tmp["capital"] = capital
-					}
-				} else if capitalFloat, ok := data["capital"].(float64); ok && capitalFloat != 0 {
-					tmp["capital"] = capitalFloat
-				}
+			if capital := qu.ObjToString(data["capital"]); capital != "" {
+				tmp["capital"] = capital
+				//if capitalStr, ok := data["capital"].(string); ok && capitalStr != "" {
+				//	if capital := ObjToMoney(capitalStr); capital != 0 { //金额转换
+				//		tmp["capital"] = capital
+				//	}
+				//} else if capitalFloat, ok := data["capital"].(float64); ok && capitalFloat != 0 {
+				//	tmp["capital"] = capitalFloat
+				//}
 			}
 			//注册时间"establish_date" : ISODate("1949-10-01T00:00:00.000+0000")
 			if data["establish_date"] != nil {
-				if establish_date, ok := data["establish_date"].(time.Time); ok {
-					tmp["establish_date"] = qu.FormatDate(&establish_date, qu.Date_Short_Layout)
+				if establish_date, ok := data["establish_date"].(primitive.DateTime); ok {
+					t := establish_date.Time()
+					tmp["establish_date"] = qu.FormatDate(&t, qu.Date_Short_Layout)
 				}
 			}
 			//经营范围

+ 1 - 0
src/service/customer_service.go

@@ -547,6 +547,7 @@ func (c *Customer) CuserRuleCreate() {
 		c.ServeJson(map[string]interface{}{
 			"id":        id,
 			"rep":       rep,
+			"s_esquery": data["s_esquery"],
 			"s_dataid":  data["s_dataid"],
 		})
 	} else {

+ 1 - 1
src/util/utiltag.go

@@ -313,7 +313,7 @@ func UtilEsFind1(tags map[string]interface{}) (error, int64) {
 				datas = append(datas, item)
 			}
 		}
-		Mgo.Update("cuser", bson.M{"_id": tags["_id"]}, bson.M{
+		Mgo.Update("cuserdepartrule", bson.M{"_id": tags["_id"]}, bson.M{
 			"$set": bson.M{
 				"i_estotal": searchResult.Hits.TotalHits,
 			}}, false, false)

+ 1 - 0
src/web/templates/private/cuser_rule_edit.html

@@ -1245,6 +1245,7 @@
             success: function (r) {
                 if (r.rep && r.id) {
                     dataMap.id = r.id
+                    $('#estxt').val(r.s_esquery);
                     state = 2;
                     showTip("保存成功",1000);
                 } else {