liujie
5 天以前 c09cfe948106d09c6fa052e990dfd44d39ddc1eb
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -396,9 +396,9 @@
//                        List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getWarehousingId, tErpSupplierWarehousing.getId()));
//                        int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum();
                        String goodsId = tErpSupplierWarehousing.getGoodsId();
                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
//                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                        int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
                        BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
                        BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(new BigDecimal(count));
                        add = add.add(multiply);
                    }else {
                        // 盘亏 查出库
@@ -408,9 +408,9 @@
                        for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
                            TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierOutboundGood.getWarehousingId());
                            String goodsId = tErpSupplierWarehousing.getGoodsId();
                            TErpGoods goods = erpGoodsMapper.selectById(goodsId);
//                            TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                            int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
                            BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
                            BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(new BigDecimal(count));
                            add = add.add(multiply);
                        }
//                        int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
@@ -483,11 +483,11 @@
                        inventoryDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                        List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber()));
                        List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getId, tErpSupplierOutboundGoods2.getWarehousingBatchId()));
                        int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum();
                        List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpSupplierWarehousingBatch::getId).collect(Collectors.toList());
                        if(!collect.isEmpty()){
                            List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods1 = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, collect));
                            List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods1 = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().in(TErpSupplierOutboundGoods::getWarehousingBatchId, collect));
                            int sum1 = tErpSupplierOutboundGoods1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
                            sum = sum-sum1;
                        }
@@ -554,22 +554,25 @@
            tErpSupplierOutboundGoods1.setTotalPrice(multiply);
            arrayList.add(tErpSupplierOutboundGoods1);
            add  = add.add(multiply);
            TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
            tErpSupplierOutbound.setOutboundType(dto.getOutboundType());
            tErpSupplierOutbound.setOutboundReason(dto.getOutboundReason());
            tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
            tErpSupplierOutbound.setSupplierId(supplierClinicId);
            tErpSupplierOutbound.setTotalMoney(add);
            String s = DateUtils.dateTimeNow();
            tErpSupplierOutbound.setOutboundNumber("G" + s);
            tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing.getGoodsId());
            erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
            for (TErpSupplierOutboundGoods tErpSupplierOutboundGoods2 : arrayList) {
                tErpSupplierOutboundGoods2.setOutboundId(tErpSupplierOutbound.getId());
                erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods2);
            }
        }
        TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
        tErpSupplierOutbound.setOutboundType(dto.getOutboundType());
        tErpSupplierOutbound.setOutboundReason(dto.getOutboundReason());
        tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
        tErpSupplierOutbound.setSupplierId(supplierClinicId);
        tErpSupplierOutbound.setTotalMoney(add);
        String s = DateUtils.dateTimeNow();
        tErpSupplierOutbound.setOutboundNumber("G" + s);
        erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
        for (TErpSupplierOutboundGoods tErpSupplierOutboundGoods : arrayList) {
            tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
            erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
        }
    }