From a32ebb199d6665bac27d4af43af267fe3854b38f Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期一, 28 十月 2019 20:22:30 +0800 Subject: [PATCH] aggregateTaskList --- controllers/task.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/controllers/task.go b/controllers/task.go index 8e5ff47..1bd5e75 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -2,9 +2,13 @@ import ( "basic.com/dbapi.git" + "basic.com/pubsub/esutil.git" "basic.com/pubsub/protomsg.git" "encoding/json" + "strconv" "time" + "webserver/cache" + "webserver/extend/config" "github.com/gin-gonic/gin" "webserver/extend/code" @@ -65,6 +69,60 @@ } } +// @Summary 妫�绱㈤〉闈㈣幏鍙栨墍鏈変换鍔″垪琛紙鍖呭惈宸插垹闄ょ殑浠诲姟锛� +// @Description 妫�绱㈤〉闈㈣幏鍙栨墍鏈変换鍔″垪琛紙鍖呭惈宸插垹闄ょ殑浠诲姟锛� +// @Produce json +// @Tags task +// @Success 200 {string} json "{"code":200, msg:"璇锋眰澶勭悊鎴愬姛",data:"",success:true}" +// @Failure 500 {string} json "{"code":500, msg:"璇锋眰澶辫触",data:"",success:false}" +// @Router /data/api-v/task/aggregateTaskList [GET] +func (tc TaskController) AggregateTaskList(c *gin.Context) { + // 鏄剧ず鎵�鏈変换鍔�: 鑾峰彇淇℃伅 + var taskApi dbapi.TaskApi + + taskInfos := taskApi.FindAll() + m := make(map[string]string) + var arr []protomsg.TaskSdkInfo + for _,ti :=range taskInfos{ + if ti.Task.Taskid != FaceExtract_VirtualTaskId{ + arr = append(arr,ti) + m[ti.Task.Taskid] = ti.Task.Taskid + } + } + var tasks []TaskSdkVo + dataBytes, err := json.Marshal(arr) + if err !=nil { + util.ResponseFormat(c,code.ComError,[]TaskSdkVo{}) + } else { + if err := json.Unmarshal(dataBytes, &tasks);err !=nil { + util.ResponseFormat(c,code.ComError,[]TaskSdkVo{}) + } else { + //澶勭悊宸茶鍒犻櫎鐨勪换鍔� + localConf, _ := cache.GetServerInfo() + if localConf.AlarmIp != "" && localConf.ServerId != "" && localConf.AlarmPort>0 { + indexName := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName + esTaskM, e := esutil.AggregateTaskList(localConf.AlarmIp, strconv.Itoa(int(localConf.AlarmPort)), indexName, localConf.ServerId) + if e==nil && esTaskM !=nil { + for _,tM :=range esTaskM { + if _,ok := m[tM["taskId"].(string)];!ok {//琛ㄧず姝や换鍔″凡琚垹闄� + tasks = append(tasks, TaskSdkVo{ + Task:TaskVo{ + Taskid: tM["taskId"].(string), + Taskname: tM["taskName"].(string), + DelFlag: true, + }, + Sdks:[]SdkVo{}, + }) + } + } + } + } + + util.ResponseFormat(c,code.Success,tasks) + } + } +} + // @Summary 娣诲姞浠诲姟 // @Description 鏌ユ壘鎵�鏈変换鍔� // @Accept json -- Gitblit v1.8.0