车间能级提升-智能设备管理系统
baoshiwei
2025-07-11 1524fa42ddf01fd72207a8a4b4667a48e4f233aa
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<template>
  <Page :auto-content-height="true" :padding="false" class="p-0" content-class="flex flex-col w-full gap-4">
    <div class="p-5">
 
      <!-- 设备健康状态可视化 -->
      <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
        <Card title="设备健康度评分" >
          <!-- 这里将放置健康度分布图表 -->
          <div ref="chartRef" class="h-64 w-full"></div>
        </Card>
        <Card title="关键指标" >
          <div class="grid grid-cols-2 gap-2">
            <div class="p-2 bg-blue-50 rounded">
              <p class="text-sm text-gray-600">健康设备</p>
              <p class="text-xl font-bold">85%</p>
            </div>
            <div class="p-2 bg-yellow-50 rounded">
              <p class="text-sm text-gray-600">预警设备</p>
              <p class="text-xl font-bold">12%</p>
            </div>
            <div class="p-2 bg-red-50 rounded">
              <p class="text-sm text-gray-600">故障设备</p>
              <p class="text-xl font-bold">3%</p>
            </div>
            <div class="p-2 bg-green-50 rounded">
              <p class="text-sm text-gray-600">维护完成</p>
              <p class="text-xl font-bold">92%</p>
            </div>
            <div class="p-2 bg-blue-50 rounded">
              <p class="text-sm text-gray-600">待处理工单</p>
              <p class="text-xl font-bold">{{ healthData.pendingWorkOrders }}</p>
            </div>
            <div class="p-2 bg-yellow-50 rounded">
              <p class="text-sm text-gray-600">备件库存预警</p>
              <p class="text-xl font-bold">{{ healthData.sparePartWarnings }}</p>
            </div>
          </div>
        </Card>
      </div>
 
      <!-- 故障预测与预警 -->
      <Card title="故障预测与预警" class="mb-6">
        <div class="grid grid-cols-1 gap-4">
 
            <!-- 这里将放置预警表格 -->
            <Table :columns="warningColumns" :data-source="warningData" :pagination="false" class="w-full">
              <template #bodyCell="{ column, record }">
                <template v-if="column.key === 'status'">
                  <a-tag :color="getStatusColor(record.status)">
                    {{ record.status }}
                  </a-tag>
                </template>
                <template v-else-if="column.key === 'action'">
                  <a-button type="link" @click="handleDetail(record)">详情</a-button>
                  <a-button type="link" @click="generateWorkOrder(record)" :disabled="record.maintenanceSuggestion === '暂无建议'">生成工单</a-button>
                </template>
              </template>
            </Table>
          </div>
 
      </Card>
 
      <!-- 备件信息 -->
      <div class="grid grid-cols-2 gap-4 mb-6">
        <!-- 设备部件寿命预测 -->
        <Card title="设备部件寿命预测">
          <Table :columns="lifePredictionColumns" :data-source="lifePredictionData" :pagination="false" class="w-full">
            <template #bodyCell="{ column, record }">
              <template v-if="column.key === 'lifeStatus'">
                <a-tag :color="getLifeStatusColor(record.remainingDays)">
                  {{ getLifeStatus(record.remainingDays) }}
                </a-tag>
              </template>
              <template v-else-if="column.key === 'action'">
                <a-button type="link" @click="showLifePredictionDetail(record)">详情</a-button>
              </template>
            </template>
          </Table>
        </Card>
 
        <!-- 备件库存与预警 -->
        <Card title="备件库存与预警">
          <Table :columns="sparePartColumns" :data-source="sparePartData" :pagination="false" class="w-full">
            <template #bodyCell="{ column, record }">
              <template v-if="column.key === 'stockStatus'">
                <a-tag :color="getStockStatusColor(record.currentStock, record.safetyStock)">
                  {{ getStockStatus(record.currentStock, record.safetyStock) }}
                </a-tag>
              </template>
              <template v-else-if="column.key === 'action'">
                <a-button type="link" @click="showSparePartDetail(record)">详情</a-button>
              </template>
            </template>
          </Table>
        </Card>
      </div>
 
 
    </div>
  </Page>
</template>
 
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { Button, Card, Form, Input, message, Select, Table, Tag } from 'ant-design-vue';
import * as echarts from 'echarts';
 
const chartRef = ref<HTMLElement | null>(null);
 
