| | |
| | | List<LocDto> locDtoList = new ArrayList<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetlList) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | Order order = orderService.selectByNo(orderDetl.getOrderNo()); |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if("人工补货单".equals(docType.getDocName())){ |
| | | if (issued <= 0.0D) { continue; } |
| | | issued = locDetlService.queryStockAndSetLocDto1(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtoList.add(locDto); |
| | | try { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | Order order = orderService.selectByNo(orderDetl.getOrderNo()); |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if("人工补货单".equals(docType.getDocName())){ |
| | | if (issued <= 0.0D) { continue; } |
| | | issued = locDetlService.queryStockAndSetLocDto1(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtoList.add(locDto); |
| | | } |
| | | }else { |
| | | if (issued <= 0.0D) { continue; } |
| | | |
| | | //从平库寻找 |
| | | issued = manLocDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | //先找AGV的库存,如果返回的issued大于0,则去四项库找 |
| | | issued = agvLocDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | //从四项库的库存里面找, |
| | | issued = locDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtoList.add(locDto); |
| | | } |
| | | } |
| | | }else { |
| | | if (issued <= 0.0D) { continue; } |
| | | |
| | | //从平库寻找 |
| | | issued = manLocDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | //先找AGV的库存,如果返回的issued大于0,则去四项库找 |
| | | issued = agvLocDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | //从四项库的库存里面找, |
| | | issued = locDetlService.queryStockAndSetLocDto(orderDetl.getMatnr(),orderDetl.getBatch(),orderDetl.getOrderNo(),locDtoList,issued,orderDetl.getThreeCode(),orderDetl.getDeadTime()); |
| | | |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtoList.add(locDto); |
| | | } |
| | | } catch (Exception e) { |
| | | // 单条明细异常时记录并继续 |
| | | log.error("出库预览异常 orderDetlId={} orderNo={} matnr={}", orderDetl.getId(), orderDetl.getOrderNo(), orderDetl.getMatnr(), e); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | } |
| | | return R.ok().add(locDtoList); |
| | | |
| | |
| | | @PostMapping("/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | @Transactional |
| | | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws Exception { |
| | | log.info("订单出库:{}", locDtos); |
| | | //判断是否可以生成出库工作档 |
| | | boolean lack = true; |
| | |
| | | } |
| | | Thread.sleep(500L); |
| | | |
| | | // 订单预校验 ===>> 1.订单状态; 2.订单带出数量 |
| | | List<OrderDto> orderDtos = orderPreVerification(locDtos); |
| | | try { |
| | | boolean debugd = false; |
| | | if(debugd){ |
| | | throw new RuntimeException("debug rollback"); |
| | | } |
| | | // 订单预校验 ===>> 1.订单状态; 2.订单带出数量 |
| | | List<OrderDto> orderDtos = orderPreVerification(locDtos); |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | List<TaskDto> agvTaskDtos = new ArrayList<>(); |
| | | generateTaskDto(locDtos, taskDtos, agvTaskDtos); |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | List<TaskDto> agvTaskDtos = new ArrayList<>(); |
| | | generateTaskDto(locDtos,taskDtos,agvTaskDtos); |
| | | //生成AGV出库任务 |
| | | agvWorkService.stockOutWrkMast(agvTaskDtos, getUserId()); |
| | | |
| | | //生成AGV出库任务 |
| | | agvWorkService.stockOutWrkMast(agvTaskDtos, getUserId()); |
| | | |
| | | // 生成出库任务 |
| | | taskDtos.stream().map(TaskDto::getLocNo).distinct().collect(Collectors.toList()); |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | workService.stockOut(staNo, taskDto, getUserId()); |
| | | // 生成出库任务 |
| | | taskDtos.stream().map(TaskDto::getLocNo).distinct().collect(Collectors.toList()); |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | workService.stockOut(staNo, taskDto, getUserId()); |
| | | } |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | log.error("订单出库异常", e); |
| | | throw e; |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |