ZhuDeKang před 5 měsíci
rodič
revize
2c35abe4c4

+ 2 - 2
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdDataCateController.java

@@ -77,10 +77,10 @@ public class MdDataCateController extends BaseController {
     public AjaxResult treeselect(MdDataCate mdDataCate) {
         List<MdDataCate> mdDataCates = mdDataCateService.selectMdDataCateList(mdDataCate).stream().peek(item -> item.setIcon("TREE")).collect(Collectors.toList());
 
-        List<MdDataSet> mdDataSets = mdDataSetService.selectMdDataSetList(new MdDataSet());
+      /*  List<MdDataSet> mdDataSets = mdDataSetService.selectMdDataSetList(new MdDataSet());
         for (MdDataSet mdDataSet : mdDataSets) {
             mdDataCates.add(new MdDataCate(mdDataSet.getDcCode(), mdDataSet.getCateId(), mdDataSet.getDcName(), "SET"));
-        }
+        }*/
         return success(mdDataCateService.buildDataTreeSelect(mdDataCates));
     }
 

+ 22 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdModelFlowController.java

@@ -2,6 +2,11 @@ package com.ruoyi.interfaces.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.agentsflex.core.chain.Chain;
+import com.agentsflex.core.chain.ChainEvent;
+import com.agentsflex.core.chain.listener.ChainEventListener;
+import dev.tinyflow.core.Tinyflow;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -95,4 +100,21 @@ public class MdModelFlowController extends BaseController
     {
         return toAjax(mdModelFlowService.deleteMdModelFlowByFlowIds(flowIds));
     }
+
+
+    @GetMapping("/run")
+    public AjaxResult run(String json){
+        Tinyflow tinyflow = new Tinyflow(json);
+
+        Chain chain = tinyflow.toChain();
+
+        chain.addEventListener(new ChainEventListener() {
+            @Override
+            public void onEvent(ChainEvent event, Chain chain) {
+                System.out.println("event: " + event.toString());
+            }
+        });
+return success();
+    }
+
 }

+ 2 - 2
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/PtServiceController.java

