sunty
2020-01-13 3dddd55662df78b3603bd0ab4d0aad4c8cdf3e53
fix should
5个文件已修改
57 ■■■■ 已修改文件
controllers/capture.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/es.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/esSearch.go 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/initForData.go 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/monitoring.go 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/capture.go
@@ -44,9 +44,9 @@
    }
    //请求头
    localConf, err2 := cache.GetServerInfo()
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        util.ResponseFormat(c,code.ComError,"es config err")
        util.ResponseFormat(c, code.ComError, "es config err")
        return
    }
    url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
@@ -67,7 +67,7 @@
        linkTagInfoAnalyServerFilterStr +
        "{\"range\":{\"linkTagInfo.picDate\":{\"gte\":\"now+8h-15s\",\"lt\":\"now+8h\"}}}" +
        "]}}" +
        "]}}," +
        "],\"minimum_should_match\":1}}," +
        "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
        "\"size\":\"1000\"," +
        "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}}"
controllers/es.go
@@ -66,7 +66,6 @@
    util.ResponseFormat(c, code.CompareResultGone, m)
}
func sourceCompare(sources []interface{}, isEsSource bool, campareByte []byte, threshold float32) []interface{} {
    var filterName = "feature"
    if isEsSource {
@@ -396,10 +395,6 @@
type Hosts struct {
    NewIp string `json:newIp`
    OldIp string `json:oldIp`
}
func forwardCommand() {
}
//func AddEsCluster(hosts []string) (string){
controllers/esSearch.go
@@ -34,8 +34,8 @@
    var arg models.EsSearch
    err := c.BindJSON(&arg)
    if err !=nil || arg.Page <=0 && arg.Size<=0 {
        util.ResponseFormat(c,code.RequestParamError,"参数有误")
    if err != nil || arg.Page <= 0 && arg.Size <= 0 {
        util.ResponseFormat(c, code.RequestParamError, "参数有误")
        return
    }
    data := findEsData(&arg)
@@ -105,7 +105,7 @@
    //判断数据ID
    idStr := ""
    linkTagInfoIdStr :=""
    linkTagInfoIdStr := ""
    //personId := searchBody.Id
    id := []string{}
    if id != nil && len(id) > 0 {
@@ -165,7 +165,7 @@
    //使用es底层机制处理分页
    //请求头
    localConf, err2 := cache.GetServerInfo()
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        return nil
    }
@@ -188,7 +188,7 @@
        isCollectStr +
        esTableIdStr +
        analyServerFilterStr +
        "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}"+
        "{\"range\":{\"picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}" +
        "]}}," +
        "{\"bool\":{\"filter\":[" +
        linkTagInfoCameraIdStr +
@@ -198,13 +198,13 @@
        linkTagInfoIsCollectStr +
        linkTagInfoEsTableIdStr +
        linkTagInfoAnalyServerFilterStr +
        "{\"range\":{\"linkTagInfo.picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}"+
        "{\"range\":{\"linkTagInfo.picDate\":{\"from\":\"" + gteDate + "\",\"to\":\"" + lteDate + "\",\"include_lower\":true,\"include_upper\":true,\"boost\":1}}}" +
        "]}}" +
        "]}}," +
        "],\"minimum_should_match\":1}}," +
        "\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"picDate\":{\"order\":\"desc\"}}]," +
        "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}" +
        "}"
    logger.Debug("findEsData.param:",prama)
    logger.Debug("findEsData.param:", prama)
    //数据解析
    tokenRes := esutil.GetEsDataReq(url, prama, true)
    //fmt.Println(tokenRes)
@@ -219,7 +219,7 @@
        if masterInfo["linkTagInfo"] != nil {
            linkTagInfo := masterInfo["linkTagInfo"].([]interface{})
            delete(masterInfo, "linkTagInfo")
            if len(linkTagInfo) >0 {
            if len(linkTagInfo) > 0 {
                slaveList := make([]interface{}, 0)
                slaveList = append(slaveList, masterInfo)
                slaveList = append(slaveList, linkTagInfo...)
@@ -230,7 +230,7 @@
                }
            }
        } else {
            if _,ok := masterInfo["linkTagInfo"];ok {
            if _, ok := masterInfo["linkTagInfo"]; ok {
                delete(masterInfo, "linkTagInfo")
            }
            sources["list"] = []interface{}{
controllers/initForData.go
@@ -33,16 +33,16 @@
    c.BindJSON(&searchBody)
    index := config.EsInfo.EsIndex.AiOcean.IndexName
    localConf, err2 := cache.GetServerInfo()
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        util.ResponseFormat(c,code.ComError,"localConf wrong")
        util.ResponseFormat(c, code.ComError, "localConf wrong")
        return
    }
    url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
        "/" + index + "/_search"
    cameraIdStr := ""
    linkTagInfoCameraIdStr := ""
    if searchBody.TreeNodes !=nil {
    if searchBody.TreeNodes != nil {
        cameraId := searchBody.TreeNodes
        if cameraId != nil && len(cameraId) > 0 {
            esCameraId := strings.Replace(strings.Trim(fmt.Sprint(cameraId), "[]"), " ", "\",\"", -1)
@@ -65,7 +65,7 @@
        linkTagInfoCameraIdStr +
        linkTagInfoAnalyServerFilterStr +
        "]}}" +
        "]}}," +
        "],\"minimum_should_match\":1}}," +
        "\"size\":\"20\",\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
        "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}" +
        "}"
@@ -76,7 +76,7 @@
type InitForMonitorArg struct {
    TreeNodes []string `json:"treeNodes"`
    Tasks []string `json:"tasks"`
    Tasks     []string `json:"tasks"`
}
// @Security ApiKeyAuth
@@ -113,9 +113,9 @@
    }
    //请求头
    localConf, err2 := cache.GetServerInfo()
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        util.ResponseFormat(c,code.ComError,"localConf wrong")
        util.ResponseFormat(c, code.ComError, "localConf wrong")
        return
    }
    url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
@@ -135,7 +135,7 @@
        linkTagInfoCameraIdStr +
        linkTagInfoAnalyServerFilterStr +
        "]}}" +
        "]}}," +
        "],\"minimum_should_match\":1}}," +
        "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
        "\"size\":\"20\"," +
        "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}}"
controllers/monitoring.go
@@ -49,9 +49,9 @@
    }
    //请求头
    localConf, err2 := cache.GetServerInfo()
    if err2 !=nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
    if err2 != nil || localConf.AlarmIp == "" || localConf.ServerId == "" {
        logger.Debug("localConfig is wrong!!!")
        util.ResponseFormat(c,code.ComError,"localConf wrong")
        util.ResponseFormat(c, code.ComError, "localConf wrong")
        return
    }
    url := "http://" + localConf.AlarmIp + ":" + strconv.Itoa(int(localConf.AlarmPort)) +
@@ -73,12 +73,12 @@
        linkTagInfoAnalyServerFilterStr +
        "{\"range\":{\"linkTagInfo.picDate\":{\"gte\":\"now+8h-15s\",\"lt\":\"now+8h\"}}}" +
        "]}}" +
        "]}}," +
        "],\"minimum_should_match\":1}}," +
        "\"sort\":[{\"picDate\":{\"order\":\"desc\"}}]," +
        "\"size\":\"1000\"," +
        "\"_source\":{\"includes\":[],\"excludes\":[\"*.feature\"]}}"
    logger.Debug("monitor param:",prama)
    logger.Debug("monitor url:",url)
    logger.Debug("monitor param:", prama)
    logger.Debug("monitor url:", url)
    tokenRes := esutil.GetEsDataReq(url, prama, true)
    /*    for _, value := range tokenRes["datalist"].([]interface{}) {
        if value.(map[string]interface{})["personId"] != nil {