From 718bcd41127a8c5c93a20ca6dfce6e5c5fcbc4e1 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 31 十月 2019 13:47:24 +0800
Subject: [PATCH] add gbCloud
---
controllers/monitoring.go | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/controllers/monitoring.go b/controllers/monitoring.go
index 209f66f..ccb3519 100644
--- a/controllers/monitoring.go
+++ b/controllers/monitoring.go
@@ -1,9 +1,11 @@
package controllers
import (
- "basic.com/dbapi.git"
+ "basic.com/valib/logger.git"
"fmt"
+ "strconv"
"strings"
+ "webserver/cache"
"github.com/gin-gonic/gin"
"webserver/extend/code"
@@ -12,41 +14,46 @@
"webserver/extend/util"
)
+// @Security ApiKeyAuth
// @Summary 瀹炴椂鐩戞帶
// @Description 瀹炴椂鐩戞帶姣斿鏁版嵁
// @Accept json
// @Produce json
// @Tags realTime
-// @Param obj body map true "搴曞簱鏁版嵁"
-// @Success 200 {string} json "{"code":200, msg:"鐩綍缁撴瀯鏁版嵁", success:true}"
-// @Failure 500 {string} json "{"code":500, msg:"杩斿洖閿欒淇℃伅", success:false}"
+// @Param obj body controllers.InitForMonitorArg 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]
-//瀹炴椂鐩戞帶
func (rc *RealTimeController) PostMonitoring(c *gin.Context) {
- searchBody := make(map[string]interface{}, 0)
+ //searchBody := make(map[string]interface{}, 0)
+ var searchBody InitForMonitorArg
c.BindJSON(&searchBody)
index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName
cameraIdStr := ""
- cameraId := searchBody["treeNodes"].([]interface{})
+ cameraId := searchBody.TreeNodes
if cameraId != nil && len(cameraId) > 0 {
esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}},"
}
//鍒ゆ柇浠诲姟ID
taskIdStr := "{\"terms\":{\"taskId\":[]}},"
- taskId := searchBody["tasks"].([]interface{})
+ taskId := searchBody.Tasks
if taskId != nil && len(taskId) > 0 {
esTaskId := strings.Replace(strings.Trim(fmt.Sprint(taskId), "[]"), " ", "\",\"", -1)
taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}},"
}
//璇锋眰澶�
- url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport +
+ localConf, err2 := cache.GetServerInfo()
+ if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
+ logger.Debug("localConfig is wrong!!!")
+ util.ResponseFormat(c,code.ComError,"localConf wrong")
+ return
+ }
+ url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
"/" + index + "/_search"
- var setApi dbapi.SysSetApi
- _, sysconf := setApi.GetServerInfo()
- analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}},"
+ analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + localConf.ServerId + "\"}},"
prama := "{\"query\":{\"bool\":{\"filter\":[" +
cameraIdStr +
--
Gitblit v1.8.0