Files
iot-device-management-frontend/apps/web-antd/src/api/iot/statistics/index.ts
2025-11-21 09:17:19 +08:00

72 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<string, number>;
}
/** 时间戳-数值的键值对类型 */
export interface TimeValueItem {
[key: string]: number;
}
/** 消息统计数据类型 */
export interface DeviceMessageSummary {
statType: number;
upstreamCounts: TimeValueItem[];
downstreamCounts: TimeValueItem[];
}
/** 消息统计数据项(按日期) */
export interface DeviceMessageSummaryByDate {
time: string;
upstreamCount: number;
downstreamCount: number;
}
/** 消息统计接口参数 */
export interface DeviceMessageReq {
interval: number;
times?: string[];
}
}
/** 获取 IoT 统计摘要数据 */
export function getStatisticsSummary() {
return requestClient.get<IotStatisticsApi.StatisticsSummary>(
'/iot/statistics/get-summary',
);
}
/** 获取设备消息的数据统计(按日期) */
export function getDeviceMessageSummaryByDate(
params: IotStatisticsApi.DeviceMessageReq,
) {
return requestClient.get<IotStatisticsApi.DeviceMessageSummaryByDate[]>(
'/iot/statistics/get-device-message-summary-by-date',
{ params },
);
}
// TODO @haohao貌似这里没用到是不是后面哪里用或者可以删除哈
/** 获取设备消息统计摘要 */
export function getDeviceMessageSummary(statType: number) {
return requestClient.get<IotStatisticsApi.DeviceMessageSummary>(
'/iot/statistics/get-device-message-summary',
{ params: { statType } },
);
}