Browse Source

交通断面统计

develop
xiepufeng 8 months ago
parent
commit
e36dcb86e1
  1. 4
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  2. 9
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficSectionDataMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
  4. 15
      zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java
  5. 12
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java
  6. 7
      zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml

4
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);
}
}

9
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<DcTrafficSectionD
* @return 返回一个布尔值表示操作是否成功true表示插入或更新成功false表示失败
*/
boolean insertOrUpdate(DcTrafficSectionData trafficSectionData);
/**
* 获取最大的统计日期
*
* @return 返回最大的统计日期
*/
Date getMaxStatisticalDate();
}

2
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -335,7 +335,7 @@ public class DeviceMessageHandler {
* @param msg 设备消息
*/
private void oneStopDeviceMessageHandle(JSONObject msg) {
// dcTrafficSectionDataService.processRealtimeOneStopMessage(msg);
dcTrafficSectionDataService.processRealtimeOneStopMessage(msg);
}

15
zc-business/src/main/java/com/zc/business/message/device/listener/DevicePropertyReportListener.java

@ -1,19 +1,7 @@
package com.zc.business.message.device.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcMeteorologicalDetectorData;
import com.zc.business.domain.MdDeviceData;
import com.zc.business.enums.IotProductEnum;
import com.zc.business.message.device.handler.DeviceMessageHandler;
import com.zc.business.service.IDcMeteorologicalDetectorDataService;
import com.zc.business.service.IMiddleDatabaseService;
import com.zc.business.service.IDcYzsqbdcHmbldDataService;
import com.zc.common.core.redis.stream.RedisStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.stream.ObjectRecord;
@ -23,9 +11,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 设备属性上报消息监听

12
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java

@ -82,7 +82,7 @@ public class DcTrafficSectionDataServiceImpl
/**
* 定义每小时第20分钟执行的任务用于清除过期缓存数据并将缓存中的数据整合后保存至数据库
*/
// @Scheduled(cron = "0 20 * * * ?") // 每小时的20分整点执行该任务
@Scheduled(cron = "0 20 * * * ?") // 每小时的20分整点执行该任务
public void performHourlyCleanupAndPersist() {
// 清除已过期的缓存数据
DailyTrafficStatisticsCache.clearExpiredData();
@ -173,14 +173,20 @@ public class DcTrafficSectionDataServiceImpl
*/
private HashMap<String, Object> buildPropertiesRequiredParameter() {
// todo 数据库中查询出最大的时间
// 获取数据统计的最大日期
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<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
props.put("terms[0].column", "timestamp$BTW");
ArrayList<String> 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));

7
zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml

@ -41,4 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_time = NOW()
</insert>
<select id="getMaxStatisticalDate" resultType="java.util.Date">
SELECT
MAX(statistical_date)
FROM
dc_traffic_section_data
</select>
</mapper>

Loading…
Cancel
Save