Browse Source

解决重启后月季度年交通数据统计错误的问题

develop
xiepufeng 8 months ago
parent
commit
02a8683776
  1. 14
      zc-business/src/main/java/com/zc/business/constant/StatisticalRecoveryOffsetTime.java
  2. 11
      zc-business/src/main/java/com/zc/business/statistics/handler/TrafficStatistics.java

14
zc-business/src/main/java/com/zc/business/constant/StatisticalRecoveryOffsetTime.java

@ -1,14 +0,0 @@
package com.zc.business.constant;
/**
* 统计恢复偏移时间类
* 用于定义与交通数据恢复相关的偏移时间常量
*
* @author xiepufeng
*/
public class StatisticalRecoveryOffsetTime {
// 定义交通数据段偏移的天数常量,表示偏移-10天
public static final int TRAFFIC_SECTION_DATA_OFFSET_DAY = -10;
}

11
zc-business/src/main/java/com/zc/business/statistics/handler/TrafficStatistics.java

@ -113,21 +113,12 @@ public class TrafficStatistics {
* @return HashMap<String, Object> 包含查询条件的HashMap对象 * @return HashMap<String, Object> 包含查询条件的HashMap对象
*/ */
private HashMap<String, Object> buildPropertiesRequiredParameter() { private HashMap<String, Object> buildPropertiesRequiredParameter() {
// 获取数据统计的最大日期
Date maxStatisticalDate = dcTrafficSectionDataMapper.getMaxStatisticalDate();
// 如果最大统计日期为null,则计算默认的最大统计日期
if (maxStatisticalDate == null) {
maxStatisticalDate = DateUtil.offsetDay(new Date(), StatisticalRecoveryOffsetTime.TRAFFIC_SECTION_DATA_OFFSET_DAY);
}
HashMap<String, Object> props = new HashMap<>(); HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内 // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
props.put("terms[0].column", "timestamp$BTW"); props.put("terms[0].column", "timestamp$BTW");
ArrayList<String> dateList = new ArrayList<>(); ArrayList<String> dateList = new ArrayList<>();
// 添加当前日期的开始和结束时间到列表,用于设定时间范围 // 添加当前日期的开始和结束时间到列表,用于设定时间范围
dateList.add(DateUtil.beginOfDay(maxStatisticalDate).toString()); dateList.add(DateUtil.beginOfMonth(new Date()).toString());
dateList.add(DateUtil.endOfDay(new Date()).toString()); dateList.add(DateUtil.endOfDay(new Date()).toString());
// 将日期列表以逗号分隔并设置为查询条件的值 // 将日期列表以逗号分隔并设置为查询条件的值
props.put("terms[0].value", String.join(",", dateList)); props.put("terms[0].value", String.join(",", dateList));

Loading…
Cancel
Save