瀏覽代碼

工作台 预警 催办 处理

master
PoffyZhang 11 月之前
父節點
當前提交
872fbeb9a2
共有 1 個檔案被更改,包括 33 行新增12 行删除
  1. +33
    -12
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningProjectTask.java

+ 33
- 12
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningProjectTask.java 查看文件

@@ -3,6 +3,7 @@ package com.ningdatech.pmapi.scheduler.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Sets;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum;
@@ -29,7 +30,9 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
@@ -74,6 +77,10 @@ public class EarlyWarningProjectTask {
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
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<String> warningProjectCodes = warnings.stream().map(ProjectEarlyWarning::getProjectCode)
.collect(Collectors.toList());
@@ -105,7 +112,17 @@ public class EarlyWarningProjectTask {
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());
if(CollUtil.isEmpty(trueWarnings)){
log.info("没有异常的项目 要去查询");
@@ -113,36 +130,40 @@ public class EarlyWarningProjectTask {
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
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())
&& w.getProcessWarning())
.collect(Collectors.toList());
checkProcessWarning(processWarning);

//2.2 填报预警 如果正常了 要改会正常
//3.2 填报预警 如果正常了 要改会正常
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getDeclaredWarning())
&& w.getDeclaredWarning())
&& w.getDeclaredWarning())
.collect(Collectors.toList());
checkDeclaredWarning(declaredWarning);

//2.3 实施预警 如果正常了 要改会正常
//3.3 实施预警 如果正常了 要改会正常
List<ProjectEarlyWarning> operationWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getOperationWarning())
&& w.getOperationWarning())
&& w.getOperationWarning())
.collect(Collectors.toList());
checkOperationWarning(operationWarning);

//2.4 续建资金预警 如果正常了 要改会正常
//3.4 续建资金预警 如果正常了 要改回正常
List<ProjectEarlyWarning> renewalFundWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getRenewalFundWarning())
&& w.getRenewalFundWarning())
&& w.getRenewalFundWarning())
.collect(Collectors.toList());
checkRenewalFundWarning(renewalFundWarning);


stopWatch.stop();
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}

private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarnings) {


Loading…
取消
儲存