|
|
@@ -3,13 +3,25 @@ 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.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationService; |
|
|
|
import com.ningdatech.pmapi.projectlib.service.IProjectService; |
|
|
|
import com.ningdatech.pmapi.sys.enumeration.ProjectEarlyWarningStatusEnum; |
|
|
|
import com.ningdatech.pmapi.sys.model.entity.ProjectEarlyWarning; |
|
|
|
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; |
|
|
|
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; |
|
|
|
import com.ningdatech.pmapi.sys.service.IProjectEarlyWarningService; |
|
|
|
import com.wflow.enums.WarningRuleTypeEnum; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.flowable.engine.TaskService; |
|
|
|
import org.flowable.task.api.Task; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
@@ -34,6 +46,12 @@ public class EarlyWarningProjectTask { |
|
|
|
|
|
|
|
private final IProjectEarlyWarningService projectEarlyWarningService; |
|
|
|
|
|
|
|
private final IEarlyWarningRecordsService earlyWarningRecordsService; |
|
|
|
|
|
|
|
private final IProjectRenewalFundDeclarationService renewalFundDeclarationService; |
|
|
|
|
|
|
|
private final TaskService taskService; |
|
|
|
|
|
|
|
@Value("${hostname}") |
|
|
|
private String HOST_NAME; |
|
|
|
|
|
|
@@ -127,19 +145,164 @@ public class EarlyWarningProjectTask { |
|
|
|
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); |
|
|
|
} |
|
|
|
|
|
|
|
private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarning) { |
|
|
|
private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarnings) { |
|
|
|
if(CollUtil.isEmpty(renewalFundWarnings)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
for(ProjectEarlyWarning renewalFundWarning : renewalFundWarnings){ |
|
|
|
String projectCode = renewalFundWarning.getProjectCode(); |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
if(Objects.isNull(project)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
WflowEarlyWarningRecords record = earlyWarningRecordsService.getOne(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) |
|
|
|
.eq(WflowEarlyWarningRecords::getProjectCode, projectCode) |
|
|
|
.eq(WflowEarlyWarningRecords::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode()) |
|
|
|
.orderByDesc(WflowEarlyWarningRecords::getWarningTime) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.isNull(record)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
//借用了NODEID 其实 是续建id |
|
|
|
String nodeId = record.getNodeId(); |
|
|
|
ProjectRenewalFundDeclaration renewalFund = renewalFundDeclarationService.getById(nodeId); |
|
|
|
if(Objects.isNull(renewalFund)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
String approvalStatus = renewalFund.getApprovalStatus(); |
|
|
|
ProjectRenewalApprovalStatusEnum match = ProjectRenewalApprovalStatusEnum |
|
|
|
.match(approvalStatus); |
|
|
|
if(Objects.nonNull(match)){ |
|
|
|
//如果是已经审批 |
|
|
|
if(match.name().equals(ProjectRenewalApprovalStatusEnum.PASS.name())){ |
|
|
|
renewalFundWarning.setRenewalFundWarning(Boolean.FALSE); |
|
|
|
//其它三种 都没有 说明已经正常了 |
|
|
|
if(!renewalFundWarning.getProcessWarning() && |
|
|
|
!renewalFundWarning.getDeclaredWarning() && |
|
|
|
!renewalFundWarning.getOperationWarning()){ |
|
|
|
renewalFundWarning.setNormal(Boolean.TRUE); |
|
|
|
} |
|
|
|
projectEarlyWarningService.updateById(renewalFundWarning); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkOperationWarning(List<ProjectEarlyWarning> operationWarning) { |
|
|
|
private void checkOperationWarning(List<ProjectEarlyWarning> operationWarnings) { |
|
|
|
if(CollUtil.isEmpty(operationWarnings)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
for( ProjectEarlyWarning operationWarning : operationWarnings){ |
|
|
|
String projectCode = operationWarning.getProjectCode(); |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
if(Objects.isNull(project)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
WflowEarlyWarningRecords record = earlyWarningRecordsService.getOne(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) |
|
|
|
.eq(WflowEarlyWarningRecords::getProjectCode, projectCode) |
|
|
|
.eq(WflowEarlyWarningRecords::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode()) |
|
|
|
.orderByDesc(WflowEarlyWarningRecords::getWarningTime) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.isNull(record)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
Integer biz = record.getBiz(); |
|
|
|
WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(biz); |
|
|
|
if(Objects.isNull(operationTypeEnum)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
Integer projectStutas = operationTypeEnum.getProjectStutas(); |
|
|
|
//已经不是这个状态了 说明已经被提交了 |
|
|
|
if(!projectStutas.equals(project.getStatus())){ |
|
|
|
operationWarning.setOperationWarning(Boolean.FALSE); |
|
|
|
//其它三种 都没有 说明已经正常了 |
|
|
|
if(!operationWarning.getProcessWarning() && |
|
|
|
!operationWarning.getDeclaredWarning() && |
|
|
|
!operationWarning.getRenewalFundWarning()){ |
|
|
|
operationWarning.setNormal(Boolean.TRUE); |
|
|
|
} |
|
|
|
projectEarlyWarningService.updateById(operationWarning); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkDeclaredWarning(List<ProjectEarlyWarning> declaredWarning) { |
|
|
|
|
|
|
|
private void checkDeclaredWarning(List<ProjectEarlyWarning> declaredWarnings) { |
|
|
|
if(CollUtil.isEmpty(declaredWarnings)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
for( ProjectEarlyWarning declaredWarning : declaredWarnings){ |
|
|
|
String projectCode = declaredWarning.getProjectCode(); |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
if(Objects.isNull(project)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
WflowEarlyWarningRecords record = earlyWarningRecordsService.getOne(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) |
|
|
|
.eq(WflowEarlyWarningRecords::getProjectCode, projectCode) |
|
|
|
.eq(WflowEarlyWarningRecords::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode()) |
|
|
|
.orderByDesc(WflowEarlyWarningRecords::getWarningTime) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.isNull(record)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
Integer biz = record.getBiz(); |
|
|
|
WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); |
|
|
|
if(Objects.isNull(flowTypeEnum)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
Integer projectStutas = flowTypeEnum.getProjectStutas(); |
|
|
|
//已经不是这个状态了 说明已经被提交了 |
|
|
|
if(!projectStutas.equals(project.getStatus())){ |
|
|
|
declaredWarning.setDeclaredWarning(Boolean.FALSE); |
|
|
|
//其它三种 都没有 说明已经正常了 |
|
|
|
if(!declaredWarning.getProcessWarning() && |
|
|
|
!declaredWarning.getOperationWarning() && |
|
|
|
!declaredWarning.getRenewalFundWarning()){ |
|
|
|
declaredWarning.setNormal(Boolean.TRUE); |
|
|
|
} |
|
|
|
projectEarlyWarningService.updateById(declaredWarning); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkProcessWarning(List<ProjectEarlyWarning> processWarning) { |
|
|
|
/** |
|
|
|
* 流程 查看 是否已经处理过 |
|
|
|
* @param processWarnings |
|
|
|
*/ |
|
|
|
private void checkProcessWarning(List<ProjectEarlyWarning> processWarnings) { |
|
|
|
if(CollUtil.isEmpty(processWarnings)){ |
|
|
|
return; |
|
|
|
} |
|
|
|
for( ProjectEarlyWarning processWarning : processWarnings){ |
|
|
|
String projectCode = processWarning.getProjectCode(); |
|
|
|
WflowEarlyWarningRecords record = earlyWarningRecordsService.getOne(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) |
|
|
|
.eq(WflowEarlyWarningRecords::getProjectCode, projectCode) |
|
|
|
.orderByDesc(WflowEarlyWarningRecords::getWarningTime) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.isNull(record)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
String nodeId = record.getNodeId(); |
|
|
|
if(StringUtils.isBlank(nodeId)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
List<Task> tasks = taskService.createTaskQuery() |
|
|
|
.taskDefinitionKey(nodeId) |
|
|
|
.list(); |
|
|
|
if(CollUtil.isEmpty(tasks)){ |
|
|
|
//说明 已经审批通过了 |
|
|
|
processWarning.setProcessWarning(Boolean.FALSE); |
|
|
|
//其它三种 都没有 说明已经正常了 |
|
|
|
if(!processWarning.getDeclaredWarning() && |
|
|
|
!processWarning.getOperationWarning() && |
|
|
|
!processWarning.getRenewalFundWarning()){ |
|
|
|
processWarning.setNormal(Boolean.TRUE); |
|
|
|
} |
|
|
|
projectEarlyWarningService.updateById(processWarning); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |