|
|
@@ -210,12 +210,61 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc |
|
|
|
@Override |
|
|
|
public JsonResult getSectionInfo() { |
|
|
|
//获取登录信息 |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
User user = CurrentUserUtil.getUserInfo(); |
|
|
|
if (ObjectUtil.isNull(user)) { |
|
|
|
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); |
|
|
|
} |
|
|
|
user.setDataPermission(3); |
|
|
|
//获取登录信息 |
|
|
|
String tenantId = user.getTenantId(); |
|
|
|
if (StringUtils.isEmpty(tenantId)) { |
|
|
|
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(), StructureEnum.TENANT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) |
|
|
|
.eq(Structure::getTenantId, tenantId)); |
|
|
|
List<Structure> structures = null; |
|
|
|
// 所有部门权限 |
|
|
|
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { |
|
|
|
structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) |
|
|
|
.eq(Structure::getTenantId, tenantId)); |
|
|
|
} |
|
|
|
// 本部门及下属部门、本部门 |
|
|
|
else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() |
|
|
|
|| DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
if (StringUtils.isEmpty(deptId)) { |
|
|
|
return JsonResult.error(SectionEnum.DEPT_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
List<String> deptIdList = new ArrayList<>(); |
|
|
|
// 本部门及下属部门 |
|
|
|
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { |
|
|
|
List<String> deptAndSubList = deptMapper.selectAllChildListById(deptId); |
|
|
|
if (StringUtils.isEmpty(deptAndSubList) && deptAndSubList.size() <= 0) { |
|
|
|
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
deptIdList.addAll(deptAndSubList); |
|
|
|
} |
|
|
|
// 本部门 |
|
|
|
else { |
|
|
|
deptIdList.add(deptId); |
|
|
|
} |
|
|
|
// 相关路段 |
|
|
|
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() |
|
|
|
.eq(SectionDept::getTenantId, tenantId) |
|
|
|
.in(SectionDept::getDeptId, deptIdList)); |
|
|
|
if (StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size() <= 0) { |
|
|
|
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//查询对应的路段ID |
|
|
|
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList()); |
|
|
|
if (StringUtils.isEmpty(sectionIdList)) { |
|
|
|
return JsonResult.error(SectionEnum.SECTION_ID_IS_NULL.getCode(), SectionEnum.SECTION_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery() |
|
|
|
.eq(Structure::getMark, 1) |
|
|
|
.eq(Structure::getTenantId, tenantId) |
|
|
|
.in(Structure::getSectionId, sectionIdList) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
if (null == structures) { |
|
|
|
return JsonResult.error(); |
|
|
|
} |