|
@@ -112,6 +112,9 @@ public class MesClient extends JFrame {
|
|
|
public static Timer plcMonitorTimer;
|
|
public static Timer plcMonitorTimer;
|
|
|
private static boolean lastDataReady = false;
|
|
private static boolean lastDataReady = false;
|
|
|
private static boolean jobSubmitting = false;
|
|
private static boolean jobSubmitting = false;
|
|
|
|
|
+ /** 气密仪器判 NG 后缓存,待工人点 NG 并填写漏点后再上传 */
|
|
|
|
|
+ private static String pendingQmSn = null;
|
|
|
|
|
+ private static QmPlcPoint.QmTestData pendingQmTestData = null;
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
if (ClientUpgrade.handleInstallArgs(args)) {
|
|
if (ClientUpgrade.handleInstallArgs(args)) {
|
|
@@ -443,6 +446,7 @@ public class MesClient extends JFrame {
|
|
|
check_quality_result = false;
|
|
check_quality_result = false;
|
|
|
jobSubmitting = false;
|
|
jobSubmitting = false;
|
|
|
lastDataReady = false;
|
|
lastDataReady = false;
|
|
|
|
|
+ clearPendingQmNg();
|
|
|
PlcService.setMesConnected(false);
|
|
PlcService.setMesConnected(false);
|
|
|
PlcService.setCollectComplete(false);
|
|
PlcService.setCollectComplete(false);
|
|
|
PlcService.clearScanCode();
|
|
PlcService.clearScanCode();
|
|
@@ -523,7 +527,7 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static void pollPlcSignals() {
|
|
private static void pollPlcSignals() {
|
|
|
- if (work_status != 1 || jobSubmitting) {
|
|
|
|
|
|
|
+ if (work_status != 1 || jobSubmitting || hasPendingQmNg()) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
@@ -554,7 +558,7 @@ public class MesClient extends JFrame {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
jobSubmitting = true;
|
|
jobSubmitting = true;
|
|
|
- SwingUtilities.invokeLater(() -> setMenuStatus("气密测试完成,正在上传结果...", 0));
|
|
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus("气密测试完成,正在处理结果...", 0));
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
String rawData = PlcService.readMesData();
|
|
String rawData = PlcService.readMesData();
|
|
@@ -566,37 +570,24 @@ public class MesClient extends JFrame {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- getUser();
|
|
|
|
|
- JSONObject retObj = DataUtil.sendQmResult(sn, user20, testData);
|
|
|
|
|
- if (retObj == null) {
|
|
|
|
|
|
|
+ String result = testData.result == null ? "NG" : testData.result.trim();
|
|
|
|
|
+ // 仪器判 NG:直接弹出漏点页
|
|
|
|
|
+ if (!"OK".equalsIgnoreCase(result)) {
|
|
|
|
|
+ pendingQmSn = sn;
|
|
|
|
|
+ pendingQmTestData = testData;
|
|
|
jobSubmitting = false;
|
|
jobSubmitting = false;
|
|
|
- SwingUtilities.invokeLater(() -> setMenuStatus("气密结果上传失败,请重试", -1));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
|
|
- if (!PlcService.pulseCollectComplete()) {
|
|
|
|
|
- jobSubmitting = false;
|
|
|
|
|
- SwingUtilities.invokeLater(() -> setMenuStatus("结果已上传,但V2800.3脉冲写入失败", -1));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- lastDataReady = false;
|
|
|
|
|
- if (!PlcService.setMesConnected(false)) {
|
|
|
|
|
- jobSubmitting = false;
|
|
|
|
|
- SwingUtilities.invokeLater(() -> setMenuStatus("结果已上传,但V2800.7写入失败", -1));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
- resetScanA();
|
|
|
|
|
- setMenuStatus("气密结果提交成功,请扫下一件", 0);
|
|
|
|
|
- scan_type = 1;
|
|
|
|
|
- scanBarcode();
|
|
|
|
|
|
|
+ finish_ok_bt.setEnabled(false);
|
|
|
|
|
+ finish_ng_bt.setEnabled(true);
|
|
|
|
|
+ setMenuStatus("气密 NG,请选择漏点点位", -1);
|
|
|
|
|
+ submitPendingQmNgWithLeakPoints();
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- jobSubmitting = false;
|
|
|
|
|
- String message = retObj.getString("message");
|
|
|
|
|
- SwingUtilities.invokeLater(() -> setMenuStatus(
|
|
|
|
|
- message == null || message.isEmpty() ? "气密结果上传失败" : message, -1));
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ getUser();
|
|
|
|
|
+ JSONObject retObj = DataUtil.sendQmResult(sn, user20, testData);
|
|
|
|
|
+ finishQmUpload(retObj);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
jobSubmitting = false;
|
|
jobSubmitting = false;
|
|
|
log.info("处理气密数据异常: {}", e.getMessage());
|
|
log.info("处理气密数据异常: {}", e.getMessage());
|
|
@@ -604,6 +595,83 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void clearPendingQmNg() {
|
|
|
|
|
+ pendingQmSn = null;
|
|
|
|
|
+ pendingQmTestData = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean hasPendingQmNg() {
|
|
|
|
|
+ return pendingQmSn != null && pendingQmTestData != null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 上传气密结果后的公共收尾:PLC 脉冲、复位扫码 */
|
|
|
|
|
+ private static void finishQmUpload(JSONObject retObj) {
|
|
|
|
|
+ if (retObj == null) {
|
|
|
|
|
+ jobSubmitting = false;
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus("气密结果上传失败,请重试", -1));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
|
|
+ if (!PlcService.pulseCollectComplete()) {
|
|
|
|
|
+ jobSubmitting = false;
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus("结果已上传,但V2800.3脉冲写入失败", -1));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ lastDataReady = false;
|
|
|
|
|
+ if (!PlcService.setMesConnected(false)) {
|
|
|
|
|
+ jobSubmitting = false;
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus("结果已上传,但V2800.7写入失败", -1));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ clearPendingQmNg();
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
|
|
+ resetScanA();
|
|
|
|
|
+ setMenuStatus("气密结果提交成功,请扫下一件", 0);
|
|
|
|
|
+ scan_type = 1;
|
|
|
|
|
+ scanBarcode();
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ jobSubmitting = false;
|
|
|
|
|
+ String message = retObj.getString("message");
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus(
|
|
|
|
|
+ message == null || message.isEmpty() ? "气密结果上传失败" : message, -1));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 打开漏点页并上传(仪器 NG 后直接调用,或取消后点 NG 重开) */
|
|
|
|
|
+ private static void submitPendingQmNgWithLeakPoints() {
|
|
|
|
|
+ if (!hasPendingQmNg()) {
|
|
|
|
|
+ setMenuStatus("无待填写的气密NG数据", -1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (jobSubmitting) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String ngLeakPoints = LeakNgPointDialog.showDialog(mesClientFrame);
|
|
|
|
|
+ if (ngLeakPoints == null) {
|
|
|
|
|
+ finish_ng_bt.setEnabled(true);
|
|
|
|
|
+ setMenuStatus("气密 NG,请选择漏点点位", -1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ jobSubmitting = true;
|
|
|
|
|
+ setMenuStatus("气密NG结果上传中...", 0);
|
|
|
|
|
+ final String sn = pendingQmSn;
|
|
|
|
|
+ final QmPlcPoint.QmTestData testData = pendingQmTestData;
|
|
|
|
|
+ final String leakPoints = ngLeakPoints;
|
|
|
|
|
+ Executors.newSingleThreadExecutor().execute(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ getUser();
|
|
|
|
|
+ JSONObject retObj = DataUtil.sendQmResult(sn, user20, testData, leakPoints);
|
|
|
|
|
+ finishQmUpload(retObj);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ jobSubmitting = false;
|
|
|
|
|
+ log.info("上传气密NG漏点异常: {}", e.getMessage());
|
|
|
|
|
+ SwingUtilities.invokeLater(() -> setMenuStatus("上传气密NG漏点异常: " + e.getMessage(), -1));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//获取用户20位
|
|
//获取用户20位
|
|
|
public static void getUser() {
|
|
public static void getUser() {
|
|
|
user20 = user_menu.getText().toString();
|
|
user20 = user_menu.getText().toString();
|
|
@@ -1001,6 +1069,10 @@ public class MesClient extends JFrame {
|
|
|
finish_ng_bt.setEnabled(false);
|
|
finish_ng_bt.setEnabled(false);
|
|
|
finish_ng_bt.addActionListener(new ActionListener() {
|
|
finish_ng_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
+ if (hasPendingQmNg()) {
|
|
|
|
|
+ submitPendingQmNgWithLeakPoints();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if(work_status == 1 && check_quality_result){
|
|
if(work_status == 1 && check_quality_result){
|
|
|
getUser();
|
|
getUser();
|
|
|
String sn = MesClient.product_sn.getText().trim();
|
|
String sn = MesClient.product_sn.getText().trim();
|