haoxuan
2023-12-05 cd388c78650efe85fe4dd41cc439208d58ab6c29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<template>
  <BackgroundBoardLayout>
    <template #leftBlock1>
      <StatisticalBox :all-list="allList"></StatisticalBox>
    </template>
    <template #leftBlock2>
      <MachineStartupRate
        ref="leftBlock2"
        :startup-rate="startupRateString"
      ></MachineStartupRate>
    </template>
    <template #leftBlock3>
      <CountView :total-object="totalObject"></CountView>
    </template>
    <template #leftBlock4>
      <OrderCompleteRadio
        :order-complete-object="orderCompleteObject"
      ></OrderCompleteRadio>
    </template>
    <template #leftBlock5>
      <WorkOrderProgress :table-data="workOrderData"></WorkOrderProgress>
    </template>
    <template #leftBlock6>
      <PerSonnelProductivity></PerSonnelProductivity>
    </template>
    <template #rightBlock1>
      <DeviceChart ref="rightBlock1" :chartData="deviceChartData"></DeviceChart>
    </template>
    <template #rightBlock2>
      <MaterialChart></MaterialChart>
    </template>
    <template #rightBlock3>
      <BarChart></BarChart>
    </template>
  </BackgroundBoardLayout>
</template>
 
<script>
import StatisticalBox from "@/views/cockpitPage/components/StatisticalBox";
import MachineStartupRate from "@/views/cockpitPage/components/MachineStartupRate";
import CountView from "@/views/cockpitPage/components/CountView";
import BackgroundBoardLayout from "@/components/cockpitPage/BackgroundBoardLayout.vue";
import PerSonnelProductivity from "@/views/cockpitPage/components/PerSonnelProductivity.vue";
import DeviceChart from "@/views/cockpitPage/components/DeviceChart.vue";
import MaterialChart from "@/views/cockpitPage/components/MaterialChart.vue";
import BarChart from "@/views/cockpitPage/components/BarChart.vue";
import OrderCompleteRadio from "@/views/cockpitPage/components/OrderCompleteRadio";
import WorkOrderProgress from "@/views/cockpitPage/components/WorkOrderProgress";
import { getDashboard } from "@/api/cockpitPage/index";
export default {
  components: {
    StatisticalBox,
    BackgroundBoardLayout,
    PerSonnelProductivity,
    DeviceChart,
    MaterialChart,
    BarChart,
    MachineStartupRate,
    CountView,
    OrderCompleteRadio,
    WorkOrderProgress,
  },
  props: {},
  data() {
    return {
      // 左上数据统计数据
      allList: [
        { value: 0, label: "开机台数" },
        { value: 0, label: "总产量" },
        { value: 0, label: "生产工单数" },
        { value: 0, label: "延期交付" },
        { 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,
    };
  },
  mounted() {
    this.getDashboard();
    // setInterval(() => {
    //   this.getDashboard();
    // }, 30000);
  },
  watch: {},
  methods: {
    async getDashboard() {
      await getDashboard().then((res) => {
        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);
      }).finally(()=>{
        setTimeout(()=>{
          this.getDashboard()
        },30000)
      });
    },
    // 处理左上数据
    setLeftBlock1(data) {
      this.allList.map((item) => {
        if (item.label === "开机台数") {
          item.value = data?.DeviceRunningAmount ?? 0;
        } else if (item.label === "总产量") {
          item.value = data?.TotalProductionAmount ?? 0;
        } else if (item.label === "生产工单数") {
          item.value = data?.WorkOrderAmount ?? 0;
        } else if (item.label === "延期交付") {
          item.value = data?.DelayWorkOrderAmount ?? 0;
        } else if (item.label === "物料不足") {
          item.value = data?.MaterialMissWorkOrderAmount ?? 0;
        } else if (item.label === "计划达成率") {
          item.value =
            typeof data?.PlanOrderFinishRate === "string"
              ? parseFloat(
                  data?.PlanOrderFinishRate.length > 0
                    ? data?.PlanOrderFinishRate
                    : "0"
                )
              : data?.PlanOrderFinishRate ?? 0;
        }
      });
    },
    // 机器开机率数据
    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 = {
        InternalDeviceRunningAmount: data?.InternalDeviceRunningAmount ?? 0,
        ExternalDeviceRunningAmount: data?.ExternalDeviceRunningAmount ?? 0,
        OutPlanProductionAmount: data?.OutPlanProductionAmount ?? 0,
        PlanProductionAmount: data?.PlanProductionAmount ?? 0,
        RealExternalProductionAmount: data?.RealExternalProductionAmount ?? 0,
        RealProductionAmount: data?.RealProductionAmount ?? 0,
      };
    },
    // 订单完成比率
    setLeftBlock4(data) {
      this.orderCompleteObject.startIndex = 0;
      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);
    },
  },
};
</script>
 
<style scoped lang="scss"></style>