|
|
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.hfln.portal.common.dto.data.event.EventsDTO;
|
|
|
import com.hfln.portal.common.request.device.DeviceListQueryReq;
|
|
|
import com.hfln.portal.common.request.device.UpdateDeviceParams;
|
|
|
import com.hfln.portal.domain.customer.util.UpdateWrapperBuilder;
|
|
|
@@ -23,6 +22,8 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.BiConsumer;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -269,25 +270,57 @@ public class DevInfoServiceImpl extends ServiceImpl<DevInfoMapper, DevInfo> impl
|
|
|
return this.baseMapper.queryStatInfoV2(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()));
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// public void fillDevNames(List<EventsDTO> dtoList) {
|
|
|
+// if (CollectionUtils.isEmpty(dtoList)){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// Set<String> allClientIds = dtoList.stream()
|
|
|
+// .map(EventsDTO::getClientId)
|
|
|
+// .collect(Collectors.toSet());
|
|
|
+//
|
|
|
+// if (!allClientIds.isEmpty()) {
|
|
|
+// Map<String, String> devIdNameMap = this.queryByClientIds(allClientIds)
|
|
|
+// .stream()
|
|
|
+// .collect(Collectors.toMap(
|
|
|
+// DevInfo::getClientId,
|
|
|
+// dev -> Optional.ofNullable(dev.getDevName()).orElse("未命名设备")
|
|
|
+// ));
|
|
|
+//
|
|
|
+// dtoList.forEach(dto -> dto.setDevName(devIdNameMap.getOrDefault(dto.getClientId(),"未知设备")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
- public void fillDevNames(List<EventsDTO> dtoList) {
|
|
|
- if (CollectionUtils.isEmpty(dtoList)){
|
|
|
+ public <T> void fillDevNames(
|
|
|
+ List<T> list,
|
|
|
+ Function<T, String> clientIdGetter,
|
|
|
+ BiConsumer<T, String> devNameSetter) {
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Set<String> allClientIds = dtoList.stream()
|
|
|
- .map(EventsDTO::getClientId)
|
|
|
+ Set<String> allClientIds = list.stream()
|
|
|
+ .map(clientIdGetter)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
- if (!allClientIds.isEmpty()) {
|
|
|
- Map<String, String> devIdNameMap = this.queryByClientIds(allClientIds)
|
|
|
- .stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- DevInfo::getClientId,
|
|
|
- dev -> Optional.ofNullable(dev.getDevName()).orElse("未命名设备")
|
|
|
- ));
|
|
|
-
|
|
|
- dtoList.forEach(dto -> dto.setDevName(devIdNameMap.getOrDefault(dto.getClientId(),"未知设备")));
|
|
|
+ if (allClientIds.isEmpty()) {
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, String> devIdNameMap = this.queryByClientIds(allClientIds)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ DevInfo::getClientId,
|
|
|
+ dev -> Optional.ofNullable(dev.getDevName()).orElse("未命名设备")
|
|
|
+ ));
|
|
|
+
|
|
|
+ list.forEach(item -> {
|
|
|
+ String clientId = clientIdGetter.apply(item);
|
|
|
+ devNameSetter.accept(item, devIdNameMap.getOrDefault(clientId, "未知设备"));
|
|
|
+ });
|
|
|
}
|
|
|
}
|