{"record":{"id":"de7cb914e2dfbdec","repo":"jeecgboot/JeecgBoot","slug":"error-de7cb9","errorCode":null,"errorMessage":"当前选择职级的职务等级为空，请前往职务管理进行修改！","messagePattern":"当前选择职级的职务等级为空，请前往职务管理进行修改！","errorType":"exception","errorClass":"JeecgBootBizTipException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java","lineNumber":1583,"sourceCode":"    //=========================begin 部门岗位改造 ==================================================================\n    @Override\n    public List<SysPositionSelectTreeVo> getPositionByDepartId(String parentId, String departId, String positionId) {\n        //step1 根据职级获取当前岗位的级别\n        SysPosition sysPosition = sysPositionMapper.selectById(positionId);\n        if(null == sysPosition){\n            return null;\n        }\n        Integer postLevel = sysPosition.getPostLevel();\n        //先获取上级部门的信息\n        SysDepart sysDepart = baseMapper.getDepartById(parentId);\n        //step2 如果是总公司 即数据为空的时候，则说明没有上级领导了\n        if (null == sysDepart) {\n            return null;\n        }\n        \n        //可能是老数据\n        if(null == postLevel){\n            throw new JeecgBootBizTipException(\"当前选择职级的职务等级为空，请前往职务管理进行修改！\");\n        }\n        return this.getParentDepartPosition(sysDepart, postLevel, departId);\n    }\n    \n    /*\n     * 获取上级部门岗位 或者当前部门下级别高的\n     *\n     * @param sysDepart\n     * @param postLevel\n     * @param id\n     * @return\n     */\n    private List<SysPositionSelectTreeVo> getParentDepartPosition(SysDepart sysDepart, Integer postLevel, String id) {\n        //step1 先获取上级部门下的数据\n        //已经存在的code\n        List<String> existCodeList = new ArrayList<>();\n        List<SysPositionSelectTreeVo> departPosition = getDepartPosition(sysDepart, postLevel, id, existCodeList);\n        //step2 获取上级部门信息，一直获取到子公司或者总公司为止","sourceCodeStart":1565,"sourceCodeEnd":1601,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java#L1565-L1601","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open 职务管理 (position management) and set the post level for the affected position.","Backfill sys_position.post_level for all NULL rows: UPDATE sys_position SET post_level = <default> WHERE post_level IS NULL.","Add a NOT NULL constraint (or UI validation) on post_level to prevent future gaps."],"exampleFix":"-- before: position has NULL post_level\nSELECT id, name, post_level FROM sys_position WHERE id = ?; -- post_level NULL\n-- after: backfill the level\nUPDATE sys_position SET post_level = 1 WHERE id = ?;\n-- and prevent recurrence\nALTER TABLE sys_position MODIFY post_level INT NOT NULL;","handlingStrategy":"validation","validationCode":"// Ensure the referenced position has a non-null post_level before resolving.\nif (sysPosition != null && sysPosition.getPostLevel() == null) {\n    throw new JeecgBootBizTipException(\"职务 [\" + sysPosition.getName() + \"] 等级为空, 请先在职务管理中维护\");\n}","typeGuard":"public boolean positionHasLevel(SysPosition p) {\n    return p != null && p.getPostLevel() != null;\n}","tryCatchPattern":"try {\n    return sysDepartService.getParentDepartPosition(sysDepart, postLevel, departId);\n} catch (JeecgBootBizTipException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"职务等级为空\")) {\n        return Result.error(\"请先在职务管理中补全职务等级\");\n    }\n    throw e;\n}","preventionTips":["Backfill sys_position.post_level for all NULL rows via a migration script.","Add UI/server validation requiring post_level when creating/editing positions.","Add a NOT NULL constraint on post_level once data is clean to prevent recurrence."],"tags":["department","position","data-integrity","legacy-data"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}