24282 před 1 rokem
rodič
revize
f4ea0c9985

+ 16 - 0
hx-flow/src/main/java/com/fjhx/flow/core/FlowDelegate.java

@@ -72,6 +72,11 @@ public abstract class FlowDelegate {
             returnToOriginator(flowId, businessId, flowStatus);
         }
 
+        // 流程作废
+        else if (FlowStatusEnum.CANCELLATION.equals(flowStatus)) {
+            cancellation(flowId, businessId, flowStatus);
+        }
+
         // 流程重新发起
         else if (NodeTypeEnum.START.equals(handleNodeType)) {
             relaunch(flowId, businessId, flowStatus, submitData);
@@ -113,4 +118,15 @@ public abstract class FlowDelegate {
 
     }
 
+    /**
+     * 作废
+     *
+     * @param flowId     流程id
+     * @param businessId 业务id
+     * @param flowStatus 流程状态枚举
+     */
+    public void cancellation(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
+
+    }
+
 }

+ 1 - 0
hx-flow/src/main/java/com/fjhx/flow/enums/FlowStatusEnum.java

@@ -15,6 +15,7 @@ public enum FlowStatusEnum {
     IN_PROGRESS(1, "进行中"),
     PASS(2, "已通过"),
     REJECT(3, "已驳回"),
+    CANCELLATION(4, "已作废"),
     ;
 
     private final Integer key;

+ 1 - 0
hx-flow/src/main/java/com/fjhx/flow/enums/HandleTypeEnum.java

@@ -15,6 +15,7 @@ public enum HandleTypeEnum {
     REJECT(2, "驳回"),
     RETURN_TO_PREVIOUS(3, "返回上一步"),
     RETURN_TO_SUBMITTER(4, "退回到发起人"),
+    CANCELLATION(5, "作废"),
     ;
 
     private final Integer key;

+ 9 - 0
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowExampleServiceImpl.java

@@ -284,6 +284,15 @@ public class FlowExampleServiceImpl extends ServiceImpl<FlowExampleMapper, FlowE
             }
         }
 
+        // 如果查看人是流程创建人,且流程未开始,添加作废按钮
+        if (Objects.equals(flowExample.getCreateUser(), SecurityUtils.getUserId())
+                && Objects.equals(flowExample.getStatus(), FlowStatusEnum.READY_START.getKey())) {
+            ApprovalRecordVo.ButtonInfo buttonInfo = new ApprovalRecordVo.ButtonInfo();
+            buttonInfo.setType(HandleTypeEnum.CANCELLATION.getKey());
+            buttonInfo.setName(HandleTypeEnum.CANCELLATION.getValue());
+            buttonInfoList.add(buttonInfo);
+        }
+
         return buttonInfoList;
     }
 

+ 29 - 5
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowProcessServiceImpl.java

@@ -242,6 +242,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 flowResult = returnToSubmitter(context);
                 break;
 
+            // 作废
+            case CANCELLATION:
+                flowResult = cancellation(context);
+                break;
+
             default:
                 throw new ServiceException("未知流程跳转类型");
 
@@ -316,7 +321,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
      * 拒绝流程
      */
     private FlowResult reject(FlowJumpContext context) {
-
         // 流程已驳回
         context.setFlowStatus(FlowStatusEnum.REJECT);
         // 流程结束,则流程节点审批人不存在
@@ -328,7 +332,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 return new FlowResult(true);
             }
         }
-
         throw new ServiceException("流程定义错误:未找到结束节点");
     }
 
@@ -363,7 +366,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
      * 退回到发起人
      */
     private FlowResult returnToSubmitter(FlowJumpContext context) {
-
         // 流程未发起
         context.setFlowStatus(FlowStatusEnum.READY_START);
         // 赋值发起人为节点审批人
@@ -375,11 +377,28 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 return new FlowResult(true);
             }
         }
-
         throw new ServiceException("流程定义错误:未找到开始节点");
     }
 
     /**
+     * 流程作废
+     */
+    private FlowResult cancellation(FlowJumpContext context) {
+        // 流程未发起
+        context.setFlowStatus(FlowStatusEnum.CANCELLATION);
+        // 流程作废,则流程节点审批人不存在
+        context.setJumpHandleUserId(null);
+
+        for (FlowDefinitionNode flowDefinitionNode : context.getFlowDefinitionNodeList()) {
+            if (NodeTypeEnum.END.getKey().equals(flowDefinitionNode.getNodeType())) {
+                context.setJumpNode(flowDefinitionNode);
+                return new FlowResult(true);
+            }
+        }
+        throw new ServiceException("流程定义错误:未找到结束节点");
+    }
+
+    /**
      * 执行节点方法
      */
     private void executiveNodeMethod(FlowJumpContext context) {
@@ -719,9 +738,14 @@ public class FlowProcessServiceImpl implements FlowProcessService {
      * 跳转节点消息推送
      */
     private void pushJumpMessage(FlowJumpContext context) {
+        HandleTypeEnum handleTypeEnum = context.getHandleType();
+
+        // 流程作废不发送消息
+        if (Objects.equals(handleTypeEnum, HandleTypeEnum.CANCELLATION)) {
+            return;
+        }
 
         FlowExample flowExample = context.getFlowExample();
-        HandleTypeEnum handleTypeEnum = context.getHandleType();
         FlowStatusEnum flowStatusEnum = context.getFlowStatus();
         FlowDefinitionNode jumpNode = context.getJumpNode();
         FlowDefinitionNode currentNode = context.getCurrentNode();