Bladeren bron

子工位提交

zhanghe 2 weken geleden
bovenliggende
commit
c06aa8e358
1 gewijzigde bestanden met toevoegingen van 160 en 37 verwijderingen
  1. 160 37
      src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

+ 160 - 37
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -1490,45 +1490,44 @@ public class MesProductRecordController extends BaseController {
 						}
 					}
 
-//					MesProductOprno mesProductOprno = new MesProductOprno();
-//					mesProductOprno.setSn(sn);
-//					mesProductOprno.setOprno(oprnoOld);
-//					mesProductOprno.setLineSn(lineSn);
-//					MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
-//					System.out.println(mesProductOprno1);
-//					if(ObjectUtils.isEmpty(mesProductOprno1)){
-//						//添加子工位表
-//						mesProductOprnoService.save(mesProductOprno);
-//						mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
-//					}
-//					//添加子工位
-//					if (!StringUtils.isEmpty(oprno) &&"OP220".equals(oprnoOld)){
-//
-//						if("OP220A".equals(oprno) ){
-//							mesProductOprno1.setResult1(content);
-//						}else if("OP220B".equals(oprno)){
-//							mesProductOprno1.setResult2(content);
-//						}
-//						mesProductOprnoService.save(mesProductOprno1);
-//
-//						// 全有结果
-//						if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
-//							String lastRet = "NG";
-//							if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
-//								lastRet = "OK";
-//							}
-//							// 2.判断物料批次是否符合绑定
-//							List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
-//							// 总结果产线要求写死“OK”
-//							mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
-//						}else {
-//							ret = "RSOK";
-//							return ret;
-//						}
-//
-//					}
 
+					//310添加子工位
+					if (!StringUtils.isEmpty(oprno) &&"OP310".equals(oprnoOld)){
+						MesProductOprno mesProductOprno = new MesProductOprno();
+						mesProductOprno.setSn(sn);
+						mesProductOprno.setOprno(oprnoOld);
+						mesProductOprno.setLineSn(lineSn);
+						MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
+						System.out.println(mesProductOprno1);
+						if(ObjectUtils.isEmpty(mesProductOprno1)){
+							//添加子工位表
+							mesProductOprnoService.save(mesProductOprno);
+							mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
+						}
+
+						if("OP310A".equals(oprno) ){
+							mesProductOprno1.setResult1(content);
+						}else if("OP310B".equals(oprno)){
+							mesProductOprno1.setResult2(content);
+						}
+						mesProductOprnoService.save(mesProductOprno1);
+
+						// 全有结果
+						if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
+							String lastRet = "NG";
+							if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
+								lastRet = "OK";
+							}
+							// 2.判断物料批次是否符合绑定
+							List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
+							// 总结果产线要求写死“OK”
+							mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
+						}else {
+							ret = "RSOK";
+							return ret;
+						}
 
+					}
 
 
 
