|
@ -43,6 +43,7 @@ public class DeviceServiceImpl implements DeviceService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<DeviceInfo> onlineAndRound(double maxLng, double maxLat, double minLng, double minLat) { |
|
|
public List<DeviceInfo> onlineAndRound(double maxLng, double maxLat, double minLng, double minLat) { |
|
|
|
|
|
log.info("maxlat={},minlat={},maxlng={},minlng={}", maxLat, minLat, maxLng, minLng); |
|
|
Set<String> keys = stringRedisTemplate.keys(TRACK_PREFIX_REDIS_KEY); |
|
|
Set<String> keys = stringRedisTemplate.keys(TRACK_PREFIX_REDIS_KEY); |
|
|
List<DeviceInfo> deviceInfos = new ArrayList<>(); |
|
|
List<DeviceInfo> deviceInfos = new ArrayList<>(); |
|
|
if (CollectionUtils.isNotEmpty(keys)) { |
|
|
if (CollectionUtils.isNotEmpty(keys)) { |
|
@ -50,14 +51,20 @@ public class DeviceServiceImpl implements DeviceService { |
|
|
if (CollectionUtils.isEmpty(values)) { |
|
|
if (CollectionUtils.isEmpty(values)) { |
|
|
return deviceInfos; |
|
|
return deviceInfos; |
|
|
} |
|
|
} |
|
|
|
|
|
log.info("所有的在线农机={}", keys); |
|
|
List<TrackDataJG> trackDataJGS = values.stream().map(s -> JSON.parseObject(s, TrackDataJG.class)).toList(); |
|
|
List<TrackDataJG> trackDataJGS = values.stream().map(s -> JSON.parseObject(s, TrackDataJG.class)).toList(); |
|
|
Predicate<TrackDataJG> predicate = t -> t.getLat() <= maxLat && t.getLat() >= minLat |
|
|
|
|
|
&& ((t.getLng() >= -180 && t.getLng() <= maxLng) || (t.getLng() >= minLng && t.getLng() <= 180)); |
|
|
|
|
|
|
|
|
Predicate<TrackDataJG> predicate = t -> { |
|
|
|
|
|
log.info("农机{},经纬度:{}", t.getDroneId(), t.getLng() + "," + t.getLat()); |
|
|
|
|
|
|
|
|
|
|
|
return t.getLat() <= maxLat && t.getLat() >= minLat |
|
|
|
|
|
&& t.getLng() <= maxLng && t.getLng() >= minLng; |
|
|
|
|
|
}; |
|
|
if (maxLat == 0 && minLat == 0 && maxLng == 0 && minLng == 0) { |
|
|
if (maxLat == 0 && minLat == 0 && maxLng == 0 && minLng == 0) { |
|
|
predicate = t -> true; |
|
|
predicate = t -> true; |
|
|
} |
|
|
} |
|
|
Consumer<TrackDataJG> consumer = t -> deviceInfos.add(new DeviceInfo().setBoxNum(t.getDroneId()).setLng(t.getLng()).setLat(t.getLat())); |
|
|
Consumer<TrackDataJG> consumer = t -> deviceInfos.add(new DeviceInfo().setBoxNum(t.getDroneId()).setLng(t.getLng()).setLat(t.getLat())); |
|
|
trackDataJGS.stream().filter(predicate).forEach(consumer); |
|
|
trackDataJGS.stream().filter(predicate).forEach(consumer); |
|
|
|
|
|
log.info("根据范围过滤后的农机列表:{}", deviceInfos); |
|
|
LoginUser loginUser = LoginUtil.getLoginUser(); |
|
|
LoginUser loginUser = LoginUtil.getLoginUser(); |
|
|
if (loginUser != null && loginUser.getDept() != null) { |
|
|
if (loginUser != null && loginUser.getDept() != null) { |
|
|
long deptId = loginUser.getDept().getId(); |
|
|
long deptId = loginUser.getDept().getId(); |
|
@ -72,7 +79,9 @@ public class DeviceServiceImpl implements DeviceService { |
|
|
iterator.remove(); |
|
|
iterator.remove(); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
deviceInfo.setDeviceId(exists.get().getDeviceId()).setStatus(exists.get().getStatus()); |
|
|
|
|
|
|
|
|
deviceInfo.setDeviceId(exists.get().getDeviceId()).setStatus(exists.get().getStatus()) |
|
|
|
|
|
.setName(exists.get().getName()) |
|
|
|
|
|
.setLicensePlate(exists.get().getLicensePlate()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|