From bd8deb0d389d7634eaa40d258c84605b92fbe43b Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期三, 17 十二月 2025 16:10:36 +0800
Subject: [PATCH] yys  仓储物流模块修改

---
 src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java |  101 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 78 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
index 151c186..ab73804 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -110,6 +110,8 @@
         procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
         procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
         procurementRecordStorageById.setUpdateTime(LocalDateTime.now());
+        procurementRecordStorageById.setUnitPrice(procurementDto.getUnitPrice());
+        procurementRecordStorageById.setTotalPrice(procurementDto.getTotalPrice());
         return procurementRecordMapper.updateById(procurementRecordStorageById);
     }
 
@@ -119,7 +121,8 @@
         procurementRecordMapper.deleteBatchIds(procurementRecordStorageById.stream().map(ProcurementRecordStorage::getId).collect(Collectors.toList()));
         // 鍒犻櫎鎵�鏈夊搴旂殑鍑哄簱璁板綍
         LambdaQueryWrapper<ProcurementRecordOut> procurementRecordOutLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        procurementRecordOutLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, procurementDto.getIds());
+        procurementRecordOutLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, procurementDto.getIds())
+                .eq(ProcurementRecordOut::getType,procurementDto.getType());
         List<ProcurementRecordOut> procurementRecordOuts = procurementRecordOutMapper.selectList(procurementRecordOutLambdaQueryWrapper);
         if(!CollectionUtils.isEmpty(procurementRecordOuts)){
             procurementRecordOutMapper.deleteBatchIds(procurementRecordOuts.stream().map(ProcurementRecordOut::getId).collect(Collectors.toList()));
@@ -192,15 +195,28 @@
         if(salesLedgerProduct == null){
             throw new RuntimeException("閿�鍞彴璐︿骇鍝佷笉瀛樺湪");
         }
+        // 鏍规嵁澶х被锛岃鏍兼煡璇㈡墍鏈変骇鍝乮d
+        LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getProductCategory, salesLedgerProduct.getProductCategory())
+                .eq(SalesLedgerProduct::getSpecificationModel, salesLedgerProduct.getSpecificationModel())
+                .eq(SalesLedgerProduct::getType, 1);
+        List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(salesLedgerProductLambdaQueryWrapper);
+        if(CollectionUtils.isEmpty(salesLedgerProducts)){
+            throw new RuntimeException("娌℃湁鎵惧埌瀵瑰簲鐨勪骇鍝�");
+        }
         salesLedgerProduct.setMinStock(procurementDto.getMinStock());
         salesLedgerProductMapper.updateById(salesLedgerProduct);
-        ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
-        procurementRecordStorageById.setCreateBy(sysUser.getNickName());
-        procurementRecordStorageById.setCreateUser(sysUser.getUserId());
-        procurementRecordStorageById.setUpdateTime(LocalDateTime.parse(entryDateStr,df));
-        procurementRecordStorageById.setUpdateUser(loginUser.getUserId());
-        procurementRecordStorageById.setCreateTime(LocalDateTime.parse(createTimeStr,df));
-        procurementRecordMapper.updateById(procurementRecordStorageById);
+        LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        procurementRecordStorageLambdaQueryWrapper.in(ProcurementRecordStorage::getSalesLedgerProductId, salesLedgerProducts.stream().map(SalesLedgerProduct::getId).collect(Collectors.toList()));
+        ProcurementRecordStorage procurementRecordStorage = ProcurementRecordStorage.builder().build();
+        procurementRecordStorage.setUnitPrice(procurementDto.getUnitPrice());
+        procurementRecordStorage.setTotalPrice(procurementDto.getTotalPrice());
+        procurementRecordStorage.setCreateBy(sysUser.getNickName());
+        procurementRecordStorage.setCreateUser(sysUser.getUserId());
+        procurementRecordStorage.setUpdateTime(LocalDateTime.parse(entryDateStr,df));
+        procurementRecordStorage.setUpdateUser(loginUser.getUserId());
+        procurementRecordStorage.setCreateTime(LocalDateTime.parse(createTimeStr,df));
+        procurementRecordMapper.update(procurementRecordStorage,procurementRecordStorageLambdaQueryWrapper);
         return 0;
     }
 
@@ -467,8 +483,11 @@
             if(customStorage.getTimeStr() != null){
                 customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getTimeStr());
             }
+            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
+                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
+            }
         }
-        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getCreateTime);
+        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
         IPage<CustomStorage> procurementPageDtoIPage = customStorageMapper.selectPage(page, customStorageLambdaQueryWrapper);
         procurementPageDtoIPage.getRecords().forEach(item -> item.setInboundNum0(item.getInboundNum()));
         List<CustomStorage> procurementPageDtos = procurementPageDtoIPage.getRecords();
@@ -534,6 +553,7 @@
             // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
             if(CollectionUtils.isEmpty(collect1)){
                 dto.setInboundNum0(dto.getInboundNum());
+                dto.setTotalInboundNum(BigDecimal.ZERO);
                 continue;
             }
 
@@ -545,25 +565,33 @@
             dto.setTotalInboundNum(totalInboundNum);
             // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
             dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
