|
|
@@ -17,7 +17,6 @@ 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;
|
|
|
@@ -43,66 +42,6 @@ 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;
|
|
|
|
|
|
@@ -202,18 +141,13 @@ 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);
|
|
|
}
|
|
|
@@ -309,9 +243,6 @@ 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);
|
|
|
}
|
|
|
/**
|
|
|
@@ -730,8 +661,6 @@ 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();
|
|
|
@@ -862,7 +791,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
}
|
|
|
mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -876,7 +805,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(mesLineProcess1.getDevices());
|
|
|
mesProductRecord.setContent("OK");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
}else if(mesProductRecord.getCraft().equals("400003")){
|
|
|
if(!oldOprno.equals(oprno)){
|
|
|
mesProductRecord.setOprno(oldOprno);
|
|
|
@@ -884,7 +813,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(mesLineProcess1.getGzs());
|
|
|
mesProductRecord.setContent("OK");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
}
|
|
|
|
|
|
// 更新主结果
|
|
|
@@ -899,9 +828,8 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
|
|
|
mesProductRecord.setMaterielSn(materielSn);
|
|
|
mesProductRecord.setContent(content);
|
|
|
- mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1244,7 +1172,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setContent(content);
|
|
|
mesProductRecord.setSource("0");
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
|
|
|
/*if(CommonUitl.formatOprno(oprno).equals("OP290") && craft.equals("400002")){
|
|
|
MesProductDhb mesProductDhb = new MesProductDhb();
|
|
|
@@ -1334,7 +1262,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn(materielSn);
|
|
|
mesProductRecord.setContent(content);
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
|
|
|
// 更新用户
|
|
|
MesProductRecord mesProductRecord2 = findByUpdateCate(sn,oprno,"400002",lineSn);
|
|
|
@@ -1366,7 +1294,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
mesProductRecord.setMaterielSn("");
|
|
|
mesProductRecord.setContent(content);
|
|
|
setPieceworkDateIfNeeded(mesProductRecord);
|
|
|
- this.update(mesProductRecord);
|
|
|
+ super.update(mesProductRecord);
|
|
|
|
|
|
if(!craft.equals("400001")){ // 不是绑定操作人员的
|
|
|
// 记录解绑物料批次
|
|
|
@@ -1514,9 +1442,6 @@ 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);
|
|
|
}
|
|
|
|
|
|
@@ -1533,4 +1458,4 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
|
|
|
public List<Map<String, Object>> pieceworkHourlyStat(Map<String, Object> params){
|
|
|
return mesProductRecordDao.pieceworkHourlyStat(params);
|
|
|
}
|
|
|
-}
|
|
|
+}
|