From 6d71f431be3fbfa24f5183efe926c3899147c0b3 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 27 Aug 2024 17:33:32 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E9=87=87=E8=B4=AD=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/projectdeclared/manage/PurchaseManage.java | 6 +-- .../model/enumeration/WarningNoticeTypeEnum.java | 5 ++- .../task/EarlyWarningInstanceNotStartTask.java | 50 ++++++---------------- .../scheduler/task/EarlyWarningProjectTask.java | 5 --- 4 files changed, 19 insertions(+), 47 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 647bdb8..6c88642 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -178,12 +178,12 @@ public class PurchaseManage { if (req.getTabStatus() != null) { if (TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(req.getTabStatus())) { query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE + - " and np.status = '{0}' ", req.getTabStatus()); + " and np.status = {0} ", req.getTabStatus()); } else if (TenderMainStatus.PURCHASE_FINISHED.eq(req.getTabStatus())) { query.exists(ExistsSqlConst.PROJECT_EXISTS_PURCHASE_STATUS_CHANGE + " and npsc.event = {0} ", TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO); } else if (ProjectStatus.TO_BE_PURCHASED.eq(req.getTabStatus())) { - query.eq(Project::getStatus, ProjectStatus.TO_BE_PURCHASED); + query.eq(Project::getStatus, ProjectStatus.TO_BE_PURCHASED.getCode()); } else { return PageVo.empty(); } @@ -203,7 +203,7 @@ public class PurchaseManage { .in(Purchase::getProjectId, projectIds); if (req.getTabStatus() != null) { if (TenderMainStatus.TO_BE_SUBMIT_PURCHASE_CONSTRUCTION_INFO.eq(req.getTabStatus())) { - purchaseQuery.eq(Purchase::getStatus, req.getStatus()); + purchaseQuery.eq(Purchase::getStatus, req.getTabStatus()); } else if (TenderMainStatus.PURCHASE_FINISHED.eq(req.getTabStatus())) { purchaseQuery.exists(ExistsSqlConst.PURCHASE_EXISTS_PURCHASE_STATUS_CHANGE + " and npsc.event = {0} ", TenderStateChangeEvent.SUBMIT_PURCHASE_CONSTRUCTION_INFO); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningNoticeTypeEnum.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningNoticeTypeEnum.java index 226a93e..f46973c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningNoticeTypeEnum.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/WarningNoticeTypeEnum.java @@ -8,8 +8,8 @@ import org.apache.commons.lang3.StringUtils; import java.util.Objects; /** - * * 预警提醒类型枚举 + * * @author ZPF * @since 2023/10/31 16:14 */ @@ -21,7 +21,8 @@ public enum WarningNoticeTypeEnum { * 预警提醒类型枚举 */ CONTACT(1, "项目联系人"), - RESPONSIBLE(2, "项目负责人"); + RESPONSIBLE(2, "项目负责人"), + NONE(0, "不通知"); private Integer code; private String desc; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java index c40a023..8fcb127 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningInstanceNotStartTask.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -34,11 +35,10 @@ import com.wflow.service.IEarlyWarningService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.net.InetAddress; import java.net.UnknownHostException; import java.time.Duration; import java.time.LocalDateTime; @@ -52,50 +52,34 @@ import java.util.stream.Collectors; * @date 2023/8/3 上午9:53 * 预警填报 超时任务 */ -@Component @Slf4j +@Component @RequiredArgsConstructor +@ConditionalOnExpression("${early-warning-instance-task:false}") public class EarlyWarningInstanceNotStartTask { - @Value("${hostname:}") - private String HOST_NAME; - private final IEarlyWarningService earlyWarningService; - private final IProjectService projectService; - private final EarlyWarningManage earlyWarningManage; - private final IOperationService operationService; - private final IUserInfoService userInfoService; - private final IProjectRenewalFundDeclarationService renewalFundDeclarationService; - private final RoleManage roleManage; - private final IProjectEarlyWarningService projectEarlyWarningService; - @Scheduled(cron = "0 0/2 * * * ?") - public void doEarlyWarningDeclared() throws UnknownHostException { - if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { - return; - } - - log.info("=========== 预警填报超时任务开始 ========"); + /** + * 填报预警 + */ + @Scheduled(cron = "${early-warning-instance-task.cron:0 0/5 * * * ?}") + public void doEarlyWarningDeclared() { StopWatch stopWatch = new StopWatch(); stopWatch.start(); - // 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则 - List warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) - .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode())); + Wrapper query = Wrappers.lambdaQuery(WflowEarlyWarning.class) + .eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode()) + .eq(WflowEarlyWarning::getIsOpen, true); + List warnings = earlyWarningService.list(query); for (WflowEarlyWarning warning : warnings) { - //2. 取出rule的数据 - if (Boolean.FALSE.equals(warning.getIsOpen())) { - log.info(warning.getId() + " 此规则关闭了"); - continue; - } - String noticeMethod = warning.getNoticeMethod(); if (StringUtils.isBlank(noticeMethod) || (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && @@ -234,10 +218,6 @@ public class EarlyWarningInstanceNotStartTask { @Scheduled(cron = "10 0/2 * * * ?") public void doEarlyWarningOperation() throws UnknownHostException { - if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { - return; - } - log.info("=========== 预警实施超时任务开始 ========"); StopWatch stopWatch = new StopWatch(); stopWatch.start(); @@ -422,10 +402,6 @@ public class EarlyWarningInstanceNotStartTask { */ @Scheduled(cron = "20 0/2 * * * ?") public void doEarlyWarningRenewalFund() throws UnknownHostException { - if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { - return; - } - log.info("=========== 预警续建资金项目 超时任务开始 ========"); StopWatch stopWatch = new StopWatch(); stopWatch.start(); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java index 40cbf36..935f29e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningProjectTask.java @@ -48,15 +48,10 @@ import java.util.stream.Collectors; public class EarlyWarningProjectTask { private final IProjectService projectService; - private final IProjectEarlyWarningService projectEarlyWarningService; - private final IEarlyWarningRecordsService earlyWarningRecordsService; - private final IProjectRenewalFundDeclarationService renewalFundDeclarationService; - private final TaskService taskService; - @Value("${hostname:}") private String HOST_NAME;