报表管理仓库出租率列表查询数据隔离
This commit is contained in:
+59
@@ -308,6 +308,55 @@ public class LeaseApplicationService {
|
||||
* businessDateEnd 业务结束时间
|
||||
*/
|
||||
public List<WarehouseOccupancyRate> warehouseOccupancyRate(ShipperLeaseDetailsDO shipperLeaseDetailsDO) {
|
||||
// 数据权限:根据 organizationId 来设置查询权限
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null) {
|
||||
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long frontendOrganizationId = shipperLeaseDetailsDO.getOrganizationId(); // 前端传递的 organizationId
|
||||
|
||||
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
|
||||
if (userOrganizationId != null && userOrganizationId == 2827L) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
shipperLeaseDetailsDO.setOrganizationId(frontendOrganizationId);
|
||||
shipperLeaseDetailsDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
shipperLeaseDetailsDO.setOrganizationId(null);
|
||||
shipperLeaseDetailsDO.setTopOrganizationId(null);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (frontendOrganizationId != null && userOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(userOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
shipperLeaseDetailsDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
if (userOrganizationId != null) {
|
||||
shipperLeaseDetailsDO.setOrganizationId(userOrganizationId);
|
||||
}
|
||||
}
|
||||
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
|
||||
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
|
||||
if (shipperLeaseDetailsDO.getOrganizationId() == null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
shipperLeaseDetailsDO.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
} else {
|
||||
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
|
||||
shipperLeaseDetailsDO.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
//仓库id 和 开始结束时间作为查询条件 查数据库 查出来当前仓库所有的
|
||||
List<ShipperLeaseDetailsPO> shipperLeaseDetailsList = shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO);
|
||||
if (shipperLeaseDetailsList == null || shipperLeaseDetailsList.isEmpty()) {
|
||||
@@ -349,6 +398,16 @@ public class LeaseApplicationService {
|
||||
warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName());
|
||||
warehouseOccupancyRate.setBusinessDate(date);
|
||||
warehouseOccupancyRate.setWarehouseId(shipperLeaseDetail.getWarehouseId());
|
||||
// 设置组织相关字段(从第一个非空记录中获取)
|
||||
if (warehouseOccupancyRate.getOrganizationId() == null && shipperLeaseDetail.getOrganizationId() != null) {
|
||||
warehouseOccupancyRate.setOrganizationId(shipperLeaseDetail.getOrganizationId());
|
||||
}
|
||||
if (warehouseOccupancyRate.getOrganizationName() == null && shipperLeaseDetail.getOrganizationName() != null) {
|
||||
warehouseOccupancyRate.setOrganizationName(shipperLeaseDetail.getOrganizationName());
|
||||
}
|
||||
if (warehouseOccupancyRate.getTopOrganizationId() == null && shipperLeaseDetail.getTopOrganizationId() != null) {
|
||||
warehouseOccupancyRate.setTopOrganizationId(shipperLeaseDetail.getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
warehouseOccupancyRate.setEntireLeaseArea(entireLeaseArea);
|
||||
warehouseOccupancyRate.setFractionalLeaseArea(fractionalLeaseArea);
|
||||
|
||||
Reference in New Issue
Block a user