| | |
| | | |
| | | import ( |
| | | "fmt" |
| | | |
| | | "github.com/gin-gonic/gin" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | |
| | | index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + index + "/_search" |
| | | prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"personIsHub\":\"1\"}},{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + sec + "s\",\"lt\":\"now+8h\"}}}]}},\"size\":\"1000\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + |
| | | prama := "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"isAlarm\":\"1\"}},{\"range\":{\"picDate\":{\"gte\":\"now+8h-" + sec + "s\",\"lt\":\"now+8h\"}}}]}},\"size\":\"1000\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"isAlarm\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]" + |
| | | "}" |
| | | fmt.Println(prama) |
| | | tokenRes := esutil.GetEsDataReq(url, prama, true) |
| | |
| | | import ( |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "strings" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "strings" |
| | | ) |
| | | |
| | | type RealTimeController struct{} |
| | |
| | | |
| | | c.BindJSON(&searchBody) |
| | | index := config.EsInfo.EsIndex.VideoPersons.IndexName + "," + config.EsInfo.EsIndex.Personaction.IndexName |
| | | videoReqNumStr := "" |
| | | videoReqNum := searchBody["treeNodes"].([]interface{}) |
| | | if videoReqNum != nil && len(videoReqNum) > 0 { |
| | | esVideoReqNum := strings.Replace(strings.Trim(fmt.Sprint(videoReqNum), "[]"), " ", "\",\"", -1) |
| | | videoReqNumStr = "{\"terms\":{\"videoReqNum\":[\"" + esVideoReqNum + "\"]}}," |
| | | cameraIdStr := "" |
| | | cameraId := searchBody["treeNodes"].([]interface{}) |
| | | if cameraId != nil && len(cameraId) > 0 { |
| | | esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) |
| | | cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," |
| | | } |
| | | //请求头 |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + index + "/_search" |
| | | |
| | | prama := "{\"query\":{\"bool\":{\"filter\":[" + |
| | | videoReqNumStr + |
| | | cameraIdStr + |
| | | "{\"range\":{\"picDate\":{\"gte\":\"now+8h-5s\",\"lt\":\"now+8h\"}}}]}}," + |
| | | "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"size\":\"1000\"," + |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]}" |
| | | "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" |
| | | fmt.Println(prama) |
| | | tokenRes := esutil.GetEsDataReq(url, prama, true) |
| | | /*for _, value := range tokenRes["datalist"].([]interface{}) { |
| | |
| | | "time" |
| | | |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/satori/go.uuid" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | "github.com/satori/go.uuid" |
| | | ) |
| | | |
| | | type DbPersonController struct { |
| | |
| | | // @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}" |
| | | // @Failure 500 {string} json "{"code":500, msg:"返回错误信息", success:false}" |
| | | // @Router /data/api-v/dbperson/deleteDbPersonById/{uuid} [POST] |
| | | |
| | | func (dbc DbPersonController) DeleteDbPerson(c *gin.Context) { |
| | | uuid := c.Params.ByName("uuid") |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + uuid + "/_update?refresh=wait_for" |
| | | params := "{\"doc\":{\"del_flag\":\"1\",\"update_time\":\"" + time.Now().Format("2006-01-02 15:04:05") + "\"}}" |
| | | params := "{\"doc\":{\"isDelete\":\"1\",\"updateTime\":\"" + time.Now().Format("2006-01-02 15:04:05") + "\"}}" |
| | | fmt.Print("删除请求url:%s;\n 请求参数params:%s", url, params) |
| | | |
| | | data := esutil.GetEsDataReq(url, params, false) |
| | | |
| | | //c.JSON(200, changeEsRespData(data,"删除成功")) |
| | | result := changeEsRespData(data, "删除成功") |
| | | if result["success"].(bool) { |
| | |
| | | util.ResponseFormat(c, code.ServiceInsideError, result["data"]) |
| | | } |
| | | } |
| | | |
| | | // @Summary 删除底库人员 |
| | | // @Description 删除库人员 |
| | | // @Accept json |
| | |
| | | s := string(bytes) |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + config.EsInfo.EsIndex.Dbtablepersons.IndexName + "/_update_by_query?refresh=wait_for" // + config.EsInfo.EsIndex.Dbtablepersons.IndexType + "/" + "/" + s |
| | | params := "{\"script\":{\"lang\":\"painless\",\"inline\":\"ctx._source.del_flag = \\\"1\\\";" + |
| | | "ctx._source.update_time = \\\"" + time.Now().Format("2006-01-02 15:04:05") + "\\\"\"},\"query\":{\"terms\":{\"_id\":"+s+"}}}" |
| | | params := "{\"script\":{\"lang\":\"painless\",\"inline\":\"ctx._source.isDelete = \\\"1\\\";" + |
| | | "ctx._source.updateTime = \\\"" + time.Now().Format("2006-01-02 15:04:05") + "\\\"\"},\"query\":{\"terms\":{\"_id\":" + s + "}}}" |
| | | fmt.Print("删除请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, false) |
| | | //c.JSON(200, changeEsRespData(data,"删除成功")) |
| | |
| | | } |
| | | if contentValue != "" { |
| | | contentParam = ",\"must\":[{\"multi_match\":{\"query\":\"" + contentValue + "\",\"type\":\"best_fields\"," + |
| | | "\"fields\":[\"personName\",\"sex\",\"idcard\",\"phoneNum\"],\"tie_breaker\":0.3}}]" |
| | | "\"fields\":[\"personName\",\"sex\",\"idCard\",\"phoneNum\"],\"tie_breaker\":0.3}}]" |
| | | } |
| | | |
| | | if orderType == "desc" { |
| | |
| | | } |
| | | |
| | | params := "{\"query\":{\"bool\":{\"filter\":[" + |
| | | "{\"term\":{\"del_flag\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" |
| | | "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" |
| | | fmt.Print("请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, true) |
| | | //c.JSON(200, data) |
| | | util.ResponseFormat(c, code.Success, data) |
| | | } |
| | | |
| | | |
| | | // @Summary 查询底库人员列表 |
| | | // @Description 查询库人员列表 |
| | |
| | | if reqBody["orderType"] != nil { |
| | | orderType = reqBody["orderType"].(string) |
| | | } // 列类型 |
| | | faceUrl := ""; var threshold float32 |
| | | faceUrl := "" |
| | | var threshold float32 |
| | | if reqBody["faceUrl"] != nil && reqBody["threshold"] != nil{ |
| | | faceUrl = reqBody["faceUrl"].(string) |
| | | threshold = float32(reqBody["threshold"].(float64)) |
| | | }else { |
| | | util.ResponseFormat(c, code.RequestParamError, nil); // 图片路径有问题 |
| | | util.ResponseFormat(c, code.RequestParamError, nil) // 图片路径有问题 |
| | | return |
| | | } |
| | | //输入框内容 |
| | |
| | | } |
| | | |
| | | params := "{\"query\":{\"bool\":{\"filter\":[" + |
| | | "{\"term\":{\"del_flag\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" |
| | | "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":" + strconv.Itoa(from) + ",\"size\":" + strconv.Itoa(size) + ",\"sort\":{\"" + orderName + "\":{\"order\":\"" + orderType + "\"}}}" |
| | | fmt.Print("请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, true) |
| | | featByte := make([]byte,0,1024) |
| | |
| | | to := page*size |
| | | datalist := sourceCompare(data["datalist"].([]interface{}),false,featByte,threshold ) |
| | | total := len(datalist) |
| | | if from > total { from = total } |
| | | if to > total { to = total } |
| | | if from > total { |
| | | from = total |
| | | } |
| | | if to > total { |
| | | to = total |
| | | } |
| | | data["datalist"] = datalist[from:to] |
| | | data["total"] = len(datalist) |
| | | //c.JSON(200, data) |
| | | util.ResponseFormat(c, code.Success, data) |
| | | } |
| | | |
| | |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/satori/go.uuid" |
| | | "log" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | "github.com/satori/go.uuid" |
| | | "log" |
| | | ) |
| | | |
| | | type DbTableController struct { |
| | |
| | | isSync := c.Params.ByName("isSync") |
| | | syncTerm := "" |
| | | if isSync == "1" { |
| | | syncTerm = ",{\"term\":{\"syncType\":\"1\"}}" // 同步库 |
| | | syncTerm = ",{\"term\":{\"isSync\":\"1\"}}" // 同步库 |
| | | } else if isSync == "2" { |
| | | syncTerm = ",{\"term\":{\"syncType\":\"2\"}}" // / 本地库 |
| | | syncTerm = ",{\"term\":{\"isSync\":\"2\"}}" // / 本地库 |
| | | } |
| | | params := "{\"query\":{\"bool\":{\"must\":[" + |
| | | "{\"term\":{\"del_flag\":\"0\"}}" + syncTerm + "]}}," + |
| | | "\"from\":0,\"size\":100,\"sort\":{\"uuid\":{\"order\":\"asc\"}}}" |
| | | "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]}}," + |
| | | "\"from\":0,\"size\":100,\"sort\":{\"id\":{\"order\":\"asc\"}}}" |
| | | fmt.Print("请求url:%s;\n 请求参数params:%s", url, params) |
| | | |
| | | data := esutil.GetEsDataReq(url, params, true) |
| | |
| | | data := esutil.GetEsDataInfo(url, true) |
| | | return data |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // @Summary 修改底库 |
| | | // @Description 修改同步或本地库 |
| | |
| | | uuid := c.Params.ByName("uuid") |
| | | url := "http://" + config.EsInfo.Masterip + ":" + config.EsInfo.Httpport + |
| | | "/" + config.EsInfo.EsIndex.DbTables.IndexName + "/" + config.EsInfo.EsIndex.DbTables.IndexType + "/" + uuid + "/_update" |
| | | params := "{\"doc\":{\"del_flag\":\"1\"}}" |
| | | params := "{\"doc\":{\"isDelete\":\"1\"}}" |
| | | fmt.Print("删除请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, false) |
| | | //c.JSON(200, changeEsRespData(data, "删除成功")) |
| | |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "math/rand" |
| | | "strconv" |
| | | "strings" |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | "webserver/extend/util" |
| | | "webserver/models" |
| | | "webserver/service" |
| | | "math/rand" |
| | | "strconv" |
| | | "strings" |
| | | ) |
| | | |
| | | type EsController struct{} |
| | |
| | | c.BindJSON(&searchBody) |
| | | isEsSource := true |
| | | databases := searchBody.DataBases |
| | | page := searchBody.Page;if page <= 0 {page = 1} |
| | | size := searchBody.Size;if size <= 0 {size = 8} |
| | | page := searchBody.Page |
| | | if page <= 0 { |
| | | page = 1 |
| | | } |
| | | size := searchBody.Size |
| | | if size <= 0 { |
| | | size = 8 |
| | | } |
| | | from := (page - 1) * size |
| | | to := page * size |
| | | threshold := searchBody.Threshold;if threshold < 0 || threshold > 100 {threshold = 60} |
| | | threshold := searchBody.Threshold |
| | | if threshold < 0 || threshold > 100 { |
| | | threshold = 60 |
| | | } |
| | | picUrl := searchBody.PicUrl |
| | | /*feature := searchBody.Feature*/ |
| | | var featByte []byte; |
| | | var featByte []byte |
| | | if len(picUrl) > 3 { // linux |
| | | /*fileName := picUrl // picIp 定义在 fileController weedfs 文件服务器 访问 路径 前缀 |
| | | detect := gorun.GetSimpleFaceDetect(fileName) |
| | |
| | | tableId := sou.(map[string]interface{})["tableId"] |
| | | if tableId != nil { |
| | | info := QueryDbTableInfo(tableId.(string)) |
| | | if info["tableName"] != nil {sou.(map[string]interface{})["tableName"] = info["tableName"] |
| | | }else {sou.(map[string]interface{})["tableName"] = "其他"} |
| | | if info["bwType"] != nil {sou.(map[string]interface{})["bwType"] = info["bwType"] |
| | | }else {sou.(map[string]interface{})["bwType"] = "4"} |
| | | if info["tableName"] != nil { |
| | | sou.(map[string]interface{})["tableName"] = info["tableName"] |
| | | } else { |
| | | sou.(map[string]interface{})["tableName"] = "其他" |
| | | } |
| | | if info["bwType"] != nil { |
| | | sou.(map[string]interface{})["bwType"] = info["bwType"] |
| | | } else { |
| | | sou.(map[string]interface{})["bwType"] = "4" |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | dmap["total"] = dataLen |
| | | util.ResponseFormat(c, code.Success, dmap) |
| | | } |
| | | |
| | | |
| | | // @Summary 查询摄像机以及启算法 |
| | | // @Description 关联查询摄像机以及启算法 |
| | |
| | | func searchEsData(searchBody models.EsSearch) map[string]interface{} { |
| | | //请求索引 |
| | | index := config.EsInfo.EsIndex.VideoPersons.IndexName // wp只查人脸数据 |
| | | queryStr := ""; |
| | | queryStr := "" |
| | | queryBody := searchBody.InputValue |
| | | //检索框 |
| | | if queryBody != "" { |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"tableName^1.5\",\"gender^2.0\",\"race^2.0\",\"content^1.0\",\"idcard^1.8\",\"picAddress^1.0\"]," + |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"tableName^1.5\",\"sex^2.0\",\"race^2.0\",\"content^1.0\",\"idCard^1.8\",\"cameraAddr^1.0\"]," + |
| | | "\"type\":\"cross_fields\",\"operator\":\"OR\",\"slop\":0,\"prefix_length\":0,\"max_expansions\":50,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1}}]," |
| | | } |
| | | gteDate := searchBody.SearchTime[0];lteDate := searchBody.SearchTime[1] |
| | | gteDate := searchBody.SearchTime[0] |
| | | lteDate := searchBody.SearchTime[1] |
| | | //判断任务ID |
| | | taskIdStr := "" |
| | | taskId := searchBody.Tasks |
| | |
| | | taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}}," |
| | | } |
| | | //判断摄像机ID |
| | | videoReqNumStr := "" |
| | | videoReqNum := searchBody.TreeNodes |
| | | if videoReqNum != nil && len(videoReqNum) > 0 { |
| | | esVideoReqNum := strings.Replace(strings.Trim(fmt.Sprint(videoReqNum), "[]"), " ", "\",\"", -1) |
| | | videoReqNumStr = "{\"terms\":{\"videoReqNum\":[\"" + esVideoReqNum + "\"]}}," |
| | | cameraIdStr := "" |
| | | cameraId := searchBody.TreeNodes |
| | | if cameraId != nil && len(cameraId) > 0 { |
| | | esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) |
| | | cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," |
| | | } |
| | | //判断库表ID |
| | | tableId := searchBody.Tabs |
| | |
| | | esTableId = strings.Replace(strings.Trim(fmt.Sprint(tableId), "[]"), " ", "\",\"", -1) |
| | | esTableIdStr = "{\"terms\":{\"tableId\":[\"" + esTableId + "\"]}}," |
| | | } |
| | | collectionStr := "" |
| | | collection := searchBody.Collection |
| | | if collection != "" { |
| | | collectionStr = "{\"term\":{\"collection\":\"" + collection + "\"}}," |
| | | isCollectionStr := "" |
| | | isCollection := searchBody.Collection |
| | | if isCollection != "" { |
| | | isCollectionStr = "{\"term\":{\"collection\":\"" + isCollection + "\"}}," |
| | | } |
| | | webPage := searchBody.Page |
| | | webSize := searchBody.Size |
| | |
| | | // prama := "{\"size\":\"0\"," + |
| | | "\"query\":{\"bool\":{" + queryStr + |
| | | "\"filter\":[" + |
| | | videoReqNumStr + |
| | | cameraIdStr + |
| | | taskIdStr + |
| | | collectionStr + |
| | | isCollectionStr + |
| | | esTableIdStr + |
| | | "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + |
| | | "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"tableName\",\"gender\",\"race\",\"content\",\"IDCard\",\"picAddress\",\"picDate\",\"sdkType\",\"age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"videoReqNum\",\"baseInfo\"]}"; |
| | | "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]}" |
| | | fmt.Println(prama) |
| | | //数据解析 |
| | | tokenRes := esutil.GetEsDataReq(url, prama, true) |
| | | return tokenRes |
| | | } |
| | | |
| | | |
| | | func sourceCompare(sources []interface{}, isEsSource bool, campareByte []byte, threshold float32) []interface{} { |
| | | var filterName = "feature" |
| | |
| | | queryBody := searchBody["inputValue"].(string) |
| | | //检索框 |
| | | if queryBody != "" { |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"BaseName^1.5\",\"Gender^2.0\",\"Race^2.0\",\"content^1.0\",\"idcard^1.8\",\"picAddress^1.0\"]," + |
| | | queryStr = "\"must\":[{\"multi_match\":{\"query\":\"" + queryBody + "\",\"fields\":[\"tableName^1.5\",\"sex^2.0\",\"race^2.0\",\"content^1.0\",\"idCard^1.8\",\"cameraAddr^1.0\"]," + |
| | | "\"type\":\"cross_fields\",\"operator\":\"OR\",\"slop\":0,\"prefix_length\":0,\"max_expansions\":50,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"fuzzy_transpositions\":true,\"boost\":1}}]," |
| | | } |
| | | gteDate := searchBody["searchTime"].([]interface{})[0].(string) |
| | |
| | | taskIdStr = "{\"terms\":{\"taskId\":[\"" + esTaskId + "\"]}}," |
| | | } |
| | | //判断摄像机ID |
| | | videoReqNumStr := "" |
| | | videoReqNum := searchBody["treeNodes"].([]interface{}) |
| | | if videoReqNum != nil && len(videoReqNum) > 0 { |
| | | esVideoReqNum := strings.Replace(strings.Trim(fmt.Sprint(videoReqNum), "[]"), " ", "\",\"", -1) |
| | | videoReqNumStr = "{\"terms\":{\"videoReqNum\":[\"" + esVideoReqNum + "\"]}}," |
| | | cameraIdStr := "" |
| | | cameraId := searchBody["treeNodes"].([]interface{}) |
| | | if cameraId != nil && len(cameraId) > 0 { |
| | | esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) |
| | | cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," |
| | | } |
| | | |
| | | //判断库表ID |
| | |
| | | index = config.EsInfo.EsIndex.VideoPersons.IndexName |
| | | esTableIdStr = "{\"terms\":{\"tableId\":[\"" + esTableId + "\"]}}," |
| | | } |
| | | collectionStr := "" |
| | | collection := searchBody["collection"].(string) |
| | | if collection != "" { |
| | | collectionStr = "{\"term\":{\"collection\":\"" + collection + "\"}}," |
| | | isCollectStr := "" |
| | | isCollect := searchBody["collection"].(string) |
| | | if isCollect != "" { |
| | | isCollectStr = "{\"term\":{\"isCollect\":\"" + isCollect + "\"}}," |
| | | } |
| | | |
| | | //使用es底层机制处理分页 |
| | |
| | | "\"size\":\"" + size + "\"," + |
| | | "\"query\":{\"bool\":{" + queryStr + |
| | | "\"filter\":[" + |
| | | videoReqNumStr + |
| | | cameraIdStr + |
| | | taskIdStr + |
| | | collectionStr + |
| | | isCollectStr + |
| | | esTableIdStr + |
| | | "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}]}}," + |
| | | "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]" + |
| | | "\"_source\":[\"baseInfo\",\"alarmRules\",\"sex\",\"analyServerName\",\"sdkName\",\"ageDescription\",\"content\",\"id\",\"cameraAddr\",\"picMaxUrl\",\"picDate\",\"race\",\"videoUrl\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"isAlarm\",\"analyServerIp\",\"cameraId\"]" + |
| | | "}" |
| | | fmt.Println(prama) |
| | | //数据解析 |
| | |
| | | return tokenRes |
| | | } |
| | | |
| | | //sdkTYype字典"\"_source\":[\"BaseName\",\"Gender\",\"Race\",\"content\",\"idcard\",\"picAddress\",\"picDate\",\"sdkType\",\"Age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"videoReqNum\",\"ageDescription\",\"likePer\"]" + |
| | | //sdkTYype字典"\"_source\":[\"BaseName\",\"Gender\",\"Race\",\"content\",\"idcard\",\"picAddress\",\"picDate\",\"sdkType\",\"Age\",\"personId\",\"personIsHub\",\"personPicUrl\",\"picLocalUrl\",\"picSmUrl\",\"videoIp\",\"videoNum\",\"cameraId\",\"ageDescription\",\"likePer\"]" + |
| | | //func sdkTypeToValue(i int) string { |
| | | // value := []string{"人脸", "车辆", "人体", "入侵", "拥挤", "靠右行", "人员异常", "个体静止"} |
| | | // return value[i-1] |
| | |
| | | |
| | | c.BindJSON(&searchBody) |
| | | index := config.EsInfo.EsIndex.VideoPersons.IndexName |
| | | videoReqNumStr := "" |
| | | videoReqNum := searchBody["treeNodes"].([]interface{}) |
| | | if videoReqNum != nil && len(videoReqNum) > 0 { |
| | | esVideoReqNum := strings.Replace(strings.Trim(fmt.Sprint(videoReqNum), "[]"), " ", "\",\"", -1) |
| | | videoReqNumStr = "{\"terms\":{\"videoReqNum\":[\"" + esVideoReqNum + "\"]}}," |
| | | cameraIdStr := "" |
| | | cameraId := searchBody["treeNodes"].([]interface{}) |
| | | if cameraId != nil && len(cameraId) > 0 { |
| | | esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1) |
| | | cameraIdStr = "{\"terms\":{\"cameraId\":[\"" + esCameraId + "\"]}}," |
| | | } |
| | | //判断任务ID |
| | | taskIdStr := "" |
| | |
| | | "/" + index + "/_search" |
| | | |
| | | prama := "{\"query\":{\"bool\":{\"filter\":[" + |
| | | videoReqNumStr + |
| | | cameraIdStr + |
| | | taskIdStr + |
| | | "{\"range\":{\"picDate\":{\"gte\":\"now+8h-5s\",\"lt\":\"now+8h\"}}}]}}," + |
| | | "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," + |
| | | "\"size\":\"1000\"," + |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"videoReqNum\"]}" |
| | | "\"_source\":[\"baseInfo\",\"gender\",\"indeviceName\",\"sdkType\",\"ageDescription\",\"content\",\"ID\",\"picAddress\",\"picMaxUrl\",\"picDate\",\"race\",\"videoNum\",\"picSmUrl\",\"taskName\",\"personIsHub\",\"IDCard\",\"videoIp\",\"cameraId\"]}" |
| | | fmt.Println(prama) |
| | | tokenRes := esutil.GetEsDataReq(url, prama, true) |
| | | /* for _, value := range tokenRes["datalist"].([]interface{}) { |
| | |
| | | "log" |
| | | "mime/multipart" |
| | | "net/http" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | | |
| | |
| | | for _, value := range dat["hits"].([]interface{}) { |
| | | source := value.(map[string]interface{})["_source"].(map[string]interface{}) |
| | | source["id"] = value.(map[string]interface{})["_id"] |
| | | sdkType := source["sdkType"] |
| | | /*sdkType := source["sdkType"] |
| | | if sdkType != nil { |
| | | sdk, _ := strconv.Atoi(sdkType.(string)) |
| | | source["sdkType"] = sdkTypeToValue(sdk) |
| | | } |
| | | }*/ |
| | | sources = append(sources, source) |
| | | } |
| | | data["datalist"] = sources |
| | |
| | | } |
| | | |
| | | //sdk类型 |
| | | func sdkTypeToValue(i int) string { |
| | | /*func sdkTypeToValue(i int) string { |
| | | value := []string{"人脸", "车辆", "人体", "入侵", "拥挤", "靠右行", "人员异常", "个体静止"} |
| | | return value[i-1] |
| | | } |
| | | }*/ |
| | | |
| | | func PutEsDataReq(url string, parama string) (map[string]interface{}, error) { |
| | | //fmt.Println("es 查询请求路径" + url) // 配置信息 获取 |
| | |
| | | if reqBody.DataBases != nil { |
| | | tableIds = reqBody.DataBases |
| | | } |
| | | startDate := "";endDate := "" |
| | | startDate := "" |
| | | endDate := "" |
| | | if reqBody.SearchTime != nil && len(reqBody.SearchTime) >= 2 { |
| | | dates := reqBody.SearchTime |
| | | startDate = dates[0];endDate = dates[1] // 起始结束时间 |
| | | startDate = dates[0] |
| | | endDate = dates[1] // 起始结束时间 |
| | | } |
| | | contentValue := reqBody.InputValue //输入框内容 |
| | | /*page := 1 ;if reqBody["page"] != nil { page = int(reqBody["page"].(float64)) } // 页码 |
| | |
| | | syncTerm += ",{\"terms\":{\"tableId\":" + string(bytes) + "}}" // 底库人员 |
| | | } |
| | | if startDate != "" && endDate != "" { |
| | | syncTerm += ",{\"range\":{\"create_time\":{\"from\":\"" + startDate + "\"," + |
| | | syncTerm += ",{\"range\":{\"createTime\":{\"from\":\"" + startDate + "\"," + |
| | | "\"to\":\"" + endDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}" // 底库人员 |
| | | } |
| | | if contentValue != "" { |
| | |
| | | "\"fields\":[\"personName\",\"sex\",\"idcard\",\"phoneNum\",\"reserved\"],\"boost\":1}}]" |
| | | } |
| | | params := "{\"query\":{\"bool\":{\"filter\":[" + |
| | | "{\"term\":{\"del_flag\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":0,\"size\":10000,\"sort\":{\"uuid\":{\"order\":\"desc\"}}}" |
| | | "{\"term\":{\"isDelete\":\"0\"}}" + syncTerm + "]" + contentParam + "}},\"from\":0,\"size\":10000,\"sort\":{\"uuid\":{\"order\":\"desc\"}}}" |
| | | fmt.Print("查询全部底库人员 请求url:%s;\n 请求参数params:%s", url, params) |
| | | data := esutil.GetEsDataReq(url, params, true) |
| | | return data |
| | | } |
| | | |
| | | |