feat: 87529 外来标准法规文本库--代替被代替规则未生效
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
package com.jero.modules.document.enums;
|
||||
|
||||
/**
|
||||
* @description
|
||||
* 法规状态枚举
|
||||
* @date 2022/1/21 15:22
|
||||
* @auth zhn
|
||||
*/
|
||||
public enum LawsStateEnum {
|
||||
ACTIVE("现行","1"),
|
||||
ABOLISH("废止","2"),
|
||||
THE_UPCOMING("即将实施","3"),
|
||||
DRAFT("草稿","4"),
|
||||
BE_REPLACED("被替代","5");
|
||||
|
||||
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
LawsStateEnum(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -7,13 +7,12 @@ package com.jero.modules.laws.standard.entity;
|
||||
*/
|
||||
public enum OutStandardStateEnum {
|
||||
|
||||
DRAFT("起草","1"),
|
||||
SEEK_FOR_OPINIONS("征求意见","2"),
|
||||
EXAMINE("审查","2.1"),
|
||||
CURRENTLY("现行","1"),
|
||||
RELEASE("发布","2"),
|
||||
APPROVAL("报批","3"),
|
||||
RELEASE("发布","4"),
|
||||
TRIAL_OPERATION("即将实施","5"),
|
||||
CURRENTLY_EFFECTIVE("现行有效","6"),
|
||||
EXAMINE("审查", "4"),
|
||||
SEEK_FOR_OPINIONS("征求意见","5"),
|
||||
DRAFT("起草","6"),
|
||||
ABOLISH("废止","7"),
|
||||
;
|
||||
|
||||
|
||||
+77
-25
@@ -1,32 +1,44 @@
|
||||
package com.jero.modules.laws.standard.job;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
|
||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
||||
import com.jero.modules.laws.standard.entity.LawsReplacedStandard;
|
||||
import com.jero.modules.laws.standard.entity.OutStandardStateEnum;
|
||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsReplacedStandardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2024/3/1 9:34
|
||||
*/
|
||||
@Slf4j
|
||||
public class UpdateStandardStatusJob implements Job {
|
||||
|
||||
@Resource
|
||||
private ILawsEnterpriseStandardService esService;
|
||||
|
||||
@Resource
|
||||
private ILawsDomesticStandardService gbService;
|
||||
private ILawsDomesticStandardService dsService;
|
||||
|
||||
@Resource
|
||||
private ILawsReplacedStandardService replacedStandardService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
@@ -53,34 +65,74 @@ public class UpdateStandardStatusJob implements Job {
|
||||
esService.updateBatchById(needUpdateEsList);
|
||||
}
|
||||
|
||||
private void updateGbStandardState(){
|
||||
private void updateGbStandardState() {
|
||||
// 新版本标准到达新认证车实施日期,被代替标准选择了自动更新逻辑,到期变成废止状态;选择不执行自动更新逻辑,到期不变废止状态
|
||||
|
||||
|
||||
|
||||
// 国内标准状态更新
|
||||
List<LawsDomesticStandard> needUpdateGbList = new ArrayList<>();
|
||||
LambdaQueryWrapper<LawsDomesticStandard> gbWrapper = new LambdaQueryWrapper<>();
|
||||
gbWrapper.eq(LawsDomesticStandard::getDelFlag, YesOrNoEnum.NO.getInteger());
|
||||
gbWrapper.isNotNull(LawsDomesticStandard::getReleaseDate);
|
||||
gbWrapper.isNotNull(LawsDomesticStandard::getImplementationDate);
|
||||
gbWrapper.eq(LawsDomesticStandard::getStandardState, OutStandardStateEnum.RELEASE.getStateValue()).or()
|
||||
.eq(LawsDomesticStandard::getStandardState, OutStandardStateEnum.TRIAL_OPERATION.getStateValue());
|
||||
List<LawsDomesticStandard> gbList = gbService.list(gbWrapper);
|
||||
for (LawsDomesticStandard gb : gbList) {
|
||||
// 介于创建时间和实施日期内的标准 状态更新为即将实施
|
||||
if (gb.getCreateTime().getTime() <= System.currentTimeMillis() &&
|
||||
gb.getImplementationDate().getTime() >= System.currentTimeMillis()) {
|
||||
gb.setStandardState(OutStandardStateEnum.TRIAL_OPERATION.getStateValue());
|
||||
needUpdateGbList.add(gb);
|
||||
List<String> allExpireStandardNumberList = new ArrayList<>();
|
||||
List<String> needAbolishStandardIdList = new ArrayList<>();
|
||||
// 获取所有已经到了外部标准
|
||||
List<LawsDomesticStandard> dbList = dsService.list();
|
||||
if (dbList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
Map<String, LawsDomesticStandard> dbMap =
|
||||
dbList.stream().collect(Collectors.toMap(LawsDomesticStandard::getStandardNumber, gb -> gb));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 根据新认证车实施日期筛选出已经到期的标准
|
||||
for (LawsDomesticStandard gb : dbList) {
|
||||
String newProductImplDate = gb.getNewAuthImplDate();
|
||||
if (StrUtil.isBlank(newProductImplDate)) {
|
||||
continue;
|
||||
}
|
||||
// 实施日期及之后的标准 状态更新为现行有效
|
||||
if (gb.getImplementationDate().getTime() <= System.currentTimeMillis()) {
|
||||
gb.setStandardState(OutStandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
||||
needUpdateGbList.add(gb);
|
||||
String[] dateStrList = newProductImplDate.split(",");
|
||||
try {
|
||||
for (String dateStr : dateStrList) {
|
||||
if (sdf.parse(dateStr).getTime() <= System.currentTimeMillis()) {
|
||||
allExpireStandardNumberList.add(gb.getStandardNumber());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("时间转换异常", e);
|
||||
}
|
||||
}
|
||||
gbService.updateBatchById(needUpdateGbList);
|
||||
|
||||
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) {
|
||||
LawsDomesticStandard lawsDomesticStandard = dbMap.get(s);
|
||||
if (lawsDomesticStandard != null) {
|
||||
if (YesOrNoEnum.YES.getValue().equals(lawsDomesticStandard.getAutoUpdateStateFlag())) {
|
||||
needAbolishStandardIdList.add(lawsDomesticStandard.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needAbolishStandardIdList.isEmpty()) {
|
||||
log.info("没有需要更新的标准");
|
||||
return;
|
||||
}
|
||||
|
||||
LambdaUpdateWrapper<LawsDomesticStandard> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(LawsDomesticStandard::getId, needAbolishStandardIdList);
|
||||
updateWrapper.set(LawsDomesticStandard::getStandardState, OutStandardStateEnum.ABOLISH.getStateValue());
|
||||
dsService.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user