ZhuDeKang 6 tháng trước cách đây
mục cha
commit
3e25bfaef6

+ 333 - 9
ruoyi-admin/src/test/java/com/ruoyi/JasyptTest.java

@@ -1,10 +1,7 @@
 package com.ruoyi;
 
-import com.aizuda.snailjob.client.job.core.handler.query.RequestQueryHandler;
-import com.aizuda.snailjob.model.response.JobApiResponse;
-import com.ruoyi.RuoYiApplication;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.interfaces.api.SnailJobApi;
+import com.agentsflex.chain.node.JsExecNode;
+import com.agentsflex.core.chain.Chain;
 import org.jasypt.encryption.StringEncryptor;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
@@ -12,9 +9,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
 @SpringBootTest(classes = RuoYiApplication.class)
 @TestPropertySource(properties = {"spring.profiles.active=druid"})
 public class JasyptTest {
@@ -24,9 +23,334 @@ public class JasyptTest {
 
     @Test
     public void encryptPwd() {
-        RequestQueryHandler jobDetail = SnailJobApi.getJobDetail(1l);
-        JobApiResponse execute = jobDetail.execute();
-        System.out.println(execute.toString());
+
+        String code = "{\n" +
+                "    \"edges\": [\n" +
+                "        {\n" +
+                "            \"id\": \"g1MbfnZ5Gwb90H8H\",\n" +
+                "            \"source\": \"node_ncZomj9VYJSr3P3V\",\n" +
+                "            \"target\": \"node_6ajjEYlMDPcYl3ae\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"jC3w6Thci7Ua8tFO\",\n" +
+                "            \"source\": \"U6DteBZHGQfaBvpP\",\n" +
+                "            \"target\": \"node_6ajjEYlMDPcYl3ae\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"LY9hCUFEEqq0AoZl\",\n" +
+                "            \"source\": \"ucHhhciLB2U9snEM\",\n" +
+                "            \"target\": \"node_6ajjEYlMDPcYl3ae\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"EIOzuvcuPaD4k9tb\",\n" +
+                "            \"source\": \"node_B3Lz55SHHuTTE3TC\",\n" +
+                "            \"target\": \"node_ncZomj9VYJSr3P3V\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"t68rwPo1Q8UFcRZc\",\n" +
+                "            \"source\": \"node_1z5lKKFYhSYjDyKI\",\n" +
+                "            \"target\": \"node_B3Lz55SHHuTTE3TC\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"M11hEF6ug1Wb79XB\",\n" +
+                "            \"source\": \"node_B3Lz55SHHuTTE3TC\",\n" +
+                "            \"target\": \"U6DteBZHGQfaBvpP\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"6mL3Q2RAiHqiCkHm\",\n" +
+                "            \"source\": \"node_B3Lz55SHHuTTE3TC\",\n" +
+                "            \"target\": \"ucHhhciLB2U9snEM\",\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"L8v1pqEBUdeqsk1e\",\n" +
+                "            \"source\": \"node_6ajjEYlMDPcYl3ae\",\n" +
+                "            \"target\": \"node_tciO7KE86u6PHgKr\"\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"aO2ayu7f6CkuKs0r\",\n" +
+                "            \"source\": \"node_tciO7KE86u6PHgKr\",\n" +
+                "            \"target\": \"node_At2IIxQgEILAOu4n\"\n" +
+                "        }\n" +
+                "    ],\n" +
+                "    \"nodes\": [\n" +
+                "        {\n" +
+                "            \"id\": \"node_1z5lKKFYhSYjDyKI\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"开始节点\",\n" +
+                "                \"description\": \"开始定义输入参数\"\n" +
+                "            },\n" +
+                "            \"type\": \"startNode\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": -547.0868680833916,\n" +
+                "                \"y\": 137.4465838737692\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"node_ncZomj9VYJSr3P3V\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"获取雨量数据\",\n" +
+                "                \"expand\": false,\n" +
+                "                \"method\": \"get\",\n" +
+                "                \"outputDefs\": [\n" +
+                "                    {\n" +
+                "                        \"id\": \"1tTsWjENoLfB4JJa\",\n" +
+                "                        \"name\": \"headers\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Object\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"9OP5JjlkBqARboVZ\",\n" +
+                "                        \"name\": \"body\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"94bsldmZ4cbcx7Or\",\n" +
+                "                        \"name\": \"statusCode\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Number\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    }\n" +
+                "                ],\n" +
+                "                \"parameters\": [\n" +
+                "                    {\n" +
+                "                        \"id\": \"xscx2BZ3xAx8FBdB\",\n" +
+                "                        \"name\": \"STCD\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\"\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"tvzDXYZDpPHuCm1b\",\n" +
+                "                        \"name\": \"\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\"\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"jGFiQp0F47cfUODL\",\n" +
+                "                        \"name\": \"\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\"\n" +
+                "                    }\n" +
+                "                ],\n" +
+                "                \"description\": \"通过 HTTP 请求获取数据\"\n" +
+                "            },\n" +
+                "            \"type\": \"httpNode\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 392.078125,\n" +
+                "                \"y\": 34.671875\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"U6DteBZHGQfaBvpP\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"获取水位数据\",\n" +
+                "                \"expand\": false,\n" +
+                "                \"method\": \"get\",\n" +
+                "                \"outputDefs\": [\n" +
+                "                    {\n" +
+                "                        \"id\": \"1tTsWjENoLfB4JJa\",\n" +
+                "                        \"name\": \"headers\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Object\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"9OP5JjlkBqARboVZ\",\n" +
+                "                        \"name\": \"body\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"94bsldmZ4cbcx7Or\",\n" +
+                "                        \"name\": \"statusCode\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Number\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    }\n" +
+                "                ],\n" +
+                "                \"description\": \"通过 HTTP 请求获取数据\"\n" +
+                "            },\n" +
+                "            \"type\": \"httpNode\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 390.078125,\n" +
+                "                \"y\": 154.671875\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"ucHhhciLB2U9snEM\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"获取气象数据\",\n" +
+                "                \"method\": \"get\",\n" +
+                "                \"outputDefs\": [\n" +
+                "                    {\n" +
+                "                        \"id\": \"1tTsWjENoLfB4JJa\",\n" +
+                "                        \"name\": \"headers\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Object\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"9OP5JjlkBqARboVZ\",\n" +
+                "                        \"name\": \"body\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"String\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true\n" +
+                "                    },\n" +
+                "                    {\n" +
+                "                        \"id\": \"94bsldmZ4cbcx7Or\",\n" +
+                "                        \"name\": \"statusCode\",\n" +
+                "                        \"refType\": \"ref\",\n" +
+                "                        \"dataType\": \"Number\",\n" +
+                "                        \"nameDisabled\": true,\n" +
+                "                        \"deleteDisabled\": true,\n" +
+                "                        \"dataTypeDisabled\": true\n" +
+                "                    }\n" +
+                "                ],\n" +
+                "                \"description\": \"通过 HTTP 请求获取数据\"\n" +
+                "            },\n" +
+                "            \"type\": \"httpNode\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 390.078125,\n" +
+                "                \"y\": 268.671875\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"node_6ajjEYlMDPcYl3ae\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"模型计算\",\n" +
+                "                \"expand\": false\n" +
+                "            },\n" +
+                "            \"type\": \"task-node\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 866.148775304685,\n" +
+                "                \"y\": 134.94990664309157\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"node_At2IIxQgEILAOu4n\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"图表节点\",\n" +
+                "                \"expand\": false\n" +
+                "            },\n" +
+                "            \"type\": \"chart-node\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 1707.2668779489672,\n" +
+                "                \"y\": 134.90843037541023\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"node_B3Lz55SHHuTTE3TC\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"新建方案\"\n" +
+                "            },\n" +
+                "            \"type\": \"task-node\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": -124.87829206235932,\n" +
+                "                \"y\": 142.06519629483878\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        },\n" +
+                "        {\n" +
+                "            \"id\": \"node_tciO7KE86u6PHgKr\",\n" +
+                "            \"data\": {\n" +
+                "                \"title\": \"输出结果\",\n" +
+                "                \"expand\": false\n" +
+                "            },\n" +
+                "            \"type\": \"task-node\",\n" +
+                "            \"dragging\": false,\n" +
+                "            \"measured\": {\n" +
+                "                \"width\": 306,\n" +
+                "                \"height\": 88\n" +
+                "            },\n" +
+                "            \"position\": {\n" +
+                "                \"x\": 1291.991164789477,\n" +
+                "                \"y\": 134.31405390092667\n" +
+                "            },\n" +
+                "            \"selected\": false\n" +
+                "        }\n" +
+                "    ],\n" +
+                "    \"viewport\": {\n" +
+                "        \"x\": 830.8418078373795,\n" +
+                "        \"y\": 130.69047266353977,\n" +
+                "        \"zoom\": 1.741101126592249\n" +
+                "    }\n" +
+                "}";
+
+        Chain chain = new Chain();
+
+        JsExecNode a = new JsExecNode();
+        a.setCode(code);
+        a.setId("a");
+//        a.setCode(code);
+        chain.addNode(a);
+
+        Map<String, Object> result = chain.executeForResult(new HashMap<>());
+        System.out.println(result.getClass());
+        System.out.println(result);
     }
 
 }

+ 186 - 0
ruoyi-admin/src/test/java/com/ruoyi/TinyflowTest.java

@@ -0,0 +1,186 @@
+package com.ruoyi;
+
+import com.agentsflex.core.chain.Chain;
+import com.agentsflex.core.chain.ChainEvent;
+import com.agentsflex.core.chain.ChainNode;
+import com.agentsflex.core.chain.event.ChainStartEvent;
+import com.agentsflex.core.chain.event.ChainStatusChangeEvent;
+import com.agentsflex.core.chain.event.NodeEndEvent;
+import com.agentsflex.core.chain.event.NodeStartEvent;
+import com.agentsflex.core.chain.listener.ChainEventListener;
+import com.agentsflex.core.chain.listener.ChainOutputListener;
+import com.agentsflex.llm.openai.OpenAILlm;
+import com.ruoyi.interfaces.tinyflow.parser.PrintNodeParser;
+import dev.tinyflow.core.Tinyflow;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TinyflowTest {
+
+    //    static String data1 = "";
+    //static String data1 = "{\"nodes\":[{\"id\":\"2\",\"type\":\"llmNode\",\"data\":{\"title\":\"大模型\",\"description\":\"处理大模型相关问题\",\"expand\":true,\"outputDefs\":[{\"id\":\"pyiig8ntGWZhVdVz\",\"dataType\":\"Object\",\"name\":\"param\",\"children\":[{\"id\":\"1\",\"name\":\"newParam1\",\"dataType\":\"String\"},{\"id\":\"2\",\"name\":\"newParam2\",\"dataType\":\"String\"}]}]},\"position\":{\"x\":600,\"y\":50},\"measured\":{\"width\":334,\"height\":687},\"selected\":false},{\"id\":\"3\",\"type\":\"startNode\",\"data\":{\"title\":\"开始节点\",\"description\":\"开始定义输入参数\",\"expand\":true,\"parameters\":[{\"id\":\"Q37GZ5KKvPpCD7Cs\",\"name\":\"name\"}]},\"position\":{\"x\":150,\"y\":25},\"measured\":{\"width\":306,\"height\":209},\"selected\":false},{\"id\":\"4\",\"type\":\"endNode\",\"data\":{\"title\":\"结束节点\",\"description\":\"结束定义输出参数\",\"expand\":true,\"outputDefs\":[{\"id\":\"z7fOwoTjQ7AbUJdm\",\"ref\":\"3.name\",\"name\":\"test\"}]},\"position\":{\"x\":994,\"y\":218},\"measured\":{\"width\":334,\"height\":209},\"selected\":false,\"dragging\":false}],\"edges\":[{\"markerEnd\":{\"type\":\"arrowclosed\",\"width\":20,\"height\":20},\"source\":\"3\",\"target\":\"2\",\"id\":\"xy-edge__3-2\"},{\"markerEnd\":{\"type\":\"arrowclosed\",\"width\":20,\"height\":20},\"source\":\"2\",\"target\":\"4\",\"id\":\"xy-edge__2-4\"}],\"viewport\":{\"x\":250,\"y\":100,\"zoom\":1}}";
+    static String data1 = "{\n" +
+            "    \"nodes\": [\n" +
+            "        {\n" +
+            "            \"id\": \"1\",\n" +
+            "            \"type\": \"startNode\",\n" +
+            "            \"data\": {\n" +
+            "                \"title\": \"开始节点\",\n" +
+            "                \"description\": \"开始定义输入参数\",\n" +
+            "                \"expand\": true,\n" +
+            "                \"parameters\": [\n" +
+            "                    {\n" +
+            "                        \"name\": \"inputParam1\",\n" +
+            "                        \"dataType\": \"String\",\n" +
+            "                        \"refType\": \"input\",\n" +
+            "                        \"required\": true,\n" +
+            "                        \"description\": \"第一个输入参数\"\n" +
+            "                    },\n" +
+            "                    {\n" +
+            "                        \"name\": \"inputParam2\",\n" +
+            "                        \"dataType\": \"Number\",\n" +
+            "                        \"refType\": \"input\",\n" +
+            "                        \"required\": false,\n" +
+            "                        \"description\": \"第二个输入参数\",\n" +
+            "                        \"defaultValue\": 100\n" +
+            "                    }\n" +
+            "                ]\n" +
+            "            },\n" +
+            "            \"position\": {\n" +
+            "                \"x\": 150,\n" +
+            "                \"y\": 25\n" +
+            "            },\n" +
+            "            \"measured\": {\n" +
+            "                \"width\": 306,\n" +
+            "                \"height\": 209\n" +
+            "            },\n" +
+            "            \"selected\": false\n" +
+            "        },\n" +
+            "        {\n" +
+            "            \"id\": \"2\",\n" +
+            "            \"data\": {\n" +
+            "                \"title\": \"打印节点\",\n" +
+            "                \"parameters\": [\n" +
+            "                    {\n" +
+            "                        \"name\": \"message\",\n" +
+            "                        \"value\": \"Hello value\",\n" +
+            "                        \"dataType\": \"String\",\n" +
+            "                        \"defaultValue\": \"Hello defaultValue\",\n" +
+            "                        \"refType\": \"fixed\"\n" +
+            "                    },\n" +
+            "                    {\n" +
+            "                        \"name\": \"input1\",\n" +
+            "                        \"dataType\": \"String\",\n" +
+            "                        \"defaultValue\": \"Hello defaultValue\",\n" +
+            "                        \"ref\": \"1.inputParam1\",\n" +
+            "                        \"refType\": \"ref\"\n" +
+            "                    }\n" +
+            "                ]\n" +
+            "            },\n" +
+            "            \"type\": \"printNode\",\n" +
+            "            \"position\": {\n" +
+            "                \"x\": 600,\n" +
+            "                \"y\": 50\n" +
+            "            },\n" +
+            "            \"measured\": {\n" +
+            "                \"width\": 334,\n" +
+            "                \"height\": 687\n" +
+            "            },\n" +
+            "            \"selected\": false\n" +
+            "        },\n" +
+            "        {\n" +
+            "            \"id\": \"3\",\n" +
+            "            \"type\": \"endNode\",\n" +
+            "            \"data\": {\n" +
+            "                \"title\": \"结束节点\",\n" +
+            "                \"description\": \"结束定义输出参数\",\n" +
+            "                \"expand\": true,\n" +
+            "                \"outputDefs\": [\n" +
+            "                    {\n" +
+            "                        \"name\": \"data\",\n" +
+            "                        \"dataType\": \"String\",\n" +
+            "                        \"ref\": \"2.msg\",\n" +
+            "                        \"refType\": \"ref\"\n" +
+            "                    }\n" +
+            "                ]\n" +
+            "            },\n" +
+            "            \"position\": {\n" +
+            "                \"x\": 994,\n" +
+            "                \"y\": 218\n" +
+            "            },\n" +
+            "            \"measured\": {\n" +
+            "                \"width\": 334,\n" +
+            "                \"height\": 209\n" +
+            "            },\n" +
+            "            \"selected\": false,\n" +
+            "            \"dragging\": false\n" +
+            "        }\n" +
+            "    ],\n" +
+            "    \"edges\": [\n" +
+            "        {\n" +
+            "            \"markerEnd\": {\n" +
+            "                \"type\": \"arrowclosed\",\n" +
+            "                \"width\": 20,\n" +
+            "                \"height\": 20\n" +
+            "            },\n" +
+            "            \"source\": \"1\",\n" +
+            "            \"target\": \"2\",\n" +
+            "            \"id\": \"xy-edge__1-2\"\n" +
+            "        },\n" +
+            "        {\n" +
+            "            \"markerEnd\": {\n" +
+            "                \"type\": \"arrowclosed\",\n" +
+            "                \"width\": 20,\n" +
+            "                \"height\": 20\n" +
+            "            },\n" +
+            "            \"source\": \"2\",\n" +
+            "            \"target\": \"3\",\n" +
+            "            \"id\": \"xy-edge__2-3\"\n" +
+            "        }\n" +
+            "    ],\n" +
+            "    \"viewport\": {\n" +
+            "        \"x\": 250,\n" +
+            "        \"y\": 100,\n" +
+            "        \"zoom\": 1\n" +
+            "    }\n" +
+            "}";
+
+    public static void main(String[] args) {
+        System.out.println(data1);
+        Tinyflow tinyflow = new Tinyflow(data1);
+        tinyflow.getChainParser().addNodeParser("printNode",new PrintNodeParser());
+//        tinyflow.setLlmProvider(id -> OpenAILlm.of(""));
+
+        Map<String, Object> variables = new HashMap<>();
+        variables.put("inputParam1", "开始节点引入1");
+        variables.put("inputParam2", 2);
+
+        Chain chain = tinyflow.toChain();
+        chain.addEventListener(new ChainEventListener() {
+            @Override
+            public void onEvent(ChainEvent event, Chain chain) {
+                if (event instanceof ChainStartEvent) {
+                }
+                if (event instanceof ChainStatusChangeEvent) {
+
+                }
+                if (event instanceof NodeStartEvent) {
+                }
+                if (event instanceof NodeEndEvent) {
+                }
+            }
+        });
+
+        chain.addOutputListener(new ChainOutputListener() {
+            @Override
+            public void onOutput(Chain chain, ChainNode node, Object outputMessage) {
+                System.out.println("outputMessage: " + outputMessage);
+            }
+        });
+
+        Map<String, Object> result = chain.executeForResult(variables);
+
+        System.out.println("result:" + result);
+    }
+}

+ 170 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/chain/chainTest.java

@@ -0,0 +1,170 @@
+/*
+package com.ruoyi.interfaces.chain;
+
+import com.agentsflex.chain.node.JsExecNode;
+import com.agentsflex.core.chain.Chain;
+import com.agentsflex.core.chain.ChainEdge;
+import com.agentsflex.core.chain.Parameter;
+import com.agentsflex.core.chain.node.CodeNode;
+import com.agentsflex.core.chain.node.EndNode;
+import com.agentsflex.core.chain.node.StartNode;
+import com.agentsflex.core.util.Maps;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class chainTest {
+    public static void main(String[] args) {
+        extracted();
+
+    }
+*/
+/*
+
+    private static void res() {
+        Chain chain = new Chain();
+
+        StartNode a = new StartNode();
+        a.setId("a");
+        chain.addNode(a);
+
+        CodeNode b = new CodeNode() {
+            @Override
+            protected Map<String, Object> executeCode(String code, Chain chain) {
+
+                try {
+                    Thread.sleep(2000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                System.out.println("b");
+                return Maps.of();
+            }
+        };
+
+        b.setId("b");
+        // 设置 b 节点为异步执行
+        b.setAsync(true);
+
+        chain.addNode(b);
+
+        CodeNode c = new CodeNode() {
+            @Override
+            protected Map<String, Object> executeCode(String code, Chain chain) {
+
+                return Collections.emptyMap();
+            }
+        };
+        c.setId("c");
+        chain.addNode(c);
+
+        TestNode d = new TestNode() {
+            @Override
+            protected Map<String, Object> execute(Chain chain) {
+                System.out.println("d: " + Thread.currentThread().getId());
+                return Maps.of();
+            }
+        };
+        d.setId("d");
+        // 此处设置 d 节点的条件为上游节点执行完毕后才执行
+        d.setCondition(new JavascriptStringCondition("_context.isUpstreamFullyExecuted()"));
+        chain.addNode(d);
+
+        ChainEdge ab = new ChainEdge();
+        ab.setSource("a");
+        ab.setTarget("b");
+        chain.addEdge(ab);
+
+        ChainEdge ac = new ChainEdge();
+        ac.setSource("a");
+        ac.setTarget("c");
+        chain.addEdge(ac);
+
+
+        ChainEdge bd = new ChainEdge();
+        bd.setSource("b");
+        bd.setTarget("d");
+        chain.addEdge(bd);
+
+        ChainEdge cd = new ChainEdge();
+        cd.setSource("c");
+        cd.setTarget("d");
+        chain.addEdge(cd);
+
+        *//*
+
+*/
+/**
+         * 最终执行顺序:
+         *      B
+         *   ↗   ↘
+         * A         D
+         *   ↘   ↗
+         *      C
+         *//*
+*/
+/*
+
+        chain.executeForResult(new HashMap<>());
+    }
+
+*//*
+
+
+    private static void extracted() {
+        // 创建执行链
+        Chain chain = new Chain();
+
+        // 创建开始节点
+        StartNode startNode = new StartNode();
+        startNode.setId("1");
+        chain.addNode(startNode);
+
+        // 创建中间节点(动态代码节点)
+        JsExecNode jsExecNode = new JsExecNode();
+        jsExecNode.setId("2");
+        jsExecNode.setCode("console.log('hello world')");
+        chain.addNode(jsExecNode);
+
+        CodeNode codeNode = new CodeNode() {
+            @Override
+            protected Map<String, Object> executeCode(String code, Chain chain) {
+                List<Parameter> parameters1 = getParameters();
+                System.out.println("测试进入");
+                System.out.println("测试进入");
+                System.out.println("测试进入");
+                System.out.println("测试进入");
+
+                return Collections.emptyMap();
+            }
+        };
+        codeNode.setAsync(false);//是否异步执行
+        codeNode.setId("code");
+        codeNode.setCode("123");
+        chain.addNode(codeNode);
+        // 创建结束节点
+        EndNode endNode = new EndNode();
+        endNode.setId("3");
+        endNode.setMessage("success");
+        chain.addNode(endNode);
+
+        // 创建 1-2 的边
+        ChainEdge edge12 = new ChainEdge();
+        edge12.setSource("1");
+        edge12.setTarget("code");
+        chain.addEdge(edge12);
+
+        // 创建 2-3 的边
+        ChainEdge edge23 = new ChainEdge();
+        edge23.setSource("code");
+        edge23.setTarget("3");
+        chain.addEdge(edge23);
+
+        // 执行执行链
+        Map<String, Object> result = chain.executeForResult(new HashMap<>());
+        System.out.println(result);
+    }
+}
+*/

+ 9 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdAppFlowController.java

@@ -96,4 +96,13 @@ public class MdAppFlowController extends BaseController
     {
         return toAjax(mdAppFlowService.deleteMdAppFlowByFlowIds(flowIds));
     }
+
+
+    @PostMapping("/runFlow")
+    public AjaxResult runFlow(@RequestBody MdAppFlow appFlow){
+
+
+        return success(mdAppFlowService.runFlow(appFlow));
+    }
+
 }

