From 294bf52b9e5d844efd17901082d4a1a195572037 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期日, 28 九月 2025 19:03:29 +0800
Subject: [PATCH] 诊所erp

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
index 254a3e1..d7da666 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -464,6 +464,41 @@
                     inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
                     inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
                     inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
+                }else {
+                    TErpSupplierOutbound tErpSupplierOutbound = erpSupplierOutboundMapper.selectById(tErpSupplierInventoryGood.getWarehousingId());
+                    List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getOutboundId, tErpSupplierOutbound.getId()));
+                    for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
+                        String warehousingId = tErpSupplierOutboundGood.getWarehousingId();
+                        TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(warehousingId);
+                        String goodsId = tErpSupplierWarehousing.getGoodsId();
+                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
+                        inventoryDetailVo.setGoodsName(goods.getGoodsName());
+                        TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
+                        inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
+                        inventoryDetailVo.setWarehouseNo(tErpSupplierWarehousing.getWarehouseNo());
+
+                        TErpSupplierOutboundGoods tErpSupplierOutboundGoods2 = erpSupplierOutboundGoodsMapper.selectById(tErpSupplierInventoryGood.getWarehousingBatchId());
+
+                        TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(tErpSupplierOutboundGoods2.getWarehousingBatchId());
+                        inventoryDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
+
+
+                        List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber()));
+                        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));
+                            int sum1 = tErpSupplierOutboundGoods1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
+                            sum = sum-sum1;
+                        }
+
+                        // sum = 剩余库存
+                        inventoryDetailVo.setNowCount(sum);
+                        inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
+                        inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
+                        inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
+                    }
+
                 }
                 inventoryDetailVos.add(inventoryDetailVo);
 

--
Gitblit v1.7.1