From 2a9c3934bb093c978a54a1c3e220e6a120855e77 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 09 一月 2026 15:11:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jtwy' into jtwy

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |   34 +++++++++++++++++++++++++++++-----
 1 files changed, 29 insertions(+), 5 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 0f822dd..5630e84 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -3,6 +3,8 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.approve.mapper.ApproveProcessMapper;
 import com.ruoyi.approve.pojo.ApproveProcess;
+import com.ruoyi.collaborativeApproval.mapper.NoticeMapper;
+import com.ruoyi.collaborativeApproval.pojo.Notice;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.device.mapper.DeviceMaintenanceMapper;
 import com.ruoyi.device.mapper.DeviceRepairMapper;
@@ -93,6 +95,9 @@
 
     @Autowired
     private SysDeptMapper sysDeptMapper;
+
+    @Autowired
+    private NoticeMapper noticeMapper;
 
     @Override
     public HomeBusinessDto business() {
@@ -420,25 +425,29 @@
 //                .ge(SalesLedger::getEntryDate, startDate)
 //                .lt(SalesLedger::getEntryDate, endDate)
         );
-        BigDecimal receivableMoney = salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+//        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 = 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 = 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 = 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));
@@ -447,7 +456,13 @@
 
         return statisticsReceivablePayableDto;
     }
-
+    public static <T> BigDecimal sumAmount(List<T> list, java.util.function.Function<T, BigDecimal> amountExtractor) {
+        return list.stream()
+                // 鎻愬彇閲戦鏃讹紝灏唍ull鏇挎崲涓築igDecimal.ZERO
+                .map(item -> Optional.ofNullable(amountExtractor.apply(item)).orElse(BigDecimal.ZERO))
+                // 绱姞锛屽垵濮嬪�间负0锛岄伩鍏嶇┖娴侀棶棰�
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+    }
     @Autowired
     private DeviceRepairMapper deviceRepairMapper;
 
@@ -456,6 +471,7 @@
         // 瀹℃壒鍗忓悓寰呭姙
         Long aLong = approveProcessMapper.selectCount(new LambdaQueryWrapper<ApproveProcess>()
                 .eq(ApproveProcess::getApproveUserCurrentId, SecurityUtils.getUserId())
+                .eq(ApproveProcess::getApproveDelete, 0)
                 .in(ApproveProcess::getApproveStatus, 0, 1, 3));
         // 璁惧鎶ヤ慨寰呭姙
         Long aLong1 = deviceRepairMapper.selectCount(new LambdaQueryWrapper<DeviceRepair>()
@@ -466,4 +482,12 @@
             put("deviceRepairTodo", aLong1);
         }};
     }
+
+    @Override
+    public Long noticesCount() {
+        // 鏌ヨ鏈繃鏈熺殑閫氱煡鏁伴噺锛氱姸鎬佷负鍙戝竷涓旇繃鏈熸椂闂村ぇ浜庣瓑浜庡綋鍓嶆棩鏈�
+        return noticeMapper.selectCount(new LambdaQueryWrapper<Notice>()
+                .eq(Notice::getStatus, 1) // 1琛ㄧず鍙戝竷鐘舵��
+                .ge(Notice::getExpirationDate, new Date())); // 杩囨湡鏃堕棿澶т簬绛変簬褰撳墠鏃ユ湡
+    }
 }

--
Gitblit v1.9.3