+ 0 - 3
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/controller/MdDataSetParamController.java

@@ -5,9 +5,6 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.StringUtils;
-import groovyjarjarpicocli.CommandLine;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;

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

@@ -3,11 +3,6 @@ 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;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -104,7 +99,7 @@ public class MdModelFlowController extends BaseController
     }
 
 
-    @GetMapping("/run")
+  /*  @GetMapping("/run")
     public AjaxResult run(String json){
         Tinyflow tinyflow = new Tinyflow(json);
 
@@ -117,6 +112,6 @@ public class MdModelFlowController extends BaseController
             }
         });
 return success();
-    }
+    }*/
 
 }

+ 7 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/domain/FlowParVo.java

@@ -0,0 +1,7 @@
+package com.ruoyi.interfaces.domain;
+
+public class FlowParVo {
+    /**
+     *
+     */
+}

+ 4 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/IMdAppFlowService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.interfaces.service;
 
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.interfaces.domain.MdAppFlow;
 
 /**
@@ -58,4 +60,6 @@ public interface IMdAppFlowService
      * @return 结果
      */
     public int deleteMdAppFlowByFlowId(Long flowId);
+
+    Map<String, Object> runFlow(MdAppFlow appFlow);
 }

+ 17 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/service/impl/MdAppFlowServiceImpl.java

