From 9e31a333ceb9e6a51d18c808eabffd8cebc8cb4e Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 五月 2026 11:35:49 +0800
Subject: [PATCH] refactor(core): 删除销售台账及相关代码中与发票和待付款金额关联的逻辑

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |  209 +++++++++------------------------------------------
 1 files changed, 39 insertions(+), 170 deletions(-)

diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index 395a414..a17c012 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -3,9 +3,8 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.ruoyi.account.mapper.AccountExpenseMapper;
-import com.ruoyi.account.mapper.AccountIncomeMapper;
-import com.ruoyi.account.pojo.AccountExpense;
+import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper;
+import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper;
 import com.ruoyi.approve.mapper.ApproveProcessMapper;
 import com.ruoyi.approve.pojo.ApproveProcess;
 import com.ruoyi.basic.mapper.CustomerMapper;
@@ -30,18 +29,14 @@
 import com.ruoyi.production.mapper.*;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
-import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
 import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
-import com.ruoyi.purchase.pojo.PaymentRegistration;
 import com.ruoyi.purchase.pojo.PurchaseLedger;
 import com.ruoyi.quality.mapper.QualityInspectMapper;
 import com.ruoyi.quality.mapper.QualityUnqualifiedMapper;
 import com.ruoyi.quality.pojo.QualityInspect;
 import com.ruoyi.quality.pojo.QualityUnqualified;
-import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
-import com.ruoyi.sales.pojo.ReceiptPayment;
 import com.ruoyi.sales.pojo.SalesLedger;
 import com.ruoyi.sales.pojo.SalesLedgerProduct;
 import com.ruoyi.staff.mapper.StaffOnJobMapper;
@@ -83,37 +78,36 @@
 
     private final ApproveProcessMapper approveProcessMapper;
 
-    private final ReceiptPaymentMapper receiptPaymentMapper;
-
-    private final PaymentRegistrationMapper paymentRegistrationMapper;
-
-    private  SysDeptMapper sysDeptMapper;
+    private final SysDeptMapper sysDeptMapper;
 
     private final NoticeMapper noticeMapper;
-    
+
     private final ProductionOrderMapper productionOrderMapper;
 
     private final ProductMapper productMapper;
-    
+
     private final StaffOnJobMapper staffOnJobMapper;
-    
+
     private final CustomerMapper customerMapper;
-    
+
     private final SupplierManageMapper supplierManageMapper;
-    
+
     private final HomeMapper homeMapper;
-    
+
     private final ProductionProductOutputMapper productionProductOutputMapper;
-    
+
     private final QualityInspectMapper qualityInspectMapper;
-    
+
     private final QualityUnqualifiedMapper qualityUnqualifiedMapper;
-    
+
     private final ProductionOperationTaskMapper productionOperationTaskMapper;
-    
-    private final AccountExpenseMapper accountExpenseMapper;
-    
-    private final AccountIncomeMapper accountIncomeMapper;
+
+    private final AccountPurchasePaymentMapper accountPurchasePaymentMapper;
+    private final AccountSalesCollectionMapper accountSalesCollectionMapper;
+
+    private final ProductionAccountMapper productionAccountMapper;
+
+    private final ProductionProductInputMapper productionProductInputMapper;
 
     @Override
     public HomeBusinessDto business() {
@@ -137,12 +131,8 @@
                             salesLedgers.stream().map(SalesLedger::getId).collect(Collectors.toList()));
             List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper
                     .selectList(salesLedgerProductMapperLambdaQueryWrapper);
-            // 鏈紑绁ㄩ噾棰�
-            BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount)
-                    .filter(Objects::nonNull)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add);
             homeBusinessDto.setMonthSaleMoney(contractAmount.setScale(2, RoundingMode.HALF_UP).toString());
-            homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal.setScale(2, RoundingMode.HALF_UP).toString());
+            homeBusinessDto.setMonthSaleHaveMoney(BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP).toString());
         }
         // 鍒涘缓LambdaQueryWrapper
         LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>();
@@ -165,14 +155,8 @@
                     .filter(Objects::nonNull)
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
 
