jeecgboot/JeecgBoot · error · JeecgBootBizTipException

当前选择职级的职务等级为空,请前往职务管理进行修改!

Error message

当前选择职级的职务等级为空,请前往职务管理进行修改!

What it means

When resolving the parent department's position by post level, the referenced SysPosition has a null post_level. This is treated as legacy/incomplete data and rejected, because the level-based upward lookup (getParentDepartPosition) cannot rank positions without a level, which would make the result non-deterministic.

Source

Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java:1583

    //=========================begin 部门岗位改造 ==================================================================
    @Override
    public List<SysPositionSelectTreeVo> getPositionByDepartId(String parentId, String departId, String positionId) {
        //step1 根据职级获取当前岗位的级别
        SysPosition sysPosition = sysPositionMapper.selectById(positionId);
        if(null == sysPosition){
            return null;
        }
        Integer postLevel = sysPosition.getPostLevel();
        //先获取上级部门的信息
        SysDepart sysDepart = baseMapper.getDepartById(parentId);
        //step2 如果是总公司 即数据为空的时候,则说明没有上级领导了
        if (null == sysDepart) {
            return null;
        }
        
        //可能是老数据
        if(null == postLevel){
            throw new JeecgBootBizTipException("当前选择职级的职务等级为空,请前往职务管理进行修改!");
        }
        return this.getParentDepartPosition(sysDepart, postLevel, departId);
    }
    
    /*
     * 获取上级部门岗位 或者当前部门下级别高的
     *
     * @param sysDepart
     * @param postLevel
     * @param id
     * @return
     */
    private List<SysPositionSelectTreeVo> getParentDepartPosition(SysDepart sysDepart, Integer postLevel, String id) {
        //step1 先获取上级部门下的数据
        //已经存在的code
        List<String> existCodeList = new ArrayList<>();
        List<SysPositionSelectTreeVo> departPosition = getDepartPosition(sysDepart, postLevel, id, existCodeList);
        //step2 获取上级部门信息,一直获取到子公司或者总公司为止

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Open 职务管理 (position management) and set the post level for the affected position.
  2. Backfill sys_position.post_level for all NULL rows: UPDATE sys_position SET post_level = <default> WHERE post_level IS NULL.
  3. Add a NOT NULL constraint (or UI validation) on post_level to prevent future gaps.

Example fix

-- before: position has NULL post_level
SELECT id, name, post_level FROM sys_position WHERE id = ?; -- post_level NULL
-- after: backfill the level
UPDATE sys_position SET post_level = 1 WHERE id = ?;
-- and prevent recurrence
ALTER TABLE sys_position MODIFY post_level INT NOT NULL;
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the referenced position has a non-null post_level before resolving.
if (sysPosition != null && sysPosition.getPostLevel() == null) {
    throw new JeecgBootBizTipException("职务 [" + sysPosition.getName() + "] 等级为空, 请先在职务管理中维护");
}

Type guard

public boolean positionHasLevel(SysPosition p) {
    return p != null && p.getPostLevel() != null;
}

Try / catch

try {
    return sysDepartService.getParentDepartPosition(sysDepart, postLevel, departId);
} catch (JeecgBootBizTipException e) {
    if (e.getMessage() != null && e.getMessage().contains("职务等级为空")) {
        return Result.error("请先在职务管理中补全职务等级");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling the department-position resolution with a SysPosition whose postLevel field is null — typically pre-existing rows created before the post_level column existed, or positions edited and left without a level.

Common situations: Migrated or old data where sys_position.post_level was never populated; a position was edited and the level cleared; partial data import omitting the level column.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/de7cb914e2dfbdec. Report an issue: GitHub.