From a527225f7f3cc93882aa870c20f0985d07d6fe92 Mon Sep 17 00:00:00 2001 From: sunty <suntianyu0923@163.com> Date: 星期四, 22 八月 2019 18:12:03 +0800 Subject: [PATCH] set yn main port 7100 --- controllers/initForData.go | 26 ++++++++++++++++++-------- 1 files changed, 18 insertions(+), 8 deletions(-) diff --git a/controllers/initForData.go b/controllers/initForData.go index 78dd39e..af18dd4 100644 --- a/controllers/initForData.go +++ b/controllers/initForData.go @@ -19,26 +19,35 @@ // @Accept json // @Produce json // @Tags realTime -// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}" -// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}" +// @Success 200 {string} json "{"code":200, msg:"", success:true}" +// @Failure 500 {string} json "{"code":500, msg:"", success:false}" // @Router /data/api-v/realTime/initForCaptureData [POST] -//瀹炴椂鎶撴媿鏁版嵁鍒濆鍖� func (rc *RealTimeController) InitForCaptureData(c *gin.Context) { searchBody := make(map[string]interface{}, 0) c.BindJSON(&searchBody) 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) } @@ -57,7 +66,7 @@ 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 { @@ -76,7 +85,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 + @@ -86,7 +95,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