|
@@ -5,6 +5,7 @@ import com.fazecast.jSerialComm.SerialPort;
|
|
|
import com.fazecast.jSerialComm.SerialPortEvent;
|
|
import com.fazecast.jSerialComm.SerialPortEvent;
|
|
|
import com.mes.component.MesRadio;
|
|
import com.mes.component.MesRadio;
|
|
|
import com.mes.component.MesWebView;
|
|
import com.mes.component.MesWebView;
|
|
|
|
|
+import com.mes.laser.LaserFlowManager;
|
|
|
import com.mes.netty.NettyClient;
|
|
import com.mes.netty.NettyClient;
|
|
|
import com.mes.util.DateLocalUtils;
|
|
import com.mes.util.DateLocalUtils;
|
|
|
import com.mes.util.JdbcUtils;
|
|
import com.mes.util.JdbcUtils;
|
|
@@ -95,6 +96,11 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
public static SerialPort serialPort; // 串口对象
|
|
public static SerialPort serialPort; // 串口对象
|
|
|
|
|
|
|
|
|
|
+ // 镭雕相关
|
|
|
|
|
+ public static JButton laser_get_code_bt; // 获取镭雕码按钮
|
|
|
|
|
+ public static JButton laser_reset_bt; // 人工复位按钮
|
|
|
|
|
+ public static LaserFlowManager laserFlowManager;
|
|
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
|
// JOptionPane.showMessageDialog(null, "已有一个程序在运行,程序退出");
|
|
// JOptionPane.showMessageDialog(null, "已有一个程序在运行,程序退出");
|
|
@@ -126,6 +132,9 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
checkTimer();
|
|
checkTimer();
|
|
|
|
|
|
|
|
|
|
+ // 启动镭雕流程管理器(含本地HTTP服务,接收镭雕软件完成上报)
|
|
|
|
|
+ initLaserFlow();
|
|
|
|
|
+
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -423,10 +432,61 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 复用op040既有建档提交逻辑(原finish_ok_bt/finish_ng_bt里的sendCreate调用抽出来)
|
|
|
|
|
+ // sn: 用于提交的编码(客户编码),qret: OK/NG
|
|
|
|
|
+ public static boolean submitLaserResult(String sn, String qret){
|
|
|
|
|
+ if(sn == null || sn.isEmpty()){
|
|
|
|
|
+ setMenuStatus("客户编码为空,无法提交",1);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ getUser();
|
|
|
|
|
+ String snPad = getBarcode(sn);
|
|
|
|
|
+ Boolean sendret = DataUtil.sendCreate(nettyClient, snPad, qret, user20);
|
|
|
|
|
+ if(!sendret){
|
|
|
|
|
+ setMenuStatus("结果提交MES失败,请重试",1);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 初始化镭雕流程管理器
|
|
|
|
|
+ public static void initLaserFlow(){
|
|
|
|
|
+ laserFlowManager = new LaserFlowManager(new LaserFlowManager.UiCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onStatus(String msg, boolean error) {
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus(msg, error ? 1 : 0));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onLockButton(boolean lock) {
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
|
|
+ if(laser_get_code_bt != null){
|
|
|
|
|
+ laser_get_code_bt.setEnabled(!lock);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onCodeReceived(String code) {
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> product_sn.setText(code));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onSubmitResult(String customerSn, String qret) {
|
|
|
|
|
+ return submitLaserResult(customerSn, qret);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ laserFlowManager.startCompleteServer();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void logoff() {
|
|
public static void logoff() {
|
|
|
// welcomeWin.setVisible(true);
|
|
// welcomeWin.setVisible(true);
|
|
|
mesClientFrame.setVisible(false);
|
|
mesClientFrame.setVisible(false);
|
|
|
|
|
|
|
|
|
|
+ if(laserFlowManager != null){
|
|
|
|
|
+ laserFlowManager.stopCompleteServer();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
nettyClient = null;
|
|
nettyClient = null;
|
|
|
// if(heartBeatTimer!=null) {
|
|
// if(heartBeatTimer!=null) {
|
|
|
// heartBeatTimer.cancel();
|
|
// heartBeatTimer.cancel();
|
|
@@ -580,15 +640,37 @@ public class MesClient extends JFrame {
|
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
|
indexPanelA.setLayout(null);
|
|
indexPanelA.setLayout(null);
|
|
|
|
|
|
|
|
|
|
+ // 镭雕:获取镭雕码 / 复位按钮,放在扫码框(回显框)上方
|
|
|
|
|
+ laser_get_code_bt = new JButton("获取镭雕码");
|
|
|
|
|
+ laser_get_code_bt.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.startLaserFlow(mes_gw, mes_line_sn);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ laser_get_code_bt.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
|
|
+ laser_get_code_bt.setBounds(81, 40, 300, 50);
|
|
|
|
|
+ indexPanelA.add(laser_get_code_bt);
|
|
|
|
|
+
|
|
|
|
|
+ // 镭雕:人工复位按钮(完成信号超时或异常时使用,强制解锁并作废当前请求)
|
|
|
|
|
+ laser_reset_bt = new JButton("复位");
|
|
|
|
|
+ laser_reset_bt.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.manualReset();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ laser_reset_bt.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
|
|
+ laser_reset_bt.setBounds(400, 40, 150, 50);
|
|
|
|
|
+ indexPanelA.add(laser_reset_bt);
|
|
|
|
|
+
|
|
|
product_sn = new JTextField();
|
|
product_sn = new JTextField();
|
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
product_sn.setEditable(false);
|
|
product_sn.setEditable(false);
|
|
|
product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
|
|
|
-// product_sn.setBounds(81, 70, 602, 70);
|
|
|
|
|
product_sn.setBounds(81, 100, 602, 70);
|
|
product_sn.setBounds(81, 100, 602, 70);
|
|
|
indexPanelA.add(product_sn);
|
|
indexPanelA.add(product_sn);
|
|
|
product_sn.setColumns(10);
|
|
product_sn.setColumns(10);
|
|
|
|
|
|
|
|
|
|
+ // 原扫码按钮不再需要,隐藏但保留逻辑(scanBarcode等方法仍被其他流程复用)
|
|
|
f_scan_data_bt_1 = new JButton("扫码");
|
|
f_scan_data_bt_1 = new JButton("扫码");
|
|
|
f_scan_data_bt_1.addActionListener(new ActionListener() {
|
|
f_scan_data_bt_1.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -598,8 +680,8 @@ public class MesClient extends JFrame {
|
|
|
});
|
|
});
|
|
|
f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
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, 32));
|
|
f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
-// f_scan_data_bt_1.setBounds(693, 70, 198, 70);
|
|
|
|
|
f_scan_data_bt_1.setBounds(693, 100, 198, 70);
|
|
f_scan_data_bt_1.setBounds(693, 100, 198, 70);
|
|
|
|
|
+ f_scan_data_bt_1.setVisible(false);
|
|
|
indexPanelA.add(f_scan_data_bt_1);
|
|
indexPanelA.add(f_scan_data_bt_1);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -667,6 +749,8 @@ public class MesClient extends JFrame {
|
|
|
finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
finish_ok_bt.setBounds(185, 341, 240, 80);
|
|
finish_ok_bt.setBounds(185, 341, 240, 80);
|
|
|
finish_ok_bt.setEnabled(false);
|
|
finish_ok_bt.setEnabled(false);
|
|
|
|
|
+ // 镭雕工位不需要手动点OK,完成信号收到后自动提交,隐藏但保留逻辑复用
|
|
|
|
|
+ finish_ok_bt.setVisible(false);
|
|
|
indexPanelA.add(finish_ok_bt);
|
|
indexPanelA.add(finish_ok_bt);
|
|
|
|
|
|
|
|
finish_ng_bt = new JButton("NG");
|
|
finish_ng_bt = new JButton("NG");
|
|
@@ -698,8 +782,63 @@ public class MesClient extends JFrame {
|
|
|
finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
finish_ng_bt.setBounds(508, 341, 240, 80);
|
|
finish_ng_bt.setBounds(508, 341, 240, 80);
|
|
|
finish_ng_bt.setEnabled(false);
|
|
finish_ng_bt.setEnabled(false);
|
|
|
|
|
+ // 镭雕工位不需要手动点NG,隐藏但保留逻辑复用
|
|
|
|
|
+ finish_ng_bt.setVisible(false);
|
|
|
indexPanelA.add(finish_ng_bt);
|
|
indexPanelA.add(finish_ng_bt);
|
|
|
|
|
|
|
|
|
|
+ // ===== 调试面板:供应商真实接口未接通前,用于模拟镭雕软件回传的各阶段信号 =====
|
|
|
|
|
+ JLabel debugTitle = new JLabel("调试面板(模拟镭雕软件信号)");
|
|
|
|
|
+ debugTitle.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugTitle.setForeground(Color.GRAY);
|
|
|
|
|
+ debugTitle.setBounds(760, 40, 260, 30);
|
|
|
|
|
+ indexPanelA.add(debugTitle);
|
|
|
|
|
+
|
|
|
|
|
+ JTextField debugSteelSnInput = new JTextField();
|
|
|
|
|
+ debugSteelSnInput.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugSteelSnInput.setBounds(760, 80, 220, 40);
|
|
|
|
|
+ debugSteelSnInput.setToolTipText("输入测试用钢印码,留空则自动生成");
|
|
|
|
|
+ indexPanelA.add(debugSteelSnInput);
|
|
|
|
|
+
|
|
|
|
|
+ JButton debugSimGetCodeBtn = new JButton("模拟获取镭雕码");
|
|
|
|
|
+ debugSimGetCodeBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.simulateGetCode(debugSteelSnInput.getText());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ debugSimGetCodeBtn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugSimGetCodeBtn.setBounds(760, 130, 220, 50);
|
|
|
|
|
+ indexPanelA.add(debugSimGetCodeBtn);
|
|
|
|
|
+
|
|
|
|
|
+ JButton debugSimOkBtn = new JButton("模拟完成信号(OK)");
|
|
|
|
|
+ debugSimOkBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.simulateComplete("OK", "");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ debugSimOkBtn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugSimOkBtn.setBounds(760, 190, 220, 50);
|
|
|
|
|
+ indexPanelA.add(debugSimOkBtn);
|
|
|
|
|
+
|
|
|
|
|
+ JButton debugSimNgBtn = new JButton("模拟完成信号(NG)");
|
|
|
|
|
+ debugSimNgBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.simulateComplete("NG", "模拟打码失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ debugSimNgBtn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugSimNgBtn.setBounds(760, 250, 220, 50);
|
|
|
|
|
+ indexPanelA.add(debugSimNgBtn);
|
|
|
|
|
+
|
|
|
|
|
+ JButton debugGenSnBtn = new JButton("测试生成客户编码");
|
|
|
|
|
+ debugGenSnBtn.addActionListener(new ActionListener() {
|
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ laserFlowManager.manualGenCustomerSn(debugSteelSnInput.getText());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ debugGenSnBtn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ debugGenSnBtn.setBounds(760, 310, 220, 50);
|
|
|
|
|
+ indexPanelA.add(debugGenSnBtn);
|
|
|
|
|
+ // ===== 调试面板结束 =====
|
|
|
|
|
|
|
|
JButton modbusBtn = new JButton("关");
|
|
JButton modbusBtn = new JButton("关");
|
|
|
modbusBtn.addActionListener(new ActionListener() {
|
|
modbusBtn.addActionListener(new ActionListener() {
|