feat: 获取当前租户
This commit is contained in:
+37
-8
@@ -61,7 +61,15 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
route.setSafeDistance(dto.getSafeDistance());
|
||||
route.setBoundaryId(dto.getBoundaryId());
|
||||
route.setRemark(dto.getRemark());
|
||||
route.setTenantId(LoginUserContextHolder.getCurrentTenantId());
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
route.setTenantId(anchor);
|
||||
route.setStatus(BoatRoute.RouteStatus.DRAFT.getCode());
|
||||
route.setIsTemplate(false);
|
||||
route.setShowInModel(dto.getShowInModel() != null ? dto.getShowInModel() : 0);
|
||||
@@ -210,16 +218,23 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
throw new BusinessException("设备SN不能为空");
|
||||
}
|
||||
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
List<String> ids = routeIds == null ? Collections.emptyList() : routeIds.stream()
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(StrUtil::trim)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, tenantId);
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, anchor);
|
||||
if (!ids.isEmpty()) {
|
||||
baseMapper.setShowInModelByRouteIds(sn, tenantId, ids);
|
||||
baseMapper.setShowInModelByRouteIds(sn, anchor, ids);
|
||||
}
|
||||
|
||||
log.info("更新无人船航线模型显示状态成功: deviceSn={}, showCount={}", sn, ids.size());
|
||||
@@ -261,12 +276,19 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
|
||||
@Override
|
||||
public Page<BoatRouteListVO> listByScenicId(Long scenicId, Integer page, Integer size) {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
Page<BoatRoute> pageParam = new Page<>(page, size);
|
||||
|
||||
LambdaQueryWrapper<BoatRoute> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BoatRoute::getScenicId, scenicId)
|
||||
.eq(BoatRoute::getTenantId, tenantId)
|
||||
.eq(BoatRoute::getTenantId, anchor)
|
||||
.eq(BoatRoute::getDeleted, 0)
|
||||
.orderByDesc(BoatRoute::getCreateTime);
|
||||
|
||||
@@ -422,8 +444,15 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
|
||||
@Override
|
||||
public List<BoatRouteListVO> listTemplates() {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<BoatRoute> templates = baseMapper.selectTemplates(tenantId);
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
List<BoatRoute> templates = baseMapper.selectTemplates(anchor);
|
||||
return convertToListVO(templates);
|
||||
}
|
||||
|
||||
|
||||
+37
-8
@@ -55,7 +55,15 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
boundary.setSourceType(dto.getSourceType() != null ? dto.getSourceType() : WaterBoundary.SourceType.MANUAL.getCode());
|
||||
boundary.setModelId(dto.getModelId());
|
||||
boundary.setShowInModel(dto.getShowInModel() != null ? dto.getShowInModel() : 1);
|
||||
boundary.setTenantId(LoginUserContextHolder.getCurrentTenantId());
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
boundary.setTenantId(anchor);
|
||||
boundary.setStatus(1); // 启用状态
|
||||
|
||||
this.save(boundary);
|
||||
@@ -71,8 +79,15 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
|
||||
@Override
|
||||
public List<WaterBoundaryVO> listByDeviceSn(String deviceSn) {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<WaterBoundary> boundaries = baseMapper.selectByDeviceSn(deviceSn, tenantId);
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
List<WaterBoundary> boundaries = baseMapper.selectByDeviceSn(deviceSn, anchor);
|
||||
return boundaries.stream()
|
||||
.map(b -> {
|
||||
WaterBoundaryVO vo = BeanUtil.copyProperties(b, WaterBoundaryVO.class);
|
||||
@@ -85,8 +100,15 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
|
||||
@Override
|
||||
public List<WaterBoundaryVO> listByScenicId(Long scenicId) {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<WaterBoundary> boundaries = baseMapper.selectByScenicId(scenicId, tenantId);
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
List<WaterBoundary> boundaries = baseMapper.selectByScenicId(scenicId, anchor);
|
||||
return boundaries.stream()
|
||||
.map(b -> {
|
||||
WaterBoundaryVO vo = BeanUtil.copyProperties(b, WaterBoundaryVO.class);
|
||||
@@ -198,7 +220,14 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
throw new BusinessException("设备SN不能为空");
|
||||
}
|
||||
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
String anchor = LoginUserContextHolder.getCurrentTenantId();
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
List<String> ids = boundaryIds == null ? Collections.emptyList() : boundaryIds.stream()
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(StrUtil::trim)
|
||||
@@ -206,9 +235,9 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 先全量重置为不显示,再批量置为显示(保证“选择几个就保存几个”)
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, tenantId);
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, anchor);
|
||||
if (!ids.isEmpty()) {
|
||||
baseMapper.setShowInModelByBoundaryIds(sn, tenantId, ids);
|
||||
baseMapper.setShowInModelByBoundaryIds(sn, anchor, ids);
|
||||
}
|
||||
|
||||
log.info("更新水域边界标绘显示状态成功: deviceSn={}, showCount={}", sn, ids.size());
|
||||
|
||||
Reference in New Issue
Block a user