|
@@ -25,6 +25,12 @@ public class MesRevice {
|
|
|
|| ret.equalsIgnoreCase("UDF");
|
|
|| ret.equalsIgnoreCase("UDF");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void enableColdPlateScanIfNeeded() {
|
|
|
|
|
+ if (MesClient.work_status == 1 && !MesClient.bindLbStatus && MesClient.f_scan_data_bt_2 != null) {
|
|
|
|
|
+ MesClient.f_scan_data_bt_2.setEnabled(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 质量查询
|
|
// 质量查询
|
|
|
public static void checkQualityRevice(String processMsgRet, String mes_msg) {
|
|
public static void checkQualityRevice(String processMsgRet, String mes_msg) {
|
|
|
try {
|
|
try {
|
|
@@ -37,14 +43,16 @@ public class MesRevice {
|
|
|
MesClient.check_quality_result = true;
|
|
MesClient.check_quality_result = true;
|
|
|
MesClient.setMenuStatus("该工件可以加工", 0);
|
|
MesClient.setMenuStatus("该工件可以加工", 0);
|
|
|
|
|
|
|
|
- if (MesClient.work_status == 0) {
|
|
|
|
|
|
|
+ if (MesClient.work_status == 0 && !MesClient.startWorkRequestSent) {
|
|
|
String barcode36 = MesClient.getBarcode(MesClient.product_sn.getText());
|
|
String barcode36 = MesClient.getBarcode(MesClient.product_sn.getText());
|
|
|
MesClient.getUser();
|
|
MesClient.getUser();
|
|
|
|
|
+ MesClient.startWorkRequestSent = true;
|
|
|
log.info("质量通过,发送开工 sn={}", barcode36.trim());
|
|
log.info("质量通过,发送开工 sn={}", barcode36.trim());
|
|
|
DataUtil.startWork(MesClient.nettyClient, barcode36, MesClient.user20);
|
|
DataUtil.startWork(MesClient.nettyClient, barcode36, MesClient.user20);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
MesClient.check_quality_result = false;
|
|
MesClient.check_quality_result = false;
|
|
|
|
|
+ MesClient.qualityRequestSent = false;
|
|
|
log.warn("质量查询不可加工 sn={}, ret={}", sn, processMsgRet);
|
|
log.warn("质量查询不可加工 sn={}, ret={}", sn, processMsgRet);
|
|
|
ErrorMsg.setErrorMsg(mes_msg);
|
|
ErrorMsg.setErrorMsg(mes_msg);
|
|
|
}
|
|
}
|
|
@@ -70,14 +78,24 @@ public class MesRevice {
|
|
|
String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
log.info("开工回包 sn={}, ret={}", sn, processMsgRet);
|
|
log.info("开工回包 sn={}, ret={}", sn, processMsgRet);
|
|
|
if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
|
|
+ // 已开工则忽略重复回包,避免把冷板绑定 UI 刷回「请扫描冷板码」
|
|
|
|
|
+ if (MesClient.work_status == 1) {
|
|
|
|
|
+ log.info("忽略重复开工回包 sn={}, jqb={}, bindLb={}",
|
|
|
|
|
+ sn, MesClient.work_status_jqb, MesClient.bindLbStatus);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
MesClient.work_status = 1;
|
|
MesClient.work_status = 1;
|
|
|
MesClient.f_scan_data_bt_1.setEnabled(false);
|
|
MesClient.f_scan_data_bt_1.setEnabled(false);
|
|
|
MesClient.tjStatus = 0;
|
|
MesClient.tjStatus = 0;
|
|
|
MesClient.work_status_jqb = 2;
|
|
MesClient.work_status_jqb = 2;
|
|
|
|
|
+ MesClient.startWorkRequestSent = true;
|
|
|
|
|
|
|
|
- MesClient.f_scan_data_bt_2.setEnabled(true);
|
|
|
|
|
- MesClient.setMenuStatus("请扫描冷板码", 0);
|
|
|
|
|
|
|
+ if (!MesClient.bindLbStatus) {
|
|
|
|
|
+ MesClient.f_scan_data_bt_2.setEnabled(true);
|
|
|
|
|
+ MesClient.setMenuStatus("请扫描冷板码", 0);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ MesClient.startWorkRequestSent = false;
|
|
|
log.warn("开工失败 sn={}, ret={}", sn, processMsgRet);
|
|
log.warn("开工失败 sn={}, ret={}", sn, processMsgRet);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -90,25 +108,50 @@ public class MesRevice {
|
|
|
try {
|
|
try {
|
|
|
String craft = ProtocolParam.getCraft(mes_msg);
|
|
String craft = ProtocolParam.getCraft(mes_msg);
|
|
|
String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
- log.info("绑定回包 sn={}, craft={}, ret={}", sn, craft, processMsgRet);
|
|
|
|
|
|
|
+ log.info("绑定回包 sn={}, craft={}, ret={}, retry={}",
|
|
|
|
|
+ sn, craft, processMsgRet, MesClient.lbBindRetryCount);
|
|
|
if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
if (isColdPlateCraft(craft)) {
|
|
if (isColdPlateCraft(craft)) {
|
|
|
|
|
+ MesClient.lbBindRetryCount = 0;
|
|
|
MesClient.setMenuStatus("绑定成功!", 0);
|
|
MesClient.setMenuStatus("绑定成功!", 0);
|
|
|
MesClient.btnUnbindLb.setEnabled(true);
|
|
MesClient.btnUnbindLb.setEnabled(true);
|
|
|
MesClient.bindLbStatus = true;
|
|
MesClient.bindLbStatus = true;
|
|
|
MesClient.f_scan_data_bt_2.setEnabled(false);
|
|
MesClient.f_scan_data_bt_2.setEnabled(false);
|
|
|
|
|
|
|
|
- MesClient.sortA = 0;
|
|
|
|
|
|
|
+ // 不强制 sortA=0:下一轮拉铆采集时与枪 okQty 对齐,避免二次绑定后计数卡死
|
|
|
|
|
+ MesClient.rivetCountNeedSync = true;
|
|
|
MesClient.aFinish = 0;
|
|
MesClient.aFinish = 0;
|
|
|
MesClient.param2.setText("0");
|
|
MesClient.param2.setText("0");
|
|
|
MesClient.work_status_jqb = 3;
|
|
MesClient.work_status_jqb = 3;
|
|
|
log.info("冷板绑定成功 sn={}, lb={}", MesClient.curSn, MesClient.product_sn_lb.getText());
|
|
log.info("冷板绑定成功 sn={}, lb={}", MesClient.curSn, MesClient.product_sn_lb.getText());
|
|
|
}
|
|
}
|
|
|
} else if (isColdPlateCraft(craft) && processMsgRet.equalsIgnoreCase("PZ")) {
|
|
} else if (isColdPlateCraft(craft) && processMsgRet.equalsIgnoreCase("PZ")) {
|
|
|
|
|
+ MesClient.lbBindRetryCount = 0;
|
|
|
log.warn("冷板绑定失败,需先上传密封圈照片 sn={}", sn);
|
|
log.warn("冷板绑定失败,需先上传密封圈照片 sn={}", sn);
|
|
|
MesClient.setMenuStatus("请先上传密封圈照片,再绑定冷板!", -1);
|
|
MesClient.setMenuStatus("请先上传密封圈照片,再绑定冷板!", -1);
|
|
|
|
|
+ enableColdPlateScanIfNeeded();
|
|
|
|
|
+ } else if (isColdPlateCraft(craft) && processMsgRet != null
|
|
|
|
|
+ && processMsgRet.trim().equalsIgnoreCase("NS")) {
|
|
|
|
|
+ // NS=服务端绑定失败(常见于报文拆包丢参数/记录未就绪),自动重试
|
|
|
|
|
+ if (MesClient.lbBindRetryCount < MesClient.LB_BIND_RETRY_MAX) {
|
|
|
|
|
+ MesClient.lbBindRetryCount++;
|
|
|
|
|
+ final int retryNo = MesClient.lbBindRetryCount;
|
|
|
|
|
+ log.warn("冷板绑定返回 NS,自动重试 {}/{} sn={}", retryNo, MesClient.LB_BIND_RETRY_MAX, sn);
|
|
|
|
|
+ MesClient.setMenuStatus("冷板绑定未就绪,自动重试(" + retryNo + ")...", 0);
|
|
|
|
|
+ javax.swing.Timer retryTimer = new javax.swing.Timer(500, e -> MesClient.sendColdPlateBind());
|
|
|
|
|
+ retryTimer.setRepeats(false);
|
|
|
|
|
+ retryTimer.start();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ MesClient.lbBindRetryCount = 0;
|
|
|
|
|
+ log.warn("冷板绑定失败,NS 重试耗尽 sn={}", sn);
|
|
|
|
|
+ MesClient.setMenuStatus("冷板绑定失败:NS,请再扫一次", -1);
|
|
|
|
|
+ enableColdPlateScanIfNeeded();
|
|
|
|
|
+ }
|
|
|
} else if (isColdPlateCraft(craft)) {
|
|
} else if (isColdPlateCraft(craft)) {
|
|
|
|
|
+ MesClient.lbBindRetryCount = 0;
|
|
|
log.warn("冷板绑定失败 sn={}, ret={}", sn, processMsgRet);
|
|
log.warn("冷板绑定失败 sn={}, ret={}", sn, processMsgRet);
|
|
|
|
|
+ MesClient.setMenuStatus("冷板绑定失败:" + processMsgRet, -1);
|
|
|
|
|
+ enableColdPlateScanIfNeeded();
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("绑定回包处理异常", e);
|
|
log.error("绑定回包处理异常", e);
|