-            //  寰呬粯娆炬�婚噾棰�
-            BigDecimal unReceiptPaymentAmount = salesLedgerProductsCopy.stream()
-                    .map(SalesLedgerProduct::getPendingTicketsTotal)
-                    .filter(Objects::nonNull)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add);
-
             homeBusinessDto.setMonthPurchaseMoney(receiveAmount.setScale(2, RoundingMode.HALF_UP).toString());
-            homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount.setScale(2, RoundingMode.HALF_UP).toString());
+            homeBusinessDto.setMonthPurchaseHaveMoney(BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP).toString());
         }
         // 缁熻搴撳瓨
         BigDecimal stockQuantityTotal = stockInventoryMapper.selectTotal();
@@ -410,6 +394,7 @@
      */
     @Override
     public StatisticsReceivablePayableDto statisticsReceivablePayable(Integer type) {
+        StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto();
         LocalDate today = LocalDate.now();
         LocalDate startDate = null;
         LocalDate endDate = null;
@@ -436,48 +421,14 @@
                 break;
         }
         // 搴旀敹
-        List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>()
-                // .ge(SalesLedger::getEntryDate, startDate)
-                // .lt(SalesLedger::getEntryDate, endDate)
-        );
-        // BigDecimal receivableMoney =
-        // salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO,
-        // BigDecimal::add);
-        BigDecimal receivableMoney = sumAmount(salesLedgers, SalesLedger::getContractAmount);
+
         // 搴斾粯
-        List<PurchaseLedger> procurementRecords = purchaseLedgerMapper
-                .selectList(new LambdaQueryWrapper<PurchaseLedger>()
-                        // .ge(PurchaseLedger::getEntryDate, startDate)
-                        // .lt(PurchaseLedger::getEntryDate, endDate)
-                );
-        // BigDecimal payableMoney =
-        // procurementRecords.stream().map(PurchaseLedger::getContractAmount).reduce(BigDecimal.ZERO,
-        // BigDecimal::add);
-        BigDecimal payableMoney = sumAmount(procurementRecords, PurchaseLedger::getContractAmount);
+
         // 棰勬敹
-        List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>()
-                // .ge(ReceiptPayment::getReceiptPaymentDate, startDate)
-                // .lt(ReceiptPayment::getReceiptPaymentDate, endDate)
-        );
-        // BigDecimal advanceMoney =
-        // receiptPayments.stream().map(ReceiptPayment::getReceiptPaymentAmount).reduce(BigDecimal.ZERO,
-        // BigDecimal::add);
-        BigDecimal advanceMoney = sumAmount(receiptPayments, ReceiptPayment::getReceiptPaymentAmount);
+
         // 棰勪粯
-        List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper
-                .selectList(new LambdaQueryWrapper<PaymentRegistration>()
-                        // .ge(PaymentRegistration::getPaymentDate, startDate)
-                        // .lt(PaymentRegistration::getPaymentDate, endDate)
-                );
-        // BigDecimal prepayMoney =
-        // paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO,
-        // BigDecimal::add);
-        BigDecimal prepayMoney = sumAmount(paymentRegistrations, PaymentRegistration::getCurrentPaymentAmount);
-        StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto();
-        statisticsReceivablePayableDto.setPayableMoney(payableMoney.subtract(prepayMoney));
-        statisticsReceivablePayableDto.setReceivableMoney(receivableMoney.subtract(advanceMoney));
-        statisticsReceivablePayableDto.setAdvanceMoney(advanceMoney);
-        statisticsReceivablePayableDto.setPrepayMoney(prepayMoney);
+
+
 
         return statisticsReceivablePayableDto;
     }
@@ -490,7 +441,7 @@
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
     }
 
-    
+
     private DeviceRepairMapper deviceRepairMapper;
 
     @Override
@@ -1160,13 +1111,9 @@
         String endStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 
         // 2. 鏌ヨ鏁版嵁
-        List<IncomeExpenseAnalysisDto> incomeList = accountIncomeMapper.selectIncomeStats(startStr, endStr, dateFormat);
+        List<IncomeExpenseAnalysisDto> incomeList = accountSalesCollectionMapper.selectIncomeStats(startStr, endStr, dateFormat);
+        List<IncomeExpenseAnalysisDto> expenseList = accountPurchasePaymentMapper.selectPayment(startStr, endStr, dateFormat);
 
