skyouc
4 小时以前 5b79201484ea59ae2dfc2590b645ccac48a81947
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/AsnOrderServiceImpl.java
@@ -254,6 +254,7 @@
     * @version 1.0
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R createByPo(Map<String, Object> params) {
        Long purchaseId = Long.parseLong(params.get("purchaseId").toString());
        List<PurchaseItem> itemList = JSONArray.parseArray(JSONObject.toJSONString(params.get("items")), PurchaseItem.class);
@@ -287,6 +288,12 @@
            if (StringUtils.isBlank(trackCode)) {
                throw new CoolException("单据跟踪码生成失败:请检查「sys_asn_mantr_label」是否配置完成!!");
            }
            PurchaseItem service = purchaseItemService.getById(item.getId());
            Double qty = Math.round((service.getQty() + item.getAnfme()) * 10000) / 10000.0;
            if (qty.compareTo(service.getAnfme()) > 0) {
                throw new CoolException("新建单据数量不能大于计划数量!!");
            }
            orderItem.setAnfme(item.getAnfme())
                    .setAsnId(order.getId())
                    .setSplrName(item.getSplrName())
@@ -309,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单明细修改失败!!");
            }
@@ -321,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)) {
@@ -354,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单明细更新失败!!");
                    }
                }
            });
@@ -365,17 +376,15 @@
            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单据更新失败!!");
                }
            }
        }
        if (!asnOrderItemService.remove(new LambdaQueryWrapper<AsnOrderItem>()
                .in(AsnOrderItem::getAsnId, ids))) {
            throw new CoolException("Details Delete Fail");
        }
        if (!this.remove(new LambdaQueryWrapper<AsnOrder>()
@@ -384,6 +393,12 @@
            throw new CoolException("任务中单据不可删除!!");
        }
        if (!asnOrderItemService.remove(new LambdaQueryWrapper<AsnOrderItem>()
                .in(AsnOrderItem::getAsnId, ids))) {
//            throw new CoolException("Details Delete Fail");
        }
        return R.ok("操作成功!!");
    }