From 09892cb8b391914c7c78a61c79503456d9958137 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 21 十月 2025 14:31:57 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java |   91 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 87 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 4da89fe..28a5f71 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
@@ -52,31 +52,37 @@
 
     @Resource
     private TErpSupplierInventoryMapper erpSupplierInventoryMapper;
+
     @Resource
     private TErpClinicInventoryMapper erpClinicInventoryMapper;
 
     @Resource
     private TErpSupplierInventoryGoodsMapper erpSupplierInventoryGoodsMapper;
+
     @Resource
     private TErpClinicInventoryGoodsMapper erpClinicInventoryGoodsMapper;
 
     @Resource
     private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper;
+
     @Resource
     private TErpClinicWarehousingMapper erpClinicWarehousingMapper;
 
     @Resource
     private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper;
+
     @Resource
     private TErpClinicWarehousingBatchMapper erpClinicWarehousingBatchMapper;
 
     @Resource
     private TErpSupplierOutboundMapper erpSupplierOutboundMapper;
+
     @Resource
     private TErpClinicOutboundMapper erpClinicOutboundMapper;
 
     @Resource
     private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
+
     @Resource
     private TErpClinicOutboundGoodsMapper erpClinicOutboundGoodsMapper;
 
@@ -85,6 +91,10 @@
 
     @Resource
     private  TCrmSupplierMapper crmSupplierMapper;
+
+    @Resource
+    private TErpProcurementMapper erpProcurementMapper;
+
 
 
     @Override
@@ -188,6 +198,14 @@
     @Override
     public boolean isExit(String goodsIdCode, String quasiNumber,String id) {
         Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsSource,1).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getGoodsIdCode, goodsIdCode).or().eq(TErpGoods::getQuasiNumber, quasiNumber)));
+        if (size > 0) {
+            return true;
+        }
+        return false;
+    }
+    @Override
+    public boolean isExitOne(String goodsIdCode, String quasiNumber,String id) {
+        Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsSource,1).ne(id!=null,TErpGoods::getId, id).and(q -> q.eq(TErpGoods::getQuasiNumber, quasiNumber)));
         if (size > 0) {
             return true;
         }
@@ -401,6 +419,14 @@
                 tErpGoodsUnits.stream().filter(t -> t.getId().equals(tErpGoods.getPackingUnitId())).findFirst().ifPresent(t -> tErpGoods.setPackingUnitName(t.getUnitName()));
             }
         }
+
+        List<String> typeIds = records.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
+        if(!typeIds.isEmpty()){
+            List<TErpGoodsType> tErpGoodsTypes = erpGoodsTypeMapper.selectBatchIds(typeIds);
+            for (TErpGoods tErpGoods : records) {
+                tErpGoodsTypes.stream().filter(t -> t.getId().equals(tErpGoods.getTypeId())).findFirst().ifPresent(t -> tErpGoods.setTypeName(t.getTypeName()));
+            }
+        }
         page.setRecords( records);
         return page;
     }
@@ -412,6 +438,10 @@
         warehouseGoodsDetailVo.setCreateTime(tErpClinicWarehousing.getCreateTime());
         warehouseGoodsDetailVo.setCreateBy(tErpClinicWarehousing.getCreateBy());
         if(tErpClinicWarehousing.getType()==1){
+            TErpProcurement tErpProcurement = erpProcurementMapper.selectById(tErpClinicWarehousing.getProcurementId());
+            warehouseGoodsDetailVo.setInventoryNumber(tErpProcurement.getProcurementCode());
+        }
+        if(tErpClinicWarehousing.getType()==2){
             TErpClinicInventory tErpClinicInventory = erpClinicInventoryMapper.selectById(tErpClinicWarehousing.getInventoryId());
             warehouseGoodsDetailVo.setInventoryNumber(tErpClinicInventory.getInventoryNumber());
         }
@@ -420,9 +450,12 @@
         for (TErpClinicWarehousingBatch tErpClinicWarehousingBatch : tErpClinicWarehousingBatches) {
             String goodsId = tErpClinicWarehousingBatch.getGoodsId();
             TErpGoods tErpGoods = erpGoodsMapper.selectById(goodsId);
+            tErpClinicWarehousingBatch.setGoodsName(tErpGoods.getGoodsName());
             String packingUnitId = tErpGoods.getPackingUnitId();
             TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId);
-            tErpClinicWarehousingBatch.setUnitName(tErpGoodsUnit.getUnitName());
+            if(tErpGoodsUnit!=null){
+                tErpClinicWarehousingBatch.setUnitName(tErpGoodsUnit.getUnitName());
+            }
 
         }
 
@@ -560,6 +593,28 @@
                 String warehousingId1 = tErpSupplierWarehousingBatch1.getWarehousingId();
                 TErpSupplierWarehousing tErpSupplierWarehousing2 = erpSupplierWarehousingMapper.selectById(warehousingId1);
 
