Bladeren bron

流程问题处理

yzc 10 maanden geleden
bovenliggende
commit
9416efc522

+ 9 - 7
hx-flow/src/main/java/com/fjhx/flow/core/FlowJumpContext.java

@@ -74,6 +74,9 @@ public class FlowJumpContext {
                 .eq(FlowExampleCurrent::getFlowExampleId, flowExample.getId())
                 .eq(FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
         );
+        if (ObjectUtil.isEmpty(one)) {
+            throw new ServiceException("该流程处理人不是您,您无权审批!");
+        }
         currentNode = flowDefinitionNodeService.getById(one.getNodeId());
 
         // 当前节点类型
@@ -82,9 +85,8 @@ public class FlowJumpContext {
         // 查找跳转类型
         handleType = HandleTypeEnum.getEnum(dto.getHandleType());
 
-//        // 跳转节点用户处理id
-//        jumpHandleUserId = dto.getHandleUserId();
-        selectUserList = dto.getSelectUserList()==null?new ArrayList<>():dto.getSelectUserList();
+        // 跳转节点用户处理
+        selectUserList = dto.getSelectUserList() == null ? new ArrayList<>() : dto.getSelectUserList();
 
     }
 
@@ -127,17 +129,17 @@ public class FlowJumpContext {
      */
     private final FlowDelegate flowDelegate;
 
-//    /**
+    //    /**
 //     * 跳转节点
 //     */
 //    private FlowDefinitionNode jumpNode;
-        private List<FlowDefinitionNode> jumpNodeList;
+    private List<FlowDefinitionNode> jumpNodeList;
 
-//    /**
+    //    /**
 //     * 跳转节点处理用户id
 //     */
 //    private String jumpHandleUserId;
-private List<FlowResult.SelectUser> selectUserList;
+    private List<FlowResult.SelectUser> selectUserList;
 
     /**
      * 流程当前状态

+ 1 - 1
hx-flow/src/main/java/com/fjhx/flow/entity/flow/dto/FlowResult.java

@@ -25,7 +25,7 @@ public class FlowResult {
     private Boolean success;
 
     /**
-     * 处理用户
+     * 处理用户 单节点
      */
     private List<SysUser> userList;
 

+ 12 - 15
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowProcessServiceImpl.java

@@ -269,25 +269,21 @@ public class FlowProcessServiceImpl implements FlowProcessService {
 
             // 结束流程
             case REJECT:
-                flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
                 flowResult = reject(context);
                 break;
 
             // 返回上一节点
             case RETURN_TO_PREVIOUS:
-                flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
                 flowResult = returnToPrevious(context);
                 break;
 
             // 退回到发起人
             case RETURN_TO_SUBMITTER:
-                flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
                 flowResult = returnToSubmitter(context);
                 break;
 
             // 作废
             case CANCELLATION:
-                flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
                 flowResult = cancellation(context);
                 break;
             //加签
@@ -302,7 +298,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 break;
             // 退回到指定节点
             case RETURN_TO_NODE:
-                flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
                 flowResult = returnToNode(context, dto);
                 break;
 
@@ -316,10 +311,17 @@ public class FlowProcessServiceImpl implements FlowProcessService {
             return flowResult;
         }
 
-        //删除当前用户待审批数据
+        //删除当前用户待审批数据,【退回、作废、驳回】删除全部待办
+        List<HandleTypeEnum> handleTypeEnums = Arrays.asList(
+                HandleTypeEnum.REJECT,
+                HandleTypeEnum.RETURN_TO_PREVIOUS,
+                HandleTypeEnum.RETURN_TO_SUBMITTER,
+                HandleTypeEnum.CANCELLATION,
+                HandleTypeEnum.RETURN_TO_NODE
+        );
         flowExampleCurrentService.remove(q -> q
                 .eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId())
-                .eq(FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
+                .eq(!handleTypeEnums.contains(context.getHandleType()), FlowExampleCurrent::getHandleUserId, SecurityUtils.getUserId())
         );
 
         flowThreadLocal.setFlowStatusEnum(context.getFlowStatus());
@@ -467,8 +469,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
 //        // 流程结束,则流程节点审批人不存在
 //        context.setJumpHandleUserId(null);
 
-        flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
-
         for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
             if (NodeTypeEnum.END.getKey().equals(flowDefinitionNode.getNodeType())) {
                 context.setJumpNodeList(new ArrayList<>());
@@ -539,8 +539,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
         // 流程未发起
         context.setFlowStatus(FlowStatusEnum.CANCELLATION);
 
-        flowExampleCurrentService.remove(q -> q.eq(FlowExampleCurrent::getFlowExampleId, context.getFlowExample().getId()));
-
         for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
             if (NodeTypeEnum.END.getKey().equals(flowDefinitionNode.getNodeType())) {
                 // 流程作废,则流程节点审批人不存在
@@ -621,8 +619,9 @@ public class FlowProcessServiceImpl implements FlowProcessService {
 
         // 查找指定节点信息
         FlowDefinitionNode jumpNode = nodeMap.get(handleNodeId);
+        List<FlowDefinitionNode> jumpNodeList = Collections.singletonList(jumpNode);
 
-        context.setJumpNodeList(Collections.singletonList(jumpNode));
+        context.setJumpNodeList(jumpNodeList);
 
         // 如果流程回退到开始节点
         if (NodeTypeEnum.START.getKey().equals(jumpNode.getNodeType())) {
@@ -633,11 +632,9 @@ public class FlowProcessServiceImpl implements FlowProcessService {
             return new FlowResult(true);
         }
 
-        FlowResult flowResult = getHandleUser(jumpNode, context.getSelectUserList());
+        FlowResult flowResult = setNextHandleNodeHandleUser(jumpNodeList, context.getSelectUserList());
         // 流程进行中
         context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
-        // 赋值流程节点审批人
-        jumpNode.setJumpHandleUserId(flowResult.getUserId());
 
         return flowResult;
     }