From d8da7e76c4bd3089cf7628e441daf822bc372dfd Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 20 一月 2026 14:28:28 +0800
Subject: [PATCH] yys  回款提示

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |  138 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 116 insertions(+), 22 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..848670b 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -1,8 +1,12 @@
 package com.ruoyi.home.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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;
@@ -20,6 +24,14 @@
 import com.ruoyi.procurementrecord.pojo.CustomStorage;
 import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut;
 import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage;
+import com.ruoyi.production.dto.ProductOrderDto;
+import com.ruoyi.production.dto.ProductWorkOrderDto;
+import com.ruoyi.production.dto.ProductionProductMainDto;
+import com.ruoyi.production.mapper.ProductOrderMapper;
+import com.ruoyi.production.mapper.ProductWorkOrderMapper;
+import com.ruoyi.production.mapper.ProductionProductMainMapper;
+import com.ruoyi.production.pojo.ProductOrder;
+import com.ruoyi.production.pojo.ProductWorkOrder;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
@@ -28,12 +40,14 @@
 import com.ruoyi.purchase.pojo.PurchaseLedger;
 import com.ruoyi.quality.mapper.QualityInspectMapper;
 import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.sales.dto.ReceiptPaymentDto;
 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.sales.service.impl.ReceiptPaymentServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -93,6 +107,15 @@
 
     @Autowired
     private SysDeptMapper sysDeptMapper;
+
+    @Autowired
+    private NoticeMapper noticeMapper;
+    @Autowired
+    private ProductOrderMapper productOrderMapper;
+    @Autowired
+    private ProductionProductMainMapper productionProductMainMapper;
+    @Autowired
+    private ProductWorkOrderMapper productWorkOrderMapper;
 
     @Override
     public HomeBusinessDto business() {
@@ -363,23 +386,23 @@
         if(CollectionUtils.isEmpty(approveProcesses)){
             approveProcesses = new ArrayList<>();
         }
-        // 鏌ヨ鏈鐢ㄥ姵淇濊褰�
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-
-        LaborIssue laborIssue1 = new LaborIssue();
-        laborIssue1.setAdoptedDate(new Date());
-        laborIssue1.setIssueDate(sdf.parse(sdf.format(new Date())));
-        List<LaborIssue> laborIssues = lavorIssueMapper.list(laborIssue1);
-        if(!CollectionUtils.isEmpty(laborIssues)){
-            for (LaborIssue laborIssue : laborIssues) {
-                ApproveProcess approveProcess = new ApproveProcess();
-                approveProcess.setApproveId(laborIssue.getOrderNo());
-                approveProcess.setApproveDeptName(sysDeptMapper.selectDeptById(loginUser.getTenantId()).getDeptName());
-                approveProcess.setApproveTime(laborIssue.getIssueDate());
-                approveProcess.setApproveReason(laborIssue.getDictTypeName() + "-" + laborIssue.getDictName() + "瓒呮椂鏈鍙�");
-                approveProcesses.add(approveProcess);
-            }
-        }
+//        // 鏌ヨ鏈鐢ㄥ姵淇濊褰�
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//
+//        LaborIssue laborIssue1 = new LaborIssue();
+//        laborIssue1.setAdoptedDate(new Date());
+//        laborIssue1.setIssueDate(sdf.parse(sdf.format(new Date())));
+//        List<LaborIssue> laborIssues = lavorIssueMapper.list(laborIssue1);  //staff_join_leave_record琛ㄨ鍒犻櫎
+//        if(!CollectionUtils.isEmpty(laborIssues)){
+//            for (LaborIssue laborIssue : laborIssues) {
+//                ApproveProcess approveProcess = new ApproveProcess();
+//                approveProcess.setApproveId(laborIssue.getOrderNo());
+//                approveProcess.setApproveDeptName(sysDeptMapper.selectDeptById(loginUser.getTenantId()).getDeptName());
+//                approveProcess.setApproveTime(laborIssue.getIssueDate());
+//                approveProcess.setApproveReason(laborIssue.getDictTypeName() + "-" + laborIssue.getDictName() + "瓒呮椂鏈鍙�");
+//                approveProcesses.add(approveProcess);
+//            }
+//        }
         return approveProcesses;
     }
 
@@ -420,25 +443,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 +474,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 +489,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 +500,64 @@
             put("deviceRepairTodo", aLong1);
         }};
     }
