From 5c23197cb1c56ca90eb6de62aa3e424b521f95c5 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 21 Nov 2023 14:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0=20=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=20=E5=82=AC=E5=8A=9E=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enumeration/WarningFlowTypeEnum.java | 12 +++--- .../enumeration/WarningOperationTypeEnum.java | 6 ++- .../scheduler/listener/EarlyWarningListener.java | 10 ++++- .../task/EarlyWarningInstanceNotStartTask.java | 45 ++++++++++++---------- .../pmapi/sys/manage/EarlyWarningManage.java | 4 +- .../sys/model/entity/WflowEarlyWarningRecords.java | 5 +++ .../pmapi/sys/model/vo/ProjectEarlyWarningVO.java | 7 ++++ .../sys/model/vo/WflowEarlyWarningRecordsVO.java | 4 ++ .../pmapi/workbench/manage/WorkbenchManage.java | 14 ++++++- 9 files changed, 77 insertions(+), 30 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java index 891d926..f1e8cea 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningFlowTypeEnum.java @@ -20,11 +20,11 @@ public enum WarningFlowTypeEnum { /** * 预警填报类型枚举 */ - UNIT_INNER_AUDIT(1, "预审申报",ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()), - PRELIMINARY_PREVIEW(2, "建设方案申报",ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()), - DEPT_UNITED_REVIEW(3,"采购结果备案",ProjectStatusEnum.TO_BE_PURCHASED.getCode()), - CONSTRUCTION_PLAN_REVIEW(4,"初验备案",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()), - PROJECT_FINAL_INSPECTION(5,"验收申报",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); + UNIT_INNER_AUDIT(1, "预审申报",ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode(),"declareManage/preExaminationDeclare"), + PRELIMINARY_PREVIEW(2, "建设方案申报",ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode(),"declareManage/constructionPlanDeclare"), + DEPT_UNITED_REVIEW(3,"采购结果备案",ProjectStatusEnum.TO_BE_PURCHASED.getCode(),"declareManage/purchaseResults"), + CONSTRUCTION_PLAN_REVIEW(4,"初验备案",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),"declareManage/initialInspectionRecord"), + PROJECT_FINAL_INSPECTION(5,"验收申报",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode(),"declareManage/finalInspectionDeclare"); private Integer code; private String desc; @@ -32,6 +32,8 @@ public enum WarningFlowTypeEnum { //对应的 待提交时的项目状态 private Integer projectStutas; + private String path; + public static String getDescByCode(Integer code) { if (Objects.isNull(code)) { return StringUtils.EMPTY; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java index 3ca2276..37120c2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/WarningOperationTypeEnum.java @@ -20,8 +20,8 @@ public enum WarningOperationTypeEnum { /** * 预警实施类型枚举 */ - CHUYAN(1, "项目初验",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()), - ZHONGYAN(2, "项目终验",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); + CHUYAN(1, "项目初验",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),"declareManage/initialInspectionRecord"), + ZHONGYAN(2, "项目终验",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode(),"declareManage/finalInspectionDeclare"); private Integer code; private String desc; @@ -29,6 +29,8 @@ public enum WarningOperationTypeEnum { //对应的 待提交时的项目状态 private Integer projectStutas; + private String path; + public static String getDescByCode(Integer code) { if (Objects.isNull(code)) { return StringUtils.EMPTY; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java index 5834492..7838282 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java @@ -3,6 +3,7 @@ package com.ningdatech.pmapi.scheduler.listener; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; @@ -25,6 +26,7 @@ import org.springframework.stereotype.Component; import java.time.ZoneId; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 预警规则触发 @@ -112,11 +114,17 @@ public class EarlyWarningListener { return; } + //这一批员工要通知的员工号 + String batchEmployees = hais.stream().map(HistoricActivityInstance::getAssignee) + .collect(Collectors.joining(StrPool.COMMA)); for(HistoricActivityInstance hai : hais){ String employeeCode = hai.getAssignee(); + String taskId = hai.getTaskId(); + String path = "toDoCenter/handleDuringExamine?instanceId=" + + instanceId + "&projectId=1610&nodeId=" + nodeId + "&taskId=" + taskId; earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,timeout,pi.getInstType(), hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime() - ,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType); + ,employeeCode,project,WarningRuleTypeEnum.PROCESS_WARNING.getCode(),noticeType,path,batchEmployees); } } } \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java index 0e0b4c3..8de93b0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java @@ -8,6 +8,7 @@ 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.basic.util.StrPool; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; @@ -130,6 +131,7 @@ public class EarlyWarningInstanceNotStartTask { log.info("匹配不到 业务类型"); return; } + String path = flowTypeEnum.getPath(); //得出 对应待提交的项目状态 Integer projectStutas = flowTypeEnum.getProjectStutas(); @@ -185,11 +187,12 @@ public class EarlyWarningInstanceNotStartTask { } for(Project needToWaringProject : needToWaringProjects){ - String employeeCode = null; String username = null; String mobile = null; //去预警通知人 1.项目联系人 2.项目负责人 如果都包含 都要发 + List batchEmployees = Lists.newArrayList(); if(notice.contains(WarningNoticeTypeEnum.CONTACT.getCode().toString())){ + String employeeCode = null; username = needToWaringProject.getContactName(); mobile = needToWaringProject.getContactPhone(); if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ @@ -201,19 +204,12 @@ public class EarlyWarningInstanceNotStartTask { employeeCode = user.getEmployeeCode(); } if(Objects.nonNull(employeeCode)){ - if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ - List 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); - } - } - + batchEmployees.add(employeeCode); } } } if(notice.contains(WarningNoticeTypeEnum.RESPONSIBLE.getCode().toString())){ + String employeeCode = null; username = needToWaringProject.getResponsibleMan(); mobile = needToWaringProject.getResponsibleManMobile(); if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(mobile)){ @@ -225,15 +221,20 @@ public class EarlyWarningInstanceNotStartTask { employeeCode = user.getEmployeeCode(); } if(Objects.nonNull(employeeCode)){ - if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ - List 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); - } + batchEmployees.add(employeeCode); + } + } + } + if(CollUtil.isNotEmpty(batchEmployees)){ + String batchEmployeesStr = batchEmployees.stream().collect(Collectors.joining(StrPool.COMMA)); + if(noticeMap.containsKey(needToWaringProject.getProjectCode())){ + List noticeTypes = noticeMap.get(needToWaringProject.getProjectCode()); + for(Integer noticeType : noticeTypes) { + for (String employeeCode : batchEmployees) { + earlyWarningManage.doEarlyWarning(noticeMethod, Objects.nonNull(noticeType) && noticeType.equals(1) ? noticeContent : adventContent, time, biz, + needToWaringProject.getUpdateOn(),employeeCode, needToWaringProject, + WarningRuleTypeEnum.DECLARED_WARNING.getCode(), noticeType, path, batchEmployeesStr); } - } } } @@ -299,6 +300,7 @@ public class EarlyWarningInstanceNotStartTask { //得出 对应待提交的项目状态 Integer projectStutas = operationTypeEnum.getProjectStutas(); + String path = operationTypeEnum.getPath(); String areaCode = warning.getAreaCode(); //测试先用分钟 //查询 所有这个区域的项目 未提交的项目 @@ -383,7 +385,7 @@ public class EarlyWarningInstanceNotStartTask { 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); + WarningRuleTypeEnum.OPERATION_WARNING.getCode(),noticeType,path,employeeCode); } } @@ -486,16 +488,19 @@ public class EarlyWarningInstanceNotStartTask { } for(ProjectRenewalFundDeclaration needToWaringProject : needToWaringProjects){ + String path = "projectStoreManage/renewalProjectAsscess?projectRenewalId=" + needToWaringProject.getId(); Project project = projectService.getProjectByCode(needToWaringProject.getProjectCode()); //去预警通知 发给区管 List users = roleManage.getUsersByRoleType(RoleEnum.REGION_MANAGER.name(),needToWaringProject.getRegionCode()); + String employeesStr = users.stream().map(UserInfo::getEmployeeCode) + .collect(Collectors.joining(StrPool.COMMA)); for(UserInfo user : users){ if(noticeTypeMap.containsKey(needToWaringProject.getProjectCode())){ List 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); + WarningRuleTypeEnum.RENEWAL_FUND.getCode(),noticeType,path,employeesStr); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java index a54b24a..5aacfd6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java @@ -57,7 +57,7 @@ public class EarlyWarningManage { */ public void doEarlyWarning(String noticeMethod,String noticeContent, Integer timeout,Integer biz, LocalDateTime startTime,String employeeCode, - Project project,Integer ruleType,Integer noticeType) { + Project project,Integer ruleType,Integer noticeType,String path,String batchEmployees) { //1.存入 预警记录 UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); @@ -104,6 +104,8 @@ public class EarlyWarningManage { records.setProjectCode(project.getProjectCode()); records.setProjectStatus(project.getStatus()); records.setNoticeType(noticeType); + records.setPath(path); + records.setBatchEmployees(batchEmployees); earlyWarningRecordsService.save(records); //2.消息提醒 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java index 9a00c44..bf30e02 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/WflowEarlyWarningRecords.java @@ -110,6 +110,11 @@ public class WflowEarlyWarningRecords implements Serializable { @ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督 4.续建资金项目") private Integer ruleType; + @ApiModelProperty(value = "路径") + private String path; + + @ApiModelProperty(value = "这一批要通知的员工号") + private String batchEmployees; private LocalDateTime createOn; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java index 053eb8d..1300f44 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/ProjectEarlyWarningVO.java @@ -62,6 +62,8 @@ public class ProjectEarlyWarningVO implements Serializable { /** * 最新的一条预警记录 */ + @ApiModelProperty(value = "预警ID") + private Long recordId; @ApiModelProperty(value = "预警员工号") private String warningEmployeecode; @ApiModelProperty(value = "通知方式 0浙政钉 1短信 逗号分隔") @@ -72,6 +74,11 @@ public class ProjectEarlyWarningVO implements Serializable { private LocalDateTime instStart; @ApiModelProperty(value = "预警时间") private LocalDateTime warningTime; + @ApiModelProperty(value = "路径") + private String path; + @ApiModelProperty(value = "这一批要通知的员工号") + private String batchEmployees; + private LocalDateTime createOn; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java index d30f631..33bc130 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/WflowEarlyWarningRecordsVO.java @@ -109,6 +109,10 @@ public class WflowEarlyWarningRecordsVO implements Serializable { @ApiModelProperty(value = "规则类型 1.流程预警规则 2.填报预警规则 3.实施监督4.续建") private Integer ruleType; + @ApiModelProperty(value = "路径") + private String path; + @ApiModelProperty(value = "这一批要通知的员工号") + private String batchEmployees; private LocalDateTime createOn; private String createBy; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java index 68821f9..b948244 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.Sets; import com.ningdatech.basic.model.PageVo; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; @@ -31,6 +32,7 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; @@ -149,9 +151,10 @@ public class WorkbenchManage { projectEarlyWarning.setCurrent(cuurent); List warningRecords = earlyWarningRecordsService.list(Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) - .groupBy(WflowEarlyWarningRecords::getProjectCode) .orderByDesc(WflowEarlyWarningRecords::getWarningTime)); + Set projectCodeSet = Sets.newHashSet(); Map warningMap = warningRecords.stream() + .filter(w -> projectCodeSet.add(w.getProjectCode())) .collect(Collectors.toMap(WflowEarlyWarningRecords::getProjectCode, w -> w)); if(CollUtil.isNotEmpty(overPage.getRecords())){ @@ -165,6 +168,9 @@ public class WorkbenchManage { vo.setWarningEmployeecode(record.getWarningEmployeecode()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); + vo.setPath(record.getPath()); + vo.setBatchEmployees(record.getBatchEmployees()); + vo.setRecordId(record.getId()); } return vo; }).collect(Collectors.toList()); @@ -184,6 +190,9 @@ public class WorkbenchManage { vo.setWarningEmployeecode(record.getWarningEmployeecode()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); + vo.setPath(record.getPath()); + vo.setBatchEmployees(record.getBatchEmployees()); + vo.setRecordId(record.getId()); } return vo; }).collect(Collectors.toList()); @@ -203,6 +212,9 @@ public class WorkbenchManage { vo.setWarningEmployeecode(record.getWarningEmployeecode()); vo.setNoticeMethod(record.getNoticeMethod()); vo.setNoticeContent(record.getNoticeContent()); + vo.setPath(record.getPath()); + vo.setBatchEmployees(record.getBatchEmployees()); + vo.setRecordId(record.getId()); } return vo; }).collect(Collectors.toList());