| | |
| | | } |
| | | BaUser userInfo = getUserInfo(result.getUserId().toString()); |
| | | PltStation stationInfo = getStationInfo(result.getStationId().toString()); |
| | | //如果是维修work_type 没有 planId processId nodeId |
| | | if (WORK_TYPE_REPAIR.equals(result.getWorkType())) { |
| | | //如果是无任务计划 如维修work_type 没有 planId processId nodeId |
| | | if (result.getPlanId() != null) { |
| | | //校验planId processId nodeId |
| | | PrAssemblyPlan assyPlan = assemblyDao.selectByPrimaryKey(result.getPlanId()); |
| | | boolean hasNodeId = assyPlan.getProcess().getNodes().stream() |
| | |
| | | public StaAssemblyWorkLast save(QueryVo vo) { |
| | | //先check |
| | | StaAssemblyWorkLast checkResult = checkUserAndStationUsed(vo); |
| | | //数据逐个封装返回 |
| | | vo.setLineId(checkResult.getLineId()); |
| | | StaAssemblyWorkLast staLast = new StaAssemblyWorkLast(); |
| | | BeanUtils.copyProperties(vo, staLast); |
| | | staLast.setUserId(checkResult.getUserId()); |
| | | staLast.setStationId(checkResult.getStationId()); |
| | | //校验planId processId nodeId |
| | | PrAssemblyPlan assyPlan = assemblyDao.selectByPrimaryKey(vo.getPlanId()); |
| | | PrAssemblyPlan assyPlan = new PrAssemblyPlan(); |
| | | if (vo.getPlanId() != null) { |
| | | assyPlan = assemblyDao.selectByPrimaryKey(vo.getPlanId()); |
| | | if (assyPlan == null) { |
| | | throw new RuntimeException("组装任务已经在系统中删除请检查,刷新并重新选择任务"); |
| | | } |
| | |
| | | if (!hasNodeId) { |
| | | throw new RuntimeException("节点信息有误或被其他人员修改,请重新选择节点信息"); |
| | | } |
| | | } |
| | | |
| | | //数据逐个封装返回 |
| | | vo.setLineId(checkResult.getLineId()); |
| | | StaAssemblyWorkLast staLast = new StaAssemblyWorkLast(); |
| | | BeanUtils.copyProperties(vo, staLast); |
| | | staLast.setUserId(checkResult.getUserId()); |
| | | staLast.setStationId(checkResult.getStationId()); |
| | | int count = 0; |
| | | if (checkResult.getId() == null) { |
| | | BeanUtils.copyProperties(vo, staLast);//vo拷贝到staLast |
| | |
| | | } else { |
| | | //保存一条history? |
| | | BeanUtils.copyProperties(checkResult, staLast); |
| | | if (vo.getPlanId() != null) { |
| | | staLast.setPlanId(assyPlan.getId()); |
| | | staLast.setProcessId(assyPlan.getProcess().getId()); |
| | | staLast.setNodeId(vo.getNodeId()); |
| | | } |
| | | staLast.setWorkType(vo.getWorkType()); |
| | | staLast.setStatus(STATUS_NORMAL); |
| | | staLast.setStartTime(new Date()); |
| | | count = assemblyWorkLastDao.updateByPrimaryKeySelective(staLast); |
| | |
| | | throw new RuntimeException("数据库存储失败"); |
| | | } |
| | | StaAssemblyWorkLast result = assemblyWorkLastDao.selectByPrimaryKey(staLast.getId()); |
| | | if (assyPlan != null) { |
| | | List<PrProductionNode> nodeInfo = assyPlan.getProcess().getNodes().stream() |
| | | .filter(node -> node.id.equals(vo.getNodeId())).collect(Collectors.toList()); |
| | | result.setPlanName(assyPlan.getName()); |
| | |
| | | result.setProName(product.getName()); |
| | | String devicePrefix = QrCodeConstant.TypeProduct + product.getCode() + assyPlan.getBatchNo(); |
| | | result.setDevicePrefix(devicePrefix); |
| | | } |
| | | return result; |
| | | } |
| | | |