diff --git a/zc-business/src/main/java/com/zc/business/controller/GantryTimingController.java b/zc-business/src/main/java/com/zc/business/controller/GantryTimingController.java index 1c95ce6d..5157e93f 100644 --- a/zc-business/src/main/java/com/zc/business/controller/GantryTimingController.java +++ b/zc-business/src/main/java/com/zc/business/controller/GantryTimingController.java @@ -3,12 +3,11 @@ package com.zc.business.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.utils.spring.SpringUtils; import com.zc.business.domain.OdsTollEtctuData; -import com.zc.business.service.IDcWarningService; -import com.zc.business.service.IOdsTollEnpassDataService; -import com.zc.business.service.IOdsTollEtctuDataService; -import com.zc.business.service.IOdsTollExpassDataService; +import com.zc.business.service.*; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + +import java.time.format.DateTimeFormatter; import java.util.Date; import javax.annotation.Resource; @@ -34,4 +33,41 @@ public class GantryTimingController { boolean remove3 = iOdsTollEnpassDataService.removeGantry(); System.out.println("清除数据:"+remove+": "+remove2+": "+remove3); } + //设备在线汇总数据统计 清除数据30天前数据 + public void deviceOnlineSumData(){ + // 获取当前日期时间 + LocalDateTime now = LocalDateTime.now(); + // 获取30天前的日期时间 + LocalDateTime thirtyDaysAgo = now.minusDays(30); + // 定义日期时间格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 格式化30天前的时间 + String thirtyDaysAgoFormatted = thirtyDaysAgo.format(formatter); + IOnlineSumService IOnlineSumService = SpringUtils.getBean(IOnlineSumService.class); + + boolean remove = IOnlineSumService.remove(thirtyDaysAgoFormatted); + System.out.println("清除设备在线汇总数据:"+remove); + //设备在线日志数据统计 + IOnlineLogService IOnlineLogService = SpringUtils.getBean(IOnlineLogService.class); + boolean remove3 = IOnlineLogService.remove(thirtyDaysAgoFormatted); + System.out.println("清除设备在线日志数据:"+remove3); + } + //路况信息 保留两天 + public void roadConditionInformation(){ + // 获取当前日期时间 + LocalDateTime now = LocalDateTime.now(); + // 获取30天前的日期时间 + LocalDateTime thirtyDaysAgo = now.minusDays(3); + // 定义日期时间格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 格式化30天前的时间 + String thirtyDaysAgoFormatted = thirtyDaysAgo.format(formatter); + IDcRoadConditionInformationService iDcRoadConditionInformationService = SpringUtils.getBean(IDcRoadConditionInformationService.class); + + boolean remove = iDcRoadConditionInformationService.remove(thirtyDaysAgoFormatted); + System.out.println("清除数据 路况信息 保留三天:"+remove); + + + } + } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java index 29beb5fe..0a1ff17c 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java @@ -62,4 +62,5 @@ public interface DcRoadConditionInformationMapper List selectlistTime(); + int remove(String thirtyDaysAgoFormatted); } diff --git a/zc-business/src/main/java/com/zc/business/mapper/OnlineLogMapper.java b/zc-business/src/main/java/com/zc/business/mapper/OnlineLogMapper.java index e27080bc..fa304ad1 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/OnlineLogMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/OnlineLogMapper.java @@ -15,4 +15,6 @@ public interface OnlineLogMapper { @Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime, @Param("deviceId")Long deviceId); + + int remove(String thirtyDaysAgoFormatted); } diff --git a/zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java b/zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java index e83159ea..54020efe 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java @@ -21,4 +21,7 @@ public interface OnlineSumMapper { List queryByDateOfDeviceType(@Param("queryDate") LocalDate queryDate); List queryByDateOfRoad(@Param("queryDate") LocalDate queryDate); List queryByDeviceTypesOfToday(OnlineQueryParams params); + + int remove(String thirtyDaysAgoFormatted); + } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java b/zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java index b023fe9a..bb524db3 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java @@ -63,4 +63,5 @@ public interface IDcRoadConditionInformationService Map selectlistTime(); + boolean remove(String thirtyDaysAgoFormatted); } diff --git a/zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java b/zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java index 341cb5e7..3126b899 100644 --- a/zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java +++ b/zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java @@ -12,4 +12,6 @@ public interface IOnlineLogService { int addBatch(List list); List queryByDate(LocalDateTime startTime, LocalDateTime endTime); List queryByDateAndDevice(LocalDateTime startTime, LocalDateTime endTime, Long deviceId); + + boolean remove(String thirtyDaysAgoFormatted); } diff --git a/zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java b/zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java index e8fde9f0..4b283e71 100644 --- a/zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java +++ b/zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java @@ -22,4 +22,7 @@ public interface IOnlineSumService { List queryByDateOfRoad(LocalDate queryDate); List queryByDeviceTypesOfToday(OnlineQueryParams params); + + //删除30天前的数据 + boolean remove(String thirtyDaysAgoFormatted); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcRoadConditionInformationServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcRoadConditionInformationServiceImpl.java index 2b7e9cae..cad438bd 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcRoadConditionInformationServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcRoadConditionInformationServiceImpl.java @@ -115,4 +115,9 @@ public class DcRoadConditionInformationServiceImpl implements IDcRoadConditionIn } return new LinkedHashMap<>(); } + + @Override + public boolean remove(String thirtyDaysAgoFormatted) { + return dcRoadConditionInformationMapper.remove(thirtyDaysAgoFormatted) > 0; + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java index 9ad89832..b56fbb68 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java @@ -27,4 +27,9 @@ public class OnlineLogServiceImpl implements IOnlineLogService { public List queryByDateAndDevice(LocalDateTime startTime, LocalDateTime endTime, Long deviceId) { return onlineLogMapper.queryByDateAndDevice(startTime, endTime, deviceId); } + + @Override + public boolean remove(String thirtyDaysAgoFormatted) { + return onlineLogMapper.remove(thirtyDaysAgoFormatted) > 0; + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java index c3b60ff6..4205892e 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java @@ -50,4 +50,9 @@ public class OnlineSumServiceImpl implements IOnlineSumService { public List queryByDeviceTypesOfToday(OnlineQueryParams params) { return onlineSumMapper.queryByDeviceTypesOfToday(params); } + + @Override + public boolean remove(String thirtyDaysAgoFormatted) { + return onlineSumMapper.remove(thirtyDaysAgoFormatted) > 0; + } } diff --git a/zc-business/src/main/resources/mapper/OnlineSumMapper.xml b/zc-business/src/main/resources/mapper/OnlineSumMapper.xml index 7dbbbec4..3e380ba5 100644 --- a/zc-business/src/main/resources/mapper/OnlineSumMapper.xml +++ b/zc-business/src/main/resources/mapper/OnlineSumMapper.xml @@ -123,5 +123,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by ${orderByField} ${orderDirection} + + DELETE FROM dc_online_sum WHERE statistical_date < #{thirtyDaysAgoFormatted} + diff --git a/zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml b/zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml index d1800b11..7d56535a 100644 --- a/zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml @@ -76,4 +76,8 @@ #{id} + + + DELETE FROM dc_road_condition_information WHERE create_time < #{thirtyDaysAgoFormatted} + \ No newline at end of file diff --git a/zc-business/src/main/resources/mapper/business/OnlineLogMapper.xml b/zc-business/src/main/resources/mapper/business/OnlineLogMapper.xml index 76bca1e5..cfe41a22 100644 --- a/zc-business/src/main/resources/mapper/business/OnlineLogMapper.xml +++ b/zc-business/src/main/resources/mapper/business/OnlineLogMapper.xml @@ -59,4 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by monitor_time desc + + DELETE FROM dc_online_log WHERE monitor_time < #{thirtyDaysAgoFormatted} +