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.*;
|
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.DjJdgzTrackRecordService;
|
import com.example.server.teamGroup.service.SysTeamGroupClassService;
|
import com.example.server.user.model.SysUser;
|
import com.example.server.utils.UserAndSiteUtils;
|
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.List;
|
import java.util.Set;
|
|
|
@Service
|
public class TrackRecordManageService {
|
@Autowired
|
private ProgressPromptService progressPromptService;
|
@Autowired
|
private DjJdgzTrackRecordService djJdgzTrackRecordService;
|
@Autowired
|
private DjJdgzNetworkLevel1Service level1Service;
|
@Autowired
|
private DjJdgzNetworkLevel3Service level3Service;
|
@Autowired
|
private StatisReportsService statistReportsService;
|
@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();
|
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, Compute.ComputeHeight(105, 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(0L, "进行中"),
|
new JComboBoxItem(1L, "已完成")
|
};
|
|
JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
|
String[] typeList = new String[]{
|
"","改换装","修理","改进性修理","不复装设备"
|
};
|
JComboBoxItem[] isealCabin = {
|
new JComboBoxItem(10000L, ""),
|
new JComboBoxItem(0L, "否"),
|
new JComboBoxItem(1L, "是"),
|
};
|
|
JLabel JLabel0 = new JLabel("工程");
|
JComboBox<JComboBoxItem> comboBox = new JComboBox<>(projectList);
|
comboBox.setPreferredSize(new Dimension(210, 28));
|
|
JLabel JLabel1 = new JLabel("部门");
|
JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList);
|
comboBox1.setPreferredSize(new Dimension(140, 28));
|
comboBox1.setMaximumSize(new Dimension(140, 28));
|
|
JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
|
|
JLabel JLabel2 = new JLabel("专业");
|
JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1);
|
comboBox2.setPreferredSize(new Dimension(140, 28));
|
comboBox2.setMaximumSize(new Dimension(140, 28));
|
|
JLabel JLabel3 = new JLabel("舱室");
|
JComboBox<JComboBoxItem> comboBox3 = new JComboBox<>(cabinList);
|
comboBox3.setPreferredSize(new Dimension(120, 28));
|
comboBox3.setMaximumSize(new Dimension(120, 28));
|
|
JLabel JLabel4 = new JLabel("类别");
|
JComboBox<String> comboBox4 = new JComboBox<>(typeList);
|
comboBox4.setPreferredSize(new Dimension(140, 28));
|
comboBox4.setMaximumSize(new Dimension(140, 28));
|
|
JLabel JLabel5 = new JLabel("状态");
|
JComboBox<JComboBoxItem> comboBox5 = new JComboBox<>(statusList);
|
comboBox5.setPreferredSize(new Dimension(120, 28));
|
comboBox5.setMaximumSize(new Dimension(120, 28));
|
|
JLabel JLabel78 = new JLabel("是否影响封舱");
|
JComboBox<JComboBoxItem> comboBox7 = new JComboBox<>(isealCabin);
|
comboBox7.setPreferredSize(new Dimension(120, 28));
|
comboBox7.setMaximumSize(new Dimension(120, 28));
|
|
JTextField sb = new JTextField(16);
|
sb.setPreferredSize(new Dimension(140, 28));
|
sb.setMaximumSize(new Dimension(140, 28));
|
|
JButton query = new JButton("查询");
|
|
JButton btnTj = new JButton("统计报表");
|
JButton btnJc = new JButton("周进度检查表");
|
JButton btnExport = new JButton("导出跟踪报表");
|
JButton btnImport = new JButton("导入跟踪报表");
|
|
comboBox.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();
|
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.getId()), null);
|
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
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();
|
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.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 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();
|
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.getId()), null);
|
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
tableModelListener(table, jFrame, list);
|
}
|
});
|
|
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();
|
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.getId()), null);
|
|
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();
|
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.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();
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.getId()), null);
|
|
CommonTable.refreshTable(list, columnDto, table);
|
table.setRowHeight(25);
|
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
tableModelListener(table, jFrame, list);
|
}
|
});
|
comboBox7.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();
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.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();
|
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();
|
JComboBoxItem isealCabinItem = (JComboBoxItem) comboBox7.getSelectedItem();
|
|
list = djJdgzTrackRecordService.getList(project.getId(), dept.getId(), team.getId(), cabin.getId(), type, Math.toIntExact(status.getId()),Math.toIntExact(isealCabinItem.getId()),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) {
|
jFrame.setEnabled(false);
|
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()), Math.toIntExact(isealCabin[0].getId()),null);
|
if (list == null || list.size() == 0) {
|
JOptionPane.showMessageDialog(null, "还未录入三级网络图数据", "提示", JOptionPane.WARNING_MESSAGE);
|
return 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("部门", "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("是否影响封舱", "isealCabin", 180, "dict", false, null, isealCabin));
|
columnDto.add(new ColumnDto("是否联调", "islt", 180, "dict", false, null, isealCabin));
|
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));
|
columnDto.add(new ColumnDto("备注", "remark", 120, null, false, null, null));
|
|
table = CommonTable.createCommonTable(list, columnDto);
|
table.setRowHeight(25);
|
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, 3, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel1, new GBC(4, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox1, new GBC(5, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel2, new GBC(7, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox2, new GBC(8, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel3, new GBC(10, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox3, new GBC(11, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel4, new GBC(13, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox4, new GBC(14, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel5, new GBC(16, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox5, new GBC(17, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
topJpanel.add(JLabel78, new GBC(19, 0, 3, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(comboBox7, new GBC(22, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5).setWeight(0,0));
|
|
topJpanel.add(btnTj, new GBC(1, 1, 3, 1).setInsets(5));
|
topJpanel.add(btnJc, new GBC(4, 1, 3, 1).setInsets(5));
|
topJpanel.add(btnImport, new GBC(7, 1, 3, 1).setInsets(5));
|
topJpanel.add(btnExport, new GBC(10, 1, 3, 1).setInsets(5));
|
topJpanel.add(mulcomboBox, new GBC(13, 1, 3, 1).setInsets(5));
|
topJpanel.add(sb, new GBC(16, 1, 3, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
topJpanel.add(query, new GBC(19, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
table.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent e) {
|
// if (historyCalled[0]) return;
|
// 获取点击的行和列
|
int row = table.rowAtPoint(e.getPoint());
|
int column = table.columnAtPoint(e.getPoint());
|
|
// 检查是否点击了有效单元格
|
if (row >= 0 && column >= 0) {
|
if (column == 14) { // 列索引从0开始
|
// 获取该单元格的值
|
Object cellValue = table.getValueAt(row, column);
|
Integer value = Integer.parseInt(cellValue.toString());
|
if (value > 0) {
|
jFrame.setEnabled(false);
|
DjJdgzTrackRecord djJdgzTrackRecord = list.get(row);
|
history(jFrame, djJdgzTrackRecord.getLevel3NodeId());
|
}
|
}
|
}
|
}
|
});
|
|
btnTj.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
jFrame.setEnabled(false);
|
JComboBoxItem selectedItemNow = (JComboBoxItem) comboBox.getSelectedItem();
|
statistReportsService.createTable(jFrame, selectedItemNow.getId());
|
}
|
});
|
btnJc.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
jFrame.setEnabled(false);
|
JComboBoxItem selectedItemNow = (JComboBoxItem) comboBox.getSelectedItem();
|
progressPromptService.createTable(jFrame, selectedItemNow.getId());
|
}
|
});
|
btnExport.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
jFrame.setEnabled(false);
|
exportTrackRecordService.openDialog(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, Compute.ComputeHeightWithScroll(105, jFrame)));
|
centerJpanel.add(scrollPane);
|
jFrame.addComponentListener(new ComponentAdapter() {
|
@Override
|
public void componentResized(ComponentEvent e) {
|
centerJpanel.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeight(105, jFrame)));
|
scrollPane.setPreferredSize(new Dimension(width - 20, Compute.ComputeHeightWithScroll(105, jFrame)));
|
centerJpanel.revalidate();
|
centerJpanel.repaint();
|
scrollPane.revalidate();
|
scrollPane.repaint();
|
}
|
});
|
|
System.out.println("comboBox width: " + comboBox.getPreferredSize().height);
|
System.out.println("comboBox2 width: " + comboBox2.getPreferredSize().height);
|
System.out.println("topJpanel width: " + topJpanel.getPreferredSize().height);
|
|
return panel;
|
}
|
|
public void history(JFrame jFrame, Long level3NodeId) {
|
jFrame.setEnabled(false);
|
JFrame frame1 = new JFrame("历史跟踪记录");
|
frame1.setSize(2000, 800);
|
frame1.setResizable(true);
|
frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
frame1.setLocationRelativeTo(null);
|
frame1.addWindowListener(new WindowAdapter() {
|
//添加第二个界面的关闭事件:
|
public void windowClosing(WindowEvent e) {
|
//添加事件:
|
jFrame.setEnabled(true);//将主界面再设置为可操作的
|
}
|
});
|
|
List<ColumnDto> columnDto = new ArrayList<>();
|
List<DjJdgzTrackRecord> list = djJdgzTrackRecordService.getHistory(level3NodeId);
|
JComboBoxItem[] trackList = {
|
new JComboBoxItem(0L, "线下"),
|
new JComboBoxItem(1L, "电话"),
|
};
|
|
JComboBoxItem[] statusList = {
|
new JComboBoxItem(0L, "进行中"),
|
new JComboBoxItem(1L, "已完成"),
|
};
|
JComboBoxItem[] hasDelayRiskList = {
|
new JComboBoxItem(0L, "无"),
|
new JComboBoxItem(1L, "有"),
|
};
|
|
columnDto.add(new ColumnDto("序号", "", 50, "autoCreate", false, null, null));
|
columnDto.add(new ColumnDto("跟踪方式", "trackMethod", 80, "dict", false, null, trackList));
|
columnDto.add(new ColumnDto("跟踪地点", "trackLocation", 180, null, false, null, null));
|
columnDto.add(new ColumnDto("助修人及其联系方式", "trackPerson", 200, null, false, null, null));
|
columnDto.add(new ColumnDto("厂方及其联系方式", "trackedPerson", 200, null, false, null, null));
|
columnDto.add(new ColumnDto("总承修单位", "generalRepair", 160, null, false, null, null));
|
columnDto.add(new ColumnDto("分承修单位", "repair", 160, null, false, null, null));
|
columnDto.add(new ColumnDto("节点进展", "currentStatus", 120, "dict", false, null, statusList));
|
columnDto.add(new ColumnDto("有无脱期风险", "hasDelayRisk", 70, "dict", false, null, hasDelayRiskList));
|
columnDto.add(new ColumnDto("预计完成时间", "estimatedCompletionTime", 220, "selectDate", false, null, null));
|
columnDto.add(new ColumnDto("存在问题", "problem", 200, null, false, null, null));
|
columnDto.add(new ColumnDto("后续计划", "followupPlan", 200, null, false, null, null));
|
columnDto.add(new ColumnDto("备注", "remark", 200, null, false, null, null));
|
|
JTable subTable = CommonTable.createCommonTable(list, columnDto);
|
subTable.setRowHeight(25);
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
JScrollPane scrollPane = new JScrollPane(subTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
scrollPane.setViewportView(subTable);
|
scrollPane.getViewport().setBackground(Color.WHITE);
|
//scrollPane.setPreferredSize(new Dimension(width - 20, height - 100));
|
|
frame1.add(scrollPane);
|
frame1.setVisible(true);
|
|
}
|
|
public void tableModelListener(JTable table, JFrame jFrame, List<DjJdgzTrackRecord> recordList) {
|
table.getModel().addTableModelListener(e -> {
|
// 检查事件类型
|
if (e.getType() == TableModelEvent.UPDATE) {
|
// 获取变化的行和列
|
int row = e.getFirstRow();
|
int column = e.getColumn();
|
|
// 获取新的值
|
Object newValue = table.getModel().getValueAt(row, column);
|
// 输出变化信息
|
if (newValue.equals("edit")) {
|
jFrame.setEnabled(false);
|
DjJdgzTrackRecord data = recordList.get(row);
|
Long level1Id = data.getLevel1NetworkId();
|
data.setProcessName(data.getLevel3NodeName());
|
Boolean isUpdate = data.getIsUpdate();
|
if (data.getId() != null) {
|
data = djJdgzTrackRecordService.get(data.getId());
|
data.setLevel1NetworkId(level1Id);
|
data.setIsUpdate(isUpdate);
|
} else {
|
DjJdgzNetworkLevel3 level3 = level3Service.get(data.getLevel3NetworkId());
|
data.setGeneralRepairUnit(level3.getGeneralRepairUnit());
|
data.setGeneralRepairUnitDirector(level3.getGeneralRepairUnitDirector());
|
data.setGeneralRepairUnitContact(level3.getGeneralRepairUnitContact());
|
data.setRepairUnit(level3.getRepairUnit());
|
data.setRepairUnitDirector(level3.getRepairUnitDirector());
|
data.setRepairUnitContact(level3.getRepairUnitContact());
|
}
|
addOrUpdate.openDialog(data, jFrame, level1Id, columnDto, table);
|
} else {
|
|
}
|
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);
|
String site = (String) UserAndSiteUtils.get("site", "site");
|
|
if (djJdgzTrackRecord.getCurrentStatus() == 1 && site.equals("工作组")) {
|
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,0, null);
|
CommonTable.refreshTable(list, columnDto, table);
|
tableModelListener(table, jFrame, list);
|
});
|
}
|
}
|
});
|
}
|
|
}
|