Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
zhou-hongcheng
2026-02-25 11:01:23 +08:00
12 changed files with 350 additions and 64 deletions
@@ -308,6 +308,55 @@ public class LeaseApplicationService {
* businessDateEnd 业务结束时间 * businessDateEnd 业务结束时间
*/ */
public List<WarehouseOccupancyRate> warehouseOccupancyRate(ShipperLeaseDetailsDO shipperLeaseDetailsDO) { 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 和 开始结束时间作为查询条件 查数据库 查出来当前仓库所有的 //仓库id 和 开始结束时间作为查询条件 查数据库 查出来当前仓库所有的
List<ShipperLeaseDetailsPO> shipperLeaseDetailsList = shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO); List<ShipperLeaseDetailsPO> shipperLeaseDetailsList = shipperLeaseDetailsService.queryList(shipperLeaseDetailsDO);
if (shipperLeaseDetailsList == null || shipperLeaseDetailsList.isEmpty()) { if (shipperLeaseDetailsList == null || shipperLeaseDetailsList.isEmpty()) {
@@ -349,6 +398,16 @@ public class LeaseApplicationService {
warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName()); warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName());
warehouseOccupancyRate.setBusinessDate(date); warehouseOccupancyRate.setBusinessDate(date);
warehouseOccupancyRate.setWarehouseId(shipperLeaseDetail.getWarehouseId()); 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.setEntireLeaseArea(entireLeaseArea);
warehouseOccupancyRate.setFractionalLeaseArea(fractionalLeaseArea); warehouseOccupancyRate.setFractionalLeaseArea(fractionalLeaseArea);
@@ -34,22 +34,55 @@ public class DifferentManageApplicationService {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) { if (loginUser != null && loginUser.getUserPo() != null) {
Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
// 当前登录用户组织ID为2827时,查询所有组织的数据 Long frontendOrganizationId = differentManageDO.getOrganizationId(); // 前端传递的 organizationId
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) { if (userOrganizationId != null && userOrganizationId == 2827L) {
// 不设置organizationId查询所有组织的数据 // 南光组织(organizationId=2827):可以查询所有组织的数据
differentManageDO.setOrganizationId(null); // 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
differentManageDO.setOrganizationId(frontendOrganizationId);
differentManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
differentManageDO.setOrganizationId(null);
differentManageDO.setTopOrganizationId(null);
}
} else { } else {
// 其他情况,只查询当前登录用户所属组织的数据 // 其他组织:设置organizationId,只查询当前组织的数据
if (userOrganizationId != null) { // 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
differentManageDO.setOrganizationId(userOrganizationId); if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
differentManageDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
differentManageDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (differentManageDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
differentManageDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
differentManageDO.setTopOrganizationId(null);
} }
} }
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
differentManageDO.setTopOrganizationId(topOrganizationId);
}
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
differentManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); if (associationWarehouseCacheDO != null) {
differentManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
} }
return differentManageDomainService.queryList(differentManageDO); return differentManageDomainService.queryList(differentManageDO);
} }
@@ -50,13 +50,57 @@ public class InventoryAdjustmentRecordApplicationService {
public List<InventoryAdjustmentRecordPO> queryList(InventoryAdjustmentRecordDO inventoryAdjustmentRecordDO) { public List<InventoryAdjustmentRecordPO> queryList(InventoryAdjustmentRecordDO inventoryAdjustmentRecordDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){ if (loginUser != null && loginUser.getUserPo() != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){ Long frontendOrganizationId = inventoryAdjustmentRecordDO.getOrganizationId(); // 前端传递的 organizationId
inventoryAdjustmentRecordDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
inventoryAdjustmentRecordDO.setOrganizationId(frontendOrganizationId);
inventoryAdjustmentRecordDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
inventoryAdjustmentRecordDO.setOrganizationId(null);
inventoryAdjustmentRecordDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId,只查询当前组织的数据
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
inventoryAdjustmentRecordDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
inventoryAdjustmentRecordDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (inventoryAdjustmentRecordDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
inventoryAdjustmentRecordDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
inventoryAdjustmentRecordDO.setTopOrganizationId(null);
}
} }
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
inventoryAdjustmentRecordDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); if (associationWarehouseCacheDO != null) {
inventoryAdjustmentRecordDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
} }
List<InventoryAdjustmentRecordPO> inventoryAdjustmentRecordPOS = inventoryAdjustmentRecordDomainService.queryList(inventoryAdjustmentRecordDO); List<InventoryAdjustmentRecordPO> inventoryAdjustmentRecordPOS = inventoryAdjustmentRecordDomainService.queryList(inventoryAdjustmentRecordDO);
@@ -66,22 +66,55 @@ public class InvestigationManageApplicationService {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) { if (loginUser != null && loginUser.getUserPo() != null) {
Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
// 当前登录用户组织ID为2827时,查询所有组织的数据 Long frontendOrganizationId = investigationManageDO.getOrganizationId(); // 前端传递的 organizationId
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) { if (userOrganizationId != null && userOrganizationId == 2827L) {
// 不设置organizationId查询所有组织的数据 // 南光组织(organizationId=2827):可以查询所有组织的数据
investigationManageDO.setOrganizationId(null); // 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
investigationManageDO.setOrganizationId(frontendOrganizationId);
investigationManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
investigationManageDO.setOrganizationId(null);
investigationManageDO.setTopOrganizationId(null);
}
} else { } else {
// 其他情况,只查询当前登录用户所属组织的数据 // 其他组织:设置organizationId,只查询当前组织的数据
if (userOrganizationId != null) { // 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
investigationManageDO.setOrganizationId(userOrganizationId); if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
investigationManageDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
investigationManageDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (investigationManageDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
investigationManageDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
investigationManageDO.setTopOrganizationId(null);
} }
} }
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
investigationManageDO.setTopOrganizationId(topOrganizationId);
}
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
investigationManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); if (associationWarehouseCacheDO != null) {
investigationManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
} }
return investigationManageDomainService.queryList(investigationManageDO); return investigationManageDomainService.queryList(investigationManageDO);
} }
@@ -53,20 +53,50 @@ public class MaterialInventoryApplicationService {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null){ if (loginUser != null && loginUser.getUserPo() != null){
Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
// 当前登录用户组织ID为2827时,查询所有组织的数据 Long frontendOrganizationId = materialInventoryDO.getOrganizationId(); // 前端传递的 organizationId
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) { if (userOrganizationId != null && userOrganizationId == 2827L) {
// 不设置organizationId查询所有组织的数据 // 南光组织(organizationId=2827):可以查询所有组织的数据
materialInventoryDO.setOrganizationId(null); // 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
materialInventoryDO.setOrganizationId(frontendOrganizationId);
materialInventoryDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
materialInventoryDO.setOrganizationId(null);
materialInventoryDO.setTopOrganizationId(null);
}
} else { } else {
// 其他情况,只查询当前登录用户所属组织的数据 // 其他组织:设置organizationId,只查询当前组织的数据
if (userOrganizationId != null) { // 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
materialInventoryDO.setOrganizationId(userOrganizationId); if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
materialInventoryDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
materialInventoryDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (materialInventoryDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
materialInventoryDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
materialInventoryDO.setTopOrganizationId(null);
} }
}
// 处理topOrganizationId逻辑
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
materialInventoryDO.setTopOrganizationId(topOrganizationId);
} }
// 前端有传warehouseId则优先使用传参;未传时才使用"用户关联仓库"作为默认值 // 前端有传warehouseId则优先使用传参;未传时才使用"用户关联仓库"作为默认值
if (materialInventoryDO.getWarehouseId() == null) { if (materialInventoryDO.getWarehouseId() == null) {
@@ -69,22 +69,55 @@ public class ShiftManageApplicationService {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) { if (loginUser != null && loginUser.getUserPo() != null) {
Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
// 当前登录用户组织ID为2827时,查询所有组织的数据 Long frontendOrganizationId = shiftManageDO.getOrganizationId(); // 前端传递的 organizationId
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) { if (userOrganizationId != null && userOrganizationId == 2827L) {
// 不设置organizationId查询所有组织的数据 // 南光组织(organizationId=2827):可以查询所有组织的数据
shiftManageDO.setOrganizationId(null); // 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
shiftManageDO.setOrganizationId(frontendOrganizationId);
shiftManageDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
shiftManageDO.setOrganizationId(null);
shiftManageDO.setTopOrganizationId(null);
}
} else { } else {
// 其他情况,只查询当前登录用户所属组织的数据 // 其他组织:设置organizationId,只查询当前组织的数据
if (userOrganizationId != null) { // 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
shiftManageDO.setOrganizationId(userOrganizationId); if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
shiftManageDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
shiftManageDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (shiftManageDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
shiftManageDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
shiftManageDO.setTopOrganizationId(null);
} }
} }
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
shiftManageDO.setTopOrganizationId(topOrganizationId);
}
AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); AssociationWarehouseCacheDO associationWarehouseCacheDO = SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
shiftManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); if (associationWarehouseCacheDO != null) {
shiftManageDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId());
}
} }
return shiftManageDomainService.queryList(shiftManageDO); return shiftManageDomainService.queryList(shiftManageDO);
} }
@@ -53,10 +53,52 @@ public class StatementStatisticsService {
public List<ImmediateInventoryPO> queryImmediateInventoryList(ImmediateInventoryDO immediateInventoryDO) { public List<ImmediateInventoryPO> queryImmediateInventoryList(ImmediateInventoryDO immediateInventoryDO) {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){ if (loginUser != null && loginUser.getUserPo() != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){ Long frontendOrganizationId = immediateInventoryDO.getOrganizationId(); // 前端传递的 organizationId
immediateInventoryDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
// 数据权限:根据 organizationId 来设置查询权限
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己
if (userOrganizationId != null && userOrganizationId == 2827L) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
// 如果前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
immediateInventoryDO.setOrganizationId(frontendOrganizationId);
immediateInventoryDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
immediateInventoryDO.setOrganizationId(null);
immediateInventoryDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId,只查询当前组织的数据
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
immediateInventoryDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
immediateInventoryDO.setOrganizationId(userOrganizationId);
}
}
// 只有当 organizationId 为 null 时,才使用 topOrganizationId 作为查询条件
// 如果 organizationId 不为 null,则优先使用 organizationId,不使用 topOrganizationId
if (immediateInventoryDO.getOrganizationId() == null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
immediateInventoryDO.setTopOrganizationId(topOrganizationId);
}
} else {
// 如果 organizationId 不为 null,清空 topOrganizationId,确保查询使用 organizationId
immediateInventoryDO.setTopOrganizationId(null);
}
} }
// 只有在用户没有明确指定仓库参数时,才使用缓存中的仓库信息 // 只有在用户没有明确指定仓库参数时,才使用缓存中的仓库信息
// 如果用户已经传递了 warehouseId、warehouseCode 或 warehouseName,优先使用这些值 // 如果用户已经传递了 warehouseId、warehouseCode 或 warehouseName,优先使用这些值
@@ -597,7 +597,7 @@ public class StockOutOrderApplicationService {
StockOutOrderDO stockOutOrderD = new StockOutOrderDO(); StockOutOrderDO stockOutOrderD = new StockOutOrderDO();
StockOutOrder stockOutOrderDb = stockOutOrderService.getById(outOrderId); StockOutOrder stockOutOrderDb = stockOutOrderService.getById(outOrderId);
if (stockOutOrderDb == null){ if (stockOutOrderDb == null){
throw new ServiceException("出库单ID不存在"); throw new ServiceException("出库单不存在");
} }
BeanUtils.copyProperties(stockOutOrderDb, stockOutOrderD); BeanUtils.copyProperties(stockOutOrderDb, stockOutOrderD);
List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailService.list(new QueryWrapper<OutMaterialDetail>().lambda() List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailService.list(new QueryWrapper<OutMaterialDetail>().lambda()
@@ -627,7 +627,7 @@ public class StockOutOrderApplicationService {
detail.setStorageCode(materialInventory.getStorageCode()); detail.setStorageCode(materialInventory.getStorageCode());
} }
stockOutOrderD.setMaterialDetailList(materialDetailList); stockOutOrderD.setMaterialDetailList(materialDetailList);
StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderDO); StockOutOrderDO assembleStockOutOrderDO = assembleParamByOutOrder(stockOutOrderD);
Boolean assignResult = stockOutOrderDomainService.autoAssign(assembleStockOutOrderDO); Boolean assignResult = stockOutOrderDomainService.autoAssign(assembleStockOutOrderDO);
if (!assignResult) { if (!assignResult) {
result = false; result = false;
@@ -417,9 +417,9 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) { for (OutMaterialDetail outMaterialDetail : outMaterialDetailList) {
BigDecimal alreadyAllocationQuantity = outMaterialDetail.getAlreadyAllocationQuantity(); BigDecimal alreadyAllocationQuantity = outMaterialDetail.getAlreadyAllocationQuantity();
// 如果已经分配数量大于0则跳过本次循环该明细已分配过不再重复处理 // 如果已经分配数量大于0则跳过本次循环该明细已分配过不再重复处理
if (alreadyAllocationQuantity != null && alreadyAllocationQuantity.compareTo(BigDecimal.ZERO) > 0) { /*if (alreadyAllocationQuantity != null && alreadyAllocationQuantity.compareTo(BigDecimal.ZERO) > 0) {
continue; continue;
} }*/
Long materialInventoryId = outMaterialDetail.getMaterialInventoryId(); Long materialInventoryId = outMaterialDetail.getMaterialInventoryId();
BigDecimal allocationQuantity = outMaterialDetail.getAllocationQuantity(); BigDecimal allocationQuantity = outMaterialDetail.getAllocationQuantity();
if (ObjectUtils.isEmpty(allocationQuantity)) { if (ObjectUtils.isEmpty(allocationQuantity)) {
@@ -115,5 +115,13 @@ public class ImmediateInventoryPO {
@ApiModelProperty("物料更多属性列表(批次属性)") @ApiModelProperty("物料更多属性列表(批次属性)")
private List<MaterialMoreDetailPO> materialMoreDetailList; private List<MaterialMoreDetailPO> materialMoreDetailList;
@ApiModelProperty("组织ID")
private Long organizationId;
@ApiModelProperty("组织名称")
private String organizationName;
@ApiModelProperty("顶级组织ID")
private Long topOrganizationId;
} }
@@ -258,10 +258,6 @@ public class StockOutOrderDomainService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){ public Boolean autoAssign(StockOutOrderDO stockOutOrderDO){
List<Long> outOrderIds = stockOutOrderDO.getOutOrderIds();
if (outOrderIds == null || outOrderIds.isEmpty()){
throw new ServiceException("出库单ID不能为空");
}
StockOutOrder stockOutOrderDb = stockOutOrderService.getById(stockOutOrderDO.getOutOrderId()); StockOutOrder stockOutOrderDb = stockOutOrderService.getById(stockOutOrderDO.getOutOrderId());
if (stockOutOrderDb == null){ if (stockOutOrderDb == null){
throw new ServiceException("出库单不存在"); throw new ServiceException("出库单不存在");
@@ -269,8 +265,6 @@ public class StockOutOrderDomainService {
if (stockOutOrderDb.getStatus() > 3){ if (stockOutOrderDb.getStatus() > 3){
throw new ServiceException("收货单已完成分配"); throw new ServiceException("收货单已完成分配");
} }
List<OutMaterialDetail> outMaterialDetailList = outMaterialDetailService.list(new QueryWrapper<OutMaterialDetail>().lambda()
.eq(OutMaterialDetail::getOutOrderNumber, stockOutOrderDb.getOutOrderNumber()));
//修改物料明细信息 //修改物料明细信息
StockOutOrderPO stockOutOrderPO = outMaterialDetailService.batchAssignUpdate(stockOutOrderDb.getOutOrderNumber(), stockOutOrderDO.getMaterialDetailList()); StockOutOrderPO stockOutOrderPO = outMaterialDetailService.batchAssignUpdate(stockOutOrderDb.getOutOrderNumber(), stockOutOrderDO.getMaterialDetailList());
//修改出库单 //修改出库单
@@ -433,6 +433,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="boxPalletNo" column="box_pallet_no" /> <result property="boxPalletNo" column="box_pallet_no" />
<result property="materialBaseInfoId" column="material_base_info_id" /> <result property="materialBaseInfoId" column="material_base_info_id" />
<result property="materialInventoryId" column="material_inventory_id" /> <result property="materialInventoryId" column="material_inventory_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
</resultMap> </resultMap>
<select id="queryImmediateInventoryList" parameterType="com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO" <select id="queryImmediateInventoryList" parameterType="com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO"
resultMap="queryImmediateInventoryListResult"> resultMap="queryImmediateInventoryListResult">
@@ -541,13 +544,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.sheet_ref_no, a.sheet_ref_no,
a.box_pallet_no, a.box_pallet_no,
b.material_base_info_id, b.material_base_info_id,
a.material_inventory_id a.material_inventory_id,
a.organization_id,
a.organization_name,
a.top_organization_id
FROM FROM
material_inventory a material_inventory a
left join material_base_info b on a.material_base_info_id=b.material_base_info_id left join material_base_info b on a.material_base_info_id=b.material_base_info_id
WHERE WHERE
a.del_flag = 1 a.del_flag = 1
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</if>
<if test="topOrganizationId != null "> <if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId} and a.top_organization_id = #{topOrganizationId}
</if> </if>