| | |
| | | } |
| | | WkOrder order = this.getById(id); |
| | | if (Objects.isNull(order)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | return R.ok("单据已不存在或已取消"); |
| | | } |
| | | if (!order.getExceStatus().equals(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val)) { |
| | | throw new CoolException("当前单据状态为" + AsnExceStatus.getExceStatus(order.getExceStatus()) + ", 不可执行取消操作!!"); |
| | |
| | | } |
| | | |
| | | if (!this.remove(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getId, id))) { |
| | | throw new CoolException("主单删除失败!!"); |
| | | return R.ok("单据已不存在或已取消"); |
| | | } |
| | | outStockItemService.remove(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, id)); |
| | | return R.ok("操作成功"); |
| | | return R.ok("取消成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R cancelOutOrderByItems(List<WkOrderItem> orderItems) { |
| | | Map<Long, List<WkOrderItem>> listMap = orderItems.stream().collect(Collectors.groupingBy(WkOrderItem::getOrderId)); |
| | | boolean anyProcessed = false; |
| | | for (Long key : listMap.keySet()) { |
| | | WkOrder order = this.getById(key); |
| | | if (Objects.isNull(order)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | continue; |
| | | } |
| | | anyProcessed = true; |
| | | List<WkOrderItem> items = listMap.get(key); |
| | | if (!items.isEmpty()) { |
| | | for (WkOrderItem orderItem : items) { |
| | |
| | | } |
| | | |
| | | if (!this.remove(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getId, key))) { |
| | | throw new CoolException("主单删除失败!!"); |
| | | continue; |
| | | } |
| | | if (!outStockItemService.remove(new LambdaQueryWrapper<WkOrderItem>() |
| | | .eq(WkOrderItem::getOrderId, key))) { |
| | | throw new CoolException("单据明细删除失败!!"); |
| | | } |
| | | outStockItemService.remove(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, key)); |
| | | } |
| | | return R.ok("操作成功"); |
| | | return R.ok(anyProcessed ? "取消成功" : "单据已不存在或已取消"); |
| | | } |
| | | |
| | | |