|
@@ -18,6 +18,9 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -42,7 +45,7 @@ public class LeanEventTriggerWarnTask {
|
|
|
@Scheduled(cron = "0 */1 * * * *")
|
|
|
public void leanEventTriggerWarnHandle(){
|
|
|
LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(FpgGatherData::getEventWarnState, "0").isNotNull(FpgGatherData::getDeviceInformationId).orderByDesc(FpgGatherData::getCreateTime);
|
|
|
+ queryWrapper.isNull(FpgGatherData::getEventWarnUpdatetime).isNotNull(FpgGatherData::getDeviceInformationId).orderByDesc(FpgGatherData::getCreateTime);
|
|
|
List<FpgGatherData> fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
|
|
|
log.info("{}{}", "FPG采集表数据总数:", fpgGatherDataList.size());
|
|
|
if (oConvertUtils.listIsNotEmpty(fpgGatherDataList)){
|
|
@@ -51,7 +54,7 @@ public class LeanEventTriggerWarnTask {
|
|
|
leanEventsHostTriggerWarnHandle(x);
|
|
|
});
|
|
|
// 逻辑删除已校验完精益事件告警的采集数据,事件告警使用状态0:使用中1:使用结束
|
|
|
- List<FpgGatherData> updateFpgGatherDataList = fpgGatherDataList.stream().map(s -> s.setEventWarnState("1")).collect(Collectors.toList());
|
|
|
+ List<FpgGatherData> updateFpgGatherDataList = fpgGatherDataList.stream().map(s -> s.setEventWarnUpdatetime(new Date())).collect(Collectors.toList());
|
|
|
if (oConvertUtils.listIsNotEmpty(updateFpgGatherDataList)){
|
|
|
log.info("{}{}", "FPG采集表数据使用结束总数:", fpgGatherDataList.size());
|
|
|
fpgGatherDataService.updateBatchById(updateFpgGatherDataList);
|
|
@@ -127,13 +130,19 @@ public class LeanEventTriggerWarnTask {
|
|
|
/**
|
|
|
* 峰平谷采集数据 过期数据定时删除
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0/60 * * * ?")
|
|
|
+ @Scheduled(cron = "0 0 3 * * *")
|
|
|
public void removeFpgGatherDataHandle(){
|
|
|
LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(FpgGatherData::getEventWarnState, "1").eq(FpgGatherData::getFpgModelState, "1");
|
|
|
+ // 获取当前时间并减去一周的时间
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ LocalDateTime oneWeekAgo = now.minusWeeks(1);
|
|
|
+ // 将LocalDateTime转换为Date类型(因为数据库字段是Date类型)
|
|
|
+ Date oneWeekAgoAsDate = Date.from(oneWeekAgo.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+ // 设置查询条件,查询eventWarnUpdatetime一周之前的数据
|
|
|
+ queryWrapper.lt(FpgGatherData::getEventWarnUpdatetime, oneWeekAgoAsDate);
|
|
|
List<FpgGatherData> fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
|
|
|
if (oConvertUtils.listIsNotEmpty(fpgGatherDataList)){
|
|
|
- fpgGatherDataService.updateBatchById(fpgGatherDataList);
|
|
|
+ fpgGatherDataService.removeBatchByIds(fpgGatherDataList);
|
|
|
}
|
|
|
}
|
|
|
}
|