24282 2 年 前
コミット
4c81e9e29e

+ 0 - 31
hx-flow/src/main/java/com/fjhx/flow/controller/flow/FlowDefinitionController.java

@@ -44,35 +44,4 @@ public class FlowDefinitionController {
         flowDefinitionService.addVersion(dto);
     }
 
-    // public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
-    //     Method method = FlowDefinitionDto.class.getMethod("send");
-    //     method.invoke(FlowDefinitionDto.class.newInstance());
-    // }
-
-    // public static void main(String[] args) {
-    //     String skipExpress = "${admin == admin2}";
-    //     HashMap<String, Object> map = new HashMap<>();
-    //     map.put("admin", "ad");
-    //     map.put("admin2", "ad");
-    //     System.out.println(expressionParsing(skipExpress,map));
-    // }
-    //
-    // public static Boolean expressionParsing(String skipExpress, Map<String, Object> map) {
-    //     if (StringUtils.isBlank(skipExpress) && map.isEmpty()) {
-    //         return false;
-    //     }
-    //     ExpressionParser parser = new SpelExpressionParser();
-    //     StandardEvaluationContext context = new StandardEvaluationContext();
-    //
-    //     TemplateParserContext templateParserContext = new TemplateParserContext("${", "}");
-    //     MapAccessor propertyAccessor = new MapAccessor();
-    //     context.setVariables(map);
-    //     context.setPropertyAccessors(Collections.singletonList(propertyAccessor));
-    //
-    //     SpelExpression expression = (SpelExpression) parser.parseExpression(skipExpress, templateParserContext);
-    //     expression.setEvaluationContext(context);
-    //     return Boolean.TRUE.equals(expression.getValue(map, boolean.class));
-    // }
-
-
 }

+ 12 - 4
hx-flow/src/main/java/com/fjhx/flow/core/FlowDelegate.java

@@ -23,20 +23,28 @@ public abstract class FlowDelegate {
         return map;
     }
 
+    /**
+     * 获取流程key
+     *
+     * @return 流程key
+     */
     public abstract String getFlowKey();
 
     /**
      * 开始流程实现类
      *
-     * @param flowId 流程id
-     * @param data   流程入参
+     * @param flowId     流程id
+     * @param submitData 流程入参
      * @return 业务id
      */
-    public abstract Long start(Long flowId, JSONObject data);
+    public abstract Long start(Long flowId, JSONObject submitData);
 
     /**
      * 结束流程实现类
+     *
+     * @param flowId     流程id
+     * @param submitData 流程入参
      */
-    public abstract void end();
+    public abstract void end(Long flowId, JSONObject submitData);
 
 }

+ 8 - 10
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowProcessServiceImpl.java

@@ -332,9 +332,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
         }
 
         flowExample.setVersion(dto.getVersion());
-
-        boolean b = flowExampleService.updateById(flowExample);
-        if (!b) {
+        boolean updateFlag = flowExampleService.updateById(flowExample);
+        if (!updateFlag) {
             throw new ServiceException("流程已被处理");
         }
         flowExampleDetailService.saveBatch(flowExampleDetailList);
@@ -371,7 +370,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 invokeMethod(flowDelegate, handlingMethod);
             } else {
                 // 执行默认方法
-                flowDelegate.end();
+                flowDelegate.end(FlowThreadLocalUtil.getFlowId(), FlowThreadLocalUtil.getCurrentData());
             }
         } catch (Exception e) {
             log.error("结束节点方法异常", e);
@@ -405,8 +404,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
      */
     private FlowDefinitionNode getNextUserNode(FlowDefinitionNode currentNode, List<FlowDefinitionNode> flowDefinitionNodeList) {
         // 父级节点map
-        Map<Long, List<FlowDefinitionNode>> parentNodeMap = flowDefinitionNodeList.stream()
-                .collect(Collectors.groupingBy(FlowDefinitionNode::getParentId));
+        Map<Long, List<FlowDefinitionNode>> parentNodeMap =
+                flowDefinitionNodeList.stream().collect(Collectors.groupingBy(FlowDefinitionNode::getParentId));
         // 查找下个节点
         List<FlowDefinitionNode> nextNodeList = parentNodeMap.get(currentNode.getId());
         FlowDefinitionNode nextNode = null;
@@ -504,25 +503,24 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                 flowResult.setSuccess(false);
                 flowResult.setUserList(userList);
                 return flowResult;
+            default:
+                throw new ServiceException("未知用户处理类型");
         }
 
-        return flowResult;
     }
 
     /**
      * 校验el表达式
      */
     public boolean expressionResult(Map<String, Object> map, String expression) {
-        boolean result;
         try {
             Expression exp = AviatorEvaluator.compile(expression);
             Object execute = exp.execute(map);
-            result = Boolean.parseBoolean(String.valueOf(execute));
+            return Boolean.parseBoolean(String.valueOf(execute));
         } catch (Exception e) {
             log.error("el表达式校验错误", e);
             throw new ServiceException("el表达式校验错误:" + e.getMessage());
         }
-        return result;
     }
 
 }