fix(ops): 修复工单队列Redis存储与自动派单问题
- Redis Sorted Set 改用 queueId 作为 member,详细信息存储在 Hash - REMOVED 状态同步更新 Redis,避免自动派单查询到已完成任务 - 新增 getWaitingTasksByUserIdFromDb() 强制从 MySQL 读取最新数据 - 修复队列状态枚举值统一为大写 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -155,6 +155,15 @@ public interface OrderQueueService {
|
||||
*/
|
||||
List<OrderQueueDTO> getWaitingTasksByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 从数据库直接获取用户的等待中任务列表(忽略 Redis 缓存)
|
||||
* 用于确保获取最新数据,例如在任务完成后自动派单下一个时
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 等待中的任务列表(已按队列分数排序)
|
||||
*/
|
||||
List<OrderQueueDTO> getWaitingTasksByUserIdFromDb(Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户的暂停任务列表(PAUSED状态,按暂停时间排序)
|
||||
*
|
||||
|
||||
@@ -28,28 +28,32 @@ public enum OrderQueueStatusEnum implements ArrayValuable<String> {
|
||||
* 等待派单 - 工单已进入队列,等待派单引擎分配
|
||||
* 对应工单状态: QUEUED
|
||||
*/
|
||||
WAITING("waiting", "等待中"),
|
||||
/**
|
||||
* 等待派单 - 工单已进入队列,等待派单引擎分配
|
||||
* 对应工单状态: QUEUED
|
||||
*/
|
||||
WAITING("WAITING", "等待中"),
|
||||
|
||||
/**
|
||||
* 处理中 - 任务已下发,正在处理(包括:已下发、已确认、已到岗)
|
||||
* 对应工单状态: DISPATCHED / CONFIRMED / ARRIVED
|
||||
*/
|
||||
PROCESSING("processing", "处理中"),
|
||||
|
||||
PROCESSING("PROCESSING", "处理中"),
|
||||
|
||||
/**
|
||||
* 暂停中 - 任务暂停(如P0任务打断、保洁员临时离线等)
|
||||
* 对应工单状态: PAUSED
|
||||
*/
|
||||
PAUSED("paused", "暂停中"),
|
||||
PAUSED("PAUSED", "暂停中"),
|
||||
|
||||
/**
|
||||
* 已移除 - 任务已完成或已取消
|
||||
* 对应工单状态: COMPLETED / CANCELLED
|
||||
*/
|
||||
REMOVED("removed", "已移除");
|
||||
REMOVED("REMOVED", "已移除");
|
||||
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(OrderQueueStatusEnum::getStatus).toArray(String[]::new);
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(OrderQueueStatusEnum::getStatus)
|
||||
.toArray(String[]::new);
|
||||
|
||||
/**
|
||||
* 状态代码
|
||||
@@ -76,7 +80,7 @@ public enum OrderQueueStatusEnum implements ArrayValuable<String> {
|
||||
if (status == null) {
|
||||
return WAITING;
|
||||
}
|
||||
|
||||
|
||||
// 兼容旧状态值
|
||||
switch (status) {
|
||||
case "dispatched":
|
||||
@@ -86,11 +90,11 @@ public enum OrderQueueStatusEnum implements ArrayValuable<String> {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return Arrays.stream(values())
|
||||
.filter(e -> e.getStatus().equals(status))
|
||||
.findFirst()
|
||||
.orElse(WAITING);
|
||||
.filter(e -> e.getStatus().equals(status))
|
||||
.findFirst()
|
||||
.orElse(WAITING);
|
||||
}
|
||||
|
||||
// ========== 业务判断方法 ==========
|
||||
|
||||
Reference in New Issue
Block a user