@@ -182,8 +182,8 @@ public class PtServiceController extends BaseController {
 
     @PostMapping("/testRun")
     public AjaxResult testRun(@RequestBody PtService ptService){
-        ptServiceService.testRun(ptService);
-        return success();
+
+        return success(ptServiceService.testRun(ptService));
     }
 
 

+ 89 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/test.java

@@ -0,0 +1,89 @@
+package com.ruoyi.interfaces.controller;
+
+import com.agentsflex.core.chain.Chain;
+import com.agentsflex.core.chain.ChainEvent;
+import com.agentsflex.core.chain.ChainSuspendException;
+import com.agentsflex.core.chain.event.*;
+import com.agentsflex.core.chain.listener.ChainEventListener;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.utils.JsonUtils;
+import dev.tinyflow.core.Tinyflow;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class test {
+
+
+    public static void main(String[] args) {
+        String json = "{\"nodes\": [{\"id\": \"node_CVKeWeJL8jn5cGr4\",\"position\": {\"x\": -83,\"y\": 67},\"data\": {\"title\": \"开始节点\",\"description\": \"开始定义输入参数\",\"expand\": true,\"parameters\": [{\"name\": \"username\",\"dataType\": \"String\",\"refType\": \"input\",\"id\": \"YtkNFKFFC5hh4zAh\",\"required\": true}, {\"name\": \"password\",\"dataType\": \"String\",\"refType\": \"input\",\"id\": \"YW0JonLnPtsDVRlp\",\"required\": true}]},\"type\": \"startNode\",\"selected\": false,\"measured\": {\"width\": 305,\"height\": 238},\"dragging\": false}, {\"id\": \"node_Lmg446ujJkBFTq7s\",\"position\": {\"x\": 333,\"y\": 68},\"data\": {\"title\": \"结束节点\",\"description\": \"结束定义输出参数\",\"expand\": true,\"outputDefs\": [{\"name\": \"用户名\",\"dataType\": \"String\",\"refType\": \"ref\",\"id\": \"0FqjBTXWXwmNHvOm\",\"ref\": \"node_CVKeWeJL8jn5cGr4.username\"}, {\"name\": \"密码\",\"dataType\": \"String\",\"refType\": \"ref\",\"id\": \"jdXNtiAiLAqP1uto\",\"ref\": \"node_CVKeWeJL8jn5cGr4.password\"}]},\"type\": \"endNode\",\"selected\": true,\"measured\": {\"width\": 368,\"height\": 238},\"dragging\": false}],\"edges\": [{\"markerEnd\": {\"type\": \"arrowclosed\",\"width\": 20,\"height\": 20},\"source\": \"node_CVKeWeJL8jn5cGr4\",\"target\": \"node_Lmg446ujJkBFTq7s\",\"id\": \"p1QfMcJuAkHG9XN7\",\"selected\": false}],\"viewport\": {\"x\": 269.9146606773976,\"y\": 109.93970251055521,\"zoom\": 0.8705505632961242}}\n";
+
+        JSONObject root = JSON.parseObject(json);
+        JSONArray nodes = root.getJSONArray("nodes");
+        JSONArray edges = root.getJSONArray("edges");
+
+        Tinyflow tinyflow = new Tinyflow(json);
+
+        Chain chain = tinyflow.toChain();
+        chain.addEventListener(new ChainEventListener() {
+            /*@Override
+            public void onEvent(ChainEvent event, Chain chain) {
+                System.out.println("event: " + event.toString());
+            }*/
+            @Override
+            public void onEvent(ChainEvent event, Chain chain) {
+                System.out.println("event: " + event.toString());
+                System.out.println("event: " + event.toString());
+                if(event instanceof ChainStartEvent){
+                    // 处理异常逻辑
+                    System.out.println("ChainStartEvent==============");
+                    System.out.println("ChainStartEvent==============");
+                }
+                if(event instanceof ChainStatusChangeEvent){
+                    // 处理异常逻辑
+                    System.out.println("ChainStatusChangeEvent==============");
+                    System.out.println("ChainStatusChangeEvent==============");
+                }
+                if(event instanceof NodeStartEvent){
+                    // 处理异常逻辑
+                    System.out.println("NodeStartEvent==============");
+                    System.out.println("NodeStartEvent==============");
+                }if(event instanceof NodeEndEvent){
+                    // 处理异常逻辑
+                    System.out.println("NodeEndEvent==============");
+                    System.out.println("NodeEndEvent==============");
+                }
+
+
+                if(event instanceof ChainResumeEvent){
+                    // 处理异常逻辑
+                    System.out.println("ChainResumeEvent==============");
+                    System.out.println("ChainResumeEvent==============");
+                }
+
+                if(event instanceof ChainEndEvent){
+                    // 处理异常逻辑
+                    System.out.println("ChainEndEvent==============");
+                    System.out.println("ChainEndEvent==============");
+                }
+
+
+            }
+        });
+
+
+        HashMap<String, Object> map = new HashMap<>();
+/*        map.put("username","123");
+        map.put("password","123");*/
+        // 执行执行链
+        try {
+
+            Map<String, Object> result = chain.executeForResult(map);
+        } catch (Exception e){
+
+        }
+        System.out.println();
+    }
+}

+ 1 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/PtServiceServiceImpl.java

@@ -143,6 +143,7 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
     @Override
     public String testRun(PtService ptService) {
         ptService.setUrl("http://localhost:8082/model/flow/list");
+        ptService.setRqtype("GET");
 
         String tokenUrl = "http://localhost:9002/sh-api/login";
         String bodyPar = "{\n" +

+ 23 - 0
ruoyi-common/pom.xml

@@ -163,6 +163,29 @@
             <artifactId>lombok</artifactId>
         </dependency>
 
+
+        <dependency>
+            <groupId>dev.tinyflow</groupId>
+            <artifactId>tinyflow-java-core</artifactId>
+            <version>1.1.6</version>
+            <exclusions>
+                <!-- 排除 SLF4J-Simple -->
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-simple</artifactId>
+                </exclusion>
+                <!-- 排除 Log4j2 -->
+                <exclusion>
+                    <groupId>org.apache.logging.log4j</groupId>
+                    <artifactId>log4j-slf4j-impl</artifactId>
+                </exclusion>
+                <!-- 排除 Reload4j -->
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-reload4j</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
 
 </project>