fix: TeamScorePoolService 改用 dept_id 查询积分池,支持二级部门独立配置
This commit is contained in:
parent
98c393ed2e
commit
f6d612c998
@ -26,24 +26,22 @@ public class TeamScorePoolService {
|
||||
|
||||
/**
|
||||
* 根据部门ID获取积分池
|
||||
* 如果当前部门没有积分池,向上查找父部门的积分池
|
||||
* 使用 dept_id 关联部门(team_id 为遗留字段)。若当前部门无积分池且存在父部门,则向上查找父部门积分池(三级部门共享二级)。
|
||||
*/
|
||||
public TeamScorePool getByDeptId(Long deptId) {
|
||||
// 首先查找当前部门的积分池(使用SQL直接查询team_id字段)
|
||||
TeamScorePool pool = teamScorePoolMapper.selectOne(
|
||||
new LambdaQueryWrapper<TeamScorePool>()
|
||||
.apply("team_id = {0}", deptId)
|
||||
.eq(TeamScorePool::getDeptId, deptId)
|
||||
);
|
||||
|
||||
// 如果当前部门没有积分池,向上查找父部门
|
||||
|
||||
if (pool == null) {
|
||||
Department department = departmentMapper.selectById(deptId);
|
||||
if (department != null && department.getParentId() != null && department.getParentId() > 0) {
|
||||
log.debug("部门{}没有积分池,查找父部门{}的积分池", deptId, department.getParentId());
|
||||
return getByDeptId(department.getParentId()); // 递归查找父部门
|
||||
return getByDeptId(department.getParentId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
10
database/backfill_team_score_pool_dept_id.sql
Normal file
10
database/backfill_team_score_pool_dept_id.sql
Normal file
@ -0,0 +1,10 @@
|
||||
-- 回填 team_score_pool.dept_id(便于按 dept_id 查询,二级部门可独立配置积分池)
|
||||
-- 说明:表以 dept_id 关联部门;team_id 为遗留字段。若历史数据仅有 team_id,在此统一回填 dept_id。
|
||||
-- 执行时机:修复 TeamScorePoolService 按 dept_id 查询后,建议执行一次。
|
||||
|
||||
USE designhub;
|
||||
|
||||
UPDATE team_score_pool
|
||||
SET dept_id = team_id
|
||||
WHERE (dept_id IS NULL OR dept_id = 0)
|
||||
AND team_id IS NOT NULL;
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user