skyouc
4 小时以前 5b79201484ea59ae2dfc2590b645ccac48a81947
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
@@ -290,7 +290,7 @@
            }
            PurchaseItem service = purchaseItemService.getById(item.getId());
            Double qty = service.getQty() + item.getAnfme();
            Double qty = Math.round((service.getQty() + item.getAnfme()) * 10000) / 10000.0;
            if (qty.compareTo(service.getAnfme()) > 0) {
                throw new CoolException("新建单据数量不能大于计划数量!!");
            }
@@ -316,7 +316,9 @@
            if (Objects.isNull(purchaseItem)) {
                throw new CoolException("单据不存在!!");
            }
            purchaseItem.setQty(purchaseItem.getQty() +  item.getAnfme());
            Double toQty = Math.round((purchaseItem.getQty() + item.getAnfme()) * 10000) / 10000.0;
            purchaseItem.setQty(toQty);
            if (!purchaseItemService.updateById(purchaseItem)) {
                throw new CoolException("PO单明细修改失败!!");
            }
@@ -328,7 +330,8 @@
            throw new CoolException(("Asn单据明细保存失败!!"));
        }
        //任务执行完成,修改已完成数量和PO单执行状态
        purchase.setQty(sum + purchase.getQty())
        Double qty = Math.round((sum + purchase.getQty()) * 10000) / 10000.0;
        purchase.setQty(qty)
                .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val);
        if (!purchaseService.saveOrUpdate(purchase)) {
@@ -361,10 +364,11 @@
            list.forEach(item -> {
                PurchaseItem purchaseItem = purchaseItemService.getById(item.getPoDetlId());
                if (!Objects.isNull(purchaseItem)) {
                    purchaseItem.setQty(purchaseItem.getQty() - item.getAnfme());
                }
                if (!purchaseItemService.updateById(purchaseItem)) {
                    throw new CoolException("PO单明细更新失败!!");
                    Double minusQty = Math.round((purchaseItem.getQty() - item.getAnfme()) * 10000) / 10000.0;
                    purchaseItem.setQty(minusQty);
                    if (!purchaseItemService.updateById(purchaseItem)) {
                        throw new CoolException("PO单明细更新失败!!");
                    }
                }
            });
@@ -372,11 +376,14 @@
            Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>()
                    .eq(Purchase::getCode, list.stream().findFirst().get().getPoCode()));
            purchase.setQty(purchase.getQty() - sum)
                    .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val);
            if (!Objects.isNull(purchase)) {
                Double qty = Math.round((purchase.getQty() - sum) * 10000) / 10000.0;
                purchase.setQty(qty)
                        .setExceStatus(POExceStatus.PO_EXCE_STATUS_EXCE_ING.val);
            if (!purchaseService.updateById(purchase)) {
                throw new CoolException("PO单据更新失败!!");
                if (!purchaseService.updateById(purchase)) {
                    throw new CoolException("PO单据更新失败!!");
                }
            }
        }