|
@@ -84,6 +84,8 @@ public class WebGatewayImpl implements WebGateway {
|
|
private TblDicItemService tblDicItemService;
|
|
private TblDicItemService tblDicItemService;
|
|
@Autowired
|
|
@Autowired
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TblTenantService tblTenantService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public UploadRes uploadDev(MultipartFile file) throws IOException {
|
|
public UploadRes uploadDev(MultipartFile file) throws IOException {
|
|
@@ -140,8 +142,27 @@ public class WebGatewayImpl implements WebGateway {
|
|
Long tenantId = (Long) StpUtil.getSession().get(UserConstants.SA_USER_TENANT_ID);
|
|
Long tenantId = (Long) StpUtil.getSession().get(UserConstants.SA_USER_TENANT_ID);
|
|
Page<DevInfo> devInfoPage = devInfoService.queryDevList(queryReq, tenantId);
|
|
Page<DevInfo> devInfoPage = devInfoService.queryDevList(queryReq, tenantId);
|
|
// 换为目标DTO
|
|
// 换为目标DTO
|
|
- List<DeviceDTO> targets = CopyUtils.copyList(devInfoPage.getRecords(), DeviceDTO.class);
|
|
|
|
- return CopyUtils.copyPage(devInfoPage, targets);
|
|
|
|
|
|
+ List<DeviceDTO> deviceDTOList = CopyUtils.copyList(devInfoPage.getRecords(), DeviceDTO.class);
|
|
|
|
+
|
|
|
|
+ //收集所有tenantId
|
|
|
|
+ Set<Long> tenantIds = deviceDTOList.stream()
|
|
|
|
+ .map(DeviceDTO::getTenantId)
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ // 批量查询租户信息
|
|
|
|
+ List<TblTenant> tenantList = tblTenantService.listByIds(tenantIds);
|
|
|
|
+ Map<Long, String> tenantIdNameMap = tenantList.stream()
|
|
|
|
+ .collect(Collectors.toMap(TblTenant::getTenantId, TblTenant::getTenantName));
|
|
|
|
+
|
|
|
|
+ //设置tenantName到DTO
|
|
|
|
+ deviceDTOList.forEach(dto -> {
|
|
|
|
+ if (dto.getTenantId() != null) {
|
|
|
|
+ dto.setTenantName(tenantIdNameMap.get(dto.getTenantId()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return CopyUtils.copyPage(devInfoPage, deviceDTOList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|