const healthData = {
  healthy: 85,
  warning: 12,
  critical: 3,
  maintained: 92,
  pendingWorkOrders: 5, // 模拟待处理工单数
  sparePartWarnings: 2, // 模拟备件库存预警数
};
 
// 高风险设备预警数据
const warningColumns = [
  { title: '设备名称', dataIndex: 'name', key: 'name' },
 
  { title: '关键部件', dataIndex: 'component', key: 'component' },
  { title: '风险指标', dataIndex: 'indicator', key: 'indicator' },
  { title: '当前值', dataIndex: 'value', key: 'value' },
  { title: '阈值', dataIndex: 'threshold', key: 'threshold' },
  { title: '状态', dataIndex: 'status', key: 'status' },
  { title: '维护建议', dataIndex: 'maintenanceSuggestion', key: 'maintenanceSuggestion' },
  { title: '操作', key: 'action' },
];
 
// 模拟高风险设备数据
const warningData = ref([
  {
    key: '1',
    name: 'SMT贴片机',
    type: 'SMT机器',
    component: '左3-Head',
    indicator: '真空压力',
    value: 32,
    threshold: 35,
    status: '中风险',
    maintenanceSuggestion: '真空压力值低于设定值,建议检查或更换吸嘴',
    maintenanceType: '预防性维护',
  },
  {
    key: '2',
    name: 'CNC加工中心',
    type: 'CNC',
    component: '主轴',
    indicator: '温度',
    value: 85,
    threshold: 80,
    status: '中风险',
    maintenanceSuggestion: '建议对主轴进行润滑保养并检查冷却系统',
    maintenanceType: '润滑维护',
  },
  {
    key: '3',
    name: '注塑机',
    type: '注塑设备',
    component: '液压系统',
    indicator: '射出压力不稳定',
    value: 28,
    threshold: 30,
    status: '低风险',
    maintenanceSuggestion: '建议检查液压系统密封件',
    maintenanceType: '检查维护',
  },
  // {
  //   key: '4',
  //   name: '空压机',
  //   type: '空气压缩机',
  //   component: '电机',
  //   indicator: '电流',
  //   value: 49,
  //   threshold: 50,
  //   status: '低风险',
  //   maintenanceSuggestion: '暂无建议',
  //   maintenanceType: '无',
  // },
]);
 
// 备件库存数据
const sparePartColumns = [
  { title: '备件名称', dataIndex: 'name', key: 'name' },
  { title: '当前库存', dataIndex: 'currentStock', key: 'currentStock' },
  { title: '安全库存', dataIndex: 'safetyStock', key: 'safetyStock' },
  { title: '预测需求', dataIndex: 'predictedDemand', key: 'predictedDemand' },
  { title: '库存状态', dataIndex: 'stockStatus', key: 'stockStatus' },
];
 
// 模拟备件数据
const sparePartData = ref([
  {
    key: '1',
    name: '传送带轴承',
    currentStock: 10,
    safetyStock: 15,
    predictedDemand: 8,
  },
  {
    key: '2',
    name: '主轴润滑油',
    currentStock: 2,
    safetyStock: 3,
    predictedDemand: 1,
  },
  {
    key: '3',
    name: '液压系统密封件',
    currentStock: 20,
    safetyStock: 25,
    predictedDemand: 5,
  },
  {
    key: '4',
    name: '电机碳刷',
    currentStock: 8,
    safetyStock: 10,
    predictedDemand: 2,
  },
]);
const getStatusColor = (status) => {
  switch (status) {
    case '高风险': return 'red';
    case '中风险': return 'orange';
    case '低风险': return 'yellow';
    default: return 'green';
  }
};
 
 
 
// 工单表单数据
const workOrderForm = ref({
  type: '',
  equipment: '',
  content: '',
  priority: 'medium',
});
 
const selectedMaintenance = ref(null);
 
const lifePredictionColumns = [
  { title: '设备名称', dataIndex: 'deviceName', key: 'deviceName' },
  { title: '部位名称', dataIndex: 'componentName', key: 'componentName' },
  { title: '部件名称', dataIndex: 'name', key: 'name' },
  { title: '预测寿命 (天)', dataIndex: 'predictedLife', key: 'predictedLife' },
  { title: '剩余寿命 (天)', dataIndex: 'remainingDays', key: 'remainingDays' },
  { title: '状态', dataIndex: 'lifeStatus', key: 'lifeStatus' },
  { title: '操作', dataIndex: 'action', key: 'action' },
];
 