-        // List<IncomeExpenseAnalysisDto> purchaseList =
-        // purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, dateFormat);
-
-        List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr,
-                dateFormat);
 
         // 3. 杞� Map锛堣嚜鍔ㄥ悎骞讹級
         Map<String, BigDecimal> incomeMap = incomeList.stream()
@@ -1175,11 +1122,7 @@
                         IncomeExpenseAnalysisDto::getAmount,
                         BigDecimal::add));
 
-        // Map<String, BigDecimal> purchaseMap = purchaseList.stream()
-        // .collect(Collectors.toMap(
-        // IncomeExpenseAnalysisDto::getDateStr,
-        // IncomeExpenseAnalysisDto::getAmount,
-        // BigDecimal::add));
+
 
         Map<String, BigDecimal> expenseMap = expenseList.stream()
                 .collect(Collectors.toMap(
@@ -1193,18 +1136,12 @@
         for (String dateStr : xAxis) {
             Map<String, Object> item = new HashMap<>();
             item.put("date", dateStr);
-
             // 鏀跺叆
             BigDecimal income = incomeMap.getOrDefault(dateStr, BigDecimal.ZERO);
             item.put("income", income.setScale(2, RoundingMode.HALF_UP));
-
-            // 鏀嚭 = 閲囪喘 + 璐㈠姟鏀嚭
-            // BigDecimal purchase = purchaseMap.getOrDefault(dateStr, BigDecimal.ZERO);
+            // 鏀嚭
             BigDecimal expense = expenseMap.getOrDefault(dateStr, BigDecimal.ZERO);
-            // BigDecimal totalExpense = purchase.add(expense);
-            BigDecimal totalExpense = expense;
-
-            item.put("expense", totalExpense.setScale(2, RoundingMode.HALF_UP));
+            item.put("expense", expense.setScale(2, RoundingMode.HALF_UP));
 
             result.add(item);
         }
@@ -1231,8 +1168,8 @@
         String startStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
         String endStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 
-        List<IncomeExpenseAnalysisDto> incomeList = accountIncomeMapper.selectIncomeStats(startStr, endStr, dateFormat);
-        List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, dateFormat);
+        List<IncomeExpenseAnalysisDto> incomeList = accountSalesCollectionMapper.selectIncomeStats(startStr, endStr, dateFormat);
+        List<IncomeExpenseAnalysisDto> expenseList = accountPurchasePaymentMapper.selectPayment(startStr, endStr, dateFormat);
 
         Map<String, BigDecimal> incomeMap = incomeList.stream().collect(Collectors
                 .toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add));
@@ -1268,11 +1205,6 @@
             rawMaterialDto.setName("鍘熸潗鏂�");
             rawMaterialDto.setValue(rawMaterialAmount != null ? rawMaterialAmount.toString() : "0");
             result.add(rawMaterialDto);
-
-            List<MapDto> expenseList = accountExpenseMapper.selectExpenseComposition(null, null);
-            if (expenseList != null) {
-                result.addAll(expenseList);
-            }
         }
 
         BigDecimal total = BigDecimal.ZERO;
@@ -1323,34 +1255,6 @@
             return dto;
         }
 
-        BigDecimal collected = products.stream()
-                .map(SalesLedgerProduct::getInvoiceTotal)
-                .filter(Objects::nonNull)
-                .reduce(BigDecimal.ZERO, BigDecimal::add);
-        dto.setMonthlyIncome(collected);
-
-        BigDecimal overdue = products.stream()
-                .map(SalesLedgerProduct::getPendingInvoiceTotal)
-                .filter(Objects::nonNull)
-                .reduce(BigDecimal.ZERO, BigDecimal::add);
-        dto.setOverdueNum(overdue);
-
-        BigDecimal total = collected.add(overdue);
-
-        if (total.compareTo(BigDecimal.ZERO) > 0) {
-            String collectionRate = collected.divide(total, 4, RoundingMode.HALF_UP)
-                    .multiply(new BigDecimal("100"))
-                    .setScale(2, RoundingMode.HALF_UP)
-                    .toString();
-            dto.setCollectionRate(collectionRate);
-
-            String overdueRate = overdue.divide(total, 4, RoundingMode.HALF_UP)
-                    .multiply(new BigDecimal("100"))
-                    .setScale(2, RoundingMode.HALF_UP)
-                    .toString();
-            dto.setOverdueRate(overdueRate);
-        }
-
         return dto;
     }
 
