出入库异常未按照仓库过滤

This commit is contained in:
秦鸿展
2026-04-22 09:18:18 +08:00
parent 6899e642c7
commit 4c1831ec6b
2 changed files with 49 additions and 20 deletions
@@ -32,17 +32,31 @@ public class InOrderAbnormalApplicationService {
public List<InOrderAbnormalPO> queryList(InOrderAbnormalDO inOrderAbnormalDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
inOrderAbnormalDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
if (loginUser != null && loginUser.getUserPo() != null) {
AssociationWarehouseCacheDO cache =
SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (inOrderAbnormalDO.getWarehouseId() == null && cache != null
&& cache.getWarehouseId() != null) {
inOrderAbnormalDO.setWarehouseId(cache.getWarehouseId());
}
// 请求未带 warehouseId 时用用户关联仓库;带了则以请求为准(与出库异常一致)
if (inOrderAbnormalDO.getWarehouseId() == null) {
AssociationWarehouseCacheDO cache =
SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (cache != null && cache.getWarehouseId() != null) {
inOrderAbnormalDO.setWarehouseId(cache.getWarehouseId());
if (inOrderAbnormalDO.getTopOrganizationId() == null) {
Long top = loginUser.getUserPo().getTopOrganizationId();
if (top == null || Long.valueOf(1L).equals(top)) {
if (cache != null) {
top = cache.getTopOrganizationId();
}
}
if (top != null && !Long.valueOf(1L).equals(top)) {
inOrderAbnormalDO.setTopOrganizationId(top);
}
}
if (inOrderAbnormalDO.getOrganizationId() == null) {
Long orgId = loginUser.getUserPo().getOrganizationId();
if (orgId == null && cache != null) {
orgId = cache.getOrganizationId();
}
if (orgId != null) {
inOrderAbnormalDO.setOrganizationId(orgId);
}
}
}
@@ -32,17 +32,32 @@ public class OutOrderAbnormalApplicationService {
public List<OutOrderAbnormalPO> queryList(OutOrderAbnormalDO outOrderAbnormalDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
outOrderAbnormalDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
if (loginUser != null && loginUser.getUserPo() != null) {
// 请求带仓库时也会读关联缓存,用于补全「会话里为空的组织」(UserPo 常见无 organizationId
AssociationWarehouseCacheDO cache =
SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (outOrderAbnormalDO.getWarehouseId() == null && cache != null
&& cache.getWarehouseId() != null) {
outOrderAbnormalDO.setWarehouseId(cache.getWarehouseId());
}
// 请求未带 warehouseId 时用用户关联仓库;带了则以请求为准(与入库异常一致)
if (outOrderAbnormalDO.getWarehouseId() == null) {
AssociationWarehouseCacheDO cache =
SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid());
if (cache != null && cache.getWarehouseId() != null) {
outOrderAbnormalDO.setWarehouseId(cache.getWarehouseId());
if (outOrderAbnormalDO.getTopOrganizationId() == null) {
Long top = loginUser.getUserPo().getTopOrganizationId();
if (top == null || Long.valueOf(1L).equals(top)) {
if (cache != null) {
top = cache.getTopOrganizationId();
}
}
if (top != null && !Long.valueOf(1L).equals(top)) {
outOrderAbnormalDO.setTopOrganizationId(top);
}
}
if (outOrderAbnormalDO.getOrganizationId() == null) {
Long orgId = loginUser.getUserPo().getOrganizationId();
if (orgId == null && cache != null) {
orgId = cache.getOrganizationId();
}
if (orgId != null) {
outOrderAbnormalDO.setOrganizationId(orgId);
}
}
}