From e206ea8f7dbb655c0d8868996dae8ff1ff5ed11a Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期四, 12 六月 2025 16:41:19 +0800
Subject: [PATCH] 修改看板大屏,动态获取数据

---
 JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingLogController.java    |   26 ++
 JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/PrimitiveTaskController.java |   27 ++
 UI-Project/src/views/KanbanData/kanbanData.vue                                                                        |   19 +-
 JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java |  160 +++++++++++++++++
 JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/TaskingLogService.java          |   14 +
 UI-Project/src/views/KanbanDisplay2/kanbanDisplay2.vue                                                                |  236 +++++++++++++------------
 6 files changed, 345 insertions(+), 137 deletions(-)

diff --git a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/PrimitiveTaskController.java b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/PrimitiveTaskController.java
index e2c2fc4..2076533 100644
--- a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/PrimitiveTaskController.java
+++ b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/PrimitiveTaskController.java
@@ -2,12 +2,12 @@
 
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.mes.md.entity.*;
+import com.mes.md.entity.KBBTJPDrawingBP;
+import com.mes.md.entity.PrimitiveTask;
 import com.mes.md.mapper.KBBTJPDrawingBPMapper;
 import com.mes.md.service.KBBTJPDrawingBPService;
 import com.mes.md.service.PrimitiveTaskService;
 import com.mes.md.service.TaskingLogService;
-import com.mes.md.service.TaskingService;
 import com.mes.utils.Result;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -104,8 +104,8 @@
     @ApiOperation("鏌ヨ 璁″垝閲� m虏 鐗囨暟锛堝鎴疯〃锛�")
     @PostMapping("/findPlannedQuantity")
     @ResponseBody
-    public Result findPlannedQuantity(@RequestBody Map<String, String> map) {
-        int dayCount=Integer.valueOf(map.get("dayCount").toString());
+    public Result findPlannedQuantity() {
+        //int dayCount=Integer.valueOf(map.get("dayCount").toString());
         Calendar cal = Calendar.getInstance();
         //璁剧疆褰撳墠鏃堕棿
         cal.setTime(new Date());
@@ -113,15 +113,30 @@
         cal.set(Calendar.MINUTE, 0);
         cal.set(Calendar.SECOND, 0);
         cal.set(Calendar.MILLISECOND, 0);
-        cal.add(Calendar.DATE, 1-dayCount);
+
+        //cal.add(Calendar.DATE, 1-dayCount);
+        cal.set(Calendar.DAY_OF_MONTH, 1);
         Date startDate = cal.getTime();
+
+        // 鑾峰彇褰撴湀鏈�鍚庝竴澶�
+        Calendar lastDayCal = (Calendar) cal.clone();
+        lastDayCal.add(Calendar.MONTH, 1);
+        lastDayCal.add(Calendar.DATE, -1);
+        Date endDate = lastDayCal.getTime();
+
+        // 鑾峰彇褰撴湀澶╂暟
+        int dayCount = lastDayCal.get(Calendar.DAY_OF_MONTH);
 
         QueryWrapper<KBBTJPDrawingBP> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("CAST(PlanDate AS DATE) AS CreateDate,isNull(sum(task_quantity),0) as task_quantity_sum,isNull(sum(length*width*task_quantity)/1000000,0) as area_sum")
-                .gt("PlanDate",startDate).groupBy("CAST(PlanDate AS DATE)")
+                .ge("PlanDate",startDate).le("PlanDate",endDate).groupBy("CAST(PlanDate AS DATE)")
                 .orderByAsc("CAST(PlanDate AS DATE)");;
         List<Map> list=kBBTJPDrawingBPMapper.selectMaps((QueryWrapper)queryWrapper);
         List<Map> resultDate=new ArrayList<>();
+
+        // 閲嶇疆鏃ュ巻鍒板綋鏈堢涓�澶�
+        cal.setTime(startDate);
+
         for (int i=0;i<dayCount;i++){
             Date thisdate=cal.getTime();
             cal.add(Calendar.DATE, 1);
diff --git a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingLogController.java b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingLogController.java
index af9354e..5b9cd83 100644
--- a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingLogController.java
+++ b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/controller/TaskingLogController.java
@@ -51,6 +51,32 @@
         }
     }
 
+   @ApiOperation("鏌ヨ鍗曞皬鏃朵骇閲�")
+   @PostMapping("/findHourlyOutput")
+   @ResponseBody
+   public Result findHourlyOutput(@RequestBody Map<String, String> map) {
+       try {
+           int dayCount = Integer.valueOf(map.get("dayCount").toString());
+           Map<String, Object> result = taskingLogService.findHourlyOutput(dayCount);
+           return Result.build(200, "鏌ヨ鎴愬姛", result);
+       } catch (Exception e) {
+           return Result.build(199, "鏌ヨ澶辫触: " + e.getMessage(), null);
+       }
+   }
+
+   @ApiOperation("鏌ヨ搴撲綅鏁版嵁")
+   @PostMapping("/selectWareHouse")
+   @ResponseBody
+   public Result selectWareHouse(@RequestBody Map<String, String> map) {
+       try {
+           int dayCount = Integer.valueOf(map.get("dayCount").toString());
+           List<Map<String, Object>> result = taskingLogService.selectWareHouse(dayCount);
+           return Result.build(200, "鏌ヨ鎴愬姛", result);
+       } catch (Exception e) {
+           return Result.build(199, "鏌ヨ澶辫触: " + e.getMessage(), null);
+       }
+   }
+
     @ApiOperation("鎻愪氦鏃ュ織浠ュ強鎶ュ伐鏁版嵁鍒颁節鐗ф暟鎹簱")
     @PostMapping("/reportTaskingLog")
     @ResponseBody
diff --git a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/TaskingLogService.java b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/TaskingLogService.java
index 9b75a69..106cae1 100644
--- a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/TaskingLogService.java
+++ b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/TaskingLogService.java
@@ -1,7 +1,6 @@
 package com.mes.md.service;
 
 import com.github.yulichang.base.MPJBaseService;
-import com.mes.md.entity.TaskLog;
 import com.mes.md.entity.TaskingLog;
 
 import java.util.Date;
@@ -39,4 +38,17 @@
      * 鍥炰紶鎶ュ伐鏁版嵁+ 璁惧鐜荤拑杩囩墖璁板綍缁� 涔濈墽
      */
     Integer reportTaskingLog();
+
+    /**
+     * 鏌ヨ鍗曞皬鏃朵骇閲�
+     * @param dayCount 鏌ヨ澶╂暟
+     */
+    Map<String, Object> findHourlyOutput(int dayCount);
+
+    /**
+     * 鏌ヨ搴撲綅鏁版嵁
+     * @param dayCount 鏌ヨ澶╂暟
+     * @return 搴撲綅鏁版嵁鍒楄〃
+     */
+    List<Map<String, Object>> selectWareHouse(int dayCount);
 }
