jar
jinlin
2025-03-04 23f02e6b45dd7cf0ab2e7827144913ca59575ea4
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
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.ComplexTable;
import com.example.server.cabin.service.CabinService;
import com.example.server.progressTrack.Dto.StatistReportsDto;
import com.example.server.progressTrack.model.DjJdgzDismantTrack;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel3;
import com.example.server.progressTrack.service.DjJdgzDismantTrackService;
import com.example.server.progressTrack.service.DjJdgzNetworkLevel3Service;
import com.example.server.teamGroup.service.SysTeamGroupClassService;
import com.example.server.user.model.SysUser;
import com.example.server.utils.CacheUtils;
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 DismantTrackAddOrUpdate {
    @Autowired
    private ExportDismantTrackService exportDismantTrackService;
    @Autowired
    private ImportDismantTrackService importDismantTrackService;
    @Autowired
    private DjJdgzDismantTrackService djJdgzDismantTrackService;
    @Autowired
    private StatisDismantService statisDismantService;
    @Autowired
    private CabinService cabinService;
    private  JTable trackTable;
    private   List<ColumnDto> columnDto;
 
    public JPanel createTrack(Integer width, Integer height, DjJdgzNetworkLevel3 djJdgzNetworkLevel3,JFrame frame) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.setPreferredSize(new Dimension(width, height));
 
        JPanel topJpanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        topJpanel.setPreferredSize(new Dimension(width - 10, 37));
 
        JPanel centerJpanel = new JPanel();
        centerJpanel.setPreferredSize(new Dimension(width - 20, height - 100));
 
        panel.add(centerJpanel, BorderLayout.CENTER);
        panel.add(topJpanel, BorderLayout.NORTH);
 
        JButton btnTj = new JButton("统计报表");
        JButton btnExport = new JButton("导出拆卸报表");
        JButton btnSave = new JButton("保存");
        JButton btnImport = new JButton("批量导入");
 
        topJpanel.add(btnTj);
        topJpanel.add(btnExport);
        topJpanel.add(btnSave);
        topJpanel.add(btnImport);
 
        List<DjJdgzDismantTrack> list = djJdgzDismantTrackService.getList(djJdgzNetworkLevel3.getId(), null);
        List<TableButton> buttonList = new ArrayList<>();
        buttonList.add(new TableButton("edit", "编辑"));
        JComboBoxItem[] cabinList = cabinService.getList();
        JComboBoxItem[] statusList = {
                new JComboBoxItem(0, "进行中"),
                new JComboBoxItem(1, "已完成"),
        };
 
        // 创建左侧表格
        //columnDto.add(new ColumnDto("ID", "id", -1, null,false));
        columnDto = new ArrayList<>();
        columnDto.add(new ColumnDto("序号", "", 50, "autoCreate", false, null, null));
        columnDto.add(new ColumnDto("舱室", "cabinId", 120, "dict", false, null, cabinList));
        columnDto.add(new ColumnDto("部件名称", "name", 200, null, false, null, null));
        columnDto.add(new ColumnDto("拆卸时间", "dismantTime", 130, "selectDate", true, null, null));
        columnDto.add(new ColumnDto("拆卸单位", "dismantUnit", 120, null, true, null, null));
        columnDto.add(new ColumnDto("拆卸人员", "dismantStaff", 120, null, true, null, null));
        columnDto.add(new ColumnDto("拆卸助修艇员", "dismantAssistant", 180, null, true, null, null));
        columnDto.add(new ColumnDto("出舱时间", "exitTime", 130, "selectDate", true, null, null));
        columnDto.add(new ColumnDto("出舱单位", "exitUnit", 120, null, true, null, null));
        columnDto.add(new ColumnDto("出舱人员", "exitStaff", 120, null, true, null, null));
        columnDto.add(new ColumnDto("出舱助修艇员", "exitAssistant", 180, null, true, null, null));
        columnDto.add(new ColumnDto("退重时间", "returnWeightTime", 130, "selectDate", true, null, null));
        columnDto.add(new ColumnDto("称重员", "weigher", 120, null, true, null, null));
        columnDto.add(new ColumnDto("退重重量", "returnWeight", 120, null, true, null, null));
        columnDto.add(new ColumnDto("退重助修艇员", "returnWeightAssistant", 180, null, true, null, null));
        columnDto.add(new ColumnDto("入库时间", "warehouseTime", 130, "selectDate", true, null, null));
        columnDto.add(new ColumnDto("入库人员", "warehouseStaff", 120, null, true, null, null));
        columnDto.add(new ColumnDto("当前存放位置", "currentLocation", 160, null, true, null, null));
        columnDto.add(new ColumnDto("状态", "status", 120, "dict", true, null, statusList));
 
        trackTable = CommonTable.createCommonTable(list, columnDto);
        trackTable.setRowHeight(25);
        trackTable.setAutoCreateRowSorter(true);
        trackTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 
 
     /*   Object[][] headerRows = new Object[2][18];
        headerRows[0] = new Object[]{"序号","舱室","部件名称","拆卸阶段", ComplexTable.mergeCellX,ComplexTable.mergeCellX,ComplexTable.mergeCellX,
                "出舱阶段",ComplexTable.mergeCellX,ComplexTable.mergeCellX,ComplexTable.mergeCellX,"退重阶段",ComplexTable.mergeCellX,ComplexTable.mergeCellX,ComplexTable.mergeCellX,
                "入库阶段",ComplexTable.mergeCellX,"当前存放位置"};
        //此处2-5是不会显示出来的,因为1-4向下合并了一行 + 向右合并了一列  , 而2-5被这个矩形范围包括了
        headerRows[1] = new Object[]{ComplexTable.mergeCellY, ComplexTable.mergeCellY ,ComplexTable.mergeCellY ,"时间","单位","人员","助修艇员",
                "时间","单位","人员","助修艇员","时间","称重员","重量","助修艇员","时间","人员",ComplexTable.mergeCellY};
 
        String[][] body = CommonTable.getRowData(list,columnDto);
 
        trackTable = new ComplexTable(headerRows,body);
        CommonTable.setColumnType(columnDto, trackTable);*/
 
        btnTj.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                statisDismantService.createTable(frame,djJdgzNetworkLevel3.getLevel1NetworkId());
            }
        });
 
        btnExport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                exportDismantTrackService.openDialog(frame);
            }
        });
 
        btnSave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                SysUser user = (SysUser) CacheUtils.get("user", "user");
                if (user.getTeamgroup()==null||user.getTeamgroup().equals(djJdgzNetworkLevel3.getTeamgroupId())){
                    CommonTable.saveTableList(list, trackTable, columnDto);
                    djJdgzDismantTrackService.save(list);
                }else{
                    JOptionPane.showMessageDialog(null, "不可操作其他专业数据", "提示", JOptionPane.WARNING_MESSAGE);
                }
            }
        });
 
        btnImport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                importDismantTrackService.FileUpload(djJdgzNetworkLevel3.getId(),frame);
            }
        });
 
 
        JScrollPane scrollPane = new JScrollPane(trackTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.setViewportView(trackTable);
        scrollPane.setPreferredSize(new Dimension(width - 20, height - 130));
        centerJpanel.add(scrollPane);
 
        return panel;
    }
    public void refreshTable(Long level3Id){
        List<DjJdgzDismantTrack> list = djJdgzDismantTrackService.getList(level3Id, null);
        CommonTable.refreshTable(list, columnDto, trackTable);
        trackTable.setRowHeight(25);
        trackTable.setAutoCreateRowSorter(true);
        trackTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    }
 
}