java ListObject objects = dataResultstoJavaListObjectclass; ListSz_device query = szDeviceServicequeryCndwheredeviceType = energy; ListSz_device result = new ArrayList;请用stream流
<p>List<Object> objects = dataResults.toJavaList(Object.class);
List<Sz_device> query = szDeviceService.query(Cnd.where("deviceType", "=", "energy"));
List<Sz_device> result = objects.stream()
.filter(obj -> obj instanceof Map) // Filter objects that are of type Map
.map(obj -> (Map<String, Object>) obj) // Cast object to Map
.filter(map -> map.containsKey("metername")) // Filter maps that contain key "metername"
.filter(map -> query.stream().noneMatch(device -> device.getName().equals(map.get("metername")))) // Filter maps where the value of "metername" is not present in query list
.map(map -> {
Sz_device device = new Sz_device();
device.setName(map.get("metername").toString()); // Set name to "metername" value
return device;
})
.collect(Collectors.toList()); // Collect the filtered Sz_device objects into a list named resul</p>
原文地址: https://www.cveoy.top/t/topic/hX4f 著作权归作者所有。请勿转载和采集!