From 2e69d5467468f2ebd898d96a4ccfcd93dfe318f7 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Fri, 10 Jan 2025 20:15:08 +0800 Subject: [PATCH] 111 --- .../service/impl/AsDeviceServiceImpl.java | 36 +++++++++++++++---- .../service/impl/SysDeptServiceImpl.java | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) 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 c796dfe..95ec4eb 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 @@ -165,6 +165,24 @@ public class AsDeviceServiceImpl extends ServiceImpl i device.setRemainingMileage(CommonUtil.getRemainingMileage(device.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance())); } } + String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + device.getMac()); + if(StrUtil.isNotBlank(msg)){ + LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class); + LogEntry.LocationValue value = logEntry.getValue(); + if(!"0.0".equals(value.getLon()) && !"0.0".equals(value.getLat())){ + // 坐标转换 WGS84 转 GCJ02 + double[] doubles = CommonUtil.coordinateConvert(value.getLon(),value.getLat()); + BigDecimal lon = BigDecimal.valueOf(doubles[1]).setScale(8, RoundingMode.HALF_UP); + // todo 0E-8 排除 + BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); + device.setLongitude(lon.toString()); + device.setLatitude(lat.toString()); + }else{ + device.setLongitude(null); + device.setLatitude(null); + } + device.setLastLocationTime(new Date(logEntry.getAt())); + } if(ObjectUtil.isNotNull(areaId) && areaId!=0){ SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId); //https://dianche.chuantewulian.cn?sn=https://dche.ccttiot.com?sn=3000900 @@ -232,12 +250,18 @@ public class AsDeviceServiceImpl extends ServiceImpl i 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 = BigDecimal.valueOf(doubles[1]).setScale(8, RoundingMode.HALF_UP); - BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); - asDevice.setLongitude(lon.toString()); - asDevice.setLatitude(lat.toString()); + if(!"0.0".equals(value.getLon()) && !"0.0".equals(value.getLat())){ + // 坐标转换 WGS84 转 GCJ02 + double[] doubles = CommonUtil.coordinateConvert(value.getLon(),value.getLat()); + BigDecimal lon = BigDecimal.valueOf(doubles[1]).setScale(8, RoundingMode.HALF_UP); + BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); + // todo 0E-8 排除 + asDevice.setLongitude(lon.toString()); + asDevice.setLatitude(lat.toString()); + }else{ + asDevice.setLongitude(null); + asDevice.setLatitude(null); + } asDevice.setLastLocationTime(new Date(logEntry.getAt())); } //正在进行中的订单 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 1badf4d..d609403 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -748,7 +748,7 @@ public class SysDeptServiceImpl implements ISysDeptService order.setPayFee(etCapitalFlow.getAmount().add(etCapitalFlow.getHandlingCharge())); order.setTotalFee(etCapitalFlow.getAmount()); List longs = etOperatingAreaService.selectAreaListByDeptId(etCapitalFlow.getOwnerId()); - if(longs.size() == 0){ + if(longs.isEmpty()){ throw new ServiceException("【管理员提现失败】提现失败,未找到该运营区,运营商id:"+etCapitalFlow.getOwnerId()); } order.setAreaId(longs.get(0));