From 53b43342f3d7a6e6d7eb54dafeab264276ea3b64 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期二, 19 十一月 2019 16:06:28 +0800 Subject: [PATCH] update all to new --- controllers/es.go | 76 -------------------------------------- controllers/tasklist.go | 2 controllers/task.go | 2 extend/config/config.go | 4 -- 4 files changed, 2 insertions(+), 82 deletions(-) diff --git a/controllers/es.go b/controllers/es.go index 8a1fa1d..baed42b 100644 --- a/controllers/es.go +++ b/controllers/es.go @@ -8,11 +8,9 @@ "github.com/gin-gonic/gin" "math/rand" "os/exec" - "strconv" "strings" "webserver/cache" "webserver/extend/code" - "webserver/extend/config" "webserver/extend/esutil" "webserver/extend/util" "webserver/models" @@ -68,80 +66,6 @@ util.ResponseFormat(c, code.CompareResultGone, m) } -func searchEsData(searchBody models.EsSearch) map[string]interface{} { - //璇锋眰绱㈠紩 - index := config.EsInfo.EsIndex.VideoPersons.IndexName // wp鍙煡浜鸿劯鏁版嵁 - queryStr := "" - queryBody := searchBody.InputValue - //妫�绱㈡ - if queryBody != "" { - queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"alarmRules.alarmLevel^1.5\",\"ageDescription^1.5\",\"taskName^1.5\",\"baseInfo.tableName^1.5\",\"sex^2.0\",\"race^2.0\",\"content^1.0\",\"baseInfo.idCard^1.8\",\"cameraAddr^1.0\"]," + - "\"type\":\"cross_fields\",\"operator\":\"OR\",\"slop\":0,\"prefix_length\":0,\"max_expansions\":50,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1}}]," - } - gteDate := searchBody.SearchTime[0] - lteDate := searchBody.SearchTime[1] - //鍒ゆ柇浠诲姟ID - taskIdStr := "" - taskId := searchBody.Tasks - if taskId != nil && len(taskId) > 0 { - esTaskId := strings.Replace(strings.Trim(fmt.Sprint(taskId), "[]"), " ", "\",\"", -1) - taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}}," - } - //鍒ゆ柇鎽勫儚鏈篒D - cameraIdStr := "" - cameraId := searchBody.TreeNodes - if cameraId != nil && len(cameraId) > 0 { - esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) - cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," - } - //鍒ゆ柇搴撹〃ID - tableId := searchBody.Tabs - esTableId := "" - esTableIdStr := "" - if tableId != nil && len(tableId) > 0 { - esTableId = strings.Replace(strings.Trim(fmt.Sprint(tableId), "[]"), " ", "\",\"", -1) - esTableIdStr = "{\"terms\":{\"baseInfo.tableId\":[\"" + esTableId + "\"]}}," - } - isCollectionStr := "" - isCollection := searchBody.Collection - if isCollection != "" { - isCollectionStr = "{\"term\":{\"collection\":\"" + isCollection + "\"}}," - } - webPage := searchBody.Page - webSize := searchBody.Size - from := (webPage - 1) * webSize - esFrom := strconv.Itoa(from) - esSize := strconv.Itoa(webSize) - //浣跨敤es搴曞眰鏈哄埗澶勭悊鍒嗛〉 - //璇锋眰澶� - 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" - - analyServerFilterStr := "{\"term\":{\"analyServerId\":\"" + localConf.ServerId + "\"}}," - - //璇锋眰浣� - prama := "{\"from\":\"" + esFrom + "\",\"size\":\"" + esSize + "\"," + - // prama := "{\"size\":\"0\"," + - "\"query\":{\"bool\":{" + queryStr + - "\"filter\":[" + - cameraIdStr + - taskIdStr + - isCollectionStr + - esTableIdStr + - analyServerFilterStr + - "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + - "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + - "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" - fmt.Println(prama) - //鏁版嵁瑙f瀽 - tokenRes := esutil.GetEsDataReq(url, prama, true) - return tokenRes -} func sourceCompare(sources []interface{}, isEsSource bool, campareByte []byte, threshold float32) []interface{} { var filterName = "feature" diff --git a/controllers/task.go b/controllers/task.go index 4f2dd14..8c2e205 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -102,7 +102,7 @@ //澶勭悊宸茶鍒犻櫎鐨勪换鍔� localConf, _ := cache.GetServerInfo() if localConf.AlarmIp != "" && localConf.ServerId != "" && localConf.AlarmPort>0 { - indexName := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + indexName := config.EsInfo.EsIndex.AiOcean.IndexName esTaskM, e := esutil.AggregateTaskList(localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort)), indexName, localConf.ServerId) if e==nil && esTaskM !=nil { for _,tM :=range esTaskM { diff --git a/controllers/tasklist.go b/controllers/tasklist.go index a59b93d..bef2c70 100644 --- a/controllers/tasklist.go +++ b/controllers/tasklist.go @@ -30,7 +30,7 @@ return } url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) + - "/" + config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + "/_search" + "/" + config.EsInfo.EsIndex.AiOcean.IndexName + "/_search" prama := "{\"size\":0,\"aggs\":{\"taskId_list\":{\"terms\":{\"field\":\"taskId\"}}}}" diff --git a/extend/config/config.go b/extend/config/config.go index 61e5126..32e4f13 100644 --- a/extend/config/config.go +++ b/extend/config/config.go @@ -40,10 +40,6 @@ } type esindexlist struct { - VideoPersons index `mapstructure:"videopersons"` - DbTables index `mapstructure:"dbtables"` - Dbtablepersons index `mapstructure:"dbtablepersons"` - Personaction index `mapstructure:"personaction"` AiOcean index `mapstructure:"aiOcean"` } type index struct { -- Gitblit v1.8.0