| | |
| | | if (!deliveryItemService.updateById(deliveryItem)) { |
| | | throw new CoolException("DO单明细更新失败!!"); |
| | | } |
| | | |
| | | Delivery delivery = deliveryService.getOne(new LambdaQueryWrapper<Delivery>().eq(Delivery::getCode, orderItem.getPoCode())); |
| | | if (!Objects.isNull(delivery)) { |
| | | Double wkQty = Math.round((delivery.getWorkQty() - delivery.getAnfme()) * 10000) / 10000.0; |
| | | delivery.setWorkQty(wkQty.compareTo(0.0) >= 0 ? wkQty : 0).setExceStatus(POExceStatus.PO_EXCE_STATUS_UN_EXCE.val); |
| | | if (!deliveryService.updateById(delivery)) { |
| | | throw new CoolException("DO单据修改失败!!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!Objects.isNull(order.getPoId())) { |
| | | Delivery delivery = deliveryService.getById(order.getPoId()); |
| | | if (!Objects.isNull(delivery)) { |
| | | Double sum = orderItems.stream().mapToDouble(AsnOrderItem::getAnfme).sum(); |
| | | Double workQty = Math.round((delivery.getWorkQty() - sum) * 10000) / 10000.0; |
| | | delivery.setWorkQty(workQty.compareTo(0.0) >= 0 ? workQty : 0).setExceStatus(POExceStatus.PO_EXCE_STATUS_UN_EXCE.val); |
| | | if (!deliveryService.updateById(delivery)) { |
| | | throw new CoolException("DO单据修改失败!!"); |
| | | } |
| | | } |
| | | } |
| | | if (!this.remove(new LambdaQueryWrapper<AsnOrder>().eq(AsnOrder::getId, id))) { |
| | | throw new CoolException("主单删除失败!!"); |
| | | } |
| | | if (!outStockItemService.remove(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, id))) { |
| | | throw new CoolException("单据明细删除失败!!"); |
| | | } |
| | | // if (!this.saveOrUpdate(order)) { |
| | | // throw new CoolException("单据取消失败!!"); |
| | | // } |
| | | return R.ok("操作成功"); |
| | | } |
| | | |