@@ -1,7 +1,13 @@
 package com.ruoyi.interfaces.service.impl;
 
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+
+import com.agentsflex.core.chain.Chain;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.interfaces.tinyflow.parser.PrintNodeParser;
+import dev.tinyflow.core.Tinyflow;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.interfaces.mapper.MdAppFlowMapper;
@@ -93,4 +99,15 @@ public class MdAppFlowServiceImpl implements IMdAppFlowService
     {
         return mdAppFlowMapper.deleteMdAppFlowByFlowId(flowId);
     }
+
+    @Override
+    public Map<String, Object> runFlow(MdAppFlow appFlow) {
+        String flowGraph = appFlow.getFlowGraph();
+        Tinyflow tinyflow = new Tinyflow(flowGraph);
+        tinyflow.getChainParser().addNodeParser("printNode",new PrintNodeParser());
+        Chain chain = tinyflow.toChain();
+
+
+        return chain.executeForResult(appFlow.getParams());
+    }
 }

+ 92 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/tinyflow/node/PrintNode.java

@@ -0,0 +1,92 @@
+package com.ruoyi.interfaces.tinyflow.node;
+
+import com.agentsflex.core.chain.Chain;
+import com.agentsflex.core.chain.Parameter;
+import com.agentsflex.core.chain.node.BaseNode;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.interfaces.domain.PtService;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 测试使用打印节点
+ */
+public class PrintNode extends BaseNode {
+    /**
+     * 参数列表
+     */
+    private List<Parameter> parameters;
+
+    /**
+     *
+     */
+    private PtService  ptService;
+    /**
+     * 接收参数
+     */
+    private Boolean receivePar;
+    /**
+     * 传递参数
+     */
+    private Boolean deliveryPar;
+
+    public PtService getPtService() {
+        return ptService;
+    }
+
+    public void setPtService(PtService ptService) {
+        this.ptService = ptService;
+    }
+
+    public boolean isReceivePar() {
+        return receivePar;
+    }
+
+    public void setReceivePar(Boolean receivePar) {
+        this.receivePar = receivePar;
+    }
+
+    public Boolean isDeliveryPar() {
+        return deliveryPar;
+    }
+
+    public void setDeliveryPar(Boolean deliveryPar) {
+        this.deliveryPar = deliveryPar;
+    }
+
+    @Override
+    public List<Parameter> getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(List<Parameter> parameters) {
+        this.parameters = parameters;
+    }
+
+    @Override
+    protected Map<String, Object> execute(Chain chain) {
+
+
+        //chain.getNodeExecuteResult()
+        // 获取参数,比如要打印的消息'
+        Map<String, Object> parameterValues = chain.getParameterValues(this);
+        //Map<String, Object> parameters = chain.getParameterValues(this,this.parameters,parameterValues);
+        System.out.println(parameterValues);
+        /*System.out.println(name);
+        System.out.println(ptService);
+*/
+
+        String input = (String)parameterValues.get("input1");
+        String message = (String)parameterValues.get("message");
+
+         input = "输入参数为:" +input+";业务节点输入参数为:"+message;
+        // 返回执行结果,可以为空,也可以包含输出数据
+        Map<String, Object> result = new HashMap<>();
+        //result.put("service", ptService);
+        result.put("msg",input);
+
+        return result;
+    }
+}

