Jelajahi Sumber

KA64工件在OP140/OP300工位跳过前工位校验
绑定校验+写入dhb表,OP140冷板绑定校验,OP140A/B后缀保留
新增 VLDW case调用冷板绑定校验,validateColdPlateBinding
记录列表查询新增OP140A合并查询OP140A+OP140B
OP140,OP140A,OP140B统一保存为OP140A

wangxichen 1 Minggu lalu
induk
melakukan
a2756f9afa

+ 12 - 0
src/main/java/com/jeesite/modules/mes/util/CommonUitl.java

@@ -442,6 +442,18 @@ public class CommonUitl {
         }
     }
 
+    /**
+     * 判断是否是+KA64IS3031开头的21位流水码
+     * @param sn 工件码
+     * @return
+     */
+    public static Boolean isKA64Sn(String sn){
+        if(sn == null || sn.length() != 21){
+            return false;
+        }
+        return sn.startsWith("+KA64IS3031");
+    }
+
     // 判断是否是单部件
     public static Boolean checkDbjOprno(String oprno,String lineSn){
         List<String> dbjoprnos = new ArrayList<>();

+ 6 - 0
src/main/java/com/jeesite/modules/mes/web/MesProcessCheckRecordController.java

@@ -204,6 +204,12 @@ public class MesProcessCheckRecordController extends BaseController {
 			shiftId = mesShiftDataResp.getMesShift().getId();
 		}
 
+		// OP140 工位号合并处理,保存时统一用 OP140A
+		String oprno = mesProcessCheckRecord.getOprno();
+		if(oprno != null && (oprno.equals("OP140") || oprno.equals("OP140A") || oprno.equals("OP140B"))){
+			mesProcessCheckRecord.setOprno("OP140A");
+		}
+
 		mesProcessCheckRecord.setResult(result);
 		mesProcessCheckRecord.setShift(shiftId);
 		mesProcessCheckRecordService.save(mesProcessCheckRecord);

+ 100 - 13
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -777,6 +777,10 @@ public class MesProductRecordController extends BaseController {
 				//msg=aaaabbbbbABWMBDWGWOP040 GY400002ID151245P00000106200123062900001      SNWL51248P0000010620012306290001      DA2023-08-18ZT14:32:33YHjinjushijinjushi1111
 				ret = bindRecord(msg);
 				break;
+			case "VLDW":
+				//校验冷板绑定报文
+				ret = validateColdPlateBinding(msg);
+				break;
 			case "MJBW":
 				//解绑报文
 				//msg=aaaabbbbbABWMJBWGWOP040 GY400002ID151245P00000106200123062900001      SNWL51248P0000010620012306290001      DA2023-08-18ZT14:32:33YHjinjushijinjushi1111
@@ -1309,7 +1313,11 @@ public class MesProductRecordController extends BaseController {
 			}
 
 			String op = "";
-			if(lxres.equals("UD") && serial != 1){ // 本工位未开始,检查上一工位结果
+			String formatOprno = CommonUitl.formatOprno(oldOprno);
+			// +KA64IS3031开头的工件在冷板绑定(OP140)和底护板绑定(OP300)工位跳过前工位校验
+			if(CommonUitl.isKA64Sn(sn) && (formatOprno.startsWith("OP140") || formatOprno.startsWith("OP300"))){
+				logger.info("=== KA64工件码在绑定工位,跳过前工位校验 sn:{}, oprno:{} ===", sn, formatOprno);
+			}else if(lxres.equals("UD") && serial != 1){ // 本工位未开始,检查上一工位结果
 				// 获取上一工位的结果记录
 				for(MesProductRecord mpr : lists){
 					if(mpr.getSerial() >= serial){
@@ -1474,17 +1482,6 @@ public class MesProductRecordController extends BaseController {
 //			}
 //		}
 
-//		if(CommonUitl.formatOprno(oprno).equals("OP290") && craft.equals("400002")){
-//			// 检查是否已绑定其他工件
-//			MesProductDhb mesProductDhb = new MesProductDhb();
-//			mesProductDhb.setBatchSn(materielSn);
-//			mesProductDhb.getSqlMap().getWhere().and("a.sn",QueryType.NE,sn);
-//			MesProductDhb mesProductDhb1 = mesProductDhbService.findInfo(mesProductDhb);
-//			if(!ObjectUtils.isEmpty(mesProductDhb1)){
-//				return "RSZY";
-//			}
-//		}
-
 		if(CommonUitl.formatOprno(oprno).equals("OP230") && craft.equals("400004")){ // 框架涂胶
 			MesProductRecord mesProductRecord = new MesProductRecord();
 			mesProductRecord.setSn(sn);
@@ -1507,8 +1504,60 @@ public class MesProductRecordController extends BaseController {
 			}
 		}
 
+		// OP300底护板绑定校验
+		if(CommonUitl.formatOprno(oprno).equals("OP300") && craft.equals("400004")){
+			// 检查是否已绑定其他工件
+			MesProductDhb mesProductDhb = new MesProductDhb();
+			mesProductDhb.setBatchSn(materielSn);
+			mesProductDhb.getSqlMap().getWhere().and("a.sn",QueryType.NE,sn);
+			MesProductDhb mesProductDhb1 = mesProductDhbService.findInfo(mesProductDhb);
+			if(!ObjectUtils.isEmpty(mesProductDhb1)){
+				return "RSZY";
+			}
+		}
+
+		// OP140冷板绑定校验
+		if(CommonUitl.formatOprno(oprno).equals("OP140") && craft.equals("400004")){
+			// 检查冷板是否已绑定其他工件 - 通过MesProductRecord表查询
+			MesProductRecord checkRecord = new MesProductRecord();
+			checkRecord.setCraft("400004");
+			checkRecord.setMaterielSn(materielSn);
+			checkRecord.getSqlMap().getWhere()
+				.and("a.sn",QueryType.NE,sn)
+				.and("a.content",QueryType.NE,"UDF");  // 过滤已解绑的记录
+			List<MesProductRecord> existingRecords = mesProductRecordService.findList(checkRecord);
+			if(!ListUtils.isEmpty(existingRecords)){
+				return "RSZY";
+			}
+		}
+
+		// OP140A/B冷板绑定工艺:保留后缀不格式化
+		String cateParam = lineSn;
+		if((oprno.equals("OP140A") || oprno.equals("OP140B")) && craft.equals("400004")){
+			cateParam = "NOFORMAT_" + lineSn;
+		}
+
 		try{
-			mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"OK",userCode,lineSn);
+			mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"OK",userCode,cateParam);
+
+			// 如果是OP300工位的底护板绑定(400004),需要插入mes_product_dhb表
+			if(CommonUitl.formatOprno(oprno).equals("OP300") && craft.equals("400004")){
+				// 先删除可能存在的旧记录
+				MesProductDhb existingDhb = new MesProductDhb();
+				existingDhb.setSn(sn);
+				MesProductDhb existing = mesProductDhbService.findInfo(existingDhb);
+				if(!ObjectUtils.isEmpty(existing)) {
+					mesProductDhbService.delete(existing);
+				}
+
+				// 插入新的底护板绑定记录
+				MesProductDhb newDhb = new MesProductDhb();
+				newDhb.setSn(sn);
+				newDhb.setBatchSn(materielSn);
+				newDhb.setCreateBy(userCode);
+				mesProductDhbService.save(newDhb);
+			}
+
 		}catch (Exception e){
 			e.printStackTrace();
 			return "RSNS";
@@ -1548,6 +1597,40 @@ public class MesProductRecordController extends BaseController {
 		return "RSOK";
 	}
 
+	//校验冷板绑定报文
+	//msg=aaaabbbbbABWVLDWGWOP140 GY400004ID151245P00000106200123062900001      SNWL51248P0000010620012306290001      DA2023-08-18ZT14:32:33YHjinjushijinjushi1111
+	private String validateColdPlateBinding(String msg){
+		String ret = "RSNS";
+		String oprno = ProtocolParam.getOprno(msg).trim();
+		String craft = ProtocolParam.getCraft(msg).trim();
+		String sn = ProtocolParam.getSn(msg).trim();
+		String materielSn = ProtocolParam.getParam(msg,1).trim();
+		String userCode = ProtocolParam.getUserCode(msg).trim();
+		String lineSn = ProtocolParam.getLineSn(msg).trim();
+
+		if(StringUtils.isEmpty(craft)||StringUtils.isEmpty(oprno)||StringUtils.isEmpty(sn)||StringUtils.isEmpty(lineSn)||StringUtils.isEmpty(materielSn)){
+			return "RSNS";
+		}
+
+		// OP420/OP140冷板绑定校验 - 只判断craft=400004
+		if(craft.equals("400004")){
+			// 检查冷板是否已绑定其他工件 - 通过MesProductRecord表查询
+			MesProductRecord mesProductRecord = new MesProductRecord();
+			mesProductRecord.setCraft("400004");
+			mesProductRecord.setMaterielSn(materielSn);
+			mesProductRecord.getSqlMap().getWhere()
+				.and("a.sn",QueryType.NE,sn)
+				.and("a.content",QueryType.NE,"UDF");  // 过滤已解绑的记录
+			List<MesProductRecord> existingRecords = mesProductRecordService.findList(mesProductRecord);
+			if(!ListUtils.isEmpty(existingRecords)){
+				return "RSZY"; // 冷板已被其他工件绑定
+			}
+		}
+
+		ret = "RSOK"; // 校验通过
+		return ret;
+	}
+
 	//工位开始工作
 	//msg=aaaabbbbbABWMKSWGWOP040 LX  ID151245P00000106200123062900001      DA2023-07-01ZT10:01:25
 	//msg=aaaabbbbbABWMKSWGWOP050 GY100000LX  ID151245P00000106200123062900001      RSOKDA2023-07-01ZT10:01:25YHjingjushijingjushi1102YaaaaaaaaNbbbbbbbb
@@ -2750,6 +2833,10 @@ public class MesProductRecordController extends BaseController {
 			String[] oprnos = {"OP130E", "OP130F"};
 			mesProductRecord.setOprno("");
 			mesProductRecord.getSqlMap().getWhere().and("a.oprno", QueryType.IN,oprnos);
+		}else if(mesProductRecord.getOprno().equals("OP140A")){
+			String[] oprnos = {"OP140A", "OP140B"};
+			mesProductRecord.setOprno("");
+			mesProductRecord.getSqlMap().getWhere().and("a.oprno", QueryType.IN,oprnos);
 		}
 
 		Page<MesProductRecord> page = mesProductRecordService.findPage(mesProductRecord);