Selaa lähdekoodia

预警 实施 消息提醒

master
PoffyZhang 1 vuosi sitten
vanhempi
commit
23bfba6ae9
5 muutettua tiedostoa jossa 419 lisäystä ja 91 poistoa
  1. +55
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java
  2. +13
    -76
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java
  3. +179
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java
  4. +154
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java
  5. +18
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java

+ 55
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java Näytä tiedosto

@@ -0,0 +1,55 @@
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 WarningOperationTypeEnum {
/**
* 预警实施类型枚举
*/
CHUYAN(1, "项目初验",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()),
ZHONGYAN(2, "项目终验",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 (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}

public static WarningOperationTypeEnum getByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
}
for (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) {
if (code.equals(t.getCode())) {
return t;
}
}
return null;
}
}

+ 13
- 76
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java Näytä tiedosto

@@ -14,6 +14,7 @@ import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService;
import com.ningdatech.pmapi.sys.manage.EarlyWarningManage;
import com.ningdatech.pmapi.sys.manage.NoticeManage;
import com.ningdatech.pmapi.sys.model.entity.Notify;
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords;
@@ -54,17 +55,7 @@ public class EarlyWarningListener {

private final IProjectService projectService;

private final IEarlyWarningRecordsService earlyWarningRecordsService;

private final UserInfoHelper userInfoHelper;

private final YxtCallOrSmsHelper yxtCallOrSmsHelper;

private final NoticeManage noticeManage;

private final INdWorkNoticeStagingService workNoticeStagingService;

private final INotifyService notifyService;
private final EarlyWarningManage earlyWarningManage;

@Async
@EventListener
@@ -120,72 +111,18 @@ public class EarlyWarningListener {
return;
}

for(HistoricActivityInstance hai : hais){
if(StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){
log.info("通知方式为空或者错误!");
return;
}

//1.存入 预警记录
String assignee = hai.getAssignee();
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee);
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords();
String content = convertContent(noticeContent,project.getProjectName(),
InstTypeEnum.getByCode(pi.getInstType()),timeout);
records.setAreaCode(project.getAreaCode());
records.setBuildOrgCode(project.getBuildOrgCode());
records.setBuildOrgName(project.getBuildOrgName());
records.setCreateOn(LocalDateTime.now());
records.setWarningTime(LocalDateTime.now());
records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
records.setInstType(pi.getInstType());
records.setNoticeMethod(noticeMethod);
records.setNoticeContent(content);
records.setProjectName(project.getProjectName());
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode());
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY);
records.setWarningEmployeecode(assignee);
earlyWarningRecordsService.save(records);

//2.消息提醒
Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content);
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name());
notifyService.save(notify);

//3.发短信
if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){
SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext();
context.setReceiveNumber(user.getMobile());
context.setContent(content);
yxtCallOrSmsHelper.sendSms(context);
}

//4.浙政钉
if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(assignee);
passWorkNoticeInfo.setMsg(content);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW);
}
if(StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){
log.info("通知方式为空或者错误!");
return;
}
}

/**
* 转换出 通知的内容
* @param noticeContent
* @param projectName
* @param instTypeEnum
* @param timeout
* @return
*/
private String convertContent(String noticeContent, String projectName, InstTypeEnum instTypeEnum, Integer timeout) {
noticeContent = noticeContent.replace("{projectName}",projectName)
.replace("{flowType}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{flowType}")
.replace("{time}",String.valueOf(timeout));
log.info("通知内容 :{}",noticeContent);
return noticeContent;
for(HistoricActivityInstance hai : hais){
String employeeCode = hai.getAssignee();
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,timeout,pi.getInstType(),
hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()
,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode());
}
}
}

+ 179
- 11
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java Näytä tiedosto

@@ -7,11 +7,16 @@ 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.projectdeclared.model.entity.Contract;
import com.ningdatech.pmapi.projectdeclared.model.entity.Operation;
import com.ningdatech.pmapi.projectdeclared.service.IContractService;
import com.ningdatech.pmapi.projectdeclared.service.IOperationService;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum;
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.ningdatech.pmapi.sys.manage.EarlyWarningManage;
import com.wflow.bean.entity.WflowEarlyWarning;
import com.wflow.enums.WarningRuleTypeEnum;
import com.wflow.service.IEarlyWarningService;
@@ -23,7 +28,9 @@ 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.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

