|
|
@@ -634,6 +634,57 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
getOrCreateOp290Row(sn, lineSn, "OP290B");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * OP420子工位:OP420A/OP420B分别提交,两边都有结果后才更新主表总结果。
|
|
|
+ * @return null=仅保存子工位,主表保持未加工;非null=汇总后的总结果
|
|
|
+ */
|
|
|
+ private String mergeOp420SubResult(String sn, String oldOprno, String lineSn, String content) {
|
|
|
+ content = "OK".equals(content) ? "OK" : "NG";
|
|
|
+ MesProductOprno query = new MesProductOprno();
|
|
|
+ query.setSn(sn);
|
|
|
+ query.setLineSn(lineSn);
|
|
|
+ query.setOprno("OP420");
|
|
|
+ MesProductOprno row = mesProductOprnoService.findInfo(query);
|
|
|
+ if (ObjectUtils.isEmpty(row)) {
|
|
|
+ row = new MesProductOprno();
|
|
|
+ row.setSn(sn);
|
|
|
+ row.setLineSn(lineSn);
|
|
|
+ row.setOprno("OP420");
|
|
|
+ mesProductOprnoService.save(row);
|
|
|
+ row = mesProductOprnoService.findInfo(query);
|
|
|
+ }
|
|
|
+ if ("OP420A".equals(oldOprno)) {
|
|
|
+ row.setResult1(content);
|
|
|
+ } else if ("OP420B".equals(oldOprno)) {
|
|
|
+ row.setResult2(content);
|
|
|
+ }
|
|
|
+ mesProductOprnoService.save(row);
|
|
|
+ if (StringUtils.isEmpty(row.getResult1()) || StringUtils.isEmpty(row.getResult2())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if ("OK".equals(row.getResult1()) && "OK".equals(row.getResult2())) {
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+ return "NG";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void finishDeviceTime(String oprno, String sn, String lineSn) {
|
|
|
+ MesDeviceTime mesDeviceTime = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno, sn, lineSn);
|
|
|
+ if (ObjectUtils.isEmpty(mesDeviceTime)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mesDeviceTime.setEndDate(new Date());
|
|
|
+ if (mesDeviceTime.getStartDate() != null && mesDeviceTime.getEndDate() != null
|
|
|
+ && mesDeviceTime.getStartDate().getTime() < mesDeviceTime.getEndDate().getTime()) {
|
|
|
+ Integer interval = Math.round((mesDeviceTime.getEndDate().getTime() - mesDeviceTime.getStartDate().getTime()) / 1000);
|
|
|
+ mesDeviceTime.setInterval(interval);
|
|
|
+ } else {
|
|
|
+ mesDeviceTime.setInterval(0);
|
|
|
+ }
|
|
|
+ mesDeviceTime.setSn(sn);
|
|
|
+ mesDeviceTimeService.save(mesDeviceTime);
|
|
|
+ }
|
|
|
+
|
|
|
private MesProductOprno getOrCreateOp290Row(String sn, String lineSn, String subOprno) {
|
|
|
MesProductOprno query = new MesProductOprno();
|
|
|
query.setSn(sn);
|
|
|
@@ -668,6 +719,20 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
content = mergedContent;
|
|
|
}
|
|
|
|
|
|
+ // OP420A/OP420B:开关打开后两边都提交才更新 OP420 总结果,避免一边做完另一边扫码显示已加工
|
|
|
+ if ("100000".equals(craft) && ("OP420A".equals(oldOprno) || "OP420B".equals(oldOprno))
|
|
|
+ && "1".equals(Global.getConfig("mes.op420.ab.check"))) {
|
|
|
+ String mergedContent = mergeOp420SubResult(sn, oldOprno, lineSn, content);
|
|
|
+ if (optime) {
|
|
|
+ finishDeviceTime(oldOprno, sn, lineSn);
|
|
|
+ }
|
|
|
+ if (mergedContent == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ oldOprno = "OP420";
|
|
|
+ content = mergedContent;
|
|
|
+ }
|
|
|
+
|
|
|
oprno = CommonUitl.formatOprno(oldOprno);
|
|
|
|
|
|
MesProductRecord mesProductRecord1 = new MesProductRecord();
|