liuxiaolong
2019-07-27 b2782f7b8b49806ac67663e2ec9e25c44b69d041
controllers/fileController.go
@@ -163,6 +163,21 @@
      util.ResponseFormat(c, code.RequestParamError, "参数有误")
      return
   }
   if searchBody.CompareNum !="" {
      //二次搜索,不需要再比对了
      co := service.GetCompResultByNum(searchBody.CompareNum)
      if co != nil {
         //二次搜索和排序
         twiceM := GetCompareDataTwice(co,&searchBody)
         util.ResponseFormat(c,code.Success,twiceM)
      } else {
         m :=make(map[string]interface{},0)
         m["compareNum"] = searchBody.CompareNum
         m["total"] = 0
         m["totalList"] = []service.CompareResult{}
         util.ResponseFormat(c,code.CompareResultGone,m)
      }
   }
   var sysSetApi dbapi.SysSetApi
   analyServerId := ""
   flag, sysconf := sysSetApi.GetServerInfo()
@@ -221,6 +236,78 @@
   }
}
func GetCompareDataTwice(co *service.CompareOnce,arg *models.EsSearch) map[string]interface{} {
   camIds := arg.TreeNodes
   tabIds := arg.Tabs
   taskIds := arg.Tasks
   alarmLevels := arg.AlarmLevel
   timeArr := arg.SearchTime
   input := arg.InputValue
   resultList := make([]service.CompareResult,0)
   for _,cr :=range co.CompareData {
      if cr.Id !=""{
         n :=0
         if len(camIds) == 0 || isInArr(cr.CameraId,camIds) {
            n++
         }
         if len(tabIds) == 0 {
            n++
         }
         if len(taskIds) == 0 || isInArr(cr.TaskId, taskIds) {
            n++
         }
         //判断报警等级
         if len(alarmLevels) == 0 {
         }
         n++
         //判断时间
         if len(timeArr) == 0 {
         }
         n++
         if input == ""{
         }
         n++
         if n == 6 {
            resultList = append(resultList,cr)
         }
      } else {
         resultList = append(resultList,cr)
      }
   }
   logger.Debug("GetCompareDataTwice.data:",resultList)
   service.SortByScore(resultList)
   from := (arg.Page-1)*arg.Size
   to := from + arg.Size
   lenth := len(resultList)
   m := make(map[string]interface{},0)
   m["total"] = lenth
   m["compareNum"] = arg.CompareNum
   if from < len(resultList) {
      if to <= len(resultList) {
         m["totalList"] = resultList[from:to]
      } else {
         m["totalList"] = resultList[from:len(resultList)]
      }
   } else {
      m["totalList"] = []service.CompareResult{}
   }
   return m
}
func isInArr(id string,arr []string) bool {
   for _,v :=range arr {
      if v == id {
         return true
      }
   }
   return false
}
// @Description 人员照片上传并获取特征值
// @Router /data/api-v/dbperson/fileUploadTest [POST]
func (controller FileController) UploadPersonTest(c *gin.Context) {