From 97f30356d83378f530b9654cd2285ac21907a983 Mon Sep 17 00:00:00 2001 From: lzh Date: Thu, 8 Jan 2026 15:12:59 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E3=80=90ops=E3=80=91=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E9=98=9F=E5=88=97=E7=8A=B6=E6=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ops/enums/OrderQueueStatusEnum.java | 77 +++++++++++++------ 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/viewsh-module-ops/viewsh-module-ops-api/src/main/java/com/viewsh/module/ops/enums/OrderQueueStatusEnum.java b/viewsh-module-ops/viewsh-module-ops-api/src/main/java/com/viewsh/module/ops/enums/OrderQueueStatusEnum.java index 3d8fc27..7b726ae 100644 --- a/viewsh-module-ops/viewsh-module-ops-api/src/main/java/com/viewsh/module/ops/enums/OrderQueueStatusEnum.java +++ b/viewsh-module-ops/viewsh-module-ops-api/src/main/java/com/viewsh/module/ops/enums/OrderQueueStatusEnum.java @@ -9,46 +9,45 @@ import java.util.Arrays; /** * 工单队列状态枚举 * - * 队列状态职责:仅管理派单相关状态,不管理工单执行状态 - * - 派单流程:WAITING → DISPATCHED - * - 异常流程:WAITING/DISPATCHED → FAILED/PAUSED/CANCELLED - * - 完成流程:DISPATCHED → COMPLETED + * 队列状态职责:管理工单在队列中的生命周期 + * - 正常流程:WAITING → PROCESSING → REMOVED + * - 中断流程:PROCESSING → PAUSED → PROCESSING → REMOVED + * + * 状态映射关系: + * - WAITING: 工单状态 QUEUED(等待派单) + * - PROCESSING: 工单状态 DISPATCHED/CONFIRMED/ARRIVED(处理中) + * - PAUSED: 工单状态 PAUSED(已暂停) + * - REMOVED: 工单状态 COMPLETED/CANCELLED(已移除) * * @author lzh */ @AllArgsConstructor @Getter public enum OrderQueueStatusEnum implements ArrayValuable { - /** * 等待派单 - 工单已进入队列,等待派单引擎分配 + * 对应工单状态: QUEUED */ - WAITING("waiting", "等待派单"), + WAITING("waiting", "等待中"), /** - * 已派单 - 已分配给执行人员,等待接单 + * 处理中 - 任务已下发,正在处理(包括:已下发、已确认、已到岗) + * 对应工单状态: DISPATCHED / CONFIRMED / ARRIVED */ - DISPATCHED("dispatched", "已派单"), + PROCESSING("processing", "处理中"), + /** - * 暂停中 - 任务暂停(如保洁员临时离线、P0任务打断等) + * 暂停中 - 任务暂停(如P0任务打断、保洁员临时离线等) + * 对应工单状态: PAUSED */ PAUSED("paused", "暂停中"), /** - * 已完成 - 任务已完成 + * 已移除 - 任务已完成或已取消 + * 对应工单状态: COMPLETED / CANCELLED */ - COMPLETED("completed", "已完成"), - - /** - * 已取消 - 工单已取消 - */ - CANCELLED("cancelled", "已取消"), - - /** - * 派单失败 - 派单失败,可重试 - */ - FAILED("failed", "派单失败"); + REMOVED("removed", "已移除"); public static final String[] ARRAYS = Arrays.stream(values()).map(OrderQueueStatusEnum::getStatus).toArray(String[]::new); @@ -74,6 +73,20 @@ public enum OrderQueueStatusEnum implements ArrayValuable { * @return 枚举实例,未找到返回WAITING */ public static OrderQueueStatusEnum fromStatus(String status) { + if (status == null) { + return WAITING; + } + + // 兼容旧状态值 + switch (status) { + case "dispatched": + return PROCESSING; + case "completed": + return REMOVED; + default: + break; + } + return Arrays.stream(values()) .filter(e -> e.getStatus().equals(status)) .findFirst() @@ -86,21 +99,21 @@ public enum OrderQueueStatusEnum implements ArrayValuable { * 判断是否为终态(不可变更) */ public boolean isTerminal() { - return this == COMPLETED || this == CANCELLED || this == FAILED; + return this == REMOVED; } /** * 判断是否可以取消 */ public boolean canCancel() { - return this == WAITING || this == DISPATCHED; + return this == WAITING || this == PROCESSING; } /** - * 判断是否正在处理中(已派单或暂停) + * 判断是否正在处理中 */ public boolean isProcessing() { - return this == DISPATCHED || this == PAUSED; + return this == PROCESSING; } /** @@ -109,4 +122,18 @@ public enum OrderQueueStatusEnum implements ArrayValuable { public boolean canAssign() { return this == WAITING; } + + /** + * 判断是否可以恢复(从暂停状态恢复) + */ + public boolean canResume() { + return this == PAUSED; + } + + /** + * 判断是否为暂停状态 + */ + public boolean isPaused() { + return this == PAUSED; + } }