+
+    @Override
+    public Long noticesCount() {
+        // 鏌ヨ鏈繃鏈熺殑閫氱煡鏁伴噺锛氱姸鎬佷负鍙戝竷涓旇繃鏈熸椂闂村ぇ浜庣瓑浜庡綋鍓嶆棩鏈�
+        return noticeMapper.selectCount(new LambdaQueryWrapper<Notice>()
+                .eq(Notice::getStatus, 1) // 1琛ㄧず鍙戝竷鐘舵��
+                .ge(Notice::getExpirationDate, new Date())); // 杩囨湡鏃堕棿澶т簬绛変簬褰撳墠鏃ユ湡
+    }
+
+    @Override
+    public ProductionProgressDto productionProgress() {
+        ProductionProgressDto productionProgressDto = new ProductionProgressDto();
+        List<ProductOrder> productOrderList = productOrderMapper.selectList(new LambdaQueryWrapper<ProductOrder>());
+        List<ProductOrderDto> productOrderDtoList = new ArrayList<>();
+        productOrderList.forEach(productOrder -> {
+            ProductOrderDto productOrderDto = productOrderMapper.productMainByOrderId(productOrder);
+//            if (productOrderDto != null && productOrderDto.getPlanQuantity() != null && productOrderDto.getQuantity() != null) {
+//                productOrderDto.setCompletionStatus((productOrderDto.getPlanQuantity().subtract(productOrderDto.getQuantity())).divide(productOrderDto.getPlanQuantity(), 2, RoundingMode.HALF_UP));
+//            }
+            productOrderDtoList.add(productOrderDto);
+        });
+        productionProgressDto.setCompletedOrderDetails(productOrderDtoList);
+        // 1. 鏌ヨ鎵�鏈夌敓浜ц鍗曪紙鍙牴鎹渶姹傛坊鍔犺繃婊ゆ潯浠讹紝濡傛帓闄ゅ凡鍒犻櫎銆佸凡鍙栨秷鐨勮鍗曪級
+        IPage<ProductOrderDto> productOrderDtoIPage = productOrderMapper.pageProductOrder(new Page<>(1, -1), new ProductOrderDto());
+
+        // 2. 鍒濆鍖栨眹鎬绘暟鎹�
+        int totalCount = productOrderDtoIPage.getRecords().size();
+        int completedCount = (int) productOrderDtoIPage.getRecords().stream().map(productOrderDto -> productOrderMapper.productMainByOrderId(productOrderDto)).filter(productOrderDto1 -> productOrderDto1.getQuantity() != null && productOrderDto1.getQuantity().compareTo(BigDecimal.ZERO) == 0).count();
+
+        // 6. 璧嬪�兼眹鎬绘暟鎹�
+        productionProgressDto.setTotalOrderCount(totalCount);
+        productionProgressDto.setCompletedOrderCount(completedCount);
+        productionProgressDto.setUncompletedOrderCount(totalCount - completedCount);
+        productionProgressDto.setCompletedProgressCount(BigDecimal.valueOf(completedCount).divide(BigDecimal.valueOf(totalCount), 2, RoundingMode.HALF_UP));
+        return productionProgressDto;
+    }
+    @Override
+    public Map<Integer, List<ProductWorkOrderDto>> workInProcessTurnover() {
+        List<ProductWorkOrderDto> productWorkOrderDtoList = productWorkOrderMapper.selectProductWorkOrderDtoList();
+       //鏍规嵁鐘舵�佸尯鍒嗗伐鍗曠殑鍚勪釜鐘舵��
+        Map<Integer, List<ProductWorkOrderDto>> productWorkOrderDtoMap = productWorkOrderDtoList.stream().collect(Collectors.groupingBy(ProductWorkOrderDto::getStatus));
+
+        return productWorkOrderDtoMap;
+
+    }
+
+    @Autowired
+    private ReceiptPaymentServiceImpl receiptPaymentService;
+
+    @Override
+    public Long overdueReceivable() {
+        // 閫氳繃寮�绁ㄦ棩鏈熻秴杩�15澶╃殑鏈洖娆炬彁绀�
+        ReceiptPaymentDto receiptPaymentDto = new ReceiptPaymentDto();
+        receiptPaymentDto.setTimeOut(true);
+        receiptPaymentDto.setStatus(false);
+        IPage<ReceiptPaymentDto> receiptPaymentDtoIPage = receiptPaymentService.bindInvoiceNoRegPage(new Page<>(-1, -1), receiptPaymentDto);
+        return receiptPaymentDtoIPage.getTotal();
+    }
+
+
 }

--
Gitblit v1.9.3