| | |
| | | // 查询存有当前物料的货位 |
| | | List<LocDetl> locDetls = locDetlService.findOfSort(mat.getMatnr()); |
| | | double issued = Optional.ofNullable(custOrder.getQty()).orElse(0.0D) ; |
| | | while (issued > 0) { |
| | | for (LocDetl locDetl : locDetls) { |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | // 保存出库通知单 |
| | | Pakout pakout = new Pakout(); |
| | | pakout.setWrkSts(1L); |
| | |
| | | if (!pakoutService.insert(pakout)) { |
| | | throw new CoolException("保存出库通知单失败"); |
| | | } |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued>=locDetl.getAnfme()?locDetl.getAnfme():issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | if (issued>=locDetl.getAnfme()) { |
| | | // 删除库存明细 |
| | | if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | throw new CoolException("删除库存明细失败"); |
| | | } |
| | | } else { |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | } |
| | | } |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |