|
@@ -95,6 +95,21 @@ public class MesClient extends JFrame {
|
|
|
public static JPanel gunPanelContainer;
|
|
public static JPanel gunPanelContainer;
|
|
|
public static JLabel pzlabel;
|
|
public static JLabel pzlabel;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * TW 项目扫码前缀 → 螺栓安装颗数
|
|
|
|
|
+ * 四驱=10,后驱/二驱=6
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final String[] BOLT_COUNT_10_PREFIXES = {
|
|
|
|
|
+ "5019016600341", // 国内四驱 B009-032
|
|
|
|
|
+ "5019016600571", // 海外四驱 B009-039
|
|
|
|
|
+ "5003136600651" // 海外右舵四驱 B009-055
|
|
|
|
|
+ };
|
|
|
|
|
+ private static final String[] BOLT_COUNT_6_PREFIXES = {
|
|
|
|
|
+ "5019016600511", // 国内后驱 B009-034
|
|
|
|
|
+ "5003136600051", // 海外后驱 B009-037
|
|
|
|
|
+ "5003136600661" // 海外右舵二驱 B009-056
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
public static java.util.Timer submitCheckTimer;
|
|
public static java.util.Timer submitCheckTimer;
|
|
|
|
|
|
|
|
public static boolean autoSubmitEnabled = true;
|
|
public static boolean autoSubmitEnabled = true;
|
|
@@ -190,7 +205,9 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
List<YgslConfig> configs = JdbcUtils.getEnabledYgslConfigs();
|
|
List<YgslConfig> configs = JdbcUtils.getEnabledYgslConfigs();
|
|
|
System.out.println("initGunPanels - 获取到配置: " + configs.size() + " 把枪");
|
|
System.out.println("initGunPanels - 获取到配置: " + configs.size() + " 把枪");
|
|
|
- for (YgslConfig config : configs) {
|
|
|
|
|
|
|
+ // 本工位只使用一把枪
|
|
|
|
|
+ if (!configs.isEmpty()) {
|
|
|
|
|
+ YgslConfig config = configs.get(0);
|
|
|
GunPanel gunPanel = new GunPanel(config);
|
|
GunPanel gunPanel = new GunPanel(config);
|
|
|
gunPanel.setTaskCompletedListener(new GunPanel.OnTaskCompletedListener() {
|
|
gunPanel.setTaskCompletedListener(new GunPanel.OnTaskCompletedListener() {
|
|
|
@Override
|
|
@Override
|
|
@@ -218,6 +235,40 @@ public class MesClient extends JFrame {
|
|
|
System.out.println("已加载 " + gunPanels.size() + " 把扭力枪");
|
|
System.out.println("已加载 " + gunPanels.size() + " 把扭力枪");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据工件码前缀解析螺栓安装颗数;无法识别返回 -1
|
|
|
|
|
+ */
|
|
|
|
|
+ public static int resolveBoltCountBySn(String sn) {
|
|
|
|
|
+ if (sn == null || sn.trim().isEmpty()) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ String code = sn.trim();
|
|
|
|
|
+ for (String prefix : BOLT_COUNT_10_PREFIXES) {
|
|
|
|
|
+ if (code.startsWith(prefix)) {
|
|
|
|
|
+ return 10;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String prefix : BOLT_COUNT_6_PREFIXES) {
|
|
|
|
|
+ if (code.startsWith(prefix)) {
|
|
|
|
|
+ return 6;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 将扫码解析出的颗数应用到当前枪 */
|
|
|
|
|
+ public static boolean applyBoltCountBySn(String sn) {
|
|
|
|
|
+ int boltCount = resolveBoltCountBySn(sn);
|
|
|
|
|
+ if (boltCount < 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (GunPanel panel : gunPanels) {
|
|
|
|
|
+ panel.setTaskCount(boltCount);
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("扫码规则设定拧紧颗数: " + boltCount + ",SN=" + sn);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void startSubmitCheckTimer() {
|
|
public static void startSubmitCheckTimer() {
|
|
|
if (submitCheckTimer != null) {
|
|
if (submitCheckTimer != null) {
|
|
|
submitCheckTimer.cancel();
|
|
submitCheckTimer.cancel();
|
|
@@ -630,12 +681,18 @@ public class MesClient extends JFrame {
|
|
|
//弹窗扫工件码
|
|
//弹窗扫工件码
|
|
|
String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
|
|
String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
|
|
|
if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
|
|
|
+ // 按 TW 项目代码前缀判断拧紧颗数
|
|
|
|
|
+ if (!applyBoltCountBySn(scanBarcode)) {
|
|
|
|
|
+ JOptionPane.showMessageDialog(mesClientFrame,
|
|
|
|
|
+ "无法识别该工件码对应的螺栓颗数规则,请确认扫码内容",
|
|
|
|
|
+ "提示窗口", JOptionPane.WARNING_MESSAGE);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//获取用户
|
|
//获取用户
|
|
|
getUser();
|
|
getUser();
|
|
|
//获取扫码内容36位
|
|
//获取扫码内容36位
|
|
|
String barcode36 = getBarcode(scanBarcode);//处理36为码
|
|
String barcode36 = getBarcode(scanBarcode);//处理36为码
|
|
|
- //工位号
|
|
|
|
|
- String gw = "";
|
|
|
|
|
switch(scan_type) {
|
|
switch(scan_type) {
|
|
|
case 1:
|
|
case 1:
|
|
|
product_sn.setText(scanBarcode);
|
|
product_sn.setText(scanBarcode);
|
|
@@ -1081,27 +1138,36 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static JTable configTable;
|
|
private static JTable configTable;
|
|
|
- private static JButton addGunButton;
|
|
|
|
|
private static JButton saveConfigButton;
|
|
private static JButton saveConfigButton;
|
|
|
|
|
|
|
|
public static void initGunConfigPanel(JPanel panel) {
|
|
public static void initGunConfigPanel(JPanel panel) {
|
|
|
- JLabel titleLabel = new JLabel("扭力枪配置管理");
|
|
|
|
|
|
|
+ JLabel titleLabel = new JLabel("扭力枪配置(仅一把)");
|
|
|
titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
|
|
titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
|
|
|
- titleLabel.setBounds(350, 20, 300, 40);
|
|
|
|
|
|
|
+ titleLabel.setBounds(320, 20, 360, 40);
|
|
|
panel.add(titleLabel);
|
|
panel.add(titleLabel);
|
|
|
|
|
|
|
|
- String[] columnNames = {"枪号", "名称", "IP地址", "端口", "任务数", "启用", "自动提交"};
|
|
|
|
|
|
|
+ JLabel tipLabel = new JLabel("拧紧颗数由扫码规则自动判断,无需在此配置");
|
|
|
|
|
+ tipLabel.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
|
|
+ tipLabel.setForeground(Color.GRAY);
|
|
|
|
|
+ tipLabel.setBounds(300, 55, 400, 25);
|
|
|
|
|
+ panel.add(tipLabel);
|
|
|
|
|
+
|
|
|
|
|
+ // 颗数不在配置中维护,只保留枪号/名称/IP/端口/启用/自动提交
|
|
|
|
|
+ String[] columnNames = {"枪号", "名称", "IP地址", "端口", "启用", "自动提交"};
|
|
|
List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
|
|
List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
|
|
|
- Object[][] data = new Object[configs.size()][7];
|
|
|
|
|
|
|
+ // 只展示一把枪(取枪号最小的一条;若库里有多条历史数据也只编辑第一把)
|
|
|
|
|
+ if (configs.size() > 1) {
|
|
|
|
|
+ configs = configs.subList(0, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ Object[][] data = new Object[configs.size()][6];
|
|
|
for (int i = 0; i < configs.size(); i++) {
|
|
for (int i = 0; i < configs.size(); i++) {
|
|
|
YgslConfig config = configs.get(i);
|
|
YgslConfig config = configs.get(i);
|
|
|
data[i][0] = config.getGunIndex();
|
|
data[i][0] = config.getGunIndex();
|
|
|
data[i][1] = config.getGunName();
|
|
data[i][1] = config.getGunName();
|
|
|
data[i][2] = config.getIpAddress();
|
|
data[i][2] = config.getIpAddress();
|
|
|
data[i][3] = config.getPort();
|
|
data[i][3] = config.getPort();
|
|
|
- data[i][4] = config.getTaskCount();
|
|
|
|
|
- data[i][5] = config.getEnabled() == 1 ? "是" : "否";
|
|
|
|
|
- data[i][6] = config.getAutoSubmit() == 1 ? "是" : "否";
|
|
|
|
|
|
|
+ data[i][4] = config.getEnabled() == 1 ? "是" : "否";
|
|
|
|
|
+ data[i][5] = config.getAutoSubmit() == 1 ? "是" : "否";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
configTable = new JTable(data, columnNames);
|
|
configTable = new JTable(data, columnNames);
|
|
@@ -1110,20 +1176,9 @@ public class MesClient extends JFrame {
|
|
|
configTable.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
|
|
configTable.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
|
|
|
|
|
|
|
|
JScrollPane scrollPane = new JScrollPane(configTable);
|
|
JScrollPane scrollPane = new JScrollPane(configTable);
|
|
|
- scrollPane.setBounds(50, 70, 900, 400);
|
|
|
|
|
|
|
+ scrollPane.setBounds(50, 90, 900, 380);
|
|
|
panel.add(scrollPane);
|
|
panel.add(scrollPane);
|
|
|
|
|
|
|
|
- addGunButton = new JButton("添加枪");
|
|
|
|
|
- addGunButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
- addGunButton.setBounds(150, 490, 120, 40);
|
|
|
|
|
- addGunButton.addActionListener(new ActionListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
|
|
- addNewGun(panel);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- panel.add(addGunButton);
|
|
|
|
|
-
|
|
|
|
|
saveConfigButton = new JButton("保存配置");
|
|
saveConfigButton = new JButton("保存配置");
|
|
|
saveConfigButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
saveConfigButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
saveConfigButton.setBounds(300, 490, 120, 40);
|
|
saveConfigButton.setBounds(300, 490, 120, 40);
|
|
@@ -1135,34 +1190,25 @@ public class MesClient extends JFrame {
|
|
|
});
|
|
});
|
|
|
panel.add(saveConfigButton);
|
|
panel.add(saveConfigButton);
|
|
|
|
|
|
|
|
- JButton deleteButton = new JButton("删除选中");
|
|
|
|
|
- deleteButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
- deleteButton.setBounds(450, 490, 120, 40);
|
|
|
|
|
- deleteButton.addActionListener(new ActionListener() {
|
|
|
|
|
|
|
+ JButton editButton = new JButton("编辑");
|
|
|
|
|
+ editButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ editButton.setBounds(450, 490, 120, 40);
|
|
|
|
|
+ editButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- int selectedRow = configTable.getSelectedRow();
|
|
|
|
|
- if (selectedRow >= 0) {
|
|
|
|
|
- int confirm = JOptionPane.showConfirmDialog(mesClientFrame, "确定要删除选中的配置吗?", "确认删除", JOptionPane.YES_NO_OPTION);
|
|
|
|
|
- if (confirm == JOptionPane.YES_OPTION) {
|
|
|
|
|
- List<YgslConfig> allConfigs = JdbcUtils.getYgslConfigs();
|
|
|
|
|
- if (selectedRow < allConfigs.size()) {
|
|
|
|
|
- JdbcUtils.deleteYgslConfig(allConfigs.get(selectedRow).getId());
|
|
|
|
|
- reloadGunConfigs(panel);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- JOptionPane.showMessageDialog(mesClientFrame, "请先选中一行", "提示", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ editGunConfig(0, panel);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- panel.add(deleteButton);
|
|
|
|
|
|
|
+ panel.add(editButton);
|
|
|
|
|
|
|
|
configTable.addMouseListener(new MouseAdapter() {
|
|
configTable.addMouseListener(new MouseAdapter() {
|
|
|
- public void mouseDoubleClick(MouseEvent e) {
|
|
|
|
|
- int row = configTable.getSelectedRow();
|
|
|
|
|
- if (row >= 0) {
|
|
|
|
|
- editGunConfig(row, panel);
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void mouseClicked(MouseEvent e) {
|
|
|
|
|
+ if (e.getClickCount() == 2) {
|
|
|
|
|
+ int row = configTable.getSelectedRow();
|
|
|
|
|
+ if (row >= 0) {
|
|
|
|
|
+ editGunConfig(row, panel);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -1170,64 +1216,62 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
private static void editGunConfig(int row, JPanel panel) {
|
|
private static void editGunConfig(int row, JPanel panel) {
|
|
|
List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
|
|
List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
|
|
|
- if (row >= configs.size()) return;
|
|
|
|
|
|
|
+ if (configs.isEmpty()) return;
|
|
|
|
|
+ if (row >= configs.size()) row = 0;
|
|
|
|
|
|
|
|
YgslConfig config = configs.get(row);
|
|
YgslConfig config = configs.get(row);
|
|
|
|
|
|
|
|
JDialog dialog = new JDialog(mesClientFrame, "编辑扭力枪", true);
|
|
JDialog dialog = new JDialog(mesClientFrame, "编辑扭力枪", true);
|
|
|
- dialog.setSize(400, 400);
|
|
|
|
|
|
|
+ dialog.setSize(400, 360);
|
|
|
dialog.setLocationRelativeTo(mesClientFrame);
|
|
dialog.setLocationRelativeTo(mesClientFrame);
|
|
|
dialog.setLayout(null);
|
|
dialog.setLayout(null);
|
|
|
|
|
|
|
|
- JLabel idLabel = new JLabel("ID: " + config.getId());
|
|
|
|
|
- idLabel.setBounds(50, 20, 300, 30);
|
|
|
|
|
- dialog.add(idLabel);
|
|
|
|
|
-
|
|
|
|
|
JLabel nameLabel = new JLabel("枪号:");
|
|
JLabel nameLabel = new JLabel("枪号:");
|
|
|
- nameLabel.setBounds(50, 60, 80, 30);
|
|
|
|
|
|
|
+ nameLabel.setBounds(50, 30, 80, 30);
|
|
|
dialog.add(nameLabel);
|
|
dialog.add(nameLabel);
|
|
|
JTextField nameField = new JTextField(String.valueOf(config.getGunIndex()));
|
|
JTextField nameField = new JTextField(String.valueOf(config.getGunIndex()));
|
|
|
- nameField.setBounds(140, 60, 180, 30);
|
|
|
|
|
|
|
+ nameField.setBounds(140, 30, 180, 30);
|
|
|
dialog.add(nameField);
|
|
dialog.add(nameField);
|
|
|
|
|
|
|
|
JLabel gunNameLabel = new JLabel("名称:");
|
|
JLabel gunNameLabel = new JLabel("名称:");
|
|
|
- gunNameLabel.setBounds(50, 100, 80, 30);
|
|
|
|
|
|
|
+ gunNameLabel.setBounds(50, 70, 80, 30);
|
|
|
dialog.add(gunNameLabel);
|
|
dialog.add(gunNameLabel);
|
|
|
JTextField gunNameField = new JTextField(config.getGunName());
|
|
JTextField gunNameField = new JTextField(config.getGunName());
|
|
|
- gunNameField.setBounds(140, 100, 180, 30);
|
|
|
|
|
|
|
+ gunNameField.setBounds(140, 70, 180, 30);
|
|
|
dialog.add(gunNameField);
|
|
dialog.add(gunNameField);
|
|
|
|
|
|
|
|
JLabel ipLabel = new JLabel("IP地址:");
|
|
JLabel ipLabel = new JLabel("IP地址:");
|
|
|
- ipLabel.setBounds(50, 140, 80, 30);
|
|
|
|
|
|
|
+ ipLabel.setBounds(50, 110, 80, 30);
|
|
|
dialog.add(ipLabel);
|
|
dialog.add(ipLabel);
|
|
|
JTextField ipField = new JTextField(config.getIpAddress());
|
|
JTextField ipField = new JTextField(config.getIpAddress());
|
|
|
- ipField.setBounds(140, 140, 180, 30);
|
|
|
|
|
|
|
+ ipField.setBounds(140, 110, 180, 30);
|
|
|
dialog.add(ipField);
|
|
dialog.add(ipField);
|
|
|
|
|
|
|
|
JLabel portLabel = new JLabel("端口:");
|
|
JLabel portLabel = new JLabel("端口:");
|
|
|
- portLabel.setBounds(50, 180, 80, 30);
|
|
|
|
|
|
|
+ portLabel.setBounds(50, 150, 80, 30);
|
|
|
dialog.add(portLabel);
|
|
dialog.add(portLabel);
|
|
|
JTextField portField = new JTextField(String.valueOf(config.getPort()));
|
|
JTextField portField = new JTextField(String.valueOf(config.getPort()));
|
|
|
- portField.setBounds(140, 180, 180, 30);
|
|
|
|
|
|
|
+ portField.setBounds(140, 150, 180, 30);
|
|
|
dialog.add(portField);
|
|
dialog.add(portField);
|
|
|
|
|
|
|
|
- JLabel taskLabel = new JLabel("任务数:");
|
|
|
|
|
- taskLabel.setBounds(50, 220, 80, 30);
|
|
|
|
|
- dialog.add(taskLabel);
|
|
|
|
|
- JTextField taskField = new JTextField(String.valueOf(config.getTaskCount()));
|
|
|
|
|
- taskField.setBounds(140, 220, 180, 30);
|
|
|
|
|
- dialog.add(taskField);
|
|
|
|
|
-
|
|
|
|
|
JLabel enabledLabel = new JLabel("启用:");
|
|
JLabel enabledLabel = new JLabel("启用:");
|
|
|
- enabledLabel.setBounds(50, 260, 80, 30);
|
|
|
|
|
|
|
+ enabledLabel.setBounds(50, 190, 80, 30);
|
|
|
dialog.add(enabledLabel);
|
|
dialog.add(enabledLabel);
|
|
|
JComboBox<String> enabledBox = new JComboBox<>(new String[]{"否", "是"});
|
|
JComboBox<String> enabledBox = new JComboBox<>(new String[]{"否", "是"});
|
|
|
- enabledBox.setBounds(140, 260, 180, 30);
|
|
|
|
|
|
|
+ enabledBox.setBounds(140, 190, 180, 30);
|
|
|
enabledBox.setSelectedIndex(config.getEnabled() == 1 ? 1 : 0);
|
|
enabledBox.setSelectedIndex(config.getEnabled() == 1 ? 1 : 0);
|
|
|
dialog.add(enabledBox);
|
|
dialog.add(enabledBox);
|
|
|
|
|
|
|
|
|
|
+ JLabel autoLabel = new JLabel("自动提交:");
|
|
|
|
|
+ autoLabel.setBounds(50, 230, 80, 30);
|
|
|
|
|
+ dialog.add(autoLabel);
|
|
|
|
|
+ JComboBox<String> autoBox = new JComboBox<>(new String[]{"否", "是"});
|
|
|
|
|
+ autoBox.setBounds(140, 230, 180, 30);
|
|
|
|
|
+ autoBox.setSelectedIndex(config.getAutoSubmit() == 1 ? 1 : 0);
|
|
|
|
|
+ dialog.add(autoBox);
|
|
|
|
|
+
|
|
|
JButton okButton = new JButton("保存");
|
|
JButton okButton = new JButton("保存");
|
|
|
- okButton.setBounds(100, 310, 80, 30);
|
|
|
|
|
|
|
+ okButton.setBounds(100, 280, 80, 30);
|
|
|
okButton.addActionListener(new ActionListener() {
|
|
okButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -1236,8 +1280,9 @@ public class MesClient extends JFrame {
|
|
|
config.setGunName(gunNameField.getText());
|
|
config.setGunName(gunNameField.getText());
|
|
|
config.setIpAddress(ipField.getText());
|
|
config.setIpAddress(ipField.getText());
|
|
|
config.setPort(Integer.parseInt(portField.getText()));
|
|
config.setPort(Integer.parseInt(portField.getText()));
|
|
|
- config.setTaskCount(Integer.parseInt(taskField.getText()));
|
|
|
|
|
|
|
+ config.setTaskCount(0);
|
|
|
config.setEnabled(enabledBox.getSelectedIndex() == 1 ? 1 : 0);
|
|
config.setEnabled(enabledBox.getSelectedIndex() == 1 ? 1 : 0);
|
|
|
|
|
+ config.setAutoSubmit(autoBox.getSelectedIndex() == 1 ? 1 : 0);
|
|
|
|
|
|
|
|
JdbcUtils.updateYgslConfig(config);
|
|
JdbcUtils.updateYgslConfig(config);
|
|
|
dialog.dispose();
|
|
dialog.dispose();
|
|
@@ -1250,84 +1295,6 @@ public class MesClient extends JFrame {
|
|
|
dialog.add(okButton);
|
|
dialog.add(okButton);
|
|
|
|
|
|
|
|
JButton cancelButton = new JButton("取消");
|
|
JButton cancelButton = new JButton("取消");
|
|
|
- cancelButton.setBounds(200, 310, 80, 30);
|
|
|
|
|
- cancelButton.addActionListener(new ActionListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
|
|
- dialog.dispose();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- dialog.add(cancelButton);
|
|
|
|
|
-
|
|
|
|
|
- dialog.setVisible(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static void addNewGun(JPanel panel) {
|
|
|
|
|
- JDialog dialog = new JDialog(mesClientFrame, "添加扭力枪", true);
|
|
|
|
|
- dialog.setSize(400, 350);
|
|
|
|
|
- dialog.setLocationRelativeTo(mesClientFrame);
|
|
|
|
|
- dialog.setLayout(null);
|
|
|
|
|
-
|
|
|
|
|
- JLabel nameLabel = new JLabel("枪号:");
|
|
|
|
|
- nameLabel.setBounds(50, 30, 80, 30);
|
|
|
|
|
- dialog.add(nameLabel);
|
|
|
|
|
- JTextField nameField = new JTextField();
|
|
|
|
|
- nameField.setBounds(140, 30, 180, 30);
|
|
|
|
|
- dialog.add(nameField);
|
|
|
|
|
-
|
|
|
|
|
- JLabel gunNameLabel = new JLabel("名称:");
|
|
|
|
|
- gunNameLabel.setBounds(50, 80, 80, 30);
|
|
|
|
|
- dialog.add(gunNameLabel);
|
|
|
|
|
- JTextField gunNameField = new JTextField("M5");
|
|
|
|
|
- gunNameField.setBounds(140, 80, 180, 30);
|
|
|
|
|
- dialog.add(gunNameField);
|
|
|
|
|
-
|
|
|
|
|
- JLabel ipLabel = new JLabel("IP地址:");
|
|
|
|
|
- ipLabel.setBounds(50, 130, 80, 30);
|
|
|
|
|
- dialog.add(ipLabel);
|
|
|
|
|
- JTextField ipField = new JTextField("192.168.5.100");
|
|
|
|
|
- ipField.setBounds(140, 130, 180, 30);
|
|
|
|
|
- dialog.add(ipField);
|
|
|
|
|
-
|
|
|
|
|
- JLabel portLabel = new JLabel("端口:");
|
|
|
|
|
- portLabel.setBounds(50, 180, 80, 30);
|
|
|
|
|
- dialog.add(portLabel);
|
|
|
|
|
- JTextField portField = new JTextField("4545");
|
|
|
|
|
- portField.setBounds(140, 180, 180, 30);
|
|
|
|
|
- dialog.add(portField);
|
|
|
|
|
-
|
|
|
|
|
- JLabel taskLabel = new JLabel("任务数:");
|
|
|
|
|
- taskLabel.setBounds(50, 230, 80, 30);
|
|
|
|
|
- dialog.add(taskLabel);
|
|
|
|
|
- JTextField taskField = new JTextField("12");
|
|
|
|
|
- taskField.setBounds(140, 230, 180, 30);
|
|
|
|
|
- dialog.add(taskField);
|
|
|
|
|
-
|
|
|
|
|
- JButton okButton = new JButton("确定");
|
|
|
|
|
- okButton.setBounds(100, 280, 80, 30);
|
|
|
|
|
- okButton.addActionListener(new ActionListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
|
|
- try {
|
|
|
|
|
- int gunIndex = Integer.parseInt(nameField.getText());
|
|
|
|
|
- String gunName = gunNameField.getText();
|
|
|
|
|
- String ip = ipField.getText();
|
|
|
|
|
- int port = Integer.parseInt(portField.getText());
|
|
|
|
|
- int taskCount = Integer.parseInt(taskField.getText());
|
|
|
|
|
-
|
|
|
|
|
- YgslConfig config = new YgslConfig(gunIndex, gunName, ip, port, taskCount);
|
|
|
|
|
- JdbcUtils.insertYgslConfig(config);
|
|
|
|
|
-
|
|
|
|
|
- dialog.dispose();
|
|
|
|
|
- reloadGunConfigs(panel);
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
- JOptionPane.showMessageDialog(dialog, "输入格式错误,请检查", "错误", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- dialog.add(okButton);
|
|
|
|
|
-
|
|
|
|
|
- JButton cancelButton = new JButton("取消");
|
|
|
|
|
cancelButton.setBounds(200, 280, 80, 30);
|
|
cancelButton.setBounds(200, 280, 80, 30);
|
|
|
cancelButton.addActionListener(new ActionListener() {
|
|
cancelButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
@Override
|
|
@@ -1350,10 +1317,11 @@ public class MesClient extends JFrame {
|
|
|
config.setGunIndex((Integer) configTable.getValueAt(i, 0));
|
|
config.setGunIndex((Integer) configTable.getValueAt(i, 0));
|
|
|
config.setGunName((String) configTable.getValueAt(i, 1));
|
|
config.setGunName((String) configTable.getValueAt(i, 1));
|
|
|
config.setIpAddress((String) configTable.getValueAt(i, 2));
|
|
config.setIpAddress((String) configTable.getValueAt(i, 2));
|
|
|
- config.setPort((Integer) configTable.getValueAt(i, 3));
|
|
|
|
|
- config.setTaskCount((Integer) configTable.getValueAt(i, 4));
|
|
|
|
|
- config.setEnabled(((String) configTable.getValueAt(i, 5)).equals("是") ? 1 : 0);
|
|
|
|
|
- config.setAutoSubmit(((String) configTable.getValueAt(i, 6)).equals("是") ? 1 : 0);
|
|
|
|
|
|
|
+ Object portVal = configTable.getValueAt(i, 3);
|
|
|
|
|
+ config.setPort(portVal instanceof Integer ? (Integer) portVal : Integer.parseInt(String.valueOf(portVal)));
|
|
|
|
|
+ config.setTaskCount(0);
|
|
|
|
|
+ config.setEnabled(((String) configTable.getValueAt(i, 4)).equals("是") ? 1 : 0);
|
|
|
|
|
+ config.setAutoSubmit(((String) configTable.getValueAt(i, 5)).equals("是") ? 1 : 0);
|
|
|
|
|
|
|
|
JdbcUtils.updateYgslConfig(config);
|
|
JdbcUtils.updateYgslConfig(config);
|
|
|
}
|
|
}
|