|
|
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.common.enumeration.CommonEnum; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; |
|
|
@@ -28,12 +30,14 @@ import com.wflow.service.IEarlyWarningService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import java.net.InetAddress; |
|
|
|
import java.net.UnknownHostException; |
|
|
|
import java.time.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
@@ -97,6 +101,7 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
} |
|
|
|
|
|
|
|
String noticeContent = warning.getNoticeContent(); |
|
|
|
String adventContent = warning.getAdventContent(); |
|
|
|
String rule = warning.getRule(); |
|
|
|
if(StringUtils.isNotBlank(rule)){ |
|
|
|
JSONArray ruleArray = JSON.parseArray(rule); |
|
|
@@ -106,11 +111,17 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
Integer time = rJson.getInteger("time"); |
|
|
|
Integer biz = rJson.getInteger("biz"); |
|
|
|
String notice = rJson.getString("notice"); |
|
|
|
if(Objects.isNull(time) || Objects.isNull(biz)){ |
|
|
|
Integer adventTime = rJson.getInteger("adventTime"); |
|
|
|
if((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)){ |
|
|
|
log.info("规则数据 错误 :{}",rJson); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtils.isBlank(notice)){ |
|
|
|
log.info("取不到提醒人配置 : " + rJson); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); |
|
|
|
if(Objects.isNull(flowTypeEnum)){ |
|
|
|
log.info("匹配不到 业务类型"); |
|
|
@@ -127,6 +138,7 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.eq(Project::getStatus,projectStutas)); |
|
|
|
|
|
|
|
Map<String,List<Integer>> noticeMap = Maps.newHashMap(); |
|
|
|
//需要发通知的项目 |
|
|
|
List<Project> needToWaringProjects = needNextProjects.stream() |
|
|
|
.filter(p -> { |
|
|
@@ -142,8 +154,17 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
List<Integer> noticeTypes = Lists.newArrayList(); |
|
|
|
if(Objects.nonNull(time) && Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); |
|
|
|
} |
|
|
|
if(Objects.nonNull(adventTime) && Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 |
|
|
|
Duration.between(p.getUpdateOn(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); |
|
|
|
} |
|
|
|
if(CollUtil.isNotEmpty(noticeTypes)){ |
|
|
|
noticeMap.put(p.getProjectCode(),noticeTypes); |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
@@ -158,10 +179,6 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
} |
|
|
|
|
|
|
|
for(Project needToWaringProject : needToWaringProjects){ |
|
|
|
if(StringUtils.isBlank(notice)){ |
|
|
|
log.info(needToWaringProject.getProjectCode() + "取不到提醒人配置!"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
String employeeCode = null; |
|
|
|
String username = null; |
|
|
|
String mobile = null; |
|
|
@@ -178,9 +195,15 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
employeeCode = user.getEmployeeCode(); |
|
|
|
} |
|
|
|
if(Objects.nonNull(employeeCode)){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.DECLARED_WARNING.getCode()); |
|
|
|
if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ |
|
|
|
List<Integer> noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); |
|
|
|
for(Integer noticeType : noticeTypes){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.DECLARED_WARNING.getCode(),noticeType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -196,9 +219,15 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
employeeCode = user.getEmployeeCode(); |
|
|
|
} |
|
|
|
if(Objects.nonNull(employeeCode)){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.DECLARED_WARNING.getCode()); |
|
|
|
if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ |
|
|
|
List<Integer> noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); |
|
|
|
for(Integer noticeType : noticeTypes){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.DECLARED_WARNING.getCode(),noticeType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -241,6 +270,7 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
} |
|
|
|
|
|
|
|
String noticeContent = warning.getNoticeContent(); |
|
|
|
String adventContent = warning.getAdventContent(); |
|
|
|
String rule = warning.getRule(); |
|
|
|
if(StringUtils.isNotBlank(rule)){ |
|
|
|
JSONArray ruleArray = JSON.parseArray(rule); |
|
|
@@ -248,8 +278,9 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
ruleArray.forEach(r -> { |
|
|
|
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); |
|
|
|
Integer time = rJson.getInteger("time"); |
|
|
|
Integer adventTime = rJson.getInteger("adventTime"); |
|
|
|
Integer biz = rJson.getInteger("biz"); |
|
|
|
if(Objects.isNull(time) || Objects.isNull(biz)){ |
|
|
|
if((Objects.isNull(time) && Objects.isNull(adventTime)) || Objects.isNull(biz)){ |
|
|
|
log.info("规则数据 错误 :{}",rJson); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -276,6 +307,7 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
.in(Operation::getProjectCode, projectCodes)); |
|
|
|
|
|
|
|
Map<String,Operation> operationMap = operations.stream().collect(Collectors.toMap(Operation::getProjectCode,o -> o)); |
|
|
|
Map<String,List<Integer>> noticeMap = Maps.newHashMap(); |
|
|
|
//需要发通知的项目 |
|
|
|
List<Project> needToWaringProjects = needNextProjects.stream() |
|
|
|
.filter(p -> { |
|
|
@@ -296,20 +328,33 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
Operation operation = operationMap.get(p.getProjectCode()); |
|
|
|
|
|
|
|
List<Integer> noticeTypes = Lists.newArrayList(); |
|
|
|
if(WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)){ |
|
|
|
//初验 |
|
|
|
if(Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
if(Objects.nonNull(time) && Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 |
|
|
|
return Boolean.TRUE; |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); |
|
|
|
} |
|
|
|
if(Objects.nonNull(adventTime) && Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 |
|
|
|
Duration.between(operation.getInitialInspectionDate(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); |
|
|
|
} |
|
|
|
}else if(WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)){ |
|
|
|
//终验 |
|
|
|
if(Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
if(Objects.nonNull(time) && Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 |
|
|
|
return Boolean.TRUE; |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); |
|
|
|
} |
|
|
|
if(Objects.nonNull(adventTime) && Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 |
|
|
|
Duration.between(operation.getFinalInspectionDate(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ //time * 60 |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(noticeTypes)){ |
|
|
|
noticeMap.put(p.getProjectCode(),noticeTypes); |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
return Boolean.FALSE; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@@ -324,9 +369,15 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
for(Project needToWaringProject : needToWaringProjects){ |
|
|
|
//去预警通知 |
|
|
|
String employeeCode = needToWaringProject.getSponsor(); |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.OPERATION_WARNING.getCode()); |
|
|
|
if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ |
|
|
|
List<Integer> noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); |
|
|
|
for(Integer noticeType : noticeTypes){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent,time,biz, |
|
|
|
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject, |
|
|
|
WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@@ -362,6 +413,8 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
} |
|
|
|
|
|
|
|
String noticeMethod = warning.getNoticeMethod(); |
|
|
|
String noticeContent = warning.getNoticeContent(); |
|
|
|
String adventContent = warning.getAdventContent(); |
|
|
|
if(StringUtils.isBlank(noticeMethod) || |
|
|
|
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && |
|
|
|
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ |
|
|
@@ -369,7 +422,6 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
String noticeContent = warning.getNoticeContent(); |
|
|
|
String rule = warning.getRule(); |
|
|
|
if(StringUtils.isNotBlank(rule)){ |
|
|
|
JSONArray ruleArray = JSON.parseArray(rule); |
|
|
@@ -377,7 +429,8 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
ruleArray.forEach(r -> { |
|
|
|
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); |
|
|
|
Integer time = rJson.getInteger("time"); |
|
|
|
if(Objects.isNull(time)){ |
|
|
|
Integer adventTime = rJson.getInteger("adventTime"); |
|
|
|
if((Objects.isNull(time) && Objects.isNull(adventTime)) && Objects.isNull(adventTime)){ |
|
|
|
log.info("规则数据 错误 :{}",rJson); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -391,15 +444,24 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
.eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE) |
|
|
|
.eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PENDING.name())); |
|
|
|
|
|
|
|
Map<String,List<Integer>> noticeTypeMap = Maps.newHashMap(); |
|
|
|
//需要发通知的项目 |
|
|
|
List<ProjectRenewalFundDeclaration> needToWaringProjects = needNextProjects.stream() |
|
|
|
.filter(p -> { |
|
|
|
//超时未审批 |
|
|
|
if(Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
List<Integer> noticeTypes = Lists.newArrayList(); |
|
|
|
if(Objects.nonNull(time) && Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() >= time * 60 && //time * 60 |
|
|
|
Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() <= time * 60 + 1){ //time * 60 |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.OVER.getCode()); |
|
|
|
} |
|
|
|
if(Objects.nonNull(adventTime) && Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() >= adventTime * 60 && //time * 60 |
|
|
|
Duration.between(p.getCreateOn(),LocalDateTime.now()).toMinutes() <= adventTime * 60 + 1){ //time * 60 |
|
|
|
noticeTypes.add(com.wflow.enums.WarningNoticeTypeEnum.ADVENT.getCode()); |
|
|
|
} |
|
|
|
if(CollUtil.isNotEmpty(noticeTypes)){ |
|
|
|
noticeTypeMap.put(p.getProjectCode(),noticeTypes); |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
|
|
|
|
return Boolean.FALSE; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@@ -416,9 +478,15 @@ public class EarlyWarningInstanceNotStartTask { |
|
|
|
//去预警通知 发给区管 |
|
|
|
List<UserInfo> users = roleManage.getUsersByRoleType(RoleEnum.REGION_MANAGER.name(),needToWaringProject.getRegionCode()); |
|
|
|
for(UserInfo user : users){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,null, |
|
|
|
needToWaringProject.getUpdateOn(),user.getEmployeeCode(),project, |
|
|
|
WarningRuleTypeEnum.RENEWAL_FUND.getCode()); |
|
|
|
if(noticeTypeMap.containsKey(needToWaringProject.getProjectCode())){ |
|
|
|
List<Integer> noticeTypes = noticeTypeMap.get(needToWaringProject.getProjectCode()); |
|
|
|
for(Integer noticeType : noticeTypes){ |
|
|
|
earlyWarningManage.doEarlyWarning(noticeMethod,Objects.nonNull(noticeType)&¬iceType.equals(1) ? noticeContent : adventContent,time,null, |
|
|
|
needToWaringProject.getUpdateOn(),user.getEmployeeCode(),project, |
|
|
|
WarningRuleTypeEnum.RENEWAL_FUND.getCode(),noticeType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|