@@ -28,6 +28,9 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
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.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
@@ -80,6 +83,8 @@ public class ConstructionPlanManage { | |||
private final DefaultDeclaredProjectManage declaredProjectManage; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 建设方案 | |||
* | |||
@@ -133,6 +138,10 @@ public class ConstructionPlanManage { | |||
//保存建设项目 | |||
modifyProject(projectInfo, instanceId, projectInfo.getConstructionPlanFile()); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -11,7 +11,6 @@ import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.ningdatech.pmapi.common.constant.CommonConst; | |||
import com.ningdatech.pmapi.common.constant.RegionConst; | |||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | |||
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; | |||
@@ -19,44 +18,34 @@ import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.common.util.ExcelExportStyle; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.*; | |||
import com.ningdatech.pmapi.projectdeclared.model.entity.ProjectDraft; | |||
import com.ningdatech.pmapi.projectdeclared.model.vo.ProjectDraftVO; | |||
import com.ningdatech.pmapi.projectdeclared.service.IProjectDraftService; | |||
import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalExportDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
import com.ningdatech.pmapi.projectlib.model.po.ProjectRenewalFundDeclarationPO; | |||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | |||
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.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.bean.entity.WflowOrgModels; | |||
import com.wflow.enums.OrgTypeEnum; | |||
import com.wflow.enums.ProcessDefTypeEnum; | |||
import com.wflow.exception.BusinessException; | |||
import com.wflow.service.OrgProcdefService; | |||
import com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
import com.wflow.workflow.bean.vo.ProcessStartParamsVo; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.AllArgsConstructor; | |||
import lombok.NoArgsConstructor; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -96,7 +85,7 @@ public class DeclaredProjectManage { | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final ProjectLibManage projectlibManager; | |||
private final NoticeManage noticeManage; | |||
private final UserInfoHelper userInfoHelper; | |||
@@ -179,6 +168,10 @@ public class DeclaredProjectManage { | |||
projectDraftService.removeById(projectInfo.getDraftId()); | |||
} | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(project,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -243,6 +236,10 @@ public class DeclaredProjectManage { | |||
//保存项目 | |||
saveOrUpdateProject(projectDto,instanceId,employeeCode); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(project,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -1,9 +1,6 @@ | |||
package com.ningdatech.pmapi.projectdeclared.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
@@ -17,16 +14,12 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | |||
import com.ningdatech.pmapi.common.util.ExcelExportStyle; | |||
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; | |||
import com.ningdatech.pmapi.datascope.utils.DataScopeUtil; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.PretrialDeclaredExportDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; | |||
import com.ningdatech.pmapi.projectdeclared.model.req.PrequalificationDeclaredListReq; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||
import com.ningdatech.pmapi.projectlib.helper.ProjectHelper; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
@@ -34,8 +27,11 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; | |||
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.IProjectStagingService; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.bean.entity.WflowModels; | |||
@@ -83,6 +79,8 @@ public class PrequalificationDeclaredProjectManage { | |||
private final IProjectInstService projectInstService; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 提交预审 | |||
* @param dto | |||
@@ -196,6 +194,10 @@ public class PrequalificationDeclaredProjectManage { | |||
//保存预审项目 | |||
preModifyProject(projectInfo, instanceId); | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
} | |||
@@ -1,17 +1,17 @@ | |||
package com.ningdatech.pmapi.projectdeclared.manage; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.TypeReference; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Maps; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
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.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.exception.BusinessException; | |||
import com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
@@ -20,10 +20,8 @@ import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessModelService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.Collections; | |||
import java.util.Map; | |||
@@ -50,6 +48,8 @@ public class ReviewByDeptJointManage { | |||
private final DefaultDeclaredProjectManage declaredProjectManage; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final NoticeManage noticeManage; | |||
/** | |||
* 部门联审 | |||
* @param project | |||
@@ -103,6 +103,10 @@ public class ReviewByDeptJointManage { | |||
return Boolean.FALSE; | |||
} | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(projectInfo,model.getFormName(),instanceId, | |||
WorkNoticeContant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return Boolean.TRUE; | |||
} | |||
@@ -4,14 +4,9 @@ import java.net.InetAddress; | |||
import java.net.UnknownHostException; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.function.Function; | |||
import com.ningdatech.basic.model.GenericResult; | |||
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.staging.utils.WorkNoticeFlowMapUtil; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.zwdd.client.ZwddClient; | |||
import org.springframework.beans.BeanUtils; | |||
@@ -20,13 +15,8 @@ import org.springframework.stereotype.Component; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.scheduler.contants.TaskContant; | |||
import com.ningdatech.pmapi.staging.contants.StagingContant; | |||
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -6,7 +6,7 @@ import com.ningdatech.pmapi.staging.contants.StagingContant; | |||
import com.ningdatech.pmapi.staging.mapper.ProjectStagingMapper; | |||
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil; | |||
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowUtil; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
@@ -28,7 +28,7 @@ public class ProjectStagingServiceImpl extends ServiceImpl<ProjectStagingMapper, | |||
private final ProjectStagingMapper mapper; | |||
private final ProjectStatusFlowMapUtil projectStatusFlowMapUtil; | |||
private final ProjectStatusFlowUtil projectStatusFlowUtil; | |||
/** | |||
* 在某些状态节点 增加一个项目到状态暂存库 | |||
@@ -61,11 +61,11 @@ public class ProjectStagingServiceImpl extends ServiceImpl<ProjectStagingMapper, | |||
@Override | |||
public Boolean addRetryTimes(ProjectStaging projectStaging) { | |||
Integer retryTimes = projectStaging.getRetryTimes() + 1; | |||
if(!projectStatusFlowMapUtil.intervalTimeMap.containsKey(retryTimes)){ | |||
if(!projectStatusFlowUtil.intervalTimeMap.containsKey(retryTimes)){ | |||
log.info("没有对应重试间隔时间 添加重试信息失败"); | |||
return Boolean.FALSE; | |||
} | |||
Integer addSeconds = projectStatusFlowMapUtil.intervalTimeMap.get(retryTimes); | |||
Integer addSeconds = projectStatusFlowUtil.intervalTimeMap.get(retryTimes); | |||
Boolean dead = Boolean.FALSE; | |||
//超过重试最大次数 dead置为 true | |||
if(retryTimes.compareTo(StagingContant.Retry.MAX_RETRY_TIMES) > 0){ | |||
@@ -29,10 +29,6 @@ public class ProjectStatusFlowMapUtil { | |||
private ReviewByDeptJointManage reviewByDeptJointManage; | |||
public Map<Integer, Function<Project,Boolean>> statusFlowFunctionMap = Maps.newHashMap(); | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
*/ | |||
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap(); | |||
/** | |||
* 初始化业务分派逻辑,代替了if-else部分 | |||
@@ -47,22 +43,4 @@ public class ProjectStatusFlowMapUtil { | |||
statusFlowFunctionMap.put(ProjectStatusEnum.DEPARTMENT_JOINT_REVIEW.getCode(), | |||
project->reviewByDeptJointManage.startTheProcess(project)); | |||
} | |||
/** | |||
* 扫描的间隔越来越长 秒数 | |||
*/ | |||
@PostConstruct | |||
public void intervalTimeMapInit(){ | |||
intervalTimeMap.put(1,60 * 2); | |||
intervalTimeMap.put(2,60 * 6); | |||
intervalTimeMap.put(3,60 * 15); | |||
intervalTimeMap.put(4,60 * 30); | |||
intervalTimeMap.put(5,60 * 60); | |||
intervalTimeMap.put(6,60 * 60 * 2); | |||
intervalTimeMap.put(7,60 * 60 * 5); | |||
intervalTimeMap.put(8,60 * 60 * 12); | |||
intervalTimeMap.put(9,60 * 60 * 24); | |||
intervalTimeMap.put(10,60 * 60 * 72); | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
package com.ningdatech.pmapi.staging.utils; | |||
import com.google.common.collect.Maps; | |||
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByDeptJointManage; | |||
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import javax.annotation.PostConstruct; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
/** | |||
* @Classname ProjectStatusFlowMapUtil | |||
* @Description 状态流转 事件函数MAP | |||
* @Date 2023/2/15 11:19 | |||
* @Author PoffyZhang | |||
*/ | |||
@Component | |||
public class ProjectStatusFlowUtil { | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
*/ | |||
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap(); | |||
/** | |||
* 初始化业务分派逻辑,代替了if-else部分 | |||
* key: 枚举 状态值 | |||
* value: lambda表达式,最终会获取发起实例的函数 | |||
*/ | |||
public ProjectStatusFlowUtil(){ | |||
intervalTimeMap.put(1,60 * 2); | |||
intervalTimeMap.put(2,60 * 6); | |||
intervalTimeMap.put(3,60 * 15); | |||
intervalTimeMap.put(4,60 * 30); | |||
intervalTimeMap.put(5,60 * 60); | |||
intervalTimeMap.put(6,60 * 60 * 2); | |||
intervalTimeMap.put(7,60 * 60 * 5); | |||
intervalTimeMap.put(8,60 * 60 * 12); | |||
intervalTimeMap.put(9,60 * 60 * 24); | |||
intervalTimeMap.put(10,60 * 60 * 72); | |||
} | |||
} |
@@ -2,6 +2,8 @@ package com.ningdatech.pmapi.staging.utils; | |||
import java.util.Map; | |||
import javax.annotation.PostConstruct; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
import com.google.common.collect.Maps; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -13,7 +15,7 @@ import lombok.RequiredArgsConstructor; | |||
* @since 2023/02/28 17:03 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
@AllArgsConstructor | |||
public class WorkNoticeFlowMapUtil { | |||
/** | |||
* key 重试的次数 , value 是增加是描述 | |||
@@ -23,8 +25,7 @@ public class WorkNoticeFlowMapUtil { | |||
/** | |||
* 扫描的间隔越来越长 秒数 | |||
*/ | |||
@PostConstruct | |||
public void intervalTimeMapInit(){ | |||
public WorkNoticeFlowMapUtil(){ | |||
intervalTimeMap.put(1,60 * 2); | |||
intervalTimeMap.put(2,60 * 6); | |||
intervalTimeMap.put(3,60 * 15); | |||
@@ -2,32 +2,56 @@ package com.ningdatech.pmapi.sys.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
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.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.model.IdVo; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.file.entity.vo.result.AttachFileVo; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.util.BizUtils; | |||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
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.enumeration.NoticeTypeEnum; | |||
import com.ningdatech.pmapi.sys.model.entity.Notice; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeListReq; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeSaveReq; | |||
import com.ningdatech.pmapi.sys.model.req.NoticeStatusModifyReq; | |||
import com.ningdatech.pmapi.sys.model.vo.NoticeDetailVO; | |||
import com.ningdatech.pmapi.sys.model.vo.NoticeListItemVO; | |||
import com.ningdatech.pmapi.sys.service.INoticeService; | |||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.flowable.engine.RuntimeService; | |||
import org.flowable.engine.runtime.ActivityInstance; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
import static com.ningdatech.pmapi.todocenter.constant.WorkNoticeContant.AUDIT_WORK_TITLE; | |||
/** | |||
* <p> | |||
* MsgManage | |||
@@ -38,11 +62,26 @@ import java.util.stream.Collectors; | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
@Slf4j | |||
public class NoticeManage { | |||
private final INoticeService noticeService; | |||
private final FileService fileService; | |||
private final IUserInfoService userInfoService; | |||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final INotifyService notifyService; | |||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||
private final RuntimeService runtimeService; | |||
private final UserInfoHelper userInfoHelper; | |||
@Transactional(rollbackFor = Exception.class) | |||
public IdVo<Long> saveOrModify(NoticeSaveReq req) { | |||
Notice notice = BeanUtil.copyProperties(req, Notice.class); | |||
@@ -128,4 +167,117 @@ public class NoticeManage { | |||
noticeService.removeById(id); | |||
} | |||
/** | |||
* 发送消息 | |||
* @param employeeCode 员工号 | |||
* @param userId 用户ID | |||
* @param project 项目 | |||
* @param procDefinitionName 流程定义名 | |||
* @param template 消息模板内容 | |||
* @param msgTypeEnum 枚举 | |||
*/ | |||
public void sendNotice(String employeeCode, Long userId, Project project, String procDefinitionName, | |||
String template, MsgTypeEnum msgTypeEnum){ | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo passWorkNoticeInfo = getSendWorkNoticeInfo(employeeCode); | |||
String passMsg = String.format(template, project.getProjectName(), procDefinitionName); | |||
passWorkNoticeInfo.setMsg(passMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, project, passMsg); | |||
notify.setType(msgTypeEnum.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, msgTypeEnum); | |||
} | |||
/** | |||
* 获取发送浙政钉工作通知的信息 | |||
* | |||
* @param currentEmployeeCode | |||
* @return com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo | |||
* @author CMM | |||
* @since 2023/02/15 14:04 | |||
*/ | |||
public WorkNoticeInfo getSendWorkNoticeInfo(String currentEmployeeCode) { | |||
UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode,currentEmployeeCode).last("limit 1")); | |||
if (Objects.isNull(auditUserInfo)) { | |||
throw new BizException("该用户不存在!"); | |||
} | |||
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo(); | |||
Long accountId = auditUserInfo.getAccountId(); | |||
if (Objects.isNull(accountId)) { | |||
throw new BizException("该用户没有录入浙政钉信息!"); | |||
} | |||
workNoticeInfo.setAccountId(accountId); | |||
// 根据浙政钉用户ID获取部门code | |||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||
.eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) | |||
.last("limit 1")); | |||
String organizationCode = employeeInfo.getOrganizationCode(); | |||
workNoticeInfo.setOrganizationCode(organizationCode); | |||
// 根据部门code获取部门名称 | |||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationCode, organizationCode)); | |||
String organizationName = dingOrganization.getOrganizationName(); | |||
workNoticeInfo.setOrganizationName(organizationName); | |||
// 构建唯一的消息ID | |||
String bizMsgId = "ZD_WORK_NOTICE_" + StrUtil.UNDERLINE + organizationCode + StrUtil.UNDERLINE | |||
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis(); | |||
workNoticeInfo.setBizMsgId(bizMsgId); | |||
String receiverUserId = String.valueOf(accountId); | |||
workNoticeInfo.setReceiverUserId(receiverUserId); | |||
return workNoticeInfo; | |||
} | |||
/** | |||
* 装配项目审核工作通知 | |||
* @param userId | |||
* @param project | |||
* @param msg | |||
*/ | |||
private Notify assemblyAuditNotify(Long userId, Project project, String msg) { | |||
Notify notify = new Notify(); | |||
notify.setTitle(AUDIT_WORK_TITLE); | |||
notify.setUserId(userId); | |||
notify.setContent(msg); | |||
notify.setReaded(Boolean.FALSE); | |||
notify.setCreateTime(LocalDateTime.now()); | |||
ProjectAuditMsgExtraDTO msgExtraDto = new ProjectAuditMsgExtraDTO(); | |||
msgExtraDto.setProjectId(project.getId()); | |||
msgExtraDto.setInstanceId(project.getInstCode()); | |||
String extraJson = JSON.toJSONString(msgExtraDto); | |||
notify.setExtraInfo(extraJson); | |||
return notify; | |||
} | |||
/** | |||
* 找寻第一个审核人 去发消息 | |||
* @param project | |||
* @param formName | |||
* @param template | |||
* @param msgTypeEnum | |||
*/ | |||
public void sendFirtUser(Project project, String formName,String instanceId, String template, MsgTypeEnum msgTypeEnum) { | |||
try { | |||
List<ActivityInstance> activityInstances = runtimeService.createActivityInstanceQuery() | |||
.processInstanceId(instanceId) | |||
.activityType("userTask") | |||
.orderByActivityInstanceStartTime() | |||
.asc() | |||
.list(); | |||
for (ActivityInstance activityInstance : activityInstances) { | |||
if(StringUtils.isNotBlank(activityInstance.getAssignee())){ | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(activityInstance.getAssignee()); | |||
sendNotice(activityInstance.getAssignee(), user.getUserId(), project, formName, | |||
template, msgTypeEnum); | |||
} | |||
} | |||
}catch (Exception e){ | |||
log.error("发送消息失败 :" + e); | |||
} | |||
} | |||
} |
@@ -1,22 +1,13 @@ | |||
package com.ningdatech.pmapi.todocenter.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage; | |||
import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; | |||
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectDraftSaveDTO; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; | |||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
@@ -25,29 +16,18 @@ import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.signature.service.ICompanySignatureService; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.staging.service.IProjectStagingService; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
import com.ningdatech.pmapi.sys.service.INotifyService; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant; | |||
import com.ningdatech.pmapi.todocenter.model.dto.ProjectAuditMsgExtraDTO; | |||
import com.ningdatech.pmapi.todocenter.service.StatisticsService; | |||
import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; | |||
import com.ningdatech.pmapi.todocenter.utils.PdfUtils; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import com.wflow.contants.HisProInsEndActId; | |||
import com.wflow.contants.WflowContant; | |||
import com.wflow.workflow.bean.process.ProgressNode; | |||
import com.wflow.workflow.bean.process.enums.NodeTypeEnum; | |||
import com.wflow.workflow.bean.vo.ProcessProgressVo; | |||
import com.wflow.workflow.enums.ProcessHandlerEnum; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import com.wflow.workflow.service.ProcessTaskService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -85,14 +65,11 @@ public class HandlerManage { | |||
private final IUserInfoService userInfoService; | |||
private final IProjectService projectService; | |||
private final StateMachineUtils stateMachineUtils; | |||
private final IDingEmployeeInfoService dingEmployeeInfoService; | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final ProcessInstanceService processInstanceService; | |||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||
private final IProjectApplicationService projectApplicationService; | |||
private final IProjectStagingService projectStagingService; | |||
private final IProjectInstService projectInstService; | |||
private final INotifyService notifyService; | |||
private final NoticeManage noticeManage; | |||
private final DeclaredProjectManage declaredProjectManage; | |||
/** | |||
@@ -147,16 +124,9 @@ public class HandlerManage { | |||
default: | |||
throw new IllegalStateException("Unexpected value: " + declaredProject.getStatus()); | |||
} | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo passWorkNoticeInfo2 = getSendWorkNoticeInfo(currentEmployeeCode); | |||
String passMsg2 = String.format(PASS_MSG_TEMPLATE2, declaredProject.getProjectName(), instance.getProcessDefinitionName()); | |||
passWorkNoticeInfo2.setMsg(passMsg2); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, passMsg2); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_PASS.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PROJECT_REVIEW_PASS); | |||
//发送消息 | |||
noticeManage.sendNotice(currentEmployeeCode,userId,declaredProject,instance.getProcessDefinitionName(), | |||
PASS_MSG_TEMPLATE2,MsgTypeEnum.PROJECT_REVIEW_PASS); | |||
} else { | |||
// 若有下一个审核人(当前节点的用户), | |||
// 向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。 | |||
@@ -164,18 +134,13 @@ public class HandlerManage { | |||
if (Objects.isNull(currentEmployeeCode)) { | |||
throw new BizException("审核人信息不存在!"); | |||
} | |||
WorkNoticeInfo sendWorkNoticeInfo = getSendWorkNoticeInfo(currentEmployeeCode); | |||
String msg = String.format(PASS_MSG_TEMPLATE, sendWorkNoticeInfo.getOrganizationName(), declaredProject.getProjectName()); | |||
sendWorkNoticeInfo.setMsg(msg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, msg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(sendWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); | |||
//发送消息 | |||
noticeManage.sendNotice(currentEmployeeCode,userId,declaredProject,instance.getProcessDefinitionName(), | |||
PASS_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW); | |||
} | |||
} | |||
/** | |||
* 驳回后 所处理的逻辑 | |||
* @param declaredProject | |||
@@ -185,17 +150,9 @@ public class HandlerManage { | |||
Long userId = LoginUserUtil.getUserId(); | |||
// 更新项目状态和流程状态 | |||
updateRejectProjectStatus(userId, declaredProject); | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo rejectWorkNoticeInfo = getSendWorkNoticeInfo(instance.getStartUserId()); | |||
String rejectMsg = String.format(REJECT_MSG_TEMPLATE, declaredProject.getProjectName(), | |||
instance.getProcessDefinitionName()); | |||
rejectWorkNoticeInfo.setMsg(rejectMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, rejectMsg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_REJECT.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(rejectWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW_REJECT); | |||
//发送消息 | |||
noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), | |||
REJECT_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW_REJECT); | |||
} | |||
/** | |||
@@ -269,17 +226,9 @@ public class HandlerManage { | |||
public void afterBackTodo(Project declaredProject, HistoricProcessInstance instance) { | |||
Long userId = LoginUserUtil.getUserId(); | |||
// 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被退回,请及时处理。 | |||
// 获取发送浙政钉工作通知必要信息 | |||
WorkNoticeInfo backWorkNoticeInfo = getSendWorkNoticeInfo(instance.getStartUserId()); | |||
String backMsg = String.format(BACK_MSG_TEMPLATE, declaredProject.getProjectName(), | |||
instance.getProcessDefinitionName()); | |||
backWorkNoticeInfo.setMsg(backMsg); | |||
// 放入系统通知表中,保存记录 | |||
Notify notify = assemblyAuditNotify(userId, declaredProject, backMsg); | |||
notify.setType(MsgTypeEnum.PROJECT_REVIEW_BACK.name()); | |||
notifyService.save(notify); | |||
// 放入工作通知暂存表中,通过扫表异步发送 | |||
workNoticeStagingService.addByWorkNotice(backWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW_BACK); | |||
//发送消息 | |||
noticeManage.sendNotice(instance.getStartUserId(),userId,declaredProject,instance.getProcessDefinitionName(), | |||
BACK_MSG_TEMPLATE,MsgTypeEnum.PROJECT_REVIEW_BACK); | |||
} | |||
@@ -345,67 +294,6 @@ public class HandlerManage { | |||
projectService.updateById(declaredProject); | |||
} | |||
/** | |||
* 装配项目审核工作通知 | |||
* @param userId | |||
* @param project | |||
* @param msg | |||
*/ | |||
private Notify assemblyAuditNotify(Long userId, Project project, String msg) { | |||
Notify notify = new Notify(); | |||
notify.setTitle(AUDIT_WORK_TITLE); | |||
notify.setUserId(userId); | |||
notify.setContent(msg); | |||
notify.setReaded(Boolean.FALSE); | |||
notify.setCreateTime(LocalDateTime.now()); | |||
ProjectAuditMsgExtraDTO msgExtraDto = new ProjectAuditMsgExtraDTO(); | |||
msgExtraDto.setProjectId(project.getId()); | |||
msgExtraDto.setInstanceId(project.getInstCode()); | |||
String extraJson = JSON.toJSONString(msgExtraDto); | |||
notify.setExtraInfo(extraJson); | |||
return notify; | |||
} | |||
/** | |||
* 获取发送浙政钉工作通知的信息 | |||
* | |||
* @param currentEmployeeCode | |||
* @return com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo | |||
* @author CMM | |||
* @since 2023/02/15 14:04 | |||
*/ | |||
public WorkNoticeInfo getSendWorkNoticeInfo(String currentEmployeeCode) { | |||
UserInfo auditUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getEmployeeCode,currentEmployeeCode).last("limit 1")); | |||
if (Objects.isNull(auditUserInfo)) { | |||
throw new BizException("该用户不存在!"); | |||
} | |||
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo(); | |||
Long accountId = auditUserInfo.getAccountId(); | |||
if (Objects.isNull(accountId)) { | |||
throw new BizException("该用户没有录入浙政钉信息!"); | |||
} | |||
workNoticeInfo.setAccountId(accountId); | |||
// 根据浙政钉用户ID获取部门code | |||
DingEmployeeInfo employeeInfo = dingEmployeeInfoService.getOne(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.eq(DingEmployeeInfo::getAccountId, accountId) | |||
.eq(DingEmployeeInfo::getMainJob,String.valueOf(Boolean.TRUE)) | |||
.last("limit 1")); | |||
String organizationCode = employeeInfo.getOrganizationCode(); | |||
workNoticeInfo.setOrganizationCode(organizationCode); | |||
// 根据部门code获取部门名称 | |||
DingOrganization dingOrganization = dingOrganizationService.getOne(Wrappers.lambdaQuery(DingOrganization.class) | |||
.eq(DingOrganization::getOrganizationCode, organizationCode)); | |||
String organizationName = dingOrganization.getOrganizationName(); | |||
workNoticeInfo.setOrganizationName(organizationName); | |||
// 构建唯一的消息ID | |||
String bizMsgId = "ZD_WORK_NOTICE_" + StrUtil.UNDERLINE + organizationCode + StrUtil.UNDERLINE | |||
+ organizationName + accountId + StrUtil.UNDERLINE + System.currentTimeMillis(); | |||
workNoticeInfo.setBizMsgId(bizMsgId); | |||
String receiverUserId = String.valueOf(accountId); | |||
workNoticeInfo.setReceiverUserId(receiverUserId); | |||
return workNoticeInfo; | |||
} | |||
public void deleteBackComments(List<HistoricVariableInstance> approves) { | |||
if(CollUtil.isNotEmpty(approves)){ | |||
for(HistoricVariableInstance approve : approves){ | |||
@@ -13,6 +13,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.sys.manage.NoticeManage; | |||
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.todocenter.manage.HandlerManage; | |||
import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage; | |||
@@ -72,7 +73,7 @@ public class TodoCenterTest extends AppTests { | |||
private HistoryService historyService; | |||
@Autowired | |||
private HandlerManage handlerManage; | |||
private NoticeManage handlerManage; | |||
@Test | |||
public void sendWorkNoticeTest() throws ExecutionException, InterruptedException { | |||