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 javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -43,26 +44,68 @@ public class UpdateStandardStatusJob implements Job {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
this.updateGbStandardState();
|
this.updateGbStandardState();
|
||||||
// this.updateEsStandardState();
|
this.updateEsStandardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEsStandardState() {
|
private void updateEsStandardState() {
|
||||||
// 企标状态更新
|
// 新标准到实施日期后,老标准状态变为废止
|
||||||
List<LawsEnterpriseStandard> needUpdateEsList = new ArrayList<>();
|
List<String> allExpireStandardNumberList = new ArrayList<>();
|
||||||
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
|
List<String> needAbolishStandardIdList = new ArrayList<>();
|
||||||
esWrapper.eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getInteger());
|
// 获取所有已经到了外部标准
|
||||||
esWrapper.isNotNull(LawsEnterpriseStandard::getReleaseDate);
|
List<LawsEnterpriseStandard> esList = esService.list();
|
||||||
esWrapper.isNotNull(LawsEnterpriseStandard::getImplementationDate);
|
if (esList.isEmpty()) {
|
||||||
esWrapper.eq(LawsEnterpriseStandard::getStandardState, StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
log.info("没有需要更新的标准");
|
||||||
List<LawsEnterpriseStandard> esList = esService.list(esWrapper);
|
return;
|
||||||
|
}
|
||||||
|
Map<String, LawsEnterpriseStandard> esMap =
|
||||||
|
esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getStandardNumber, es -> es));
|
||||||
|
// 根据新认证车实施日期筛选出已经到期的标准
|
||||||
for (LawsEnterpriseStandard es : esList) {
|
for (LawsEnterpriseStandard es : esList) {
|
||||||
// 实施日期及之后的标准 状态更新为现行有效
|
Date implementationDate = es.getImplementationDate();
|
||||||
if (es.getImplementationDate().getTime() <= System.currentTimeMillis()) {
|
if (implementationDate == null) {
|
||||||
es.setStandardState(StandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
continue;
|
||||||
needUpdateEsList.add(es);
|
}
|
||||||
|
// 判断当前时间是否大于实施日期
|
||||||
|
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() {
|
private void updateGbStandardState() {
|
||||||
|
|||||||
Reference in New Issue
Block a user