| | |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, TaskDto taskDto, Long userId) { |
| | | Date now = new Date(); |
| | | taskDto.sortLocDtos(); |
| | | List<LocDto> locDtos = taskDto.getLocDtos(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { |
| | |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } |
| | | if (locDto.getAnfme()==null) { continue; } |
| | | LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch(), locDto.getContainerCode()); |
| | | if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) { |
| | | throw new CoolException(locDto.getLocNo() + "库位中" + locDto.getMatnr() + "商品库存不足!"); |
| | |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setBatch(locDto.getBatch()); |
| | | wrkDetl.setOrderNo(locDto.getOrderNo()); |
| | | wrkDetl.setAnfme(locDto.getAnfme()); // 数量 |
| | | wrkDetl.setAnfme(locDto.getAnfme()); // 作业数量 |
| | | wrkDetl.setStock(locDto.getStock()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | |
| | | }); |
| | | } |
| | | |
| | | // 修改订单明细 |
| | | if (!BaseController.isJSON(locDto.getOrderNo())) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getCsocode(),locDto.getIsoseq()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null,locDto.getCsocode(),locDto.getIsoseq()); |
| | | } |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme(),locDto.getCsocode(),locDto.getIsoseq())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class); |
| | | |
| | | //实际出库数量 |
| | | Double locAnfme = locDto.getAnfme(); |
| | | //订单实际出库数量 |
| | | Double orderAnfme; |
| | | |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getCsocode(),locDto.getIsoseq()); |
| | | if (locDto.getAnfme() > 0) { |
| | | // 修改订单明细 |
| | | if (!BaseController.isJSON(locDto.getOrderNo())) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getCsocode(),locDto.getIsoseq()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), null,locDto.getCsocode(),locDto.getIsoseq()); |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null,locDto.getCsocode(),locDto.getIsoseq()); |
| | | } |
| | | |
| | | orderAnfme = orderDetl.getAnfme() - orderDetl.getQty(); |
| | | |
| | | if(locAnfme > orderAnfme){ |
| | | locAnfme -= orderAnfme; |
| | | }else { |
| | | orderAnfme = locAnfme; |
| | | } |
| | | |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderAnfme,orderDetl.getThreeCode(),orderDetl.getDeadTime())) { |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme(),locDto.getCsocode(),locDto.getIsoseq())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } else { |
| | | // 订单合并出库 |
| | | List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class); |
| | | |
| | | //实际出库数量 |
| | | Double locAnfme = locDto.getAnfme(); |
| | | //订单实际出库数量 |
| | | Double orderAnfme; |
| | | |
| | | for (OrderDto orderDto : orderDtoList) { |
| | | OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getCsocode(),locDto.getIsoseq()); |
| | | if (orderDetl == null) { |
| | | orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), null,locDto.getCsocode(),locDto.getIsoseq()); |
| | | } |
| | | |
| | | orderAnfme = orderDetl.getAnfme() - orderDetl.getQty(); |
| | | |
| | | if(locAnfme > orderAnfme){ |
| | | locAnfme -= orderAnfme; |
| | | }else { |
| | | orderAnfme = locAnfme; |
| | | } |
| | | |
| | | if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderAnfme,orderDetl.getThreeCode(),orderDetl.getDeadTime())) { |
| | | throw new CoolException("修改订单明细数量失败"); |
| | | } |
| | | orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | private void generateAgvWaitpakin(WrkDetl wrkDetl){ |
| | | if (wrkDetl.getAnfme() <= 0D) { |
| | | return; |
| | | } |
| | | |
| | | String orderNo = wrkDetl.getOrderNo(); |
| | | if(orderNo.contains("{")){ |
| | | JSONArray orderArray = JSON.parseArray(orderNo); |