| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "basic.com/pubsub/esutil.git" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | "time" |
| | | "webserver/cache" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/util" |
| | | ) |
| | | |
| | |
| | | // @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.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 { |
| | | // if _,ok := m[tM["taskId"].(string)];!ok {//表示此任务已被删除 |
| | | // taskId := tM["taskId"].(string) |
| | | // m[taskId] = taskId |
| | | // tasks = append(tasks, TaskSdkVo{ |
| | | // Task:TaskVo{ |
| | | // Taskid: taskId, |
| | | // Taskname: tM["taskName"].(string), |
| | | // DelFlag: true, |
| | | // }, |
| | | // Sdks:[]SdkVo{}, |
| | | // }) |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // util.ResponseFormat(c,code.Success,tasks) |
| | | // } |
| | | //} |
| | | util.ResponseFormat(c,code.Success,[]interface{}{}) |
| | | var api dbapi.CameraRuleApi |
| | | |
| | | var result []SceneIfDelResult |
| | | m := make(map[string]string) |
| | | if b, allRules := api.FindAll(); b { |
| | | for _,cg :=range allRules { |
| | | for _,g := range cg.Rules { |
| | | m[g.Id] = g.SceneName |
| | | result = append(result, SceneIfDelResult{ |
| | | Id: g.Id, |
| | | Name: g.SceneName, |
| | | IsDelete: false, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | localConf, _ := cache.GetServerInfo() |
| | | if localConf.AlarmIp != "" && localConf.ServerId != "" && localConf.AlarmPort>0 { |
| | | 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 { |
| | | if _,ok := m[tM["taskId"].(string)];!ok {//表示此任务已被删除 |
| | | taskId := tM["taskId"].(string) |
| | | taskName := tM["taskName"].(string) |
| | | m[taskId] = taskName |
| | | result = append(result, SceneIfDelResult{ |
| | | Id: taskId, |
| | | Name: taskName, |
| | | IsDelete: true, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | util.ResponseFormat(c, code.Success, result) |
| | | } |
| | | |
| | | //// @Security ApiKeyAuth |