+
+
+
@@ -452,7 +455,7 @@ export default {
this.selectedNodeParamsTimeout = setTimeout(() => {
selectedNodeModel.label = newVal.label
selectedNodeModel.appConfig = newVal.appConfig
- selectedNodeModel.attrs = newVal.attrs
+ selectedNodeModel.columns = newVal.columns
try {
this.selectedNode.update(selectedNodeModel)
}catch (e) {
@@ -516,21 +519,21 @@ export default {
methods: {
//todo
ucTypeChang(index, row) {
- console.log(typeof this.selectedNodeParams.attrs[index].ucMock)
+ console.log(typeof this.selectedNodeParams.columns[index].ucMock)
if (row.ucType == 'input' && row.ucCon != 'BETWEEN') {
- this.selectedNodeParams.attrs[index].type = 1
- if (typeof (this.selectedNodeParams.attrs[index].ucMock) != 'string') {
- this.selectedNodeParams.attrs[index].ucMock = ''
+ this.selectedNodeParams.columns[index].type = 1
+ if (typeof (this.selectedNodeParams.columns[index].ucMock) != 'string') {
+ this.selectedNodeParams.columns[index].ucMock = ''
}
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
- this.selectedNodeParams.attrs[index].type = 2
- this.selectedNodeParams.attrs[index].ucMock = {begin: '', end: ''}
+ this.selectedNodeParams.columns[index].type = 2
+ this.selectedNodeParams.columns[index].ucMock = {begin: '', end: ''}
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
- this.selectedNodeParams.attrs[index].type = 3
- this.selectedNodeParams.attrs[index].ucMock = ''
+ this.selectedNodeParams.columns[index].type = 3
+ this.selectedNodeParams.columns[index].ucMock = ''
} else if (row.ucType == 'datetime' && row.ucCon == 'BETWEEN') {
- this.selectedNodeParams.attrs[index].type = 4
- this.selectedNodeParams.attrs[index].ucMock = []
+ this.selectedNodeParams.columns[index].type = 4
+ this.selectedNodeParams.columns[index].ucMock = []
}
},
@@ -1196,16 +1199,16 @@ export default {
// 开始添加
if (starts){
let droppoint = graph.getPointByClient(clientX, clientY)
- let column = []
+ let columns = []
for (let i = 0; i < nodeType.topSearchColumnList.length; i++) {
let item = nodeType.topSearchColumnList[i]
if (item.isUse === 1) {
item.isQuery = 0
- item.ucCon = null
- item.ucType = null
+ item.ucCon = ''
+ item.ucType = ''
item.type = 1
- item.ucMock = null
- column.push(item)
+ item.ucMock = ''
+ columns.push(item)
}
}
@@ -1221,7 +1224,7 @@ export default {
tableId: nodeType.id,
table: nodeType.tableName,
type: 'dice-er-box',
- column: column,
+ columns: columns,
size: [300, 500],
width: 250,
height: 316,
diff --git a/ebts-ui/src/views/tool/top/packages/topology/src/utils/collapse/move.js b/ebts-ui/src/views/tool/top/packages/topology/src/utils/collapse/move.js
deleted file mode 100644
index 139e6d3..0000000
--- a/ebts-ui/src/views/tool/top/packages/topology/src/utils/collapse/move.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * @author: clay
- * @data: 2021/5/11 17:33
- * @email: clay@hchyun.com
- * @description: node
- */
-export default function(e){
- e.preventDefault();
- const {
- graph
- } = this;
- const nodes = graph.getNodes().filter((n) => {
- const bbox = n.getBBox();
-
- return isInBBox(graph.getPointByClient(e.clientX, e.clientY), bbox);
- });
- if (nodes) {
- nodes.forEach((node) => {
- const model = node.getModel();
- if (model.attrs.length < 9) {
- return;
- }
- const idx = model.startIndex || 0;
- let startX = model.startX || 0.5;
- let startIndex = idx + e.deltaY * 0.02;
- startX -= e.deltaX;
- if (startIndex < 0) {
- startIndex = 0;
- }
- if (startX > 0) {
- startX = 0;
- }
- if (startIndex > model.attrs.length - 1) {
- startIndex = model.attrs.length - 1;
- }
- graph.update(node, {
- startIndex,
- startX,
- });
- });
- }
-}
-const isInBBox = (point, bbox) => {
- const {
- x,
- y
- } = point;
- const {
- minX,
- minY,
- maxX,
- maxY
- } = bbox;
-
- return x < maxX && x > minX && y > minY && y < maxY;
-};
-
diff --git a/ebts-ui/src/views/tool/top/topology.vue b/ebts-ui/src/views/tool/top/topology.vue
index 550ee95..2aae4a0 100644
--- a/ebts-ui/src/views/tool/top/topology.vue
+++ b/ebts-ui/src/views/tool/top/topology.vue
@@ -145,7 +145,14 @@ export default {
this.topId = this.$route.params && this.$route.params.topId;
getQuery(this.topId).then(res =>{
this.baseData = res.data
- this.graphData = JSON.parse(res.data.topJson)
+ if (res.data.topJson){
+ this.graphData = JSON.parse(res.data.topJson)
+ }else {
+ this.graphData ={
+ nodes:[],
+ edges:[]
+ }
+ }
let graphData = deepClone(this.graphData)
this.$refs.topology.initTopo(graphData)
this.randomChange()
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopEdge.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopEdge.java
new file mode 100644
index 0000000..325310e
--- /dev/null
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopEdge.java
@@ -0,0 +1,81 @@
+package com.ebts.generator.entity;
+
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ * @author: Clay
+ * @date: 2021/7/26 16:04
+ * @description:TopEdge
+ * @email: clay@hchyun.com
+ */
+public class TopEdge {
+
+
+ private String id;
+ private String source;
+ private String sourceEdge;
+ private String target;
+ private String targetEdge;
+ private JSONObject appConfig;
+
+
+
+
+ public TopEdge() {
+ }
+
+ public TopEdge(String id,String source, String target, JSONObject appConfig) {
+ this.id = id;
+ this.source = source;
+ this.target = target;
+ this.appConfig = appConfig;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getSourceEdge() {
+ return sourceEdge;
+ }
+
+ public void setSourceEdge(String sourceEdge) {
+ this.sourceEdge = sourceEdge;
+ }
+
+ public String getTargetEdge() {
+ return targetEdge;
+ }
+
+ public void setTargetEdge(String targetEdge) {
+ this.targetEdge = targetEdge;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public JSONObject getAppConfig() {
+ return appConfig;
+ }
+
+ public void setAppConfig(JSONObject appConfig) {
+ this.appConfig = appConfig;
+ }
+}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopNode.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopNode.java
new file mode 100644
index 0000000..7974a2c
--- /dev/null
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/entity/TopNode.java
@@ -0,0 +1,121 @@
+package com.ebts.generator.entity;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.ebts.common.utils.StringUtils;
+
+/**
+ * @author: Clay
+ * @date: 2021/7/26 17:26
+ * @description:TopNode
+ * @email: clay@hchyun.com
+ */
+public class TopNode {
+ private String id;
+ private String table;
+ private String relTable;
+ private StringBuffer tableSQL = new StringBuffer(" ");
+ private StringBuffer conditions = new StringBuffer();
+ private JSONArray columns;
+
+ public String getConditions() {
+ return conditions.toString();
+ }
+
+ public String getRelTable() {
+ return relTable;
+ }
+
+ public String getTableSQL() {
+ return tableSQL.toString();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTable() {
+ return table;
+ }
+
+ public void setTable(String table) {
+ this.table = table;
+ this.relTable = StringUtils.sqlFormat(table);
+ boolean start = false;
+ for (int i = 0; i < this.columns.size(); i++) {
+ JSONObject column = this.columns.getJSONObject(i);
+ if (column.getInteger("isUse") == 1) {
+ if (start) {
+ tableSQL.append(", ");
+ }
+ tableSQL.append(this.relTable).append(".").append(column.getString("columnName"));
+ if (StringUtils.isNotNull(column.getString("columnComment"))) {
+ tableSQL.append(" as ").append("'").append(column.getString("columnComment")).append("'");
+ }
+ start = true;
+ }
+
+ if (column.getInteger("isQuery") == 1 ) {
+ String sql = " and " + relTable + "." + column.getString("columnName");
+ switch (column.getString("ucCon")) {
+ case "EQ":
+ sql += " = '" + column.getString("ucMock") + "'";
+ break;
+ case "NE":
+ sql += " != '" + column.getString("ucMock") + "'";
+ break;
+ case "GT":
+ sql += " > '" + column.getString("ucMock") + "'";
+ break;
+ case "GTE":
+ sql += " >= '" + column.getString("ucMock") + "'";
+ break;
+ case "LT":
+ sql += " < '" + column.getString("ucMock") + "'";
+ break;
+ case "LTE":
+ sql += " <= '" + column.getString("ucMock") + "'";
+ break;
+ case "LIKE":
+ sql += " like '%" + column.getString("ucMock") + "%'";
+ break;
+ case "BETWEEN":
+ try {
+ JSONObject jsonObject = JSONObject.parseObject(column.getString("ucMock"));
+ if ("input".equals(column.getString("ucType"))) {
+ Object begin = jsonObject.get("begin");
+ Object end = jsonObject.get("end");
+ if (begin != null && end != null) {
+ sql += " between '" + begin + "' AND '" + end + "'";
+ } else {
+ sql = "";
+ }
+ } else if ("datetime".equals(column.getString("ucType"))) {
+ Object startTime = jsonObject.get("startTime");
+ Object endTime = jsonObject.get("endTime");
+ sql += " between '" + startTime + "' AND '" + endTime + "'";
+ }
+ } catch (RuntimeException e) {
+ sql = "";
+ }
+ break;
+ }
+ conditions.append(sql);
+ }
+ }
+ }
+
+ public JSONArray getColumns() {
+ return columns;
+ }
+
+ public void setColumns(JSONArray columns) {
+ this.columns = columns;
+ }
+
+
+}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/TopQueryServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/TopQueryServiceImpl.java
index d741d22..07592c5 100644
--- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/TopQueryServiceImpl.java
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/TopQueryServiceImpl.java
@@ -9,12 +9,15 @@ import com.ebts.generator.dao.QueryDao;
import com.ebts.generator.dao.RelationalMapDao;
import com.ebts.generator.dao.TopSearchTableDao;
import com.ebts.generator.entity.RelationalMap;
+import com.ebts.generator.entity.TopEdge;
+import com.ebts.generator.entity.TopNode;
import com.ebts.generator.service.TopQueryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,6 +31,7 @@ import java.util.Map;
@Service
public class TopQueryServiceImpl implements TopQueryService {
private final Logger logger = LoggerFactory.getLogger(TopQueryServiceImpl.class);
+ private int index = 0;
@Autowired
private TopSearchTableDao topSearchTableDao;
@@ -49,37 +53,171 @@ public class TopQueryServiceImpl implements TopQueryService {
try {
JSONObject graphData = JSON.parseObject(jsonData);
- JSONArray nodes = graphData.getJSONArray("nodes");
- JSONArray edges = graphData.getJSONArray("edges");
- JSONObject node = nodes.getJSONObject(0);
-
- StringBuffer sql = new StringBuffer("select ");
-
- JSONArray attrs = node.getJSONArray("attrs");
- boolean start = false;
- for (int i = 0; i < attrs.size(); i++) {
- JSONObject column = attrs.getJSONObject(i);
- if (column.getInteger("isUse") == 1) {
- if (start) {
- sql.append(", ");
+ List topEdges = JSON.parseArray(graphData.getString("edges"), TopEdge.class);
+ List topNodes = JSON.parseArray(graphData.getString("nodes"), TopNode.class);
+ System.out.println(topNodes);
+ for (int i = 0; i < topEdges.size(); i++) {
+ for (int j = 0; j < topEdges.size(); j++) {
+ if (i != j) {
+ TopEdge topEdgeJ = topEdges.get(j);
+ if (topEdges.get(i).getSource().equals(topEdgeJ.getTarget())) {
+ topEdges.get(i).setSourceEdge(topEdgeJ.getId());
+ }
+// if (topEdges.get(i).getTarget().equals(topEdgeJ.getSource())) {
+// topEdges.get(i).setTargetEdge(topEdgeJ.getId());
+// }
}
- sql.append(column.getString("columnName"));
- if (StringUtils.isNotNull(column.getString("columnComment"))){
- sql.append(" as ");
- sql.append("'" + column.getString("columnComment") + "'");
- }
- start=true;
}
}
- sql.append(" from " + node.getString("table"));
- System.out.println(sql.toString());
- List