sunty
2019-06-25 f3863b12653fc47996073710b56e792de0be4c8d
根据新索引结构修改算法和接口
9个文件已修改
205 ■■■■ 已修改文件
controllers/androidAction.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/capture.go 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtableperson.go 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/dbtablesCon.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/es.go 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/esSearch.go 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/monitoring.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
extend/esutil/EsClient.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/CameraVideoService.go 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/androidAction.go
@@ -2,7 +2,6 @@
import (
    "fmt"
    "github.com/gin-gonic/gin"
    "webserver/extend/code"
    "webserver/extend/config"
@@ -29,8 +28,8 @@
    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)
controllers/capture.go
@@ -3,11 +3,11 @@
import (
    "fmt"
    "github.com/gin-gonic/gin"
    "strings"
    "webserver/extend/code"
    "webserver/extend/config"
    "webserver/extend/esutil"
    "webserver/extend/util"
    "strings"
)
type RealTimeController struct{}
@@ -27,22 +27,22 @@
    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{}) {
controllers/dbtableperson.go
@@ -8,12 +8,12 @@
    "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 {
@@ -113,13 +113,16 @@
// @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) {
@@ -130,6 +133,7 @@
        util.ResponseFormat(c, code.ServiceInsideError, result["data"])
    }
}
// @Summary 删除底库人员
// @Description 删除库人员
// @Accept  json
@@ -146,8 +150,8 @@
    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,"删除成功"))
@@ -209,7 +213,7 @@
    }
    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" {
@@ -219,13 +223,12 @@
    }
    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 查询库人员列表
@@ -253,12 +256,13 @@
    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
    }
    //输入框内容
@@ -285,7 +289,7 @@
    }
    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)
@@ -302,11 +306,14 @@
    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)
}
controllers/dbtablesCon.go
@@ -4,13 +4,13 @@
    "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 {
@@ -31,13 +31,13 @@
    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)
@@ -53,10 +53,6 @@
    data := esutil.GetEsDataInfo(url, true)
    return data
    }
// @Summary 修改底库
// @Description 修改同步或本地库
@@ -146,7 +142,7 @@
    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, "删除成功"))
controllers/es.go
@@ -4,15 +4,15 @@
    "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{}
@@ -31,14 +31,23 @@
    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)
@@ -82,10 +91,16 @@
            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"
                }
            }
        }
    }
@@ -94,7 +109,6 @@
    dmap["total"] = dataLen
    util.ResponseFormat(c, code.Success, dmap)
}
// @Summary 查询摄像机以及启算法
// @Description 关联查询摄像机以及启算法
@@ -148,14 +162,15 @@
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
@@ -164,11 +179,11 @@
        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
@@ -178,10 +193,10 @@
        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
@@ -197,19 +212,18 @@
//    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"
controllers/esSearch.go
@@ -46,7 +46,7 @@
    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)
@@ -59,11 +59,11 @@
        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
@@ -75,10 +75,10 @@
        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底层机制处理分页
@@ -90,13 +90,13 @@
        "\"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)
    //数据解析
@@ -104,7 +104,7 @@
    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]
controllers/monitoring.go
@@ -26,11 +26,11 @@
    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 := ""
@@ -44,12 +44,12 @@
        "/" + 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{}) {
extend/esutil/EsClient.go
@@ -9,7 +9,6 @@
    "log"
    "mime/multipart"
    "net/http"
    "strconv"
    "strings"
    "time"
@@ -46,11 +45,11 @@
        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
@@ -62,10 +61,10 @@
}
//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) //  配置信息 获取
service/CameraVideoService.go
@@ -16,10 +16,12 @@
    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))       } // 页码
@@ -35,7 +37,7 @@
        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 != "" {
@@ -43,10 +45,8 @@
            "\"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
}