From f4e8f206a6760bdc31734dfcb1c65916b5b76311 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期四, 22 八月 2019 12:05:58 +0800 Subject: [PATCH] add cluster --- controllers/initForData.go | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/controllers/initForData.go b/controllers/initForData.go index cce730b..8999776 100644 --- a/controllers/initForData.go +++ b/controllers/initForData.go @@ -1,6 +1,7 @@ package controllers import ( + "basic.com/dbapi.git" "fmt" "github.com/gin-gonic/gin" "strings" @@ -20,7 +21,7 @@ // @Tags realTime // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" // @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" -// @Router /data/api-v/realTime/action [POST] +// @Router /data/api-v/realTime/initForCaptureData [POST] //瀹炴椂鎶撴媿鏁版嵁鍒濆鍖� func (rc *RealTimeController) InitForCaptureData(c *gin.Context) { searchBody := make(map[string]interface{}, 0) @@ -28,16 +29,26 @@ index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + "/" + index + "/_search" + cameraIdStr := "" + if searchBody["treeNodes"] !=nil { + cameraId := searchBody["treeNodes"].([]interface{}) + if cameraId != nil && len(cameraId) > 0 { + esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) + cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," + } + } + var setApi dbapi.SysSetApi _, sysconf := setApi.GetServerInfo() analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}" prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"isAlarm\":\"1\"}}," + + cameraIdStr + analyServerFilterStr + "]}},\"size\":\"20\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"isAlarm\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]" + "}" - fmt.Println(prama) + //logger.Debug("InitForCaptureData:", prama) tokenRes := esutil.GetEsDataReq(url, prama, true) util.ResponseFormat(c, code.Success, tokenRes) } @@ -50,13 +61,13 @@ // @Param obj body map true "搴曞簱鏁版嵁" // @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" // @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" -// @Router /data/api-v/realTime/monitoring [POST] +// @Router /data/api-v/realTime/initForMonitoringData [POST] //瀹炴椂鐩戞帶鏁版嵁鍒濆鍖� func (rc *RealTimeController) InitForMonitoringData(c *gin.Context) { searchBody := make(map[string]interface{}, 0) c.BindJSON(&searchBody) - index := config.EsInfo.EsIndex.VideoPersons.IndexName + index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName cameraIdStr := "" cameraId := searchBody["treeNodes"].([]interface{}) if cameraId != nil && len(cameraId) > 0 { @@ -75,7 +86,7 @@ "/" + index + "/_search" var setApi dbapi.SysSetApi _, sysconf := setApi.GetServerInfo() - analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}" prama := "{\"query\":{\"bool\":{\"filter\":[" + cameraIdStr + @@ -85,7 +96,8 @@ "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + "\"size\":\"20\"," + "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" - fmt.Println(prama) + //logger.Debug("url:", url) + //logger.Debug("InitForMonitoringData:", prama) tokenRes := esutil.GetEsDataReq(url, prama, true) util.ResponseFormat(c, code.Success, tokenRes) -} \ No newline at end of file +} -- Gitblit v1.8.0