hzd há 3 dias atrás
pai
commit
897712e258

+ 76 - 1
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -134,6 +134,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
     @Autowired
     private MesProductModifyRecordService mesProductModifyRecordService;
 
+	@Autowired
+	private MesProductOprnoService mesProductOprnoService;
+
 	@Override
 	public void save(MesProductRecord mesProductRecord) {
 		if (StringUtils.isEmpty(mesProductRecord.getSource())) {
@@ -587,14 +590,86 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	}
 
 	/**
+	 * OP290子工位:OP290A/OP290B分别提交,子表齐且都为OK后才更新主表总结果
+	 * @return null=仅保存子工位结果,暂不更新主表;非null=汇总后的总结果
+	 */
+	private String mergeOp290SubResult(String sn, String oldOprno, String lineSn, String content) {
+		if (!"OP290A".equals(oldOprno) && !"OP290B".equals(oldOprno)) {
+			return content;
+		}
+		content = "OK".equals(content) ? "OK" : "NG";
+
+		MesProductOprno query = new MesProductOprno();
+		query.setSn(sn);
+		query.setLineSn(lineSn);
+		query.setOprno(oldOprno);
+		MesProductOprno existing = mesProductOprnoService.findInfo(query);
+		if (ObjectUtils.isEmpty(existing)) {
+			initOp290SubRows(sn, lineSn);
+		}
+
+		MesProductOprno rowA = getOrCreateOp290Row(sn, lineSn, "OP290A");
+		MesProductOprno rowB = getOrCreateOp290Row(sn, lineSn, "OP290B");
+		if ("OP290A".equals(oldOprno)) {
+			rowA.setResult1(content);
+			mesProductOprnoService.save(rowA);
+		} else {
+			rowB.setResult1(content);
+			mesProductOprnoService.save(rowB);
+		}
+
+		rowA = getOrCreateOp290Row(sn, lineSn, "OP290A");
+		rowB = getOrCreateOp290Row(sn, lineSn, "OP290B");
+		if (StringUtils.isEmpty(rowA.getResult1()) || StringUtils.isEmpty(rowB.getResult1())) {
+			return null;
+		}
+		if ("OK".equals(rowA.getResult1()) && "OK".equals(rowB.getResult1())) {
+			return "OK";
+		}
+		return "NG";
+	}
+
+	private void initOp290SubRows(String sn, String lineSn) {
+		getOrCreateOp290Row(sn, lineSn, "OP290A");
+		getOrCreateOp290Row(sn, lineSn, "OP290B");
+	}
+
+	private MesProductOprno getOrCreateOp290Row(String sn, String lineSn, String subOprno) {
+		MesProductOprno query = new MesProductOprno();
+		query.setSn(sn);
+		query.setLineSn(lineSn);
+		query.setOprno(subOprno);
+		MesProductOprno row = mesProductOprnoService.findInfo(query);
+		if (ObjectUtils.isEmpty(row)) {
+			row = new MesProductOprno();
+			row.setSn(sn);
+			row.setLineSn(lineSn);
+			row.setOprno(subOprno);
+			mesProductOprnoService.save(row);
+			row = mesProductOprnoService.findInfo(query);
+		}
+		return row;
+	}
+
+	/**
 	 * 质量上传(总结果) 100000
 	 */
 	@Transactional
 	public void updateRecordResult(String sn, String oprno, String craft, String materielSn, String content, String userCode, List<ParamsResp> paramsResps,String lineSn,Boolean optime,List<BindMaterialResp> bmlists) {
 		String oldOprno = oprno;
-		oprno = CommonUitl.formatOprno(oprno);
 		sn = sn.trim();
 
+		if ("100000".equals(craft) && ("OP290A".equals(oldOprno) || "OP290B".equals(oldOprno))) {
+			String mergedContent = mergeOp290SubResult(sn, oldOprno, lineSn, content);
+			if (mergedContent == null) {
+				return;
+			}
+			oldOprno = "OP290A";
+			content = mergedContent;
+		}
+
+		oprno = CommonUitl.formatOprno(oldOprno);
+
 		MesProductRecord mesProductRecord1 = new MesProductRecord();
 
 		mesProductRecord1.setOprno(oprno);

+ 4 - 1
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -3039,6 +3039,9 @@ public class MesProductRecordController extends BaseController {
 		if(mesProductRecord.getOprno().length() == 5){
 			mesProductRecord.setOprno(mesProductRecord.getOprno()+"A");
 		}
+		if(mesProductRecord.getOprno().equals("OP550A")){
+			mesProductRecord.setOprno("OP550");
+		}
 		Page page1 = new Page<>(request, response);
 		mesProductRecord.setPage(page1);
 		mesProductRecord.setCraft("100000");
@@ -4208,7 +4211,7 @@ public class MesProductRecordController extends BaseController {
 						MesDeviceTime mesDeviceTime1 = mesDeviceTimeService.findList(mesDeviceTime).get(0);
 						System.out.println("mesDeviceTime1:"+mesDeviceTime1.getEndDate());
 						// 当前时间要在这个工件结束时间三分钟后
-						long twoHoursInMillis = 150 * 1000;
+						long twoHoursInMillis = 3 * 30 * 1000;
 						long timeDifference = System.currentTimeMillis() - mesDeviceTime1.getEndDate().getTime();
 						if(timeDifference < twoHoursInMillis){
 							return renderResult(Global.FALSE, text("未在规定时间内!"));