diff --git a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
index 242a9f5..6a8b100 100644
--- a/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
+++ b/JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/md/service/impl/TaskingLogServiceImpl.java
@@ -74,10 +74,14 @@
             if (lineType != null && !lineType.isEmpty()) {
                 taskingWrapper.apply("operation_record REGEXP '.*[^0-9]" + lineType + "$'");
             }
-
-            // 鎸夋椂闂存帓搴�
-            taskingWrapper.orderByDesc("operation_record_time");
-
+            
+            // 鎸夋椂闂存帓搴忥紙闄嶅簭)
+            //taskingWrapper.orderByDesc("operation_record_time");
+            //(鍗囧簭)
+            taskingWrapper.orderByAsc("operation_record_time");
+            // 鍏堟寜sortOrder鎺掑簭锛屽啀鎸夋椂闂存帓搴�
+            //taskingWrapper.orderByAsc("sort_order", "operation_record_time");
+            
             // 鎵ц鏌ヨ
             List<Map<String, Object>> taskingList = baseMapper.selectMaps(taskingWrapper);
 
@@ -116,7 +120,6 @@
 
         List<Map<String, Object>> listTasking1 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>()
                 .select("task_type, operation_record, operation_mode, DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time, count(*) as count")
-                .eq("task_type", "瀹氬埗")
                 .eq("operation_record", "鏃嬭浆1")
                 .eq("operation_mode", "缁撴潫")
                 .gt("operation_record_time", startDate)
@@ -124,7 +127,6 @@
                 .orderByAsc("DATE_FORMAT(operation_record_time, '%Y-%m-%d')"));
         List<Map<String, Object>> listTasking2 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>()
                 .select("task_type,operation_record,operation_mode,DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time,count(1) as count")
-                .eq("task_type", "瀹氬埗")
                 .eq("operation_record", "鏃嬭浆2")
                 .eq("operation_mode", "缁撴潫")
                 .gt("operation_record_time", startDate)
@@ -274,4 +276,150 @@
         }
         return 0;
     }
