From 69cf5d01dbd70e8caa3764d82c5cb77b75570423 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 14 Jun 2025 17:15:07 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90IoT=20=E7=89=A9=E8=81=94?= =?UTF-8?q?=E7=BD=91=E3=80=91=E8=AE=BE=E5=A4=87=E6=B6=88=E6=81=AF=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=9A=84=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/statistics/index.ts | 27 +- src/utils/formatTime.ts | 27 -- src/views/iot/device/device/DeviceForm.vue | 1 - .../iot/home/components/ComparisonCard.vue | 4 +- .../iot/home/components/DeviceCountCard.vue | 46 ++-- .../home/components/DeviceStateCountCard.vue | 29 +- .../iot/home/components/MessageTrendCard.vue | 258 ++++++------------ src/views/iot/home/index.vue | 49 +--- 8 files changed, 147 insertions(+), 294 deletions(-) diff --git a/src/api/iot/statistics/index.ts b/src/api/iot/statistics/index.ts index 0f88217a..cdcb94d2 100644 --- a/src/api/iot/statistics/index.ts +++ b/src/api/iot/statistics/index.ts @@ -28,19 +28,32 @@ export interface IotStatisticsDeviceMessageSummaryRespVO { downstreamCounts: TimeValueItem[] } +/** 新的消息统计数据项 */ +export interface IotStatisticsDeviceMessageSummaryByDateRespVO { + time: string + upstreamCount: number + downstreamCount: number +} + +/** 新的消息统计接口参数 */ +export interface IotStatisticsDeviceMessageReqVO { + interval: number + times?: string[] +} + // IoT 数据统计 API -export const ProductCategoryApi = { - // 查询基础的数据统计 - getIotStatisticsSummary: async () => { +export const StatisticsApi = { + // 查询全局的数据统计 + getStatisticsSummary: async () => { return await request.get({ url: `/iot/statistics/get-summary` }) }, - // 查询设备上下行消息的数据统计 - getIotStatisticsDeviceMessageSummary: async (params: { startTime: number; endTime: number }) => { - return await request.get({ - url: `/iot/statistics/get-log-summary`, + // 获取设备消息的数据统计 + getDeviceMessageSummaryByDate: async (params: IotStatisticsDeviceMessageReqVO) => { + return await request.get({ + url: `/iot/statistics/get-device-message-summary-by-date`, params }) } diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 89f40281..99eb428c 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -330,30 +330,3 @@ export function getDateRange( dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss') ] } - -/** - * 获取指定小时前的时间戳 - * @param hours 小时数 - * @returns 返回指定小时前的时间戳(毫秒) - */ -export function getHoursAgo(hours: number): number { - return dayjs().subtract(hours, 'hour').valueOf() -} - -/** - * 获取标准时间范围的时间戳 - * @param range 时间范围,支持 '8h' | '24h' | '7d' - * @returns 返回开始时间戳(毫秒) - */ -export function getTimeRangeStart(range: '8h' | '24h' | '7d'): number { - switch (range) { - case '8h': - return getHoursAgo(8) - case '24h': - return getHoursAgo(24) - case '7d': - return dayjs().subtract(7, 'day').valueOf() - default: - return dayjs().valueOf() - } -} diff --git a/src/views/iot/device/device/DeviceForm.vue b/src/views/iot/device/device/DeviceForm.vue index a66ab3c7..6c9f4594 100644 --- a/src/views/iot/device/device/DeviceForm.vue +++ b/src/views/iot/device/device/DeviceForm.vue @@ -80,7 +80,6 @@ import { DeviceApi, DeviceVO } from '@/api/iot/device/device' import { DeviceGroupApi } from '@/api/iot/device/group' import { DeviceTypeEnum, ProductApi, ProductVO } from '@/api/iot/product/product' import { UploadImg } from '@/components/UploadFile' -import { generateRandomStr } from '@/utils' /** IoT 设备表单 */ defineOptions({ name: 'IoTDeviceForm' }) diff --git a/src/views/iot/home/components/ComparisonCard.vue b/src/views/iot/home/components/ComparisonCard.vue index 4ccda660..2da729e1 100644 --- a/src/views/iot/home/components/ComparisonCard.vue +++ b/src/views/iot/home/components/ComparisonCard.vue @@ -22,8 +22,8 @@ diff --git a/src/views/iot/home/index.vue b/src/views/iot/home/index.vue index 153b20ea..3d60acef 100644 --- a/src/views/iot/home/index.vue +++ b/src/views/iot/home/index.vue @@ -56,11 +56,7 @@ - + @@ -68,12 +64,7 @@ - -