zhaoqingang
2025-02-10 2332cb0d6829a421b4d1826bb1825f9df6afdd74
测试 场景分析 bug
1个文件已修改
45 ■■■■■ 已修改文件
models/locationAnalysis.go 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/locationAnalysis.go
@@ -327,44 +327,34 @@
        }
        filters = append(filters, addrParams)
    }
    //// 重点人员过滤
    //if len(locationModel.KeyPersonType) > 0 {
    //    filters = append(filters, map[string]interface{}{
    //        "terms": map[string]interface{}{
    //            "keyPersonType": strings.Split(locationModel.KeyPersonType, ","),
    //        },
    //    })
    //}
    // 时间范围
    //filters = append(filters, map[string]interface{}{
    //    "range": map[string]interface{}{
    //        "picDate": map[string]interface{}{
    //            "gte": start.Format(time.DateTime),
    //            "lt":  now.Format(time.DateTime),
    //        },
    //    },
    //})
    var queryTimes []map[string]interface{}
    //var queryTimes []map[string]interface{}
    for date := startTime; date.Before(nowTime); date = date.Add(24 * time.Hour) {
        start := time.Date(date.Year(), date.Month(), date.Day(), locationModel.StartTime, 0, 0, 0, date.Location())
        end := time.Date(date.Year(), date.Month(), date.Day(), locationModel.EndTime, 0, 0, 0, date.Location())
        queryTimes = append(queryTimes, map[string]interface{}{
        //queryTimes = append(queryTimes, map[string]interface{}{
        //    "range": map[string]interface{}{
        //        "picDate": map[string]interface{}{
        //            "gte": start.Format(time.DateTime), // "2006-01-02 15:04:05d"
        //            "lte": end.Format(time.DateTime),
        //        },
        //    },
        //})
        filters = append(filters, map[string]interface{}{
            "range": map[string]interface{}{
                "picDate": map[string]interface{}{
                    "gte": start.Format(time.DateTime), // "2006-01-02 15:04:05d"
                    "gte": start.Format(time.DateTime),
                    "lte": end.Format(time.DateTime),
                },
            },
        })
    }
    filters = append(filters, map[string]interface{}{
        "bool": map[string]interface{}{
            "should": queryTimes,
        },
    })
    //filters = append(filters, map[string]interface{}{
    //    "bool": map[string]interface{}{
    //        "filter": queryTimes,
    //    },
    //})
    logger.Debugf("filters--------------------------------------- %s", filters)
    query := map[string]interface{}{
        "query": map[string]interface{}{
@@ -454,6 +444,7 @@
    if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
        return nil, fmt.Errorf("error parsing response body: %s", err)
    }
    logger.Debugf("result--------------------------------------- %s", result)
    // 解析聚合结果
    var records []*LocationRecord
    if aggs, ok := result["aggregations"].(map[string]interface{}); ok {