From e36dcb86e1d21dc8a2157d964f95b32dd9a56012 Mon Sep 17 00:00:00 2001 From: xiepufeng <1072271977@qq.com> Date: Wed, 20 Mar 2024 18:47:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=96=AD=E9=9D=A2=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zc/business/controller/VideoController.java | 4 ++-- .../mapper/DcTrafficSectionDataMapper.java | 9 +++++++++ .../device/handler/DeviceMessageHandler.java | 2 +- .../listener/DevicePropertyReportListener.java | 15 --------------- .../impl/DcTrafficSectionDataServiceImpl.java | 12 +++++++++--- .../business/DcTrafficSectionDataMapper.xml | 7 +++++++ 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java index 51c9aa2f..427407cc 100644 --- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java +++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java @@ -73,7 +73,7 @@ public class VideoController extends BaseController { private final static String CAM_DEPT_ID = "1301730"; @PostConstruct public void init() { - synchronizeIotIds(); + synchronizeIotIds(); } /** @@ -138,7 +138,7 @@ public class VideoController extends BaseController { // 批量更新摄像头设备的物联ID iDcDeviceService.updateBatchById(devicesToUpdate); - } catch (HttpException | IOException e) { + } catch (Exception e) { logger.error("获取摄像头信息失败!", e); } } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSectionDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSectionDataMapper.java index 7825c2c0..99b5dca6 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSectionDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSectionDataMapper.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zc.business.domain.DcTrafficSectionData; import org.apache.ibatis.annotations.Mapper; +import java.util.Date; + /** * 交通断面数据统计Mapper接口 * @@ -19,4 +21,11 @@ public interface DcTrafficSectionDataMapper extends BaseMapper buildPropertiesRequiredParameter() { - // todo 数据库中查询出最大的时间 + // 获取数据统计的最大日期 + Date maxStatisticalDate = dcTrafficSectionDataMapper.getMaxStatisticalDate(); + + // 如果最大统计日期为null,则计算默认的最大统计日期 + if (maxStatisticalDate == null) { + maxStatisticalDate = DateUtil.offsetDay(new Date(), StatisticalRecoveryOffsetTime.TRAFFIC_SECTION_DATA_OFFSET_DAY); + } HashMap props = new HashMap<>(); // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内 props.put("terms[0].column", "timestamp$BTW"); ArrayList dateList = new ArrayList<>(); // 添加当前日期的开始和结束时间到列表,用于设定时间范围 - dateList.add(DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), StatisticalRecoveryOffsetTime.TRAFFIC_SECTION_DATA_OFFSET_DAY)).toString()); + dateList.add(DateUtil.beginOfDay(maxStatisticalDate).toString()); dateList.add(DateUtil.endOfDay(new Date()).toString()); // 将日期列表以逗号分隔并设置为查询条件的值 props.put("terms[0].value", String.join(",", dateList)); diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml index da504afd..1fe5c30f 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml @@ -41,4 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_time = NOW() + +