|
|
@@ -82,6 +82,15 @@ public class MesClient extends JFrame {
|
|
|
public static JButton f_scan_data_bt_2;
|
|
|
public static JButton btnUnbindLb;
|
|
|
public static boolean bindLbStatus = false;
|
|
|
+ /** 质量查询已发送,避免定时器连发 */
|
|
|
+ public static boolean qualityRequestSent = false;
|
|
|
+ /** 开工已发送,避免重复开工 */
|
|
|
+ public static boolean startWorkRequestSent = false;
|
|
|
+ /** 冷板绑定后需与拉铆枪 okQty 对齐基准 */
|
|
|
+ public static boolean rivetCountNeedSync = false;
|
|
|
+ /** 冷板绑定 NS 自动重试次数 */
|
|
|
+ public static int lbBindRetryCount = 0;
|
|
|
+ public static final int LB_BIND_RETRY_MAX = 2;
|
|
|
|
|
|
public static String user20 = "";
|
|
|
|
|
|
@@ -564,6 +573,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static void clearLbBindUi() {
|
|
|
bindLbStatus = false;
|
|
|
+ rivetCountNeedSync = false;
|
|
|
if (product_sn_lb != null) {
|
|
|
product_sn_lb.setText("");
|
|
|
}
|
|
|
@@ -583,6 +593,10 @@ public class MesClient extends JFrame {
|
|
|
check_quality_result = false;
|
|
|
tjStatus = 0;
|
|
|
manualSubmitFlag = false;
|
|
|
+ qualityRequestSent = false;
|
|
|
+ startWorkRequestSent = false;
|
|
|
+ rivetCountNeedSync = false;
|
|
|
+ lbBindRetryCount = 0;
|
|
|
MesClient.finish_ok_bt.setEnabled(false);
|
|
|
MesClient.finish_ng_bt.setEnabled(false);
|
|
|
product_sn.setText("");
|
|
|
@@ -688,7 +702,10 @@ public class MesClient extends JFrame {
|
|
|
work_status_jqb = 1;
|
|
|
}
|
|
|
}else if (work_status_jqb == 1){
|
|
|
- // 已扫码,等待允许加工信号
|
|
|
+ // 已扫码,等待允许加工信号(只发一次,等回包)
|
|
|
+ if (qualityRequestSent) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
String sn = product_sn.getText();
|
|
|
if (sn == null || sn.trim().isEmpty() || "".equals(sn)) {
|
|
|
setMenuStatus("读码结果为空", -1);
|
|
|
@@ -698,13 +715,18 @@ public class MesClient extends JFrame {
|
|
|
Boolean checkQualityResult = DataUtil.checkQuality(MesClient.nettyClient, barcode36,MesClient.user20);
|
|
|
if (!checkQualityResult){
|
|
|
setMenuStatus("消息发送失败,请重试",-1);
|
|
|
+ qualityRequestSent = false;
|
|
|
+ } else {
|
|
|
+ qualityRequestSent = true;
|
|
|
}
|
|
|
}else if (work_status_jqb == 2){
|
|
|
- //上料完成信号
|
|
|
+ //上料完成信号:仅写 PLC,不再重复开工(开工已由质量回包触发)
|
|
|
if (MesClient.s7PLC.readBoolean("DB32.0.3")){
|
|
|
- //允许上料信号
|
|
|
MesClient.s7PLC.writeBoolean("DB32.0.2",false);
|
|
|
- DataUtil.startWork(nettyClient,MesClient.product_sn.getText(),user20);
|
|
|
+ if (work_status == 0 && !startWorkRequestSent) {
|
|
|
+ startWorkRequestSent = true;
|
|
|
+ DataUtil.startWork(nettyClient, MesClient.product_sn.getText(), user20);
|
|
|
+ }
|
|
|
}
|
|
|
}else if (work_status_jqb == 3){
|
|
|
if (MesClient.s7PLC.readBoolean("DB32.0.4")){
|
|
|
@@ -799,30 +821,78 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
|
|
|
public static void scanBarcodeLb() {
|
|
|
+ if (bindLbStatus) {
|
|
|
+ setMenuStatus("冷板已绑定,如需重绑请先解绑", 1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
product_sn_lb.setText("");
|
|
|
String scanBarcode = JOptionPane.showInputDialog(null, "请扫冷板码");
|
|
|
System.out.println("冷板码=" + scanBarcode);
|
|
|
if (scanBarcode != null && !scanBarcode.equalsIgnoreCase("")) {
|
|
|
getUser();
|
|
|
- product_sn_lb.setText(scanBarcode);
|
|
|
+ product_sn_lb.setText(scanBarcode.trim());
|
|
|
mesClientFrame.repaint();
|
|
|
|
|
|
if (!tcp_connect_flag) {
|
|
|
setMenuStatus("设备未连接Mes服务器", 1);
|
|
|
+ if (f_scan_data_bt_2 != null) {
|
|
|
+ f_scan_data_bt_2.setEnabled(true);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String productSn = product_sn.getText();
|
|
|
+ if ((productSn == null || productSn.trim().isEmpty()) && curSn != null && !curSn.trim().isEmpty()) {
|
|
|
+ productSn = curSn;
|
|
|
+ product_sn.setText(curSn);
|
|
|
+ }
|
|
|
+ if (productSn == null || productSn.trim().isEmpty()) {
|
|
|
+ setMenuStatus("工件码为空,请先扫工件码", 1);
|
|
|
+ if (f_scan_data_bt_2 != null) {
|
|
|
+ f_scan_data_bt_2.setEnabled(true);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String warehouseSn = getBarcode(product_sn_lb.getText());
|
|
|
- String sn = getBarcode(product_sn.getText());
|
|
|
- Boolean retObj = DataUtil.bindWarehouse(nettyClient, sn, warehouseSn, user20, "400006");
|
|
|
- if (!retObj) {
|
|
|
- setMenuStatus("绑定失败!", 1);
|
|
|
+ if (f_scan_data_bt_2 != null) {
|
|
|
+ f_scan_data_bt_2.setEnabled(false);
|
|
|
}
|
|
|
+ lbBindRetryCount = 0;
|
|
|
+ setMenuStatus("冷板绑定中...", 0);
|
|
|
+ sendColdPlateBind();
|
|
|
} else {
|
|
|
setMenuStatus("冷板码为空,请重新扫码", 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** 发送冷板绑定(支持 NS 自动重试复用) */
|
|
|
+ public static void sendColdPlateBind() {
|
|
|
+ String lb = product_sn_lb != null ? product_sn_lb.getText() : "";
|
|
|
+ String productSn = product_sn != null ? product_sn.getText() : "";
|
|
|
+ if ((productSn == null || productSn.trim().isEmpty()) && curSn != null && !curSn.trim().isEmpty()) {
|
|
|
+ productSn = curSn;
|
|
|
+ }
|
|
|
+ if (lb == null || lb.trim().isEmpty() || productSn == null || productSn.trim().isEmpty()) {
|
|
|
+ setMenuStatus("冷板绑定参数为空", 1);
|
|
|
+ if (f_scan_data_bt_2 != null && work_status == 1 && !bindLbStatus) {
|
|
|
+ f_scan_data_bt_2.setEnabled(true);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getUser();
|
|
|
+ String warehouseSn = getBarcode(lb.trim());
|
|
|
+ String sn = getBarcode(productSn.trim());
|
|
|
+ log.info("发送冷板绑定 sn={}, lb={}, retry={}", sn.trim(), lb.trim(), lbBindRetryCount);
|
|
|
+ Boolean retObj = DataUtil.bindWarehouse(nettyClient, sn, warehouseSn, user20, "400006");
|
|
|
+ if (!retObj) {
|
|
|
+ setMenuStatus("绑定失败!", 1);
|
|
|
+ lbBindRetryCount = 0;
|
|
|
+ if (f_scan_data_bt_2 != null) {
|
|
|
+ f_scan_data_bt_2.setEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void logoff() {
|
|
|
welcomeWin.setVisible(true);
|
|
|
mesClientFrame.setVisible(false);
|