+ 39 - 0
ruoyi-api-patform/src/main/java/com/ruoyi/interfaces/tinyflow/parser/PrintNodeParser.java

@@ -0,0 +1,39 @@
+package com.ruoyi.interfaces.tinyflow.parser;
+
+import com.agentsflex.core.chain.node.BaseNode;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.interfaces.domain.PtService;
+import dev.tinyflow.core.Tinyflow;
+import com.ruoyi.interfaces.tinyflow.node.PrintNode;
+import dev.tinyflow.core.parser.BaseNodeParser;
+
+public class PrintNodeParser extends BaseNodeParser {
+
+    /**
+     *
+     * @param root 原json对象
+     * @param data 原json对象中的data对象
+     * @param tinyflow
+     * @return
+     */
+    @Override
+    protected BaseNode doParse(JSONObject root, JSONObject data, Tinyflow tinyflow) {
+        PrintNode node = new PrintNode();
+        node.setId(data.getString("id"));
+        // 可以设置其他属性,比如节点名称、描述等
+
+        if (data != null) {
+            node.setName(data.getString("title"));
+            //JSONArray parameters = data.getJSONArray("parameters");
+            // 解析其他配置参数,比如消息内容
+            node.setParameters(getParameters(data,"parameters"));
+            Boolean receivePar = data.getBoolean("receivePar");
+            node.setReceivePar(receivePar);
+            node.setDeliveryPar(data.getBoolean("deliveryPar"));
+            PtService service = data.getObject("service", PtService.class);
+            node.setPtService(service);
+        }
+
+        return node;
+    }
+}

+ 8 - 0
ruoyi-common/pom.xml

@@ -185,6 +185,14 @@
         </dependency>
 
 
+<!--
+        <dependency>
+            <groupId>com.agentsflex</groupId>
+            <artifactId>agents-flex-spring-boot-starter</artifactId>
+            <version>1.3.4</version>
+        </dependency>
+-->
+
 
         <dependency>
             <groupId>dev.tinyflow</groupId>