|
|
@@ -17,6 +17,7 @@ import com.jeesite.modules.mes.dao.*;
|
|
|
import com.jeesite.modules.mes.entity.*;
|
|
|
import com.jeesite.modules.mes.resp.*;
|
|
|
import com.jeesite.modules.mes.util.CommonUitl;
|
|
|
+import com.jeesite.modules.mes.util.AssemblyRestRule;
|
|
|
import com.jeesite.modules.mes.util.CopyUtil;
|
|
|
import com.jeesite.modules.sys.dao.UserDao;
|
|
|
import com.jeesite.modules.utils.ProtocolParam;
|
|
|
@@ -42,6 +43,66 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
@Autowired
|
|
|
private MesProductRecordDao mesProductRecordDao;
|
|
|
|
|
|
+ /** 通过数据库原结果原子地维护计时,防止重复OK上报延长静置。 */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void update(MesProductRecord record) {
|
|
|
+ validateAssemblyResultUpdate(record);
|
|
|
+ if (!StringUtils.isEmpty(record.getId()) && !StringUtils.isEmpty(record.getContent())) {
|
|
|
+ mesProductRecordDao.updateAssemblyClock(record);
|
|
|
+ }
|
|
|
+ super.update(record);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validateAssemblyResultUpdate(MesProductRecord record) {
|
|
|
+ if (!"OK".equals(record.getContent())) return;
|
|
|
+ MesProductRecord existing = StringUtils.isEmpty(record.getId()) ? null : super.get(record);
|
|
|
+ MesProductRecord target = existing == null ? record : existing;
|
|
|
+ if (!"100000".equals(target.getCraft())) return;
|
|
|
+ String blocked = checkAssemblyUpload(target.getSn(), target.getOprno(), target.getLineSn(), null);
|
|
|
+ if (blocked != null) throw new ServiceException(blocked);
|
|
|
+ }
|
|
|
+
|
|
|
+ public MesProductRecord findAssemblyRecord(String sn, String lineSn) {
|
|
|
+ MesProductRecord query = new MesProductRecord();
|
|
|
+ query.setSn(sn);
|
|
|
+ query.setCraft("100000");
|
|
|
+ query.getSqlMap().getWhere().and("a.line_sn", QueryType.EQ, lineSn);
|
|
|
+ MesProductRecord result = null;
|
|
|
+ for (MesProductRecord row : findList(query)) {
|
|
|
+ if (!"OP200".equals(CommonUitl.formatOprno(row.getOprno()))) continue;
|
|
|
+ // 多条装配主结果不猜测有效记录,交由现场核实。
|
|
|
+ if (result != null) return null;
|
|
|
+ result = row;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String checkAssemblyRest(String sn, String oprno, String lineSn, Date at) {
|
|
|
+ if (!"INSP080".equals(CommonUitl.formatOprno(oprno))) return null;
|
|
|
+ MesProductRecord assembly = findAssemblyRecord(sn, lineSn);
|
|
|
+ return AssemblyRestRule.check(assembly != null && "OK".equals(assembly.getContent()),
|
|
|
+ assembly == null ? null : assembly.getAssemblyCompletedAt(), at);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String checkAssemblyUpload(String sn, String oprno, String lineSn, Date testTime) {
|
|
|
+ if (!"INSP080".equals(CommonUitl.formatOprno(oprno))) return null;
|
|
|
+ Date now = new Date();
|
|
|
+ String blocked = checkAssemblyRest(sn, oprno, lineSn, now);
|
|
|
+ if (blocked != null) return blocked;
|
|
|
+ MesDeviceTime timing = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno, sn, lineSn);
|
|
|
+ if (timing == null || timing.getStartDate() == null || timing.getStartDate().after(now)) {
|
|
|
+ return "缺少有效的半成品气密加工前校验记录,请重新扫码校验";
|
|
|
+ }
|
|
|
+ blocked = checkAssemblyRest(sn, oprno, lineSn, timing.getStartDate());
|
|
|
+ if (blocked != null) return "气密开始时未满足静置要求:" + blocked;
|
|
|
+ if (testTime != null) {
|
|
|
+ if (testTime.after(now)) return "气密检测时间不能晚于服务端当前时间";
|
|
|
+ blocked = checkAssemblyRest(sn, oprno, lineSn, testTime);
|
|
|
+ }
|
|
|
+ return blocked;
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
private MesProductCateService mesProductCateService;
|
|
|
|
|
|
@@ -141,13 +202,18 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void save(MesProductRecord mesProductRecord) {
|
|
|
+ validateAssemblyResultUpdate(mesProductRecord);
|
|
|
if (StringUtils.isEmpty(mesProductRecord.getSource())) {
|
|
|
mesProductRecord.setSource("0");
|
|
|
}
|
|
|
|
|
|
// 设置计件时间
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
+ if (!mesProductRecord.getIsNewRecord() && !StringUtils.isEmpty(mesProductRecord.getContent())) {
|
|
|
+ mesProductRecordDao.updateAssemblyClock(mesProductRecord);
|
|
|
+ }
|
|
|
|
|
|
super.save(mesProductRecord);
|
|
|
}
|
|
|
@@ -243,6 +309,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
return super.findPage(mesProductRecord);
|
|
|
}
|
|
|
public boolean updateAll(MesProductRecord mesProductRecord) {
|
|
|
+ String blocked = checkAssemblyUpload(mesProductRecord.getSn(), mesProductRecord.getOprno(),
|
|
|
+ mesProductRecord.getLineSn(), null);
|
|
|
+ if (blocked != null) throw new ServiceException(blocked);
|
|
|
return mesProductRecordDao.updateAll(mesProductRecord);
|
|
|
}
|
|
|
/**
|
|
|
@@ -661,6 +730,8 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
*/
|
|
|
@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 restBlocked = checkAssemblyUpload(sn, oprno, lineSn, null);
|
|
|
+ if (restBlocked != null) throw new ServiceException(restBlocked);
|
|
|
String oldOprno = oprno;
|
|
|
oprno = CommonUitl.formatOprno(oprno);
|
|
|
sn = sn.trim();
|
|
|
@@ -791,7 +862,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
}
|
|
|
mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -805,7 +876,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(mesLineProcess1.getDevices());
|
|
|
mesProductRecord.setContent("OK");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
}else if(mesProductRecord.getCraft().equals("400003")){
|
|
|
if(!oldOprno.equals(oprno)){
|
|
|
mesProductRecord.setOprno(oldOprno);
|
|
|
@@ -813,7 +884,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(mesLineProcess1.getGzs());
|
|
|
mesProductRecord.setContent("OK");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
}
|
|
|
|
|
|
// 更新主结果
|
|
|
@@ -828,8 +899,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
|
|
|
mesProductRecord.setMaterielSn(materielSn);
|
|
|
mesProductRecord.setContent(content);
|
|
|
+ mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1172,7 +1244,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setContent(content);
|
|
|
mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
|
|
|
/*if(CommonUitl.formatOprno(oprno).equals("OP290") && craft.equals("400002")){
|
|
|
MesProductDhb mesProductDhb = new MesProductDhb();
|
|
|
@@ -1262,7 +1334,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(materielSn);
|
|
|
mesProductRecord.setContent(content);
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
|
|
|
// 更新用户
|
|
|
MesProductRecord mesProductRecord2 = findByUpdateCate(sn,oprno,"400002",lineSn);
|
|
|
@@ -1294,7 +1366,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn("");
|
|
|
mesProductRecord.setContent(content);
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- super.update(mesProductRecord);
|
|
|
+ this.update(mesProductRecord);
|
|
|
|
|
|
if(!craft.equals("400001")){ // 不是绑定操作人员的
|
|
|
// 记录解绑物料批次
|
|
|
@@ -1442,6 +1514,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
|
|
|
//通过首件检查结果OK/NG 修改工位结果 10000
|
|
|
public void updateResultByCheckFirst(MesProductRecord mesProductRecord){
|
|
|
+ String blocked = checkAssemblyUpload(mesProductRecord.getSn(), mesProductRecord.getOprno(),
|
|
|
+ mesProductRecord.getLineSn(), null);
|
|
|
+ if (blocked != null) throw new ServiceException(blocked);
|
|
|
mesProductRecordDao.updateResultByCheckFirst(mesProductRecord);
|
|
|
}
|
|
|
|
|
|
@@ -1458,4 +1533,4 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
public List<Map<String, Object>> pieceworkHourlyStat(Map<String, Object> params){
|
|
|
return mesProductRecordDao.pieceworkHourlyStat(params);
|
|
|
}
|
|
|
-}
|
|
|
+}
|