|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.basics.domain.PtRoom;
|
|
|
import org.dromara.backstage.basics.domain.PtRoomType;
|
|
|
import org.dromara.backstage.basics.domain.bo.PtRoomBatchSetBo;
|
|
|
@@ -24,7 +25,9 @@ import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
+import org.dromara.hotel.api.service.RemoteAreaPermissionsService;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -49,6 +52,9 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
|
|
|
private final PtRoomTypeMapper roomTypeMapper;
|
|
|
|
|
|
+ @DubboReference
|
|
|
+ private RemoteAreaPermissionsService areaPermissionsService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询房间定义
|
|
|
*
|
|
|
@@ -97,6 +103,15 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
@Override
|
|
|
public TableDataInfo<PtRoomVo> queryPageListByAreaIds(QueryRoomBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<PtRoom> lqw = new LambdaQueryWrapper<>();
|
|
|
+ //校验权限
|
|
|
+ boolean isAdmin = LoginHelper.isSuperAdmin();
|
|
|
+ if (!isAdmin) {
|
|
|
+ List<Long> floors = getHasPermissionFloor(LoginHelper.getUserId());
|
|
|
+ if(CollectionUtil.isEmpty(floors)){
|
|
|
+ return TableDataInfo.build(new Page<>());
|
|
|
+ }
|
|
|
+ lqw.in(PtRoom::getAreaId, floors);
|
|
|
+ }
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRoomType()), PtRoom::getRoomType, bo.getRoomType());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), PtRoom::getStatus, bo.getStatus());
|
|
|
lqw.in(CollectionUtil.isNotEmpty(bo.getFloorIds()), PtRoom::getAreaId, bo.getFloorIds())
|
|
|
@@ -152,6 +167,16 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ //校验权限
|
|
|
+ boolean isAdmin = LoginHelper.isSuperAdmin();
|
|
|
+ if (!isAdmin) {
|
|
|
+ List<Long> floors = getHasPermissionFloor(LoginHelper.getUserId());
|
|
|
+ if(CollectionUtil.isEmpty(floors)){
|
|
|
+ // 没有任何权限
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ lqw.in(PtRoom::getAreaId, floors);
|
|
|
+ }
|
|
|
lqw.orderByDesc(PtRoom::getCreateTime);
|
|
|
List<PtRoomVo> ptRoomVos = baseMapper.selectVoList(lqw);
|
|
|
setAreaName(ptRoomVos);
|
|
|
@@ -170,6 +195,20 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据区域id查询房间
|
|
|
+ * @param bo
|
|
|
+ * @param areaIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PtRoomVo> selectListByAreas(PtRoomBo bo,List<Long> areaIds) {
|
|
|
+ LambdaQueryWrapper<PtRoom> lqw = buildQueryWrapper(bo);
|
|
|
+ if (CollectionUtil.isNotEmpty(areaIds)){
|
|
|
+ lqw.in(PtRoom::getAreaId,areaIds);
|
|
|
+ }
|
|
|
+ return baseMapper.selectVoList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 仅用于选择房间
|
|
|
*
|
|
|
@@ -309,22 +348,37 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
/**
|
|
|
* 查询所有房间状态的房间数量
|
|
|
*
|
|
|
+ * 根据客房权限,进行过滤
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<String, Long> getCountByStatus() {
|
|
|
|
|
|
+ HotelRoomStatusEnum[] values = HotelRoomStatusEnum.values();
|
|
|
Map<String, Long> map = new HashMap<>();
|
|
|
+ List<Long> floors = new ArrayList<>();
|
|
|
+
|
|
|
+ boolean isAdmin = LoginHelper.isSuperAdmin();
|
|
|
+ Long userId = LoginHelper.getUserId();
|
|
|
+ if(!isAdmin){
|
|
|
+ floors = getHasPermissionFloor(userId);
|
|
|
+ if(CollectionUtil.isEmpty(floors)){
|
|
|
+ for (HotelRoomStatusEnum value : values) {
|
|
|
+ map.put(value.code(), 0L);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
LambdaQueryWrapper<PtRoom> lambdaQuery = Wrappers.<PtRoom>lambdaQuery();
|
|
|
- lambdaQuery.eq(PtRoom::getRoomType, FJLXEnum.KF.code());
|
|
|
+ lambdaQuery.eq(PtRoom::getRoomType, FJLXEnum.KF.code()).in(!isAdmin, PtRoom::getAreaId, floors);
|
|
|
|
|
|
List<PtRoomVo> list = baseMapper.selectVoList(lambdaQuery);
|
|
|
|
|
|
// 按 status 分组 统计
|
|
|
Map<String, Long> mapList = list.stream().collect(Collectors.groupingBy(PtRoomVo::getStatus, Collectors.counting()));
|
|
|
|
|
|
- HotelRoomStatusEnum[] values = HotelRoomStatusEnum.values();
|
|
|
if (mapList.isEmpty()) {
|
|
|
for (HotelRoomStatusEnum value : values) {
|
|
|
map.put(value.code(), 0L);
|
|
|
@@ -338,6 +392,21 @@ public class PtRoomServiceImpl implements IPtRoomService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询当前账号有权限的楼层
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Long> getHasPermissionFloor(Long userId){
|
|
|
+ List<Long> rs = new ArrayList<>();
|
|
|
+ List<Long> areaPermissions = areaPermissionsService.getAreaPermissions(userId);
|
|
|
+ if(CollectionUtil.isNotEmpty(areaPermissions)){
|
|
|
+ // 根据楼栋 查询 楼层
|
|
|
+ return areaService.queryFloorByLDList(areaPermissions);
|
|
|
+ }
|
|
|
+
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|