From 5d78b36e851a5862302f2e40c99a4477020c79bc Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期五, 20 九月 2019 13:46:52 +0800 Subject: [PATCH] 查找此人时先切图 --- controllers/esSearch.go | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/controllers/esSearch.go b/controllers/esSearch.go index 8b51bb9..feeb04c 100644 --- a/controllers/esSearch.go +++ b/controllers/esSearch.go @@ -6,10 +6,11 @@ "github.com/gin-gonic/gin" "strconv" "strings" + "webserver/cache" "webserver/extend/code" "webserver/extend/config" "webserver/extend/esutil" - "webserver/extend/logger" + "basic.com/valib/logger.git" "webserver/extend/util" "webserver/models" ) @@ -42,7 +43,7 @@ } //鑾峰彇鐩戞帶绛夌骇 -func getAlarmLevel(alarmlevel []int) []string { +func getAlarmLevel(alarmlevel []int32) []string { d := dbapi.DicApi{} res, data := d.FindByType("ALARMLEVEL") if data == nil { @@ -50,7 +51,7 @@ } logger.Debug(res) // logger.Debug(data) - alarmLevel := make(map[int]string) + alarmLevel := make(map[int32]string) tmp := data.(map[string]interface{}) for _, value := range tmp["ALARMLEVEL"].([]interface{}) { // logger.Debug(value.(map[string]interface{})["value"]," ",value.(map[string]interface{})["name"]) @@ -60,7 +61,7 @@ if err != nil { logger.Debug(err) } - alarmLevel[vl] = name + alarmLevel[int32(vl)] = name } alarmLevelRes := make([]string, len(alarmlevel)) for i, v := range alarmlevel { @@ -140,11 +141,15 @@ //浣跨敤es搴曞眰鏈哄埗澶勭悊鍒嗛〉 //璇锋眰澶� - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { + logger.Debug("localConfig is wrong!!!") + return nil + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + index + "/_search?search_type=dfs_query_then_fetch" - var setApi dbapi.SysSetApi - _, sysconf := setApi.GetServerInfo() - analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + sysconf.ServerId + "\"}}," + + analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + localConf.ServerId + "\"}}," //璇锋眰浣� prama := "{\"from\":\"" + from + "\"," + @@ -196,7 +201,12 @@ } func GetLinkInfo(linkId string, id string) []map[string]interface{} { - url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + + localConf, err2 := cache.GetServerInfo() + if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" { + logger.Debug("localConfig is wrong!!!") + return nil + } + url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + "/" + config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + "/_search?search_type=dfs_query_then_fetch" jsonDSL := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"linkId.keyword\":\"" + linkId + "\"}}],\"must_not\":[{\"term\":{\"id\":\"" + id + "\"}}]}},\"size\":100}" -- Gitblit v1.8.0