From 5cb412a4da2a03fef243e4b66f5d65e34a38c6cd Mon Sep 17 00:00:00 2001 From: haohao <1036606149@qq.com> Date: Mon, 15 Dec 2025 21:51:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E3=80=90antd=E3=80=91=E3=80=90iot?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E9=A6=96=E9=A1=B5=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=20ReqVO=E3=80=81RespVO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/iot/statistics/index.ts | 56 ++++++++----------- apps/web-antd/src/views/iot/home/data.ts | 5 +- apps/web-antd/src/views/iot/home/index.vue | 43 +------------- .../iot/home/modules/device-count-card.vue | 8 +-- .../home/modules/device-state-count-card.vue | 8 +-- .../iot/home/modules/message-trend-card.vue | 10 +--- 6 files changed, 32 insertions(+), 98 deletions(-) diff --git a/apps/web-antd/src/api/iot/statistics/index.ts b/apps/web-antd/src/api/iot/statistics/index.ts index 9f3a04266..a02b342d2 100644 --- a/apps/web-antd/src/api/iot/statistics/index.ts +++ b/apps/web-antd/src/api/iot/statistics/index.ts @@ -1,21 +1,20 @@ import { requestClient } from '#/api/request'; export namespace IotStatisticsApi { - // TODO @haohao:需要跟后端对齐,必要的 ReqVO、RespVO /** 统计摘要数据 */ - export interface StatisticsSummary { - productCategoryCount: number; - productCount: number; - deviceCount: number; - deviceMessageCount: number; - productCategoryTodayCount: number; - productTodayCount: number; - deviceTodayCount: number; - deviceMessageTodayCount: number; - deviceOnlineCount: number; - deviceOfflineCount: number; - deviceInactiveCount: number; - productCategoryDeviceCounts: Record; + export interface StatisticsSummaryRespVO { + productCategoryCount: number; // 品类数量 + productCount: number; // 产品数量 + deviceCount: number; // 设备数量 + deviceMessageCount: number; // 上报数量 + productCategoryTodayCount: number; // 今日新增品类数量 + productTodayCount: number; // 今日新增产品数量 + deviceTodayCount: number; // 今日新增设备数量 + deviceMessageTodayCount: number; // 今日新增上报数量 + deviceOnlineCount: number; // 在线数量 + deviceOfflineCount: number; // 离线数量 + deviceInactiveCount: number; // 待激活设备数量 + productCategoryDeviceCounts: Record; // 按品类统计的设备数量 } /** 时间戳-数值的键值对类型 */ @@ -30,15 +29,15 @@ export namespace IotStatisticsApi { downstreamCounts: TimeValueItem[]; } - /** 消息统计数据项(按日期) */ - export interface DeviceMessageSummaryByDate { - time: string; - upstreamCount: number; - downstreamCount: number; + /** 设备消息数量统计(按日期) */ + export interface DeviceMessageSummaryByDateRespVO { + time: string; // 时间轴 + upstreamCount: number; // 上行消息数量 + downstreamCount: number; // 下行消息数量 } - /** 消息统计接口参数 */ - export interface DeviceMessageReq { + /** 设备消息统计请求 */ + export interface DeviceMessageReqVO { interval: number; times?: string[]; } @@ -46,26 +45,17 @@ export namespace IotStatisticsApi { /** 获取 IoT 统计摘要数据 */ export function getStatisticsSummary() { - return requestClient.get( + return requestClient.get( '/iot/statistics/get-summary', ); } /** 获取设备消息的数据统计(按日期) */ export function getDeviceMessageSummaryByDate( - params: IotStatisticsApi.DeviceMessageReq, + params: IotStatisticsApi.DeviceMessageReqVO, ) { - return requestClient.get( + return requestClient.get( '/iot/statistics/get-device-message-summary-by-date', { params }, ); } - -// TODO @haohao:貌似这里,没用到?是不是后面哪里用,或者可以删除哈? -/** 获取设备消息统计摘要 */ -export function getDeviceMessageSummary(statType: number) { - return requestClient.get( - '/iot/statistics/get-device-message-summary', - { params: { statType } }, - ); -} diff --git a/apps/web-antd/src/views/iot/home/data.ts b/apps/web-antd/src/views/iot/home/data.ts index 562490f34..5a84bd8e9 100644 --- a/apps/web-antd/src/views/iot/home/data.ts +++ b/apps/web-antd/src/views/iot/home/data.ts @@ -1,7 +1,10 @@ import type { IotStatisticsApi } from '#/api/iot/statistics'; +/** 统计数据 */ +export type StatsData = IotStatisticsApi.StatisticsSummaryRespVO; + /** 默认统计数据 */ -export const defaultStatsData: IotStatisticsApi.StatisticsSummary = { +export const defaultStatsData: StatsData = { productCategoryCount: 0, productCount: 0, deviceCount: 0, diff --git a/apps/web-antd/src/views/iot/home/index.vue b/apps/web-antd/src/views/iot/home/index.vue index 763c03e0c..4a51e6873 100644 --- a/apps/web-antd/src/views/iot/home/index.vue +++ b/apps/web-antd/src/views/iot/home/index.vue @@ -1,5 +1,4 @@