jinlin
2025-04-28 efce7ce3e63712ecc8b4c3039a73b508fc3ea880
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
package com.example.client.service;
 
import com.example.client.dto.ColumnDto;
import com.example.client.dto.JComboBoxItem;
import com.example.client.utils.CommonTable;
import com.example.client.utils.Compute;
import com.example.client.utils.GBC;
import com.example.server.progressTrack.model.DjJdgzTrackRecord;
import com.example.server.progressTrack.service.DjJdgzTrackRecordService;
import com.example.server.teamGroup.service.SysTeamGroupClassService;
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 ProgressPromptService {
    @Autowired
    private DjJdgzTrackRecordService djJdgzTrackRecordService;
 
    private JTable table;
    private List<DjJdgzTrackRecord> list;
    @Autowired
    private SysTeamGroupClassService sysTeamGroupClassService;
 
    public void createTable(JFrame jFrame,Long level1NetworkId) {
        JFrame frame1 = new JFrame("进度检查");
        frame1.setSize(1200, 700);
        frame1.setResizable(false);
        frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame1.setLocationRelativeTo(null);
        frame1.setVisible(true);
        frame1.addWindowListener(new WindowAdapter() {
            //添加第二个界面的关闭事件:
            public void windowClosing(WindowEvent e) {
                //添加事件:
                jFrame.setEnabled(true);//将主界面再设置为可操作的
            }
        });
 
        JPanel topJpanel = new JPanel();
        GridBagLayout layout = new GridBagLayout();
        topJpanel.setLayout(layout);
        topJpanel.setPreferredSize(new Dimension(1200 - 20, 40));
        topJpanel.setBackground(Color.WHITE);
 
        JPanel centerJpanel = new JPanel();
        centerJpanel.setPreferredSize(new Dimension(1200 - 20,700-40));
        centerJpanel.setBackground(Color.WHITE);
        frame1.add(topJpanel, BorderLayout.NORTH);
        frame1.add(centerJpanel, BorderLayout.CENTER);
 
        JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
 
        JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
 
        JLabel JLabel1 = new JLabel("部门");
        JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList);
        comboBox1.setPreferredSize(new Dimension(140, 28));
        comboBox1.setMaximumSize(new Dimension(140, 28));
 
        JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
 
        JLabel JLabel2 = new JLabel("专业");
        JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1);
        comboBox2.setPreferredSize(new Dimension(140, 28));
        comboBox2.setMaximumSize(new Dimension(140, 28));
 
        JTextField sb = new JTextField(16);
        sb.setPreferredSize(new Dimension(140, 28));
        sb.setMaximumSize(new Dimension(140, 28));
 
        JButton query = new JButton("查询");
        query.setPreferredSize(new Dimension(90, 28));
 
        topJpanel.add(JLabel1, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        topJpanel.add(comboBox1, new GBC(1, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
 
        topJpanel.add(JLabel2, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
        topJpanel.add(comboBox2, new GBC(4, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
 
        topJpanel.add(sb, new GBC(8, 0, 3, 1).setInsets(5));
        topJpanel.add(query, new GBC(15, 0, 1, 1).setInsets(5));
 
 
        List<ColumnDto> columnDto = new ArrayList<>();
        list = djJdgzTrackRecordService.prompt(level1NetworkId, null, null, null);
 
        //columnDto.add(new ColumnDto("ID", "id", -1, null,false));
        columnDto.add(new ColumnDto("工程名称", "ProjectName", 280, null, false, null,null));
        columnDto.add(new ColumnDto("班组专业", "teamgroupName", 150, null, false, null,null));
        columnDto.add(new ColumnDto("一级节点", "level1NodeName", 150, null, false, null,null));
        columnDto.add(new ColumnDto("二级节点", "level2NodeName", 150, null, false, null,null));
        columnDto.add(new ColumnDto("项目名称", "level3NetworkName", 150, null, false, null,null));
        columnDto.add(new ColumnDto("当前节点", "level3NodeName", 150, null, false, null,null));
        columnDto.add(new ColumnDto("状态", "status", 150, null, false, null,null));
        table = CommonTable.createCommonTable(list, columnDto);
        table.setRowHeight(25);
 
 
        comboBox1.addItemListener(new ItemListener() {
            public void itemStateChanged(final ItemEvent event) {
                JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
                Long deptId = dept.getId();
                JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(deptId);
                comboBox2.setModel(new DefaultComboBoxModel<>(teamList));
 
                JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
 
                list = djJdgzTrackRecordService.prompt(level1NetworkId,deptId,team.getId(),null);
 
                CommonTable.refreshTable(list, columnDto, table);
                table.setRowHeight(25);
 
                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            }
        });
 
        comboBox2.addItemListener(new ItemListener() {
            public void itemStateChanged(final ItemEvent event) {
                JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
                JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
 
                list = djJdgzTrackRecordService.prompt(level1NetworkId,dept.getId(),team.getId(),null);
 
                CommonTable.refreshTable(list, columnDto, table);
                table.setRowHeight(25);
 
                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            }
        });
 
        query.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                list = djJdgzTrackRecordService.prompt(level1NetworkId, null, null,sb.getText());
 
                CommonTable.refreshTable(list, columnDto, table);
                table.setRowHeight(25);
 
                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            }
        });
 
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        JScrollPane scrollTable = new JScrollPane(table);
        scrollTable.setPreferredSize(new Dimension(1200 - 20,700-40));
 
        centerJpanel.add(scrollTable);
        frame1.setVisible(true);
    }
 
}