| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | databases := searchBody.DataBases |
| | | from := 0 |
| | | to := 0 |
| | | |
| | | data := make(map[string]interface{}) |
| | | searchBody.Page = 1 |
| | | searchBody.Size = 15000 |
| | | |
| | | if len(databases) == 1 && databases[0] == "esData" { |
| | | searchBody.IsAggs = false |
| | | } else { |
| | | data = service.QueryDbPersonsForCompare(*searchBody) |
| | | 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) |
| | | } |
| | | } |
| | | sources := data["datalist"].([]interface{}) |
| | | |
| | | if len(sources) > 0 { |
| | | //进行比对 |
| | | } else { |
| | | fmt.Println("查询条件下无数据 source 数据为空:" + string(len(sources))) |
| | | } |
| | | dataLen := len(sources) |
| | | if from > dataLen-1 { |
| | | from = 0 |
| | | to = 0 |
| | | } |
| | | if to > dataLen { |
| | | to = dataLen |
| | | } |
| | | |
| | | dmap := make(map[string]interface{}, 2) |
| | | dmap["datalist"] = sources |
| | | dmap["total"] = dataLen |
| | | util.ResponseFormat(c, code.Success, dmap) |
| | | |
| | | m :=make(map[string]interface{},0) |
| | | m["compareNum"] = searchBody.CompareNum |
| | | m["total"] = 0 |
| | | m["totalList"] = []service.CompareResult{} |
| | | util.ResponseFormat(c,code.CompareResultGone,m) |
| | | } |
| | | |
| | | func searchEsData(searchBody models.EsSearch) map[string]interface{} { |
| | |
| | | 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() |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | NotLogin = &Code{ http.StatusUnauthorized, false, "登录失效,请重新登录"} |
| | | DbPersonUploadSuccess = &Code{ http.StatusOK, true, "人员上传成功"} |
| | | DbPersonUpdateSuccess = &Code{ http.StatusOK, true, "人员更新成功"} |
| | | |
| | | CompareResultGone = &Code{ http.StatusOK,true,"上次比对已失效,请从新比对"} |
| | | ComError = &Code{http.StatusInternalServerError, false, ""} |
| | | ) |
| | |
| | | InputValue string `json:"inputValue"`//输入框 |
| | | Collection string `json:"collection"`// |
| | | AlarmLevel []string `json:"alarmLevel"`//布防等级 |
| | | CompareNum string `json:"compareNum"`//比对编号 |
| | | } |