| | |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | /** 入库单业务类型:拣料入库、盘点入库等不可修改明细,此处为字典 value,按实际配置补充 */ |
| | | private static final Set<String> ASN_WKTYPE_NO_EDIT = Collections.unmodifiableSet(new HashSet<>( |
| | | Arrays.asList("53", "57"))); // 53=拣料再入库 57=盘点再入库(与 TaskType 一致,若字典不同请改为实际 value) |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception { |
| | |
| | | if (Objects.isNull(orders.getId())) { |
| | | throw new CoolException("数据错误:单据ID不能为空!!"); |
| | | } |
| | | if (!this.updateById(orders)) { |
| | | throw new CoolException("主单修改失败!!"); |
| | | WkOrder currentOrder = this.getById(orders.getId()); |
| | | if (Objects.isNull(currentOrder)) { |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | | // 仅未执行状态可修改 |
| | | if (!Objects.equals(currentOrder.getExceStatus(), AsnExceStatus.ASN_EXCE_STATUS_UN_EXCE.val)) { |
| | | throw new CoolException("当前单据状态不允许修改,仅未执行状态可修改"); |
| | | } |
| | | // 拣料入库、盘点入库类型不可修改 |
| | | if (StringUtils.isNotBlank(currentOrder.getWkType()) && ASN_WKTYPE_NO_EDIT.contains(currentOrder.getWkType())) { |
| | | throw new CoolException("拣料入库、盘点入库类型的单据不能修改"); |
| | | } |
| | | if (Objects.isNull(params.getItems()) || params.getItems().isEmpty()) { |
| | | return R.ok("明细参数不能为空!!"); |
| | | throw new CoolException("明细参数不能为空!!"); |
| | | } |
| | | if (!this.updateById(orders)) { |
| | | throw new CoolException("主单修改失败!!"); |
| | | } |
| | | |
| | | svaeOrUpdateOrderItem(params, loginUserId); |
| | |
| | | } |
| | | |
| | | PurchaseItem service = purchaseItemService.getById(item.getId()); |
| | | Double qty = Math.round((service.getQty() + item.getAnfme()) * 10000) / 10000.0; |
| | | Double qty = Math.round((service.getQty() + item.getAnfme()) * 1000000) / 1000000.0; |
| | | if (qty.compareTo(service.getAnfme()) > 0) { |
| | | throw new CoolException("新建单据数量不能大于计划数量!!"); |
| | | } |
| | |
| | | throw new CoolException("单据不存在!!"); |
| | | } |
| | | |
| | | Double toQty = Math.round((purchaseItem.getQty() + item.getAnfme()) * 10000) / 10000.0; |
| | | Double toQty = Math.round((purchaseItem.getQty() + item.getAnfme()) * 1000000) / 1000000.0; |
| | | purchaseItem.setQty(toQty); |
| | | if (!purchaseItemService.updateById(purchaseItem)) { |
| | | throw new CoolException("PO单明细修改失败!!"); |
| | |
| | | throw new CoolException(("Asn单据明细保存失败!!")); |
| | | } |
| | | //任务执行完成,修改已完成数量和PO单执行状态 |
| | | Double qty = Math.round((sum + purchase.getQty()) * 10000) / 10000.0; |
| | | Double qty = Math.round((sum + purchase.getQty()) * 1000000) / 1000000.0; |
| | | purchase.setQty(qty) |
| | | .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val); |
| | | |
| | |
| | | list.forEach(item -> { |
| | | PurchaseItem purchaseItem = purchaseItemService.getById(item.getPoDetlId()); |
| | | if (!Objects.isNull(purchaseItem)) { |
| | | Double minusQty = Math.round((purchaseItem.getQty() - item.getAnfme()) * 10000) / 10000.0; |
| | | Double minusQty = Math.round((purchaseItem.getQty() - item.getAnfme()) * 1000000) / 1000000.0; |
| | | purchaseItem.setQty(minusQty); |
| | | if (!purchaseItemService.updateById(purchaseItem)) { |
| | | throw new CoolException("PO单明细更新失败!!"); |
| | |
| | | Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>() |
| | | .eq(Purchase::getCode, list.stream().findFirst().get().getPoCode())); |
| | | if (!Objects.isNull(purchase)) { |
| | | Double qty = Math.round((purchase.getQty() - sum) * 10000) / 10000.0; |
| | | Double qty = Math.round((purchase.getQty() - sum) * 1000000) / 1000000.0; |
| | | purchase.setQty(qty) |
| | | .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val); |
| | | |