From e3799b9d987596de79ae7607a205d547c8060340 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 29 四月 2026 16:27:24 +0800
Subject: [PATCH] feat: 工序修改为字典,首页产品部件统计调整

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 17 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 2d3e608..2012680 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -20,6 +20,7 @@
 import com.ruoyi.collaborativeApproval.mapper.NoticeMapper;
 import com.ruoyi.collaborativeApproval.pojo.Notice;
 import com.ruoyi.common.enums.ApproveTypeEnum;
+import com.ruoyi.common.utils.DictUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.device.mapper.DeviceRepairMapper;
@@ -145,7 +146,7 @@
 
     @Autowired
     private ProductProcessMapper productProcessMapper;
-    
+
     @Autowired
     private AccountExpenseMapper accountExpenseMapper;
 
@@ -584,8 +585,8 @@
     public ProductionTurnoverDto workInProcessTurnover() {
         ProductionTurnoverDto productionTurnoverDto = new ProductionTurnoverDto();
         ProductWorkOrderDto workOrder = new ProductWorkOrderDto();
-        workOrder.setPlanStartTime(LocalDate.now().minusMonths(1));
-        workOrder.setPlanEndTime(LocalDate.now());
+        workOrder.setPlanStartTime(LocalDateTime.now());
+        workOrder.setPlanEndTime(LocalDateTime.now());
         List<ProductWorkOrderDto> productWorkOrders = productWorkOrderMapper
                 .pageProductWorkOrder(new Page<>(1, -1), workOrder).getRecords();
         long sum = productWorkOrders.stream()
@@ -1589,30 +1590,31 @@
 
     @Override
     public List<MapDto> processOutputAnalysis(Integer type) {
-        LocalDate today = LocalDate.now();
-        LocalDate startDate;
-        LocalDate endDate = today;
+        // 鑾峰彇褰撳墠鏃堕棿鐐�
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime startDateTime;
+        LocalDateTime endDateTime = now.with(LocalTime.MAX);
 
         switch (type) {
             case 1: // 鍛�
-                startDate = today.with(DayOfWeek.MONDAY);
+                startDateTime = now.with(DayOfWeek.MONDAY).with(LocalTime.MIN);
                 break;
             case 2: // 鏈�
-                startDate = today.withDayOfMonth(1);
+                startDateTime = now.withDayOfMonth(1).with(LocalTime.MIN);
                 break;
             case 3: // 瀛e害
-                int currentMonth = today.getMonthValue();
+                int currentMonth = now.getMonthValue();
                 int startMonth = ((currentMonth - 1) / 3) * 3 + 1;
-                startDate = LocalDate.of(today.getYear(), startMonth, 1);
+                startDateTime = LocalDateTime.of(now.getYear(), startMonth, 1, 0, 0, 0);
                 break;
             default:
-                startDate = today.with(DayOfWeek.MONDAY);
+                startDateTime = now.with(DayOfWeek.MONDAY).with(LocalTime.MIN);
                 break;
         }
 
         ProductWorkOrderDto queryDto = new ProductWorkOrderDto();
-        queryDto.setPlanStartTime(startDate);
-        queryDto.setPlanEndTime(endDate);
+        queryDto.setPlanStartTime(startDateTime);
+        queryDto.setPlanEndTime(endDateTime);
 
         List<ProductWorkOrderDto> list = productWorkOrderMapper.pageProductWorkOrder(new Page<>(1, -1), queryDto)
                 .getRecords();
@@ -1632,7 +1634,7 @@
         BigDecimal total = processOutputMap.values().stream()
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
 
-        if (BigDecimal.ZERO.compareTo(total) == 0) {
+        if (total.compareTo(BigDecimal.ZERO) == 0) {
             return new ArrayList<>();
         }
 
@@ -2480,8 +2482,7 @@
     }
 
     @Override
-    public List<processDataProductionStatisticsDto> processDataProductionStatistics(Integer type,
-                                                                                    List<Long> processIds) {
+    public List<processDataProductionStatisticsDto> processDataProductionStatistics(Integer type, List<Long> processTypes) {
         LoginUser loginUser = SecurityUtils.getLoginUser();
         Long userId = SecurityUtils.isAdmin(loginUser.getUserId()) ? null : loginUser.getUserId();
 
@@ -2510,6 +2511,24 @@
         LocalDateTime startDateTime = startDate.atStartOfDay();
         LocalDateTime endDateTime = endDate.atTime(LocalTime.MAX);
 
-        return productProcessMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processIds);
+        List<processDataProductionStatisticsDto> result = productProcessMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processTypes);
+        if (!ObjectUtils.isEmpty(result)) {
+            result.forEach(dto -> {
+                if (dto == null) {
+                    return;
+                }
+                Integer processType = dto.getProcessType();
+                String dictLabel = null;
+                if (processType != null) {
+                    dictLabel = DictUtils.getDictLabel("product_process_type", String.valueOf(processType));
+                }
+                if (StringUtils.isEmpty(dictLabel)) {
+                    dictLabel = "鍏朵粬";
+                }
+                dto.setProcessName(dictLabel);
+            });
+        }
+
+        return result;
     }
 }

--
Gitblit v1.9.3