فهرست منبع

新增自定义流程属性-完整测试修改

wangliang 3 سال پیش
والد
کامیت
d7d27337e5

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowApprove.java

@@ -60,6 +60,10 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "流程转办")
     private String transferAssignee;
 
+    @ApiModelProperty(value = "会签待办")
+    @TableField(value = "all_assignee", updateStrategy = FieldStrategy.IGNORED)
+    private String allAssignee;
+
     public TFFlowApprove() {
 
     }
@@ -75,6 +79,14 @@ public class TFFlowApprove extends BaseEntity implements Serializable {
         this.setup = FlowApproveSetupEnum.SUBMIT.getSetup();
     }
 
+    public String getAllAssignee() {
+        return allAssignee;
+    }
+
+    public void setAllAssignee(String allAssignee) {
+        this.allAssignee = allAssignee;
+    }
+
     public String getTransferAssignee() {
         return transferAssignee;
     }

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
@@ -69,6 +70,10 @@ public class TFFlowLog extends BaseEntity implements Serializable {
     @TableField(value = "approve_multi_setup", updateStrategy = FieldStrategy.IGNORED)
     private Integer approveMultiSetup;
 
+    @ApiModelProperty(value = "审批用户类别")
+    @TableField(value = "approve_user_approve_type", updateStrategy = FieldStrategy.IGNORED)
+    private CustomFlowMultipleUserApproveTypeEnum approveUserApproveType;
+
     public TFFlowLog() {
 
     }
@@ -97,6 +102,14 @@ public class TFFlowLog extends BaseEntity implements Serializable {
         insertInfo(userId);
     }
 
+    public CustomFlowMultipleUserApproveTypeEnum getApproveUserApproveType() {
+        return approveUserApproveType;
+    }
+
+    public void setApproveUserApproveType(CustomFlowMultipleUserApproveTypeEnum approveUserApproveType) {
+        this.approveUserApproveType = approveUserApproveType;
+    }
+
     public Integer getApproveMultiSetup() {
         return approveMultiSetup;
     }

+ 56 - 18
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -453,7 +453,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                     tfFlowLog,
                     sysUser,
                     map,
-                    multiInstance,
+                    currFlow,
                     nrOfCompletedInstances,
                     nrOfInstances,
                     currFlowTaskResult,
@@ -486,7 +486,7 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @param tfFlowLog
      * @param sysUser
      * @param map
-     * @param multiInstance
+     * @param currFlow
      * @param nrOfCompletedInstances
      * @param nrOfInstances
      * @param currFlowTaskResult
@@ -500,7 +500,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                                   TFFlowLog tfFlowLog,
                                   SysUser sysUser,
                                   Map<String, Object> map,
-                                  boolean multiInstance,
+                                  FlowNode currFlow,
                                   Integer nrOfCompletedInstances,
                                   Integer nrOfInstances,
                                   FlowTaskResult currFlowTaskResult,
@@ -523,13 +523,38 @@ public class ActivitiServiceImpl implements ActivitiService {
         tfFlowLog.setPaperAttachmentId((String) map.get(SystemConstant.PAPAER_ATTACHMENT_IDS));
         CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
         if (Objects.nonNull(customFlowVarDto)) {
-            if (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE && multiInstance && Objects.nonNull(nrOfCompletedInstances)
+            if (tfFlowLog.getApproveOperation() == FlowApproveOperationEnum.APPROVE && Objects.nonNull(nrOfCompletedInstances)
                     && Objects.nonNull(nrOfInstances)
                     && nrOfCompletedInstances.intValue() != nrOfInstances.intValue()) {
-                tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                if (currFlow.getBehavior() instanceof SequentialMultiInstanceBehavior) {//串行
+                    tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                } else if (currFlow.getBehavior() instanceof ParallelMultiInstanceBehavior) {//并行
+                    Map<String, CustomFlowVarDto> allAgginessMap = null;
+                    CustomFlowVarDto customFlowVarAllDto = null;
+                    if (Objects.nonNull(tfFlowApprove.getAllAssignee())) {
+                        allAgginessMap = JacksonUtil.readJson(tfFlowApprove.getAllAssignee(), Map.class);
+                        customFlowVarAllDto = gson.fromJson(gson.toJson(allAgginessMap.get(nextFlowTaskResult.getTaskKey())), CustomFlowVarDto.class);
+                    } else {
+                        allAgginessMap = new HashMap<>();
+                        customFlowVarAllDto = customFlowVarDto;
+                    }
+                    allAgginessMap.put(nextFlowTaskResult.getTaskKey(), customFlowVarAllDto);
+                    List<String> approveIds = customFlowVarAllDto.getApproveIds();
+                    approveIds.remove(String.valueOf(sysUser.getId()));
+                    if (Objects.nonNull(approveIds) && approveIds.size() > 0) {
+                        tfFlowLog.setPendApproveId(approveIds.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                    }
+                    tfFlowApprove.setAllAssignee(JacksonUtil.parseJson(allAgginessMap));
+                }
             } else {
+                if (Objects.nonNull(tfFlowApprove.getAllAssignee())) {
+                    Map<String, CustomFlowVarDto> allAgginessMap = JacksonUtil.readJson(tfFlowApprove.getAllAssignee(), Map.class);
+                    allAgginessMap.remove(currFlowTaskResult.getTaskKey());
+                    tfFlowApprove.setAllAssignee(allAgginessMap.size() == 0 ? null : JacksonUtil.parseJson(allAgginessMap));
+                }
                 tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
             }
+            tfFlowLog.setApproveUserApproveType(customFlowVarDto.getMultipleUserApproveType());
         }
         map.put(SystemConstant.APPROVE_TF_FLOW_LOG, tfFlowLog);
         tfFlowApproveService.saveOrUpdate(tfFlowApprove);
@@ -1042,40 +1067,53 @@ public class ActivitiServiceImpl implements ActivitiService {
             agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
         }
 
+        ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
+        SysUser exchangeUser = sysUserService.getById(userId);
+        //流程流水日志
+        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()));
         Gson gson = new Gson();
         CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
         if (customFlowVarDto.getApproveIds().size() == 1) {
             customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
         } else {
             if (multiInstance && Objects.nonNull(nrOfCompletedInstances)) {
-                if (currFlow.getBehavior() instanceof SequentialMultiInstanceBehavior) {
+                if (currFlow.getBehavior() instanceof SequentialMultiInstanceBehavior) {//串行
                     List<String> approveIds = customFlowVarDto.getApproveIds();
                     approveIds.remove(nrOfCompletedInstances.intValue());
                     approveIds.add(nrOfCompletedInstances.intValue(), userId);
-                } else if (currFlow.getBehavior() instanceof ParallelMultiInstanceBehavior) {
+                    tfFlowLog.setPendApproveId(approveIds.subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                } else if (currFlow.getBehavior() instanceof ParallelMultiInstanceBehavior) {//并行
                     removeApproveUserId(customFlowVarDto, String.valueOf(sysUser.getId()), userId);
+                    if (Objects.nonNull(tfFlowApprove.getAllAssignee())) {
+                        Map<String, CustomFlowVarDto> allAgginessMap = JacksonUtil.readJson(tfFlowApprove.getAllAssignee(), Map.class);
+                        if (Objects.nonNull(allAgginessMap.get(userTask.getId()))) {
+                            CustomFlowVarDto customFlowVarAllDto = gson.fromJson(gson.toJson(allAgginessMap.get(userTask.getId())), CustomFlowVarDto.class);
+                            List<String> approveIds = customFlowVarAllDto.getApproveIds();
+                            approveIds.remove(String.valueOf(sysUser.getId()));
+                            approveIds.add(userId);
+                            allAgginessMap.put(userTask.getId(), customFlowVarAllDto);
+                            tfFlowLog.setPendApproveId(approveIds.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                        }
+                        tfFlowApprove.setAllAssignee(JacksonUtil.parseJson(allAgginessMap));
+                    } else {
+                        tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                    }
                 }
             } else {
                 removeApproveUserId(customFlowVarDto, String.valueOf(sysUser.getId()), userId);
             }
         }
-
         agginessMap.put(userTask.getId(), customFlowVarDto);
-        taskService.setAssignee(taskId, userId);
-
         tfFlowApprove.setTransferAssignee(JacksonUtil.parseJson(agginessMap));
         tfFlowApproveService.updateById(tfFlowApprove);
 
-        ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
-        SysUser exchangeUser = sysUserService.getById(userId);
-        //流程流水日志
-        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()));
-        if (multiInstance) {
-            tfFlowLog.setPendApproveId(customFlowVarDto.getApproveIds().subList(nrOfCompletedInstances, nrOfInstances).toString().replaceAll("\\[", "").replaceAll("\\]", ""));
-        }
-
+        tfFlowLog.setApproveMultiSetup(Objects.nonNull(nrOfCompletedInstances) ? nrOfCompletedInstances++ : nrOfCompletedInstances);
         tfFlowLog.setApproveSetup(tfFlowApprove.getSetup());
+        tfFlowLog.setApproveUserApproveType(customFlowVarDto.getMultipleUserApproveType());
         tfFlowLogService.save(tfFlowLog);
+
+//        int i = 1 / 0;
+        taskService.setAssignee(taskId, userId);
         return true;
     }