Kaynağa Gözat

预警整改

master
PoffyZhang 11 ay önce
ebeveyn
işleme
77a2e1442d
4 değiştirilmiş dosya ile 107 ekleme ve 30 silme
  1. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java
  2. +96
    -28
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java
  3. +3
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java
  4. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java

+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java Dosyayı Görüntüle

@@ -52,6 +52,7 @@ public class EarlyWarningListener {
Integer timeout = event.getTimeout();
String noticeMethod = event.getNoticeMethod();
String noticeContent = event.getNoticeContent();
Integer noticeType = event.getNoticeType();

//1.根据nodeId 查询到 node 去查找 未完成 项目实例关系表 找到实例
List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery()
@@ -108,7 +109,7 @@ public class EarlyWarningListener {
String employeeCode = hai.getAssignee();
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,timeout,pi.getInstType(),
hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()
,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode());
,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType);
}
}
}

+ 96
- 28
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java Dosyayı Görüntüle

@@ -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)&&noticeType.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)&&noticeType.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)&&noticeType.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)&&noticeType.equals(1) ? noticeContent : adventContent,time,null,
needToWaringProject.getUpdateOn(),user.getEmployeeCode(),project,
WarningRuleTypeEnum.RENEWAL_FUND.getCode(),noticeType);
}
}

}
}
});


+ 3
- 1
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java Dosyayı Görüntüle

@@ -56,7 +56,8 @@ public class EarlyWarningManage {
* @param project
*/
public void doEarlyWarning(String noticeMethod,String noticeContent, Integer timeout,Integer biz,
LocalDateTime startTime,String employeeCode, Project project,Integer ruleType) {
LocalDateTime startTime,String employeeCode,
Project project,Integer ruleType,Integer noticeType) {
//1.存入 预警记录
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode);
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords();
@@ -102,6 +103,7 @@ public class EarlyWarningManage {
records.setProjectId(project.getId());
records.setProjectCode(project.getProjectCode());
records.setProjectStatus(project.getStatus());
records.setNoticeType(noticeType);
earlyWarningRecordsService.save(records);

//2.消息提醒


+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java Dosyayı Görüntüle

@@ -94,6 +94,12 @@ public class WflowEarlyWarningRecords implements Serializable {
private String noticeContent;

/**
* 通知类型
*/
@ApiModelProperty(value = "1超期 2临期")
private Integer noticeType;

/**
* 申报单位
*/
@ApiModelProperty(value = "申报单位CODE")


Yükleniyor…
İptal
Kaydet