|
@@ -4207,4 +4207,176 @@ public class MesProductRecordController extends BaseController {
|
|
|
return resp;
|
|
return resp;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 开始工作
|
|
|
|
|
+ @PostMapping(value = "pcstart")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp pcstart(HttpServletRequest request) {
|
|
|
|
|
+ CommonResp resp = new CommonResp<>();
|
|
|
|
|
+ mesLogService.apisave(request);
|
|
|
|
|
+ String sn = request.getParameter("sn");
|
|
|
|
|
+ String oprno = request.getParameter("oprno");
|
|
|
|
|
+ String lineSn = request.getParameter("lineSn");
|
|
|
|
|
+ String userCode = request.getParameter("ucode");
|
|
|
|
|
+ if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(lineSn)){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage("参数错误");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+ MesDeviceTime mesDeviceTime = new MesDeviceTime();
|
|
|
|
|
+ mesDeviceTime.setSn(sn);
|
|
|
|
|
+ mesDeviceTime.setOprno(oprno);
|
|
|
|
|
+ mesDeviceTime.setStartDate(new Date());
|
|
|
|
|
+ mesDeviceTime.setProductCate(lineSn);
|
|
|
|
|
+ mesDeviceTime.setCreateBy(userCode);
|
|
|
|
|
+ mesDeviceTime.setUpdateBy(userCode);
|
|
|
|
|
+ String ret = "RSNS";
|
|
|
|
|
+ try {
|
|
|
|
|
+ ret = mesDeviceTimeService.add(mesDeviceTime);
|
|
|
|
|
+ if(ret.equals("OK")){
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ resp.setMessage("开始成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 绑定接口
|
|
|
|
|
+ @PostMapping(value = "pcbind")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp pcbind(HttpServletRequest request) {
|
|
|
|
|
+ CommonResp resp = new CommonResp<>();
|
|
|
|
|
+ mesLogService.apisave(request);
|
|
|
|
|
+ String oprno = request.getParameter("oprno");
|
|
|
|
|
+ String craft = request.getParameter("craft");
|
|
|
|
|
+ String lineSn = request.getParameter("lineSn");
|
|
|
|
|
+ String sn = request.getParameter("sn");
|
|
|
|
|
+ String materielSn = request.getParameter("materielSn");
|
|
|
|
|
+ String userCode = request.getParameter("ucode");
|
|
|
|
|
+ if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(lineSn) || StringUtils.isEmpty(craft) || StringUtils.isEmpty(materielSn) || StringUtils.isEmpty(userCode)){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage("参数错误");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"OK",userCode,lineSn);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ resp.setMessage("绑定成功");
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 解绑
|
|
|
|
|
+ @PostMapping(value = "pcunbind")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp pcunbind(HttpServletRequest request) {
|
|
|
|
|
+ CommonResp resp = new CommonResp<>();
|
|
|
|
|
+ mesLogService.apisave(request);
|
|
|
|
|
+ String oprno = request.getParameter("oprno");
|
|
|
|
|
+ String lineSn = request.getParameter("lineSn");
|
|
|
|
|
+ String sn = request.getParameter("sn");
|
|
|
|
|
+ String userCode = request.getParameter("ucode");
|
|
|
|
|
+ String craft = request.getParameter("craft");
|
|
|
|
|
+ String materielSn = request.getParameter("materielSn");
|
|
|
|
|
+ if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(lineSn) || StringUtils.isEmpty(userCode) || StringUtils.isEmpty(craft) ){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage("参数错误");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"UDF",userCode,lineSn);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ resp.setMessage("解绑成功");
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|