From fd7446cbdb4f852cd0d9098aa3f103fd15edbfbe Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期日, 04 一月 2026 14:28:52 +0800
Subject: [PATCH] 财务管理的存货核算获取数据接口,统计数据类

---
 src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java |   72 ++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 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 358f20b..6e103b4 100644
--- a/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -16,6 +16,7 @@
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -102,6 +103,7 @@
     public int updatePro(ProcurementUpdateDto procurementDto) {
         ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
         procurementRecordStorageById.setInboundNum(procurementDto.getQuantityStock());
+        procurementRecordStorageById.setWarnNum(procurementDto.getWarnNum());
         procurementRecordStorageById.setUpdateUser(SecurityUtils.getLoginUser().getUserId());
         procurementRecordStorageById.setUpdateTime(LocalDateTime.now());
         return procurementRecordMapper.updateById(procurementRecordStorageById);
@@ -176,6 +178,12 @@
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         String entryDateStr = procurementDto.getEntryDate() + " 00:00:00";
         String createTimeStr = procurementDto.getCreateTime() + " 00:00:00";
+        SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(procurementDto.getSalesLedgerProductId());
+        if(salesLedgerProduct == null){
+            throw new RuntimeException("閿�鍞彴璐︿骇鍝佷笉瀛樺湪");
+        }
+        salesLedgerProduct.setMinStock(procurementDto.getMinStock());
+        salesLedgerProductMapper.updateById(salesLedgerProduct);
         ProcurementRecordStorage procurementRecordStorageById = getProcurementRecordById(procurementDto.getId());
         procurementRecordStorageById.setCreateBy(sysUser.getNickName());
         procurementRecordStorageById.setCreateUser(sysUser.getUserId());
@@ -328,6 +336,69 @@
     }
 
     @Override
+    public InventoryInformationDto getReportList() {
+        InventoryInformationDto inventoryInformationDto = new InventoryInformationDto();
+        IPage<ProcurementPageDto> procurementPageDtoIPage = this.listPage(new Page<>(1, -1), new ProcurementPageDto());
+        if(CollectionUtils.isEmpty(procurementPageDtoIPage.getRecords())){
+            return inventoryInformationDto;
+        }
+        // 璁$畻鎬诲簱瀛樻暟閲�
+        inventoryInformationDto.setTotalInventoryCount(procurementPageDtoIPage.getRecords().stream()
+                .map(ProcurementPageDto::getInboundNum0)
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .intValue());
+        // 璁$畻鎬诲簱瀛橀噾棰�-ProcurementPageDto閲屾瘡涓璞$殑inboundNum0鍊煎拰taxInclusiveUnitPrice鐨勪箻绉紝涔嬪悗鐩稿姞寰楀埌鎬诲簱瀛橀噾棰�
+        BigDecimal totalInventoryValue = procurementPageDtoIPage.getRecords().stream()
+                // 杩囨护绌哄璞★紝閬垮厤NPE
+                .filter(Objects::nonNull)
+                // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+                .map(dto -> {
+                    // 鍏ュ簱鏁伴噺锛歯ull 鈫� 0
+                    BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO);
+                    // 鍚◣鍗曚环锛歯ull 鈫� 0
+                    BigDecimal taxInclusiveUnitPrice = Optional.ofNullable(dto.getTaxInclusiveUnitPrice()).orElse(BigDecimal.ZERO);
+                    // 璁$畻鍗曚釜瀵硅薄鐨勫簱瀛橀噾棰濓細鏁伴噺 脳 鍚◣鍗曚环
+                    return inboundNum0.multiply(taxInclusiveUnitPrice);
+                })
+                // 鎵�鏈夊崟涓噾棰濇眰鍜岋紝鍒濆鍊间负0
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        // 璁剧疆鎬诲簱瀛橀噾棰�
+        inventoryInformationDto.setTotalInventoryValue(totalInventoryValue);
+        // 璁$畻搴撳瓨鍙樺姩鏁伴噺-ProcurementPageDto閲屾瘡涓璞$殑inboundNum鍊煎拰inboundNum0鍊肩殑宸�硷紝涔嬪悗鐩稿姞寰楀埌搴撳瓨鍙樺姩鏁伴噺
+        inventoryInformationDto.setInventoryChangeCount(procurementPageDtoIPage.getRecords().stream()
+                // 杩囨护绌哄璞★紝閬垮厤NPE
+                .filter(Objects::nonNull)
+                // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+                .map(dto -> {
+                    // 鍏ュ簱鏁伴噺锛歯ull 鈫� 0
+                    BigDecimal inboundNum = Optional.ofNullable(dto.getInboundNum()).orElse(BigDecimal.ZERO);
+                    // 寰呭嚭搴撴暟閲忥細null 鈫� 0
+                    BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO);
+                    // 璁$畻鍗曚釜瀵硅薄鐨勫簱瀛樺彉鍔ㄦ暟閲忥細鏁伴噺 - 寰呭嚭搴撴暟閲�
+                    return inboundNum.subtract(inboundNum0);
+                })
+                // 鎵�鏈夊崟涓彉鍔ㄦ暟閲忔眰鍜岋紝鍒濆鍊间负0
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .intValue());
+        // 璁$畻搴撳瓨鍙樺姩閲戦ProcurementPageDto閲屾瘡涓璞$殑taxInclusiveTotalPrice鍊肩殑鍜�
+        BigDecimal inventoryChangeValue = procurementPageDtoIPage.getRecords().stream()
+                // 杩囨护绌哄璞★紝閬垮厤NPE
+                .filter(Objects::nonNull)
+                // 澶勭悊姣忎釜瀵硅薄鐨勭┖鍊硷細null杞负0
+                .map(dto -> {
+                    // 鍚◣鎬讳环锛歯ull 鈫� 0
+                    BigDecimal taxInclusiveTotalPrice = Optional.ofNullable(dto.getTaxInclusiveTotalPrice()).orElse(BigDecimal.ZERO);
+                    // 璁$畻鍗曚釜瀵硅薄鐨勫叆搴撳簱瀛橀噾棰濓細鍚◣鎬讳环
+                    return taxInclusiveTotalPrice;
+                })
+                // 鎵�鏈夊崟涓彉鍔ㄩ噾棰濇眰鍜岋紝鍒濆鍊间负0
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        // 璁剧疆搴撳瓨鍙樺姩閲戦
+        inventoryInformationDto.setInventoryChangeValue(inventoryChangeValue.subtract(totalInventoryValue));
+        return inventoryInformationDto;
+    }
+
+    @Override
     public int add(ProcurementAddDto procurementDto) {
         LoginUser loginUser = SecurityUtils.getLoginUser();
         // 鎵归噺鏂板
@@ -341,6 +412,7 @@
                     .salesLedgerProductId(detail.getId())
                     .inboundBatches(aLong.equals(0L) ? "绗�1鎵规" : "绗�"+ (aLong + 1) + "鎵规")
                     .inboundNum(detail.getInboundQuantity())
+                    .warnNum(detail.getWarnNum())
                     .createTime(LocalDateTime.now())
                     .createUser(loginUser.getUserId())
                     .updateTime(LocalDateTime.now())

--
Gitblit v1.9.3