From efce7ce3e63712ecc8b4c3039a73b508fc3ea880 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期一, 28 四月 2025 10:20:37 +0800
Subject: [PATCH] 修改

---
 src/main/java/com/example/server/progressTrack/service/NetWorkDiagramService.java |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/example/server/progressTrack/service/NetWorkDiagramService.java b/src/main/java/com/example/server/progressTrack/service/NetWorkDiagramService.java
index 78a5b2a..4cc3de7 100644
--- a/src/main/java/com/example/server/progressTrack/service/NetWorkDiagramService.java
+++ b/src/main/java/com/example/server/progressTrack/service/NetWorkDiagramService.java
@@ -4,7 +4,6 @@
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;;
-import cn.hutool.json.XML;
 import com.example.client.service.BaseService;
 import com.example.client.utils.UUIDUtil;
 import com.example.server.progressTrack.Dto.*;
@@ -13,7 +12,6 @@
 import com.example.server.utils.TimeUtils;
 import com.mxgraph.util.mxConstants;
 import com.mxgraph.view.mxGraph;
-import com.mxgraph.view.mxStylesheet;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -1187,10 +1185,11 @@
         return result;
     }
 
-    public mxGraph getCsDiagram(mxGraph graph, String json, List<NetworkNodeStatusDto> nodeStatusList, Integer panelWidth, Integer panelHeight) {
+    public mxGraph getCsDiagram(mxGraph graph, String json, List<NetworkNodeStatusDto> nodeStatusList, Integer panelWidth, Integer panelHeight, List<DiagramNodeDto> list) {
         if (StringUtils.isBlank(json)) {
             return graph;
         }
+
         Map<Long, StatusEnum> statusMap = new HashMap<>();
         if (nodeStatusList != null) {
             Date today = new Date();
@@ -1311,7 +1310,7 @@
                 if ("1888761224410202114".equals(idValue)) {
                     System.out.println(2222);
                 }
-                Object insertVertex = createInsertVertex(graph, jsonArray.getJSONObject(i), defX, defY, status);
+                Object insertVertex = createInsertVertex(graph, jsonArray.getJSONObject(i), defX, defY, status, list);
                 map.put(idValue, insertVertex);
             }
         }
@@ -1449,7 +1448,7 @@
         return graph;
     }
 
-    public Object createInsertVertex(mxGraph graph, JSONObject jsonObject, Integer defX, Integer defY, StatusEnum status) {
+    public Object createInsertVertex(mxGraph graph, JSONObject jsonObject, Integer defX, Integer defY, StatusEnum status, List<DiagramNodeDto> list) {
         Object parent = graph.getDefaultParent();
         String shapeValue = jsonObject.get("shape").toString();
         Object graphObject = null;
@@ -1457,7 +1456,7 @@
             case "custom-circle":
             case "custom-circle1":
                 String text = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/text".split("/"));
-                //String title = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/title/text".split("/"));
+                String title = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/title/text".split("/"));
                 String idValue = jsonObject.get("id").toString();
 
                 Integer x = (Integer) JsonUtils2.getJsonValueByPath(jsonObject, "position/x".split("/")) + defX;
@@ -1466,8 +1465,21 @@
                 Integer height = (Integer) JsonUtils2.getJsonValueByPath(jsonObject, "size/height".split("/"));
                 if (status != null) {
                     String fontColor = "fontColor=" + fillColorArr[status.ordinal()] + ";";
-                    graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height,
-                            "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE);
+                    if (list != null && list.size() > 0) {
+                        for (DiagramNodeDto node : list) {
+                            if (text.equals(node.getProcessName())){
+                                graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height,
+                                        "whiteSpace=wrap;labelWidth=60;" + fontColor );
+                                break;
+                            }else{
+                                graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height,
+                                        "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE);
+                            }
+                        }
+                    }else{
+                        graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height,
+                                "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE);
+                    }
                 } else {
                     if ("寮�濮�".equals(text) || "缁撴潫".equals(text)) {
                         graphObject = graph.insertVertex(parent, idValue, "", x + width / 4, y + height / 4, width / 2, height / 2,
@@ -1477,9 +1489,9 @@
                                 "whiteSpace=wrap;labelWidth=60;" + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE);
                     }
                 }
-                /*if (StringUtils.isNotBlank(title)) {
+                if (StringUtils.isNotBlank(title)) {
                     createText(graph, title, x, y, width, height);
-                }*/
+                }
                 break;
             case "custom-rect":
                 String label = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/label/textWrap/text".split("/"));

--
Gitblit v1.9.1