|
|
|
@ -159,74 +159,77 @@ public class BasicdataWarehouseServiceImpl extends BaseServiceImpl<BasicdataWare
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<BasicdataWarehouseEntity> getMyWarehouseList() { |
|
|
|
|
Set<Long> deptIds = new HashSet<>(); |
|
|
|
|
// 获取当前登陆人
|
|
|
|
|
BladeUser user = AuthUtil.getUser(); |
|
|
|
|
|
|
|
|
|
List<BasicdataWarehouseEntity> results = null; |
|
|
|
|
// 获取缓存中的仓库
|
|
|
|
|
List<BasicdataWarehouseEntity> results = redis.get(CacheNames.tenantKeyObj(user.getTenantId(), CacheNames.USER_WAREHOUSE_OWN, user.getUserId())); |
|
|
|
|
if(ObjectUtil.isEmpty(results)){ |
|
|
|
|
Set<Long> deptIds = new HashSet<>(); |
|
|
|
|
// 获取当前登陆人
|
|
|
|
|
|
|
|
|
|
String defaultRoleId = DictBizCache.getValue(DictBizConstant.DEFAULT_MALL_ROLE_ID, DictBizConstant.DEFAULT_MALL_ROLE_ID); |
|
|
|
|
String defaultRoleId = DictBizCache.getValue(DictBizConstant.DEFAULT_MALL_ROLE_ID, DictBizConstant.DEFAULT_MALL_ROLE_ID); |
|
|
|
|
|
|
|
|
|
log.info(">>>>>>> 当前登录的人 {} 角色信息 {}",user.getAccount(),user.getRoleId()); |
|
|
|
|
// 最大的管理员
|
|
|
|
|
if (ObjectUtil.isEmpty(user.getRoleId())) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info(">>>>>>> 当前登录的人 {} 角色信息 {}",user.getAccount(),user.getRoleId()); |
|
|
|
|
// 最大的管理员
|
|
|
|
|
if (ObjectUtil.isEmpty(user.getRoleId())) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if (user.getRoleId().contains(defaultRoleId)) { |
|
|
|
|
|
|
|
|
|
// 当前这登录的用户为商场用户
|
|
|
|
|
// 根据当前登录人查询商场信息
|
|
|
|
|
List<BasicdataClientUserEntity> basicdataClientUserEntityListByUserIds = basicdataClientUserMapper.getBasicdataClientUserEntityListByUserId(user.getUserId()); |
|
|
|
|
List clientIds = null; |
|
|
|
|
if (Func.isNotEmpty(basicdataClientUserEntityListByUserIds)) { |
|
|
|
|
clientIds = basicdataClientUserEntityListByUserIds.stream().map(BasicdataClientUserEntity::getClientId).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
// 根据商场信息查询商场的服务仓库
|
|
|
|
|
LambdaQueryWrapper<BasicdataStorageServicesEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.in(BasicdataStorageServicesEntity::getClientId, clientIds); |
|
|
|
|
// 得到仓库列表
|
|
|
|
|
List<BasicdataStorageServicesEntity> basicdataStorageServicesEntities = basicdataStorageServicesMapper.selectList(lambdaQueryWrapper); |
|
|
|
|
|
|
|
|
|
if (basicdataStorageServicesEntities != null && !basicdataStorageServicesEntities.isEmpty()) { |
|
|
|
|
results = new ArrayList<>(); |
|
|
|
|
for (BasicdataStorageServicesEntity basicdataStorageServicesEntity : basicdataStorageServicesEntities) { |
|
|
|
|
BasicdataWarehouseEntity basicdataWarehouseEntity = new BasicdataWarehouseEntity(); |
|
|
|
|
basicdataWarehouseEntity.setId(basicdataStorageServicesEntity.getServeWarehouseId()); |
|
|
|
|
basicdataWarehouseEntity.setName(basicdataStorageServicesEntity.getServeWarehouseName()); |
|
|
|
|
results.add(basicdataWarehouseEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (user.getRoleId().contains(defaultRoleId)) { |
|
|
|
|
} else { |
|
|
|
|
//查询出部门表
|
|
|
|
|
String deptId = user.getDeptId(); |
|
|
|
|
log.info(">>> 部门 {}",deptId); |
|
|
|
|
String[] split = deptId.split(","); |
|
|
|
|
for (String s : split) { |
|
|
|
|
List<Dept> userDeptNode = deptClient.getUserDeptNode(Long.parseLong(s)); |
|
|
|
|
if (Func.isEmpty(userDeptNode)) { |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
userDeptNode.forEach(u -> { |
|
|
|
|
deptIds.add(u.getId()); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
deptIds.add(Long.parseLong(s)); |
|
|
|
|
|
|
|
|
|
// 当前这登录的用户为商场用户
|
|
|
|
|
// 根据当前登录人查询商场信息
|
|
|
|
|
List<BasicdataClientUserEntity> basicdataClientUserEntityListByUserIds = basicdataClientUserMapper.getBasicdataClientUserEntityListByUserId(user.getUserId()); |
|
|
|
|
List clientIds = null; |
|
|
|
|
if (Func.isNotEmpty(basicdataClientUserEntityListByUserIds)) { |
|
|
|
|
clientIds = basicdataClientUserEntityListByUserIds.stream().map(BasicdataClientUserEntity::getClientId).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
// 根据商场信息查询商场的服务仓库
|
|
|
|
|
LambdaQueryWrapper<BasicdataStorageServicesEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.in(BasicdataStorageServicesEntity::getClientId, clientIds); |
|
|
|
|
// 得到仓库列表
|
|
|
|
|
List<BasicdataStorageServicesEntity> basicdataStorageServicesEntities = basicdataStorageServicesMapper.selectList(lambdaQueryWrapper); |
|
|
|
|
|
|
|
|
|
if (basicdataStorageServicesEntities != null && !basicdataStorageServicesEntities.isEmpty()) { |
|
|
|
|
results = new ArrayList<>(); |
|
|
|
|
for (BasicdataStorageServicesEntity basicdataStorageServicesEntity : basicdataStorageServicesEntities) { |
|
|
|
|
BasicdataWarehouseEntity basicdataWarehouseEntity = new BasicdataWarehouseEntity(); |
|
|
|
|
basicdataWarehouseEntity.setId(basicdataStorageServicesEntity.getServeWarehouseId()); |
|
|
|
|
basicdataWarehouseEntity.setName(basicdataStorageServicesEntity.getServeWarehouseName()); |
|
|
|
|
results.add(basicdataWarehouseEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//查询出部门表
|
|
|
|
|
String deptId = user.getDeptId(); |
|
|
|
|
log.info(">>> 部门 {}",deptId); |
|
|
|
|
String[] split = deptId.split(","); |
|
|
|
|
for (String s : split) { |
|
|
|
|
List<Dept> userDeptNode = deptClient.getUserDeptNode(Long.parseLong(s)); |
|
|
|
|
if (Func.isEmpty(userDeptNode)) { |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
userDeptNode.forEach(u -> { |
|
|
|
|
deptIds.add(u.getId()); |
|
|
|
|
}); |
|
|
|
|
if (deptIds.isEmpty()) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
deptIds.add(Long.parseLong(s)); |
|
|
|
|
assert results != null; |
|
|
|
|
results.addAll(baseMapper.selectList(Wrappers.<BasicdataWarehouseEntity>query().lambda().in(BasicdataWarehouseEntity::getDepartment, deptIds))) ; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (deptIds.isEmpty()) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
results = baseMapper.selectList(Wrappers.<BasicdataWarehouseEntity>query().lambda().in(BasicdataWarehouseEntity::getDepartment, deptIds)); |
|
|
|
|
|
|
|
|
|
redis.setEx(CacheNames.tenantKeyObj(user.getTenantId(), CacheNames.USER_WAREHOUSE_OWN, user.getUserId()),results,3600L); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return results; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|