From 8d1a8a22ff13bab740ff3c427eb531fd6ce97844 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期二, 05 十二月 2023 15:26:12 +0800
Subject: [PATCH] 机器开机率、工单进度统计、设备负荷比接口联调

---
 src/views/cockpitPage/index.vue |  134 ++++++++++++++++++++++++++++++--------------
 1 files changed, 92 insertions(+), 42 deletions(-)

diff --git a/src/views/cockpitPage/index.vue b/src/views/cockpitPage/index.vue
index 449e7a8..286e86a 100644
--- a/src/views/cockpitPage/index.vue
+++ b/src/views/cockpitPage/index.vue
@@ -4,7 +4,10 @@
       <StatisticalBox :all-list="allList"></StatisticalBox>
     </template>
     <template #leftBlock2>
-      <MachineStartupRate></MachineStartupRate>
+      <MachineStartupRate
+        ref="leftBlock2"
+        :startup-rate="startupRateString"
+      ></MachineStartupRate>
     </template>
     <template #leftBlock3>
       <CountView :total-object="totalObject"></CountView>
@@ -15,13 +18,13 @@
       ></OrderCompleteRadio>
     </template>
     <template #leftBlock5>
-      <WorkOrderProgress></WorkOrderProgress>
+      <WorkOrderProgress :table-data="workOrderData"></WorkOrderProgress>
     </template>
     <template #leftBlock6>
       <PerSonnelProductivity></PerSonnelProductivity>
     </template>
     <template #rightBlock1>
-      <DeviceChart></DeviceChart>
+      <DeviceChart ref="rightBlock1" :chartData="deviceChartData"></DeviceChart>
     </template>
     <template #rightBlock2>
       <MaterialChart></MaterialChart>
@@ -69,12 +72,26 @@
         { value: 0, label: "鐗╂枡涓嶈冻" },
         { value: 0, label: "璁″垝杈炬垚鐜�" },
       ],
+      // 鏈哄櫒寮�鏈虹巼
+      startupRate: {
+        Total: 0, // 鎬绘満鍣ㄦ暟
+        Running: 0, // 寮�鏈哄彴鏁�
+        Maintenance: 0, // 缁翠慨涓澶囨暟
+      },
+      startupRateString: "0", // 寮�鏈虹巼
       // 宸︿腑鏁版嵁缁熻瀵硅薄
       totalObject: {},
       // 璁㈠崟瀹屾垚姣旂巼
       orderCompleteObject: {
         startIndex: 0,
         orderCompleteList: [],
+      },
+      // 宸ュ崟杩涘害缁熻
+      workOrderData: [],
+      // 璁惧璐熻嵎瀵规瘮
+      deviceChartData: {
+        datax: [],
+        datay: [],
       },
       dataindex: 0,
     };
@@ -83,7 +100,7 @@
     this.getDashboard();
     setInterval(() => {
       this.getDashboard();
-    }, 300000);
+    }, 30000);
   },
   watch: {},
   methods: {
@@ -92,10 +109,16 @@
         console.log(res);
         // 宸︿笂鏁板�肩粺璁℃暟鎹�
         this.setLeftBlock1(res.data);
+        // 鏈哄櫒寮�鏈虹巼鏁版嵁
+        this.setleftBlock2(res.data);
         //  宸︿腑鏁版嵁缁熻鍊�
         this.setLeftBlock3(res.data);
         // 璁㈠崟瀹屾垚姣旂巼
         this.setLeftBlock4(res.data);
+        // 宸ュ崟杩涘害缁熻
+        this.setLeftBlock5(res.data);
+        // 璁惧璐熻嵎瀵规瘮
+        this.setRightBlock1(res.data);
       });
     },
     // 澶勭悊宸︿笂鏁版嵁
@@ -123,6 +146,28 @@
         }
       });
     },
