2023-07-10 15:20:27 +08:00
|
|
|
package com.zhgd.xmgl.task;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.zhgd.xmgl.modules.safety.entity.ProjectSubItem;
|
2023-07-26 18:10:45 +08:00
|
|
|
import com.zhgd.xmgl.modules.safety.service.IInspectRecordService;
|
2023-07-10 15:20:27 +08:00
|
|
|
import com.zhgd.xmgl.modules.safety.service.IProjectSubItemService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2023-07-26 18:10:45 +08:00
|
|
|
import java.util.Arrays;
|
2023-07-10 15:20:27 +08:00
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: 视频监控定时任务
|
|
|
|
|
**/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Component
|
|
|
|
|
public class SlippageTask {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IProjectSubItemService projectSubItemService;
|
|
|
|
|
|
2023-07-26 18:10:45 +08:00
|
|
|
@Autowired
|
|
|
|
|
private IInspectRecordService inspectRecordService;
|
|
|
|
|
|
2023-07-10 15:20:27 +08:00
|
|
|
/**
|
2023-07-26 18:10:45 +08:00
|
|
|
* 每天凌晨计算项目进度是否逾期、临期
|
2023-07-10 15:20:27 +08:00
|
|
|
*/
|
|
|
|
|
@Scheduled(cron = "0 0 2 * * ?")
|
|
|
|
|
private void projectSubItem() {
|
2023-07-26 18:10:45 +08:00
|
|
|
List<Integer> states = Arrays.asList(3, 6, 7);
|
2023-07-10 15:20:27 +08:00
|
|
|
List<ProjectSubItem> change = new ArrayList<>();
|
|
|
|
|
List<ProjectSubItem> list = projectSubItemService.list();
|
|
|
|
|
list.stream().forEach(l -> {
|
2023-07-26 18:10:45 +08:00
|
|
|
if (l.getState() < 3 && DateUtil.between(new Date(), l.getPlanEndTime(), DateUnit.DAY, false) <= 15) {
|
2023-07-10 15:20:27 +08:00
|
|
|
l.setState(4);
|
|
|
|
|
change.add(l);
|
|
|
|
|
}
|
2023-07-26 18:10:45 +08:00
|
|
|
if (!states.contains(l.getState()) && DateUtil.between(l.getPlanEndTime(), new Date(), DateUnit.DAY, false) > 0) {
|
|
|
|
|
l.setState(5);
|
|
|
|
|
change.add(l);
|
|
|
|
|
}
|
2023-07-10 15:20:27 +08:00
|
|
|
});
|
|
|
|
|
if (change.size() > 0) {
|
|
|
|
|
projectSubItemService.updateBatchById(change);
|
|
|
|
|
}
|
|
|
|
|
log.info("=========定时修改项目进度状态任务执行成功========");
|
|
|
|
|
}
|
2023-07-26 18:10:45 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 每天凌晨计算安全质量临期
|
|
|
|
|
*/
|
|
|
|
|
// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
|
// private void inspectRecord() {
|
|
|
|
|
// List<Integer> states = Arrays.asList(4, 8);
|
|
|
|
|
// List<InspectRecord> change = new ArrayList<>();
|
|
|
|
|
// List<InspectRecord> list = inspectRecordService.list();
|
|
|
|
|
// list.stream().forEach(l -> {
|
|
|
|
|
// if (l.getState() < 3 && DateUtil.between(new Date(), l.getDeadline(), DateUnit.DAY, false) <= 15) {
|
|
|
|
|
// l.setState(4);
|
|
|
|
|
// change.add(l);
|
|
|
|
|
// }
|
|
|
|
|
// if (!states.contains(l.getState()) && DateUtil.between(l.getDeadline(), new Date(), DateUnit.DAY, false) > 0) {
|
|
|
|
|
// l.setState(5);
|
|
|
|
|
// change.add(l);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// if (change.size() > 0) {
|
|
|
|
|
// projectSubItemService.updateBatchById(change);
|
|
|
|
|
// }
|
|
|
|
|
// log.info("=========定时修改项目进度状态任务执行成功========");
|
|
|
|
|
// }
|
2023-07-10 15:20:27 +08:00
|
|
|
}
|