|
@@ -3,6 +3,7 @@ package com.ningdatech.pmapi.scheduler.task; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.date.StopWatch; |
|
|
import cn.hutool.core.date.StopWatch; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
import com.google.common.collect.Sets; |
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; |
|
|
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; |
|
@@ -29,7 +30,9 @@ import java.net.InetAddress; |
|
|
import java.net.UnknownHostException; |
|
|
import java.net.UnknownHostException; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
import java.util.Objects; |
|
|
import java.util.Objects; |
|
|
|
|
|
import java.util.Set; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -74,6 +77,10 @@ public class EarlyWarningProjectTask { |
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
return; |
|
|
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> warnings = projectEarlyWarningService.list(); |
|
|
List<String> warningProjectCodes = warnings.stream().map(ProjectEarlyWarning::getProjectCode) |
|
|
List<String> warningProjectCodes = warnings.stream().map(ProjectEarlyWarning::getProjectCode) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
@@ -105,7 +112,17 @@ public class EarlyWarningProjectTask { |
|
|
projectEarlyWarningService.saveBatch(toAdd); |
|
|
projectEarlyWarningService.saveBatch(toAdd); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//2.去查询 各个报警 是否已经正常 |
|
|
|
|
|
|
|
|
//2.删除 已经不存在的项目 |
|
|
|
|
|
List<ProjectEarlyWarning> toRemove = warnings.stream() |
|
|
|
|
|
.filter(w -> !projectMap.containsKey(w.getProjectCode())) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if(CollUtil.isNotEmpty(toRemove)){ |
|
|
|
|
|
List<Long> removeIds = toRemove.stream().map(ProjectEarlyWarning::getId) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
projectEarlyWarningService.removeBatchByIds(removeIds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//3.去查询 各个报警 是否已经正常 |
|
|
List<ProjectEarlyWarning> trueWarnings = warnings.stream().filter(w -> Objects.nonNull(w.getNormal()) && !w.getNormal()).collect(Collectors.toList()); |
|
|
List<ProjectEarlyWarning> trueWarnings = warnings.stream().filter(w -> Objects.nonNull(w.getNormal()) && !w.getNormal()).collect(Collectors.toList()); |
|
|
if(CollUtil.isEmpty(trueWarnings)){ |
|
|
if(CollUtil.isEmpty(trueWarnings)){ |
|
|
log.info("没有异常的项目 要去查询"); |
|
|
log.info("没有异常的项目 要去查询"); |
|
@@ -113,36 +130,40 @@ public class EarlyWarningProjectTask { |
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
//2.1 预警预警 如果正常了 要改会正常 |
|
|
|
|
|
|
|
|
checkNormal(trueWarnings); |
|
|
|
|
|
|
|
|
|
|
|
stopWatch.stop(); |
|
|
|
|
|
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()) |
|
|
List<ProjectEarlyWarning> processWarning = trueWarnings.stream().filter(w -> Objects.nonNull(w.getProcessWarning()) |
|
|
&& w.getProcessWarning()) |
|
|
&& w.getProcessWarning()) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
checkProcessWarning(processWarning); |
|
|
checkProcessWarning(processWarning); |
|
|
|
|
|
|
|
|
//2.2 填报预警 如果正常了 要改会正常 |
|
|
|
|
|
|
|
|
//3.2 填报预警 如果正常了 要改会正常 |
|
|
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w -> |
|
|
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w -> |
|
|
Objects.nonNull(w.getDeclaredWarning()) |
|
|
Objects.nonNull(w.getDeclaredWarning()) |
|
|
&& w.getDeclaredWarning()) |
|
|
|
|
|
|
|
|
&& w.getDeclaredWarning()) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
checkDeclaredWarning(declaredWarning); |
|
|
checkDeclaredWarning(declaredWarning); |
|
|
|
|
|
|
|
|
//2.3 实施预警 如果正常了 要改会正常 |
|
|
|
|
|
|
|
|
//3.3 实施预警 如果正常了 要改会正常 |
|
|
List<ProjectEarlyWarning> operationWarning = trueWarnings.stream().filter(w -> |
|
|
List<ProjectEarlyWarning> operationWarning = trueWarnings.stream().filter(w -> |
|
|
Objects.nonNull(w.getOperationWarning()) |
|
|
Objects.nonNull(w.getOperationWarning()) |
|
|
&& w.getOperationWarning()) |
|
|
|
|
|
|
|
|
&& w.getOperationWarning()) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
checkOperationWarning(operationWarning); |
|
|
checkOperationWarning(operationWarning); |
|
|
|
|
|
|
|
|
//2.4 续建资金预警 如果正常了 要改会正常 |
|
|
|
|
|
|
|
|
//3.4 续建资金预警 如果正常了 要改回正常 |
|
|
List<ProjectEarlyWarning> renewalFundWarning = trueWarnings.stream().filter(w -> |
|
|
List<ProjectEarlyWarning> renewalFundWarning = trueWarnings.stream().filter(w -> |
|
|
Objects.nonNull(w.getRenewalFundWarning()) |
|
|
Objects.nonNull(w.getRenewalFundWarning()) |
|
|
&& w.getRenewalFundWarning()) |
|
|
|
|
|
|
|
|
&& w.getRenewalFundWarning()) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
checkRenewalFundWarning(renewalFundWarning); |
|
|
checkRenewalFundWarning(renewalFundWarning); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stopWatch.stop(); |
|
|
|
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarnings) { |
|
|
private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarnings) { |
|
|