From bb4451860e4917b8e698c45a9bc1dcd0bedfdf42 Mon Sep 17 00:00:00 2001 From: liutao <790864623@qq.com> Date: Fri, 10 Jul 2026 17:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B6=E5=93=81=E8=BD=A6?= =?UTF-8?q?=E9=97=B4=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard1/dashboard3/index.vue | 108 ++++++++++++------ 1 file changed, 73 insertions(+), 35 deletions(-) diff --git a/src/views/report/dashboardPage/dashboard1/dashboard3/index.vue b/src/views/report/dashboardPage/dashboard1/dashboard3/index.vue index a3bdc7ba..f425ff79 100644 --- a/src/views/report/dashboardPage/dashboard1/dashboard3/index.vue +++ b/src/views/report/dashboardPage/dashboard1/dashboard3/index.vue @@ -50,7 +50,7 @@
{{ item.name }} - {{ t('AlarmBoard.alarmPrefix') }} {{ formatMinutes(item.alarmMinutes) }} + {{ t('AlarmBoard.alarmPrefix') }} {{ formatHours(item.alarmTime) }} {{ item.lastReportTime }}
@@ -67,10 +67,10 @@
{{ t('Detail.columns.deviceName') }} {{ t('Detail.columns.currentStatus') }} - {{ t('Detail.columns.runningTime') }} - {{ t('Detail.columns.standbyTime') }} - {{ t('Detail.columns.alarmTime') }} - {{ t('Detail.columns.efficiency') }} + 运行时间(小时) + 待机时间(小时) + 故障时间(小时) + 稼动率
{{ statusText[row.status] }} - {{ formatMinutes(row.runningMinutes) }} - {{ formatMinutes(row.standbyMinutes) }} - {{ formatMinutes(row.alarmMinutes) }} - {{ formatPercent(row.utilizationRate) }} + {{ formatHours(row.runningTime) }} + {{ formatHours(row.standbyTime) }} + {{ formatHours(row.alarmTime) }} + {{ formatPercentText(row.utilizationRate) }}
{{ t('Detail.empty') }}
@@ -124,6 +124,10 @@ import type { DeviceOperationOverviewRespVO, DeviceOperationOverviewTimelineRowVO } from '@/api/iot/deviceOperationOverview' +import { + DeviceOperationRecordApi, + type DeviceOperationRecordVO +} from '@/api/iot/deviceOperationRecord' import { DeviceApi, type DeviceVO } from '@/api/iot/device' import { OrganizationApi } from '@/api/mes/organization' @@ -152,10 +156,10 @@ interface DetailRow { id: string name: string status: RunStatus - runningMinutes: number - standbyMinutes: number - alarmMinutes: number - utilizationRate: number + runningTime: number + standbyTime: number + alarmTime: number + utilizationRate: string lastReportTime: string } @@ -172,6 +176,7 @@ const overviewData = ref({ timelineRows: [], totalDevices: 0 }) +const operationRecordRows = ref([]) const last24HourlyStatus = ref([]) const deviceStatusStatistics = ref({ total: 0, @@ -256,18 +261,21 @@ const statusCards = computed(() => [ ]) const detailRows = computed(() => { - return overviewData.value.timelineRows.map((row) => { - const minutes = calcMinutes(row) - const status = deviceOperatingStatusMap.value[String(row.id)] || getCurrentStatus(row) + return operationRecordRows.value.map((row) => { + const id = String(row.deviceId ?? row.id) + const status = + deviceOperatingStatusMap.value[id] || + overviewStatusMap.value[id] || + 'offline' return { - id: String(row.id), - name: row.name || '-', + id, + name: row.deviceName || '-', status, - runningMinutes: minutes.running, - standbyMinutes: minutes.standby, - alarmMinutes: minutes.fault, - utilizationRate: Number(row.utilizationRate) || 0, - lastReportTime: status === 'fault' || minutes.fault > 0 ? lastUpdateTime.value || '-' : '-' + runningTime: Number(row.totalRunningTime) || 0, + standbyTime: Number(row.totalStandbyTime) || 0, + alarmTime: Number(row.totalFaultTime) || 0, + utilizationRate: row.utilizationRate || '0%', + lastReportTime: status === 'fault' || Number(row.totalFaultTime) > 0 ? lastUpdateTime.value || '-' : '-' } }) }) @@ -288,8 +296,8 @@ const pagedRows = computed(() => { const detailPageText = computed(() => `${detailPage.value} / ${totalDetailPages.value}`) const alarmDevices = computed(() => { return detailRows.value - .filter((item) => item.status === 'fault' || item.alarmMinutes > 0) - .sort((a, b) => b.alarmMinutes - a.alarmMinutes) + .filter((item) => item.status === 'fault' || item.alarmTime > 0) + .sort((a, b) => b.alarmTime - a.alarmTime) .slice(0, 2) }) const hourlyRates = computed(() => { @@ -313,13 +321,15 @@ const sevenDayAverageRate = computed(() => average(weekTrend.value.map((item) => const formatPercent = (value?: number) => `${Number(value || 0).toFixed(1)}%` -const formatMinutes = (minutes: number) => { - const safeMinutes = Math.max(0, Math.round(minutes || 0)) - const hours = Math.floor(safeMinutes / 60) - const rest = safeMinutes % 60 - if (!hours) return t('Time.minute', { minute: rest }) - if (!rest) return t('Time.hour', { hour: hours }) - return t('Time.hourMinute', { hour: hours, minute: rest }) +const formatPercentText = (value?: string | number) => { + const text = String(value ?? '').trim() + if (!text) return '0%' + return text.includes('%') ? text : `${Number(text || 0).toFixed(1)}%` +} + +const formatHours = (hours: number) => { + const value = Number(hours || 0) + return `${Number(value.toFixed(2))}${t('Time.hour', { hour: '' }).trim()}` } const average = (values: number[]) => { @@ -421,6 +431,13 @@ const getCurrentStatus = (row: DeviceOperationOverviewTimelineRowVO): RunStatus return currentSegment?.status || row.segments?.[row.segments.length - 1]?.status || 'offline' } +const overviewStatusMap = computed(() => { + return overviewData.value.timelineRows.reduce>((acc, row) => { + acc[String(row.id)] = getCurrentStatus(row) + return acc + }, {}) +}) + const calcMinutes = (row: DeviceOperationOverviewTimelineRowVO) => { return (row.segments || []).reduce>( (acc, segment) => { @@ -473,7 +490,7 @@ const getDeviceIds = () => { return collectDeviceIdsByOrg(route.query.orgId ? String(route.query.orgId) : undefined) } -const buildParams = (startTime: string, endTime: string, pageSize = 1000) => ({ +const buildParams = (startTime: string, endTime: string, pageSize = 100) => ({ ids: getDeviceIds().join(','), startTime, endTime, @@ -525,6 +542,22 @@ const refreshTodayData = async () => { lastUpdateTime.value = dayjs().format('YYYY/M/D HH:mm:ss') } +const getOperationRecordRows = (data: any): DeviceOperationRecordVO[] => { + return Array.isArray(data) ? data : Array.isArray(data?.list) ? data.list : [] +} + +const refreshOperationRecordRows = async () => { + const { start, end } = getDayRange() + const response = await DeviceOperationRecordApi.getDeviceOperationRecordPage({ + pageNo: 1, + pageSize: 100, + ids: getDeviceIds().join(','), + startTime: start, + endTime: end + }) + operationRecordRows.value = getOperationRecordRows(response) +} + const refreshLast24HourTrend = async () => { const { start, end } = getLast24HoursRange() const response = await DeviceOperationOverviewApi.getRunOverview(buildParams(start, end)) @@ -549,7 +582,12 @@ const refreshWeekTrend = async () => { } const refreshData = async () => { - await Promise.all([refreshTodayData(), refreshDeviceStatusStatistics(), refreshLast24HourTrend()]) + await Promise.all([ + refreshTodayData(), + refreshOperationRecordRows(), + refreshDeviceStatusStatistics(), + refreshLast24HourTrend() + ]) await refreshWeekTrend() renderCharts() } @@ -619,7 +657,7 @@ const resizeCharts = () => { onMounted(async () => { updateClock() - clockTimer = window.setInterval(updateClock, 1000) + clockTimer = window.setInterval(updateClock, 100) await loadOrganizationList() await refreshData() refreshTimer = window.setInterval(() => {