186 lines
5.4 KiB
TypeScript
186 lines
5.4 KiB
TypeScript
import { requestClient } from '#/api/request';
|
||
|
||
export namespace OpsCleaningApi {
|
||
/** 工牌状态枚举 */
|
||
export enum BadgeStatus {
|
||
BUSY = 'BUSY', // 忙碌
|
||
IDLE = 'IDLE', // 空闲
|
||
OFFLINE = 'OFFLINE', // 离线
|
||
PAUSED = 'PAUSED', // 暂停中
|
||
}
|
||
|
||
/** 通知类型枚举 */
|
||
export enum NotifyType {
|
||
VIBRATE = 'VIBRATE', // 震动
|
||
VOICE = 'VOICE', // 语音
|
||
}
|
||
|
||
/** 升级优先级请求 */
|
||
export interface UpgradePriorityReq {
|
||
orderId: number; // 工单ID
|
||
reason: string; // 升级原因
|
||
}
|
||
|
||
/** 工牌通知请求 */
|
||
export interface DeviceNotifyReq {
|
||
badgeId: number; // 工牌设备ID
|
||
type: NotifyType; // 通知类型
|
||
content?: string; // 语音内容(仅语音通知需要)
|
||
}
|
||
|
||
/** 工牌状态信息 */
|
||
export interface BadgeStatusItem {
|
||
deviceId: number; // 设备ID
|
||
deviceKey: string; // 设备编码
|
||
status: BadgeStatus; // 状态
|
||
currentAreaId?: number; // 当前区域ID
|
||
currentAreaName?: string; // 当前区域名称
|
||
batteryLevel: number; // 电量(0-100)
|
||
lastHeartbeatTime: string; // 最后心跳时间
|
||
todayCompletedCount?: number; // 今日完成工单数
|
||
todayWorkMinutes?: number; // 今日工作时长(分钟)
|
||
}
|
||
|
||
/** 工牌状态列表查询参数 */
|
||
export interface BadgeListQuery {
|
||
areaId?: number; // 区域ID(可选)
|
||
status?: BadgeStatus; // 状态筛选(可选)
|
||
}
|
||
|
||
/** 工牌状态列表响应 */
|
||
export interface BadgeListResp {
|
||
list: BadgeStatusItem[];
|
||
}
|
||
|
||
/** 工单时间轴节点 */
|
||
export interface TimelineItem {
|
||
status: string; // 状态
|
||
statusName: string; // 状态名称
|
||
time: string; // 时间
|
||
operator?: string; // 操作人
|
||
description?: string; // 描述
|
||
extra?: Record<string, any>; // 额外信息(如RSSI值、信标ID等)
|
||
}
|
||
|
||
/** 工单时间轴响应 */
|
||
export interface OrderTimelineResp {
|
||
orderId: number;
|
||
currentStatus: string;
|
||
timeline: TimelineItem[];
|
||
}
|
||
|
||
/** 工牌实时状态 */
|
||
export interface BadgeRealtimeStatus {
|
||
deviceId: number; // 设备ID
|
||
deviceKey: string; // 设备Key
|
||
status: BadgeStatus | string; // 设备状态(兼容大小写)
|
||
batteryLevel: number | null; // 电量(可能为空)
|
||
lastHeartbeatTime: string; // 最后心跳时间
|
||
rssi?: number | null; // 信号强度(可能为空)
|
||
isInArea: boolean; // 是否在区域内
|
||
areaId?: number; // 当前区域ID
|
||
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 }
|
||
});
|
||
}
|
||
|
||
// ==================== 保洁专属接口 ====================
|
||
|
||
/** 升级工单优先级 (P0 插队) */
|
||
export function upgradePriority(data: OpsCleaningApi.UpgradePriorityReq) {
|
||
return requestClient.post('/ops/clean/order/upgrade-priority', data);
|
||
}
|
||
|
||
/** 发送工牌通知 (语音/震动) */
|
||
export function sendDeviceNotify(data: OpsCleaningApi.DeviceNotifyReq) {
|
||
return requestClient.post('/ops/clean/device/notify', data);
|
||
}
|
||
|
||
/** 查询工牌实时状态列表 */
|
||
export function getBadgeStatusList(params?: OpsCleaningApi.BadgeListQuery) {
|
||
return requestClient.get<OpsCleaningApi.BadgeStatusItem[]>(
|
||
'/ops/clean/badge/list',
|
||
{ params },
|
||
);
|
||
}
|
||
|
||
/** 获取工单时间轴 */
|
||
export function getOrderTimeline(orderId: number | string) {
|
||
return requestClient.get<OpsCleaningApi.OrderTimelineResp>(
|
||
`/ops/clean/order/timeline/${orderId}`,
|
||
);
|
||
}
|
||
|
||
/** 获取工牌实时状态 */
|
||
export function getBadgeRealtimeStatus(badgeId: number) {
|
||
return requestClient.get<OpsCleaningApi.BadgeRealtimeStatus>(
|
||
`/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}`,
|
||
);
|
||
}
|