From 0da945da9f19f45d849fe8b14dc06bb59c5e4283 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 22 五月 2026 14:36:24 +0800
Subject: [PATCH] feat(purchase): 完善采购报表及增值税比对功能

---
 src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java |   76 ++++++++++++++++++++++----------------
 1 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java
index e9a586f..911c808 100644
--- a/src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java
@@ -3,11 +3,17 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.account.dto.DeviceTypeDetail;
-import com.ruoyi.account.dto.DeviceTypeDistributionVO;
-import com.ruoyi.account.mapper.BorrowInfoMapper;
-import com.ruoyi.account.pojo.BorrowInfo;
+import com.ruoyi.account.bean.dto.AccountReportDto;
+import com.ruoyi.account.bean.dto.DeviceTypeDetail;
+import com.ruoyi.account.bean.dto.DeviceTypeDistributionVO;
+import com.ruoyi.account.bean.vo.AccountReportVo;
+import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper;
+import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper;
+import com.ruoyi.account.pojo.purchase.AccountPurchasePayment;
+import com.ruoyi.account.pojo.sales.AccountSalesCollection;
+import com.ruoyi.account.service.AccountingService;
 import com.ruoyi.device.mapper.DeviceLedgerMapper;
 import com.ruoyi.device.pojo.DeviceLedger;
 import com.ruoyi.framework.web.domain.AjaxResult;
@@ -17,10 +23,8 @@
 import com.ruoyi.procurementrecord.pojo.CustomStorage;
 import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut;
 import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
-import com.ruoyi.procurementrecord.service.impl.ProcurementRecordOutServiceImpl;
-import com.ruoyi.procurementrecord.service.impl.ProcurementRecordServiceImpl;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -36,23 +40,18 @@
  */
 @Service
 @Slf4j
-public class AccountingServiceImpl {
+@RequiredArgsConstructor
+public class AccountingServiceImpl implements AccountingService {
 
-    @Autowired
-    private DeviceLedgerMapper deviceLedgerMapper;
+    private final DeviceLedgerMapper deviceLedgerMapper;
+    private final CustomStorageMapper customStorageMapper;
+    private final ProcurementRecordMapper procurementRecordMapper;
+    private final ProcurementRecordOutMapper procurementRecordOutMapper;
+    private final AccountSalesCollectionMapper accountSalesCollectionMapper;
+    private final AccountPurchasePaymentMapper accountPurchasePaymentMapper;
 
-    @Autowired
-    private BorrowInfoMapper borrowInfoMapper;
 
-    @Autowired
-    private CustomStorageMapper customStorageMapper;
-
-    @Autowired
-    private ProcurementRecordMapper procurementRecordMapper;
-
-    @Autowired
-    private ProcurementRecordOutMapper procurementRecordOutMapper;
-
+    @Override
     public AjaxResult total(Integer year) {
         Map<String,Object> map = new HashMap<>();
         map.put("deprAmount",0); // 鎶樻棫閲戦
@@ -85,17 +84,8 @@
             map.put("netValue",reduce.subtract(total));
         }
         // 璐熷��
-        LambdaQueryWrapper<BorrowInfo> borrowInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        borrowInfoLambdaQueryWrapper.like(BorrowInfo::getCreateTime,year)
-                .eq(BorrowInfo::getStatus,1);
-        List<BorrowInfo> borrowInfos = borrowInfoMapper.selectList(borrowInfoLambdaQueryWrapper);
-        if(CollectionUtils.isNotEmpty(borrowInfos)){
-            BigDecimal reduce = borrowInfos.stream()
-                    .map(BorrowInfo::getBorrowAmount)
-                    .filter(Objects::nonNull)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add);
-            map.put("debt",reduce);
-        }
+        map.put("debt",BigDecimal.ZERO);
+
         // 搴撳瓨璧勪骇
         LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>();
         procurementRecordStorageLambdaQueryWrapper.like(ProcurementRecordStorage::getCreateTime,year);
@@ -255,6 +245,7 @@
         return totalDepreciation.setScale(2, BigDecimal.ROUND_HALF_UP);
     }
 
+    @Override
     public AjaxResult deviceTypeDistribution(Integer year) {
         // 2. 缁勮杩斿洖VO
        DeviceTypeDistributionVO vo = new DeviceTypeDistributionVO();
@@ -278,6 +269,7 @@
         return AjaxResult.success(vo);
     }
 
+    @Override
     public AjaxResult calculateDepreciation(Page page, Integer year) {
         LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
         deviceLedgerLambdaQueryWrapper.like(DeviceLedger::getCreateTime,year)
@@ -289,4 +281,24 @@
         }
         return AjaxResult.success(deviceLedgerIPage);
     }
+
+    @Override
+    public AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) {
+        AccountReportVo accountReportVo = new AccountReportVo();
+        //鎬昏惀鏀�=鏀舵鍗曟�婚噾棰�
+        //鎬绘敹鍏ョ瑪鏁�=鏀舵鍗曟�荤瑪鏁�
+        List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(Wrappers.<AccountSalesCollection>lambdaQuery()
+                .between(AccountSalesCollection::getCollectionDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd()));
+        accountReportVo.setTotalIncome(accountSalesCollections.stream().map(AccountSalesCollection::getCollectionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+        accountReportVo.setIncomeNumber(accountSalesCollections.size());
+        //鎬绘敮鍑�=浠樻鍗曟�婚噾棰�
+        //鎬绘敮鍑虹瑪鏁�=浠樻鍗曟�荤瑪鏁�
+        List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery()
+                .between(AccountPurchasePayment::getPaymentDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd()));
+        accountReportVo.setTotalExpense(accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+        accountReportVo.setExpenseNumber(accountPurchasePayments.size());
+        //鍑�鍒╂鼎=鎬昏惀鏀�-鎬绘敮鍑�
+        accountReportVo.setNetRevenue(accountReportVo.getTotalIncome().subtract(accountReportVo.getTotalExpense()));
+        return accountReportVo;
+    }
 }

--
Gitblit v1.9.3