From 955b31aa83e1c2ba955039288aada8d174090626 Mon Sep 17 00:00:00 2001 From: pengqiang <1067496116@qq.com> Date: Tue, 27 Dec 2022 14:18:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E5=AE=9A=E9=83=A8=E9=97=A8=E9=A2=86?= =?UTF-8?q?=E5=AF=BC=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ypeEnum.java => ActCandidateTypeEnum.java} | 11 +++++---- .../work/config/activiti/ActConstant.java | 5 ++++ .../work/service/ActListenerService.java | 4 +++- .../work/service/ActTaskDefService.java | 24 +++++++++++++++++-- .../work/service/ProjectProcessService.java | 5 ++-- .../templates/admin/act_task_def.ftl | 3 ++- 6 files changed, 42 insertions(+), 10 deletions(-) rename src/main/java/cn/palmte/work/config/activiti/{CandidateTypeEnum.java => ActCandidateTypeEnum.java} (72%) diff --git a/src/main/java/cn/palmte/work/config/activiti/CandidateTypeEnum.java b/src/main/java/cn/palmte/work/config/activiti/ActCandidateTypeEnum.java similarity index 72% rename from src/main/java/cn/palmte/work/config/activiti/CandidateTypeEnum.java rename to src/main/java/cn/palmte/work/config/activiti/ActCandidateTypeEnum.java index 11cffbe..53be5e7 100644 --- a/src/main/java/cn/palmte/work/config/activiti/CandidateTypeEnum.java +++ b/src/main/java/cn/palmte/work/config/activiti/ActCandidateTypeEnum.java @@ -8,27 +8,30 @@ import lombok.Getter; * 审批人设置枚举 */ @Getter -public enum CandidateTypeEnum { +public enum ActCandidateTypeEnum { USER(0, "按用户设置审批人"), ROLE(1, "按角色设置审批人"), - STARTER_LEADER(2, "按发起人部门领导设置审批人"); + STARTER_LEADER(2, "按发起人部门领导设置审批人"), + DEPT_LEADER(3, "按指定的部门领导设置审批人"); private int type; private String name; - CandidateTypeEnum(int type, String name) { + ActCandidateTypeEnum(int type, String name) { this.type = type; this.name = name; } - public static CandidateTypeEnum ofType(int type) { + public static ActCandidateTypeEnum ofType(int type) { if (type == USER.getType()) { return USER; } else if (type == ROLE.getType()) { return ROLE; } else if (type == STARTER_LEADER.getType()) { return STARTER_LEADER; + } else if (type == DEPT_LEADER.getType()) { + return DEPT_LEADER; } else { throw new ResponseException("不支持的类型【" + type + "】"); } diff --git a/src/main/java/cn/palmte/work/config/activiti/ActConstant.java b/src/main/java/cn/palmte/work/config/activiti/ActConstant.java index 5d1e040..f458f65 100644 --- a/src/main/java/cn/palmte/work/config/activiti/ActConstant.java +++ b/src/main/java/cn/palmte/work/config/activiti/ActConstant.java @@ -7,6 +7,11 @@ public class ActConstant { */ public static final String START_PROCESS_USERID = "startUserId"; + /** + * 部门领导id + */ + public static final String DEPT_LEADER_ID = "deptLeaderId"; + /** * 单实例 或签 */ diff --git a/src/main/java/cn/palmte/work/service/ActListenerService.java b/src/main/java/cn/palmte/work/service/ActListenerService.java index bdbd5cc..633c151 100644 --- a/src/main/java/cn/palmte/work/service/ActListenerService.java +++ b/src/main/java/cn/palmte/work/service/ActListenerService.java @@ -116,7 +116,9 @@ public class ActListenerService { processInstance.getProcessInstanceId(), businessKey, adminId); projectInstanceService.updateApprover(Integer.parseInt(businessKey), adminId); } else if (actUtil.isNewProcess(procDefId)) { - projectProcessService.updateAudit(Integer.parseInt(businessKey), null, enableUsers); + if (!enableUsers.isEmpty()) { + projectProcessService.updateAudit(Integer.parseInt(businessKey), null, enableUsers); + } logger.info("**** rwcjjt 任务创建监听 更新审批2 procInsId:{}, projectId:{}, enableUsers:{} **** ", processInstance.getProcessInstanceId(), businessKey, enableUsers); } diff --git a/src/main/java/cn/palmte/work/service/ActTaskDefService.java b/src/main/java/cn/palmte/work/service/ActTaskDefService.java index 0df63e0..07a45eb 100644 --- a/src/main/java/cn/palmte/work/service/ActTaskDefService.java +++ b/src/main/java/cn/palmte/work/service/ActTaskDefService.java @@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import top.jfunc.common.db.QueryHelper; +import top.jfunc.common.db.bean.Record; import top.jfunc.common.db.utils.Pagination; import java.util.*; @@ -352,7 +353,7 @@ public class ActTaskDefService { //通过特殊类型查询 List candidateTypeList = taskDef.getCandidateTypeList(); logger.info("findCandidateUsers-type-task:{}, typeList:{}", taskDef.getTaskName(), candidateTypeList); - List userListByType = queryCandidatesByTypes(candidateRoleList, procInsId); + List userListByType = queryCandidatesByTypes(candidateTypeList, procInsId); logger.info("findCandidateUsers-type-task:{}, userListByType:{}", taskDef.getTaskName(), userListByType); if (!userListByType.isEmpty()) { res.addAll(userListByType); @@ -363,6 +364,13 @@ public class ActTaskDefService { return resList; } + /** + * 通过类型查找审批人 + * + * @param types + * @param procInsId + * @return + */ private List queryCandidatesByTypes(List types, String procInsId) { if (types == null || types.isEmpty()) { return Collections.emptyList(); @@ -370,13 +378,25 @@ public class ActTaskDefService { List userIdList = new ArrayList<>(); for (String typeStr : types) { - if (CandidateTypeEnum.STARTER_LEADER.getType() == Integer.parseInt(typeStr)) { + + ActCandidateTypeEnum candidateTypeEnum = ActCandidateTypeEnum.ofType(Integer.parseInt(typeStr)); + if (ActCandidateTypeEnum.STARTER_LEADER == candidateTypeEnum) { //查找发起人部门主管 String startUserId = actUtil.getStartUserId(procInsId); int leaderId = accountService.getOneLevelDeptManagerId(Integer.parseInt(startUserId)); + logger.info("queryCandidatesByType startLeader:{}, procInsId:{} ", leaderId, procInsId); if (leaderId != 0) { userIdList.add(String.valueOf(leaderId)); } + } else if (ActCandidateTypeEnum.DEPT_LEADER == candidateTypeEnum) { + Record record = actUtil.getVariable(ActConstant.DEPT_LEADER_ID, procInsId); + if (record != null) { + String deptLeaderId = record.getStr("text"); + userIdList.add(deptLeaderId); + logger.info("queryCandidatesByType deptLeader:{}, procInsId:{} ", deptLeaderId, procInsId); + }else{ + logger.error("queryCandidatesByType not find deptLeader procInsId:{} ", procInsId); + } } } diff --git a/src/main/java/cn/palmte/work/service/ProjectProcessService.java b/src/main/java/cn/palmte/work/service/ProjectProcessService.java index 411573b..7cc13a5 100644 --- a/src/main/java/cn/palmte/work/service/ProjectProcessService.java +++ b/src/main/java/cn/palmte/work/service/ProjectProcessService.java @@ -1,5 +1,6 @@ package cn.palmte.work.service; +import cn.palmte.work.config.activiti.ActConstant; import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @@ -226,13 +227,13 @@ public class ProjectProcessService { BigDecimal repaidAmount = getProjectRepaidAmount(entity.getProjectId()); variables.put("repaidAmount", repaidAmount); // 合同金额 - variables.put("amount", project.getContractAmount() == null ? 0 : project.getContractAmount()); + variables.put("contractAmount", project.getContractAmount() == null ? 0 : project.getContractAmount()); // 项目类型 variables.put("projectType", project.getType()); // 合作类型 variables.put("cooperationType", project.getCooperateType() == null ? 0 : project.getCooperateType()); // 部门领导ID - variables.put("deptLeaderId", entity.getApplyDeptLeaderId()); + variables.put(ActConstant.DEPT_LEADER_ID, entity.getApplyDeptLeaderId()); startAuditProgress(entity, variables); } diff --git a/src/main/resources/templates/admin/act_task_def.ftl b/src/main/resources/templates/admin/act_task_def.ftl index 4b6fc3e..a56993e 100644 --- a/src/main/resources/templates/admin/act_task_def.ftl +++ b/src/main/resources/templates/admin/act_task_def.ftl @@ -76,7 +76,8 @@