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 {
|
public enum OutStandardStateEnum {
|
||||||
|
|
||||||
DRAFT("起草","1"),
|
CURRENTLY("现行","1"),
|
||||||
SEEK_FOR_OPINIONS("征求意见","2"),
|
RELEASE("发布","2"),
|
||||||
EXAMINE("审查","2.1"),
|
|
||||||
APPROVAL("报批","3"),
|
APPROVAL("报批","3"),
|
||||||
RELEASE("发布","4"),
|
EXAMINE("审查", "4"),
|
||||||
TRIAL_OPERATION("即将实施","5"),
|
SEEK_FOR_OPINIONS("征求意见","5"),
|
||||||
CURRENTLY_EFFECTIVE("现行有效","6"),
|
DRAFT("起草","6"),
|
||||||
ABOLISH("废止","7"),
|
ABOLISH("废止","7"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
+77
-25
@@ -1,32 +1,44 @@
|
|||||||
package com.jero.modules.laws.standard.job;
|
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.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.jero.common.constant.enums.YesOrNoEnum;
|
import com.jero.common.constant.enums.YesOrNoEnum;
|
||||||
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
|
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
|
||||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||||
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
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.entity.OutStandardStateEnum;
|
||||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||||
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
|
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.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: Mzaxd
|
* @author: Mzaxd
|
||||||
* @Date: 2024/3/1 9:34
|
* @Date: 2024/3/1 9:34
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class UpdateStandardStatusJob implements Job {
|
public class UpdateStandardStatusJob implements Job {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ILawsEnterpriseStandardService esService;
|
private ILawsEnterpriseStandardService esService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ILawsDomesticStandardService gbService;
|
private ILawsDomesticStandardService dsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ILawsReplacedStandardService replacedStandardService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
@@ -53,34 +65,74 @@ public class UpdateStandardStatusJob implements Job {
|
|||||||
esService.updateBatchById(needUpdateEsList);
|
esService.updateBatchById(needUpdateEsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGbStandardState(){
|
private void updateGbStandardState() {
|
||||||
// 新版本标准到达新认证车实施日期,被代替标准选择了自动更新逻辑,到期变成废止状态;选择不执行自动更新逻辑,到期不变废止状态
|
// 新版本标准到达新认证车实施日期,被代替标准选择了自动更新逻辑,到期变成废止状态;选择不执行自动更新逻辑,到期不变废止状态
|
||||||
|
List<String> allExpireStandardNumberList = new ArrayList<>();
|
||||||
|
List<String> needAbolishStandardIdList = new ArrayList<>();
|
||||||
|
// 获取所有已经到了外部标准
|
||||||
// 国内标准状态更新
|
List<LawsDomesticStandard> dbList = dsService.list();
|
||||||
List<LawsDomesticStandard> needUpdateGbList = new ArrayList<>();
|
if (dbList.isEmpty()) {
|
||||||
LambdaQueryWrapper<LawsDomesticStandard> gbWrapper = new LambdaQueryWrapper<>();
|
log.info("没有需要更新的标准");
|
||||||
gbWrapper.eq(LawsDomesticStandard::getDelFlag, YesOrNoEnum.NO.getInteger());
|
return;
|
||||||
gbWrapper.isNotNull(LawsDomesticStandard::getReleaseDate);
|
}
|
||||||
gbWrapper.isNotNull(LawsDomesticStandard::getImplementationDate);
|
Map<String, LawsDomesticStandard> dbMap =
|
||||||
gbWrapper.eq(LawsDomesticStandard::getStandardState, OutStandardStateEnum.RELEASE.getStateValue()).or()
|
dbList.stream().collect(Collectors.toMap(LawsDomesticStandard::getStandardNumber, gb -> gb));
|
||||||
.eq(LawsDomesticStandard::getStandardState, OutStandardStateEnum.TRIAL_OPERATION.getStateValue());
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
List<LawsDomesticStandard> gbList = gbService.list(gbWrapper);
|
// 根据新认证车实施日期筛选出已经到期的标准
|
||||||
for (LawsDomesticStandard gb : gbList) {
|
for (LawsDomesticStandard gb : dbList) {
|
||||||
// 介于创建时间和实施日期内的标准 状态更新为即将实施
|
String newProductImplDate = gb.getNewAuthImplDate();
|
||||||
if (gb.getCreateTime().getTime() <= System.currentTimeMillis() &&
|
if (StrUtil.isBlank(newProductImplDate)) {
|
||||||
gb.getImplementationDate().getTime() >= System.currentTimeMillis()) {
|
|
||||||
gb.setStandardState(OutStandardStateEnum.TRIAL_OPERATION.getStateValue());
|
|
||||||
needUpdateGbList.add(gb);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 实施日期及之后的标准 状态更新为现行有效
|
String[] dateStrList = newProductImplDate.split(",");
|
||||||
if (gb.getImplementationDate().getTime() <= System.currentTimeMillis()) {
|
try {
|
||||||
gb.setStandardState(OutStandardStateEnum.CURRENTLY_EFFECTIVE.getStateValue());
|
for (String dateStr : dateStrList) {
|
||||||
needUpdateGbList.add(gb);
|
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