package com.example.client.service;
|
|
import com.example.client.dto.ColumnDto;
|
import com.example.client.dto.JComboBoxItem;
|
import com.example.client.utils.CommonTable;
|
import com.example.client.utils.Compute;
|
import com.example.client.utils.GBC;
|
import com.example.server.cabin.service.CabinService;
|
import com.example.server.progressTrack.model.DjJdgzNetworkLevel3;
|
import com.example.server.progressTrack.model.DjJdgzShip;
|
import com.example.server.progressTrack.service.DjJdgzNetworkLevel3Service;
|
import com.example.server.progressTrack.service.DjJdgzShipService;
|
import com.example.server.teamGroup.service.SysTeamGroupClassService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.swing.*;
|
import java.awt.*;
|
import java.awt.event.*;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
|
@Service
|
public class DismantTrackService {
|
@Autowired
|
private DjJdgzNetworkLevel3Service level3Service;
|
@Autowired
|
private SysTeamGroupClassService sysTeamGroupClassService;
|
@Autowired
|
private DismantTrackAddOrUpdate addOrUpdate;
|
@Autowired
|
private CabinService cabinService;
|
@Autowired
|
private DjJdgzShipService djJdgzShipService;
|
private List<DjJdgzNetworkLevel3> list;
|
|
public JPanel createTable(Integer width, Integer height, JFrame frame) {
|
JPanel panel = new JPanel();
|
panel.setPreferredSize(new Dimension(width, height));
|
|
JPanel jLeft = new JPanel(new BorderLayout());
|
|
JPanel top = new JPanel();
|
JPanel center = new JPanel();
|
|
top.setPreferredSize(new Dimension(600, 100));
|
center.setPreferredSize(new Dimension(600, Compute.ComputeHeight(100,frame)));
|
jLeft.setPreferredSize(new Dimension(600, Compute.ComputeHeight(0,frame)));
|
jLeft.add(center, BorderLayout.CENTER);
|
jLeft.add(top, BorderLayout.NORTH);
|
|
GridBagLayout layout = new GridBagLayout();
|
top.setLayout(layout);
|
|
// 创建左侧表格
|
|
//columnDto.add(new ColumnDto("ID", "id", -1, null,false));
|
JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
|
JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
|
JComboBoxItem[] cabinList = cabinService.getList();
|
String[] typeList = new String[]{
|
"","改换装","修理","改进性修理","不复装设备"
|
};
|
List<DjJdgzShip> shipList = djJdgzShipService.getList();
|
Map<String, Long> shipMap = new HashMap<>();
|
|
JLabel JLabel0 = new JLabel("工程");
|
JComboBox comboBox = new JComboBox();
|
|
comboBox.setPreferredSize(new Dimension(110, 28));
|
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());
|
|
JLabel JLabel1 = new JLabel("部门");
|
JComboBox<JComboBoxItem> comboBox1 = new JComboBox<>(deptList);
|
comboBox1.setPreferredSize(new Dimension(110, 28));
|
|
JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId());
|
|
JLabel JLabel2 = new JLabel("专业");
|
JComboBox<JComboBoxItem> comboBox2 = new JComboBox<>(teamList1);
|
comboBox2.setPreferredSize(new Dimension(110, 28));
|
|
JLabel JLabel3 = new JLabel("舱室");
|
JComboBox<JComboBoxItem> comboBox3 = new JComboBox<>(cabinList);
|
comboBox3.setPreferredSize(new Dimension(110, 28));
|
|
JLabel JLabel4 = new JLabel("类别");
|
JComboBox<String> comboBox4 = new JComboBox<>(typeList);
|
comboBox4.setPreferredSize(new Dimension(110, 28));
|
|
JTextField sb = new JTextField();
|
sb.setPreferredSize(new Dimension(130, 28));
|
JButton query = new JButton("查询");
|
|
top.add(JLabel0, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
top.add(comboBox, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
top.add(JLabel1, new GBC(2, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
top.add(comboBox1, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
top.add(JLabel2, new GBC(4, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
top.add(comboBox2, new GBC(5, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
top.add(JLabel3, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
top.add(comboBox3, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
top.add(JLabel4, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5));
|
top.add(comboBox4, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
top.add(sb, new GBC(4, 1, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
top.add(query, new GBC(6, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5));
|
|
List<ColumnDto> columnDto = new ArrayList<>();
|
list = level3Service.getList(shipList.get(0).getId(), deptList[0].getId(), teamList[0].getId(), cabinList[0].getId(), typeList[0],null, null,null);
|
if (list == null || list.size() == 0) {
|
JOptionPane.showMessageDialog(null, "还未录入三级网络图数据", "提示", JOptionPane.WARNING_MESSAGE);
|
return null;
|
}
|
|
columnDto.add(new ColumnDto("序号", "", 60, "autoCreate", false, null, null));
|
columnDto.add(new ColumnDto("设备名称", "name", 200, null, false, null, null));
|
columnDto.add(new ColumnDto("部门", "deptId", 150, "dict", false, null, deptList));
|
columnDto.add(new ColumnDto("专业", "teamgroupId", 150, "dict", false, null, teamList));
|
columnDto.add(new ColumnDto("舱室", "cabinId", 100, "dict", false, null, cabinList));
|
columnDto.add(new ColumnDto("类别", "type", 100, null, false, null, null));
|
|
JTable subTable = CommonTable.createCommonTable(list, columnDto);
|
subTable.setRowHeight(25);
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
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();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null, null,null);
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
});
|
|
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));
|
comboBox2.setSelectedIndex(0);
|
|
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();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null,null,null);
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
}
|
}
|
});
|
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();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null, null,null);
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
});
|
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();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getList(shipId, dept.getId(), team.getId(), cabin.getId(), type, null,null,null);
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
});
|
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();
|
|
Long shipId = shipMap.get(content);
|
list = level3Service.getList(shipId, dept.getId(), team.getId(), cabin.getId(), type,null, null,null);
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
});
|
|
query.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
list = level3Service.getList(null, null, null, null, null,null,null, sb.getText());
|
|
CommonTable.refreshTable(list, columnDto, subTable);
|
subTable.setRowHeight(25);
|
|
subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
}
|
});
|
|
JScrollPane scrollTable = new JScrollPane(subTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
scrollTable.setViewportView(subTable);
|
scrollTable.setPreferredSize(new Dimension(600,Compute.ComputeHeightWithScroll(100,frame)));
|
center.add(scrollTable);
|
frame.addComponentListener(new ComponentAdapter() {
|
@Override
|
public void componentResized(ComponentEvent e) {
|
center.setPreferredSize(new Dimension(600, Compute.ComputeHeight(100,frame)));
|
jLeft.setPreferredSize(new Dimension(600, Compute.ComputeHeight(0,frame)));
|
scrollTable.setPreferredSize(new Dimension(600,Compute.ComputeHeightWithScroll(100,frame)));
|
jLeft.revalidate();
|
jLeft.repaint();
|
center.revalidate();
|
center.repaint();
|
scrollTable.revalidate();
|
scrollTable.repaint();
|
}
|
});
|
|
JPanel track = addOrUpdate.createTrack(width - 620, height, list.get(0), frame);
|
|
// 创建水平分割面板
|
JSplitPane hSplitPane = new JSplitPane(
|
JSplitPane.HORIZONTAL_SPLIT,
|
jLeft,
|
track
|
);
|
hSplitPane.setDividerLocation(620);
|
hSplitPane.setDividerSize(10);
|
hSplitPane.setOneTouchExpandable(true);
|
hSplitPane.setContinuousLayout(true);
|
|
panel.add(hSplitPane, BorderLayout.CENTER);
|
|
subTable.addMouseListener(new MouseAdapter() {
|
public void mouseClicked(MouseEvent e) {
|
// 仅当鼠标左键单击时响应
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
// 得到选中的行列的索引值
|
int r = subTable.getSelectedRow();
|
DjJdgzNetworkLevel3 data = list.get(r);
|
addOrUpdate.refreshTable(data.getId());
|
}
|
}
|
});
|
|
return panel;
|
}
|
|
}
|