+
+
+    /**
+     * 鏌ヨ鍗曞皬鏃朵骇閲�
+     * @param dayCount 鏌ヨ澶╂暟
+     * @return Map 鍖呭惈姣忓ぉ涓ゆ潯绾跨殑骞冲潎灏忔椂浜ч噺
+     */
+    @Override
+    public Map<String, Object> findHourlyOutput(int dayCount) {
+        try {
+            // 璁$畻寮�濮嬫椂闂�
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(new Date());
+            cal.set(Calendar.HOUR_OF_DAY, 0);
+            cal.set(Calendar.MINUTE, 0);
+            cal.set(Calendar.SECOND, 0);
+            cal.set(Calendar.MILLISECOND, 0);
+            cal.add(Calendar.DATE, -dayCount + 1);
+            Date startDate = cal.getTime();
+
+            // 鏌ヨ涓�绾挎暟鎹紝鎸夊ぉ鍒嗙粍缁熻鎬讳骇閲忓拰宸ヤ綔灏忔椂鏁�
+            QueryWrapper<TaskingLog> line1Query = new QueryWrapper<>();
+            line1Query.select(
+                    "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+                    "COUNT(*) as total_count",
+                    "COUNT(DISTINCT DATE_FORMAT(operation_record_time, '%H')) as working_hours"
+                )
+                .eq("operation_record", "鏃嬭浆1")
+                .eq("operation_mode", "缁撴潫")
+                .ge("operation_record_time", startDate)
+                .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")
+                .orderByAsc("date");
+            List<Map<String, Object>> line1Results = baseMapper.selectMaps(line1Query);
+
+            // 鏌ヨ浜岀嚎鏁版嵁锛屾寜澶╁垎缁勭粺璁℃�讳骇閲忓拰宸ヤ綔灏忔椂鏁�
+            QueryWrapper<TaskingLog> line2Query = new QueryWrapper<>();
+            line2Query.select(
+                    "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+                    "COUNT(*) as total_count",
+                    "COUNT(DISTINCT DATE_FORMAT(operation_record_time, '%H')) as working_hours"
+                )
+                .eq("operation_record", "鏃嬭浆2")
+                .eq("operation_mode", "缁撴潫")
+                .ge("operation_record_time", startDate)
+                .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")
+                .orderByAsc("date");
+            List<Map<String, Object>> line2Results = baseMapper.selectMaps(line2Query);
+
+            // 鍚堝苟缁撴灉
+            Map<String, Object> result = new HashMap<>();
+            Map<String, Map<String, Object>> dailyStats = new HashMap<>();
+
+            // 澶勭悊涓�绾挎暟鎹�
+            for (Map<String, Object> line1Data : line1Results) {
+                String date = (String) line1Data.get("date");
+                int totalCount = ((Number) line1Data.get("total_count")).intValue();
+                int workingHours = ((Number) line1Data.get("working_hours")).intValue();
+                
+                Map<String, Object> dailyData = new HashMap<>();
+                dailyData.put("date", date);
+                dailyData.put("line1Count", totalCount);
+                dailyData.put("line1Hours", workingHours);
+                dailyData.put("line1HourlyAvg", workingHours > 0 ? totalCount / workingHours : 0);
+                
+                dailyStats.put(date, dailyData);
+            }
+
+            // 澶勭悊浜岀嚎鏁版嵁
+            for (Map<String, Object> line2Data : line2Results) {
+                String date = (String) line2Data.get("date");
+                int totalCount = ((Number) line2Data.get("total_count")).intValue();
+                int workingHours = ((Number) line2Data.get("working_hours")).intValue();
+                
+                Map<String, Object> dailyData = dailyStats.computeIfAbsent(date, k -> {
+                    Map<String, Object> newData = new HashMap<>();
+                    newData.put("date", date);
+                    return newData;
+                });
+                
+                dailyData.put("line2Count", totalCount);
+                dailyData.put("line2Hours", workingHours);
+                dailyData.put("line2HourlyAvg", workingHours > 0 ? totalCount / workingHours : 0);
+            }
+
+            // 杞崲涓烘渶缁堢殑杩斿洖鏍煎紡
+            List<Map<String, Object>> finalStats = new ArrayList<>(dailyStats.values());
+
+            // 鎸夋棩鏈熸帓搴�
+            finalStats.sort((a, b) -> ((String)a.get("date")).compareTo((String)b.get("date")));
+
+            result.put("dailyStats", finalStats);
+            return result;
+        } catch (Exception e) {
+            log.error("璁$畻鍗曞皬鏃朵骇閲忓け璐�", e);
+            throw new RuntimeException("璁$畻鍗曞皬鏃朵骇閲忓け璐�: " + e.getMessage());
+        }
+    }
+
+    /**
+     * 鏌ヨ搴撲綅鏁版嵁
+     * 鎸夊簱浣嶇粺璁★細
+     * - 鏍囧噯宸ヨ壓锛氱粺璁′笂鐗�1鍜屼笂鐗�2鐨勮褰�
+     * - 瀹氬埗宸ヨ壓锛氱粺璁℃棆杞�1鍜屾棆杞�2鐨勮褰�
+     */
+    @Override
+    public List<Map<String, Object>> selectWareHouse(int dayCount) {
+        try {
+            // 璁$畻寮�濮嬫椂闂�
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(new Date());
+            cal.set(Calendar.HOUR_OF_DAY, 0);
+            cal.set(Calendar.MINUTE, 0);
+            cal.set(Calendar.SECOND, 0);
+            cal.set(Calendar.MILLISECOND, 0);
+            cal.add(Calendar.DATE, -dayCount + 1);  
+            Date startDate = cal.getTime();
+            
+            // 浣跨敤QueryWrapper鏋勫缓鏌ヨ
+            QueryWrapper<TaskingLog> queryWrapper = new QueryWrapper<>();
+            queryWrapper.select(
+                    "DATE_FORMAT(operation_record_time, '%Y-%m-%d') as date",
+                    "warehouse",
+                    "COUNT(*) as count"
+                )
+                .and(wrapper -> wrapper
+                    .and(w -> w
+                        .eq("task_type", "鏍囧噯")
+                        .in("operation_record", "涓婄墖1", "涓婄墖2")
+                    )
+                    .or(w -> w
+                        .eq("task_type", "瀹氬埗")
+                        .in("operation_record", "鏃嬭浆1", "鏃嬭浆2")
+                    )
+                )
+                .eq("operation_mode", "缁撴潫")
+                .ge("operation_record_time", startDate)
+                .groupBy("DATE_FORMAT(operation_record_time, '%Y-%m-%d')", "warehouse")
+                .orderByAsc("date", "warehouse");
+
+            return baseMapper.selectMaps(queryWrapper);
+
+        } catch (Exception e) {
+            log.error("鏌ヨ搴撲綅鏁版嵁澶辫触", e);
+            throw new RuntimeException("鏌ヨ搴撲綅鏁版嵁澶辫触: " + e.getMessage());
+        }
+    }
 }
