From f26a0cab5bca17b7eab57f6330e576271e17a17f Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期三, 13 十一月 2019 19:12:08 +0800
Subject: [PATCH] update ynSwagger,sync to master

---
 controllers/task.go |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 106 insertions(+), 10 deletions(-)

diff --git a/controllers/task.go b/controllers/task.go
index 999f82e..4a5a246 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"
@@ -35,6 +39,7 @@
 )
 
 /*
+// @Security ApiKeyAuth
 // @Summary 鏌ユ壘鎵�鏈変换鍔★紝鍖呭惈浠诲姟淇℃伅鍜屽搴旂殑绠楁硶淇℃伅
 // @Description 鏌ユ壘鎵�鏈変换鍔�
 // @Produce json
@@ -68,6 +73,66 @@
 }
 
 /*
+// @Security ApiKeyAuth
+// @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 {//琛ㄧず姝や换鍔″凡琚垹闄�
+							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)
+		}
+	}
+}
+
+/*
+// @Security ApiKeyAuth
 // @Summary 娣诲姞浠诲姟
 // @Description 鏌ユ壘鎵�鏈変换鍔�
 // @Accept json
@@ -106,8 +171,10 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 缁欎换鍔℃坊鍔犵畻娉�
 // @Description 浠诲姟娣诲姞绠楁硶
+// @Accept json
 // @Produce json
 // @Tags task
 // @Param taskSdkAdd body controllers.TaskSdkAdd true "浠诲姟id"
@@ -133,12 +200,13 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 浠诲姟鍒犻櫎绠楁硶
 // @Description 鏍规嵁taskid鍜宻dkid鍒犻櫎
 // @Produce json
 // @Tags task
-// @Param taskId path string true "浠诲姟id"
-// @Param sdkId path string true "绠楁硶id"
+// @Param taskId query string true "浠诲姟id"
+// @Param sdkId query string true "绠楁硶id"
 // @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/delTaskSdk [GET]
@@ -160,12 +228,14 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 鏇存柊浠诲姟鍚嶇О
 // @Description 鏇存柊浠诲姟鍚嶇О
+// @Accept x-www-form-urlencoded
 // @Produce json
 // @Tags task
-// @Param taskId query string true "taskId"
-// @Param taskName query string true "taskName"
+// @Param taskId formData string true "taskId"
+// @Param taskName formData string true "taskName"
 // @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/updateTaskName [POST]
@@ -192,8 +262,10 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 鏇存柊浠诲姟鐘舵��
 // @Description 锛堢畻娉曚笉鍙�,鍙洿鏂颁换鍔$姸鎬侊級
+// @Accept json
 // @Produce json
 // @Tags task
 // @Param taskStatus body controllers.TaskStatusVo true "鍙傛暟"
@@ -218,13 +290,13 @@
 	}
 }
 
-
 /*
+// @Security ApiKeyAuth
 // @Summary 鍒犻櫎浠诲姟
 // @Description 鏍规嵁浠诲姟id鍒犻櫎浠诲姟
 // @Produce json
 // @Tags task
-// @Param taskId path string true "浠诲姟id"
+// @Param taskId query string true "浠诲姟id"
 // @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/delete [GET]
@@ -259,6 +331,7 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 淇濆瓨绠楁硶瑙勫垯
 // @Description 淇濆瓨绠楁硶瑙勫垯
 // @Accept json
@@ -287,11 +360,14 @@
 }
 
 /*
+// @Security ApiKeyAuth
 // @Summary 鍒犻櫎绠楁硶瑙勫垯
 // @Description 鍒犻櫎绠楁硶瑙勫垯
+// @Accept x-www-form-urlencoded
 // @Produce json
 // @Tags 绠楁硶瑙勫垯
-// @Param id query string true "id"
+// @Param taskId formData string true "taskId"
+// @Param sdkId formData string true "sdkId"
 // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
 // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
 // @Router /data/api-v/task/deleteTaskSdkRule [post]
@@ -311,14 +387,14 @@
 	}
 }
 
-
 /*
+// @Security ApiKeyAuth
 // @Summary 鏌ヨ绠楁硶瑙勫垯
 // @Description 鏌ヨ绠楁硶瑙勫垯
 // @Produce json
 // @Tags 绠楁硶瑙勫垯
-// @Param taskId path string true "浠诲姟id"
-// @Param sdkId path string true "绠楁硶id"
+// @Param taskId query string true "浠诲姟id"
+// @Param sdkId query string true "绠楁硶id"
 // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
 // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
 // @Router /data/api-v/task/getRulesByTaskSdk [get]
@@ -338,3 +414,23 @@
 		util.ResponseFormat(c,code.ComError,"鏌ヨ澶辫触")
 	}
 }
+
+/*
+// @Security ApiKeyAuth
+// @Summary 缁熻姣忎釜浠诲姟鐨勬憚鍍忔満鏁伴噺
+// @Description 缁熻姣忎釜浠诲姟鐨勬憚鍍忔満鏁伴噺
+// @Produce json
+// @Tags task
+// @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}"
+// @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}"
+// @Router /data/api-v/task/statisticTaskCamera [get]
+*/
+func (tc TaskController) StatisticTaskCamera(c *gin.Context) {
+	var taskApi dbapi.TaskApi
+	b,d := taskApi.StatisticTaskCamera()
+	if b {
+		util.ResponseFormat(c,code.Success, d)
+	} else {
+		util.ResponseFormat(c,code.ComError, "")
+	}
+}

--
Gitblit v1.8.0