From 7049a9a623d3eb4cf589ad07f42db0a483df71ea Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期三, 13 三月 2024 15:02:49 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerEdge.jsx | 108 +++++++
zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerCrn.jsx | 124 ++++++++
zy-asrs-flow/src/components/Flow/GraphDrawer.jsx | 140 --------
zy-asrs-flow/src/services/flow/api.js | 9
zy-asrs-flow/src/components/Flow/GraphComponent.jsx | 63 +++
zy-asrs-wcs/src/main/resources/application.yml | 2
zy-asrs-flow/src/components/Flow/GraphConfig.jsx | 5
/dev/null | 92 ------
zy-asrs-flow/src/components/Flow/css/GrapDrawer.less | 0
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/controller/FlowController.java | 68 ++++
zy-asrs-flow/src/components/Flow/css/GraphTools.less | 0
zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerNode.jsx | 71 ++++
zy-asrs-flow/src/config/setting.ts | 2
zy-asrs-flow/src/components/Flow/GraphTools.jsx | 170 ++++------
zy-asrs-flow/src/services/route.js | 1
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/entity/param/FlowLogicCodeParam.java | 20 +
16 files changed, 542 insertions(+), 333 deletions(-)
diff --git a/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerCrn.jsx b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerCrn.jsx
new file mode 100644
index 0000000..1bafa98
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerCrn.jsx
@@ -0,0 +1,124 @@
+import React, { useRef, useEffect, useState } from "react";
+import { Button, Drawer, Input, Switch, Select } from 'antd';
+import { initNodeData } from "../GraphConfig";
+
+const { TextArea } = Input;
+
+export const GraphDrawerCrn = ({ graphRef, isReady }) => {
+
+ const [open, setOpen] = useState(false);
+ const [init, setInit] = useState(false);
+ const [nodeData, setNodeData] = useState(null);
+ const [codeContent, setCodeContent] = useState(null);
+ const [execClass, setExecClass] = useState(null);
+ const [execApi, setExecApi] = useState(null);
+
+ const classList = [
+ { value: 'crnClass', label: '鍫嗗灈鏈虹被' },
+ ];
+
+ const apiList = [
+ { value: 'load', label: '鍙栬揣' },
+ { value: 'unload', label: '鏀捐揣' },
+ { value: 'load_unload', label: '鍙栨斁璐�' },
+ ];
+
+ const showNodeDrawer = (graph, node) => {
+ if (node.data.type == "crn") {
+ setOpen(true);
+ setNodeData(node);
+ if (node.data == null) {
+ node.data = initNodeData;
+ }
+
+ if (node.data.codeContent != null) {
+ setCodeContent(node.data.codeContent);
+ }
+
+ if (node.data.execClass != null) {
+ setExecClass(node.data.execClass);
+ }else{
+ setExecClass(null);
+ }
+
+ if (node.data.execApi != null) {
+ setExecApi(node.data.execApi);
+ }else {
+ setExecApi(null);
+ }
+ }
+ };
+
+ const onNodeClose = (e) => {
+ setOpen(false);
+ setNodeData(null);
+ setCodeContent(null);
+ };
+
+ const nodeTextAreaChange = (e) => {
+ setCodeContent(e.target.value);
+ nodeData.data.codeContent = e.target.value;
+ }
+
+ const nodeDataInputChange = (e) => {
+ nodeData.label = e.target.value;
+ }
+
+ const classListChange = (e) => {
+ setExecClass(e);
+ nodeData.data.execClass = e;
+ }
+
+ const apiListChange = (e) => {
+ setExecApi(e);
+ nodeData.data.execApi = e;
+ }
+
+ useEffect(() => {
+ if (isReady) {
+ const graph = graphRef.current;
+
+ if (!init) {
+ graph.on("node:dblclick", ({ node }) => {
+ showNodeDrawer(graph, node);
+ })
+ setInit(true);
+ }
+ }
+ }, [apiList])
+
+ if (nodeData) {
+ return (
+ <>
+ <Drawer title={nodeData.label} onClose={onNodeClose} open={open} size="large">
+ <div className="graphDrawerContainer">
+ <div>鍫嗗灈鏈虹粍浠�</div>
+ <div>ID锛歿nodeData.id}</div>
+ <div>缁勪欢鍚嶏細<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
+ <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={nodeData.data.root} /></div>
+ <div>
+ 鎵ц绫伙細
+ <Select
+ style={{ width: 120 }}
+ options={classList}
+ onChange={classListChange}
+ defaultValue={execClass}
+ />
+ </div>
+ <div>
+ 鎵ц鎺ュ彛锛�
+ <Select
+ style={{ width: 120 }}
+ options={apiList}
+ onChange={apiListChange}
+ defaultValue={execApi}
+ />
+ </div>
+ <div>鍙墽琛屼唬鐮侊細</div>
+ <TextArea value={codeContent} onChange={nodeTextAreaChange} rows={10} />
+ </div>
+ </Drawer>
+ </>
+ );
+ }
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerEdge.jsx b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerEdge.jsx
new file mode 100644
index 0000000..257aee7
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerEdge.jsx
@@ -0,0 +1,108 @@
+import React, { useRef, useEffect, useState } from "react";
+import { Button, Drawer, Input, Switch, AutoComplete } from 'antd';
+import { CloseSquareFilled } from '@ant-design/icons';
+import { initNodeData } from "../GraphConfig";
+
+const { TextArea } = Input;
+
+export const GraphDrawerEdge = ({ graphRef, isReady }) => {
+
+ const [open, setOpen] = useState(false);
+ const [init, setInit] = useState(false);
+ const [edgeData, setEdgeData] = useState(null);
+ const [codeContent, setCodeContent] = useState(null);
+
+ const options = [
+ { value: 'true' },
+ { value: 'false' },
+ ];
+
+ const showEdgeDrawer = (graph, edge) => {
+ setOpen(true);
+ setEdgeData(edge);
+ if (edge.data == null) {
+ edge.data = initNodeData;
+ }
+
+ if (edge.data.codeContent != null) {
+ setCodeContent(edge.data.codeContent);
+ }
+
+ if (edge.labels.length == 0) {
+ edge.appendLabel({
+ attrs: {
+ label: {
+ text: ""
+ }
+ }
+ })
+ }
+
+ }
+
+ const onEdgeClose = (e) => {
+ setOpen(false);
+ setEdgeData(null);
+ setCodeContent(null);
+ };
+
+ const edgeTextAreaChange = (e) => {
+ setCodeContent(e.target.value);
+ edgeData.data.codeContent = e.target.value;
+ }
+
+ const edgeDataInputChange = (value) => {
+ edgeData.removeLabelAt(0);
+ edgeData.appendLabel({
+ attrs: {
+ label: {
+ text: value
+ }
+ }
+ })
+ edgeData.data.logicBool = value == 'true' ? true : false;
+ }
+
+ useEffect(() => {
+ if (isReady) {
+ const graph = graphRef.current;
+
+ if (!init) {
+ graph.on("edge:dblclick", ({ edge }) => {
+ showEdgeDrawer(graph, edge);
+ })
+ setInit(true);
+ }
+ }
+ })
+
+ if (edgeData) {
+ return (
+ <>
+ <Drawer title={edgeData.label} onClose={onEdgeClose} open={open} size="large">
+ <div className="graphDrawerContainer">
+ <div>ID锛歿edgeData.id}</div>
+ <div>
+ 灞炴�ц鎯咃細
+ <AutoComplete
+ style={{
+ width: 200,
+ }}
+ options={options}
+ filterOption={(inputValue, option) =>
+ option.value.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1
+ }
+ allowClear={{ clearIcon: <CloseSquareFilled /> }}
+ defaultValue={edgeData.labels[0].attrs.label.text}
+ onChange={edgeDataInputChange}
+ />
+ </div>
+ <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={edgeData.data.root} /></div>
+ <div>鍙墽琛屼唬鐮侊細</div>
+ <TextArea value={codeContent} onChange={edgeTextAreaChange} rows={10} />
+ </div>
+ </Drawer>
+ </>
+ );
+ }
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerNode.jsx b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerNode.jsx
new file mode 100644
index 0000000..b9a17a4
--- /dev/null
+++ b/zy-asrs-flow/src/components/Flow/Drawer/GraphDrawerNode.jsx
@@ -0,0 +1,71 @@
+import React, { useRef, useEffect, useState } from "react";
+import { Button, Drawer, Input, Switch } from 'antd';
+import { initNodeData } from "../GraphConfig";
+
+const { TextArea } = Input;
+
+export const GraphDrawerNode = ({ graphRef, isReady }) => {
+
+ const [open, setOpen] = useState(false);
+ const [init, setInit] = useState(false);
+ const [nodeData, setNodeData] = useState(null);
+ const [codeContent, setCodeContent] = useState(null);
+
+ const showNodeDrawer = (graph, node) => {
+ if (node.data.type == null || node.data.type == "none") {
+ setOpen(true);
+ setNodeData(node);
+ if (node.data == null) {
+ node.data = initNodeData;
+ }
+
+ if (node.data.codeContent != null) {
+ setCodeContent(node.data.codeContent);
+ }
+ }
+ };
+
+ const onNodeClose = (e) => {
+ setOpen(false);
+ setNodeData(null);
+ setCodeContent(null);
+ };
+
+ const nodeTextAreaChange = (e) => {
+ setCodeContent(e.target.value);
+ nodeData.data.codeContent = e.target.value;
+ }
+
+ const nodeDataInputChange = (e) => {
+ nodeData.label = e.target.value;
+ }
+
+ useEffect(() => {
+ if (isReady) {
+ const graph = graphRef.current;
+
+ if (!init) {
+ graph.on("node:dblclick", ({ node }) => {
+ showNodeDrawer(graph, node);
+ })
+ setInit(true);
+ }
+ }
+ })
+
+ if (nodeData) {
+ return (
+ <>
+ <Drawer title={nodeData.label} onClose={onNodeClose} open={open} size="large">
+ <div className="graphDrawerContainer">
+ <div>ID锛歿nodeData.id}</div>
+ <div>缁勪欢鍚嶏細<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
+ <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={nodeData.data.root} /></div>
+ <div>鍙墽琛屼唬鐮侊細</div>
+ <TextArea value={codeContent} onChange={nodeTextAreaChange} rows={10} />
+ </div>
+ </Drawer>
+ </>
+ );
+ }
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphComponent.jsx b/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
index 1a8bbb0..995e51b 100644
--- a/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphComponent.jsx
@@ -1440,6 +1440,10 @@
{
name: 'group1',
title: '甯哥敤缁勪欢',
+ },
+ {
+ name: 'group2',
+ title: '閫昏緫缁勪欢'
}
],
})
@@ -1468,9 +1472,57 @@
data: initNodeData,
})
- const n3Data = JSON.parse(JSON.stringify(initNodeData))
- n3Data.isLogic = true;//閫昏緫鍒ゆ柇
- const n3 = graph.createNode({
+ const crnData = JSON.parse(JSON.stringify(initNodeData))
+ crnData.type = "crn";
+ const crnStencil = graph.createNode({
+ shape: "rect",
+ width: 80,
+ height: 40,
+ label: "鍫嗗灈鏈虹粍浠�",
+ attrs: commonGraphAttrs,
+ ports: commonGraphPorts,
+ data: crnData,
+ })
+
+ const shuttleData = JSON.parse(JSON.stringify(initNodeData))
+ shuttleData.type = "shuttle";
+ const shuttleStencil = graph.createNode({
+ shape: "rect",
+ width: 80,
+ height: 40,
+ label: "鍥涘悜杞︾粍浠�",
+ attrs: commonGraphAttrs,
+ ports: commonGraphPorts,
+ data: shuttleData,
+ })
+
+ const liftData = JSON.parse(JSON.stringify(initNodeData))
+ liftData.type = "lift";
+ const liftStencil = graph.createNode({
+ shape: "rect",
+ width: 80,
+ height: 40,
+ label: "鎻愬崌鏈虹粍浠�",
+ attrs: commonGraphAttrs,
+ ports: commonGraphPorts,
+ data: liftData,
+ })
+
+ const devpData = JSON.parse(JSON.stringify(initNodeData))
+ devpData.type = "devp";
+ const devpStencil = graph.createNode({
+ shape: "rect",
+ width: 80,
+ height: 40,
+ label: "杈撻�佺嚎缁勪欢",
+ attrs: commonGraphAttrs,
+ ports: commonGraphPorts,
+ data: devpData,
+ })
+
+ const logicStencilData = JSON.parse(JSON.stringify(initNodeData))
+ logicStencilData.isLogic = true;//閫昏緫鍒ゆ柇
+ const logicStencil = graph.createNode({
shape: 'path',
width: 100,
height: 60,
@@ -1479,10 +1531,11 @@
attrs: commonGraphAttrs,
label: '閫昏緫鍒ゆ柇',
ports: commonGraphPorts,
- data: n3Data,
+ data: logicStencilData,
})
- stencil.load([n1, n2, n3], 'group1')
+ stencil.load([n1, n2, crnStencil, shuttleStencil, liftStencil, devpStencil], 'group1')
+ stencil.load([logicStencil], 'group2')
}
function initBind(graph) {
diff --git a/zy-asrs-flow/src/components/Flow/GraphConfig.jsx b/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
index 9e41776..646a93b 100644
--- a/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphConfig.jsx
@@ -93,7 +93,7 @@
}
const initGraphConnecting = {
- router: 'manhattan',
+ // router: 'manhattan',
connector: {
name: 'rounded',
args: {
@@ -135,6 +135,9 @@
searchLogicId: 1,//榛樿閫昏緫id
searchLogicBool: true,//榛樿閫昏緫id鏂瑰悜
searchIndex: 0,//榛樿鎵ц浼樺厛绾�
+ type: "none", //缁勪欢绫诲瀷
+ execClass: null,//鎵ц绫�
+ execApi: null,//鎵ц鎺ュ彛
}
export { commonGraphPorts, commonGraphAttrs, initGraphConnecting, initNodeData }
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx b/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
index df442c5..858b6eb 100644
--- a/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphDrawer.jsx
@@ -1,134 +1,16 @@
import React, { useRef, useEffect, useState } from "react";
-import { Button, Drawer, Input, Switch } from 'antd';
-import { initNodeData } from "./GraphConfig";
-import './GrapDrawer.less';
-
-const { TextArea } = Input;
+import { GraphDrawerNode } from "./Drawer/GraphDrawerNode";
+import { GraphDrawerEdge } from "./Drawer/GraphDrawerEdge";
+import { GraphDrawerCrn } from "./Drawer/GraphDrawerCrn";
+import './css/GrapDrawer.less';
export const GraphDrawer = ({ graphRef, isReady }) => {
- const [open, setOpen] = useState(false);
- const [init, setInit] = useState(false);
- const [nodeData, setNodeData] = useState(null);
- const [edgeData, setEdgeData] = useState(null);
- const [codeContent, setCodeContent] = useState(null);
-
- const showNodeDrawer = (graph, node) => {
- setOpen(true);
- setNodeData(node);
- if (node.data == null) {
- node.data = initNodeData;
- }
-
- if (node.data.codeContent != null) {
- setCodeContent(node.data.codeContent);
- }
- };
-
- const showEdgeDrawer = (graph, edge) => {
- setOpen(true);
- setEdgeData(edge);
- if (edge.data == null) {
- edge.data = initNodeData;
- }
-
- if (edge.data.codeContent != null) {
- setCodeContent(edge.data.codeContent);
- }
-
- if (edge.labels.length == 0) {
- edge.appendLabel({
- attrs: {
- label: {
- text: ""
- }
- }
- })
- }
-
- }
-
- const onNodeClose = (e) => {
- setOpen(false);
- setNodeData(null);
- setCodeContent(null);
- };
-
- const onEdgeClose = (e) => {
- setOpen(false);
- setEdgeData(null);
- setCodeContent(null);
- };
-
- const nodeTextAreaChange = (e) => {
- setCodeContent(e.target.value);
- nodeData.data.codeContent = e.target.value;
- }
-
- const edgeTextAreaChange = (e) => {
- setCodeContent(e.target.value);
- edgeData.data.codeContent = e.target.value;
- }
-
- const nodeDataInputChange = (e) => {
- nodeData.label = e.target.value;
- }
-
- const edgeDataInputChange = (e) => {
- edgeData.removeLabelAt(0);
- edgeData.appendLabel({
- attrs: {
- label: {
- text: e.target.value
- }
- }
- })
- edgeData.data.logicBool = e.target.value == 'true' ? true : false;
- }
-
- useEffect(() => {
- if (isReady) {
- const graph = graphRef.current;
-
- if (!init) {
- graph.on("node:dblclick", ({ node }) => {
- showNodeDrawer(graph, node);
- })
- graph.on("edge:dblclick", ({ edge }) => {
- showEdgeDrawer(graph, edge);
- })
- setInit(true);
- }
- }
- })
-
- if (nodeData) {
- return (
- <>
- <Drawer title={nodeData.label} onClose={onNodeClose} open={open} size="large">
- <div className="graphDrawerContainer">
- <div>ID锛歿nodeData.id}</div>
- <div>缁勪欢鍚嶏細<Input defaultValue={nodeData.label} onChange={nodeDataInputChange} /></div>
- <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={nodeData.data.root} /></div>
- <div>鍙墽琛屼唬鐮侊細</div>
- <TextArea value={codeContent} onChange={nodeTextAreaChange} rows={10} />
- </div>
- </Drawer>
- </>
- );
- } else if (edgeData) {
- return (
- <>
- <Drawer title={edgeData.label} onClose={onEdgeClose} open={open} size="large">
- <div className="graphDrawerContainer">
- <div>ID锛歿edgeData.id}</div>
- <div>灞炴�ц鎯咃細<Input defaultValue={edgeData.labels[0].attrs.label.text} onChange={edgeDataInputChange} /></div>
- <div>鏍硅妭鐐癸細<Switch checkedChildren="鏄�" unCheckedChildren="鍚�" checked={edgeData.data.root} /></div>
- <div>鍙墽琛屼唬鐮侊細</div>
- <TextArea value={codeContent} onChange={edgeTextAreaChange} rows={10} />
- </div>
- </Drawer>
- </>
- );
- }
+ return (
+ <>
+ <GraphDrawerNode graphRef={graphRef} isReady={isReady} />
+ <GraphDrawerEdge graphRef={graphRef} isReady={isReady} />
+ <GraphDrawerCrn graphRef={graphRef} isReady={isReady} />
+ </>
+ );
}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx b/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx
deleted file mode 100644
index 79c198a..0000000
--- a/zy-asrs-flow/src/components/Flow/GraphTools copy.jsx
+++ /dev/null
@@ -1,348 +0,0 @@
-import React, { useRef, useEffect, useState } from "react";
-import { Button, message } from 'antd';
-import { last } from "lodash";
-
-export const GraphTools = ({ graphRef, isReady }) => {
-
- let codeContent = "";
-
- const exportData = () => {
- const graph = graphRef.current;
- if (isReady) {
- const data = graph.toJSON();
- console.log(data);
- // 杩欓噷浣犲彲浠ュ皢鏁版嵁鍙戦�佸埌鏈嶅姟鍣ㄦ垨淇濆瓨鍒版湰鍦�
-
- const edges = [];
- const nodes = [];
- let rootNode = null;
- data.cells.forEach((item) => {
- if (item.shape == "edge") {
- edges.push(item)
- } else {
- nodes.push(item)
- if (item.data.root) {
- rootNode = item;
- }
- }
- })
-
- if (rootNode == null) {
- message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
- return;
- }
-
- console.log(getDescendants(rootNode, nodes, graph));
-
- transCode(rootNode, nodes, graph)
- // nodeDFS(rootNode, nodes, graph, codeContent)
- // console.log(codeContent);
- }
- }
-
- const transCode = (rootNode, nodes, graph) => {
- let codeContent = "";
- const descendants = [];
- let stack = [rootNode];
-
- let existLogicNode = [];
- let values = nodeDFS(rootNode, nodes, graph);
-
- let cpValues = JSON.parse(JSON.stringify(values))
- console.log(cpValues);
-
- let groupCode = {};
- let logicGroupSearch = [];
- let currentLogic = null;
- cpValues.forEach((value) => {
- if (value.data.isLogic) {
- let tmp = {};
- if (currentLogic == null) {
- tmp = {
- id: value.id,
- parent: null,
- currentCode: ""
- }
- } else {
- tmp = {
- id: value.id,
- parent: currentLogic,
- currentCode: ""
- }
- }
- currentLogic = value.id;
- logicGroupSearch.push(tmp);
- }
- })
-
- console.log(cpValues);
- console.log(logicGroupSearch);
-
- let codeContentTmp = "";
- while (values.length > 0) {
- const current = values.pop();
- const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
-
- connectedEdges.forEach((edge) => {
- //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
- if (edge.source.cell != current.id) {
- //鍙栦笂涓�鑺傜偣
- let lastNode = null;
- nodes.forEach((node) => {
- if (node.id == edge.source.cell) {
- lastNode = node;
- }
- })
-
- if (lastNode != null) {
- //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
- if (lastNode.data.isLogic) {
- let nestedCode = `
- //**********${current.attrs.text.text}-start**********//
- ${current.data.codeContent}
- //**********${current.attrs.text.text}-end**********//
- `;
- codeContentTmp = "\n" + nestedCode + codeContentTmp;
-
- let nestedIfCode = `
- ${codeContentTmp}
- `;
-
- if (groupCode[lastNode.id] == null) {
- groupCode[lastNode.id] = [{
- code: nestedIfCode,
- logicBool: edge.data.logicBool,
- condition: lastNode.data.codeContent
- }];
- } else {
- groupCode[lastNode.id].push({
- code: nestedIfCode,
- logicBool: edge.data.logicBool,
- condition: lastNode.data.codeContent
- });
- }
-
- codeContent += nestedIfCode;
- codeContentTmp = "";
-
- console.log(lastNode, current, true, codeContent);
- } else {
- if (current.data.codeContent != null && !current.data.isLogic) {
- let nestedCode = `
- //**********${current.attrs.text.text}-start**********//
- ${current.data.codeContent}
- //**********${current.attrs.text.text}-end**********//
- `;
- codeContentTmp = "\n" + nestedCode + codeContentTmp;
- }
- }
- }
- }
- })
-
- }
-
- for (let i = logicGroupSearch.length - 1; i >= 0; i--) {
- let logic = logicGroupSearch[i];
- let logicGroup = groupCode[logic.id];
-
- let logic1 = logicGroup[0];
- let nestedIfCode = "";
-
- if (logicGroup.length > 1) {
- let logic2 = logicGroup[0];
-
- if (logic1.logicBool) {
- nestedIfCode = `
- if (${logic1.condition}) {
- ${logic1.code}
- }else {
- ${logic2.code}
- }
- `;
- } else {
- nestedIfCode = `
- if (!(${logic1.condition})) {
- ${logic1.code}
- }else {
- ${logic2.code}
- }
- `;
- }
- }
-
- if (logic.parent != null) {
- logicGroupSearch.forEach((item) => {
- if (item.id == logic.parent) {
- item.currentCode += nestedIfCode;
- }
- })
- }
-
- console.log(logicGroupSearch,nestedIfCode);
- }
-
- console.log(groupCode);
- console.log(codeContent);
-
- }
-
- // const transCode = (rootNode, nodes, graph) => {
- // let codeContent = "";
- // const descendants = [];
- // let stack = [rootNode];
-
- // let count = 0;
- // while (stack.length > 0) {
- // const current = stack.pop();
- // descendants.push(current);
-
- // const children = getChildren(current, nodes, graph);
- // stack.push(...children);
-
- // // 杈撳嚭浠g爜
- // if (!current.data.isLogic) {
- // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
- // connectedEdges.forEach((edge) => {
- // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
- // if(edge.source.cell != current.id){
- // //鍙栦笂涓�鑺傜偣
- // let lastNode = null;
- // nodes.forEach((node) => {
- // if(node.id == edge.source.cell){
- // lastNode = node;
- // }
- // })
-
- // if(lastNode != null) {
- // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
- // if(lastNode.data.isLogic){
- // console.log(lastNode);
- // let nestedIfCode = "";
- // if(lastNode.data.logicBool == 'true') {
- // nestedIfCode = `
- // if (${lastNode.data.codeContent}) {
- // ${current.data.codeContent}
- // }
- // `;
- // }else{
- // nestedIfCode = `
- // if (!(${lastNode.data.codeContent})) {
- // ${current.data.codeContent}
- // }
- // `;
- // }
-
-
- // codeContent += "\n" + nestedIfCode;
- // console.log(codeContent);
- // }else{
- // if (current.data.codeContent != null) {
- // codeContent += "\n" + current.data.codeContent;
- // }
- // }
- // }
- // }
- // console.log(current);
- // })
- // } else {
- // // if (current.data.codeContent != null) {
- // // codeContent += "\n" + current.data.codeContent;
- // // }
-
- // // const connectedEdges = graph.getConnectedEdges(current);
- // // console.log(connectedEdges);
- // // stack = []
- // // let test = []
- // // connectedEdges.forEach((edge) => {
- // // nodes.forEach((item) => {
- // // if (item.id === edge.target.cell && item.id != current.id) {
- // // test.push(item);
- // // }
- // // })
- // // });
- // // console.log(test);
- // // console.log();
- // // let nestedIfCode = `
- // // if (true}) {
- // // ${current.data.codeContent}
- // // }
- // // `;
-
- // // codeContent += "\n" + nestedIfCode;
- // // console.log(codeContent);
- // }
-
- // }
-
- // console.log(codeContent);
- // }
-
- const nodeDFS = (node, nodes, graph) => {
- let values = [];
- if (graph) {
- const connectedEdges = graph.getConnectedEdges(node);
- const children = [];
-
- console.log(node);
- connectedEdges.forEach((edge) => {
- nodes.forEach((item) => {
- if (item.id === edge.target.cell && item.id != node.id) {
- children.push(item);
- }
- })
- });
-
- console.log(connectedEdges);
- if (children.length != 0) {
- console.log(children);
- children.forEach((node) => {
- console.log(node);
- values.push(node);
- values = values.concat(nodeDFS(node, nodes, graph))
- })
- }
- }
-
- return values;
- }
-
- const getChildren = (node, nodes, graph) => {
- const connectedEdges = graph.getConnectedEdges(node);
- const children = [];
-
- connectedEdges.forEach((edge) => {
- nodes.forEach((item) => {
- if (item.id === edge.target.cell && item.id != node.id) {
- children.push(item);
- }
- })
- });
-
- return children;
- }
-
- const getDescendants = (node, nodes, graph) => {
- const descendants = [];
- const stack = [node];
-
- let count = 0;
- while (stack.length > 0) {
- const current = stack.pop();
- descendants.push(current);
-
- const children = getChildren(current, nodes, graph);
- stack.push(...children);
- }
-
- return descendants;
- }
-
- return (
- <>
- <Button type="primary" onClick={exportData}>
- 瀵煎嚭鏁版嵁
- </Button>
- </>
- );
-}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools.jsx b/zy-asrs-flow/src/components/Flow/GraphTools.jsx
index e8d6518..e93b74b 100644
--- a/zy-asrs-flow/src/components/Flow/GraphTools.jsx
+++ b/zy-asrs-flow/src/components/Flow/GraphTools.jsx
@@ -2,7 +2,8 @@
import { Button, message, Modal } from 'antd';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { solarizedlight } from 'react-syntax-highlighter/dist/esm/styles/prism';
-import './GraphTools.less'
+import { exportDataToServer } from "../../services/flow/api";
+import './css/GraphTools.less'
export const GraphTools = ({ graphRef, isReady }) => {
@@ -76,15 +77,16 @@
return;
}
- console.log(getDescendants(rootNode, nodes, graph));
-
- const codeContent = transCode(rootNode, nodes, graph)
- console.log(codeContent);
+ let result = sortNodes(rootNode, nodes, graph);
+ exportDataToServer({
+ data: result
+ }).then((res) => {
+ console.log(res);
+ })
}
}
- const transCode = (rootNode, nodes, graph) => {
- let codeContent = "";
+ const sortNodes = (rootNode, nodes, graph) => {
let values = nodeDFS(rootNode, nodes, graph);
const searchNode = {
id: 1,
@@ -93,7 +95,6 @@
};
let cpValues = JSON.parse(JSON.stringify(values))
- console.log(cpValues);
let searchIndex = 0;
cpValues.forEach((value) => {
@@ -131,6 +132,56 @@
}
})
+ return cpValues;
+ }
+
+ const transCode = (rootNode, nodes, graph) => {
+ let codeContent = "";
+
+ let values = nodeDFS(rootNode, nodes, graph);
+ const searchNode = {
+ id: 1,
+ parent: null,
+ logicBool: true
+ };
+
+ let cpValues = JSON.parse(JSON.stringify(values))
+
+ let searchIndex = 0;
+ cpValues.forEach((value) => {
+ if (value.data.isLogic) {
+ value.data.searchLogicId = searchNode.id;
+ value.data.searchLogicBool = searchNode.logicBool;
+ value.data.searchIndex = searchIndex++;
+
+ let tmpSearchNode = JSON.parse(JSON.stringify(searchNode))
+ searchNode.parent = tmpSearchNode;
+ searchNode.id = value.id;
+ searchNode.logicBool = null;
+ searchIndex = 0;
+ } else {
+ let id = searchNode.id;
+ let logicBool = searchNode.logicBool;
+
+ const connectedEdges = graph.getConnectedEdges(value);//鍙栬竟
+ connectedEdges.forEach((edge) => {
+ let tmpSearchNode = JSON.parse(JSON.stringify(searchNode));
+ while (tmpSearchNode.parent != null) {
+ if (edge.source.cell == tmpSearchNode.id) {
+ logicBool = edge.data.logicBool;//鏇存柊鏂瑰悜
+ searchNode.logicBool = edge.data.logicBool;
+ id = tmpSearchNode.id;
+ break;
+ }
+ tmpSearchNode = tmpSearchNode.parent;
+ }
+ })
+
+ value.data.searchLogicId = id;
+ value.data.searchLogicBool = logicBool;
+ value.data.searchIndex = searchIndex++;
+ }
+ })
console.log(cpValues);
console.log(searchNode);
@@ -197,6 +248,8 @@
obj.id = key;
sortTmp[tmp[key].index] = obj;
}
+
+ console.log(sortTmp);
// 鍚堝苟True鍜孎alse
sortTmp.forEach((item) => {
@@ -287,104 +340,13 @@
return formattedCode;
}
- // const transCode = (rootNode, nodes, graph) => {
- // let codeContent = "";
- // const descendants = [];
- // let stack = [rootNode];
-
- // let count = 0;
- // while (stack.length > 0) {
- // const current = stack.pop();
- // descendants.push(current);
-
- // const children = getChildren(current, nodes, graph);
- // stack.push(...children);
-
- // // 杈撳嚭浠g爜
- // if (!current.data.isLogic) {
- // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
- // connectedEdges.forEach((edge) => {
- // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
- // if(edge.source.cell != current.id){
- // //鍙栦笂涓�鑺傜偣
- // let lastNode = null;
- // nodes.forEach((node) => {
- // if(node.id == edge.source.cell){
- // lastNode = node;
- // }
- // })
-
- // if(lastNode != null) {
- // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
- // if(lastNode.data.isLogic){
- // console.log(lastNode);
- // let nestedIfCode = "";
- // if(lastNode.data.logicBool == 'true') {
- // nestedIfCode = `
- // if (${lastNode.data.codeContent}) {
- // ${current.data.codeContent}
- // }
- // `;
- // }else{
- // nestedIfCode = `
- // if (!(${lastNode.data.codeContent})) {
- // ${current.data.codeContent}
- // }
- // `;
- // }
-
-
- // codeContent += "\n" + nestedIfCode;
- // console.log(codeContent);
- // }else{
- // if (current.data.codeContent != null) {
- // codeContent += "\n" + current.data.codeContent;
- // }
- // }
- // }
- // }
- // console.log(current);
- // })
- // } else {
- // // if (current.data.codeContent != null) {
- // // codeContent += "\n" + current.data.codeContent;
- // // }
-
- // // const connectedEdges = graph.getConnectedEdges(current);
- // // console.log(connectedEdges);
- // // stack = []
- // // let test = []
- // // connectedEdges.forEach((edge) => {
- // // nodes.forEach((item) => {
- // // if (item.id === edge.target.cell && item.id != current.id) {
- // // test.push(item);
- // // }
- // // })
- // // });
- // // console.log(test);
- // // console.log();
- // // let nestedIfCode = `
- // // if (true}) {
- // // ${current.data.codeContent}
- // // }
- // // `;
-
- // // codeContent += "\n" + nestedIfCode;
- // // console.log(codeContent);
- // }
-
- // }
-
- // console.log(codeContent);
- // }
-
const nodeDFS = (node, nodes, graph) => {
let values = [];
if (graph) {
const connectedEdges = graph.getConnectedEdges(node);
const children = [];
- console.log(node);
+ // console.log(node);
connectedEdges.forEach((edge) => {
nodes.forEach((item) => {
if (item.id === edge.target.cell && item.id != node.id) {
@@ -393,11 +355,11 @@
})
});
- console.log(connectedEdges);
+ // console.log(connectedEdges);
if (children.length != 0) {
- console.log(children);
+ // console.log(children);
children.forEach((node) => {
- console.log(node);
+ // console.log(node);
values.push(node);
values = values.concat(nodeDFS(node, nodes, graph))
})
@@ -450,7 +412,7 @@
</Button>
</div>
- <Modal title="Basic Modal" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
+ <Modal title="棰勮浠g爜" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
<SyntaxHighlighter language="java" style={solarizedlight}>
{preCode}
</SyntaxHighlighter>
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools2.jsx b/zy-asrs-flow/src/components/Flow/GraphTools2.jsx
deleted file mode 100644
index caf08bf..0000000
--- a/zy-asrs-flow/src/components/Flow/GraphTools2.jsx
+++ /dev/null
@@ -1,323 +0,0 @@
-import React, { useRef, useEffect, useState } from "react";
-import { Button, message } from 'antd';
-import { last } from "lodash";
-
-export const GraphTools = ({ graphRef, isReady }) => {
-
- let codeContent = "";
-
- const exportData = () => {
- const graph = graphRef.current;
- if (isReady) {
- const data = graph.toJSON();
- console.log(data);
- // 杩欓噷浣犲彲浠ュ皢鏁版嵁鍙戦�佸埌鏈嶅姟鍣ㄦ垨淇濆瓨鍒版湰鍦�
-
- const edges = [];
- const nodes = [];
- let rootNode = null;
- data.cells.forEach((item) => {
- if (item.shape == "edge") {
- edges.push(item)
- } else {
- nodes.push(item)
- if (item.data.root) {
- rootNode = item;
- }
- }
- })
-
- if (rootNode == null) {
- message.warning('璇疯缃▼搴忓叆鍙g粍浠�');
- return;
- }
-
- console.log(getDescendants(rootNode, nodes, graph));
-
- transCode(rootNode, nodes, graph)
- // nodeDFS(rootNode, nodes, graph, codeContent)
- // console.log(codeContent);
- }
- }
-
- const transCode = (rootNode, nodes, graph) => {
- let codeContent = "";
- const descendants = [];
- let stack = [rootNode];
-
- let existLogicNode = [];
- let values = nodeDFS(rootNode, nodes, graph);
-
- let cpValues = JSON.parse(JSON.stringify(values))
- console.log(cpValues);
-
- let groupCode = {};
- let logicGroupSearch = {};
- let currentLogic = null;
- cpValues.forEach((value) => {
- if(value.data.isLogic) {
- let tmp = {};
- if(currentLogic == null) {
- tmp = {
- id: value.id,
- parent: null
- }
- }else{
- tmp = {
- id: value.id,
- parent: currentLogic
- }
- }
- currentLogic = value.id;
- logicGroupSearch[value.id] = tmp;
- }
- })
-
- console.log(logicGroupSearch);
-
- let codeContentTmp = "";
- while (values.length > 0) {
- const current = values.pop();
- const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
-
- connectedEdges.forEach((edge) => {
- //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
- if (edge.source.cell != current.id) {
- //鍙栦笂涓�鑺傜偣
- let lastNode = null;
- nodes.forEach((node) => {
- if (node.id == edge.source.cell) {
- lastNode = node;
- }
- })
-
- if (lastNode != null) {
- //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
- if (lastNode.data.isLogic) {
- let nestedCode = `
- //**********${current.attrs.text.text}-start**********//
- ${current.data.codeContent}
- //**********${current.attrs.text.text}-end**********//
- `;
- codeContentTmp = "\n" + nestedCode + codeContentTmp;
-
- let nestedIfCode = "";
- if (existLogicNode.indexOf(lastNode.id) == -1) {
- //鍒ゆ柇杈归�昏緫鍊�
- if (edge.data.logicBool == true) {
- nestedIfCode = `
- //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
- if (${lastNode.data.codeContent}) {
- ${codeContentTmp}
- // }
- // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
- `;
- } else {
- nestedIfCode = `
- //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
- if (!(${lastNode.data.codeContent})) {
- ${codeContentTmp}
- // }
- // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
- `;
- }
- existLogicNode.push(lastNode.id);
-
- groupCode[lastNode.id + "-true"] = nestedIfCode;
- } else {
- nestedIfCode = `
- //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-start**********//
- else {
- ${codeContentTmp}
- // }
- // //**********閫昏緫鍒ゆ柇-${lastNode.attrs.text.text}-end**********//
- `;
-
- groupCode[lastNode.id + "-false"] = nestedIfCode;
- }
-
-
- codeContent += nestedIfCode;
- codeContentTmp = "";
-
- console.log(lastNode, current, true, codeContent);
- } else {
- if (current.data.codeContent != null && !current.data.isLogic) {
- let nestedCode = `
- //**********${current.attrs.text.text}-start**********//
- ${current.data.codeContent}
- //**********${current.attrs.text.text}-end**********//
- `;
- codeContentTmp = "\n" + nestedCode + codeContentTmp;
- }
- }
- }
- }
- })
-
- }
-
- console.log(groupCode);
- console.log(codeContent);
-
- }
-
- // const transCode = (rootNode, nodes, graph) => {
- // let codeContent = "";
- // const descendants = [];
- // let stack = [rootNode];
-
- // let count = 0;
- // while (stack.length > 0) {
- // const current = stack.pop();
- // descendants.push(current);
-
- // const children = getChildren(current, nodes, graph);
- // stack.push(...children);
-
- // // 杈撳嚭浠g爜
- // if (!current.data.isLogic) {
- // const connectedEdges = graph.getConnectedEdges(current);//鍙栬竟
- // connectedEdges.forEach((edge) => {
- // //杩囨护浠庤嚜韬妭鐐瑰嚭鍘荤殑杈�
- // if(edge.source.cell != current.id){
- // //鍙栦笂涓�鑺傜偣
- // let lastNode = null;
- // nodes.forEach((node) => {
- // if(node.id == edge.source.cell){
- // lastNode = node;
- // }
- // })
-
- // if(lastNode != null) {
- // //鍒ゆ柇鑺傜偣鏄惁閫昏緫鑺傜偣
- // if(lastNode.data.isLogic){
- // console.log(lastNode);
- // let nestedIfCode = "";
- // if(lastNode.data.logicBool == 'true') {
- // nestedIfCode = `
- // if (${lastNode.data.codeContent}) {
- // ${current.data.codeContent}
- // }
- // `;
- // }else{
- // nestedIfCode = `
- // if (!(${lastNode.data.codeContent})) {
- // ${current.data.codeContent}
- // }
- // `;
- // }
-
-
- // codeContent += "\n" + nestedIfCode;
- // console.log(codeContent);
- // }else{
- // if (current.data.codeContent != null) {
- // codeContent += "\n" + current.data.codeContent;
- // }
- // }
- // }
- // }
- // console.log(current);
- // })
- // } else {
- // // if (current.data.codeContent != null) {
- // // codeContent += "\n" + current.data.codeContent;
- // // }
-
- // // const connectedEdges = graph.getConnectedEdges(current);
- // // console.log(connectedEdges);
- // // stack = []
- // // let test = []
- // // connectedEdges.forEach((edge) => {
- // // nodes.forEach((item) => {
- // // if (item.id === edge.target.cell && item.id != current.id) {
- // // test.push(item);
- // // }
- // // })
- // // });
- // // console.log(test);
- // // console.log();
- // // let nestedIfCode = `
- // // if (true}) {
- // // ${current.data.codeContent}
- // // }
- // // `;
-
- // // codeContent += "\n" + nestedIfCode;
- // // console.log(codeContent);
- // }
-
- // }
-
- // console.log(codeContent);
- // }
-
- const nodeDFS = (node, nodes, graph) => {
- let values = [];
- if (graph) {
- const connectedEdges = graph.getConnectedEdges(node);
- const children = [];
-
- console.log(node);
- connectedEdges.forEach((edge) => {
- nodes.forEach((item) => {
- if (item.id === edge.target.cell && item.id != node.id) {
- children.push(item);
- }
- })
- });
-
- console.log(connectedEdges);
- if (children.length != 0) {
- console.log(children);
- children.forEach((node) => {
- console.log(node);
- values.push(node);
- values = values.concat(nodeDFS(node, nodes, graph))
- })
- }
- }
-
- return values;
- }
-
- const getChildren = (node, nodes, graph) => {
- const connectedEdges = graph.getConnectedEdges(node);
- const children = [];
-
- connectedEdges.forEach((edge) => {
- nodes.forEach((item) => {
- if (item.id === edge.target.cell && item.id != node.id) {
- children.push(item);
- }
- })
- });
-
- return children;
- }
-
- const getDescendants = (node, nodes, graph) => {
- const descendants = [];
- const stack = [node];
-
- let count = 0;
- while (stack.length > 0) {
- const current = stack.pop();
- descendants.push(current);
-
- const children = getChildren(current, nodes, graph);
- stack.push(...children);
- }
-
- return descendants;
- }
-
- return (
- <>
- <Button type="primary" onClick={exportData}>
- 瀵煎嚭鏁版嵁
- </Button>
- </>
- );
-}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/StencilComponent.jsx b/zy-asrs-flow/src/components/Flow/StencilComponent.jsx
deleted file mode 100644
index bc6f7a7..0000000
--- a/zy-asrs-flow/src/components/Flow/StencilComponent.jsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import React, { useRef, useEffect } from "react";
-import { Stencil } from '@antv/x6-plugin-stencil';
-
-export const StencilComponent = (({ graphRef, isReady, stencilContainer }) => {
-
- useEffect(() => {
- if (isReady) {
- const graph = graphRef.current;
-
- const stencil = new Stencil({
- title: 'Stencil',
- target: graphRef.current,
- search(cell, keyword) {
- return cell.shape.indexOf(keyword) !== -1
- },
- placeholder: 'Search by shape name',
- notFoundText: 'Not Found',
- collapsable: true,
- stencilGraphHeight: 0,
- groups: [
- {
- name: 'group1',
- title: 'Group(Collapsable)',
- },
- {
- name: 'group2',
- title: 'Group',
- collapsable: false,
- },
- ],
- })
-
- stencilContainer.current.appendChild(stencil.container)
-
- const commonAttrs = {
- body: {
- fill: '#fff',
- stroke: '#8f8f8f',
- strokeWidth: 1,
- },
- }
-
- const n1 = graph.createNode({
- shape: 'rect',
- x: 40,
- y: 40,
- width: 80,
- height: 40,
- label: 'rect',
- attrs: commonAttrs,
- })
-
- const n2 = graph.createNode({
- shape: 'circle',
- x: 180,
- y: 40,
- width: 40,
- height: 40,
- label: 'circle',
- attrs: commonAttrs,
- })
-
- const n3 = graph.createNode({
- shape: 'ellipse',
- x: 280,
- y: 40,
- width: 80,
- height: 40,
- label: 'ellipse',
- attrs: commonAttrs,
- })
-
- const n4 = graph.createNode({
- shape: 'path',
- x: 420,
- y: 40,
- width: 40,
- height: 40,
- // https://www.svgrepo.com/svg/13653/like
- path: 'M24.85,10.126c2.018-4.783,6.628-8.125,11.99-8.125c7.223,0,12.425,6.179,13.079,13.543c0,0,0.353,1.828-0.424,5.119c-1.058,4.482-3.545,8.464-6.898,11.503L24.85,48L7.402,32.165c-3.353-3.038-5.84-7.021-6.898-11.503c-0.777-3.291-0.424-5.119-0.424-5.119C0.734,8.179,5.936,2,13.159,2C18.522,2,22.832,5.343,24.85,10.126z',
- attrs: commonAttrs,
- label: 'path123',
- })
-
- stencil.load([n1, n2], 'group1')
- stencil.load([n3, n4], 'group2')
- }
-
- })
-
- return <div className="app-stencil" ref={stencilContainer} />
-})
\ No newline at end of file
diff --git a/zy-asrs-flow/src/components/Flow/GrapDrawer.less b/zy-asrs-flow/src/components/Flow/css/GrapDrawer.less
similarity index 100%
rename from zy-asrs-flow/src/components/Flow/GrapDrawer.less
rename to zy-asrs-flow/src/components/Flow/css/GrapDrawer.less
diff --git a/zy-asrs-flow/src/components/Flow/GraphTools.less b/zy-asrs-flow/src/components/Flow/css/GraphTools.less
similarity index 100%
rename from zy-asrs-flow/src/components/Flow/GraphTools.less
rename to zy-asrs-flow/src/components/Flow/css/GraphTools.less
diff --git a/zy-asrs-flow/src/config/setting.ts b/zy-asrs-flow/src/config/setting.ts
index d1e75bd..32a86f4 100644
--- a/zy-asrs-flow/src/config/setting.ts
+++ b/zy-asrs-flow/src/config/setting.ts
@@ -1,5 +1,5 @@
// 鎺ュ彛鍦板潃
-export const API_BASE_URL: string = 'http://192.168.4.113:9090/wcs';
+export const API_BASE_URL: string = 'http://127.0.0.1:9090/wcs';
// 椤圭洰鍚嶇О
export const PROJECT_NAME: string = 'admin';
diff --git a/zy-asrs-flow/src/services/flow/api.js b/zy-asrs-flow/src/services/flow/api.js
new file mode 100644
index 0000000..cf227e5
--- /dev/null
+++ b/zy-asrs-flow/src/services/flow/api.js
@@ -0,0 +1,9 @@
+import { request } from '@umijs/max';
+import React from 'react';
+
+export function exportDataToServer(data) {
+ return request('/flow/analysisExportData', {
+ data: data,
+ method: 'POST'
+ });
+}
\ No newline at end of file
diff --git a/zy-asrs-flow/src/services/route.js b/zy-asrs-flow/src/services/route.js
index 0b5a631..979bb36 100644
--- a/zy-asrs-flow/src/services/route.js
+++ b/zy-asrs-flow/src/services/route.js
@@ -26,6 +26,7 @@
export async function getRoutersInfo() {
return getRouters().then((res) => {
+ console.log(res);
if (res.code === 200) {
// return res.data;
const routersInfo = convertCompatRouters(res.data);
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/controller/FlowController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/controller/FlowController.java
new file mode 100644
index 0000000..441ea98
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/controller/FlowController.java
@@ -0,0 +1,68 @@
+package com.zy.asrs.wcs.asrs.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.asrs.framework.common.R;
+import com.zy.asrs.wcs.asrs.entity.param.FlowLogicCodeParam;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+@RestController
+@RequestMapping("/flow")
+public class FlowController {
+
+ @PostMapping("/analysisExportData")
+ public R analysisExportData(@RequestBody HashMap<String, Object> param) {
+ System.out.println(param);
+ List<LinkedHashMap<String, Object>> data = (List<LinkedHashMap<String, Object>>) param.get("data");
+
+ ArrayList<FlowLogicCodeParam> list = new ArrayList<>();
+
+ FlowLogicCodeParam first = new FlowLogicCodeParam();
+ first.setId("1");
+ list.add(first);
+ for (LinkedHashMap<String, Object> map : data) {
+ LinkedHashMap<String, Object> mapData = (LinkedHashMap<String, Object>) map.get("data");
+ String id = map.get("id").toString();
+ Boolean isLogic = Boolean.parseBoolean(mapData.get("isLogic").toString());
+ String searchLogicId = mapData.get("searchLogicId").toString();
+ Boolean searchLogicBool = Boolean.parseBoolean(mapData.get("searchLogicBool").toString());
+ String codeContent = mapData.get("codeContent").toString();
+ if (isLogic) {
+ FlowLogicCodeParam flowLogicCodeParam = new FlowLogicCodeParam();
+ flowLogicCodeParam.setId(id);
+ flowLogicCodeParam.setLogic(codeContent);
+
+ FlowLogicCodeParam last = list.get(list.size() - 1);
+ if (searchLogicBool) {
+ last.getLogicTrue().add(map);
+ }else {
+ last.getLogicFalse().add(map);
+ }
+
+ list.add(flowLogicCodeParam);
+ }else {
+ for (FlowLogicCodeParam codeParam : list) {
+ if (codeParam.getId().equals(searchLogicId)) {
+ if (searchLogicBool) {
+ codeParam.getLogicTrue().add(map);
+ }else {
+ codeParam.getLogicFalse().add(map);
+ }
+ }
+ }
+ }
+
+ }
+
+ System.out.println(list);
+
+ return R.ok();
+ }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/entity/param/FlowLogicCodeParam.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/entity/param/FlowLogicCodeParam.java
new file mode 100644
index 0000000..eda5b53
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/asrs/entity/param/FlowLogicCodeParam.java
@@ -0,0 +1,20 @@
+package com.zy.asrs.wcs.asrs.entity.param;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class FlowLogicCodeParam {
+
+ private String id;
+
+ private String logic;
+
+ private List<Map<String, Object>> logicTrue = new ArrayList<>();
+
+ private List<Map<String, Object>> logicFalse = new ArrayList<>();
+
+}
diff --git a/zy-asrs-wcs/src/main/resources/application.yml b/zy-asrs-wcs/src/main/resources/application.yml
index 149e9c7..ee9ebac 100644
--- a/zy-asrs-wcs/src/main/resources/application.yml
+++ b/zy-asrs-wcs/src/main/resources/application.yml
@@ -18,7 +18,7 @@
# password: zy@123
url: jdbc:mysql://127.0.0.1:3306/asrs?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
- password: xltys1995
+ password: root
# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://47.97.1.152:51433;databasename=jkasrs
# username: sa
--
Gitblit v1.9.1