diff --git a/UI-Project/src/views/KanbanData/kanbanData.vue b/UI-Project/src/views/KanbanData/kanbanData.vue
index 87a17e9..7b4a4b7 100644
--- a/UI-Project/src/views/KanbanData/kanbanData.vue
+++ b/UI-Project/src/views/KanbanData/kanbanData.vue
@@ -62,7 +62,8 @@
 
 
 // 褰撳墠婵�娲荤殑鏍囩椤�
-const activeTab = ref('yield')
+const activeTab = ref('utilization')
+const showTab = ref(false)
 
 // 鍗曞皬鏃朵骇閲忔暟鎹�
 const yieldFormData = ref({
@@ -685,7 +686,7 @@
     <el-main>
       <el-tabs v-model="activeTab">
         <!-- 鍗曞皬鏃朵骇閲忔爣绛鹃〉 -->
-        <el-tab-pane label="鍗曞皬鏃朵骇閲�" name="yield">
+        <el-tab-pane label="鍗曞皬鏃朵骇閲�"  name="yield">
           <!-- 娣诲姞鐩爣鍊艰缃儴鍒� -->
           <div class="target-setting">
             <el-form :inline="true" label-width="100px">
@@ -714,7 +715,7 @@
               </el-form-item>
             </el-form>
           </div>
-          <el-form :inline="true" :model="yieldFormData" label-width="100px" class="form-container">
+          <el-form :inline="true" :model="yieldFormData" label-width="100px" v-if="showTab" class="form-container">
             <el-form-item label="鏃ユ湡">
               <el-date-picker
                 v-model="yieldFormData.recordDate"
@@ -746,7 +747,7 @@
             </el-form-item>
           </el-form>
 
-          <el-table :data="yieldData"  v-loading="yieldLoading" style="width: 100%">
+          <el-table :data="yieldData"  v-loading="yieldLoading" style="width: 100%" v-if="showTab">
             <el-table-column prop="recordDate" label="鏃ユ湡" width="180">
               <template #default="scope">
                 <el-date-picker
@@ -949,7 +950,7 @@
         </el-tab-pane>
 
         <!-- 鍦ㄥ埗閲忔爣绛鹃〉 -->
-        <el-tab-pane label="鍦ㄥ埗閲�" name="quantity">
+        <el-tab-pane label="鍦ㄥ埗閲�"  name="quantity">
           <!-- 娣诲姞鐩爣鍊艰缃儴鍒� -->
           <div class="target-setting">
             <el-form :inline="true" label-width="100px">
@@ -1001,8 +1002,8 @@
             <el-form-item label="绫诲瀷">
               <el-select v-model="quantityFormData.locationCode" placeholder="閫夋嫨绫诲瀷" style="width: 180px">
                 <el-option label="鍗婃垚鍝�" value="鍗婃垚鍝�" />
-                <el-option label="7014" value="7014" />
-                <el-option label="7016" value="7016" />
+                <!-- <el-option label="7014" value="7014" />
+                <el-option label="7016" value="7016" /> -->
               </el-select>
             </el-form-item>
             <el-form-item label="鏁伴噺">
@@ -1021,7 +1022,7 @@
             </el-form-item>
           </el-form>
 
-          <el-table :data="quantityData"  v-loading="quantityLoading" style="width: 100%">
+          <el-table :data="quantityData"  v-loading="quantityLoading" style="width: 100%" >
             <el-table-column prop="recordDate" label="鏃ユ湡" width="180">
               <template #default="scope">
                 <el-date-picker
@@ -1095,7 +1096,7 @@
         </el-tab-pane>
 
         <!-- 璁″垝浜ч噺鏍囩椤� -->
-        <el-tab-pane label="璁″垝浜ч噺" name="planned">
+        <el-tab-pane label="璁″垝浜ч噺" v-if="showTab" name="planned">
           <el-form :inline="true" :model="plannedFormData" label-width="100px" class="form-container">
             <el-form-item label="鏃ユ湡">
               <el-date-picker
diff --git a/UI-Project/src/views/KanbanDisplay2/kanbanDisplay2.vue b/UI-Project/src/views/KanbanDisplay2/kanbanDisplay2.vue
index b32a997..b8b2c84 100644
--- a/UI-Project/src/views/KanbanDisplay2/kanbanDisplay2.vue
+++ b/UI-Project/src/views/KanbanDisplay2/kanbanDisplay2.vue
@@ -98,12 +98,29 @@
 // 璁″垝閲忔暟鎹�
 const loadPlannedData = async () => {
   try {
-    const res = await request.post('/deviceInteraction/plannedAmount/chartPlanned', {
-      dayCount: 30  // 纭繚璇锋眰30澶╃殑鏁版嵁
-    });
+    const res = await request.post('/deviceInteraction/primitiveTask/findPlannedQuantity', {});
     if (res.code === 200) {
-      plannedData.value = res.data;
-      updateOptionPlanned();
+      // 纭繚鏁版嵁瀛樺湪
+      if (res.data && Array.isArray(res.data)) {
+        plannedData.value = res.data.map(item => ([
+          {
+            recordTime: item.CreateDate,
+            type: '骞虫柟',
+            value: item.area_sum || 0
+          },
+          {
+            recordTime: item.CreateDate,
+            type: '鐗囨暟',
+            value: item.task_quantity_sum || 0
+          }
+        ])).flat(); 
+        
+        updateOptionPlanned();
+      } else {
+        console.error('璁″垝閲忔暟鎹牸寮忎笉姝g‘:', res.data);
+      }
+    } else {
+      console.error('鑾峰彇璁″垝閲忔暟鎹け璐�:', res.message);
     }
   } catch (error) {
     console.error('鑾峰彇璁″垝閲忔暟鎹け璐�:', error);
@@ -114,11 +131,11 @@
 // 鍗曞皬鏃朵骇閲忔暟鎹�
 const loadYieldData = async () => {
   try {
-    const res = await request.post('/deviceInteraction/yield/chartYield', {
+    const res = await request.post('/deviceInteraction/taskingLog/findHourlyOutput', {
       dayCount: 30  // 纭繚璇锋眰30澶╃殑鏁版嵁
     });
-    if (res.code === 200) {
-      yieldData.value = res.data;
+    if (res.code === 200 && res.data && res.data.dailyStats) {
+      yieldData.value = res.data.dailyStats;
       updateOptionYield(yieldTarget1.value, yieldTarget2.value);
     }
   } catch (error) {
@@ -144,11 +161,60 @@
 // 鍔犺浇鍦ㄥ埗閲忔暟鎹�
 const loadInventoryData = async () => {
   try {
-    const res = await request.post('/deviceInteraction/quantity/chartQuantity', {
-      dayCount: 30  // 纭繚璇锋眰30澶╃殑鏁版嵁
+    // 鑾峰彇鏃ユ湡鏁扮粍
+    const { dates } = generateMonthDates();
+
+    // 鑾峰彇鍗婃垚鍝佹暟鎹�
+    const resQuantity = await request.post('/deviceInteraction/quantity/chartQuantity', {
+      dayCount: 30
     });
-    if (res.code === 200) {
-      quantityData.value = res.data;
+
+    // 鑾峰彇搴撲綅鏁版嵁锛�7014鍜�7016锛�
+    const resWareHouse = await request.post('/deviceInteraction/taskingLog/selectWareHouse', {
+      dayCount: 30
+    });
+
+    if (resQuantity.code === 200 && resWareHouse.code === 200) {
+      // 澶勭悊鍗婃垚鍝佹暟鎹�
+      const semiData = Array(dates.length).fill(0);
+      const data7014 = Array(dates.length).fill(0);
+      const data7016 = Array(dates.length).fill(0);
+
+      // 澶勭悊鍗婃垚鍝佹暟鎹�
+      if (resQuantity.data) {
+        resQuantity.data.forEach(item => {
+          if (item.locationCode === '鍗婃垚鍝�') {
+            const date = new Date(item.recordTime || item.recordDate);
+            const formattedDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
+            const dateIndex = dates.indexOf(formattedDate);
+            if (dateIndex !== -1) {
+              semiData[dateIndex] = item.quantity;
+            }
+          }
+        });
+      }
+
+      // 澶勭悊搴撲綅鏁版嵁
+      if (resWareHouse.data) {
+        resWareHouse.data.forEach(item => {
+          const dateIndex = dates.indexOf(item.date);
+          if (dateIndex !== -1) {
+            if (item.warehouse === '7014') {
+              data7014[dateIndex] = item.count;
+            } else if (item.warehouse === '7016') {
+              data7016[dateIndex] = item.count;
+            }
+          }
+        });
+      }
+
+      // 鏇存柊鍥捐〃鏁版嵁
+      quantityData.value = {
+        semiData,
+        data7014,
+        data7016
+      };
+
       updateOptionQuantity(quantityTarget1.value, quantityTarget2.value, quantityTarget3.value);
     }
   } catch (error) {
@@ -207,7 +273,8 @@
   const dates = [];
   for (let i = 1; i <= daysInMonth; i++) {
     const date = new Date(currentYear, currentMonth, i);
-    const formattedDate = `${date.getFullYear()}-${date.getMonth() + 1}-${i}`;
+    // 淇敼鏃ユ湡鏍煎紡涓� YYYY-MM-DD
+    const formattedDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(i).padStart(2, '0')}`;
     dates.push(formattedDate);
   }
 
@@ -236,7 +303,7 @@
   // 鐢熸垚褰撴湀鎵�鏈夋棩鏈熺殑鏁扮粍
   const dates = [];
   for (let d = new Date(firstDayOfMonth); d <= lastDayOfMonth; d.setDate(d.getDate() + 1)) {
-    dates.push(`${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`);
+    dates.push(`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`);
   }
   const daysInMonth = dates.length;
 
@@ -251,16 +318,15 @@
   // 鏍规嵁API杩斿洖鐨勬暟鎹粨鏋勮繘琛屽垎缁勫鐞�
   sortedData.forEach(item => {
     const date = new Date(item.recordTime);
-    const formattedDate = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
+    const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
     const dateIndex = dates.indexOf(formattedDate);
     if (dateIndex !== -1) {
-      // 鏍规嵁type瀛楁鍖哄垎骞虫柟鍜岀墖鏁�
       if (item.type === '骞虫柟') {
-        squareData[dateIndex] = item.value;
-        totalSquare += item.value || 0;
+        squareData[dateIndex] = Number(item.value) || 0;
+        totalSquare += Number(item.value) || 0;
       } else if (item.type === '鐗囨暟') {
-        pieceData[dateIndex] = item.value;
-        totalPieces += item.value || 0;
+        pieceData[dateIndex] = Number(item.value) || 0;
+        totalPieces += Number(item.value) || 0;
       }
     }
   });
@@ -273,7 +339,9 @@
   if (textDay && textprice && textarea) {
     // 鏍煎紡鍖栨棩鏈熸樉绀�
     const formatDate = (date) => {
-      return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
+      const month = (date.getMonth() + 1).toString().padStart(2, '0');
+      const day = date.getDate().toString().padStart(2, '0');
+      return `${date.getFullYear()}-${month}-${day}`;
     };
 
     textDay.innerHTML = "鏃ユ湡锛�<br>" + formatDate(firstDayOfMonth) + " - " + formatDate(lastDayOfMonth);
@@ -303,16 +371,10 @@
     legend: {
       data: ['骞虫柟', '鐗囨暟'],
       icon: 'roundRect',
-      // x:'left',
-      // y:'center',
-      // orient: 'vertical', 
       textStyle: {
         fontSize: 20,
         fontWeight: 'bold',
-        color: 'white',
-        formatter: function (name) {
-          return '{vertical|' + name.split('').join('\n') + '}';
-        }
+        color: 'white'
       }
     },
     grid: [
@@ -368,7 +430,6 @@
         gridIndex: 0,
         axisLabel: {
           fontSize: 20,
-          formatter: '{value} ',
           color: 'white',
           show: false
         },
@@ -381,7 +442,6 @@
         gridIndex: 1,
         axisLabel: {
           fontSize: 20,
-          formatter: '{value} ',
           color: 'white',
           show: false
         },
@@ -444,20 +504,13 @@
     ]
   };
 
-  // 缁樺埗鍥捐〃
-  // const chartDom = document.getElementById('drawLineChart_day51');
-  // if (chartDom) {
-  //   const chart = echarts.init(chartDom);
-  //   chart.setOption(OptionDayMode);
-  //   charts.push(chart);
-  // }
-  draw('drawLineChart_day51', OptionDayMode)
+  draw('drawLineChart_day51', OptionDayMode);
 }
 
 const updateOptionYield = (targetValue1, targetValue2) => {
   // 鎸夋棩鏈熸帓搴忓苟澶勭悊鏁版嵁
   const sortedData = [...yieldData.value].sort((a, b) =>
-    new Date(a.recordTime) - new Date(b.recordTime)
+    new Date(a.date) - new Date(b.date)
   );
 
   // 鑾峰彇褰撴湀鏃ユ湡鏁扮粍
@@ -469,15 +522,12 @@
 
   // 涓烘瘡涓棩鏈熷噯澶囨暟鎹�
   sortedData.forEach(item => {
-    const date = new Date(item.recordTime);
-    const formattedDate = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
+    const date = new Date(item.date);
+    const formattedDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
     const dateIndex = dates.indexOf(formattedDate);
     if (dateIndex !== -1) {
-      if (item.lineNo === '涓�绾�') {
-        line1Data[dateIndex] += item.yieldvalue;
-      } else if (item.lineNo === '浜岀嚎') {
-        line2Data[dateIndex] += item.yieldvalue;
-      }
+      line1Data[dateIndex] = Number(item.line1HourlyAvg || 0);
+      line2Data[dateIndex] = Number(item.line2HourlyAvg || 0);
     }
   });
 
@@ -621,7 +671,8 @@
         label: {
           show: true,
           fontSize: 20,
-          color: 'white'
+          color: 'white',
+          formatter: '{c}'  // 鏄剧ず鏁板��
         },
         areaStyle: {
           color: '#000000',
@@ -661,7 +712,8 @@
         label: {
           show: true,
           fontSize: 20,
-          color: 'white'
+          color: 'white',
+          formatter: '{c}'  // 鏄剧ず鏁板��
         },
         areaStyle: {
           color: 'white',
@@ -685,12 +737,6 @@
     ]
   };
 
-  // const chartDom = document.getElementById('drawLineChart_yield');
-  // if (chartDom) {
-  //   const chart = echarts.init(chartDom);
-  //   chart.setOption(OptionYield);
-  //   charts.push(chart);
-  // }
   draw('drawLineChart_yield', OptionYield)
 }
 
@@ -710,7 +756,7 @@
   // 涓烘瘡涓棩鏈熷噯澶囨暟鎹�
   sortedData.forEach(item => {
     const date = new Date(item.recordTime || item.recordDate);
-    const formattedDate = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
+    const formattedDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
     const dateIndex = dates.indexOf(formattedDate);
     if (dateIndex !== -1) {
       if (item.lineNo === '鏍囧噯') {
@@ -768,22 +814,6 @@
         color: 'white'
       }
     },
-    // toolbox: {
-    //   show: true,
-    //   itemSize: 20,
-    //   iconStyle: {
-    //     borderColor: 'white'
-    //   },
-    //   feature: {
-    //     dataZoom: {
-    //       yAxisIndex: 'none'
-    //     },
-    //     dataView: { readOnly: false },
-    //     magicType: { type: ['line', 'bar'] },
-    //     restore: {},
-    //     saveAsImage: {}
-    //   },
-    // },
     grid: [{
       left: '5%',
       right: '1%',
@@ -949,46 +979,18 @@
     ]
   };
 
-  // const chartDom = document.getElementById('drawLineChart_utilization');
-  // if (chartDom) {
-  //   const chart = echarts.init(chartDom);
-  //   chart.setOption(OptionUtilization);
-  //   charts.push(chart);
-  // }
   draw('drawLineChart_utilization', OptionUtilization);
 
 }
 
 const updateOptionQuantity = (targetValue1, targetValue2, targetValue3) => {
-  // 鎸夋棩鏈熸帓搴忓苟澶勭悊鏁版嵁
-
-  const sortedData = [...quantityData.value].sort((a, b) =>
-    new Date(a.recordTime || a.recordDate) - new Date(b.recordTime || b.recordDate)
-  );
-
   // 鑾峰彇褰撴湀鏃ユ湡鏁扮粍
   const { dates, daysInMonth } = generateMonthDates();
 
-  // 鍒嗙鍚勫簱浣嶆暟鎹�
-  const semiData = Array(daysInMonth).fill(0);
-  const data7014 = Array(daysInMonth).fill(0);
-  const data7016 = Array(daysInMonth).fill(0);
-
-  // 涓烘瘡涓棩鏈熷噯澶囨暟鎹�
-  sortedData.forEach(item => {
-    const date = new Date(item.recordTime || item.recordDate);
-    const formattedDate = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
-    const dateIndex = dates.indexOf(formattedDate);
-    if (dateIndex !== -1) {
-      if (item.locationCode === '鍗婃垚鍝�') {
-        semiData[dateIndex] = item.quantity;
-      } else if (item.locationCode === '7014') {
-        data7014[dateIndex] = item.quantity;
-      } else if (item.locationCode === '7016') {
-        data7016[dateIndex] = item.quantity;
-      }
-    }
-  });
+  // 浣跨敤quantityData涓殑鏁版嵁
+  const semiData = quantityData.value?.semiData || Array(daysInMonth).fill(0);
+  const data7014 = quantityData.value?.data7014 || Array(daysInMonth).fill(0);
+  const data7016 = quantityData.value?.data7016 || Array(daysInMonth).fill(0);
 
   // 鍦ㄥ埗閲忕殑閰嶇疆 - 涓婁腑涓嬩笁灞傚竷灞�
   const OptionQuantity = {
@@ -1283,15 +1285,11 @@
     ]
   };
 
-  // const chartDom = document.getElementById('drawLineChart_quantity');
-  // if (chartDom) {
-  //   const chart = echarts.init(chartDom);
-  //   chart.setOption(OptionQuantity);
-  //   charts.push(chart);
-  // }
   draw('drawLineChart_quantity', OptionQuantity);
 }
 
+let refreshInterval = null
+let checkTargetsInterval = null
 
 onMounted(() => {
   setScale()
@@ -1317,7 +1315,7 @@
       await loadPlannedData()
 
       // 璁剧疆瀹氭椂鍒锋柊鏁版嵁
-      const refreshInterval = setInterval(async () => {
+      refreshInterval = setInterval(async () => {
         try {
           await loadYieldData()
           await loadUtilizationData()
@@ -1330,7 +1328,7 @@
       }, 15000) // 姣�15绉掑埛鏂颁竴娆�
 
       // 娣诲姞鐩戝惉localStorage鍙樺寲鐨勫畾鏃跺櫒
-      const checkTargetsInterval = setInterval(() => {
+      checkTargetsInterval = setInterval(() => {
         const newYieldTarget1 = Number(localStorage.getItem('yieldTarget1'))
         const newYieldTarget2 = Number(localStorage.getItem('yieldTarget2'))
         const newUtilizationTarget1 = Number(localStorage.getItem('utilizationTarget1'))
@@ -1360,10 +1358,6 @@
         }
       }, 1000) // 姣忕妫�鏌ヤ竴娆�
 
-      onUnmounted(() => {
-        clearInterval(refreshInterval)
-        clearInterval(checkTargetsInterval)
-      })
     } catch (error) {
       console.error('鍒濆鍖栨暟鎹け璐�:', error)
     }
@@ -1371,7 +1365,19 @@
 })
 
 onUnmounted(() => {
+  // 娓呯悊浜嬩欢鐩戝惉鍣�
   window.removeEventListener('resize', handleResize)
+  
+  // 娓呯悊瀹氭椂鍣�
+  if (refreshInterval) {
+    clearInterval(refreshInterval)
+    refreshInterval = null
+  }
+  if (checkTargetsInterval) {
+    clearInterval(checkTargetsInterval)
+    checkTargetsInterval = null
+  }
+  
   // 娓呯悊鎵�鏈夊浘琛ㄥ疄渚�
   charts.forEach(chart => {
     if (chart && !chart.isDisposed()) {

--
Gitblit v1.8.0