From 718ded0f5f8dd6f1da43b9de2ff20ddc12714007 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 19 九月 2025 18:47:17 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/haizhentong

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
index 646aef0..b51fd6c 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -21,7 +21,9 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -145,8 +147,12 @@
                     .last("LIMIT 1"));
             supplierClinicId =crmClinic.getId();
         }
+
+        // 当前时间一个月后
+        Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1);
+
         PageInfo<TErpGoodsInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
-        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user,supplierClinicId);
+        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsPageList(query, pageInfo, user,supplierClinicId,endDate);
         if (list.isEmpty()) {
             return pageInfo;
         }
@@ -167,6 +173,49 @@
         }
         pageInfo.setRecords(list);
         return pageInfo;
+    }
+    @Override
+    public List<TErpGoodsInventoryVO> pageInventoryGoodsList(String warehouseId, SysUser user) {
+        Integer roleType = user.getRoleType();
+        String supplierClinicId = null;
+        if(roleType == 4){
+            // 供应商
+            TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class)
+                    .eq(TCrmSupplier::getUserId, user.getUserId())
+                    .last("LIMIT 1"));
+            supplierClinicId =crmSupplier.getId();
+        }
+        if(roleType == 5){
+            // 诊所
+            TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class)
+                    .eq(TCrmClinic::getUserId, user.getUserId())
+                    .last("LIMIT 1"));
+            supplierClinicId =crmClinic.getId();
+        }
+
+        // 当前时间一个月后
+        Date endDate = DateUtils.addMonths(DateUtils.getNowDate(), 1);
+
+        List<TErpGoodsInventoryVO> list = this.baseMapper.pageInventoryGoodsList(warehouseId, user,supplierClinicId,endDate);
+        if (list.isEmpty()) {
+            return list;
+        }
+        List<String> typeIds = list.stream().map(TErpGoodsInventoryVO::getTypeId).collect(Collectors.toList());
+        if (!typeIds.isEmpty()) {
+            List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
+            for (TErpGoodsInventoryVO tErpGoodsVO : list) {
+                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
+                tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName());
+            }
+        }
+        List<String> packingUnitId = list.stream().map(TErpGoodsInventoryVO::getPackingUnitId).collect(Collectors.toList());
+        if (!packingUnitId.isEmpty()) {
+            List<TErpGoodsUnit> tErpGoodsUnits = erpGoodsUnitMapper.selectBatchIds(packingUnitId);
+            for (TErpGoodsInventoryVO tErpGoodsVO : list) {
+                tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoodsVO.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoodsVO.setPackingUnitName(t.getUnitName()));
+            }
+        }
+        return list;
     }
 
     @Override
@@ -246,18 +295,16 @@
                 TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                 tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                 tErpSupplierOutbound.setSupplierId(supplierClinicId);
-                tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing1.getGoodsId());
                 tErpSupplierOutbound.setOutboundType(6);
                 tErpSupplierOutbound.setOutboundNumber("G" + s);
                 int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
                 tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
-                tErpSupplierOutbound.setGoodsId(erpGoods.getId());
                 erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
 
 
                 TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
                 tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
-                tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing.getId());
+                tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
                 tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                 tErpSupplierOutboundGoods.setOutboundCount(count);
                 tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));

--
Gitblit v1.7.1