+            // 搴撳瓨浠峰��
+            if(dto.getUnitPrice() != null){
+                dto.setTotalPrice(dto.getTotalInboundNum().multiply(dto.getUnitPrice()));
+            }
         }
         return procurementPageDtoCopyIPage;
     }
 
     @Override
     public IPage<CustomStorage> listPageCopyByCustom(Page page, CustomStorage customStorage) {
-        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        customStorageLambdaQueryWrapper.groupBy(CustomStorage::getProductCategory, CustomStorage::getSpecificationModel);
-        if(customStorage != null){
-            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
-                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
-            }
-            // 绛涢�夊叆搴撴椂闂�
-            if(customStorage.getInboundDate() != null){
-                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getInboundDate());
-            }
-        }
-        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getCreateTime);
-        IPage<CustomStorage> pageList = customStorageMapper.selectPage(page, customStorageLambdaQueryWrapper);
+//        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        customStorageLambdaQueryWrapper.groupBy(CustomStorage::getProductCategory, CustomStorage::getSpecificationModel,CustomStorage::getTaxInclusiveUnitPrice);
+//        if(customStorage != null){
+//            if(!StringUtils.isEmpty(customStorage.getSupplierName())){
+//                customStorageLambdaQueryWrapper.like(CustomStorage::getSupplierName, customStorage.getSupplierName());
+//            }
+//            // 绛涢�夊叆搴撴椂闂�
+//            if(customStorage.getInboundDate() != null){
+//                customStorageLambdaQueryWrapper.eq(CustomStorage::getInboundDate, customStorage.getInboundDate());
+//            }
+//            if(!StringUtils.isEmpty(customStorage.getProductCategory())){
+//                customStorageLambdaQueryWrapper.like(CustomStorage::getProductCategory, customStorage.getProductCategory());
+//            }
+//        }
+//        customStorageLambdaQueryWrapper.orderByDesc(CustomStorage::getInboundDate);
+        IPage<CustomStorage> pageList = customStorageMapper.listPageCopyByCustom(page, customStorage);
+
         List<CustomStorage> procurementPageDtoCopyList = pageList.getRecords();
         // 璁$畻寰呭叆搴撴暟閲�
         // 鏌ヨ閲囪喘璁板綍宸插叆搴撴暟閲�
@@ -587,6 +615,7 @@
             // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
             if(CollectionUtils.isEmpty(collect1)){
                 dto.setInboundNum0(dto.getInboundNum());
+                dto.setTotalInboundNum(BigDecimal.ZERO);
                 continue;
             }
 
@@ -598,6 +627,10 @@
             dto.setTotalInboundNum(totalInboundNum);
             // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
             dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
+            // 搴撳瓨浠峰��
+            if(dto.getTaxInclusiveUnitPrice() != null){
+                dto.setTaxInclusiveTotalPrice(dto.getInboundNum0().multiply(dto.getTaxInclusiveUnitPrice()));
+            }
         }
         pageList.setRecords(procurementPageDtoCopyList);
         return pageList;
@@ -611,6 +644,21 @@
     @Override
     public AjaxResult deleteCustom(List<Long> ids) {
         return AjaxResult.success(customStorageMapper.deleteBatchIds(ids));
+    }
+
+    @Override
+    public int updateManagementByCustom(ProcurementManagementUpdateDto procurementDto) {
+        CustomStorage customStorage = customStorageMapper.selectById(procurementDto.getId());
+        if(customStorage == null){
+            throw new RuntimeException("鏉愭枡搴撳瓨涓嶅瓨鍦�");
+        }
+        LambdaQueryWrapper<CustomStorage> customStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        customStorageLambdaQueryWrapper.eq(CustomStorage::getProductCategory, customStorage.getProductCategory())
+                .eq(CustomStorage::getSpecificationModel, customStorage.getSpecificationModel());
+        CustomStorage one = new CustomStorage();
+        one.setTaxInclusiveUnitPrice(procurementDto.getTaxInclusiveUnitPrice());
+        one.setTaxInclusiveTotalPrice(procurementDto.getTaxInclusiveTotalPrice());
+        return customStorageMapper.update(one,customStorageLambdaQueryWrapper);
     }
 
     @Override
@@ -630,6 +678,8 @@
                     .inboundNum(detail.getInboundQuantity())
                     .type(procurementDto.getType())
                     .warnNum(detail.getWarnNum())
+                    .unitPrice(detail.getUnitPrice())
+                    .totalPrice(detail.getInboundQuantity().multiply(detail.getUnitPrice()))
                     .createTime(LocalDateTime.now())
                     .createUser(loginUser.getUserId())
                     .updateTime(LocalDateTime.now())
@@ -709,12 +759,13 @@
         for (ProcurementPageDtoCopy dto : procurementPageDtoCopyList) {
             // 鏍规嵁閲囪喘鍙拌处ID绛涢�夊搴旂殑鍑哄簱璁板綍
             List<ProcurementRecordOut> collect1 = procurementRecords.stream()
-                    .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()))
+                    .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId()) && ProcurementRecordOut.getType().equals(1))
                     .collect(Collectors.toList());
 
             // 濡傛灉娌℃湁鐩稿叧鐨勫嚭搴撹褰曪紝璺宠繃璇ユ潯鏁版嵁
             if(CollectionUtils.isEmpty(collect1)){
                 dto.setInboundNum0(dto.getInboundNum());
+                dto.setTotalInboundNum(BigDecimal.ZERO);
                 continue;
             }
 
@@ -726,6 +777,10 @@
             dto.setTotalInboundNum(totalInboundNum);
             // 寰呭嚭搴撴暟閲� = 鎬绘暟閲� - 宸插嚭搴撴暟閲�
             dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum));
+            // 搴撳瓨浠峰��
+            if(dto.getUnitPrice() != null){
+                dto.setTotalPrice(dto.getInboundNum0().multiply(dto.getUnitPrice()));
+            }
         }
         return procurementPageDtoCopyIPage;
     }

--
Gitblit v1.9.3