@@ -10,6 +10,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | ||||
import com.ningdatech.pmapi.sys.service.IProjectEarlyWarningService; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | import com.wflow.enums.WarningRuleTypeEnum; | ||||
import com.wflow.workflow.notify.event.EarlyWarningEvent; | import com.wflow.workflow.notify.event.EarlyWarningEvent; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -43,6 +44,8 @@ public class EarlyWarningListener { | |||||
private final EarlyWarningManage earlyWarningManage; | private final EarlyWarningManage earlyWarningManage; | ||||
private final IProjectEarlyWarningService projectEarlyWarningService; | |||||
@Async | @Async | ||||
@EventListener | @EventListener | ||||
public void onApplicationEvent(EarlyWarningEvent event) { | public void onApplicationEvent(EarlyWarningEvent event) { | ||||
@@ -98,6 +101,10 @@ public class EarlyWarningListener { | |||||
return; | return; | ||||
} | } | ||||
//项目 预警信息 | |||||
projectEarlyWarningService.earlyWarning(project, | |||||
WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType); | |||||
if(StringUtils.isBlank(noticeMethod) || | if(StringUtils.isBlank(noticeMethod) || | ||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | ||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | ||||
@@ -21,6 +21,7 @@ import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationSer | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | import com.ningdatech.pmapi.projectlib.service.IProjectService; | ||||
import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; | ||||
import com.ningdatech.pmapi.sys.manage.RoleManage; | import com.ningdatech.pmapi.sys.manage.RoleManage; | ||||
import com.ningdatech.pmapi.sys.service.IProjectEarlyWarningService; | |||||
import com.ningdatech.pmapi.user.entity.UserInfo; | import com.ningdatech.pmapi.user.entity.UserInfo; | ||||
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | ||||
import com.ningdatech.pmapi.user.service.IUserInfoService; | import com.ningdatech.pmapi.user.service.IUserInfoService; | ||||
@@ -72,6 +73,8 @@ public class EarlyWarningInstanceNotStartTask { | |||||
private final RoleManage roleManage; | private final RoleManage roleManage; | ||||
private final IProjectEarlyWarningService projectEarlyWarningService; | |||||
@Scheduled(cron = "0 0/2 * * * ?") | @Scheduled(cron = "0 0/2 * * * ?") | ||||
public void doEarlyWarningDeclared() throws UnknownHostException { | public void doEarlyWarningDeclared() throws UnknownHostException { | ||||
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | ||||
@@ -165,6 +168,9 @@ public class EarlyWarningInstanceNotStartTask { | |||||
} | } | ||||
if(CollUtil.isNotEmpty(noticeTypes)){ | if(CollUtil.isNotEmpty(noticeTypes)){ | ||||
noticeMap.put(p.getProjectCode(),noticeTypes); | noticeMap.put(p.getProjectCode(),noticeTypes); | ||||
//项目 填报预警 | |||||
projectEarlyWarningService.earlyWarning(p, | |||||
WarningRuleTypeEnum.DECLARED_WARNING.getCode(),noticeTypes); | |||||
return Boolean.TRUE; | return Boolean.TRUE; | ||||
} | } | ||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
@@ -353,6 +359,9 @@ public class EarlyWarningInstanceNotStartTask { | |||||
} | } | ||||
if(CollUtil.isNotEmpty(noticeTypes)){ | if(CollUtil.isNotEmpty(noticeTypes)){ | ||||
noticeMap.put(p.getProjectCode(),noticeTypes); | noticeMap.put(p.getProjectCode(),noticeTypes); | ||||
//项目 运维预警 | |||||
projectEarlyWarningService.earlyWarning(p, | |||||
WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeTypes); | |||||
return Boolean.TRUE; | return Boolean.TRUE; | ||||
} | } | ||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
@@ -460,6 +469,9 @@ public class EarlyWarningInstanceNotStartTask { | |||||
} | } | ||||
if(CollUtil.isNotEmpty(noticeTypes)){ | if(CollUtil.isNotEmpty(noticeTypes)){ | ||||
noticeTypeMap.put(p.getProjectCode(),noticeTypes); | noticeTypeMap.put(p.getProjectCode(),noticeTypes); | ||||
//项目 运维预警 | |||||
projectEarlyWarningService.earlyWarning(p.getProjectCode(), | |||||
WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeTypes); | |||||
return Boolean.TRUE; | return Boolean.TRUE; | ||||
} | } | ||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
@@ -1,9 +1,13 @@ | |||||
package com.ningdatech.pmapi.scheduler.task; | package com.ningdatech.pmapi.scheduler.task; | ||||
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.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | 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.service.IProjectEarlyWarningService; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
@@ -11,7 +15,10 @@ import org.springframework.scheduling.annotation.Scheduled; | |||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import java.net.InetAddress; | import java.net.InetAddress; | ||||
import java.net.UnknownHostException; | import java.net.UnknownHostException; | ||||
import java.time.LocalDateTime; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Objects; | |||||
import java.util.stream.Collectors; | |||||
/** | /** | ||||
* @author ZPF | * @author ZPF | ||||
@@ -25,6 +32,8 @@ public class EarlyWarningProjectTask { | |||||
private final IProjectService projectService; | private final IProjectService projectService; | ||||
private final IProjectEarlyWarningService projectEarlyWarningService; | |||||
@Value("${hostname}") | @Value("${hostname}") | ||||
private String HOST_NAME; | private String HOST_NAME; | ||||
@@ -41,7 +50,96 @@ public class EarlyWarningProjectTask { | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | ||||
.eq(Project::getNewest, Boolean.TRUE)); | .eq(Project::getNewest, Boolean.TRUE)); | ||||
if(CollUtil.isEmpty(projects)){ | |||||
log.info("系统没有项目 退出任务"); | |||||
stopWatch.stop(); | |||||
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | |||||
return; | |||||
} | |||||
List<ProjectEarlyWarning> warnings = projectEarlyWarningService.list(); | |||||
List<String> warningProjectCodes = warnings.stream().map(ProjectEarlyWarning::getProjectCode) | |||||
.collect(Collectors.toList()); | |||||
//1.先补全 异常项目管理中 不存在的项目 | |||||
List<ProjectEarlyWarning> toAdd = projects.stream() | |||||
.filter(p -> { | |||||
if(CollUtil.isEmpty(warningProjectCodes)){ | |||||
return Boolean.TRUE; | |||||
} | |||||
if(!warningProjectCodes.contains(p.getProjectCode())){ | |||||
return Boolean.TRUE; | |||||
} | |||||
return Boolean.FALSE; | |||||
}) | |||||
.map(p -> { | |||||
ProjectEarlyWarning earlyWarning = new ProjectEarlyWarning(); | |||||
earlyWarning.setAreaCode(p.getAreaCode()); | |||||
earlyWarning.setBuildOrgCode(p.getBuildOrgCode()); | |||||
earlyWarning.setProjectCode(p.getProjectCode()); | |||||
earlyWarning.setCreateOn(LocalDateTime.now()); | |||||
earlyWarning.setStatus(ProjectEarlyWarningStatusEnum.NORMAL.name()); | |||||
earlyWarning.setRuleType(null); | |||||
return earlyWarning; | |||||
}) | |||||
.collect(Collectors.toList()); | |||||
if(CollUtil.isNotEmpty(toAdd)){ | |||||
projectEarlyWarningService.saveBatch(toAdd); | |||||
} | |||||
//2.去查询 各个报警 是否已经正常 | |||||
List<ProjectEarlyWarning> trueWarnings = warnings.stream().filter(w -> Objects.nonNull(w.getNormal()) && !w.getNormal()).collect(Collectors.toList()); | |||||
if(CollUtil.isEmpty(trueWarnings)){ | |||||
log.info("没有异常的项目 要去查询"); | |||||
stopWatch.stop(); | |||||
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | |||||
return; | |||||
} | |||||
//2.1 预警预警 如果正常了 要改会正常 | |||||
List<ProjectEarlyWarning> processWarning = trueWarnings.stream().filter(w -> Objects.nonNull(w.getProcessWarning()) | |||||
&& w.getProcessWarning()) | |||||
.collect(Collectors.toList()); | |||||
checkProcessWarning(processWarning); | |||||
//2.2 填报预警 如果正常了 要改会正常 | |||||
List<ProjectEarlyWarning> declaredWarning = trueWarnings.stream().filter(w -> | |||||
Objects.nonNull(w.getDeclaredWarning()) | |||||
&& w.getDeclaredWarning()) | |||||
.collect(Collectors.toList()); | |||||
checkDeclaredWarning(declaredWarning); | |||||
//2.3 实施预警 如果正常了 要改会正常 | |||||
List<ProjectEarlyWarning> operationWarning = trueWarnings.stream().filter(w -> | |||||
Objects.nonNull(w.getOperationWarning()) | |||||
&& w.getOperationWarning()) | |||||
.collect(Collectors.toList()); | |||||
checkOperationWarning(operationWarning); | |||||
//2.4 续建资金预警 如果正常了 要改会正常 | |||||
List<ProjectEarlyWarning> renewalFundWarning = trueWarnings.stream().filter(w -> | |||||
Objects.nonNull(w.getRenewalFundWarning()) | |||||
&& w.getRenewalFundWarning()) | |||||
.collect(Collectors.toList()); | |||||
checkRenewalFundWarning(renewalFundWarning); | |||||
stopWatch.stop(); | stopWatch.stop(); | ||||
log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | log.info("=========== 预警项目维度任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | ||||
} | } | ||||
private void checkRenewalFundWarning(List<ProjectEarlyWarning> renewalFundWarning) { | |||||
} | |||||
private void checkOperationWarning(List<ProjectEarlyWarning> operationWarning) { | |||||
} | |||||
private void checkDeclaredWarning(List<ProjectEarlyWarning> declaredWarning) { | |||||
} | |||||
private void checkProcessWarning(List<ProjectEarlyWarning> processWarning) { | |||||
} | |||||
} | } |
@@ -0,0 +1,53 @@ | |||||
package com.ningdatech.pmapi.sys.enumeration; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
import lombok.NoArgsConstructor; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Objects; | |||||
/** | |||||
* | |||||
* 项目预警状态枚举 | |||||
* @author ZPF | |||||
* @since 2023/02/24 16:14 | |||||
*/ | |||||
@Getter | |||||
@NoArgsConstructor | |||||
@AllArgsConstructor | |||||
public enum ProjectEarlyWarningStatusEnum { | |||||
/** | |||||
* 项目预警状态枚举 | |||||
*/ | |||||
NORMAL(1, "正常"), | |||||
OVER_TIME(2, "超期"), | |||||
ADVENT_TIME(3, "临期"); | |||||
private Integer code; | |||||
private String desc; | |||||
public static String match(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return StringUtils.EMPTY; | |||||
} | |||||
for (ProjectEarlyWarningStatusEnum t : ProjectEarlyWarningStatusEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t.desc; | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
public static String getNameByCode(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return StringUtils.EMPTY; | |||||
} | |||||
for (ProjectEarlyWarningStatusEnum t : ProjectEarlyWarningStatusEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t.name(); | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
} |
@@ -0,0 +1,17 @@ | |||||
package com.ningdatech.pmapi.sys.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.ningdatech.pmapi.sys.model.entity.ProjectEarlyWarning; | |||||
import org.springframework.stereotype.Repository; | |||||
/** | |||||
* <p> | |||||
* Mapper 接口 | |||||
* </p> | |||||
* | |||||
* @author PoffyZhang | |||||
*/ | |||||
@Repository | |||||
public interface ProjectEarlyWarningMapper extends BaseMapper<ProjectEarlyWarning> { | |||||
} |
@@ -0,0 +1,64 @@ | |||||
package com.ningdatech.pmapi.sys.model.entity; | |||||
import com.baomidou.mybatisplus.annotation.IdType; | |||||
import com.baomidou.mybatisplus.annotation.TableId; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import lombok.NoArgsConstructor; | |||||
import lombok.ToString; | |||||
import lombok.experimental.Accessors; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* 项目预警 | |||||
* @author PoffyZhang | |||||
*/ | |||||
@Data | |||||
@NoArgsConstructor | |||||
@ToString(callSuper = true) | |||||
@Accessors(chain = true) | |||||
@TableName("nd_project_early_warning") | |||||
@ApiModel(value = "ProjectEarlyWarning", description = "项目预警") | |||||
public class ProjectEarlyWarning implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty(value = "id") | |||||
@TableId(value = "id", type = IdType.AUTO) | |||||
private Long id; | |||||
@ApiModelProperty(value = "项目编码") | |||||
private String projectCode; | |||||
@ApiModelProperty(value = "区域") | |||||
private String areaCode; | |||||
@ApiModelProperty(value = "建设单位CODE") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty(value = "预警状态") | |||||
private String status; | |||||
@ApiModelProperty(value = "流程预警是否异常") | |||||
private Boolean processWarning; | |||||
@ApiModelProperty(value = "填报预警是否异常") | |||||
private Boolean declaredWarning; | |||||
@ApiModelProperty(value = "运维预警是否异常") | |||||
private Boolean operationWarning; | |||||
@ApiModelProperty(value = "续建资金预警是否异常") | |||||
private Boolean renewalFundWarning; | |||||
@ApiModelProperty(value = "是否正常") | |||||
private Boolean normal; | |||||
@ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督 4.续建资金项目") | |||||
private Integer ruleType; | |||||
@ApiModelProperty(value = "1超期 2临期") | |||||
private Integer noticeType; | |||||
private LocalDateTime createOn; | |||||
} |
@@ -44,6 +44,8 @@ public class WflowEarlyWarningRecords implements Serializable { | |||||
*/ | */ | ||||
@ApiModelProperty(value = "项目编码") | @ApiModelProperty(value = "项目编码") | ||||
private String projectCode; | private String projectCode; | ||||
@ApiModelProperty(value = "建设单位") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty(value = "项目id") | @ApiModelProperty(value = "项目id") | ||||
private Long projectId; | private Long projectId; | ||||
@ApiModelProperty(value = "项目名称") | @ApiModelProperty(value = "项目名称") | ||||
@@ -99,18 +101,13 @@ public class WflowEarlyWarningRecords implements Serializable { | |||||
@ApiModelProperty(value = "1超期 2临期") | @ApiModelProperty(value = "1超期 2临期") | ||||
private Integer noticeType; | private Integer noticeType; | ||||
/** | |||||
* 申报单位 | |||||
*/ | |||||
@ApiModelProperty(value = "申报单位CODE") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty(value = "申报单位") | @ApiModelProperty(value = "申报单位") | ||||
private String buildOrgName; | private String buildOrgName; | ||||
/** | /** | ||||
* 规则 | * 规则 | ||||
*/ | */ | ||||
@ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督") | |||||
@ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督 4.续建资金项目") | |||||
private Integer ruleType; | private Integer ruleType; | ||||
@@ -0,0 +1,19 @@ | |||||
package com.ningdatech.pmapi.sys.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.sys.model.entity.ProjectEarlyWarning; | |||||
import java.util.List; | |||||
/** | |||||
* @author PoffyZhang | |||||
*/ | |||||
public interface IProjectEarlyWarningService extends IService<ProjectEarlyWarning> { | |||||
Boolean earlyWarning(Project project, Integer ruleType, Integer noticeType); | |||||
Boolean earlyWarning(Project project, Integer ruleType, List<Integer> noticeTypes); | |||||
Boolean earlyWarning(String projectCode, Integer code, List<Integer> noticeTypes); | |||||
} |
@@ -0,0 +1,120 @@ | |||||
package com.ningdatech.pmapi.sys.service.impl; | |||||
import cn.hutool.core.collection.CollUtil; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.pmapi.common.constant.BizConst; | |||||
import com.ningdatech.pmapi.projectlib.mapper.ProjectMapper; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||||
import com.ningdatech.pmapi.sys.enumeration.ProjectEarlyWarningStatusEnum; | |||||
import com.ningdatech.pmapi.sys.mapper.ProjectEarlyWarningMapper; | |||||
import com.ningdatech.pmapi.sys.model.entity.ProjectEarlyWarning; | |||||
import com.ningdatech.pmapi.sys.service.IProjectEarlyWarningService; | |||||
import com.wflow.enums.WarningNoticeTypeEnum; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.springframework.stereotype.Service; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
/** | |||||
* <p> | |||||
* 业务实现类 | |||||
* 菜单 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
*/ | |||||
@Slf4j | |||||
@Service | |||||
@RequiredArgsConstructor | |||||
public class ProjectEarlyWarningServiceImpl extends ServiceImpl<ProjectEarlyWarningMapper, ProjectEarlyWarning> | |||||
implements IProjectEarlyWarningService { | |||||
private final IProjectService projectService; | |||||
@Override | |||||
public Boolean earlyWarning(Project project, Integer ruleType, Integer noticeType) { | |||||
return doEarlyWarning(project, ruleType, noticeType); | |||||
} | |||||
@Override | |||||
public Boolean earlyWarning(Project project, Integer ruleType, List<Integer> noticeTypes) { | |||||
if(CollUtil.isNotEmpty(noticeTypes)){ | |||||
if(noticeTypes.contains(WarningNoticeTypeEnum.OVER.getCode())){ | |||||
return doEarlyWarning(project, ruleType,WarningNoticeTypeEnum.OVER.getCode()); | |||||
}else{ | |||||
return doEarlyWarning(project, ruleType,WarningNoticeTypeEnum.ADVENT.getCode()); | |||||
} | |||||
} | |||||
return doEarlyWarning(project, ruleType, null); | |||||
} | |||||
@Override | |||||
public Boolean earlyWarning(String projectCode, Integer ruleType, List<Integer> noticeTypes) { | |||||
Project project = projectService.getProjectByCode(projectCode); | |||||
if(Objects.isNull(project)){ | |||||
return Boolean.FALSE; | |||||
} | |||||
return earlyWarning(project,ruleType,noticeTypes); | |||||
} | |||||
private Boolean doEarlyWarning(Project project, Integer ruleType, Integer noticeType) { | |||||
if(Objects.isNull(project) || Objects.isNull(ruleType)){ | |||||
return Boolean.FALSE; | |||||
} | |||||
String projectCode = project.getProjectCode(); | |||||
ProjectEarlyWarning old = getOne(Wrappers.lambdaQuery(ProjectEarlyWarning.class) | |||||
.eq(ProjectEarlyWarning::getProjectCode, projectCode) | |||||
.last(BizConst.LIMIT_1)); | |||||
ProjectEarlyWarning warning = new ProjectEarlyWarning(); | |||||
if(Objects.nonNull(old)){ | |||||
warning.setId(old.getId()); | |||||
}else{ | |||||
warning.setBuildOrgCode(project.getBuildOrgCode()); | |||||
warning.setAreaCode(project.getAreaCode()); | |||||
} | |||||
switch (WarningRuleTypeEnum.checkByCode(ruleType)){ | |||||
case PROCESS_WARNING: | |||||
warning.setProcessWarning(Boolean.TRUE); | |||||
break; | |||||
case DECLARED_WARNING: | |||||
warning.setDeclaredWarning(Boolean.TRUE); | |||||
break; | |||||
case OPERATION_WARNING: | |||||
warning.setOperationWarning(Boolean.TRUE); | |||||
break; | |||||
case RENEWAL_FUND: | |||||
warning.setRenewalFundWarning(Boolean.TRUE); | |||||
break; | |||||
default: | |||||
return Boolean.FALSE; | |||||
} | |||||
warning.setRuleType(ruleType); | |||||
if(Objects.isNull(noticeType)){ | |||||
warning.setStatus(ProjectEarlyWarningStatusEnum.OVER_TIME.name()); | |||||
}else{ | |||||
switch (WarningNoticeTypeEnum.match(noticeType)){ | |||||
case OVER: | |||||
warning.setStatus(ProjectEarlyWarningStatusEnum.OVER_TIME.name()); | |||||
break; | |||||
case ADVENT: | |||||
warning.setStatus(ProjectEarlyWarningStatusEnum.OVER_TIME.name()); | |||||
break; | |||||
default: | |||||
warning.setStatus(ProjectEarlyWarningStatusEnum.OVER_TIME.name()); | |||||
break; | |||||
} | |||||
} | |||||
warning.setNoticeType(noticeType); | |||||
warning.setNormal(Boolean.FALSE); | |||||
return saveOrUpdate(warning); | |||||
} | |||||
} |
@@ -1,5 +1,6 @@ | |||||
package com.ningdatech.pmapi.workbench.manage; | package com.ningdatech.pmapi.workbench.manage; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | import com.ningdatech.pmapi.common.helper.UserInfoHelper; | ||||
@@ -7,6 +8,7 @@ import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; | |||||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | ||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | ||||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | import com.ningdatech.pmapi.sys.manage.NoticeManage; | ||||
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; | |||||
import com.ningdatech.pmapi.sys.model.req.NoticeListReq; | import com.ningdatech.pmapi.sys.model.req.NoticeListReq; | ||||
import com.ningdatech.pmapi.sys.model.req.WarningListReq; | import com.ningdatech.pmapi.sys.model.req.WarningListReq; | ||||
import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | ||||
@@ -18,6 +20,7 @@ import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | import com.ningdatech.pmapi.user.util.LoginUserUtil; | ||||
import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; | import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; | ||||
import com.ningdatech.pmapi.workbench.model.vo.WorkbenchVO; | import com.ningdatech.pmapi.workbench.model.vo.WorkbenchVO; | ||||
import com.wflow.enums.WarningNoticeTypeEnum; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | import com.wflow.enums.WarningRuleTypeEnum; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
@@ -84,43 +87,21 @@ public class WorkbenchManage { | |||||
res.setNoticeList(noticeManage.listToMapByManager(noticeListReq,user)); | res.setNoticeList(noticeManage.listToMapByManager(noticeListReq,user)); | ||||
}, ForkJoinPool.commonPool()), | }, ForkJoinPool.commonPool()), | ||||
CompletableFuture.runAsync(() -> { | CompletableFuture.runAsync(() -> { | ||||
//4.预警记录 | |||||
List<WorkbenchVO.EarlyWarning> eaylies = Lists.newArrayList(); | |||||
WarningListReq req = new WarningListReq(); | |||||
// req.setBuildOrgCode(user.getEmpPosUnitCode()); | |||||
WorkbenchVO.EarlyWarning early1 = new WorkbenchVO.EarlyWarning(); | |||||
early1.setType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | |||||
early1.setTypeName(WarningRuleTypeEnum.PROCESS_WARNING.getDesc()); | |||||
PageVo<WflowEarlyWarningRecordsVO> records1 = earlyWarningRecordsService | |||||
.records(WarningRuleTypeEnum.PROCESS_WARNING.getCode(), req); | |||||
early1.setTotal(records1.getTotal().intValue()); | |||||
early1.setRecords(Lists.newArrayList(records1.getRecords())); | |||||
eaylies.add(early1); | |||||
WorkbenchVO.EarlyWarning early2 = new WorkbenchVO.EarlyWarning(); | |||||
early2.setType(WarningRuleTypeEnum.DECLARED_WARNING.getCode()); | |||||
early1.setTypeName(WarningRuleTypeEnum.DECLARED_WARNING.getDesc()); | |||||
PageVo<WflowEarlyWarningRecordsVO> records2 = earlyWarningRecordsService | |||||
.records(WarningRuleTypeEnum.DECLARED_WARNING.getCode(), req); | |||||
early2.setRecords(Lists.newArrayList(records2.getRecords())); | |||||
early2.setTotal(records2.getTotal().intValue()); | |||||
eaylies.add(early2); | |||||
WorkbenchVO.EarlyWarning early3 = new WorkbenchVO.EarlyWarning(); | |||||
early3.setType(WarningRuleTypeEnum.OPERATION_WARNING.getCode()); | |||||
early3.setTypeName(WarningRuleTypeEnum.OPERATION_WARNING.getDesc()); | |||||
PageVo<WflowEarlyWarningRecordsVO> records3 = earlyWarningRecordsService | |||||
.records(WarningRuleTypeEnum.OPERATION_WARNING.getCode(), req); | |||||
early3.setRecords(Lists.newArrayList(records3.getRecords())); | |||||
early3.setTotal(records3.getTotal().intValue()); | |||||
eaylies.add(early3); | |||||
WorkbenchVO.EarlyWarning early4 = new WorkbenchVO.EarlyWarning(); | |||||
early4.setType(WarningRuleTypeEnum.RENEWAL_FUND.getCode()); | |||||
early4.setTypeName(WarningRuleTypeEnum.RENEWAL_FUND.getDesc()); | |||||
PageVo<WflowEarlyWarningRecordsVO> records4 = earlyWarningRecordsService | |||||
.records(WarningRuleTypeEnum.RENEWAL_FUND.getCode(), req); | |||||
early4.setRecords(Lists.newArrayList(records4.getRecords())); | |||||
early4.setTotal(records4.getTotal().intValue()); | |||||
eaylies.add(early4); | |||||
res.setEarlyWarning(eaylies); | |||||
//4.项目预警记录 | |||||
WorkbenchVO.ProjectEarlyWarning projectEarlyWarning = new WorkbenchVO.ProjectEarlyWarning(); | |||||
//4.1 | |||||
//累积预警统计 | |||||
WorkbenchVO.WarningStatistics accumulate = new WorkbenchVO.WarningStatistics(); | |||||
Long overCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) | |||||
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.OVER.getCode()) | |||||
.or(q2 -> q2.isNull(WflowEarlyWarningRecords::getNoticeType))); | |||||
accumulate.setOver(overCount.intValue()); | |||||
Long adventCount = earlyWarningRecordsService.count(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) | |||||
.eq(WflowEarlyWarningRecords::getNoticeType, WarningNoticeTypeEnum.ADVENT.getCode())); | |||||
accumulate.setAdvent(adventCount.intValue()); | |||||
projectEarlyWarning.setAccumulate(accumulate); | |||||
res.setProjectEarlyWarning(projectEarlyWarning); | |||||
}, ForkJoinPool.commonPool()) | }, ForkJoinPool.commonPool()) | ||||
).join(); | ).join(); | ||||
@@ -1,5 +1,6 @@ | |||||
package com.ningdatech.pmapi.workbench.model.vo; | package com.ningdatech.pmapi.workbench.model.vo; | ||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | ||||
import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; | import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; | ||||
import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | import com.ningdatech.pmapi.sys.model.vo.WflowEarlyWarningRecordsVO; | ||||
@@ -41,6 +42,42 @@ public class WorkbenchVO implements Serializable { | |||||
@ApiModelProperty("预警记录") | @ApiModelProperty("预警记录") | ||||
public List<EarlyWarning> earlyWarning; | public List<EarlyWarning> earlyWarning; | ||||
@ApiModelProperty("项目预警记录") | |||||
public ProjectEarlyWarning projectEarlyWarning; | |||||
@Data | |||||
public static class ProjectEarlyWarning { | |||||
@ApiModelProperty("统计数据-累积") | |||||
private WarningStatistics accumulate; | |||||
@ApiModelProperty("统计数据-当前") | |||||
private WarningStatistics current; | |||||
@ApiModelProperty("流程项目预警") | |||||
private PageVo<ProjectEarlyWarning> process; | |||||
@ApiModelProperty("填报项目预警") | |||||
private PageVo<ProjectEarlyWarning> declared; | |||||
@ApiModelProperty("实施项目预警") | |||||
private PageVo<ProjectEarlyWarning> operation; | |||||
@ApiModelProperty("续建资金项目预警") | |||||
private PageVo<ProjectEarlyWarning> renewalFund; | |||||
} | |||||
@Data | |||||
public static class WarningStatistics { | |||||
@ApiModelProperty("正常") | |||||
private Integer normal = 0; | |||||
@ApiModelProperty("临期") | |||||
private Integer advent = 0; | |||||
@ApiModelProperty("超期") | |||||
private Integer over = 0; | |||||
} | |||||
@Data | @Data | ||||
public static class EarlyWarning { | public static class EarlyWarning { | ||||
@ApiModelProperty("类型") | @ApiModelProperty("类型") | ||||