From d30e385951ce03335a5023f0775fd144da3c0b88 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期二, 18 三月 2025 11:18:31 +0800 Subject: [PATCH] 修改 --- src/main/java/com/example/client/service/TrackRecordManageService.java | 354 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 298 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/example/client/service/TrackRecordManageService.java b/src/main/java/com/example/client/service/TrackRecordManageService.java index 52c1c2c..363d012 100644 --- a/src/main/java/com/example/client/service/TrackRecordManageService.java +++ b/src/main/java/com/example/client/service/TrackRecordManageService.java @@ -3,23 +3,24 @@ 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.*; +import com.example.server.cabin.service.CabinService; import com.example.server.progressTrack.model.*; import com.example.server.progressTrack.service.DjJdgzNetworkLevel1Service; import com.example.server.progressTrack.service.DjJdgzNetworkLevel3Service; -import com.example.server.progressTrack.service.DjJdgzShipService; 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 javax.swing.event.TableModelEvent; +import javax.swing.table.TableColumnModel; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.Set; @Service @@ -37,98 +38,240 @@ @Autowired private ExportTrackRecordService exportTrackRecordService; @Autowired + private ImportTrackRecordService importTrackRecordService; + @Autowired private TrackRecordAddOrUpdate addOrUpdate; // 娉ㄥ叆 AddOrupdate 瀹炰緥 + @Autowired + private SysTeamGroupClassService sysTeamGroupClassService; + @Autowired + private CabinService cabinService; private JTable table; private List<DjJdgzTrackRecord> list; private List<ColumnDto> columnDto; + private TableColumnModel columnModel; public JPanel createTable(Integer width, Integer height, JFrame jFrame) { JPanel panel = new JPanel(); - JPanel topJpanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - topJpanel.setPreferredSize(new Dimension(width, 37)); + JPanel topJpanel = new JPanel(); + GridBagLayout layout = new GridBagLayout(); + topJpanel.setLayout(layout); + topJpanel.setPreferredSize(new Dimension(width - 20, 100)); topJpanel.setBackground(Color.WHITE); JPanel centerJpanel = new JPanel(); - centerJpanel.setPreferredSize(new Dimension(width - 20, height - 100)); + centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(100,jFrame))); centerJpanel.setBackground(Color.WHITE); panel.add(topJpanel, BorderLayout.NORTH); panel.add(centerJpanel, BorderLayout.CENTER); JComboBoxItem[] projectList = level1Service.getProjectList(); + + JComboBoxItem[] cabinList = cabinService.getList(); + JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList(); JComboBoxItem[] statusList = { - new JComboBoxItem(0, "杩涜涓�"), - new JComboBoxItem(1, "宸插畬鎴�") + new JComboBoxItem(0L, "杩涜涓�"), + new JComboBoxItem(1L, "宸插畬鎴�") }; + + JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null); + String[] typeList = new String[]{ + "鏀硅", "鍔犺", "鎹㈣", "鏀硅繘鎬т慨鐞�", "" + }; + + JLabel JLabel0 = new JLabel("宸ョ▼"); + JComboBox<JComboBoxItem> comboBox = new JComboBox<>(projectList); + comboBox.setPreferredSize(new Dimension(150, 28)); + + JLabel JLabel1 = new JLabel("閮ㄩ棬"); + JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList); + comboBox1.setPreferredSize(new Dimension(150, 28)); + + JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId()); + + JLabel JLabel2 = new JLabel("涓撲笟"); + JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1); + comboBox2.setPreferredSize(new Dimension(150, 28)); + + JLabel JLabel3 = new JLabel("鑸卞"); + JComboBox<JComboBoxItem> comboBox3 = new JComboBox<>(cabinList); + comboBox3.setPreferredSize(new Dimension(150, 28)); + + JLabel JLabel4 = new JLabel("绫诲埆"); + JComboBox<String> comboBox4 = new JComboBox<>(typeList); + comboBox4.setPreferredSize(new Dimension(150, 28)); + + JLabel JLabel5 = new JLabel("鐘舵��"); + JComboBox<JComboBoxItem> comboBox5 = new JComboBox<>(statusList); + comboBox5.setPreferredSize(new Dimension(150, 28)); + + JTextField sb = new JTextField(16); + sb.setPreferredSize(new Dimension(150, 28)); + JButton query = new JButton("鏌ヨ"); JButton btnTj = new JButton("缁熻鎶ヨ〃"); JButton btnJc = new JButton("鍛ㄨ繘搴︽鏌ヨ〃"); JButton btnExport = new JButton("瀵煎嚭璺熻釜鎶ヨ〃"); - JComboBox<JComboBoxItem> comboBox = new JComboBox<>(projectList); - JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(statusList); - JComboBoxItem selectedItem = (JComboBoxItem) comboBox.getSelectedItem(); - JComboBoxItem selectedItem2 = (JComboBoxItem) comboBox2.getSelectedItem(); + JButton btnImport = new JButton("瀵煎叆璺熻釜鎶ヨ〃"); comboBox.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent event) { - JComboBoxItem selectedItemNow = (JComboBoxItem) comboBox.getSelectedItem(); - JComboBoxItem selectedItem2Now = (JComboBoxItem) comboBox2.getSelectedItem(); - Long level1Id = selectedItemNow.getId(); - Long Status = selectedItem2Now.getId(); + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); - list = djJdgzTrackRecordService.getList(level1Id, Math.toIntExact(Status)); + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); + CommonTable.refreshTable(list, columnDto, table); table.setRowHeight(25); - table.setAutoCreateRowSorter(true); - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - tableModelListener(table, jFrame); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); + } + }); + + comboBox1.addItemListener(new ItemListener() { + public void itemStateChanged(final ItemEvent event) { + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + Long deptId = dept.getId(); + JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(deptId); + comboBox2.setModel(new DefaultComboBoxModel<>(teamList)); + + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); + + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); + + CommonTable.refreshTable(list, columnDto, table); + table.setRowHeight(25); + + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); } }); comboBox2.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent event) { - JComboBoxItem selectedItemNow = (JComboBoxItem) comboBox.getSelectedItem(); - JComboBoxItem selectedItem2Now = (JComboBoxItem) comboBox2.getSelectedItem(); - Long level1Id = selectedItemNow.getId(); - Long Status = selectedItem2Now.getId(); + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); - list = djJdgzTrackRecordService.getList(level1Id, Math.toIntExact(Status)); + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); + CommonTable.refreshTable(list, columnDto, table); table.setRowHeight(25); - table.setAutoCreateRowSorter(true); - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - tableModelListener(table, jFrame); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); } }); - topJpanel.add(btnTj); - topJpanel.add(btnJc); - topJpanel.add(btnExport); - topJpanel.add(comboBox); - topJpanel.add(comboBox2); + comboBox3.addItemListener(new ItemListener() { + public void itemStateChanged(final ItemEvent event) { + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); - comboBox.setPreferredSize(new Dimension(300, 28)); - comboBox2.setPreferredSize(new Dimension(300, 28)); + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); - list = djJdgzTrackRecordService.getList(selectedItem.getId(), Math.toIntExact(selectedItem2.getId())); + CommonTable.refreshTable(list, columnDto, table); + table.setRowHeight(25); + + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); + } + }); + comboBox4.addItemListener(new ItemListener() { + public void itemStateChanged(final ItemEvent event) { + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); + + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); + + CommonTable.refreshTable(list, columnDto, table); + table.setRowHeight(25); + + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); + } + }); + + comboBox5.addItemListener(new ItemListener() { + public void itemStateChanged(final ItemEvent event) { + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); + JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); + JComboBoxItem cabin = (JComboBoxItem) comboBox3.getSelectedItem(); + String type = comboBox4.getSelectedItem().toString(); + JComboBoxItem status = (JComboBoxItem) comboBox5.getSelectedItem(); + + list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()), null); + + CommonTable.refreshTable(list, columnDto, table); + table.setRowHeight(25); + + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); + } + }); + query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JComboBoxItem project = (JComboBoxItem) comboBox.getSelectedItem(); + list = djJdgzTrackRecordService.getList(project.getId(), null, null, null, null, null, sb.getText()); + + CommonTable.refreshTable(list, columnDto, table); + table.setRowHeight(25); + + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableModelListener(table, jFrame, list); + } + }); + + btnImport.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JComboBoxItem selectedItemNow = (JComboBoxItem) comboBox.getSelectedItem(); + importTrackRecordService.FileUpload(columnDto, table, jFrame); + } + }); + + list = djJdgzTrackRecordService.getList(projectList[0].getId(), deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0], Math.toIntExact(statusList[0].getId()), null); List<TableButton> buttonList = new ArrayList<>(); buttonList.add(new TableButton("edit", "缂栬緫")); columnDto = new ArrayList<>(); //columnDto.add(new ColumnDto("ID", "id", -1, null,false)); columnDto.add(new ColumnDto("搴忓彿", "", 50, "autoCreate", false, null, null)); - columnDto.add(new ColumnDto("宸ョ▼鍚嶇О", "ProjectName", 180, null, false, null, null)); + columnDto.add(new ColumnDto("閮ㄩ棬", "deptId", 120, "dict", false, null, deptList)); + columnDto.add(new ColumnDto("涓撲笟", "teamgroupName", 120, null, false, null, null)); + columnDto.add(new ColumnDto("鑸卞", "cabinId", 100, "dict", false, null, cabinList)); + columnDto.add(new ColumnDto("绫诲埆", "type", 100, null, false, null, null)); columnDto.add(new ColumnDto("涓�绾ц妭鐐�", "level1NodeName", 120, null, false, null, null)); columnDto.add(new ColumnDto("浜岀骇鑺傜偣", "level2NodeName", 120, null, false, null, null)); - columnDto.add(new ColumnDto("椤圭洰鍚嶇О", "level3NetworkName", 120, null, false, null, null)); - columnDto.add(new ColumnDto("褰撳墠鑺傜偣", "level3NodeName", 120, null, false, null, null)); - columnDto.add(new ColumnDto("璁″垝瀹屾垚鏃堕棿", "requiredCompletionTime", 200, null, false, null, null)); - columnDto.add(new ColumnDto("鎬绘壙淇崟浣�", "generalRepair", 180, null, false, null, null)); - columnDto.add(new ColumnDto("鍒嗘壙淇崟浣�", "repair", 180, null, false, null, null)); + columnDto.add(new ColumnDto("璁惧鍚嶇О", "level3NetworkName", 120, null, false, null, null)); + columnDto.add(new ColumnDto("褰撳墠鑺傜偣", "level3NodeName", 150, null, false, null, null)); + columnDto.add(new ColumnDto("璁″垝瀹屾垚鏃堕棿", "requiredCompletionTime", 180, null, false, null, null)); columnDto.add(new ColumnDto("璺熻釜璁板綍", "", 100, "", true, buttonList, null)); + columnDto.add(new ColumnDto("鎬绘壙淇崟浣�", "generalRepair", 200, null, false, null, null)); + columnDto.add(new ColumnDto("鍒嗘壙淇崟浣�", "repair", 200, null, false, null, null)); columnDto.add(new ColumnDto("鍘嗗彶璁板綍", "trackNum", 100, null, false, null, null)); columnDto.add(new ColumnDto("瀹屾垚鏃堕棿", "actualCompletion", 200, null, false, null, null)); columnDto.add(new ColumnDto("闄勪欢", "fileName", 200, null, false, null, null)); @@ -136,8 +279,61 @@ table = CommonTable.createCommonTable(list, columnDto); table.setRowHeight(25); - table.setAutoCreateRowSorter(true); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + List<String> itemList = new ArrayList<>(); + for (ColumnDto dto : columnDto) { + itemList.add(dto.getColumnDesc()); // 灏� dto.getColumnDesc() 娣诲姞鍒� List 涓� + } + + String[] items = itemList.toArray(new String[0]); + columnModel = table.getColumnModel(); + MultiSelectComboBox2 mulcomboBox = new MultiSelectComboBox2(items,columnDto,columnModel); + +/* final Integer[] lastIndex = {-1}; + mulcomboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent event) { + int selectedIndex = mulcomboBox.getSelectedIndex(); + if (lastIndex[0] == selectedIndex){ + lastIndex[0] = -1; + return; + }else{ + lastIndex[0] = selectedIndex; + } + if (selectedIndex != -1) { + // 鏇存柊 selectedIndices + if (event.getStateChange() == ItemEvent.SELECTED){ + Integer width = columnDto.get(selectedIndex).getColumnWidth(); + columnModel.getColumn(selectedIndex).setPreferredWidth(width); + }else{ + columnModel.getColumn(selectedIndex).setPreferredWidth(0); + } + } + } + });*/ + + topJpanel.add(JLabel0, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + topJpanel.add(JLabel1, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox1, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + topJpanel.add(JLabel2, new GBC(4, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox2, new GBC(5, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + topJpanel.add(JLabel3, new GBC(6, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox3, new GBC(7, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + topJpanel.add(JLabel4, new GBC(8, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox4, new GBC(9, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + topJpanel.add(JLabel5, new GBC(10, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(comboBox5, new GBC(11, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + + topJpanel.add(btnTj, new GBC(1, 1, 1, 1).setInsets(5)); + topJpanel.add(btnJc, new GBC(2, 1, 2, 1).setInsets(5)); + topJpanel.add(btnImport, new GBC(4, 1, 2, 1).setInsets(5)); + topJpanel.add(btnExport, new GBC(6, 1, 2, 1).setInsets(5)); + topJpanel.add(mulcomboBox, new GBC(8, 1, 2, 1).setInsets(5)); + topJpanel.add(sb, new GBC(10, 1, 2, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); + topJpanel.add(query, new GBC(12, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); + table.addMouseListener(new MouseAdapter() { @Override @@ -149,7 +345,7 @@ // 妫�鏌ユ槸鍚︾偣鍑讳簡鏈夋晥鍗曞厓鏍� if (row >= 0 && column >= 0) { - if (column == 10) { // 鍒楃储寮曚粠0寮�濮� + if (column == 13) { // 鍒楃储寮曚粠0寮�濮� // 鑾峰彇璇ュ崟鍏冩牸鐨勫�� Object cellValue = table.getValueAt(row, column); Integer value = Integer.parseInt(cellValue.toString()); @@ -182,13 +378,24 @@ exportTrackRecordService.openDialog(jFrame); } }); - tableModelListener(table, jFrame); + tableModelListener(table, jFrame, list); 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, height - 130)); + scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(100,jFrame))); centerJpanel.add(scrollPane); + jFrame.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(100,jFrame))); + scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(100,jFrame))); + centerJpanel.revalidate(); + centerJpanel.repaint(); + scrollPane.revalidate(); + scrollPane.repaint(); + } + }); return panel; } @@ -211,17 +418,17 @@ List<ColumnDto> columnDto = new ArrayList<>(); List<DjJdgzTrackRecord> list = djJdgzTrackRecordService.getHistory(level3NodeId); JComboBoxItem[] trackList = { - new JComboBoxItem(0, "绾夸笅"), - new JComboBoxItem(1, "鐢佃瘽"), + new JComboBoxItem(0L, "绾夸笅"), + new JComboBoxItem(1L, "鐢佃瘽"), }; JComboBoxItem[] statusList = { - new JComboBoxItem(0, "杩涜涓�"), - new JComboBoxItem(1, "宸插畬鎴�"), + new JComboBoxItem(0L, "杩涜涓�"), + new JComboBoxItem(1L, "宸插畬鎴�"), }; JComboBoxItem[] hasDelayRiskList = { - new JComboBoxItem(0, "鏃�"), - new JComboBoxItem(1, "鏈�"), + new JComboBoxItem(0L, "鏃�"), + new JComboBoxItem(1L, "鏈�"), }; columnDto.add(new ColumnDto("搴忓彿", "", 50, "autoCreate", false, null, null)); @@ -251,7 +458,7 @@ } - public void tableModelListener(JTable table, JFrame jFrame) { + public void tableModelListener(JTable table, JFrame jFrame, List<DjJdgzTrackRecord> recordList) { table.getModel().addTableModelListener(e -> { // 妫�鏌ヤ簨浠剁被鍨� if (e.getType() == TableModelEvent.UPDATE) { @@ -263,7 +470,7 @@ Object newValue = table.getModel().getValueAt(row, column); // 杈撳嚭鍙樺寲淇℃伅 if (newValue.equals("edit")) { - DjJdgzTrackRecord data = list.get(row); + DjJdgzTrackRecord data = recordList.get(row); Long level1Id = data.getLevel1NetworkId(); data.setProcessName(data.getLevel3NodeName()); Boolean isUpdate = data.getIsUpdate(); @@ -271,7 +478,7 @@ data = djJdgzTrackRecordService.get(data.getId()); data.setLevel1NetworkId(level1Id); data.setIsUpdate(isUpdate); - }else{ + } else { DjJdgzNetworkLevel3 level3 = level3Service.get(data.getLevel3NetworkId()); data.setGeneralRepairUnit(level3.getGeneralRepairUnit()); data.setGeneralRepairUnitDirector(level3.getGeneralRepairUnitDirector()); @@ -288,6 +495,41 @@ System.out.println("鍗曞厓鏍煎彉鍖�: 琛�=" + row + ", 鍒�=" + column + ", 鏂板��=" + newValue); } }); + + table.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (e.isPopupTrigger()) { + showPopupMenu(e); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { + showPopupMenu(e); + } + } + + private void showPopupMenu(MouseEvent e) { + JPopupMenu popupMenu = new JPopupMenu(); + JMenuItem menuItem1 = new JMenuItem("鎾ゅ洖"); + popupMenu.add(menuItem1); + int row = table.rowAtPoint(e.getPoint()); + int col = table.columnAtPoint(e.getPoint()); + DjJdgzTrackRecord djJdgzTrackRecord = list.get(row); + if (djJdgzTrackRecord.getCurrentStatus() == 1) { + table.setRowSelectionInterval(row, row); + popupMenu.show(e.getComponent(), e.getX(), e.getY()); + menuItem1.addActionListener(ex -> { + djJdgzTrackRecordService.retract(djJdgzTrackRecord.getId()); + List<DjJdgzTrackRecord> list = djJdgzTrackRecordService.getList(djJdgzTrackRecord.getLevel1NetworkId(), null, null, null, null, 0, null); + CommonTable.refreshTable(list, columnDto, table); + tableModelListener(table, jFrame, list); + }); + } + } + }); } } -- Gitblit v1.9.1