From df4e05af6aee00109360e40b9c2132da8d13f5f8 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期二, 19 十一月 2019 20:39:30 +0800
Subject: [PATCH] fix esutil

---
 EsApi.go |   57 +++++++++++++++++++++++++++++----------------------------
 1 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/EsApi.go b/EsApi.go
index dd608ed..4535e47 100644
--- a/EsApi.go
+++ b/EsApi.go
@@ -104,8 +104,8 @@
 }
 
 // 鏍规嵁鎶撴媿浜哄憳id鏌ヨ鎶撴媿浜哄憳淇℃伅
-func Videopersonsinfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.Videopersons, error) {
-	var videopersonsInfo []protomsg.Videopersons
+func AIOceaninfosbyid (id []string, indexName string, serverIp string, serverPort string) ([]protomsg.AIOcean, error) {
+	var aIOceanInfo []protomsg.AIOcean
 	videopersonsPersonId := strings.Replace(strings.Trim(fmt.Sprint(id), "[]"), " ", "\",\"", -1)
 	var dbinfoRequest = `
             {
@@ -125,17 +125,17 @@
         `
 	buf, err := EsReq("POST", "http://"+serverIp+":"+serverPort+"/"+indexName+"/_search",[]byte(dbinfoRequest))
 	if err != nil {
-		return videopersonsInfo,  err
+		return aIOceanInfo,  err
 	}
 
 	sources, err := Sourcelist(buf)
 	if err != nil {
-		return videopersonsInfo , err
+		return aIOceanInfo , err
 	}
 
-	videoperson := Videopersonsbyid(sources)
-	println(videoperson)
-	return videoperson,nil
+	aIOcean := AIOceanAnalysis(sources)
+	println(aIOcean)
+	return aIOcean,nil
 }
 
 // 鏍规嵁搴曞簱浜哄憳id鏌ヨ搴曞簱浜哄憳淇℃伅
@@ -505,8 +505,8 @@
 }
 
 //鍒濆鍖栧疄鏃舵姄鎷�
-func InitRealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool	,quantity int) ([]protomsg.Videopersons, error){
-	var videopersonsInfo []protomsg.Videopersons
+func InitRealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool	,quantity int) ([]protomsg.AIOcean, error){
+	var aIOceanInfo []protomsg.AIOcean
 	url := "http://" + serverIp + ":" + serverPort +
 		"/" + indexName + "/_search"
 	queryStr := ""
@@ -520,7 +520,7 @@
 			"filter":[
 				{
 					"term":{
-						"isAlarm":1
+						"isAlarm":true
 					}
 				}
 			]
@@ -531,26 +531,26 @@
 	"size":`+strconv.Itoa(quantity)+`,
 	`+queryStr+`
 	"sort":[{"picDate":{"order":"desc"}}],
-	"_source": ["baseInfo", "alarmRules", "sex", "analyServerName", "sdkName", "ageDescription", "content", "id", "cameraAddr", "picMaxUrl", "picDate", "race", "videoUrl", "picSmUrl", "taskName", "personIsHub", "isAlarm", "analyServerIp", "cameraId"]
+	"_source": {"includes":[],"excludes":["*.feature"]}
 	}`
 	buf, err := EsReq("POST", url, []byte(DSLJson))
 	if err != nil {
-		return videopersonsInfo, err
+		return aIOceanInfo, err
 	}
 
 	sources, err := Sourcelist(buf)
 	if err != nil {
-		return videopersonsInfo, err
+		return aIOceanInfo, err
 	}
 
-	videoperson := Videopersonsbyid(sources)
+	aIOcean := AIOceanAnalysis(sources)
 	//fmt.Println(len(videoperson))
-	return videoperson, nil
+	return aIOcean, nil
 }
 
 //瀹炴椂鎶撴媿
-func RealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool	) ([]protomsg.Videopersons, error){
-	var videopersonsInfo []protomsg.Videopersons
+func RealTimeCapture(serverIp string, serverPort string, indexName string, isAlarm bool	) ([]protomsg.AIOcean, error){
+	var aIOceanInfo []protomsg.AIOcean
 	url := "http://" + serverIp + ":" + serverPort +
 		"/" + indexName + "/_search"
 	queryStr := ""
@@ -587,24 +587,24 @@
 
 	buf, err := EsReq("POST", url, []byte(DSLJson))
 	if err != nil {
-		return videopersonsInfo, err
+		return aIOceanInfo, err
 	}
 
 	sources, err := Sourcelist(buf)
 	if err != nil {
-		return videopersonsInfo, err
+		return aIOceanInfo, err
 	}
 
-	videoperson := Videopersonsbyid(sources)
-	fmt.Println(len(videoperson))
-	return videoperson, nil
+	aIOcean := AIOceanAnalysis(sources)
+	fmt.Println(len(aIOcean))
+	return aIOcean, nil
 }
 
 //缁煎悎缁熻
 func StatisticsComprehensive(serverIp string, serverPort string, indexName string, isAlarm bool) (total int, err error){
 	isAlarmStr := ""
 	if isAlarm == true {
-		isAlarmStr = `,{"term":{"isAlarm":1}}`
+		isAlarmStr = `,{"term":{"isAlarm":true}}`
 	}
 	url := "http://" + serverIp + ":" + serverPort +
 		"/" + indexName + "/_search"
@@ -662,9 +662,9 @@
 		}
 	},
 	"aggs":{
-		"sdkName_status":{
+		"sdkId_status":{
 			"terms":{
-				"field":"taskName.raw"
+				"field":"taskId"
 			}
 		}
 	}
@@ -683,7 +683,7 @@
 	if !ok {
 		return nil, errors.New("first hits change error!")
 	}
-	sdkName_status, ok := middle["sdkName_status"].(map[string]interface{})
+	sdkName_status, ok := middle["sdkId_status"].(map[string]interface{})
 	if !ok {
 		return nil, errors.New("first hits change error!")
 	}
@@ -695,9 +695,9 @@
 			fmt.Println("change to source error!")
 			continue
 		}
-		sdkName := tmpbuf["key"].(string)
+		sdkId := tmpbuf["key"].(string)
 		count := int(tmpbuf["doc_count"].(float64))
-		source["name"] = sdkName
+		source["id"] = sdkId
 		source["value"] = count
 		sources = append(sources, source)
 	}
@@ -705,6 +705,7 @@
 	return sources,nil
 }
 
+
 //鑱氬悎浠诲姟鍒楄〃锛宼askId+taskName
 func AggregateTaskList(serverIp string, serverPort string, indexName string, analyServerId string) (sources []map[string]interface{},err error){
 	url := "http://" + serverIp + ":" + serverPort +

--
Gitblit v1.8.0