diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java new file mode 100644 index 0000000..891d926 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java @@ -0,0 +1,58 @@ +package com.ningdatech.pmapi.projectlib.enumeration; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +import java.util.Objects; + +/** + * + * 预警填报类型枚举 + * @author CMM + * @since 2023/02/24 16:14 + */ +@Getter +@NoArgsConstructor +@AllArgsConstructor +public enum WarningFlowTypeEnum { + /** + * 预警填报类型枚举 + */ + UNIT_INNER_AUDIT(1, "预审申报",ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()), + PRELIMINARY_PREVIEW(2, "建设方案申报",ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()), + DEPT_UNITED_REVIEW(3,"采购结果备案",ProjectStatusEnum.TO_BE_PURCHASED.getCode()), + CONSTRUCTION_PLAN_REVIEW(4,"初验备案",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()), + PROJECT_FINAL_INSPECTION(5,"验收申报",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); + + private Integer code; + private String desc; + + //对应的 待提交时的项目状态 + private Integer projectStutas; + + public static String getDescByCode(Integer code) { + if (Objects.isNull(code)) { + return StringUtils.EMPTY; + } + for (WarningFlowTypeEnum t : WarningFlowTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static WarningFlowTypeEnum getByCode(Integer code) { + if (Objects.isNull(code)) { + return null; + } + for (WarningFlowTypeEnum t : WarningFlowTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t; + } + } + return null; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java index 11d1cfe..c941c8b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java @@ -7,7 +7,11 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.common.enumeration.CommonEnum; -import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; +import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; +import com.ningdatech.pmapi.projectlib.service.IProjectInstService; +import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.wflow.bean.entity.WflowEarlyWarning; import com.wflow.enums.WarningRuleTypeEnum; import com.wflow.service.IEarlyWarningService; @@ -21,6 +25,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * @author ZPF @@ -37,6 +42,10 @@ public class EarlyWarningInstanceNotStartTask { private final IEarlyWarningService earlyWarningService; + private final IProjectService projectService; + + private final IProjectInstService projectInstService; + @Scheduled(cron = "0 2 * * * ?") public void doTask() throws UnknownHostException { if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { @@ -78,13 +87,26 @@ public class EarlyWarningInstanceNotStartTask { return; } - InstTypeEnum instTypeEnum = InstTypeEnum.getByCode(biz); - if(Objects.isNull(instTypeEnum)){ + WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); + if(Objects.isNull(flowTypeEnum)){ log.info("匹配不到 流程类型"); return; } - + //得出 对应待提交的项目状态 + Integer projectStutas = flowTypeEnum.getProjectStutas(); + String areaCode = warning.getAreaCode(); + //测试先用分钟 + //查询 所有这个区域的项目 未提交的项目 + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getAreaCode, areaCode) + .eq(Project::getNewest, Boolean.TRUE) + .eq(Project::getStatus,projectStutas)); + List projectIds = projects.stream().map(Project::getId) + .collect(Collectors.toList()); + projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId,projectIds) + .eq(ProjectInst::getInstType,biz)); }); } }