jinlin
2025-03-01 86f02fee03614fef275c6e0c355d73318ca3025e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package com.example.client.service;
 
import com.example.client.dto.ColumnDto;
import com.example.client.dto.JComboBoxItem;
import com.example.client.model.TableButton;
import com.example.client.utils.CommonTable;
import com.example.client.utils.GBC;
import com.example.client.utils.MultiSelectComboBox;
import com.example.server.cabin.service.CabinService;
import com.example.server.progressTrack.Dto.NetworkNodeStatusDto;
import com.example.server.progressTrack.model.DjJdgzDismantTrack;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel3;
import com.example.server.progressTrack.model.DjJdgzTrackRecord;
import com.example.server.progressTrack.service.DjJdgzDismantTrackService;
import com.example.server.progressTrack.service.DjJdgzNetworkLevel3Service;
import com.example.server.progressTrack.service.NetWorkDiagramService;
import com.example.server.teamGroup.service.SysTeamGroupClassService;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
 
 
@Service
public class DismantTrackService {
    @Autowired
    private DjJdgzNetworkLevel3Service level3Service;
    @Autowired
    private SysTeamGroupClassService sysTeamGroupClassService;
    @Autowired
    private DjJdgzDismantTrackService djJdgzDismantTrackService;
    @Autowired
    private CabinService cabinService;
 
    public JPanel createTable(Integer width, Integer height) {
        height = height - 100;
        JPanel panel = new JPanel();
 
        JPanel jLeft = new JPanel(new BorderLayout());
        JPanel top = new JPanel(new BorderLayout());
        jLeft.setPreferredSize(new Dimension(width / 3 - 20, height));
        top.setPreferredSize(new Dimension(width / 3 - 20, 100));
 
        // 创建左侧表格
        List<ColumnDto> columnDto = new ArrayList<>();
        List<DjJdgzNetworkLevel3> list = level3Service.getList(null);
 
        //columnDto.add(new ColumnDto("ID", "id", -1, null,false));
        JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
        JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
        JComboBoxItem[] cabinList = cabinService.getList();
        String[] typeList = new String[]{
                "改装","加装","换装","改进性修理"
        };
 
        JLabel JLabel1 = new JLabel("部门");
        JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList);
        comboBox1.setPreferredSize(new Dimension(100, 28));
 
        JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
 
