From 2a8a4cf20e55bbef3a9f8959136ee828b058dac0 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 14 十月 2026 15:47:20 +0800
Subject: [PATCH] Merge commit 'e0296ea7' into dev_pro_河南鹤壁_首检

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |   77 ++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 37 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 d3c21a2..0f854d1 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -61,6 +61,7 @@
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
@@ -497,9 +498,20 @@
 
     @Override
     public ProductionProgressDto productionProgress() {
+        LocalDateTime now = LocalDateTime.now();
+
+        LocalDateTime startOfMonth = now
+                .with(TemporalAdjusters.firstDayOfMonth())
+                .with(LocalTime.MIN);
+
+        LocalDateTime endOfMonth = now
+                .with(TemporalAdjusters.lastDayOfMonth())
+                .with(LocalTime.MAX);
+
+
         ProductionProgressDto productionProgressDto = new ProductionProgressDto();
-        List<ProductionProgressOrderDto> orderDetails = productionOrderMapper.selectProgressOrders(
-                LocalDateTime.now().minusMonths(1), LocalDateTime.now());
+        List<ProductionProgressOrderDto> orderDetails = productionOrderMapper
+                .selectProgressOrders(startOfMonth, endOfMonth);
         productionProgressDto.setCompletedOrderDetails(orderDetails);
         long totalCount = orderDetails.size();
         long count = orderDetails.stream().filter(
@@ -519,7 +531,7 @@
     public ProductionTurnoverDto workInProcessTurnover() {
         ProductionTurnoverDto productionTurnoverDto = new ProductionTurnoverDto();
         List<ProductionTaskStatisticsDto> taskList = productionOperationTaskMapper
-                .selectTaskStatisticsByDate(LocalDate.now().minusMonths(1), LocalDate.now());
+                .selectTaskStatisticsByDate(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()), LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()));
         long sum = taskList.stream()
                 .filter(task -> defaultDecimal(task.getPlanQuantity()).compareTo(defaultDecimal(task.getCompleteQuantity())) > 0)
                 .map(ProductionTaskStatisticsDto::getPlanQuantity)
@@ -1147,7 +1159,6 @@
                         BigDecimal::add));
 
 
-
         Map<String, BigDecimal> expenseMap = expenseList.stream()
                 .collect(Collectors.toMap(
                         IncomeExpenseAnalysisDto::getDateStr,
@@ -1345,15 +1356,15 @@
         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 = null;
+        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<>();
 
         if (!CollectionUtils.isEmpty(inputList)) {
             for (Map<String, Object> map : inputList) {
-                String date = (String) map.get("date");
+                String date = (String) map.get("statDate");
                 if (date == null)
                     continue;
                 InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto());
@@ -1366,7 +1377,7 @@
 
         if (!CollectionUtils.isEmpty(outputList)) {
             for (Map<String, Object> map : outputList) {
-                String date = (String) map.get("date");
+                String date = (String) map.get("statDate");
                 if (date == null)
                     continue;
                 InputOutputAnalysisDto dto = dateMap.getOrDefault(date, new InputOutputAnalysisDto());
@@ -1625,16 +1636,16 @@
     @Override
     public List<MapDto> orderCount() {
         LocalDate now = LocalDate.now();
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
-        String currentStart = now.withDayOfMonth(1).atStartOfDay()
-                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-        String currentEnd = now.atTime(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        LocalDateTime startDateTime = now.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay();
+        LocalDateTime endDateTime = now.with(TemporalAdjusters.lastDayOfMonth()).atTime(LocalTime.MAX);
 
-        LocalDate lastMonthDate = now.minusMonths(1);
-        String lastStart = lastMonthDate.withDayOfMonth(1).atStartOfDay()
-                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-        String lastEnd = lastMonthDate.withDayOfMonth(lastMonthDate.lengthOfMonth()).atTime(LocalTime.MAX)
-                .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+        String currentStart = startDateTime.format(dateTimeFormatter);
+        String currentEnd = endDateTime.format(dateTimeFormatter);
+
+        String lastStart = startDateTime.minusMonths(1).format(dateTimeFormatter);
+        String lastEnd = endDateTime.format(dateTimeFormatter);
 
         int currentCreated = productionOrderMapper.countCreated(currentStart, currentEnd);
         int lastCreated = productionOrderMapper.countCreated(lastStart, lastEnd);
@@ -1693,45 +1704,37 @@
         LocalDate endDate = range[1];
 
         String startStr = startDate.toString();
-        String endStr = endDate.toString();
+        String endStr = endDate.plusDays(1).toString();
 
         List<QualityInspect> list = qualityInspectMapper.selectList(
                 new LambdaQueryWrapper<QualityInspect>()
                         .eq(QualityInspect::getInspectType, inspectType)
                         .eq(QualityInspect::getInspectState, 1)
                         .ge(QualityInspect::getCheckTime, startStr)
-                        .le(QualityInspect::getCheckTime, endStr));
+                        .lt(QualityInspect::getCheckTime, endStr));
 
         return buildQualifiedAnalysis(list);
     }
 
     private LocalDate[] calcDateRange(Integer type) {
-        LocalDate today = LocalDate.now();
+        int rangeType = (type == null) ? 1 : type;
+        LocalDate anchor = LocalDate.now();
         LocalDate startDate;
-        LocalDate endDate;
 
-        switch (type) {
-            case 1: // 鍛�
-                startDate = today.with(DayOfWeek.MONDAY);
-                endDate = today.with(DayOfWeek.SUNDAY);
+        switch (rangeType) {
+            case 2: // 杩戜竴鏈�
+                startDate = anchor.minusMonths(1).plusDays(1);
                 break;
-            case 2: // 鏈�
-                startDate = today.with(TemporalAdjusters.firstDayOfMonth());
-                endDate = today.with(TemporalAdjusters.lastDayOfMonth());
+            case 3: // 杩戜竴瀛e害
+                startDate = anchor.minusMonths(3).plusDays(1);
                 break;
-            case 3: // 瀛e害
-                int currentMonth = today.getMonthValue();
-                int startMonth = ((currentMonth - 1) / 3) * 3 + 1;
-                startDate = LocalDate.of(today.getYear(), startMonth, 1);
-                endDate = LocalDate.of(today.getYear(), startMonth + 2, 1)
-                        .with(TemporalAdjusters.lastDayOfMonth());
-                break;
+            case 1: // 杩戜竴鍛�
             default:
-                startDate = today.with(DayOfWeek.MONDAY);
-                endDate = today.with(DayOfWeek.SUNDAY);
+                startDate = anchor.minusDays(6);
+                break;
         }
 
-        return new LocalDate[]{startDate, endDate};
+        return new LocalDate[]{startDate, anchor};
     }
 
     private QualityQualifiedAnalysisDto buildQualifiedAnalysis(List<QualityInspect> list) {

--
Gitblit v1.9.3