You've already forked FrameTour-BE
feat(device): 支持按多个景区ID查询设备列表
- 在 DeviceV2Client 中新增 scenicIds 查询参数 - 修改 DeviceIntegrationService.listDevices 方法以支持 scenicIds 参数 - 优化参数优先级逻辑:scenicId 优先于 scenicIds - 更新所有调用点以传递新的 scenicIds 参数 - 保持向后兼容性,确保原有接口行为不变 - 增加日志记录以便调试和监控参数使用情况
This commit is contained in:
@@ -53,9 +53,9 @@ public class DeviceV2Controller {
|
||||
if (pageSize > 100) {
|
||||
pageSize = 100;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
PageResponse<DeviceV2DTO> response = deviceIntegrationService.listDevices(page, pageSize, name, no, type, isActive, scenicId);
|
||||
PageResponse<DeviceV2DTO> response = deviceIntegrationService.listDevices(page, pageSize, name, no, type, isActive, scenicId, null);
|
||||
return ApiResponse.success(response);
|
||||
} catch (Exception e) {
|
||||
log.error("分页查询设备核心信息列表失败", e);
|
||||
@@ -380,7 +380,7 @@ public class DeviceV2Controller {
|
||||
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||||
log.info("获取景区所有设备列表, scenicId: {}, page: {}, pageSize: {}", scenicId, page, pageSize);
|
||||
try {
|
||||
PageResponse<DeviceV2DTO> response = deviceIntegrationService.listDevices(page, pageSize, name, no, type, null, scenicId);
|
||||
PageResponse<DeviceV2DTO> response = deviceIntegrationService.listDevices(page, pageSize, name, no, type, null, scenicId, null);
|
||||
return ApiResponse.success(response);
|
||||
} catch (Exception e) {
|
||||
log.error("获取景区所有设备列表失败, scenicId: {}", scenicId, e);
|
||||
|
||||
@@ -60,9 +60,9 @@ public class ScenicV2Controller {
|
||||
if (pageSize > 100) {
|
||||
pageSize = 100;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
PageResponse<ScenicV2DTO> response = scenicIntegrationService.listScenics(page, pageSize, status, name);
|
||||
PageResponse<ScenicV2DTO> response = scenicIntegrationService.listScenics(page, pageSize, status, name, null);
|
||||
return ApiResponse.success(response);
|
||||
} catch (Exception e) {
|
||||
log.error("分页查询景区核心信息列表失败", e);
|
||||
@@ -156,7 +156,7 @@ public class ScenicV2Controller {
|
||||
log.info("查询景区列表, status: {}", status);
|
||||
try {
|
||||
// 默认查询1000条数据,第1页
|
||||
PageResponse<ScenicV2DTO> scenics = scenicIntegrationService.listScenics(1, 1000, status, null);
|
||||
PageResponse<ScenicV2DTO> scenics = scenicIntegrationService.listScenics(1, 1000, status, null, null);
|
||||
return ApiResponse.success(scenics);
|
||||
} catch (Exception e) {
|
||||
log.error("查询景区列表失败, status: {}", status, e);
|
||||
|
||||
@@ -60,7 +60,8 @@ public interface DeviceV2Client {
|
||||
@RequestParam(value = "no", required = false) String no,
|
||||
@RequestParam(value = "type", required = false) String type,
|
||||
@RequestParam(value = "isActive", required = false) Integer isActive,
|
||||
@RequestParam(value = "scenicId", required = false) Long scenicId);
|
||||
@RequestParam(value = "scenicId", required = false) Long scenicId,
|
||||
@RequestParam(value = "scenicIds", required = false) String scenicIds);
|
||||
|
||||
/**
|
||||
* 根据配置条件筛选设备
|
||||
|
||||
@@ -67,11 +67,28 @@ public class DeviceIntegrationService {
|
||||
}
|
||||
|
||||
public PageResponse<DeviceV2DTO> listDevices(Integer page, Integer pageSize, String name, String no,
|
||||
String type, Integer isActive, Long scenicId) {
|
||||
log.debug("分页查询设备列表, page: {}, pageSize: {}, name: {}, no: {}, type: {}, isActive: {}, scenicId: {}",
|
||||
page, pageSize, name, no, type, isActive, scenicId);
|
||||
String type, Integer isActive, Long scenicId, String scenicIds) {
|
||||
log.debug("分页查询设备列表, page: {}, pageSize: {}, name: {}, no: {}, type: {}, isActive: {}, scenicId: {}, scenicIds: {}",
|
||||
page, pageSize, name, no, type, isActive, scenicId, scenicIds);
|
||||
|
||||
// 参数优先级处理:scenicId 优先于 scenicIds
|
||||
Long finalScenicId = null;
|
||||
String finalScenicIds = null;
|
||||
|
||||
if (scenicId != null) {
|
||||
// 优先使用单个 scenicId(向后兼容)
|
||||
finalScenicId = scenicId;
|
||||
finalScenicIds = null;
|
||||
log.debug("使用单个 scenicId 参数: {}", finalScenicId);
|
||||
} else if (scenicIds != null && !scenicIds.trim().isEmpty()) {
|
||||
// 使用 scenicIds
|
||||
finalScenicId = null;
|
||||
finalScenicIds = scenicIds;
|
||||
log.debug("使用 scenicIds 参数: {}", finalScenicIds);
|
||||
}
|
||||
|
||||
CommonResponse<PageResponse<DeviceV2DTO>> response = deviceV2Client.listDevices(
|
||||
page, pageSize, name, no, type, isActive, scenicId);
|
||||
page, pageSize, name, no, type, isActive, finalScenicId, finalScenicIds);
|
||||
return handleResponse(response, "分页查询设备列表失败");
|
||||
}
|
||||
|
||||
@@ -163,14 +180,14 @@ public class DeviceIntegrationService {
|
||||
* 获取景区的IPC设备列表
|
||||
*/
|
||||
public PageResponse<DeviceV2DTO> getScenicIpcDevices(Long scenicId, Integer page, Integer pageSize) {
|
||||
return listDevices(page, pageSize, null, null, "IPC", 1, scenicId);
|
||||
return listDevices(page, pageSize, null, null, "IPC", 1, scenicId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取景区的所有激活设备
|
||||
*/
|
||||
public PageResponse<DeviceV2DTO> getScenicActiveDevices(Long scenicId, Integer page, Integer pageSize) {
|
||||
return listDevices(page, pageSize, null, null, null, 1, scenicId);
|
||||
return listDevices(page, pageSize, null, null, null, 1, scenicId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,8 @@ public interface ScenicV2Client {
|
||||
CommonResponse<PageResponse<ScenicV2DTO>> listScenics(@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String name);
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String scenicIds);
|
||||
|
||||
// ==================== Scenic Config V2 Operations ====================
|
||||
|
||||
|
||||
@@ -63,9 +63,10 @@ public class ScenicIntegrationService {
|
||||
return handleResponse(response, "筛选景区失败");
|
||||
}
|
||||
|
||||
public PageResponse<ScenicV2DTO> listScenics(Integer page, Integer pageSize, Integer status, String name) {
|
||||
log.debug("分页查询景区列表, page: {}, pageSize: {}, status: {}, name: {}", page, pageSize, status, name);
|
||||
CommonResponse<PageResponse<ScenicV2DTO>> response = scenicV2Client.listScenics(page, pageSize, status, name);
|
||||
public PageResponse<ScenicV2DTO> listScenics(Integer page, Integer pageSize, Integer status, String name, String scenicIds) {
|
||||
log.debug("分页查询景区列表, page: {}, pageSize: {}, status: {}, name: {}, scenicIds: {}",
|
||||
page, pageSize, status, name, scenicIds);
|
||||
CommonResponse<PageResponse<ScenicV2DTO>> response = scenicV2Client.listScenics(page, pageSize, status, name, scenicIds);
|
||||
return handleResponse(response, "分页查询景区列表失败");
|
||||
}
|
||||
|
||||
|
||||
@@ -208,10 +208,10 @@ public class ScenicRepository {
|
||||
status = Integer.valueOf(scenicReqQuery.getStatus());
|
||||
}
|
||||
String name = scenicReqQuery.getName();
|
||||
|
||||
|
||||
// 调用 zt-scenic 服务的 list 方法
|
||||
PageResponse<ScenicV2DTO> response = scenicIntegrationService.listScenics(page, pageSize, status, name);
|
||||
|
||||
PageResponse<ScenicV2DTO> response = scenicIntegrationService.listScenics(page, pageSize, status, name, null);
|
||||
|
||||
// 将 ScenicV2DTO 列表转换为 ScenicEntity 列表
|
||||
if (response != null && response.getList() != null) {
|
||||
return response.getList();
|
||||
|
||||
@@ -309,7 +309,7 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
|
||||
@Override
|
||||
public ApiResponse<List<DeviceRespVO>> getDevices(Long scenicId) {
|
||||
PageResponse<DeviceV2DTO> deviceV2ListResponse = deviceIntegrationService.listDevices(1, 1000, null, null, null, 1, scenicId);
|
||||
PageResponse<DeviceV2DTO> deviceV2ListResponse = deviceIntegrationService.listDevices(1, 1000, null, null, null, 1, scenicId, null);
|
||||
List<DeviceRespVO> deviceRespVOList = deviceV2ListResponse.getList().stream().map(device -> {
|
||||
DeviceRespVO deviceRespVO = new DeviceRespVO();
|
||||
deviceRespVO.setId(device.getId());
|
||||
|
||||
@@ -83,7 +83,7 @@ public class DeviceVideoContinuityCheckTask {
|
||||
|
||||
while (true) {
|
||||
PageResponse<DeviceV2DTO> pageResponse = deviceIntegrationService.listDevices(
|
||||
currentPage, pageSize, null, null, null, 1, null
|
||||
currentPage, pageSize, null, null, null, 1, null, null
|
||||
);
|
||||
|
||||
if (pageResponse == null || pageResponse.getList() == null
|
||||
|
||||
@@ -37,7 +37,7 @@ public class VideoPieceCleaner {
|
||||
public void clean() {
|
||||
log.info("开始删除视频文件");
|
||||
// 通过zt-device服务获取所有激活设备
|
||||
PageResponse<DeviceV2DTO> deviceListResponse = deviceIntegrationService.listDevices(1, 10000, null, null, null, 1, null);
|
||||
PageResponse<DeviceV2DTO> deviceListResponse = deviceIntegrationService.listDevices(1, 10000, null, null, null, 1, null, null);
|
||||
if (deviceListResponse == null || deviceListResponse.getList() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user