feat: 企标到实施日期自动更改被代替标准状态定时任务
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.laws.standard.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@Slf4j
|
||||
public class ReplaceImplementationDateMsgJob implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
}
|
||||
}
|
||||
+57
-14
@@ -20,6 +20,7 @@ import org.quartz.JobExecutionException;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,26 +44,68 @@ public class UpdateStandardStatusJob implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
this.updateGbStandardState();
|
||||
// this.updateEsStandardState();
|
||||
this.updateEsStandardState();
|
||||
}
|
||||
|
||||
private void updateEsStandardState() {
|
||||
// 企标状态更新
|
||||
List<LawsEnterpriseStandard> needUpdateEsList = new ArrayList<>();
|
||||
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
||||
esWrapper.eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getInteger());
|
||||
esWrapper.isNotNull(LawsEnterpriseStandard::getReleaseDate);
|
||||
esWrapper.isNotNull(LawsEnterpriseStandard::getImplementationDate);
|
||||
esWrapper.eq(LawsEnterpriseStandard::getStandardState, StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
||||
List<LawsEnterpriseStandard> esList = esService.list(esWrapper);
|
||||
// 新标准到实施日期后,老标准状态变为废止
|
||||
List<String> allExpireStandardNumberList = new ArrayList<>();
|
||||
List<String> needAbolishStandardIdList = new ArrayList<>();
|
||||
// 获取所有已经到了外部标准
|
||||
List<LawsEnterpriseStandard> esList = esService.list();
|
||||
if (esList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
Map<String, LawsEnterpriseStandard> esMap =
|
||||
esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getStandardNumber, es -> es));
|
||||
// 根据新认证车实施日期筛选出已经到期的标准
|
||||
for (LawsEnterpriseStandard es : esList) {
|
||||
// 实施日期及之后的标准 状态更新为现行有效
|
||||
if (es.getImplementationDate().getTime() <= System.currentTimeMillis()) {
|
||||
es.setStandardState(StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
||||
needUpdateEsList.add(es);
|
||||
Date implementationDate = es.getImplementationDate();
|
||||
if (implementationDate == null) {
|
||||
continue;
|
||||
}
|
||||
// 判断当前时间是否大于实施日期
|
||||
if (implementationDate.getTime() <= System.currentTimeMillis()) {
|
||||
allExpireStandardNumberList.add(es.getStandardNumber());
|
||||
}
|
||||
}
|
||||
esService.updateBatchById(needUpdateEsList);
|
||||
|
||||
if (allExpireStandardNumberList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据所有到期的标准编号,找到他们代替的标准
|
||||
LambdaQueryWrapper<LawsReplacedStandard> replaceStandardWrapper = new LambdaQueryWrapper<>();
|
||||
replaceStandardWrapper.in(LawsReplacedStandard::getReplacedBy, allExpireStandardNumberList);
|
||||
replaceStandardWrapper.eq(LawsReplacedStandard::getType, 1);
|
||||
List<LawsReplacedStandard> replacedStandardList = replacedStandardService.list(replaceStandardWrapper);
|
||||
|
||||
if (replacedStandardList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> replacedStandardNumberList = replacedStandardList.stream()
|
||||
.map(LawsReplacedStandard::getReplaced).collect(Collectors.toList());
|
||||
|
||||
for (String s : replacedStandardNumberList) {
|
||||
LawsEnterpriseStandard es = esMap.get(s);
|
||||
if (es != null) {
|
||||
needAbolishStandardIdList.add(es.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (needAbolishStandardIdList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
|
||||
LambdaUpdateWrapper<LawsEnterpriseStandard> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(LawsEnterpriseStandard::getId, needAbolishStandardIdList);
|
||||
updateWrapper.set(LawsEnterpriseStandard::getStandardState, StandardStateEnum.ABOLISH.getStateValue());
|
||||
esService.update(updateWrapper);
|
||||
}
|
||||
|
||||
private void updateGbStandardState() {
|
||||
|
||||
Reference in New Issue
Block a user