|  |  |  | 
|---|
|  |  |  | import com.example.client.dto.ColumnDto; | 
|---|
|  |  |  | import com.example.client.dto.JComboBoxItem; | 
|---|
|  |  |  | import com.example.client.utils.*; | 
|---|
|  |  |  | import com.example.server.progressTrack.model.DjJdgzNetworkLevel2List; | 
|---|
|  |  |  | import com.example.server.cabin.service.CabinService; | 
|---|
|  |  |  | import com.example.server.progressTrack.model.DjJdgzNetworkLevel3; | 
|---|
|  |  |  | import com.example.server.progressTrack.service.*; | 
|---|
|  |  |  | import com.example.server.teamGroup.service.SysTeamGroupClassService; | 
|---|
|  |  |  | import com.example.server.user.model.SysUser; | 
|---|
|  |  |  | import com.example.server.utils.UserAndSiteUtils; | 
|---|
|  |  |  | import com.example.server.utils.DownLoadTmpFile; | 
|---|
|  |  |  | import com.mxgraph.view.mxGraph; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.swing.*; | 
|---|
|  |  |  | import javax.swing.event.ChangeEvent; | 
|---|
|  |  |  | import javax.swing.table.DefaultTableModel; | 
|---|
|  |  |  | import javax.swing.table.TableCellRenderer; | 
|---|
|  |  |  | import java.awt.*; | 
|---|
|  |  |  | import java.awt.datatransfer.DataFlavor; | 
|---|
|  |  |  | import java.awt.datatransfer.Transferable; | 
|---|
|  |  |  | import java.awt.event.ActionEvent; | 
|---|
|  |  |  | import java.awt.event.ActionListener; | 
|---|
|  |  |  | import java.awt.event.ItemEvent; | 
|---|
|  |  |  | import java.awt.event.ItemListener; | 
|---|
|  |  |  | import java.awt.event.*; | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DjJdgzNetworkLevel2Service level2Service; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DjJdgzNetworkLevel1ListService level1ListService; | 
|---|
|  |  |  | private SysTeamGroupClassService sysTeamGroupClassService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CabinService cabinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DjJdgzNetworkLevel1Service level1Service; | 
|---|
|  |  |  | @Value("${data.tmp-path}") | 
|---|
|  |  |  | private String tmpPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void FileUpload(List<ColumnDto> columnDto, JTable subTable,JFrame jFrame) { | 
|---|
|  |  |  | frame = new JFrame("导入"); | 
|---|
|  |  |  | public void FileUpload(List<ColumnDto> columnDto, JTable subTable, JFrame jFrame) { | 
|---|
|  |  |  | frame = new JFrame("导入三级网络图"); | 
|---|
|  |  |  | frame.setSize(900, 600); | 
|---|
|  |  |  | frame.setResizable(true); | 
|---|
|  |  |  | frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); | 
|---|
|  |  |  | frame.setLocationRelativeTo(null); | 
|---|
|  |  |  | frame.setVisible(true); | 
|---|
|  |  |  | frame.addWindowListener(new WindowAdapter() { | 
|---|
|  |  |  | //添加第二个界面的关闭事件: | 
|---|
|  |  |  | public void windowClosing(WindowEvent e) { | 
|---|
|  |  |  | //添加事件: | 
|---|
|  |  |  | jFrame.setEnabled(true);//将主界面再设置为可操作的 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | GridBagLayout layout = new GridBagLayout(); | 
|---|
|  |  |  | frame.setLayout(layout); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | JLabel label0 = new JLabel("工程"); | 
|---|
|  |  |  | JComboBox<JComboBoxItem> comboBox0 = new JComboBox<>(projectList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JLabel label1 = new JLabel("二级网络图"); | 
|---|
|  |  |  | JLabel label1 = new JLabel("一级网络图节点"); | 
|---|
|  |  |  | JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(); | 
|---|
|  |  |  | comboBox1.setModel(new DefaultComboBoxModel<>(level2List)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { | 
|---|
|  |  |  | super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); | 
|---|
|  |  |  | setText(truncateText(value.toString(), 15)); // 截断文本 | 
|---|
|  |  |  | if(value!=null){ | 
|---|
|  |  |  | setText(truncateText(value.toString(), 15)); // 截断文本 | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | setText(""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return this; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | downloadbtn.addActionListener(new ActionListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void actionPerformed(ActionEvent e) { | 
|---|
|  |  |  | DownLoadTmpFile.down("三级网络图导入模板.xlsx",frame); | 
|---|
|  |  |  | DownLoadTmpFile.down(tmpPath + "三级网络图导入模板.xlsx", frame); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysUser user = (SysUser) UserAndSiteUtils.get("user","user"); | 
|---|
|  |  |  | if (user==null){ | 
|---|
|  |  |  | JOptionPane.showMessageDialog(null, "用户失效请退出并重新登录", "提示", JOptionPane.WARNING_MESSAGE); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | model.setDataVector(data, columnIdentifiers); | 
|---|
|  |  |  | table.setModel(model); | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setPreferredWidth(600); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setPreferredWidth(100); | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setPreferredWidth(550); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setPreferredWidth(150); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setCellRenderer(new TableViewRenderer()); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellRenderer(new TableCellRendererButton()); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellEditor(new TableCellEditorButton(null,null)); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellEditor(new TableCellEditorButton(null, null)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Object[] options = {"OK ", "CANCEL "}; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String filePath = result.toString(); | 
|---|
|  |  |  | String flag = level3Service.importDiagramFromExcel(filePath,level1Id[0],level2Id[0],level2NodeId[0] ); | 
|---|
|  |  |  | String flag = level3Service.importDiagramFromExcel(filePath, level1Id[0], level2Id[0], level2NodeId[0]); | 
|---|
|  |  |  | return flag; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (uploadSucceeded.equals("true")) { | 
|---|
|  |  |  | waitUtil.dispose(); | 
|---|
|  |  |  | frame.dispose(); | 
|---|
|  |  |  | List<DjJdgzNetworkLevel3> list = level3Service.getList(null); | 
|---|
|  |  |  | CommonTable.refreshTable(list,columnDto,subTable); | 
|---|
|  |  |  | level3ManageService.tableModelListener(list,subTable,jFrame); | 
|---|
|  |  |  | jFrame.setEnabled(true);//将主界面再设置为可操作的 | 
|---|
|  |  |  | JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList(); | 
|---|
|  |  |  | JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null); | 
|---|
|  |  |  | JComboBoxItem[] cabinList = cabinService.getList(); | 
|---|
|  |  |  | String[] typeList = new String[]{ | 
|---|
|  |  |  | "","改装", "加装", "换装", "修理","改进性修理" | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | List<DjJdgzNetworkLevel3> list = level3Service.getList(null, deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0],0,null); | 
|---|
|  |  |  | CommonTable.refreshTable(list, columnDto, subTable); | 
|---|
|  |  |  | level3ManageService.tableModelListener(list, subTable, jFrame); | 
|---|
|  |  |  | System.out.println("导入成功时间" + new Date()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | waitUtil.dispose(); | 
|---|
|  |  |  | 
|---|
|  |  |  | JOptionPane.showMessageDialog(null, "只能上传.xlsx或.xls的文件,且不超过2G\"", "提示", JOptionPane.WARNING_MESSAGE); | 
|---|
|  |  |  | return flag; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysUser user = (SysUser) UserAndSiteUtils.get("user","user"); | 
|---|
|  |  |  | if (user==null){ | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | JOptionPane.showMessageDialog(null, "用户失效请退出并重新登录", "提示", JOptionPane.WARNING_MESSAGE); | 
|---|
|  |  |  | return flag; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | model.setDataVector(data, columnIdentifiers); | 
|---|
|  |  |  | table.setModel(model); | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setPreferredWidth(650); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setPreferredWidth(80); | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setPreferredWidth(550); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setPreferredWidth(150); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | table.getColumnModel().getColumn(0).setCellRenderer(new TableViewRenderer()); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellRenderer(new TableCellRendererButton()); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellEditor(new TableCellEditorButton(null,null)); | 
|---|
|  |  |  | table.getColumnModel().getColumn(1).setCellEditor(new TableCellEditorButton(null, null)); | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|