feat: 企标稽查拖期状态刷新定时任务
This commit is contained in:
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package com.jero.modules.laws.enterprise.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspect;
|
||||||
|
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectReport;
|
||||||
|
import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectReportService;
|
||||||
|
import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Mzaxd
|
||||||
|
* @Date: 2023/12/12 14:18
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class ESInspectStatusRefresh implements Job {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseStandardInspectService inspectService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseStandardInspectReportService inspectReportService;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String INSPECT_STATUS_DELAY = "4";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
List<EnterpriseStandardInspectReport> reportList = inspectReportService.list();
|
||||||
|
Map<String, List<EnterpriseStandardInspectReport>> reportMap = reportList
|
||||||
|
.stream().filter(r -> StrUtil.isNotBlank(r.getInspectId()))
|
||||||
|
.collect(Collectors.groupingBy(EnterpriseStandardInspectReport::getInspectId));
|
||||||
|
log.info("开始执行企标稽查状态刷新任务");
|
||||||
|
List<EnterpriseStandardInspect> list = inspectService.list();
|
||||||
|
// 遍历所有稽查记录,判断是否已经超过稽查截止日期,如果超过则将稽查状态置为已超期
|
||||||
|
for (EnterpriseStandardInspect inspect : list) {
|
||||||
|
Date planInspectDate = inspect.getPlanInspectDate();
|
||||||
|
if (inspect.getPlanInspectDate() == null) {
|
||||||
|
log.info("企标稽查记录{}未设置稽查截止日期,无法判断是否超期", inspect.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.DATE, -1); // 将日期设置为昨天
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 23); // 设置小时为23
|
||||||
|
calendar.set(Calendar.MINUTE, 59); // 设置分钟为59
|
||||||
|
calendar.set(Calendar.SECOND, 59); // 设置秒为59
|
||||||
|
Date yesterdayLastSecond = calendar.getTime(); // 获取昨天最后一秒的时间
|
||||||
|
|
||||||
|
if (planInspectDate.before(yesterdayLastSecond)) {
|
||||||
|
// 判断是否能找到稽查报告记录,如果找不到则将稽查状态置为已超期
|
||||||
|
List<EnterpriseStandardInspectReport> enterpriseStandardInspectReports = reportMap.get(inspect.getId());
|
||||||
|
if (enterpriseStandardInspectReports == null || enterpriseStandardInspectReports.isEmpty()) {
|
||||||
|
inspect.setInspectStatus(INSPECT_STATUS_DELAY);
|
||||||
|
inspectService.updateById(inspect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("企标稽查状态刷新任务执行结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user