feat(ops): 重构派单队列评分逻辑,支持楼层差与等待老化综合排序
- 新增 QueueScoreCalculator/QueueScoreContext/QueueScoreResult,统一按优先级分 + 楼层差分 - 等待老化分计算队列总分,并将 PRIORITY_WEIGHT 调整为 1500 - OrderQueueService 新增 rebuildWaitingTasksByUserId 接口,OrderQueueServiceEnhanced 支持按执行人重算 WAITING 队列、以当前执行工单楼层为基准动态重排,并在事务提交后同步刷新 Redis - RedisOrderQueueServiceImpl 支持持久化 baseFloorNo、targetFloorNo、floorDiff、waitMinutes、scoreUpdateTime 等评分明细,清队列时同时清理关联 Hash,避免脏数据残留 - DispatchEngineImpl、CleanerPriorityScheduleStrategy、BadgeDeviceScheduleStrategy 调整为非抢占式派单:P0 忙碌时仅入队等待,空闲时直接派发,自动派单前按总分重排并派发下一单 - CleanOrderServiceImpl 取消 P0 自动打断链路,升级到 P0 后仅重算等待队列并发送通知;补充 QueueScoreCalculatorTest、OrderQueueServiceEnhancedTest、CleanerPriorityScheduleStrategyTest、CleanOrderEndToEndTest 覆盖新行为
This commit is contained in:
@@ -40,13 +40,8 @@ public class OrderQueueDTO {
|
||||
|
||||
/**
|
||||
* 队列分数(用于排序)
|
||||
* 计算公式:优先级分数 + 时间戳
|
||||
* - P0: 0 + timestamp
|
||||
* - P1: 1000000 + timestamp
|
||||
* - P2: 2000000 + timestamp
|
||||
* - P3: 3000000 + timestamp
|
||||
*
|
||||
* 用于数据库层面的排序,优先级高的排在前面,同优先级按时间排序
|
||||
* 计算公式:优先级分 + 楼层差分 - 等待老化分
|
||||
* 分数越小越靠前,用于等待队列的动态重排
|
||||
*/
|
||||
private Double queueScore;
|
||||
|
||||
@@ -95,6 +90,31 @@ public class OrderQueueDTO {
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 评分基准楼层
|
||||
*/
|
||||
private Integer baseFloorNo;
|
||||
|
||||
/**
|
||||
* 目标工单楼层
|
||||
*/
|
||||
private Integer targetFloorNo;
|
||||
|
||||
/**
|
||||
* 楼层差
|
||||
*/
|
||||
private Integer floorDiff;
|
||||
|
||||
/**
|
||||
* 等待分钟数
|
||||
*/
|
||||
private Long waitMinutes;
|
||||
|
||||
/**
|
||||
* 分数更新时间
|
||||
*/
|
||||
private LocalDateTime scoreUpdateTime;
|
||||
|
||||
// ========== 兼容旧字段名的getter方法 ==========
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,6 +164,15 @@ public interface OrderQueueService {
|
||||
*/
|
||||
List<OrderQueueDTO> getWaitingTasksByUserIdFromDb(Long userId);
|
||||
|
||||
/**
|
||||
* 按当前上下文重算指定执行人等待队列的总分并返回最新排序结果
|
||||
*
|
||||
* @param userId 执行人ID
|
||||
* @param fallbackAreaId 当没有执行中工单时可使用的楼层基准区域ID
|
||||
* @return 已按最新总分排序的 WAITING 工单列表
|
||||
*/
|
||||
List<OrderQueueDTO> rebuildWaitingTasksByUserId(Long userId, Long fallbackAreaId);
|
||||
|
||||
/**
|
||||
* 获取用户的暂停任务列表(PAUSED状态,按暂停时间排序)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user