diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index c2a2740..eae58b8 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -731,10 +731,28 @@ public class AsDeviceServiceImpl extends ServiceImpl i asDevice.setRemainingPower(electricQuantity.toString()); } } + // 根据sn获取redis中的最新定位 + getLatestLocation(asDevice); } return asDevices; } + private void getLatestLocation(AsDevice asDevice) { + String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + asDevice.getSn()); + if(StrUtil.isNotBlank(msg)){ + log.info("【根据sn号查询车辆实时信息】-========redis缓存中的数据:" + msg); + LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class); + log.info("【根据sn号查询车辆实时信息】============logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry)); + LogEntry.LocationValue value = logEntry.getValue(); + // 坐标转换 WGS84 转 GCJ02 + double[] doubles = CommonUtil.coordinateConvert(value.getLon(),value.getLat()); + BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP); + BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP); + asDevice.setLongitude(lon.toString()); + asDevice.setLatitude(lat.toString()); + } + } + /** * 查询车辆数量 */