Przeglądaj źródła

Merge remote-tracking branch 'origin/dev' into dev

tags/24090101
WendyYang 2 miesięcy temu
rodzic
commit
afdfe5fc4c
3 zmienionych plików z 114 dodań i 64 usunięć
  1. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningFlowTypeEnum.java
  2. +65
    -24
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java
  3. +48
    -39
      hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningFlowTypeEnum.java Wyświetl plik

@@ -24,7 +24,7 @@ public enum WarningFlowTypeEnum {
*/
APPROVED_PROJECT_NOT_PURCHASED(1, "已立项未采购", ProjectStatus.TO_BE_PURCHASED, "project/declareManage/projectManages/purchaseResults"),
PURCHASED_UNMODIFIED(2, "已采购未改造完成", ProjectStatus.ON_ADAPTING, "project/declareManage/projectManages/adaptiveTransformation"),
MODIFIED_NOT_FINAL_INSPECTION(3, "已改造完成未终验", ProjectStatus.ON_PILOT_RUNNING, "project/declareManage/projectManages/finalInspectionDeclare");
MODIFIED_NOT_FINAL_INSPECTION(3, "已改造完成未终验", ProjectStatus.TO_BE_FIRST_INSPECTED, "project/declareManage/projectManages/finalInspectionDeclare");

private Integer code;
private String desc;


+ 65
- 24
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java Wyświetl plik

@@ -1,6 +1,7 @@
package com.hz.pm.api.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.Lists;
import com.google.common.collect.Sets;
@@ -57,7 +58,10 @@ 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();
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE));

@@ -86,24 +90,50 @@ public class EarlyWarningProjectTask {
return;
}
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);
//@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));

if (CollUtil.isEmpty(projects)) {
return;
}

// 3.2 填报预警 如果正常了 要改会正常
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getDeclaredWarning())
&& w.getDeclaredWarning())
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);
}