@@ -1382,38 +1286,14 @@
                 if (p.getTaxInclusiveTotalPrice() != null) {
                     rawMaterialCost = rawMaterialCost.add(p.getTaxInclusiveTotalPrice());
                 }
-
-                if (p.getTicketsTotal() != null) {
-                    paidAmount = paidAmount.add(p.getTicketsTotal());
-                }
-
-                if (p.getPendingTicketsTotal() != null) {
-                    pendingAmount = pendingAmount.add(p.getPendingTicketsTotal());
-                }
             }
         }
 
         // 鍏朵粬璐圭敤
-        LambdaQueryWrapper<AccountExpense> expenseWrapper = new LambdaQueryWrapper<>();
-        expenseWrapper.ge(AccountExpense::getExpenseDate,
-                java.sql.Date.valueOf(currentMonth.atDay(1)));
-        expenseWrapper.le(AccountExpense::getExpenseDate,
-                java.sql.Date.valueOf(currentMonth.atEndOfMonth()));
 
-        List<AccountExpense> expenses = accountExpenseMapper.selectList(expenseWrapper);
-
-        BigDecimal otherExpense = BigDecimal.ZERO;
-        if (!CollectionUtils.isEmpty(expenses)) {
-            for (AccountExpense e : expenses) {
-                if (e.getExpenseMoney() != null) {
-                    otherExpense = otherExpense.add(e.getExpenseMoney());
-                }
-            }
-        }
 
         // 鏈堝害鎬绘敮鍑�
-        // BigDecimal monthlyExpenditure = rawMaterialCost.add(otherExpense);
-        BigDecimal monthlyExpenditure = otherExpense;
+        BigDecimal monthlyExpenditure = BigDecimal.ZERO;
         dto.setMonthlyExpenditure(monthlyExpenditure);
 
         // 宸蹭粯娆� 梅锛堝凡浠樻 + 寰呬粯娆撅級
@@ -1436,13 +1316,6 @@
         List<SalesLedgerProduct> salesProducts = salesLedgerProductMapper.selectList(salesWrapper);
 
         BigDecimal revenue = BigDecimal.ZERO;
-        if (!CollectionUtils.isEmpty(salesProducts)) {
-            for (SalesLedgerProduct s : salesProducts) {
-                if (s.getInvoiceAmount() != null) {
-                    revenue = revenue.add(s.getInvoiceAmount());
-                }
-            }
-        }
 
         // 姣涘埄娑� & 鍒╂鼎鐜�
         if (revenue.compareTo(BigDecimal.ZERO) > 0) {
@@ -1464,9 +1337,6 @@
 
         return dto;
     }
-
-    
-    private ProductionProductInputMapper productionProductInputMapper;
 
     @Override
     public List<InputOutputAnalysisDto> inputOutputAnalysis(Integer type) {
@@ -1498,7 +1368,8 @@
         String endStr = endDate.atStartOfDay()
                 .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 
-        List<Map<String, Object>> inputList = productionProductInputMapper.selectInputStats(startStr, endStr);
+//        List<Map<String, Object>> inputList = productionProductInputMapper.selectInputStats(startStr, endStr);
+        List<Map<String, Object>> inputList = null;
         List<Map<String, Object>> outputList = productionProductOutputMapper.selectDailyOutputStats(startStr, endStr);
 
         Map<String, InputOutputAnalysisDto> dateMap = new HashMap<>();
@@ -1724,8 +1595,6 @@
                 .collect(Collectors.toList());
     }
 
-    
-    private ProductionAccountMapper salesLedgerProductionAccountingMapper;
 
     @Override
     public List<ProductionAccountingDto> productionAccountingAnalysis(Integer type) {
@@ -1754,7 +1623,7 @@
 
         String endStr = endDate.plusDays(1).atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 
-        List<Map<String, Object>> wagesList = salesLedgerProductionAccountingMapper.selectDailyWagesStats(startStr,
+        List<Map<String, Object>> wagesList = productionAccountMapper.selectDailyWagesStats(startStr,
                 endStr);
 
         if (CollectionUtils.isEmpty(wagesList)) {

--
Gitblit v1.9.3