Просмотр исходного кода

fix: CZ060 OP145A 扫码校验通过后直接过站为 OK

复用现有工位结果接口写入 OK,避免上位机报 Error 未回传时工位停在 UDF。
后续上位机回传 NG 时保留扫码写入的 OK。
wangxichen 6 дней назад
Родитель
Сommit
f5035a6ed5

+ 22 - 16
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -4552,6 +4552,16 @@ public class MesProductRecordController extends BaseController {
 				}
 			}
 
+			if (usesScanResult(lineSn, oldOprno)) {
+				try {
+					mesProductRecordService.updateRecordResult(request, sn, oldOprno, "100000", "", "OK", userCode,
+							new ArrayList<>(), lineSn, false, new ArrayList<>(), isRepair);
+				} catch (Exception e) {
+					logger.error("OP145A scan result save failed for " + sn, e);
+					resp.setErrMsg("工位结果保存失败");
+					return resp;
+				}
+			}
 			resp.setErrMsg("工件可以加工");
 			resp.setIsSuccess(true);
 		}else if(checkret.equals("JZ")){
@@ -4609,10 +4619,8 @@ public class MesProductRecordController extends BaseController {
 	}
 
 
-	private static boolean isOp145LeakTestError(String lineSn, String oprno, String result) {
-		return "CZ060".equals(lineSn)
-				&& "OP145".equals(CommonUitl.formatOprno(oprno))
-				&& "ERROR".equalsIgnoreCase(result.trim());
+	private static boolean usesScanResult(String lineSn, String oprno) {
+		return "CZ060".equals(lineSn) && "OP145A".equals(oprno);
 	}
 
 	@PostMapping(value = "qmresult")
@@ -4646,14 +4654,13 @@ public class MesProductRecordController extends BaseController {
 			return renderResult(Global.FALSE, text("参数错误!"));
 		}
 
+		if (usesScanResult(lineSn, oprno)) {
+			return renderResult(Global.TRUE, text("操作成功!"));
+		}
+
 		sn = mesProductHmbService.formatHmbSn(sn,oprno,lineSn);
 
 		try{
-			if (isOp145LeakTestError(lineSn, oprno, result)) {
-				mesProductRecordService.updateRecordResult(null, sn, oprno, "100000", "", "OK",
-						userCode == null ? "" : userCode, new ArrayList<>(), lineSn, true, new ArrayList<>(), "0");
-				return renderResult(Global.TRUE, text("操作成功!"));
-			}
 			// 检查工件是否是样件
 			String check = Global.getConfig("mes.qm.sample");
 			if(check.equals("1")){ // 开启样本数值验证
@@ -4749,16 +4756,15 @@ public class MesProductRecordController extends BaseController {
 			return resp;
 		}
 
+		if (usesScanResult(lineSn, oprno)) {
+			resp.setErrMsg("操作成功");
+			resp.setIsSuccess(true);
+			return resp;
+		}
+
 		sn = mesProductHmbService.formatHmbSn(sn,oprno,lineSn);
 
 		try{
-			if (isOp145LeakTestError(lineSn, oprno, result)) {
-				mesProductRecordService.updateRecordResult(null, sn, oprno, "100000", "", "OK",
-						userCode, new ArrayList<>(), lineSn, true, new ArrayList<>(), "0");
-				resp.setErrMsg("操作成功");
-				resp.setIsSuccess(true);
-				return resp;
-			}
 			MesProductQm mesProductQm = new MesProductQm();
 			mesProductQm.setOprno(oprno);
 			mesProductQm.setComponentNum(sn);