in backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java [282:321]
public BaseVO<DeviceInfoVO> getDevicesInfoByGroupName(
@PathVariable("serverId") Integer serverId,
@PathVariable("groupName") String groupName,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("pageNum") Integer pageNum,
@RequestParam(value = "keyword", required = false) String keyword,
HttpServletRequest request)
throws BaseException {
checkParameter(groupName);
check(request, serverId);
Connection connection = connectionService.getById(serverId);
CountDTO countDTO =
iotDBService.getDevicesByGroup(connection, groupName, pageSize, pageNum, keyword);
List<String> deviceNames = countDTO.getObjects();
DeviceInfoVO deviceInfoVO = new DeviceInfoVO();
Integer totalPage = countDTO.getTotalPage();
Integer totalCount = countDTO.getTotalCount();
deviceInfoVO.setTotalCount(totalCount);
deviceInfoVO.setTotalPage(totalPage);
List<Integer> lines = iotDBService.getTimeseriesCount(connection, deviceNames);
List<Device> devices = deviceService.getDevices(connection.getHost(), deviceNames);
List<DeviceInfo> deviceInfos = new ArrayList<>();
if (deviceNames != null) {
for (int i = 0; i < deviceNames.size(); i++) {
String deviceName = deviceNames.get(i);
DeviceInfo deviceInfo = new DeviceInfo();
deviceInfo.setDeviceName(deviceName);
deviceInfo.setLine(lines.get(i));
deviceInfo.setParents(iotDBService.getDeviceParents(connection, groupName, deviceName));
if (devices.get(i) != null) {
deviceInfo.setDeviceId(devices.get(i).getId());
deviceInfo.setCreator(devices.get(i).getCreator());
deviceInfo.setDescription(devices.get(i).getDescription());
}
deviceInfos.add(deviceInfo);
}
}
deviceInfoVO.setDeviceInfos(deviceInfos);
return BaseVO.success("Get successfully", deviceInfoVO);
}