feat: 设备管理添加经纬度以及高度和租户
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { request } from 'umi';
|
||||
import { deviceApi } from './device';
|
||||
import { listMission, MissionStatus } from './mission';
|
||||
import { ordersApi } from './orders';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,7 @@ export interface DeviceStats {
|
||||
offline: number;
|
||||
fault: number;
|
||||
onlineRate: number;
|
||||
tourismCount: number;
|
||||
byType: { type: string; name: string; count: number }[];
|
||||
}
|
||||
|
||||
@@ -53,8 +55,14 @@ export interface AlertItem {
|
||||
*/
|
||||
export async function getDeviceStats(params?: { tenantId?: string; includeChildren?: boolean }): Promise<DeviceStats> {
|
||||
try {
|
||||
const res = await deviceApi.deviceList({ page: 1, limit: 1000, ...params });
|
||||
const devices = res.data || [];
|
||||
// 并行获取设备列表和景区列表
|
||||
const [deviceRes, tourismRes] = await Promise.all([
|
||||
deviceApi.deviceList({ page: 1, limit: 1000, ...params }),
|
||||
ordersApi.tourism({ current: 1, pageSize: 1000, ...params }).catch(() => ({ data: [] })),
|
||||
]);
|
||||
|
||||
const devices = deviceRes.data || [];
|
||||
const tourisms = tourismRes.data || [];
|
||||
|
||||
const online = devices.filter((d: any) => d.status === 1 || d.boundStatus === 1).length;
|
||||
const offline = devices.filter((d: any) => d.status === 0 || d.boundStatus === 0).length;
|
||||
@@ -87,6 +95,7 @@ export async function getDeviceStats(params?: { tenantId?: string; includeChildr
|
||||
offline,
|
||||
fault,
|
||||
onlineRate: total > 0 ? Math.round((online / total) * 100) : 0,
|
||||
tourismCount: tourisms.length,
|
||||
byType,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -97,6 +106,7 @@ export async function getDeviceStats(params?: { tenantId?: string; includeChildr
|
||||
offline: 0,
|
||||
fault: 0,
|
||||
onlineRate: 0,
|
||||
tourismCount: 0,
|
||||
byType: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -89,6 +89,12 @@ export async function getModelsByTourismId(tourismId: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function getModelsByDeviceSn(deviceSn: string) {
|
||||
return request<API.Result<ThreeDModelVO[]>>(`${API_BASE}/device/${deviceSn}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAvailableModels() {
|
||||
return request<API.Result<ThreeDModelVO[]>>(`${API_BASE}/available`, {
|
||||
method: 'GET',
|
||||
|
||||
Reference in New Issue
Block a user