|
@@ -995,7 +995,84 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
}
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 检查模板与现有模板是否一致,不一致则创建模板
|
|
|
|
|
+ private void checkTempalte(String sn,String oprno,String lineSn){
|
|
|
|
|
+ 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 mesProduct = mesProductService.findBySn(sn);
|
|
|
|
|
+ if(ObjectUtils.isEmpty(mesProduct)){
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
private String checkProductCreate(String sn, String lineSn, String userCode){
|
|
private String checkProductCreate(String sn, String lineSn, String userCode){
|
|
|
// 检查工件状态
|
|
// 检查工件状态
|
|
|
MesProduct mesProduct = new MesProduct();
|
|
MesProduct mesProduct = new MesProduct();
|
|
@@ -1158,6 +1235,8 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return bs+"UD";
|
|
return bs+"UD";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ checkTempalte(sn,oprno,lineSn); // 检查模板
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 检查工件状态
|
|
// 检查工件状态
|
|
@@ -1850,47 +1929,74 @@ public class MesProductRecordController extends BaseController {
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 智能电批
|
|
|
|
|
- @RequestMapping(value = "check")
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServletRequest request) {
|
|
|
|
|
- mesLogService.apisave2(mesElectricTorque.getOprno(),mesElectricTorque.getLineSn(),mesElectricTorque.toString(),request);
|
|
|
|
|
- String oprno = mesElectricTorque.getOprno();
|
|
|
|
|
- String lineSn = mesElectricTorque.getLineSn();
|
|
|
|
|
- String sn = mesElectricTorque.getSn();
|
|
|
|
|
- if ("".equals(oprno) ||oprno==null|| "".equals(lineSn)||lineSn==null){
|
|
|
|
|
- return renderResult(Global.FALSE, text("操作失败,缺少参数值!"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- MesLineProcess mesLineProcess = mesLineProcessService.findInfoByOprnoLineSn(oprno,lineSn);
|
|
|
|
|
- if(ObjectUtils.isEmpty(mesLineProcess)){
|
|
|
|
|
- return renderResult(Global.FALSE, text("子工位未配置!"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- String ret = checkQualityResult(oprno,sn,lineSn,"");
|
|
|
|
|
- String processMsgRet = ret.substring(3,5);
|
|
|
|
|
- // OK当前工位已加工合格/NG当前工位已加工不合格/QN前工位不合格/UD可以加工/其他-该工件不可加工
|
|
|
|
|
- if(processMsgRet.equals("UD")){
|
|
|
|
|
- try{
|
|
|
|
|
- // 开始工作
|
|
|
|
|
- MesDeviceTime mesDeviceTime = new MesDeviceTime();
|
|
|
|
|
- mesDeviceTime.setOprno(oprno);
|
|
|
|
|
- mesDeviceTime.setSn(sn);
|
|
|
|
|
- mesDeviceTime.setStartDate(new Date());
|
|
|
|
|
- mesDeviceTime.setProductCate(lineSn);
|
|
|
|
|
- mesDeviceTimeService.add(mesDeviceTime);
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- return renderResult(Global.TRUE, text("工件可以加工!"));
|
|
|
|
|
- }else{
|
|
|
|
|
- String lx = ret.substring(0,3);
|
|
|
|
|
- String lmsg = ErrorMsg.getErrorMsg(processMsgRet,lx);
|
|
|
|
|
- return renderResult(Global.FALSE, text(lmsg));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+// // 智能电批
|
|
|
|
|
+// @RequestMapping(value = "check")
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServletRequest request) {
|
|
|
|
|
+// mesLogService.apisave2(mesElectricTorque.getOprno(),mesElectricTorque.getLineSn(),mesElectricTorque.toString(),request);
|
|
|
|
|
+// String oprno = mesElectricTorque.getOprno();
|
|
|
|
|
+// String lineSn = mesElectricTorque.getLineSn();
|
|
|
|
|
+// String sn = mesElectricTorque.getSn();
|
|
|
|
|
+// if ("".equals(oprno) ||oprno==null|| "".equals(lineSn)||lineSn==null){
|
|
|
|
|
+// return renderResult(Global.FALSE, text("操作失败,缺少参数值!"));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// MesLineProcess mesLineProcess = mesLineProcessService.findInfoByOprnoLineSn(oprno,lineSn);
|
|
|
|
|
+// if(ObjectUtils.isEmpty(mesLineProcess)){
|
|
|
|
|
+// return renderResult(Global.FALSE, text("子工位未配置!"));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// String ret = checkQualityResult(oprno,sn,lineSn,"");
|
|
|
|
|
+// String processMsgRet = ret.substring(3,5);
|
|
|
|
|
+// // OK当前工位已加工合格/NG当前工位已加工不合格/QN前工位不合格/UD可以加工/其他-该工件不可加工
|
|
|
|
|
+// if(processMsgRet.equals("UD")){
|
|
|
|
|
+// try{
|
|
|
|
|
+// // 开始工作
|
|
|
|
|
+// MesDeviceTime mesDeviceTime = new MesDeviceTime();
|
|
|
|
|
+// mesDeviceTime.setOprno(oprno);
|
|
|
|
|
+// mesDeviceTime.setSn(sn);
|
|
|
|
|
+// mesDeviceTime.setStartDate(new Date());
|
|
|
|
|
+// mesDeviceTime.setProductCate(lineSn);
|
|
|
|
|
+// mesDeviceTimeService.add(mesDeviceTime);
|
|
|
|
|
+// }catch (Exception e){
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+// return renderResult(Global.TRUE, text("工件可以加工!"));
|
|
|
|
|
+// }else{
|
|
|
|
|
+// String lx = ret.substring(0,3);
|
|
|
|
|
+// String lmsg = ErrorMsg.getErrorMsg(processMsgRet,lx);
|
|
|
|
|
+// return renderResult(Global.FALSE, text(lmsg));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// 智能电批
|
|
|
|
|
+@RequestMapping(value = "check")
|
|
|
|
|
+@ResponseBody
|
|
|
|
|
+public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServletRequest request) {
|
|
|
|
|
+ mesLogService.apisave2(mesElectricTorque.getOprno(),mesElectricTorque.getLineSn(),mesElectricTorque.toString(),request);
|
|
|
|
|
+ String oprno = mesElectricTorque.getOprno();
|
|
|
|
|
+ String lineSn = mesElectricTorque.getLineSn();
|
|
|
|
|
+ String sn = mesElectricTorque.getSn();
|
|
|
|
|
+ if ("".equals(oprno) ||oprno==null|| "".equals(lineSn)||lineSn==null){
|
|
|
|
|
+ return renderResult(Global.FALSE, text("操作失败,缺少参数值!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MesLineProcess mesLineProcess = mesLineProcessService.findInfoByOprnoLineSn(oprno,lineSn);
|
|
|
|
|
+ if(ObjectUtils.isEmpty(mesLineProcess)){
|
|
|
|
|
+ return renderResult(Global.FALSE, text("子工位未配置!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String ret = checkQualityCommon(oprno,sn,lineSn,"");
|
|
|
|
|
+ String checkret = ret.substring(3,5);
|
|
|
|
|
+ if(checkret.equals("UD")){
|
|
|
|
|
+ return renderResult(Global.TRUE, text("工件可以加工!"));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ String lx = ret.substring(0,3);
|
|
|
|
|
+ String lmsg = ErrorMsg.getErrorMsg(checkret,lx);
|
|
|
|
|
+ return renderResult(Global.FALSE, text(lmsg));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+}
|
|
|
// 设备状态
|
|
// 设备状态
|
|
|
@PostMapping(value = "device")
|
|
@PostMapping(value = "device")
|
|
|
@ResponseBody
|
|
@ResponseBody
|