| | |
| | | } |
| | | |
| | | @Override |
| | | public List<OrganizationChartEntity> selectConfigList(List<String> ids) { |
| | | List<OrganizationChartEntity> ocList=baseMapper.selectConfigList(null,null,ids); |
| | | return ocList; |
| | | } |
| | | |
| | | @Override |
| | | public int insertConfig(OrganizationChartEntity entity) { |
| | | return baseMapper.insertConfig(entity); |
| | | } |
| | |
| | | return ids; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getDepartmentId(String id){ |
| | | String parentId = parentId(id); |
| | | List<String> departmentIds=new ArrayList<>(); |
| | | departmentIds.add(parentId); |
| | | List<OrganizationChartEntity> organizationChartEntities = baseMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getParentId, parentId)); |
| | | for (OrganizationChartEntity organizationChart :organizationChartEntities){ |
| | | departmentIds.add(organizationChart.getId().toString()); |
| | | departmentIds=getDepartmentIds(organizationChart.getId().toString(),departmentIds); |
| | | } |
| | | return departmentIds; |
| | | } |
| | | |
| | | @Override |
| | | public String getStairId(String id) |
| | | { |
| | | OrganizationChartEntity entity= baseMapper.selectConfigById(id); |
| | | if(entity!=null && StringUtils.isEmpty(entity.getParentId())) |
| | | { |
| | | return entity.getId()+""; |
| | | } |
| | | else |
| | | { |
| | | return getParentId(entity.getParentId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id 获取一级部门id 递归 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public String getParentId(String id) |
| | | { |
| | | String ultimatelyId; |
| | | OrganizationChartEntity entity= baseMapper.selectConfigById(id); |
| | | if(entity==null) |
| | | { |
| | | return id; |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(entity.getParentId())) |
| | | { |
| | | ultimatelyId= getParentId(entity.getParentId()); |
| | | return ultimatelyId; |
| | | } |
| | | else |
| | | { |
| | | ultimatelyId=entity.getId()+""; |
| | | return ultimatelyId; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public String parentId(String id){ |
| | | String parentId=id; |
| | | OrganizationChartEntity organizationChart = baseMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getId, id)); |
| | | if (organizationChart.getParentId().length()>0){ |
| | | parentId=parentId(organizationChart.getParentId()); |
| | | } |
| | | return parentId; |
| | | } |
| | | |
| | | public List<String> getDepartmentIds(String id,List<String> departmentIds){ |
| | | List<OrganizationChartEntity> organizationChartEntities = baseMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda().eq(OrganizationChartEntity::getParentId, id)); |
| | | if (organizationChartEntities.size()==0){ |
| | | return departmentIds; |
| | | } |
| | | else { |
| | | for (OrganizationChartEntity organizationChart :organizationChartEntities){ |
| | | departmentIds.add(organizationChart.getId().toString()); |
| | | departmentIds=getDepartmentIds(organizationChart.getId().toString(),departmentIds); |
| | | } |
| | | } |
| | | return departmentIds; |
| | | } |
| | | |
| | | |
| | | |
| | | //递归取id |