From 0aba990c0299cdc9245eb43165ccb8cecd35764a Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Fri, 13 Sep 2024 09:27:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E5=AE=9A=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AsDeviceServiceImpl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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()); + } + } + /** * 查询车辆数量 */