|
|
|
|
@ -1330,22 +1330,14 @@ public class DeviceServiceImpl implements DeviceService {
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询所有设备的最新运行记录
|
|
|
|
|
List<DeviceOperationRecordDO> records = deviceOperationRecordMapper.selectList(
|
|
|
|
|
Wrappers.<DeviceOperationRecordDO>lambdaQuery()
|
|
|
|
|
.in(DeviceOperationRecordDO::getDeviceId, deviceIds)
|
|
|
|
|
.orderByDesc(DeviceOperationRecordDO::getCreateTime));
|
|
|
|
|
List<DeviceOperationRecordDO> records = deviceOperationRecordMapper.selectLatestRecords(deviceIds);
|
|
|
|
|
|
|
|
|
|
// 构建设备ID到最新记录的映射
|
|
|
|
|
Map<Long, DeviceOperationRecordDO> latestRecordMap = new HashMap<>();
|
|
|
|
|
for (DeviceOperationRecordDO record : records) {
|
|
|
|
|
// 只保留每个设备的第一条记录(因为已经按创建时间倒序排序)
|
|
|
|
|
if (!latestRecordMap.containsKey(record.getDeviceId())) {
|
|
|
|
|
latestRecordMap.put(record.getDeviceId(), record);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return latestRecordMap;
|
|
|
|
|
// 直接用 Stream 转 Map
|
|
|
|
|
return records.stream()
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
DeviceOperationRecordDO::getDeviceId,
|
|
|
|
|
Function.identity()
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|