liuwei 2 mesi fa
parent
commit
37f61cf12b

+ 8 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -1417,6 +1417,14 @@ public class MesProductRecordController extends BaseController {
 		}
 		return ret;
 	}
+	/**
+	 * 按工位模板补建缺失的 mes_product_record(与质量校验 checkTempalte 相同)。
+	 * 供定时任务等在报工「记录不存在」时调用。
+	 */
+	public void ensureOprnoTemplateRecords(String sn, String oprno, String lineSn) {
+		checkTempalte(sn, oprno, lineSn);
+	}
+
 	// 检查模板与现有模板是否一致,不一致则创建模板
 	private void checkTempalte(String sn,String oprno,String lineSn){
 		String fOprno = CommonUitl.formatOprno(oprno);

+ 27 - 1
src/main/java/com/jeesite/modules/scheduling/FrameworkQmScheduling.java

@@ -215,7 +215,7 @@ public class FrameworkQmScheduling {
 			logger.error("框架气密数据保存失败[{}],保持 {}=true 待重试 qmSn={}", ch.name, ch.completeFlag, qmSn);
 			return;
 		}
-		if (!submitStationResult(ch.name, qmSn, stationResult)) {
+		if (!submitStationResultWithTemplateRetry(ch.name, qmSn, stationResult)) {
 			logger.error("框架气密工位结果提交失败[{}],保持 {}=true 待重试 qmSn={}", ch.name, ch.completeFlag, qmSn);
 			return;
 		}
@@ -254,6 +254,32 @@ public class FrameworkQmScheduling {
 		}
 	}
 
+	/**
+	 * 报工:失败时按质量校验同款逻辑补建工位模板记录,再二次提交。
+	 */
+	private boolean submitStationResultWithTemplateRetry(String channel, String sn, String result) {
+		if (submitStationResult(channel, sn, result)) {
+			return true;
+		}
+		String oprno = getOprno();
+		if (oprno.length() == 5) {
+			oprno = oprno + "A";
+		}
+		String lineSn = getLineSn(sn);
+		if (StringUtils.isBlank(lineSn)) {
+			logger.warn("框架气密补模板跳过[{}]:无法解析产线编号 sn={}", channel, sn);
+			return false;
+		}
+		try {
+			logger.warn("框架气密报工失败[{}],补建工位模板后二次提交 sn={} oprno={}", channel, sn, oprno);
+			mesProductRecordController.ensureOprnoTemplateRecords(sn, oprno, lineSn);
+		} catch (Exception e) {
+			logger.error("框架气密补建工位模板失败[{}] sn={}:{}", channel, sn, e.getMessage());
+			return false;
+		}
+		return submitStationResult(channel, sn, result);
+	}
+
 	private boolean submitStationResult(String channel, String sn, String result) {
 		try {
 			String oprno = getOprno();