+                if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){
+                    TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
+                    tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
+                    tErpSupplierOutbound.setSupplierId(supplierClinicId);
+                    tErpSupplierOutbound.setOutboundType(1);
+                    tErpSupplierOutbound.setOutboundNumber("G" + s);
+                    int count = inventoryGoodsDto.getDamagedCount();
+                    tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
+                    tErpSupplierOutbound.setGoodsId(tErpSupplierWarehousing2.getGoodsId());
+                    erpSupplierOutboundMapper.insert(tErpSupplierOutbound);
+
+
+                    TErpSupplierOutboundGoods tErpSupplierOutboundGoods = new TErpSupplierOutboundGoods();
+                    tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
+                    tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
+                    tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
+                    tErpSupplierOutboundGoods.setOutboundCount(count);
+                    tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousing1.getUnitAmount().multiply(new BigDecimal(count)));
+                    erpSupplierOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
+                }
+
+
                 TErpSupplierOutbound tErpSupplierOutbound = new TErpSupplierOutbound();
                 tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
                 tErpSupplierOutbound.setSupplierId(supplierClinicId);
@@ -628,6 +683,8 @@
             TErpClinicWarehousing tErpSupplierWarehousing1 = erpClinicWarehousingMapper.selectById(warehousingId);
             TErpGoods erpGoods = this.getById(tErpSupplierWarehousingBatch.getGoodsId());
 
+
+
             // 盘点是盘亏盘盈   赢
             if (inventoryGoodsDto.getNum() < inventoryGoodsDto.getInventoryCount()) {
                 // 添加入库信息
@@ -636,12 +693,18 @@
 //                tErpSupplierWarehousing.setGoodsName(erpGoods.getGoodsName());
 //                tErpSupplierWarehousing.setPurchaseCount(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum());
 //                tErpSupplierWarehousing.setUnitAmount(erpGoods.getSalesAmount());
-                tErpSupplierWarehousing.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum())));
+                tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousingBatch.getUnitAmount().multiply(new BigDecimal(inventoryGoodsDto.getInventoryCount() - inventoryGoodsDto.getNum())));
                 // 当前年月日时分秒
                 String time = DateUtils.dateTimeNow();
                 tErpSupplierWarehousing.setWarehouseNo("G" + time);
                 tErpSupplierWarehousing.setType(2);
                 tErpSupplierWarehousing.setInventoryId(tErpSupplierInventory.getId());
+                if(erpGoods.getGoodsSource()==1){
+                    TCrmSupplier supplier = crmSupplierMapper.selectById(erpGoods.getSupplierClinicId());
+                    tErpSupplierWarehousing.setSupplierName(supplier.getSupplierName());
+                }else {
+                    tErpSupplierWarehousing.setSupplierName(erpGoods.getSupplierName());
+                }
                 erpClinicWarehousingMapper.insert(tErpSupplierWarehousing);
 
                 // 添加批次信息
@@ -673,13 +736,33 @@
             } else {
 
 
+                if(inventoryGoodsDto.getDamagedCount()!=null && inventoryGoodsDto.getDamagedCount()>0){
+                    TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound();
+//                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
+//                tErpSupplierOutbound.setSupplierId(supplierClinicId);
+                    tErpSupplierOutbound.setOutboundType(1);
+                    tErpSupplierOutbound.setOutboundNumber("G" + s);
+                    int count = inventoryGoodsDto.getDamagedCount();
+                    tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
+                    tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId());
+                    erpClinicOutboundMapper.insert(tErpSupplierOutbound);
+
+
+                    TErpClinicOutboundGoods tErpSupplierOutboundGoods = new TErpClinicOutboundGoods();
+                    tErpSupplierOutboundGoods.setOutboundId(tErpSupplierOutbound.getId());
+                    tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
+                    tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
+                    tErpSupplierOutboundGoods.setOutboundCount(count);
+                    tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
+                    erpClinicOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
+                }
                 TErpClinicOutbound tErpSupplierOutbound = new TErpClinicOutbound();
 //                tErpSupplierOutbound.setWarehouseId(dto.getWarehouseId());
 //                tErpSupplierOutbound.setSupplierId(supplierClinicId);
                 tErpSupplierOutbound.setOutboundType(6);
                 tErpSupplierOutbound.setOutboundNumber("G" + s);
                 int count = inventoryGoodsDto.getNum() - inventoryGoodsDto.getInventoryCount();
-                tErpSupplierOutbound.setTotalMoney(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
+                tErpSupplierOutbound.setTotalMoney(tErpSupplierWarehousingBatch.getSalesAmount().multiply(new BigDecimal(count)));
                 tErpSupplierOutbound.setInventoryId(tErpSupplierInventory.getId());
                 erpClinicOutboundMapper.insert(tErpSupplierOutbound);
 
@@ -689,7 +772,7 @@
                 tErpSupplierOutboundGoods.setWarehousingId(tErpSupplierWarehousing1.getId());
                 tErpSupplierOutboundGoods.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                 tErpSupplierOutboundGoods.setOutboundCount(count);
-                tErpSupplierOutboundGoods.setTotalPrice(erpGoods.getSalesAmount().multiply(new BigDecimal(count)));
+                tErpSupplierOutboundGoods.setTotalPrice(tErpSupplierWarehousingBatch.getSalesAmount().multiply(new BigDecimal(count)));
                 erpClinicOutboundGoodsMapper.insert(tErpSupplierOutboundGoods);
 
 

--
Gitblit v1.7.1