+    // 鏈哄櫒寮�鏈虹巼鏁版嵁
+    setleftBlock2(data) {
+      this.startupRate = {
+        Total: data?.TotalDeviceAmount ?? 0,
+        Running: data?.DeviceRunningAmount ?? 0,
+        Maintenance: data?.InMaintenanceDeviceAmount ?? 0,
+      };
+      // 寮�鏈虹巼
+      let setsInUse = (this.startupRate.Running / this.startupRate.Total) * 100;
+      this.startupRateString = setsInUse.toFixed(1).toString();
+      // 缁翠慨鐜�
+      let maintenanceRate =
+        (this.startupRate.Maintenance / this.startupRate.Total) * 100;
+      // 闂茬疆鐜�
+      let idle = 100 - setsInUse - maintenanceRate;
+      let chartData = [
+        { value: idle.toFixed(1), name: "闂茬疆" },
+        { value: maintenanceRate.toFixed(1), name: "缁翠慨" },
+        { value: setsInUse.toFixed(1), name: "宸ヤ綔" },
+      ];
+      this.$refs.leftBlock2.pieChart("chart", chartData);
+    },
     // 宸︿腑鏁版嵁缁熻鍊�
     setLeftBlock3(data) {
       this.totalObject = {
@@ -137,44 +182,49 @@
     // 璁㈠崟瀹屾垚姣旂巼
     setLeftBlock4(data) {
       this.orderCompleteObject.startIndex = 0;
-      // 姝ゅ鍚庨潰浼氭浛鎹㈡垚鐪熷疄鍚庣杩斿洖鏁版嵁
-      if (this.dataindex == 1) {
-        this.orderCompleteObject.orderCompleteList = [
-          { title: "SSSSDD19070047", radio: 20.6 },
-          { title: "SDD19070048", radio: 79 },
-          { title: "SDD19070049", radio: 100 },
-          { title: "SDD19070050", radio: 30 },
-          { title: "DD19070047", radio: 20.6 },
-          { title: "DD19070048", radio: 49 },
-          { title: "DD19070049", radio: 60 },
-          { title: "SSDD19070050", radio: 10 },
-          { title: "SDD19070047", radio: 33.6 },
-          { title: "DD19070048", radio: 69 },
-          { title: "SDD19070049", radio: 70 },
-          { title: "DD19070050", radio: 20 },
-          { title: "SDD19070047", radio: 66.6 },
-          { title: "DD19070048", radio: 46 },
-        ];
-        this.dataindex = 0;
-      } else {
-        this.orderCompleteObject.orderCompleteList = [
-          { title: "fffffDD19070047", radio: 50.6 },
-          { title: "DD19070043", radio: 89 },
-          { title: "DD15566649", radio: 100 },
-          { title: "ASD5555550", radio: 30 },
-          { title: "DD19070047", radio: 30.6 },
-          { title: "DD19070048", radio: 49 },
-          { title: "DD19070049", radio: 60 },
-          { title: "DD19070050", radio: 10 },
-          { title: "DD19070047", radio: 33.6 },
-          { title: "DD19070048", radio: 69 },
-          { title: "DD19070049", radio: 70 },
-          { title: "DD19070050", radio: 20 },
-          { title: "DD19070047", radio: 66.6 },
-          { title: "DD19070048", radio: 96 },
-        ];
-        this.dataindex = 1;
-      }
+      this.orderCompleteObject.orderCompleteList = [];
+      let list = data.OrderFinishRate.map((item) => {
+        return {
+          title: item.Name,
+          radio: parseFloat(item.Value),
+        };
+      });
+      this.orderCompleteObject.orderCompleteList = list;
+    },
+    // 宸ュ崟杩涘害缁熻
+    setLeftBlock5(data) {
+      let list = data.WorkOrderStats.map((item) => {
+        let completeProgerss = [];
+        for (let i = 0; i < item.ProcedureNum; i++) {
+          let status = 0;
+          if (i < item.FinishProcedureNum) {
+            status = 1;
+          } else if (
+            i >= item.FinishProcedureNum &&
+            i < item.FinishProcedureNum + item.ProcessingProcedureNum
+          ) {
+            status = 2;
+          } else {
+            status = 0;
+          }
+          completeProgerss.push({ status: status });
+        }
+        return {
+          ...item,
+          completeProgerss: completeProgerss,
+        };
+      });
+      this.workOrderData = list;
+    },
+    // 璁惧璐熻嵎瀵规瘮
+    setRightBlock1(data) {
+      this.deviceChartData.datax = [];
+      this.deviceChartData.datay = [];
+      data.DeviceLoad.map((item) => {
+        this.deviceChartData.datax.push(item.Name);
+        this.deviceChartData.datay.push(parseFloat(item.Value));
+      });
+      // this.$refs.rightBlock1.pieChart("chart", this.deviceChartData);
     },
   },
 };

--
Gitblit v1.8.0