fix: 修复排队状态查询逻辑

当任务没有 receiver_dept_id 时,从 task_unlock_status 表中查询对应的部门ID
This commit is contained in:
Your Name 2026-01-29 11:50:12 +08:00
parent 4d4b1e2189
commit bf2f720fe7
2 changed files with 21 additions and 1 deletions

View File

@ -187,14 +187,27 @@ public class TaskItemService {
// 确定目标部门
Long targetDeptId = deptId;
if (targetDeptId == null) {
// 优先使用已接单的部门
targetDeptId = item.getReceiverDeptId();
}
if (targetDeptId == null) {
// 🔥 从 task_unlock_status 表中查询该任务对应的部门
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.designhub.entity.TaskUnlockStatus> wrapper =
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
wrapper.eq(com.designhub.entity.TaskUnlockStatus::getTaskItemId, item.getId())
.last("LIMIT 1");
com.designhub.entity.TaskUnlockStatus unlockStatus = taskUnlockService.getUnlockStatusMapper().selectOne(wrapper);
if (unlockStatus != null) {
targetDeptId = unlockStatus.getDeptId();
}
}
// 填充解锁状态
if (targetDeptId != null) {
taskUnlockService.fillUnlockStatus(item, targetDeptId, releaseType);
} else {
// 无法确定部门,默认可抢
// 无法确定部门,默认可抢(兼容旧数据)
item.setUnlockStatus("unlocked");
item.setCanGrab(true);
}

View File

@ -46,6 +46,13 @@ public class TaskUnlockService {
private static final int DEFAULT_DAILY_UNLOCK_MIN = 5;
private static final int DEFAULT_BATCH_SIZE = 5;
/**
* 获取 TaskUnlockStatusMapper(供其他 Service 使用)
*/
public TaskUnlockStatusMapper getUnlockStatusMapper() {
return unlockStatusMapper;
}
// ==================== 配置相关 ====================
/**