Prechádzať zdrojové kódy

自定义流程接口-加入抄送用户属性

wangliang 3 rokov pred
rodič
commit
cadc36616d

+ 35 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowVarDto.java

@@ -21,7 +21,7 @@ public class CustomFlowVarDto implements Serializable {
     @ApiModelProperty(value = "流程节点变量")
     String flowTaskVar;
 
-    @ApiModelProperty(value = "审批人")
+    @ApiModelProperty(value = "审批人id")
     List<String> approveIds;
 
     @ApiModelProperty(value = "属性")
@@ -36,9 +36,15 @@ public class CustomFlowVarDto implements Serializable {
     @ApiModelProperty(value = "自定义流程驳回重新提交类型")
     CustomFlowRejectResubmitTypeEnum rejectResubmitType;
 
-    @ApiModelProperty(value = "审批人")
+    @ApiModelProperty(value = "审批人姓名")
     String approveUserNames;
 
+    @ApiModelProperty(value = "抄送人id")
+    List<String> copyForUserIds;
+
+    @ApiModelProperty(value = "抄送人姓名")
+    String copyForUserNames;
+
     public CustomFlowVarDto() {
 
     }
@@ -47,15 +53,19 @@ public class CustomFlowVarDto implements Serializable {
         this.flowTaskVar = flowTaskVar;
     }
 
-    public CustomFlowVarDto(String flowTaskVar, List<String> approveIds) {
+    public CustomFlowVarDto(String flowTaskVar, List<String> approveIds, List<String> copyForUserIds, String copyForUserNames) {
         this.flowTaskVar = flowTaskVar;
         this.approveIds = approveIds;
+        this.copyForUserIds = copyForUserIds;
+        this.copyForUserNames = copyForUserNames;
     }
 
-    public CustomFlowVarDto(String flowTaskVar, List<String> approveIds, String approveUserNames) {
+    public CustomFlowVarDto(String flowTaskVar, List<String> approveIds, String approveUserNames, List<String> copyForUserIds, String copyForUserNames) {
         this.flowTaskVar = flowTaskVar;
         this.approveIds = approveIds;
         this.approveUserNames = approveUserNames;
+        this.copyForUserIds = copyForUserIds;
+        this.copyForUserNames = copyForUserNames;
     }
 
     public CustomFlowVarDto(String flowTaskVar, List<String> approveIds,
@@ -63,7 +73,9 @@ public class CustomFlowVarDto implements Serializable {
                             CustomFlowMultipleUserApproveTypeEnum multipleUserApproveType,
                             CustomFlowRejectTypeEnum rejectType,
                             CustomFlowRejectResubmitTypeEnum rejectResubmitType,
-                            String approveUserNames) {
+                            String approveUserNames,
+                            List<String> copyForUserIds,
+                            String copyForUserNames) {
         this.flowTaskVar = flowTaskVar;
         this.approveIds = approveIds;
         this.approveUserType = approveUserType;
@@ -71,6 +83,24 @@ public class CustomFlowVarDto implements Serializable {
         this.rejectType = rejectType;
         this.rejectResubmitType = rejectResubmitType;
         this.approveUserNames = approveUserNames;
+        this.copyForUserIds = copyForUserIds;
+        this.copyForUserNames = copyForUserNames;
+    }
+
+    public List<String> getCopyForUserIds() {
+        return copyForUserIds;
+    }
+
+    public void setCopyForUserIds(List<String> copyForUserIds) {
+        this.copyForUserIds = copyForUserIds;
+    }
+
+    public String getCopyForUserNames() {
+        return copyForUserNames;
+    }
+
+    public void setCopyForUserNames(String copyForUserNames) {
+        this.copyForUserNames = copyForUserNames;
     }
 
     public String getApproveUserNames() {

+ 11 - 16
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -885,7 +885,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                     //默认在开始节点后新增一个审批节点
                     customFlowDefaultDto = multiWorkFlow.createDefaultUserTask(customFlowDto, flowTaskLink, DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK);
                     setupMap.put(customFlowDefaultDto.getFlowTaskId(), new FlowTaskResult(customFlowDefaultDto.getContent(), customFlowDefaultDto.getFlowTaskId(), customFlowDefaultDto.getSetup()));
-                    agginessMap.computeIfAbsent(customFlowDefaultDto.getFlowTaskId(), v -> new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList(""))));
+                    agginessMap.computeIfAbsent(customFlowDefaultDto.getFlowTaskId(), v -> new CustomFlowVarDto(SystemConstant.APPROVE_ID, new ArrayList(Arrays.asList("")), null, null));
                     process.addFlowElement(createUserTask(CustomFlowTypeEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, Objects.nonNull(flowTaskLink.getLast().getTask().getContent()) && !Objects.equals(flowTaskLink.getLast().getTask().getContent(), "") ? flowTaskLink.getLast().getTask().getContent() : DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK_NAME, DefaultInstanceConvertToMultiInstance.APPROVE_ID_EXP));
                     break;
                 case PROCESS://过程节点
@@ -895,6 +895,10 @@ public class ActivitiServiceImpl implements ActivitiService {
                     CustomFlowPropertyDto customFlowPropertyDto = customFlowDto.getProperty();
                     List<String> approveUserIds = new ArrayList<>();//审批用户
                     List<String> copyUserIds = new ArrayList<>();//抄送用户
+                    //抄送用户
+                    if (Objects.nonNull(customFlowPropertyDto.getCopyForUsers()) && customFlowPropertyDto.getCopyForUsers().size() > 0) {
+                        copyUserIds.addAll(customFlowPropertyDto.getCopyForUsers().stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
+                    }
                     if (Objects.nonNull(customFlowDto.getProperty())) {
                         //选人属性
                         switch (customFlowPropertyDto.getApproveUserType()) {
@@ -903,20 +907,15 @@ public class ActivitiServiceImpl implements ActivitiService {
                                     approveUserIds.addAll(customFlowPropertyDto.getApproveUsers().stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
                                 }
                                 break;
-                            case ROLE://角色
-                                if (Objects.nonNull(customFlowPropertyDto.getApproveRoles()) && customFlowPropertyDto.getApproveRoles().size() > 0) {
-                                    List<SysUser> sysUserList = sysUserService.findByRoleIds(customFlowPropertyDto.getApproveRoles().stream().map(x -> x.getId()).collect(Collectors.toList()));
-                                    if (Objects.isNull(sysUserList) || sysUserList.size() == 0) {
-                                        throw ExceptionResultEnum.ERROR.exception(customFlowPropertyDto.getApproveRoles().stream().map(x -> x.getName()).collect(Collectors.toList()) + "角色下未找到用户");
-                                    }
-                                    approveUserIds.addAll(sysUserList.stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
-                                }
-                                break;
                             default:
                                 break;
                         }
                         ApproveUserResult approveUserResult = sysUserService.findByIds(approveUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
-                        agginessMap.put(node.getTask().getFlowTaskId(), new CustomFlowVarDto(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + i, approveUserIds, node.getTask().getProperty().getApproveUserType(), node.getTask().getProperty().getMultipleUserApproveType(), node.getTask().getProperty().getRejectType(), node.getTask().getProperty().getRejectResubmitType(), approveUserResult.getPendApproveUsers()));
+                        ApproveUserResult approveUserResultCopyUser = null;
+                        if (copyUserIds.size() > 0) {
+                            approveUserResultCopyUser = sysUserService.findByIds(copyUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
+                        }
+                        agginessMap.put(node.getTask().getFlowTaskId(), new CustomFlowVarDto(DefaultInstanceConvertToMultiInstance.DEFAULT_ASSIGNEE_LIST + i, approveUserIds, node.getTask().getProperty().getApproveUserType(), node.getTask().getProperty().getMultipleUserApproveType(), node.getTask().getProperty().getRejectType(), node.getTask().getProperty().getRejectResubmitType(), approveUserResult.getPendApproveUsers(), copyUserIds, Objects.nonNull(approveUserResultCopyUser) ? approveUserResultCopyUser.getPendApproveUsers() : null));
                         if (Objects.nonNull(customFlowPropertyDto.getRejectType()) && !Objects.equals(customFlowPropertyDto.getRejectType(), "")) {
                             //驳回属性
                             switch (customFlowPropertyDto.getRejectType()) {
@@ -1014,10 +1013,6 @@ public class ActivitiServiceImpl implements ActivitiService {
                                     break;
                             }
                         }
-                        //抄送用户
-                        if (Objects.nonNull(customFlowPropertyDto.getCopyForUsers())) {
-                            copyUserIds.addAll(customFlowPropertyDto.getCopyForUsers().stream().map(x -> String.valueOf(x.getId())).collect(Collectors.toList()));
-                        }
                     }
                     process.addFlowElement(createUserTask(CustomFlowTypeEnum.USER_TASK.getId() + i, Objects.nonNull(customFlowDto.getContent()) && !Objects.equals(customFlowDto.getContent(), "") ? customFlowDto.getContent() : DefaultInstanceConvertToMultiInstance.USER_TASK_APPROVE_NAME, approveUserIds, customFlowPropertyDto.getMultipleUserApproveType()));
                     break;
@@ -1242,7 +1237,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
         List<String> approveUserIds = new ArrayList(Arrays.asList(String.valueOf(approveId)));
         ApproveUserResult approveUserResult = sysUserService.findByIds(approveUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
-        agginessMap.put(CustomFlowTypeEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, approveUserIds, approveUserResult.getPendApproveUsers()));
+        agginessMap.put(CustomFlowTypeEnum.USER_TASK.getId() + DefaultInstanceConvertToMultiInstance.DEFAULT_USER_TASK, new CustomFlowVarDto(SystemConstant.APPROVE_ID, approveUserIds, approveUserResult.getPendApproveUsers(), null, null));
         flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
 
         map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());