@@ -1642,6 +1641,91 @@ public class MesProductRecordController extends BaseController {
 //			}
 //		}
 
+		String fOprno = CommonUitl.formatOprno(oprno);
+		// 判断当前模板是否和当前模板清单一致
+		// 查询当前工位的相关模板
+		List<MesTemplateItems> mesTemplateItemsList = mesTemplateItemsService.findListByOprno(fOprno);
+		// 查询已经有的Record
+		List<MesProductRecord> mesProductRecordList = mesProductRecordService.findBySnAndOprnoLike(sn,fOprno);
+		//根据craft对比,找出没加入的模板项
+		if(!ListUtils.isEmpty(mesTemplateItemsList)){
+			// 提取已存在的工艺号集合
+			Set<String> existCrafts = new HashSet<>();
+			if(!ListUtils.isEmpty(mesProductRecordList)){
+				for(MesProductRecord record : mesProductRecordList){
+					existCrafts.add(record.getCraft());
+				}
+			}
+
+			// 找出模板中存在但记录中不存在的工艺项
+			List<MesTemplateItems> missingItems = new ArrayList<>();
+			for(MesTemplateItems templateItem : mesTemplateItemsList){
+				if(!existCrafts.contains(templateItem.getCraft())){
+					missingItems.add(templateItem);
+				}
+			}
+
+			// 如果有缺失的模板项,需要补充创建
+			if(!ListUtils.isEmpty(missingItems)){
+				logger.warn("产品SN:{}, 工位:{}, 缺失模板项数量:{}", sn, fOprno, missingItems.size());
+
+				// 获取产品信息
+//					MesProduct mesProduct1 = new MesProduct();
+//					mesProduct1.setSn(sn);
+				MesProduct mesProduct = mesProductService.findBySn(sn);
+				if(ObjectUtils.isEmpty(mesProduct)){
+					throw new ServiceException(text("产品不存在!"));
+				}
+
+//					// 获取模板信息
+//					MesProductCate mesProductCate = mesProductCateService.findBySn(mesProduct.getCate());
+//					if(ObjectUtils.isEmpty(mesProductCate)){
+//						throw new ServiceException(text("产品类型不正确!"));
+//					}
+
+				Long cdate = Long.valueOf(CommonUitl.Date2TimeStamp(new Date()));
+				List<MesProductRecord> recordsToAdd = new ArrayList<>();
+
+				// 获取当前最大序号
+				int maxSerial = 0;
+				if(!ListUtils.isEmpty(mesProductRecordList)){
+					for(MesProductRecord record : mesProductRecordList){
+						if(record.getSerial() != null && record.getSerial() > maxSerial){
+							maxSerial = record.getSerial();
+						}
+					}
+				}
+
+				// 创建缺失的记录
+				for(MesTemplateItems missingItem : missingItems){
+					MesProductRecord newRecord = new MesProductRecord();
+					newRecord.setSn(sn);
+					newRecord.setPid("0");
+					newRecord.setCateSn(mesProduct.getCate());
+					newRecord.setLineSn(lineSn);
+					newRecord.setCraft(missingItem.getCraft());
+					newRecord.setOprno(missingItem.getOprno());
+					newRecord.setSerial(maxSerial);
+					newRecord.setTid(missingItem.getId());
+					newRecord.setTreeLevel(0);
+					newRecord.setCdate(cdate);
+					newRecord.setContent("UDF"); // 默认未定义状态
+					newRecord.setSource("0");
+					newRecord.setCreateDate(new Date());
+					newRecord.setUpdateDate(new Date());
+
+					recordsToAdd.add(newRecord);
+				}
+
+				// 批量插入缺失的记录
+				if(!ListUtils.isEmpty(recordsToAdd)){
+					mesProductRecordService.insertBatch(recordsToAdd, recordsToAdd.size());
+					logger.info("产品SN:{}, 补充创建记录数量:{}", sn, recordsToAdd.size());
+				}
+			}
+
+		}
+
 		try{
 			mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"OK",userCode,lineSn);
 		}catch (Exception e){
@@ -3865,6 +3949,45 @@ public class MesProductRecordController extends BaseController {
 						}
 					}
 
+
+					//310添加子工位
+					if (!StringUtils.isEmpty(oprno) &&"OP310".equals(oprnoOld)){
+						MesProductOprno mesProductOprno = new MesProductOprno();
+						mesProductOprno.setSn(sn);
+						mesProductOprno.setOprno(oprnoOld);
+						mesProductOprno.setLineSn(lineSn);
+						MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
+						System.out.println(mesProductOprno1);
+						if(ObjectUtils.isEmpty(mesProductOprno1)){
+							//添加子工位表
+							mesProductOprnoService.save(mesProductOprno);
+							mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
+						}
+
+						if("OP310A".equals(oprno) ){
+							mesProductOprno1.setResult1(result);
+						}else if("OP310B".equals(oprno)){
+							mesProductOprno1.setResult2(result);
+						}
+						mesProductOprnoService.save(mesProductOprno1);
+
+						// 全有结果
+						if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
+							String lastRet = "NG";
+							if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
+								lastRet = "OK";
+							}
+							// 2.判断物料批次是否符合绑定
+							List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
+							// 总结果产线要求写死“OK”
+							mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
+						}else {
+							ret = "RSOK";
+							return ret;
+						}
+
+					}
+
 					if (oprnoOld.equals("OP380")){
 						// 查询开始时间
 						MesDeviceTime mesDeviceTime = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno,sn,lineSn);