From 47b42159fbe69fb2b4dbc13c75dd45abd00a55ae Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 13 二月 2026 11:10:34 +0800
Subject: [PATCH] fix: 查询日期缺少时分秒

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 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 f655af5..84d1934 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -2,6 +2,7 @@
 
 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.account.mapper.AccountIncomeMapper;
 import com.ruoyi.account.pojo.AccountExpense;
@@ -1031,28 +1032,20 @@
 
     @Override
     public List<MapDto> salesPurchaseStorageProductCount() {
-        LocalDate now = LocalDate.now();
-        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime currentMonthStart = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
+        LocalDateTime lastMonth = now.minusMonths(1);
+        LocalDateTime lastMonthStart = lastMonth.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
+        LocalDateTime lastMonthEnd = lastMonth.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
 
-        String currentMonthStart = now.with(TemporalAdjusters.firstDayOfMonth()).format(dtf);
-        String currentMonthNow = now.format(dtf);
-
-        LocalDate lastMonth = now.minusMonths(1);
-        String lastMonthStart = lastMonth.with(TemporalAdjusters.firstDayOfMonth()).format(dtf);
-        String lastMonthEnd = lastMonth.with(TemporalAdjusters.lastDayOfMonth()).format(dtf);
-
-        // 閿�鍞�
-        int currentSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, currentMonthStart,
-                currentMonthNow);
+        //  閿�鍞�
+        int currentSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, currentMonthStart, now);
         int lastSales = salesLedgerProductMapper.selectProductCountByTypeAndDate(1, lastMonthStart, lastMonthEnd);
-
-        // 閲囪喘
-        int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart,
-                currentMonthNow);
+        //  閲囪喘
+        int currentPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, currentMonthStart, now);
         int lastPurchase = salesLedgerProductMapper.selectProductCountByTypeAndDate(2, lastMonthStart, lastMonthEnd);
-
-        // 鍌ㄥ瓨
-        int currentStorage = stockInventoryMapper.selectStorageProductCountByDate(currentMonthStart, currentMonthNow);
+        //  鍌ㄥ瓨
+        int currentStorage = stockInventoryMapper.selectStorageProductCountByDate(currentMonthStart, now);
         int lastStorage = stockInventoryMapper.selectStorageProductCountByDate(lastMonthStart, lastMonthEnd);
 
         List<MapDto> list = new ArrayList<>();
@@ -2430,6 +2423,13 @@
         dto.setProcessNum(sumQuantity(qualityInspectList, 1)); // 杩囩▼
         dto.setFactoryNum(sumQuantity(qualityInspectList, 2)); // 鍑哄巶
 
+        // 鍋囪 qualityInspectList 鏄竴涓� List<QualityInspect> 绫诲瀷鐨勯泦鍚�
+        Map<String, List<QualityInspect>> groupedByCheckResult = qualityInspectList.stream()
+                .collect(Collectors.groupingBy(QualityInspect::getCheckResult));
+        List<QualityInspect> qualityInspects = groupedByCheckResult.get("涓嶅悎鏍�");
+        if(ObjectUtils.isNull(qualityInspects) || qualityInspects.size()==0){
+            return null;
+        }
         // 4. 澶勭悊鍥捐〃椤� (Item)
         List<QualityStatisticsItem> itemList = new ArrayList<>();
 
@@ -2439,7 +2439,7 @@
                         i -> i.getCheckTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()));
         if (type == 3) {
             // 瀛e害妯″紡锛氭寜鏈堝垎缁�
-            Map<String, List<QualityInspect>> groupByMonth = qualityInspectList.stream()
+            Map<String, List<QualityInspect>> groupByMonth = qualityInspects.stream()
                     .collect(Collectors.groupingBy(i -> {
                         LocalDate ld = dateMap.get(i);
                         return ld.format(DateTimeFormatter.ofPattern("yyyy-MM"));
@@ -2452,7 +2452,7 @@
             }
         } else {
             // 鍛ㄦ垨鏈堟ā寮忥細鎸夊ぉ鍒嗙粍
-            Map<String, List<QualityInspect>> groupByDay = qualityInspectList.stream()
+            Map<String, List<QualityInspect>> groupByDay = qualityInspects.stream()
                     .collect(Collectors.groupingBy(i -> {
                         LocalDate ld = dateMap.get(i);
                         return ld.format(DateTimeFormatter.ofPattern("MM/dd"));
@@ -2524,4 +2524,4 @@
 
         return productProcessMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processIds);
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3