@@ -44,10 +51,14 @@ public class EarlyWarningInstanceNotStartTask {

private final IProjectService projectService;

private final IProjectInstService projectInstService;
private final EarlyWarningManage earlyWarningManage;

@Scheduled(cron = "0 2 * * * ?")
public void doTask() throws UnknownHostException {
private final IContractService contractService;

private final IOperationService operationService;

@Scheduled(cron = "0 0/2 * * * ?")
public void doEarlyWarningDeclared() throws UnknownHostException {
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) {
return;
}
@@ -74,6 +85,7 @@ public class EarlyWarningInstanceNotStartTask {
return;
}

String noticeContent = warning.getNoticeContent();
String rule = warning.getRule();
if(StringUtils.isNotBlank(rule)){
JSONArray ruleArray = JSON.parseArray(rule);
@@ -89,7 +101,7 @@ public class EarlyWarningInstanceNotStartTask {

WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz);
if(Objects.isNull(flowTypeEnum)){
log.info("匹配不到 流程类型");
log.info("匹配不到 业务类型");
return;
}

@@ -98,15 +110,47 @@ public class EarlyWarningInstanceNotStartTask {
String areaCode = warning.getAreaCode();
//测试先用分钟
//查询 所有这个区域的项目 未提交的项目
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class)
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getAreaCode, areaCode)
.eq(Project::getNewest, Boolean.TRUE)
.eq(Project::getStatus,projectStutas));
List<Long> projectIds = projects.stream().map(Project::getId)
//需要发通知的项目
List<Project> needToWaringProjects = needNextProjects.stream()
.filter(p -> {
//判断 当状态在 建设中的时候 是不是要初验了
if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(p);
//如果合同信息提交过了 才是 待初验状态
if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){
if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class)
.in(Contract::getProjectId, allVersionProjectId))){
return Boolean.FALSE;
}
}
}

if(Duration.between(LocalDateTime.now(),p.getUpdateOn()).toMinutes() >= time || //time * 60
Duration.between(LocalDateTime.now(),p.getUpdateOn()).toMinutes() <= time + 1){ //time * 60
return Boolean.TRUE;
}
return Boolean.FALSE;
})
.collect(Collectors.toList());
projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId,projectIds)
.eq(ProjectInst::getInstType,biz));

if(StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){
log.info("通知方式为空或者错误!");
return;
}