const lifePredictionData = ref([
    { key: '4', deviceName: '空压机', componentName: '电机', name: '传感器', predictedLife: 500, remainingDays: 10 },
      { key: '2', deviceName: 'CNC加工中心', componentName: '主轴', name: '齿轮', predictedLife: 730, remainingDays: 30 },
  { key: '1', deviceName: 'SMT贴片机', componentName: '传送带', name: '轴承', predictedLife: 365, remainingDays: 50 },
 
  { key: '3', deviceName: '注塑机', componentName: '液压系统', name: '滤芯', predictedLife: 180, remainingDays: 90 },
 
  { key: '5', deviceName: '焊接机器人', componentName: '焊枪', name: '焊嘴', predictedLife: 240, remainingDays: 60 }
]);
 
const getLifeStatus = (remainingDays) => {
  if (remainingDays <= 30) {
    return '即将到期';
  } else if (remainingDays <= 90) {
    return '中期预警';
  } else {
    return '寿命充足';
  }
};
 
const getLifeStatusColor = (remainingDays) => {
  if (remainingDays <= 30) {
    return 'red';
  } else if (remainingDays <= 90) {
    return 'orange';
  } else {
    return 'green';
  }
};
 
const showLifePredictionDetail = (record) => {
  message.info(`备件名称: ${record.name}, 预测寿命: ${record.predictedLife}天, 剩余寿命: ${record.remainingDays}天`);
};
 
 
 
const getStockStatus = (currentStock, safetyStock) => {
  if (currentStock <= safetyStock) {
    return '库存预警';
  } else {
    return '库存充足';
  }
};
 
const getStockStatusColor = (currentStock, safetyStock) => {
  if (currentStock <= safetyStock) {
    return 'red';
  } else {
    return 'green';
  }
};
 
const showSparePartDetail = (record) => {
  message.info(`备件名称: ${record.name}, 当前库存: ${record.currentStock}, 安全库存: ${record.safetyStock}, 预测需求: ${record.predictedDemand}`);
};
 
const generateWorkOrder = (record) => {
  selectedMaintenance.value = record;
  workOrderForm.value = {
    type: record.maintenanceType,
    equipment: record.name,
    content: record.maintenanceSuggestion,
    priority: 'medium',
  };
};
 
const submitWorkOrder = () => {
  console.log('提交工单:', workOrderForm.value);
  // 这里可以添加工单提交逻辑
  message.success('工单提交成功');
  selectedMaintenance.value = null;
  workOrderForm.value = {
    type: '',
    equipment: '',
    content: '',
    priority: 'medium',
  };
};
 
import { useRouter } from 'vue-router';
 
const router = useRouter();
 
const handleDetail = (record) => {
  // 根据设备名称不同跳转不同的详情页面
  if (record.name === 'SMT贴片机') {
    console.log('设备ID111:', record.name)
    router.push({ path: '/predictive/smt-detail', query: { deviceId: record.key } });
  } else if (record.name === 'CNC加工中心') {
    router.push({ path: '/predictive/cnc-detail', query: { deviceId: record.key } });
  } else if (record.name === '注塑机') {
    router.push({ path: '/predictive/injection-detail', query: { deviceId: record.key } });
  } else {
    router.push({ path: '/predictive/air-compressor-detail', query: { deviceId: record.key } });
  }
};
 
onMounted(() => {
  if (chartRef.value) {
    const myChart = echarts.init(chartRef.value);
    const option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      xAxis: {
        type: 'category',
        data: ['10分', '9分', '8分', '7分', '6分', '5分', '4分', '3分', '2分', '1分'],
        
      },
      yAxis: {
        type: 'value',
        name: '设备数量',
        minInterval: 1
      },
      series: [
        {
          name: '设备数量',
          type: 'bar',
          barWidth: '60%',
          data: [
            { value: 48, itemStyle: { color: '#52c41a' } },
            { value: 53, itemStyle: { color: '#52c41a' } },
            { value: 37, itemStyle: { color: '#52c41a' } },
            { value: 29, itemStyle: { color: '#52c41a' } },
            { value: 21, itemStyle: { color: '#52c41a' } },
            { value: 8, itemStyle: { color: '#faad14' } },
            { value: 5, itemStyle: { color: '#faad14' } },
           
          ],
          label: {
            show: true,
            position: 'top',
            formatter: '{c}台'
          }
        }
      ]
    };
    myChart.setOption(option);
 
    // 响应式调整图表大小
    window.addEventListener('resize', () => {
      myChart.resize();
    });
  }
});
</script>
 
<style scoped>
/* 可以在这里添加组件样式 */
</style>