Browse Source

设备日志,路况信息定时删除

develop
王兴琳 3 months ago
parent
commit
f32b8eb2a9
  1. 44
      zc-business/src/main/java/com/zc/business/controller/GantryTimingController.java
  2. 1
      zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/mapper/OnlineLogMapper.java
  4. 3
      zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java
  5. 1
      zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java
  6. 2
      zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java
  7. 3
      zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java
  8. 5
      zc-business/src/main/java/com/zc/business/service/impl/DcRoadConditionInformationServiceImpl.java
  9. 5
      zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java
  10. 5
      zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java
  11. 3
      zc-business/src/main/resources/mapper/OnlineSumMapper.xml
  12. 4
      zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml
  13. 3
      zc-business/src/main/resources/mapper/business/OnlineLogMapper.xml

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

1
zc-business/src/main/java/com/zc/business/mapper/DcRoadConditionInformationMapper.java

@ -62,4 +62,5 @@ public interface DcRoadConditionInformationMapper
List<DcRoadConditionInformation> selectlistTime();
int remove(String thirtyDaysAgoFormatted);
}

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

3
zc-business/src/main/java/com/zc/business/mapper/OnlineSumMapper.java

@ -21,4 +21,7 @@ public interface OnlineSumMapper {
List<OnlineSum> queryByDateOfDeviceType(@Param("queryDate") LocalDate queryDate);
List<OnlineSum> queryByDateOfRoad(@Param("queryDate") LocalDate queryDate);
List<OnlineSum> queryByDeviceTypesOfToday(OnlineQueryParams params);
int remove(String thirtyDaysAgoFormatted);
}

1
zc-business/src/main/java/com/zc/business/service/IDcRoadConditionInformationService.java

@ -63,4 +63,5 @@ public interface IDcRoadConditionInformationService
Map<String,String> selectlistTime();
boolean remove(String thirtyDaysAgoFormatted);
}

2
zc-business/src/main/java/com/zc/business/service/IOnlineLogService.java

@ -12,4 +12,6 @@ public interface IOnlineLogService {
int addBatch(List<OnlineLog> list);
List<OnlineLog> queryByDate(LocalDateTime startTime, LocalDateTime endTime);
List<OnlineLog> queryByDateAndDevice(LocalDateTime startTime, LocalDateTime endTime, Long deviceId);
boolean remove(String thirtyDaysAgoFormatted);
}

3
zc-business/src/main/java/com/zc/business/service/IOnlineSumService.java

@ -22,4 +22,7 @@ public interface IOnlineSumService {
List<OnlineSum> queryByDateOfRoad(LocalDate queryDate);
List<OnlineSum> queryByDeviceTypesOfToday(OnlineQueryParams params);
//删除30天前的数据
boolean remove(String thirtyDaysAgoFormatted);
}

5
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;
}
}

5
zc-business/src/main/java/com/zc/business/service/impl/OnlineLogServiceImpl.java

@ -27,4 +27,9 @@ public class OnlineLogServiceImpl implements IOnlineLogService {
public List<OnlineLog> queryByDateAndDevice(LocalDateTime startTime, LocalDateTime endTime, Long deviceId) {
return onlineLogMapper.queryByDateAndDevice(startTime, endTime, deviceId);
}
@Override
public boolean remove(String thirtyDaysAgoFormatted) {
return onlineLogMapper.remove(thirtyDaysAgoFormatted) > 0;
}
}

5
zc-business/src/main/java/com/zc/business/service/impl/OnlineSumServiceImpl.java

@ -50,4 +50,9 @@ public class OnlineSumServiceImpl implements IOnlineSumService {
public List<OnlineSum> queryByDeviceTypesOfToday(OnlineQueryParams params) {
return onlineSumMapper.queryByDeviceTypesOfToday(params);
}
@Override
public boolean remove(String thirtyDaysAgoFormatted) {
return onlineSumMapper.remove(thirtyDaysAgoFormatted) > 0;
}
}

3
zc-business/src/main/resources/mapper/OnlineSumMapper.xml

@ -123,5 +123,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by ${orderByField} ${orderDirection}
</if>
</select>
<delete id="remove" parameterType="string">
DELETE FROM dc_online_sum WHERE statistical_date &lt; #{thirtyDaysAgoFormatted}
</delete>
</mapper>

4
zc-business/src/main/resources/mapper/business/DcRoadConditionInformationMapper.xml

@ -76,4 +76,8 @@
#{id}
</foreach>
</delete>
<delete id="remove" parameterType="string">
DELETE FROM dc_road_condition_information WHERE create_time &lt; #{thirtyDaysAgoFormatted}
</delete>
</mapper>

3
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
</select>
<delete id="remove" parameterType="string">
DELETE FROM dc_online_log WHERE monitor_time &lt; #{thirtyDaysAgoFormatted}
</delete>
</mapper>

Loading…
Cancel
Save