for(Project needToWaringProject : needToWaringProjects){
//去预警通知
String employeeCode = needToWaringProject.getSponsor();
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz,
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject,
WarningRuleTypeEnum.DECLARED_WARNING.getCode());
}
});
}
}
@@ -116,4 +160,128 @@ public class EarlyWarningInstanceNotStartTask {
log.info("=========== 预警填报超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}

@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();

// 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则
List<WflowEarlyWarning> warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class)
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.OPERATION_WARNING.getCode()));
for(WflowEarlyWarning warning : warnings){
//2. 取出rule的数据
if(!warning.getIsOpen()){
log.info(warning.getId() + " 此规则关闭了");
continue;
}

String noticeMethod = warning.getNoticeMethod();
if(StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){
log.info("通知方式为空或者错误!");
return;
}

String noticeContent = warning.getNoticeContent();
String rule = warning.getRule();
if(StringUtils.isNotBlank(rule)){
JSONArray ruleArray = JSON.parseArray(rule);
if(CollUtil.isNotEmpty(ruleArray)){
ruleArray.forEach(r -> {
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r));
Integer time = rJson.getInteger("time");
Integer biz = rJson.getInteger("biz");
if(Objects.isNull(time) || Objects.isNull(biz)){
log.info("规则数据 错误 :{}",rJson);
return;
}

WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(biz);
if(Objects.isNull(operationTypeEnum)){
log.info("匹配不到 业务类型");
return;
}

//得出 对应待提交的项目状态
Integer projectStutas = operationTypeEnum.getProjectStutas();
String areaCode = warning.getAreaCode();
//测试先用分钟
//查询 所有这个区域的项目 未提交的项目
List<Project> needNextProjects = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getAreaCode, areaCode)
.eq(Project::getNewest, Boolean.TRUE)
.eq(Project::getStatus,projectStutas));

List<String> projectCodes = needNextProjects.stream().map(Project::getProjectCode).collect(Collectors.toList());

List<Operation> operations = operationService.list(Wrappers.lambdaQuery(Operation.class)
.in(Operation::getProjectCode, projectCodes));

Map<String,Operation> operationMap = operations.stream().collect(Collectors.toMap(Operation::getProjectCode,o -> o));
//需要发通知的项目
List<Project> needToWaringProjects = needNextProjects.stream()
.filter(p -> {
//判断 当状态在 建设中的时候 是不是要初验了
if(ProjectStatusEnum.UNDER_CONSTRUCTION.getCode().equals(projectStutas)){
List<Long> allVersionProjectId = projectService.getAllVersionProjectId(p);
//如果合同信息提交过了 才是 待初验状态
if(StringUtils.isNotBlank(p.getPreliminaryInspectionMaterials())){
if(0L == contractService.count(Wrappers.lambdaQuery(Contract.class)
.in(Contract::getProjectId, allVersionProjectId))){
return Boolean.FALSE;
}
}
}

//判断 实施信息中 初验和终验的时间
if(!operationMap.containsKey(p.getProjectCode())){
return Boolean.FALSE;
}
Operation operation = operationMap.get(p.getProjectCode());
if(WarningOperationTypeEnum.CHUYAN.getCode().equals(biz)){
//初验
if(Duration.between(LocalDateTime.now(),operation.getInitialInspectionDate()).toMinutes() >= time || //time * 60
Duration.between(LocalDateTime.now(),operation.getInitialInspectionDate()).toMinutes() <= time + 1){ //time * 60
return Boolean.TRUE;
}
}else if(WarningOperationTypeEnum.ZHONGYAN.getCode().equals(biz)){
//终验
if(Duration.between(LocalDateTime.now(),operation.getFinalInspectionDate()).toMinutes() >= time || //time * 60
Duration.between(LocalDateTime.now(),operation.getFinalInspectionDate()).toMinutes() <= time + 1){ //time * 60
return Boolean.TRUE;
}
}

return Boolean.FALSE;
})
.collect(Collectors.toList());

if(StringUtils.isBlank(noticeMethod) ||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) &&
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){
log.info("通知方式为空或者错误!");
return;
}

for(Project needToWaringProject : needToWaringProjects){
//去预警通知
String employeeCode = needToWaringProject.getSponsor();
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,biz,
needToWaringProject.getUpdateOn(),employeeCode,needToWaringProject,
WarningRuleTypeEnum.OPERATION_WARNING.getCode());
}
});
}
}
}

stopWatch.stop();
log.info("=========== 预警实施超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds());
}
}

+ 154
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java Näytä tiedosto

@@ -0,0 +1,154 @@
package com.ningdatech.pmapi.sys.manage;

import com.ningdatech.pmapi.common.enumeration.CommonEnum;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper;
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService;
import com.ningdatech.pmapi.sys.model.entity.Notify;
import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords;
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService;
import com.ningdatech.pmapi.sys.service.INotifyService;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.yxt.model.cmd.SendSmsCmd;
import com.wflow.enums.WarningRuleTypeEnum;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Objects;

/**
* @Classname EarlyWarningManage
* @Description
* @Date 2023/8/7 9:25
* @Author PoffyZhang
*/
@Component
@AllArgsConstructor
@Slf4j
public class EarlyWarningManage {

private final UserInfoHelper userInfoHelper;

private final NoticeManage noticeManage;

private final IEarlyWarningRecordsService earlyWarningRecordsService;

private final YxtCallOrSmsHelper yxtCallOrSmsHelper;

private final INdWorkNoticeStagingService workNoticeStagingService;

private final INotifyService notifyService;

/**
* 预警通知
* @param noticeMethod
* @param noticeContent
* @param timeout
* @param employeeCode
* @param project
*/
public void doEarlyWarning(String noticeMethod,String noticeContent, Integer timeout,Integer biz,
LocalDateTime startTime,String employeeCode, Project project,Integer ruleType) {
//1.存入 预警记录
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode);
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords();
String content = StringUtils.EMPTY;

switch (WarningRuleTypeEnum.checkByCode(ruleType)){
case PROCESS_WARNING:
convertContent(noticeContent,project.getProjectName(),
InstTypeEnum.getByCode(biz),timeout);
break;
case DECLARED_WARNING:
convertContent(noticeContent,project.getProjectName(),
WarningOperationTypeEnum.getByCode(biz),timeout);
break;
case OPERATION_WARNING:
convertContent(noticeContent,project.getProjectName(),
WarningFlowTypeEnum.getByCode(biz),timeout);
break;
default:
log.info("匹配不到 规则类型");
return;
}

records.setAreaCode(project.getAreaCode());
records.setBuildOrgCode(project.getBuildOrgCode());
records.setBuildOrgName(project.getBuildOrgName());
records.setCreateOn(LocalDateTime.now());
records.setWarningTime(LocalDateTime.now());
records.setInstStart(startTime);
records.setInstType(biz);
records.setNoticeMethod(noticeMethod);
records.setNoticeContent(content);
records.setProjectName(project.getProjectName());
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode());
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY);
records.setWarningEmployeecode(employeeCode);
earlyWarningRecordsService.save(records);

