feat: ops接口ts文件
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace OpsCleaningApi {
|
||||
/** 保洁员状态枚举 */
|
||||
export enum CleanerStatus {
|
||||
/** 工牌状态枚举 */
|
||||
export enum BadgeStatus {
|
||||
BUSY = 'BUSY', // 忙碌
|
||||
IDLE = 'IDLE', // 空闲
|
||||
OFFLINE = 'OFFLINE', // 离线
|
||||
@@ -23,17 +23,16 @@ export namespace OpsCleaningApi {
|
||||
|
||||
/** 工牌通知请求 */
|
||||
export interface DeviceNotifyReq {
|
||||
cleanerId: number; // 保洁员ID
|
||||
badgeId: number; // 工牌设备ID
|
||||
type: NotifyType; // 通知类型
|
||||
content?: string; // 语音内容(仅语音通知需要)
|
||||
}
|
||||
|
||||
/** 保洁员状态信息 */
|
||||
export interface CleanerStatusItem {
|
||||
userId: number; // 用户ID
|
||||
userName: string; // 用户名称
|
||||
avatar?: string; // 头像
|
||||
status: CleanerStatus; // 状态
|
||||
/** 工牌状态信息 */
|
||||
export interface BadgeStatusItem {
|
||||
deviceId: number; // 设备ID
|
||||
deviceKey: string; // 设备编码
|
||||
status: BadgeStatus; // 状态
|
||||
currentAreaId?: number; // 当前区域ID
|
||||
currentAreaName?: string; // 当前区域名称
|
||||
batteryLevel: number; // 电量(0-100)
|
||||
@@ -42,15 +41,15 @@ export namespace OpsCleaningApi {
|
||||
todayWorkMinutes?: number; // 今日工作时长(分钟)
|
||||
}
|
||||
|
||||
/** 保洁员状态列表查询参数 */
|
||||
export interface CleanerListQuery {
|
||||
/** 工牌状态列表查询参数 */
|
||||
export interface BadgeListQuery {
|
||||
areaId?: number; // 区域ID(可选)
|
||||
status?: CleanerStatus; // 状态筛选(可选)
|
||||
status?: BadgeStatus; // 状态筛选(可选)
|
||||
}
|
||||
|
||||
/** 保洁员状态列表响应 */
|
||||
export interface CleanerListResp {
|
||||
list: CleanerStatusItem[];
|
||||
/** 工牌状态列表响应 */
|
||||
export interface BadgeListResp {
|
||||
list: BadgeStatusItem[];
|
||||
}
|
||||
|
||||
/** 工单时间轴节点 */
|
||||
@@ -70,19 +69,70 @@ export namespace OpsCleaningApi {
|
||||
timeline: TimelineItem[];
|
||||
}
|
||||
|
||||
/** 保洁员工牌实时状态 */
|
||||
/** 工牌实时状态 */
|
||||
export interface BadgeRealtimeStatus {
|
||||
cleanerId: number; // 保洁员ID
|
||||
deviceId: number; // 设备ID
|
||||
deviceKey: string; // 设备Key
|
||||
status: CleanerStatus; // 设备状态
|
||||
batteryLevel: number; // 电量
|
||||
status: BadgeStatus | string; // 设备状态(兼容大小写)
|
||||
batteryLevel: number | null; // 电量(可能为空)
|
||||
lastHeartbeatTime: string; // 最后心跳时间
|
||||
rssi?: number; // 信号强度
|
||||
rssi?: number | null; // 信号强度(可能为空)
|
||||
isInArea: boolean; // 是否在区域内
|
||||
areaId?: number; // 当前区域ID
|
||||
areaName?: string; // 当前区域名称
|
||||
areaName?: string | null; // 当前区域名称(可能为空)
|
||||
}
|
||||
|
||||
/** 业务日志类型 */
|
||||
export type BusinessLogType = 'alert' | 'device' | 'operation' | 'system';
|
||||
|
||||
/** 业务日志项 */
|
||||
export interface BusinessLog {
|
||||
id: number;
|
||||
type: BusinessLogType; // 日志类型
|
||||
title: string; // 标题
|
||||
content: string; // 内容
|
||||
operator: string; // 操作人
|
||||
time: string; // 时间
|
||||
status?: string; // 关联的状态阶段
|
||||
extra?: Record<string, any>; // 额外信息
|
||||
}
|
||||
|
||||
/** 业务日志响应 */
|
||||
export interface BusinessLogsResp {
|
||||
orderId: number;
|
||||
logs: BusinessLog[];
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== IoT 设备接口(直接调用 IoT 模块) ====================
|
||||
|
||||
/** IoT 设备状态响应 */
|
||||
export interface IotDeviceStatus {
|
||||
deviceId: number;
|
||||
deviceCode: string;
|
||||
status: number; // 0=未激活, 1=在线, 2=离线
|
||||
statusChangeTime: string;
|
||||
}
|
||||
|
||||
/** 获取 IoT 设备状态 */
|
||||
export function getIotDeviceStatus(deviceId: number) {
|
||||
return requestClient.get<IotDeviceStatus>(`/iot/device/status/get-status`, {
|
||||
params: { deviceId }
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量获取 IoT 设备状态 */
|
||||
export function batchGetIotDeviceStatus(deviceIds: number[]) {
|
||||
return requestClient.get<IotDeviceStatus[]>(`/iot/device/status/batch-get-status`, {
|
||||
params: { deviceIds }
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取 IoT 设备最新属性(含电量、RSSI等) */
|
||||
export function getIotDeviceProperties(deviceId: number) {
|
||||
return requestClient.get<Record<string, any>>(`/iot/device/property/get-latest`, {
|
||||
params: { deviceId }
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 保洁专属接口 ====================
|
||||
@@ -97,32 +147,39 @@ export function sendDeviceNotify(data: OpsCleaningApi.DeviceNotifyReq) {
|
||||
return requestClient.post('/ops/clean/device/notify', data);
|
||||
}
|
||||
|
||||
/** 查询保洁员实时状态列表 */
|
||||
export function getCleanerStatusList(params?: OpsCleaningApi.CleanerListQuery) {
|
||||
return requestClient.get<OpsCleaningApi.CleanerListResp>(
|
||||
'/ops/clean/cleaner/list',
|
||||
/** 查询工牌实时状态列表 */
|
||||
export function getBadgeStatusList(params?: OpsCleaningApi.BadgeListQuery) {
|
||||
return requestClient.get<OpsCleaningApi.BadgeStatusItem[]>(
|
||||
'/ops/clean/badge/list',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取工单时间轴 */
|
||||
export function getOrderTimeline(orderId: number) {
|
||||
export function getOrderTimeline(orderId: number | string) {
|
||||
return requestClient.get<OpsCleaningApi.OrderTimelineResp>(
|
||||
`/ops/clean/order/timeline/${orderId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取保洁员工牌实时状态 */
|
||||
export function getBadgeRealtimeStatus(cleanerId: number) {
|
||||
/** 获取工牌实时状态 */
|
||||
export function getBadgeRealtimeStatus(badgeId: number) {
|
||||
return requestClient.get<OpsCleaningApi.BadgeRealtimeStatus>(
|
||||
`/ops/clean/badge/realtime/${cleanerId}`,
|
||||
`/ops/clean/badge/realtime/${badgeId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 手动完成工单(兜底操作) */
|
||||
/** 手动完成工单(兜底操作) */
|
||||
export function manualCompleteOrder(orderId: number, remark?: string) {
|
||||
return requestClient.post('/ops/clean/order/manual-complete', {
|
||||
orderId,
|
||||
remark,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取工单业务日志 */
|
||||
export function getOrderBusinessLogs(orderId: number | string) {
|
||||
return requestClient.get<OpsCleaningApi.BusinessLogsResp>(
|
||||
`/ops/order/business-logs/${orderId}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user