From b2f5c965f5278a7f40d84ef88aa92fc8f8a76ca4 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期六, 07 十一月 2026 14:27:00 +0800
Subject: [PATCH] feat: 补齐退单管理/成本分析/执行分析/远程诊断/停机报表/风险监测前端

---
 src/views/mes/dv/statistics/oee.vue |   86 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/src/views/mes/dv/statistics/oee.vue b/src/views/mes/dv/statistics/oee.vue
index 34dfd39..1e706fa 100644
--- a/src/views/mes/dv/statistics/oee.vue
+++ b/src/views/mes/dv/statistics/oee.vue
@@ -143,7 +143,63 @@
   const minutes = Math.floor(seconds / 60);
   return `${Math.floor(minutes / 60)}灏忔椂${minutes % 60}鍒�${seconds % 60}绉抈;
 }
-onMounted(() => { void load(); void loadCollect(); });
+/** ===== 鍋滄満姹囨�绘姤琛紙璺ㄨ澶囷紝鎸夐噰闆嗛棿闅旀帹绠楋級 ===== */
+interface DowntimeItem {
+  machineryId: number;
+  machineryCode: string;
+  machineryName: string;
+  deviceCode: string;
+  sampleCount: number;
+  downtimeCount: number;
+  downtimeMinutes: number;
+  intervals: { start: string; end: string; seconds: number }[];
+}
+interface DowntimeDetail {
+  startTime: string;
+  endTime: string;
+  timeoutMinutes: number;
+  totalMinutes: number;
+  downtimeMinutes: number;
+  downtimeRate: number;
+  items: DowntimeItem[];
+}
+const downtimeRange = ref<[Dayjs, Dayjs]>([dayjs().subtract(7, 'day'), dayjs()]);
+const downtimeLoading = ref(false);
+const downtimeResult = ref<DowntimeDetail>();
+const downtimeError = ref('');
+const downtimeColumns = [
+  { title: '璁惧缂栫爜', dataIndex: 'machineryCode' },
+  { title: '璁惧鍚嶇О', dataIndex: 'machineryName' },
+  { title: '鏁伴噰璁惧', dataIndex: 'deviceCode' },
+  { title: '閲囨牱鏁�', dataIndex: 'sampleCount' },
+  { title: '鍋滄満娆℃暟', dataIndex: 'downtimeCount' },
+  { title: '鍋滄満鍚堣(鍒�)', dataIndex: 'downtimeMinutes' },
+];
+
+async function loadDowntime() {
+  downtimeLoading.value = true;
+  downtimeError.value = '';
+  try {
+    const range = downtimeRange.value;
+    downtimeResult.value = await requestClient.get<DowntimeDetail>(
+      '/mes/dv/statistics/downtime',
+      {
+        params: {
+          startTime: range[0].startOf('day').format('YYYY-MM-DD HH:mm:ss'),
+          endTime: range[1].endOf('day').format('YYYY-MM-DD HH:mm:ss'),
+        },
+      },
+    );
+  } catch (e: unknown) {
+    downtimeResult.value = undefined;
+    // 淇濈暀鍚庣缁欏嚭鐨勫彲璇诲師鍥狅紙濡傝秴鍑轰繚鐣欐湡銆佸尯闂磋繃闀匡級
+    downtimeError.value = (e as Error).message || '鍋滄満鎶ヨ〃鍔犺浇澶辫触';
+  } finally {
+    downtimeLoading.value = false;
+  }
+}
+
+onMounted(() => { void load(); void loadCollect(); void loadDowntime(); });
 </script>
 
 <template>
@@ -166,6 +222,34 @@
       <Card title="璁惧鏄庣粏">
         <Table :columns="columns" :data-source="result?.items ?? []" :loading="loading" row-key="machineryId" :scroll="{ x: 1000 }" />
       </Card>
+      <Card title="鍋滄満姹囨�绘姤琛紙璺ㄨ澶囷級">
+        <template #extra>
+          <div class="flex items-center gap-2">
+            <DatePicker.RangePicker v-model:value="downtimeRange" />
+            <Button type="primary" :loading="downtimeLoading" @click="loadDowntime">鏌ヨ</Button>
+          </div>
+        </template>
+        <Alert class="mb-4" type="info" show-icon message="鎸夐噰闆嗛棿闅旇秴杩囩绾块槇鍊兼帹绠楀仠鏈猴紱閫氫俊涓柇璁″叆鍋滄満浣嗕笉鏍囪涓烘満姊版晠闅溿�傚崟娆℃渶澶氭煡璇� 31 澶╋紝涓斾笉寰楄秴鍑烘暟閲囧巻鍙蹭繚鐣欐湡銆�" />
+        <Alert v-if="downtimeError" class="mb-4" type="warning" show-icon :message="downtimeError" />
+        <template v-if="downtimeResult">
+          <Row :gutter="16" class="mb-4">
+            <Col :span="6"><Statistic title="鍋滄満鍚堣(鍒�)" :value="downtimeResult.downtimeMinutes" /></Col>
+            <Col :span="6"><Statistic title="鍋滄満鐜�" :value="downtimeResult.downtimeRate" suffix="%" /></Col>
+            <Col :span="6"><Statistic title="缁熻鍖洪棿(鍒�)" :value="downtimeResult.totalMinutes" /></Col>
+            <Col :span="6"><Statistic title="璁惧鏁�" :value="downtimeResult.items?.length ?? 0" /></Col>
+          </Row>
+          <Table :columns="downtimeColumns" :data-source="downtimeResult.items ?? []" :loading="downtimeLoading" row-key="machineryId" :scroll="{ x: 900 }" size="small" bordered>
+            <template #bodyCell="{ column, record }">
+              <template v-if="column.dataIndex === 'downtimeMinutes'">
+                {{ record.downtimeMinutes }}
+              </template>
+              <template v-else-if="column.dataIndex === 'sampleCount'">
+                {{ record.sampleCount }}
+              </template>
+            </template>
+          </Table>
+        </template>
+      </Card>
       <Card title="璁惧鏁伴噰瀹炴椂鐘舵��">
         <template #extra><Button :loading="collectLoading" @click="loadCollect">鍒锋柊</Button></template>
         <Alert v-if="collectError" type="warning" show-icon message="鏁伴噰鐘舵�佸姞杞藉け璐ワ紝璇锋鏌ユ暟閲囨湇鍔″悗閲嶈瘯銆�" class="mb-4" />

--
Gitblit v1.9.3