//2.消息提醒
Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content);
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name());
notifyService.save(notify);

//3.发短信
if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){
SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext();
context.setReceiveNumber(user.getMobile());
context.setContent(content);
yxtCallOrSmsHelper.sendSms(context);
}

//4.浙政钉
if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(employeeCode);
passWorkNoticeInfo.setMsg(content);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW);
}
}

/**
* 转换出 通知的内容
* @param noticeContent
* @param projectName
* @param instTypeEnum
* @param timeout
* @return
*/
private String convertContent(String noticeContent, String projectName, InstTypeEnum instTypeEnum, Integer timeout) {
noticeContent = noticeContent.replace("{projectName}",projectName)
.replace("{flowType}",Objects.nonNull(instTypeEnum) ? instTypeEnum.getDesc() : "{flowType}")
.replace("{time}",String.valueOf(timeout));
log.info("通知内容 :{}",noticeContent);
return noticeContent;
}

private String convertContent(String noticeContent, String projectName, WarningFlowTypeEnum warningFlowTypeEnum, Integer timeout) {
noticeContent = noticeContent.replace("{projectName}",projectName)
.replace("{flowType}",Objects.nonNull(warningFlowTypeEnum) ? warningFlowTypeEnum.getDesc() : "{flowType}")
.replace("{time}",String.valueOf(timeout));
log.info("通知内容 :{}",noticeContent);
return noticeContent;
}

private String convertContent(String noticeContent, String projectName, WarningOperationTypeEnum operationTypeEnum, Integer timeout) {
noticeContent = noticeContent.replace("{projectName}",projectName)
.replace("{flowType}",Objects.nonNull(operationTypeEnum) ? operationTypeEnum.getDesc() : "{flowType}")
.replace("{time}",String.valueOf(timeout));
log.info("通知内容 :{}",noticeContent);
return noticeContent;
}
}

+ 18
- 4
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java Näytä tiedosto

@@ -1,6 +1,8 @@
package com.ningdatech.pmapi.sys.model.vo;

import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum;
import com.ningdatech.pmapi.projectlib.enumeration.WarningOperationTypeEnum;
import com.wflow.enums.WarningRuleTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -107,10 +109,22 @@ public class WflowEarlyWarningRecordsVO implements Serializable {
private String updateBy;

public String getInstTypeName(){
if(Objects.nonNull(this.instType)){
InstTypeEnum instEnum = InstTypeEnum.getByCode(this.instType);
if(Objects.nonNull(instEnum)){
return instEnum.getDesc();
if(Objects.nonNull(this.instType) && Objects.nonNull(this.ruleType)){
if(this.ruleType.equals(WarningRuleTypeEnum.PROCESS_WARNING.getCode())){
InstTypeEnum instEnum = InstTypeEnum.getByCode(this.instType);
if(Objects.nonNull(instEnum)){
return instEnum.getDesc();
}
}else if(this.ruleType.equals(WarningRuleTypeEnum.DECLARED_WARNING.getCode())){
WarningFlowTypeEnum warningFlowTypeEnum = WarningFlowTypeEnum.getByCode(this.instType);
if(Objects.nonNull(warningFlowTypeEnum)){
return warningFlowTypeEnum.getDesc();
}
}else if(this.ruleType.equals(WarningRuleTypeEnum.OPERATION_WARNING.getCode())){
WarningOperationTypeEnum operationTypeEnum = WarningOperationTypeEnum.getByCode(this.instType);
if(Objects.nonNull(operationTypeEnum)){
return operationTypeEnum.getDesc();
}
}
}
return StringUtils.EMPTY;


Loading…
Peruuta
Tallenna