diff --git a/src/api/iot/statistics/index.ts b/src/api/iot/statistics/index.ts index 0f88217ab..cdcb94d2e 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 89f40281e..99eb428c3 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 a66ab3c71..6c9f4594c 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 4ccda6609..2da729e1d 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 153b20ea7..3d60acefc 100644 --- a/src/views/iot/home/index.vue +++ b/src/views/iot/home/index.vue @@ -56,11 +56,7 @@ - + @@ -68,12 +64,7 @@ - -