        JLabel JLabel2 = new JLabel("专业");
        JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1);
        comboBox2.setPreferredSize(new Dimension(100, 28));
 
        JLabel JLabel3= new JLabel("舱室");
        JComboBox<JComboBoxItem> comboBox3 = new JComboBox(cabinList);
        comboBox3.setPreferredSize(new Dimension(100, 28));
 
        JLabel JLabel4 = new JLabel("类别");
        JComboBox<String> comboBox4 = new JComboBox<>(typeList);
        comboBox3.setPreferredSize(new Dimension(100, 28));
 
        JTextField sb = new JTextField();
 
        comboBox1.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    JComboBoxItem selectedItem = (JComboBoxItem) comboBox1.getSelectedItem();
                    if (selectedItem != null) {
                        long selectedId = selectedItem.getId();
 
                        JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(selectedId);
                        comboBox2.setModel(new DefaultComboBoxModel<>(teamList));
                        comboBox2.setSelectedIndex(-1);
                    }
                }
            }
        });
        top.add(JLabel1, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        top.add(comboBox1, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
        top.add(JLabel2, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        top.add(comboBox2, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
 
        top.add(JLabel3, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        top.add(comboBox3, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
        top.add(JLabel4, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        top.add(comboBox4, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
 
        top.add(sb, new GBC(0, 2, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
 
        jLeft.add(top,BorderLayout.NORTH);
 
        columnDto.add(new ColumnDto("序号", "", width / 20 - 10, "autoCreate", false, null,null));
        columnDto.add(new ColumnDto("部门", "deptId", width / 18, "dict", false, null,deptList));
        columnDto.add(new ColumnDto("专业", "teamgroupId", width / 18, "dict", false, null,teamList));
        columnDto.add(new ColumnDto("舱室", "cabinId", width / 18, "dicts", false, null,cabinList));
        columnDto.add(new ColumnDto("类别", "type", width / 18, null, false, null,null));
        columnDto.add(new ColumnDto("设备名称", "name", width / 18, null, false, null,null));
 
        JTable subTable = CommonTable.createCommonTable(list, columnDto);
        subTable.setRowHeight(25);
        subTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
 
        JScrollPane scrollTable = new JScrollPane(subTable);
        jLeft.add(scrollTable, BorderLayout.CENTER);
 
        JTable trackTable = new JTable();
        JPanel track = this.createTrack(width,height,list.get(0),trackTable);
        trackTable.setPreferredSize(new Dimension(width - width / 3, height));
 
        // 创建水平分割面板
        JSplitPane hSplitPane = new JSplitPane(
                JSplitPane.HORIZONTAL_SPLIT,
                jLeft,
                track
        );
        hSplitPane.setDividerLocation(width / 4);
        hSplitPane.setDividerSize(10);
        hSplitPane.setOneTouchExpandable(true);
        hSplitPane.setContinuousLayout(true);
 
        panel.add(hSplitPane, BorderLayout.CENTER);
 
        subTable.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                // 仅当鼠标左键单击时响应
                if (e.getButton() == MouseEvent.BUTTON1) {
                    // 得到选中的行列的索引值
                    int r = subTable.getSelectedRow();
                    DjJdgzNetworkLevel3 data = list.get(r);
                }
            }
        });
 
        return panel;
    }
 
    private JPanel createTrack(Integer width, Integer height, DjJdgzNetworkLevel3 djJdgzNetworkLevel3, JTable trackTable) {
        JPanel panel = new JPanel();
 
        JPanel topJpanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        topJpanel.setPreferredSize(new Dimension(width, 37));
        topJpanel.setBackground(Color.WHITE);
 
        JPanel centerJpanel = new JPanel();
        centerJpanel.setPreferredSize(new Dimension(width - 20, height - 100));
        centerJpanel.setBackground(Color.WHITE);
        panel.add(topJpanel, BorderLayout.NORTH);
        panel.add(centerJpanel, BorderLayout.CENTER);
 
        JComboBoxItem[] cabinList = cabinService.getList();
        String[] typeList = new String[]{
                "改装","加装","换装","改进性修理"
        };
 
        JComboBox<JComboBoxItem> comboBox = new JComboBox(cabinList);
        comboBox.setPreferredSize(new Dimension(100, 28));
 
        JComboBox<String> comboBox2 = new JComboBox<>(typeList);
        comboBox2.setPreferredSize(new Dimension(100, 28));
 
        JButton btnTj = new JButton("统计报表");
        JButton btnExport = new JButton("导出拆卸报表");
 
        topJpanel.add(btnTj);
        topJpanel.add(btnExport);
        topJpanel.add(comboBox);
        topJpanel.add(comboBox2);
 
        comboBox.setPreferredSize(new Dimension(300, 28));
        comboBox2.setPreferredSize(new Dimension(300, 28));
 
        List<DjJdgzDismantTrack> list = djJdgzDismantTrackService.getList(djJdgzNetworkLevel3.getId(),null);
        List<TableButton> buttonList = new ArrayList<>();
        buttonList.add(new TableButton("edit", "编辑"));
 
        // 创建左侧表格
        List<ColumnDto> columnDto = new ArrayList<>();
        //columnDto.add(new ColumnDto("ID", "id", -1, null,false));
        columnDto.add(new ColumnDto("序号", "", 50, "autoCreate", false, null, null));
        columnDto.add(new ColumnDto("部门", "deptId", 160, null, false, null, null));
        columnDto.add(new ColumnDto("专业", "teamgroupId", 160, null, false, null, null));
        columnDto.add(new ColumnDto("舱室", "cabinId", 120, null, false, null, null));
        columnDto.add(new ColumnDto("部件名称", "name", 200, null, false, null, null));
        columnDto.add(new ColumnDto("拆卸时间", "dismantTime", 200, null, false, null, null));
        columnDto.add(new ColumnDto("拆卸单位", "dismantUnit", 200, null, false, null, null));
        columnDto.add(new ColumnDto("拆卸人员", "dismantStaff", 200, null, false, null, null));
        columnDto.add(new ColumnDto("拆卸助修艇员", "dismantAssistant", 200, null, false, null, null));
        columnDto.add(new ColumnDto("出舱时间", "exitTime", 200, "", true, buttonList, null));
        columnDto.add(new ColumnDto("出舱单位", "exitUnit", 200, null, false, null, null));
        columnDto.add(new ColumnDto("出舱人员", "exitStaff", 200, null, false, null, null));
        columnDto.add(new ColumnDto("出舱助修艇员", "exitAssistant", 200, null, false, null, null));
        columnDto.add(new ColumnDto("退重时间", "returnWeightTime", 200, null, false, null, null));
        columnDto.add(new ColumnDto("称重员", "weigher", 200, null, false, null, null));
        columnDto.add(new ColumnDto("退重重量", "returnWeight", 200, null, false, null, null));
        columnDto.add(new ColumnDto("退重助修艇员", "returnWeightAssistant", 200, null, false, null, null));
        columnDto.add(new ColumnDto("入库时间", "warehouseTime", 200, null, false, null, null));
        columnDto.add(new ColumnDto("入库人员", "warehouseStaff", 200, null, false, null, null));
        columnDto.add(new ColumnDto("当前存放位置", "currentLocation", 200, null, false, null, null));
 
        trackTable = CommonTable.createCommonTable(list, columnDto);
        trackTable.setRowHeight(25);
        trackTable.setAutoCreateRowSorter(true);
        trackTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 
        trackTable.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
 
            }
        });
 
        btnTj.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
 
            }
        });
 
        btnExport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
 
            }
        });
 
 
        JScrollPane scrollPane = new JScrollPane(trackTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.setViewportView(trackTable);
        scrollPane.getViewport().setBackground(Color.WHITE);
        scrollPane.setPreferredSize(new Dimension(width - 20, height - 120));
        centerJpanel.add(scrollPane);
 
        return panel;
    }
 
}