|
|
@@ -3,7 +3,6 @@ package com.mes.ui;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.mes.component.MesRadio;
|
|
|
import com.mes.component.MesWebView;
|
|
|
-import com.mes.controller.LaserController;
|
|
|
import com.mes.device.LaserDevice;
|
|
|
import com.mes.netty.NettyClient;
|
|
|
import com.mes.netty.ProtocolParam;
|
|
|
@@ -143,6 +142,11 @@ public class MesClient extends JFrame {
|
|
|
public static JTextField param22; // B面加工时间
|
|
|
public static JTextField param23; // B面零件数
|
|
|
|
|
|
+ // 顶部扫码区(参考 OP60)
|
|
|
+ public static JTextField scanTextField; // 扫码输入框
|
|
|
+ public static JLabel scanCurSideLabel; // 当前上料面标签
|
|
|
+ public static String lastSideAtLoad = ""; // 上次检测到的上料面
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
|
@@ -188,7 +192,7 @@ public class MesClient extends JFrame {
|
|
|
//读配置文件
|
|
|
private static void readProperty() throws IOException{
|
|
|
String enconding = "UTF-8";
|
|
|
- InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("resources/config/config.properties");
|
|
|
Properties pro = new Properties();
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
pro.load(br);
|
|
|
@@ -393,69 +397,94 @@ public class MesClient extends JFrame {
|
|
|
return barcodeRet;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新顶部「当前上料面」标签
|
|
|
+ * side="A" → 当前:A面(上料位)
|
|
|
+ * side="B" → 当前:B面(上料位)
|
|
|
+ * side="" → 转台未到位
|
|
|
+ */
|
|
|
+ public static void updateCurSideLabel(String side) {
|
|
|
+ if (scanCurSideLabel == null) return;
|
|
|
+ if ("A".equals(side)) {
|
|
|
+ scanCurSideLabel.setText("当前:A面");
|
|
|
+ scanCurSideLabel.setForeground(new Color(0, 128, 64));
|
|
|
+ } else if ("B".equals(side)) {
|
|
|
+ scanCurSideLabel.setText("当前:B面");
|
|
|
+ scanCurSideLabel.setForeground(new Color(0, 128, 64));
|
|
|
+ } else {
|
|
|
+ scanCurSideLabel.setText("当前:转台未到位");
|
|
|
+ scanCurSideLabel.setForeground(new Color(200, 100, 0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 扫码处理(参考 OP60,走顶部 scanTextField)
|
|
|
+ * A/B 面由 #1581 转台位置自动判断(=1 → 上料面 B,=2 → 上料面 A,=0 → 未到位)
|
|
|
+ */
|
|
|
public static void scanBarcode() {
|
|
|
- if(work_status == 1){
|
|
|
- JOptionPane.showMessageDialog(mesClientFrame,"工作中,勿扫码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
+ // 从扫码框取值并清空
|
|
|
+ String sn = scanTextField != null ? scanTextField.getText().trim() : "";
|
|
|
+ if (scanTextField != null) {
|
|
|
+ scanTextField.setText("");
|
|
|
}
|
|
|
- String scanBarcodeTitle = "请扫工件码(A面或B面)";
|
|
|
+ mesClientFrame.repaint();
|
|
|
|
|
|
- //弹窗扫工件码
|
|
|
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
|
|
|
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
|
- //获取用户
|
|
|
- getUser();
|
|
|
- //获取扫码内容36位
|
|
|
- String barcode36 = getBarcode(scanBarcode);//处理36为码
|
|
|
-
|
|
|
- // 判断A面还是B面(简单逻辑:询问用户)
|
|
|
- String[] options = {"A面", "B面"};
|
|
|
- int choice = JOptionPane.showOptionDialog(
|
|
|
- mesClientFrame,
|
|
|
- "请选择扫码面:",
|
|
|
- "选择面",
|
|
|
- JOptionPane.DEFAULT_OPTION,
|
|
|
- JOptionPane.QUESTION_MESSAGE,
|
|
|
- null,
|
|
|
- options,
|
|
|
- options[0]
|
|
|
- );
|
|
|
-
|
|
|
- String side = choice == 0 ? "A" : "B";
|
|
|
-
|
|
|
- if(side.equals("A")) {
|
|
|
- product_sn.setText(scanBarcode);
|
|
|
- } else {
|
|
|
- product_sn2.setText(scanBarcode);
|
|
|
- }
|
|
|
+ if (sn.isEmpty()) {
|
|
|
+ MesClient.setMenuStatus("工件码不能为空", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //刷新界面
|
|
|
- mesClientFrame.repaint();
|
|
|
+ // 判 A/B 面:读 #1581
|
|
|
+ String side = (laserDevice != null) ? laserDevice.readSideAtLoad() : "";
|
|
|
+ if (side.isEmpty()) {
|
|
|
+ MesClient.setMenuStatus("转台未到位,暂不能扫码", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if(!tcp_connect_flag) {
|
|
|
- MesClient.setMenuStatus("设备未连接Mes服务器",-1);
|
|
|
+ // 已合格工件未处理完 → 拒收
|
|
|
+ if (side.equals("A")) {
|
|
|
+ if (!product_sn.getText().isEmpty()
|
|
|
+ && com.mes.controller.LaserControllerDual.mesQualityFlagA) {
|
|
|
+ MesClient.setMenuStatus("A面已有合格工件码,勿重复扫码", -1);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- // 查询工件质量(MES质检)
|
|
|
- Boolean sendret = DataUtil.checkQuality(nettyClient,barcode36,user20,side);
|
|
|
- if(!sendret){
|
|
|
- MesClient.setMenuStatus("消息发送失败,请重试",-1);
|
|
|
+ product_sn.setText(sn);
|
|
|
+ } else {
|
|
|
+ if (!product_sn2.getText().isEmpty()
|
|
|
+ && com.mes.controller.LaserControllerDual.mesQualityFlagB) {
|
|
|
+ MesClient.setMenuStatus("B面已有合格工件码,勿重复扫码", -1);
|
|
|
return;
|
|
|
}
|
|
|
+ product_sn2.setText(sn);
|
|
|
+ }
|
|
|
|
|
|
- // 扫码处理交给控制器
|
|
|
- if(laserController != null) {
|
|
|
- if(side.equals("A")) {
|
|
|
- laserController.onScanCodeA(scanBarcode, user20);
|
|
|
- } else {
|
|
|
- laserController.onScanCodeB(scanBarcode, user20);
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- MesClient.setMenuStatus("请扫工件码,请重试",-1);
|
|
|
+ MesClient.setMenuStatus("扫码成功", 0);
|
|
|
+ mesClientFrame.repaint();
|
|
|
+
|
|
|
+ if (!tcp_connect_flag) {
|
|
|
+ MesClient.setMenuStatus("设备未连接Mes服务器", -1);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ // 取用户
|
|
|
+ getUser();
|
|
|
+ String barcode36 = getBarcode(sn);
|
|
|
+
|
|
|
+ // 查询工件质量(MES 质检)
|
|
|
+ Boolean sendret = DataUtil.checkQuality(nettyClient, barcode36, user20, side);
|
|
|
+ if (!sendret) {
|
|
|
+ MesClient.setMenuStatus("消息发送失败,请重试", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 扫码处理交给控制器(推进状态机 tjFlag → 1)
|
|
|
+ if (laserController != null) {
|
|
|
+ if (side.equals("A")) {
|
|
|
+ laserController.onScanCodeA(sn, user20);
|
|
|
+ } else {
|
|
|
+ laserController.onScanCodeB(sn, user20);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void logoff() {
|
|
|
@@ -621,153 +650,210 @@ public class MesClient extends JFrame {
|
|
|
contentPane.add(tabbedPane);
|
|
|
|
|
|
//首页 - 双面布局(参考OP060)
|
|
|
- JPanel indexPanelA = new CenteredPanel(972, 550);
|
|
|
+ JPanel indexPanelA = new JPanel();
|
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
|
indexPanelA.setLayout(null);
|
|
|
|
|
|
- // 扫码按钮(居中)
|
|
|
- f_scan_data_bt_1 = new JButton("扫码");
|
|
|
- f_scan_data_bt_1.addActionListener(new ActionListener() {
|
|
|
+ // ========== 顶部扫码区(参考 OP60)==========
|
|
|
+ scanCurSideLabel = new JLabel("当前:转台未到位");
|
|
|
+ scanCurSideLabel.setForeground(new Color(128, 128, 128));
|
|
|
+ scanCurSideLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ scanCurSideLabel.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
|
|
|
+ scanCurSideLabel.setBounds(26, 15, 240, 50);
|
|
|
+ indexPanelA.add(scanCurSideLabel);
|
|
|
+
|
|
|
+ scanTextField = new JTextField("");
|
|
|
+ scanTextField.setHorizontalAlignment(SwingConstants.LEFT);
|
|
|
+ scanTextField.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
+ scanTextField.setBounds(280, 15, 683, 50);
|
|
|
+ scanTextField.setColumns(10);
|
|
|
+ scanTextField.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
scanBarcode();
|
|
|
}
|
|
|
});
|
|
|
- f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
- f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
- f_scan_data_bt_1.setBounds(400, 10, 180, 60);
|
|
|
- indexPanelA.add(f_scan_data_bt_1);
|
|
|
+ indexPanelA.add(scanTextField);
|
|
|
|
|
|
// ========== A面区域 ==========
|
|
|
- pxstatus1 = new JLabel("A面");
|
|
|
- pxstatus1.setForeground(new Color(0, 128, 255));
|
|
|
+ pxstatus1 = new JLabel("A");
|
|
|
+ pxstatus1.setForeground(new Color(255, 128, 64));
|
|
|
pxstatus1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- pxstatus1.setFont(new Font("微软雅黑", Font.BOLD, 22));
|
|
|
- pxstatus1.setBounds(26, 80, 446, 35);
|
|
|
+ pxstatus1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
|
|
|
+ pxstatus1.setBounds(26, 90, 446, 44);
|
|
|
indexPanelA.add(pxstatus1);
|
|
|
|
|
|
product_sn = new JTextField();
|
|
|
+ product_sn.setText("");
|
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
product_sn.setEditable(false);
|
|
|
- product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- product_sn.setBounds(26, 120, 446, 60);
|
|
|
+ product_sn.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
+ product_sn.setBounds(26, 144, 446, 70);
|
|
|
+ product_sn.setColumns(10);
|
|
|
indexPanelA.add(product_sn);
|
|
|
|
|
|
- JLabel lblSpeed1 = new JLabel("进给速度:");
|
|
|
- lblSpeed1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblSpeed1.setBounds(26, 200, 100, 30);
|
|
|
+ // A面参数显示(下移 3 个字体大小 = 54px)
|
|
|
+ JLabel lblSpeed1 = new JLabel("进给速度");
|
|
|
+ lblSpeed1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblSpeed1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblSpeed1.setBounds(26, 334, 100, 40);
|
|
|
indexPanelA.add(lblSpeed1);
|
|
|
|
|
|
param1 = new JTextField();
|
|
|
param1.setEnabled(false);
|
|
|
param1.setEditable(false);
|
|
|
param1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param1.setBounds(130, 200, 100, 30);
|
|
|
+ param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param1.setColumns(10);
|
|
|
+ param1.setBounds(136, 334, 100, 40);
|
|
|
indexPanelA.add(param1);
|
|
|
|
|
|
- JLabel lblTime1 = new JLabel("加工时间:");
|
|
|
- lblTime1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblTime1.setBounds(26, 240, 100, 30);
|
|
|
+ JLabel lblTime1 = new JLabel("加工时间");
|
|
|
+ lblTime1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblTime1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblTime1.setBounds(266, 334, 100, 40);
|
|
|
indexPanelA.add(lblTime1);
|
|
|
|
|
|
param2 = new JTextField();
|
|
|
param2.setEnabled(false);
|
|
|
param2.setEditable(false);
|
|
|
param2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param2.setBounds(130, 240, 100, 30);
|
|
|
+ param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param2.setColumns(10);
|
|
|
+ param2.setBounds(376, 334, 100, 40);
|
|
|
indexPanelA.add(param2);
|
|
|
|
|
|
- JLabel lblCount1 = new JLabel("零件数:");
|
|
|
- lblCount1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblCount1.setBounds(26, 280, 100, 30);
|
|
|
+ JLabel lblCount1 = new JLabel("零件数");
|
|
|
+ lblCount1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblCount1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblCount1.setBounds(26, 395, 100, 40);
|
|
|
indexPanelA.add(lblCount1);
|
|
|
|
|
|
param3 = new JTextField();
|
|
|
param3.setEnabled(false);
|
|
|
param3.setEditable(false);
|
|
|
param3.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param3.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param3.setBounds(130, 280, 100, 30);
|
|
|
+ param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param3.setColumns(10);
|
|
|
+ param3.setBounds(136, 395, 100, 40);
|
|
|
indexPanelA.add(param3);
|
|
|
|
|
|
- // ========== B面区域 ==========
|
|
|
- JSeparator separator = new JSeparator();
|
|
|
- separator.setOrientation(SwingConstants.VERTICAL);
|
|
|
- separator.setBounds(495, 80, 2, 240);
|
|
|
- indexPanelA.add(separator);
|
|
|
+ // ========== 中间分隔线(上半段:工件码区域)==========
|
|
|
+ JSeparator separator_1_top = new JSeparator();
|
|
|
+ separator_1_top.setOrientation(SwingConstants.VERTICAL);
|
|
|
+ separator_1_top.setBounds(495, 77, 23, 217);
|
|
|
+ indexPanelA.add(separator_1_top);
|
|
|
+
|
|
|
+ // ========== 中间分隔线(下半段:参数区域,跟着下移 54px)==========
|
|
|
+ JSeparator separator_1 = new JSeparator();
|
|
|
+ separator_1.setOrientation(SwingConstants.VERTICAL);
|
|
|
+ separator_1.setBounds(495, 294, 23, 157);
|
|
|
+ indexPanelA.add(separator_1);
|
|
|
|
|
|
- pxstatus2 = new JLabel("B面");
|
|
|
- pxstatus2.setForeground(new Color(0, 128, 255));
|
|
|
+ // ========== B面区域 ==========
|
|
|
+ pxstatus2 = new JLabel("B");
|
|
|
+ pxstatus2.setForeground(new Color(255, 128, 64));
|
|
|
pxstatus2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- pxstatus2.setFont(new Font("微软雅黑", Font.BOLD, 22));
|
|
|
- pxstatus2.setBounds(517, 80, 446, 35);
|
|
|
+ pxstatus2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
|
|
|
+ pxstatus2.setBounds(517, 90, 446, 44);
|
|
|
indexPanelA.add(pxstatus2);
|
|
|
|
|
|
product_sn2 = new JTextField();
|
|
|
+ product_sn2.setText("");
|
|
|
product_sn2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ product_sn2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
product_sn2.setEditable(false);
|
|
|
- product_sn2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- product_sn2.setBounds(517, 120, 446, 60);
|
|
|
+ product_sn2.setColumns(10);
|
|
|
+ product_sn2.setBounds(517, 144, 446, 70);
|
|
|
indexPanelA.add(product_sn2);
|
|
|
|
|
|
- JLabel lblSpeed2 = new JLabel("进给速度:");
|
|
|
- lblSpeed2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblSpeed2.setBounds(517, 200, 100, 30);
|
|
|
+ // ========== 横向分隔线(下移 3 个字体大小 = 54px)==========
|
|
|
+ JSeparator separator_h = new JSeparator();
|
|
|
+ separator_h.setOrientation(SwingConstants.HORIZONTAL);
|
|
|
+ separator_h.setBounds(26, 294, 937, 10);
|
|
|
+ indexPanelA.add(separator_h);
|
|
|
+
|
|
|
+ // B面参数显示(下移 3 个字体大小 = 54px)
|
|
|
+ JLabel lblSpeed2 = new JLabel("进给速度");
|
|
|
+ lblSpeed2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblSpeed2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblSpeed2.setBounds(528, 334, 100, 40);
|
|
|
indexPanelA.add(lblSpeed2);
|
|
|
|
|
|
param21 = new JTextField();
|
|
|
param21.setEnabled(false);
|
|
|
param21.setEditable(false);
|
|
|
param21.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param21.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param21.setBounds(621, 200, 100, 30);
|
|
|
+ param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param21.setColumns(10);
|
|
|
+ param21.setBounds(638, 334, 100, 40);
|
|
|
indexPanelA.add(param21);
|
|
|
|
|
|
- JLabel lblTime2 = new JLabel("加工时间:");
|
|
|
- lblTime2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblTime2.setBounds(517, 240, 100, 30);
|
|
|
+ JLabel lblTime2 = new JLabel("加工时间");
|
|
|
+ lblTime2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblTime2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblTime2.setBounds(772, 334, 100, 40);
|
|
|
indexPanelA.add(lblTime2);
|
|
|
|
|
|
param22 = new JTextField();
|
|
|
param22.setEnabled(false);
|
|
|
param22.setEditable(false);
|
|
|
param22.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param22.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param22.setBounds(621, 240, 100, 30);
|
|
|
+ param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param22.setColumns(10);
|
|
|
+ param22.setBounds(882, 334, 100, 40);
|
|
|
indexPanelA.add(param22);
|
|
|
|
|
|
- JLabel lblCount2 = new JLabel("零件数:");
|
|
|
- lblCount2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- lblCount2.setBounds(517, 280, 100, 30);
|
|
|
+ JLabel lblCount2 = new JLabel("零件数");
|
|
|
+ lblCount2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblCount2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ lblCount2.setBounds(528, 395, 100, 40);
|
|
|
indexPanelA.add(lblCount2);
|
|
|
|
|
|
param23 = new JTextField();
|
|
|
param23.setEnabled(false);
|
|
|
param23.setEditable(false);
|
|
|
param23.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- param23.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
- param23.setBounds(621, 280, 100, 30);
|
|
|
+ param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
+ param23.setColumns(10);
|
|
|
+ param23.setBounds(638, 395, 100, 40);
|
|
|
indexPanelA.add(param23);
|
|
|
|
|
|
- // 返修标签(隐藏,需要时显示)
|
|
|
- fxlabel = new JLabel("返修件,请仔细检查");
|
|
|
- fxlabel.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
- fxlabel.setBounds(300, 350, 400, 50);
|
|
|
- fxlabel.setForeground(Color.RED);
|
|
|
- fxlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- fxlabel.setVisible(false);
|
|
|
- indexPanelA.add(fxlabel);
|
|
|
-
|
|
|
- // 占位按钮(隐藏)
|
|
|
- finish_ok_bt = new JButton("OK");
|
|
|
+ // 隐藏的扫码按钮(通过菜单触发)
|
|
|
+ finish_ok_bt = new JButton("扫码");
|
|
|
finish_ok_bt.setVisible(false);
|
|
|
+ finish_ok_bt.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ scanBarcode();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
+ finish_ok_bt.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 32));
|
|
|
+ finish_ok_bt.setBounds(136, 167, 230, 80);
|
|
|
+ finish_ok_bt.setEnabled(false);
|
|
|
indexPanelA.add(finish_ok_bt);
|
|
|
|
|
|
- finish_ng_bt = new JButton("NG");
|
|
|
+ finish_ng_bt = new JButton("扫码");
|
|
|
finish_ng_bt.setVisible(false);
|
|
|
+ finish_ng_bt.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ scanBarcode();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
+ finish_ng_bt.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 32));
|
|
|
+ finish_ng_bt.setBounds(633, 167, 230, 80);
|
|
|
+ finish_ng_bt.setEnabled(false);
|
|
|
indexPanelA.add(finish_ng_bt);
|
|
|
|
|
|
+ // 返修标签
|
|
|
+ fxlabel = new JLabel("该工件为返修件,请仔细检查");
|
|
|
+ fxlabel.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 38));
|
|
|
+ fxlabel.setBounds(250, 430, 500, 70);
|
|
|
+ fxlabel.setForeground(Color.RED);
|
|
|
+ fxlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ fxlabel.setVisible(false);
|
|
|
+ indexPanelA.add(fxlabel);
|
|
|
+
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
tabbedPane.setEnabledAt(0, true);
|
|
|
|
|
|
@@ -1109,6 +1195,30 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
}, 1000, 1000);
|
|
|
|
|
|
+ // 2.5 转台位置检测(1秒)— 更新顶部标签 + 保持扫码框焦点
|
|
|
+ Timer sideDetectTimer = new Timer();
|
|
|
+ sideDetectTimer.schedule(new TimerTask() {
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ if (scanTextField != null) {
|
|
|
+ SwingUtilities.invokeLater(() -> scanTextField.requestFocusInWindow());
|
|
|
+ }
|
|
|
+ if (laserDevice == null || !laserDevice.isConnected()) return;
|
|
|
+
|
|
|
+ String side = laserDevice.readSideAtLoad();
|
|
|
+ SwingUtilities.invokeLater(() -> updateCurSideLabel(side));
|
|
|
+
|
|
|
+ // 记录最近一次上料面(供状态跟踪用;不主动写 #1590,避免跟 checkStatus 打架)
|
|
|
+ if (!side.equals(lastSideAtLoad)) {
|
|
|
+ lastSideAtLoad = side;
|
|
|
+ log.info("转台面切换,检测到上料面={}", side.isEmpty() ? "未到位" : side);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("转台位置检测异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000, 1000);
|
|
|
+
|
|
|
// 3. 参数上传定时器(30秒)
|
|
|
Timer laserUploadTimer = new Timer();
|
|
|
laserUploadTimer.schedule(new TimerTask() {
|