| | |
| | | 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 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; |
| | |
| | | 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) { |
| | |
| | | // 创建下拉框 |
| | | 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(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); |
| | | |
| | |
| | | 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 |
| | |
| | | |
| | | 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, ""), |