jinlin
2025-04-28 efce7ce3e63712ecc8b4c3039a73b508fc3ea880
src/main/java/com/example/client/service/Level2ViewService.java
@@ -3,6 +3,7 @@
import com.example.client.dto.ColumnDto;
import com.example.client.utils.CommonTable;
import com.example.client.utils.Compute;
import com.example.server.progressTrack.Dto.DiagramNodeDto;
import com.example.server.progressTrack.Dto.NetworkNodeStatusDto;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel1;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel2;
@@ -11,6 +12,7 @@
import com.example.server.progressTrack.service.NetWorkDiagramService;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -25,6 +27,8 @@
public class Level2ViewService {
    @Autowired
    private DjJdgzNetworkLevel2Service level2Service;
    @Autowired
    private DjJdgzNetworkLevel1Service level1Service;
    @Autowired
    private NetWorkDiagramService netWorkDiagramService;
@@ -41,7 +45,7 @@
        // 创建子表格
        List<ColumnDto> columnDto = new ArrayList<>();
        List<DjJdgzNetworkLevel2> list = level2Service.getList(null);
        List<DjJdgzNetworkLevel1> list = level1Service.getList(null);
        //columnDto.add(new ColumnDto("ID", "id", -1, null,false));
        if (list == null || list.size() == 0) {
            JOptionPane.showMessageDialog(null, "还未录入二级网络图数据", "提示", JOptionPane.WARNING_MESSAGE);
@@ -49,8 +53,8 @@
        }
        columnDto.add(new ColumnDto("序号", "", 120, "autoCreate", false, null, null));
        columnDto.add(new ColumnDto("工程", "ProjectName", 145, null, false, null, null));
        columnDto.add(new ColumnDto("一级节点", "processName", 125, null, false, null, null));
        columnDto.add(new ColumnDto("工程", "ProjectName", 270, null, false, null, null));
        //columnDto.add(new ColumnDto("一级节点", "processName", 125, null, false, null, null));
        JTable subTable = CommonTable.createCommonTable(list, columnDto);
        subTable.setRowHeight(25);
@@ -86,10 +90,14 @@
        panel.add(hSplitPane, BorderLayout.CENTER);
        mxGraph graph = new mxGraph();
        String json = list.get(0).getContent();
        List<NetworkNodeStatusDto> nodeStatusList = level2Service.getNodeStatusData(list.get(0).getId());
        graph = netWorkDiagramService.getCsDiagram(graph, json, nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height);
        List<DiagramNodeDto> list2 = level1Service.getNodeList(list.get(0).getId());
        List<DiagramNodeDto> list22 = level1Service.getNodeList2(list.get(0).getId());
        String json = netWorkDiagramService.createSimpleDiagram(list2);
        List<NetworkNodeStatusDto> nodeStatusList = level1Service.getNodeStatus(list.get(0).getId());
        graph = netWorkDiagramService.getCsDiagram(graph, json, nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height,list22);
        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        graphComponent.setConnectable(false);
@@ -116,10 +124,14 @@
                if (e.getButton() == MouseEvent.BUTTON1) {
                    // 得到选中的行列的索引值
                    int r = subTable.getSelectedRow();
                    DjJdgzNetworkLevel2 data = list.get(r);
                    List<NetworkNodeStatusDto> nodeStatusList = level2Service.getNodeStatusData(data.getId());
                    mxGraph csDiagram = netWorkDiagramService.getCsDiagram(graph2[0], data.getContent(), nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height);
                    if (nodeStatusList != null && nodeStatusList.size() > 0) {
                    List<DiagramNodeDto> list2 = level1Service.getNodeList(list.get(r).getId());
                    String json = netWorkDiagramService.createSimpleDiagram(list2);
                    List<NetworkNodeStatusDto> nodeStatusList = level1Service.getNodeStatus(list.get(r).getId());
                    List<DiagramNodeDto> list22 = level1Service.getNodeList2(list.get(r).getId());
                    mxGraph csDiagram = netWorkDiagramService.getCsDiagram(graph2[0], json, nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height,list22);
                    if (StringUtils.isNotBlank(json)) {
                        graph2[0] = csDiagram;
                    } else {
                        graph2[0].removeCells(graph2[0].getChildVertices(graph2[0].getDefaultParent()));