|
|
@@ -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<WflowEarlyWarning> warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) |
|
|
|
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode())); |
|
|
|
Wrapper<WflowEarlyWarning> query = Wrappers.lambdaQuery(WflowEarlyWarning.class) |
|
|
|
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode()) |
|
|
|
.eq(WflowEarlyWarning::getIsOpen, true); |
|
|
|
List<WflowEarlyWarning> 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(); |
|
|
|