|
|
@@ -58,7 +58,7 @@ public class EarlyWarningProjectTask { |
|
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 5, initialDelay = 5, timeUnit = TimeUnit.MINUTES) |
|
|
|
public void doEarlyWarningDeclared() { |
|
|
|
public void doEarlyWarningDelayed() { |
|
|
|
log.info("=========== 预警项目状态校验任务开始 ==========="); |
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
stopWatch.start(); |
|
|
@@ -94,22 +94,46 @@ public class EarlyWarningProjectTask { |
|
|
|
log.info("=========== 预警项目状态校验任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
} |
|
|
|
|
|
|
|
// 3.去查询 各个报警 是否已经正常 |
|
|
|
private void checkNormal(List<ProjectEarlyWarning> trueWarnings) { |
|
|
|
// 3.1 流程预警 如果正常了 要改会正常 |
|
|
|
List<ProjectEarlyWarning> processWarning = trueWarnings.stream().filter(w -> Objects.nonNull(w.getProcessWarning()) |
|
|
|
&& w.getProcessWarning()) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
checkProcessWarning(processWarning); |
|
|
|
//@Scheduled(fixedDelay = 5, initialDelay = 5, timeUnit = TimeUnit.MINUTES) |
|
|
|
public void doEarlyWarningDeclared() { |
|
|
|
log.info("=========== 预警项目状态校验任务开始 ==========="); |
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
stopWatch.start(); |
|
|
|
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE)); |
|
|
|
|
|
|
|
// 3.2 填报预警 如果正常了 要改会正常 |
|
|
|
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w -> |
|
|
|
Objects.nonNull(w.getDeclaredWarning()) |
|
|
|
&& w.getDeclaredWarning()) |
|
|
|
if (CollUtil.isEmpty(projects)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Set<String> projectSet = Sets.newHashSet(); |
|
|
|
Map<String, Project> projectMap = projects.stream().filter(p -> projectSet.add(p.getProjectCode())) |
|
|
|
.collect(Collectors.toMap(Project::getProjectCode, p -> p)); |
|
|
|
List<ProjectEarlyWarning> warnings = projectEarlyWarningService.list(); |
|
|
|
|
|
|
|
// 删除 已经不存在的项目 |
|
|
|
List<ProjectEarlyWarning> toRemove = warnings.stream() |
|
|
|
.filter(w -> !projectMap.containsKey(w.getProjectCode())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
checkDeclaredWarning(declaredWarning); |
|
|
|
if (CollUtil.isNotEmpty(toRemove)) { |
|
|
|
List<Long> removeIds = toRemove.stream().map(ProjectEarlyWarning::getId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
projectEarlyWarningService.removeBatchByIds(removeIds); |
|
|
|
} |
|
|
|
|
|
|
|
// 去查询 各个报警 是否已经正常 |
|
|
|
List<ProjectEarlyWarning> trueWarnings = warnings.stream().filter(w -> Objects.nonNull(w.getNormal()) && !w.getNormal()).collect(Collectors.toList()); |
|
|
|
if (CollUtil.isEmpty(trueWarnings)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
checkNormal(trueWarnings); |
|
|
|
stopWatch.stop(); |
|
|
|
log.info("=========== 预警项目状态校验任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
} |
|
|
|
|
|
|
|
// 3.3 滞后预警 如果正常了 要改会正常 |
|
|
|
// 3.去查询 各个报警 是否已经正常 |
|
|
|
private void checkNormal(List<ProjectEarlyWarning> trueWarnings) { |
|
|
|
// 滞后预警 如果正常了 要改回正常 |
|
|
|
List<ProjectEarlyWarning> delayWarning = trueWarnings.stream().filter(w -> |
|
|
|
Objects.nonNull(w.getDelayWarning()) |
|
|
|
&& w.getDelayWarning()) |
|
|
@@ -144,9 +168,8 @@ public class EarlyWarningProjectTask { |
|
|
|
// 已经不是这个状态了 说明已经被提交了 |
|
|
|
if (!projectStatus.eq(project.getStatus())) { |
|
|
|
checkCommited(delay, flowTypeEnum, projectCode); |
|
|
|
// 其它几种 都没有 说明已经正常了 |
|
|
|
if (Boolean.FALSE.equals(delay.getProcessWarning()) && |
|
|
|
Boolean.FALSE.equals(delay.getDeclaredWarning())) { |
|
|
|
// 如果滞后预警正常了 改回正常 |
|
|
|
if (Boolean.FALSE.equals(delay.getDelayWarning())){ |
|
|
|
delay.setNormal(Boolean.TRUE); |
|
|
|
delay.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name()); |
|
|
|
} |
|
|
@@ -202,7 +225,11 @@ public class EarlyWarningProjectTask { |
|
|
|
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(projectCode, events); |
|
|
|
// 说明进行了采购&合同信息备案 |
|
|
|
if (Objects.nonNull(projectStatusChange)) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
if (WarningRuleTypeEnum.DECLARED_WARNING.getCode().equals(warning.getRuleType())) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
}else if (WarningRuleTypeEnum.DELAY_WARNING.getCode().equals(warning.getRuleType())){ |
|
|
|
warning.setDelayWarning(Boolean.FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
@@ -213,7 +240,11 @@ public class EarlyWarningProjectTask { |
|
|
|
PurchaseStatusChange purchaseStatusChange = purchaseStatusChangeService.getLastOne(projectCode, events); |
|
|
|
// 说明进行了单位确认 |
|
|
|
if (Objects.nonNull(purchaseStatusChange)) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
if (WarningRuleTypeEnum.DECLARED_WARNING.getCode().equals(warning.getRuleType())) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
}else if (WarningRuleTypeEnum.DELAY_WARNING.getCode().equals(warning.getRuleType())){ |
|
|
|
warning.setDelayWarning(Boolean.FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@@ -225,7 +256,11 @@ public class EarlyWarningProjectTask { |
|
|
|
ProjectStatusChange projectStatusChange = projectStatusChangeService.getLastOne(projectCode, events); |
|
|
|
// 说明提交了终验申请 |
|
|
|
if (Objects.nonNull(projectStatusChange)) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
if (WarningRuleTypeEnum.DECLARED_WARNING.getCode().equals(warning.getRuleType())) { |
|
|
|
warning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
}else if (WarningRuleTypeEnum.DELAY_WARNING.getCode().equals(warning.getRuleType())){ |
|
|
|
warning.setDelayWarning(Boolean.FALSE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|