package com.example.client.service;
|
|
import com.example.client.dto.ColumnDto;
|
import com.example.client.dto.JComboBoxItem;
|
import com.example.client.utils.*;
|
import com.example.server.ExportExcel.dto.ExcelColumnDto;
|
import com.example.server.cabin.service.CabinService;
|
import com.example.server.progressTrack.Dto.TableNodeDto;
|
import com.example.server.progressTrack.model.DjJdgzShip;
|
import com.example.server.progressTrack.service.*;
|
import com.example.server.teamGroup.service.SysTeamGroupClassService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.swing.*;
|
import java.awt.*;
|
import java.awt.event.*;
|
import java.io.File;
|
import java.util.List;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
|
@Service
|
public class Level3View2Service {
|
@Autowired
|
private DjJdgzNetworkLevel3Service level3Service;
|
@Autowired
|
private DjJdgzShipService djJdgzShipService;
|
@Autowired
|
private SysTeamGroupClassService sysTeamGroupClassService;
|
@Autowired
|
private CabinService cabinService;
|
@Autowired
|
private StatisProductService statisProductService;
|
|
private JTable table;
|
private List<TableNodeDto> list;
|
private Map<String, Long> shipMap = new HashMap<>();
|
private List<ColumnDto> columnDto;
|
@Autowired
|
private DjJdgzNetworkLevel1Service djJdgzNetworkLevel1Service;
|
|
|
public JPanel createTable(Integer width, Integer height, JFrame frame) {
|
JPanel panel = new JPanel(new BorderLayout());
|
|
JPanel topJpanel1 = new JPanel(new BorderLayout());
|
topJpanel1.setPreferredSize(new Dimension(width, 150));
|
topJpanel1.setBackground(Color.WHITE);
|
|
JPanel topJpanel2 = new JPanel();
|
|
CustomPanel customPanel = new CustomPanel();
|
customPanel.setPreferredSize(new Dimension(width, 50));
|
customPanel.setBackground(Color.WHITE);
|
|
topJpanel1.add(topJpanel2, BorderLayout.CENTER);
|
topJpanel1.add(customPanel, BorderLayout.SOUTH);
|
|
GridBagLayout layout = new GridBagLayout();
|
topJpanel2.setLayout(layout);
|
topJpanel2.setPreferredSize(new Dimension(width, 100));
|
topJpanel2.setBackground(Color.WHITE);
|
|
JPanel centerJpanel = new JPanel();
|
centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(145, frame)));
|
centerJpanel.setBackground(Color.WHITE);
|
panel.add(topJpanel1, BorderLayout.NORTH);
|
panel.add(centerJpanel, BorderLayout.CENTER);
|
|
List<DjJdgzShip> shipList = djJdgzShipService.getList();
|
JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
|
JComboBoxItem[] cabinList = cabinService.getList();
|
JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
|
String[] typeList = new String[]{
|
"修理", "改换装", "改进性修理", "不复装设备"
|
};
|
|
JComboBoxItem[] isealCabin = {
|
new JComboBoxItem(10000L, ""),
|
new JComboBoxItem(0L, "否"),
|
new JComboBoxItem(1L, "是"),
|
};
|
|
JLabel JLabel0 = new JLabel("工程");
|
JComboBox comboBox = new JComboBox();
|
comboBox.setPreferredSize(new Dimension(185, 28));
|
|
JLabel JLabel1 = new JLabel("部门");
|
JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList);
|
comboBox1.setPreferredSize(new Dimension(185, 28));
|
|
JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
|
|
JLabel JLabel2 = new JLabel("专业");
|
JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1);
|
comboBox2.setPreferredSize(new Dimension(185, 28));
|
|
JLabel JLabel3 = new JLabel("舱室");
|
JComboBox<JComboBoxItem> comboBox3 = new JComboBox<>(cabinList);
|
comboBox3.setPreferredSize(new Dimension(185, 28));
|
|
JLabel JLabel4 = new JLabel("类别");
|
JComboBox<String> comboBox4 = new JComboBox<>(typeList);
|
comboBox4.setPreferredSize(new Dimension(185, 28));
|
|
JLabel JLabel5 = new JLabel("是否影响封舱");
|
JComboBox<JComboBoxItem> comboBox56 = new JComboBox<>(isealCabin);
|
comboBox56.setPreferredSize(new Dimension(185, 28));
|
|
JLabel JLabel6 = new JLabel("是否联调");
|
JComboBox<JComboBoxItem> comboBox6 = new JComboBox<>(isealCabin);
|
comboBox6.setPreferredSize(new Dimension(185, 28));
|
|
JTextField sb = new JTextField(16);
|
JButton query = new JButton("查询");
|
|
List<ColorDescription> colorDescriptions = new ArrayList<>();
|
colorDescriptions.add(new ColorDescription("", "全部"));
|
colorDescriptions.add(new ColorDescription("#3498DB", "进行中"));
|
colorDescriptions.add(new ColorDescription("#F1C40F", "临期(7天)"));
|
colorDescriptions.add(new ColorDescription("#E74C3C", "逾期"));
|
colorDescriptions.add(new ColorDescription("#2ECC71", "正常完成"));
|
colorDescriptions.add(new ColorDescription("#006400", "超期完成"));
|
|
// 创建下拉框
|
ColorDescriptionComboBox comboBox5 = new ColorDescriptionComboBox(colorDescriptions);
|
JButton btnTjz = new JButton("设备进度统计总表");
|
JButton btnExport = new JButton("导出");
|
|
topJpanel2.add(JLabel0, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(JLabel1, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox1, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(JLabel2, new GBC(4, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox2, new GBC(5, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(JLabel3, new GBC(6, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox3, new GBC(7, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(JLabel4, new GBC(8, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox4, new GBC(9, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
topJpanel2.add(JLabel5, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(comboBox56, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(JLabel6, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(comboBox6, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(sb, new GBC(4, 1, 2, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel2.add(query, new GBC(6, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(comboBox5, new GBC(7, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(btnExport, new GBC(8, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
topJpanel2.add(btnTjz, new GBC(9, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
|
list = level3Service.getNodeList(shipList.get(0).getId(), deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0], Math.toIntExact(isealCabin[0].getId()), Math.toIntExact(isealCabin[0].getId()), null);
|
|
columnDto = new ArrayList<>();
|
//columnDto.add(new ColumnDto("ID", "id", -1, null,false));
|
columnDto = getColumnDtoByType(typeList[0]);
|
table = CommonTable.createCommonTable(list, columnDto);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
MouseMotionListener mouseMotionListener = new MouseMotionListener() {
|
@Override
|
public void mouseDragged(MouseEvent e) {
|
// 不需要处理鼠标拖动事件
|
}
|
|
@Override
|
public void mouseMoved(MouseEvent e) {
|
Point point = e.getPoint();
|
int row = table.rowAtPoint(point);
|
int column = table.columnAtPoint(point);
|
|
if (row <= list.size() && column > 3) {
|
List<TableNodeDto> filteredData = list;
|
if (comboBox5.getSelectedItem() instanceof String) {
|
|
} else {
|
ColorDescription selectedColorDescription = (ColorDescription) comboBox5.getSelectedItem();
|
if (selectedColorDescription != null) {
|
String selectedHexColor = selectedColorDescription.getHexColor();
|
if (StringUtils.isNotBlank(selectedHexColor)) {
|
filteredData = list.stream()
|
.filter(dto -> dto.getTime1Color() != null && dto.getTime1Color().equals(selectedHexColor) ||
|
dto.getTime2Color() != null && dto.getTime2Color().equals(selectedHexColor) ||
|
dto.getTime3Color() != null && dto.getTime3Color().equals(selectedHexColor) ||
|
dto.getTime4Color() != null && dto.getTime4Color().equals(selectedHexColor) ||
|
dto.getTime5Color() != null && dto.getTime5Color().equals(selectedHexColor))
|
.collect(Collectors.toList());
|
}
|
}
|
}
|
String hexColor = (String) table.getValueAt(row, column);
|
String tooltip = getTooltipText(hexColor, filteredData.get(row));
|
table.setToolTipText(tooltip);
|
} else {
|
table.setToolTipText(null);
|
}
|
}
|
};
|
|
table.addMouseMotionListener(mouseMotionListener);
|
|
comboBox.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
}
|
});
|
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));
|
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
|
}
|
}
|
}
|
});
|
|
comboBox2.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
comboBox3.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
columnDto = getColumnDtoByType(type);
|
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
comboBox4.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
|
comboBox56.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
comboBox6.addItemListener(new ItemListener() {
|
public void itemStateChanged(final ItemEvent event) {
|
String content = comboBox.getSelectedItem().toString();
|
JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem();
|
JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem();
|
JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem();
|
String type = comboBox4.getSelectedItem().toString();
|
|
JComboBoxItem isCabin = (JComboBoxItem) comboBox56.getSelectedItem();
|
JComboBoxItem isLt = (JComboBoxItem) comboBox6.getSelectedItem();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getNodeList(shipId, dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(isCabin.getId()), Math.toIntExact(isLt.getId()), null);
|
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
|
query.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
String type = comboBox4.getSelectedItem().toString();
|
list = level3Service.getNodeList(null, null, null, null, type, null, null, sb.getText());
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
});
|
|
for (int i = 0; i < shipList.size(); i++) {
|
shipMap.put(shipList.get(i).getShipNo(), shipList.get(i).getId());
|
comboBox.addItem(shipList.get(i).getShipNo());
|
}
|
comboBox.setSelectedItem(shipList.get(0).getShipNo());
|
|
btnTjz.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
String content = comboBox.getSelectedItem().toString();
|
Long shipId = shipMap.get(content);
|
String type = comboBox4.getSelectedItem().toString();
|
statisProductService.createTable(frame, shipId, type);
|
}
|
});
|
btnExport.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
frame.setEnabled(false);
|
export(frame);
|
}
|
});
|
|
comboBox5.addItemListener(new ItemListener() {
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
if (comboBox5.getSelectedItem() instanceof String) {
|
return;
|
}
|
ColorDescription selectedColorDescription = (ColorDescription) comboBox5.getSelectedItem();
|
if (selectedColorDescription != null) {
|
String selectedHexColor = selectedColorDescription.getHexColor();
|
if (StringUtils.isNotBlank(selectedHexColor)) {
|
List<TableNodeDto> filteredData = list.stream()
|
.filter(dto -> dto.getTime1Color() != null && dto.getTime1Color().equals(selectedHexColor) ||
|
dto.getTime2Color() != null && dto.getTime2Color().equals(selectedHexColor) ||
|
dto.getTime3Color() != null && dto.getTime3Color().equals(selectedHexColor) ||
|
dto.getTime4Color() != null && dto.getTime4Color().equals(selectedHexColor) ||
|
dto.getTime5Color() != null && dto.getTime5Color().equals(selectedHexColor))
|
.collect(Collectors.toList());
|
CommonTable.refreshTable(filteredData, columnDto, table);
|
}else{
|
String type = comboBox4.getSelectedItem().toString();
|
list = level3Service.getNodeList(null, null, null, null, type, null, null, sb.getText());
|
columnDto = getColumnDtoByType(type);
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
}
|
}
|
}
|
}
|
});
|
|
table.setEnabled(false);
|
JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
scrollPane.setViewportView(table);
|
scrollPane.getViewport().setBackground(Color.WHITE);
|
scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(145, frame)));
|
centerJpanel.add(scrollPane);
|
frame.addComponentListener(new ComponentAdapter() {
|
@Override
|
public void componentResized(ComponentEvent e) {
|
centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(145, frame)));
|
scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(145, frame)));
|
centerJpanel.revalidate();
|
centerJpanel.repaint();
|
scrollPane.revalidate();
|
scrollPane.repaint();
|
}
|
});
|
|
return panel;
|
}
|
|
private void export(JFrame jFrame) {
|
JFrame frame1 = new JFrame("导出三级网络图状态");
|
frame1.setSize(300, 400);
|
frame1.setResizable(true);
|
frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
frame1.setLocationRelativeTo(null);
|
frame1.setVisible(true);
|
frame1.addWindowListener(new WindowAdapter() {
|
//添加第二个界面的关闭事件:
|
public void windowClosing(WindowEvent e) {
|
//添加事件:
|
jFrame.setEnabled(true);//将主界面再设置为可操作的
|
}
|
});
|
GridBagLayout layout = new GridBagLayout();
|
frame1.setLayout(layout);
|
|
JComboBoxItem[] projectList = djJdgzNetworkLevel1Service.getProjectList();
|
JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
|
|
String[] typeList = new String[]{
|
"","进行中","临期","逾期","正常完成","超期完成"
|
};
|
|
JLabel JLabel1 = new JLabel("工程");
|
JComboBox<JComboBoxItem> comboBox0 = new JComboBox<>(projectList);
|
comboBox0.setPreferredSize(new Dimension(200, 28));
|
comboBox0.setSelectedIndex(-1);
|
|
JLabel JLabel4 = new JLabel("部门");
|
JComboBox<JComboBoxItem> comboBox3 = new JComboBox<>(deptList);
|
comboBox3.setPreferredSize(new Dimension(200, 28));
|
|
JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
|
|
JLabel JLabel5 = new JLabel("专业");
|
JComboBox<JComboBoxItem> comboBox4 = new JComboBox<>(teamList1);
|
comboBox4.setPreferredSize(new Dimension(200, 28));
|
|
JLabel JLabel7 = new JLabel("状态");
|
JComboBox<String> comboBox6 = new JComboBox<>(typeList);
|
comboBox6.setPreferredSize(new Dimension(200, 28));
|
|
comboBox3.addItemListener(new ItemListener() {
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
JComboBoxItem selectedItem = (JComboBoxItem) comboBox3.getSelectedItem();
|
if (selectedItem != null) {
|
long selectedId = selectedItem.getId();
|
|
JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(selectedId);
|
comboBox4.setModel(new DefaultComboBoxModel<>(teamList));
|
comboBox4.setSelectedIndex(-1);
|
}
|
}
|
}
|
});
|
|
JButton btnExport = new JButton("导出");
|
|
frame1.add(JLabel1, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
frame1.add(comboBox0, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
frame1.add(JLabel4, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
frame1.add(comboBox3, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
frame1.add(JLabel5, new GBC(0, 2, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
frame1.add(comboBox4, new GBC(1, 2, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
frame1.add(JLabel7, new GBC(0, 3, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
frame1.add(comboBox6, new GBC(1, 3, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
frame1.add(btnExport, new GBC(0, 4, 2, 1).setWeight(1, 0));
|
|
btnExport.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
JComboBoxItem projectItem = (JComboBoxItem) comboBox0.getSelectedItem();
|
JComboBoxItem deptItem = (JComboBoxItem) comboBox3.getSelectedItem();
|
JComboBoxItem teamGroupItem = (JComboBoxItem) comboBox4.getSelectedItem();
|
String statusItem = comboBox6.getSelectedItem().toString();
|
|
Long level1NetworkId = null;
|
Long deptId = null;
|
Long teamGroupId = null;
|
String status = null;
|
|
if (projectItem != null) {
|
level1NetworkId = projectItem.getId();
|
} else {
|
JOptionPane.showMessageDialog(null, "没有选择工程", "提示", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
if (deptId != null) {
|
deptId = deptItem.getId();
|
}
|
if (teamGroupItem != null) {
|
teamGroupId = teamGroupItem.getId();
|
}
|
|
if (StringUtils.isNotBlank(statusItem)) {
|
status = statusItem;
|
}
|
|
String fileName = "三级网络图状态.xlsx";
|
JFileChooser fileChooser = new JFileChooser();
|
fileChooser.setSelectedFile(new File(fileName));
|
int result = fileChooser.showSaveDialog(frame1);
|
|
if (result == JFileChooser.APPROVE_OPTION) {
|
File selectedFile = fileChooser.getSelectedFile();
|
level3Service.exportExcel(selectedFile.getPath(), level1NetworkId,deptId, teamGroupId, status);
|
JOptionPane.showMessageDialog(frame1, "文件导出成功");
|
} else {
|
JOptionPane.showMessageDialog(frame1, "文件导出取消");
|
}
|
}
|
});
|
|
}
|
|
private JComboBoxItem[] createIsealCabinItems() {
|
return new JComboBoxItem[]{
|
new JComboBoxItem(10000L, ""),
|
new JComboBoxItem(0L, "否"),
|
new JComboBoxItem(1L, "是")
|
};
|
}
|
|
private List<ColumnDto> getColumnDtoByType(String type) {
|
List<ColumnDto> columns = new ArrayList<>();
|
if ("修理".equals(type)) {
|
columns.add(new ColumnDto("序号", "", 100, "autoCreate", false, null, null));
|
columns.add(new ColumnDto("设备名称", "name", 327, null, true, null, null));
|
columns.add(new ColumnDto("是否影响封舱", "isealCabin", 160, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("是否联调", "islt", 100, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("设备拆卸出舱", "time1Color", 187, "Circle", true, null, null));
|
columns.add(new ColumnDto("设备分交", "time2Color", 187, "Circle", true, null, null));
|
columns.add(new ColumnDto("拆检鉴定", "time3Color", 187, "Circle", true, null, null));
|
columns.add(new ColumnDto("设备返厂", "time4Color", 187, "Circle", true, null, null));
|
columns.add(new ColumnDto("回装", "time5Color", 187, "Circle", true, null, null));
|
} else if ("改换装".equals(type) || "改进性修理".equals(type)) {
|
columns.add(new ColumnDto("序号", "", 144, "autoCreate", false, null, null));
|
columns.add(new ColumnDto("设备名称", "name", 320, null, true, null, null));
|
columns.add(new ColumnDto("是否影响封舱", "isealCabin", 320, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("是否联调", "islt", 144, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("设备到厂", "time1Color", 320, "Circle", true, null, null));
|
columns.add(new ColumnDto("设备安装", "time2Color", 320, "Circle", true, null, null));
|
} else if ("不复装设备".equals(type)) {
|
columns.add(new ColumnDto("序号", "", 100, "autoCreate", false, null, null));
|
columns.add(new ColumnDto("设备名称", "name", 320, null, true, null, null));
|
columns.add(new ColumnDto("是否影响封舱", "isealCabin", 160, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("是否联调", "islt", 100, "dict", false, null, createIsealCabinItems()));
|
columns.add(new ColumnDto("拆卸出舱", "time1Color", 155, "Circle", true, null, null));
|
columns.add(new ColumnDto("入库", "time2Color", 155, "Circle", true, null, null));
|
columns.add(new ColumnDto("存放位置", "time3Color", 155, "Circle", true, null, null));
|
columns.add(new ColumnDto("移交T队", "time4Color", 155, "Circle", true, null, null));
|
columns.add(new ColumnDto("备注", "remark", 300, null, false, null, null));
|
}
|
return columns;
|
}
|
|
private static String getTooltipText(String hexColor, TableNodeDto tableNodeDto) {
|
switch (hexColor) {
|
case "#3498DB":
|
return "进行中";
|
case "#F1C40F":
|
return tableNodeDto.getLqText();
|
case "#E74C3C":
|
return tableNodeDto.getYqText();
|
case "#2ECC71":
|
return "正常完成";
|
case "#006400":
|
return tableNodeDto.getCqText();
|
default:
|
return "未开始";
|
}
|
}
|
|
|
}
|