// 3.3 滞后预警 如果正常了 要改会正常
// 去查询 各个报警 是否已经正常
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.去查询 各个报警 是否已经正常
private void checkNormal(List<ProjectEarlyWarning> trueWarnings) {
// 滞后预警 如果正常了 要改回正常
List<ProjectEarlyWarning> delayWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getDelayWarning())
&& w.getDelayWarning())
@@ -138,9 +168,8 @@ public class EarlyWarningProjectTask {
// 已经不是这个状态了 说明已经被提交了
if (!projectStatus.eq(project.getStatus())) {
checkCommited(delay, flowTypeEnum, projectCode);
// 其它几种 都没有 说明已经正常了
if (!delay.getProcessWarning() &&
!delay.getDeclaredWarning()) {
// 如果滞后预警正常了 改回正常
if (Boolean.FALSE.equals(delay.getDelayWarning())){
delay.setNormal(Boolean.TRUE);
delay.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}
@@ -177,8 +206,8 @@ public class EarlyWarningProjectTask {
if (!projectStatus.eq(project.getStatus())) {
checkCommited(declaredWarning, flowTypeEnum, projectCode);
// 其它几种 都没有 说明已经正常了
if (!declaredWarning.getProcessWarning() &&
!declaredWarning.getDelayWarning()) {
if (Boolean.FALSE.equals(declaredWarning.getProcessWarning()) &&
Boolean.FALSE.equals(declaredWarning.getDelayWarning())) {
declaredWarning.setNormal(Boolean.TRUE);
declaredWarning.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}
@@ -196,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;
@@ -207,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);
}
}

}
@@ -219,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;
@@ -255,8 +296,8 @@ public class EarlyWarningProjectTask {
//说明 已经审批通过了
processWarning.setProcessWarning(Boolean.FALSE);
//其它三种 都没有 说明已经正常了
if (!processWarning.getDeclaredWarning() &&
!processWarning.getDelayWarning()) {
if (Boolean.FALSE.equals(processWarning.getDeclaredWarning()) &&
Boolean.FALSE.equals(processWarning.getDelayWarning())) {
processWarning.setNormal(Boolean.TRUE);
processWarning.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}


+ 48
- 39
hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java Wyświetl plik

@@ -138,31 +138,37 @@ public class DelayWarningTest extends AppTests {
switch (flowType) {
// 已立项未采购 获取 立项时间
case APPROVED_PROJECT_NOT_PURCHASED:{
Map<String, ProjectStatusChange> approvedProjectNotPurchasedMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.DECLARED_RECORD_PASS);
if (CollUtil.isNotEmpty(approvedProjectNotPurchasedMap)){
projectStatusChangeMap.putAll(approvedProjectNotPurchasedMap);
stepName = TaskConstant.StepName.PURCHASE;
stepName = TaskConstant.StepName.PURCHASE;
if (CollUtil.isNotEmpty(projectCodes)) {
Map<String, ProjectStatusChange> approvedProjectNotPurchasedMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.DECLARED_RECORD_PASS);
if (CollUtil.isNotEmpty(approvedProjectNotPurchasedMap)) {
projectStatusChangeMap.putAll(approvedProjectNotPurchasedMap);
}
}
}
break;
// 已采购未改造完成 获取合同签订时间
case PURCHASED_UNMODIFIED:{
Map<String, ProjectStatusChange> purchasedUnmodifiedMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD);
if (CollUtil.isNotEmpty(purchasedUnmodifiedMap)){
projectStatusChangeMap.putAll(purchasedUnmodifiedMap);
stepName = TaskConstant.StepName.ADAPT_MODIFY;
stepName = TaskConstant.StepName.ADAPT_MODIFY;
if (CollUtil.isNotEmpty(projectCodes)) {
Map<String, ProjectStatusChange> purchasedUnmodifiedMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD);
if (CollUtil.isNotEmpty(purchasedUnmodifiedMap)) {
projectStatusChangeMap.putAll(purchasedUnmodifiedMap);
}
}
}
break;
// 已改造完成未终验 获取单位确认时间
case MODIFIED_NOT_FINAL_INSPECTION:{
Map<String, ProjectStatusChange> modifiedNotFinalInspectionMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM);
if (CollUtil.isNotEmpty(modifiedNotFinalInspectionMap)){
projectStatusChangeMap.putAll(modifiedNotFinalInspectionMap);
stepName = TaskConstant.StepName.FINAL;
stepName = TaskConstant.StepName.FINAL;
if (CollUtil.isNotEmpty(projectCodes)) {
Map<String, ProjectStatusChange> modifiedNotFinalInspectionMap = projectStatusChangeService.listLastEventMap(projectCodes,
ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM);
if (CollUtil.isNotEmpty(modifiedNotFinalInspectionMap)) {
projectStatusChangeMap.putAll(modifiedNotFinalInspectionMap);
}
}
}
break;
@@ -223,6 +229,9 @@ public class DelayWarningTest extends AppTests {

@Test
public void two(){
log.info("=========== 预警项目状态校验任务开始 ===========");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getNewest, Boolean.TRUE));

@@ -251,6 +260,8 @@ public class DelayWarningTest extends AppTests {
return;
}
checkNormal(trueWarnings);
stopWatch.stop();
log.info("=========== 预警项目状态校验任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}

private long getDurationTime(LocalDateTime touchTime, LocalDateTime now, ChronoUnit timeUnit) {
@@ -259,20 +270,7 @@ public class DelayWarningTest extends AppTests {

// 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);

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

// 3.3 滞后预警 如果正常了 要改会正常
// 滞后预警 如果正常了 要改回正常
List<ProjectEarlyWarning> delayWarning = trueWarnings.stream().filter(w ->
Objects.nonNull(w.getDelayWarning())
&& w.getDelayWarning())
@@ -307,9 +305,8 @@ public class DelayWarningTest extends AppTests {
// 已经不是这个状态了 说明已经被提交了
if (!projectStatus.eq(project.getStatus())) {
checkCommited(delay, flowTypeEnum, projectCode);
// 其它几种 都没有 说明已经正常了
if (!delay.getProcessWarning() &&
!delay.getDeclaredWarning()) {
// 如果滞后预警正常了 改回正常
if (Boolean.FALSE.equals(delay.getDelayWarning())){
delay.setNormal(Boolean.TRUE);
delay.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}
@@ -346,8 +343,8 @@ public class DelayWarningTest extends AppTests {
if (!projectStatus.eq(project.getStatus())) {
checkCommited(declaredWarning, flowTypeEnum, projectCode);
// 其它几种 都没有 说明已经正常了
if (!declaredWarning.getProcessWarning() &&
!declaredWarning.getDelayWarning()) {
if (Boolean.FALSE.equals(declaredWarning.getProcessWarning()) &&
Boolean.FALSE.equals(declaredWarning.getDelayWarning())) {
declaredWarning.setNormal(Boolean.TRUE);
declaredWarning.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}
@@ -365,7 +362,11 @@ public class DelayWarningTest extends AppTests {
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;
@@ -376,7 +377,11 @@ public class DelayWarningTest extends AppTests {
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);
}
}

}
@@ -388,7 +393,11 @@ public class DelayWarningTest extends AppTests {
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;
@@ -424,8 +433,8 @@ public class DelayWarningTest extends AppTests {
//说明 已经审批通过了
processWarning.setProcessWarning(Boolean.FALSE);
//其它三种 都没有 说明已经正常了
if (!processWarning.getDeclaredWarning() &&
!processWarning.getDelayWarning()) {
if (Boolean.FALSE.equals(processWarning.getDeclaredWarning()) &&
Boolean.FALSE.equals(processWarning.getDelayWarning())) {
processWarning.setNormal(Boolean.TRUE);
processWarning.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name());
}


Ładowanie…
Anuluj
Zapisz