From 4024a94338a5622694c14ac2a8b210492836d282 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Thu, 26 Dec 2024 20:28:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/AppVerifyController.java | 4 ++ .../service/impl/AsDeviceServiceImpl.java | 65 +++++++++---------- .../mapper/system/EtCommandLogMapper.xml | 1 + .../mapper/system/EtLocationLogMapper.xml | 2 +- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index 58f8251..e1a8433 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -135,6 +135,9 @@ public class AppVerifyController extends BaseController @Autowired private RedisLock redisLock; + @Autowired + private IEtLocationLogService etLocationLogService; + /** * 故障上报 @@ -1726,6 +1729,7 @@ public class AppVerifyController extends BaseController } logger.info("【根据时间查询车辆轨迹】:{}",sn,startTime,endTime); List trajectoryDetails = asDeviceService.trajectoryDetails(sn,startTime,endTime); + etLocationLogService.analytic(trajectoryDetails); ajax.put(AjaxResult.DATA_TAG,trajectoryDetails); return ajax; } 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 28a42f1..d02edda 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 @@ -2775,8 +2775,8 @@ public class AsDeviceServiceImpl extends ServiceImpl i @Override public List trajectoryDetails(String sn, String startTime,String endTime) { AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); - List etLocationLogs = etLocationLogMapper.selectEtLocationLogListByCreateTime(device.getMac(), startTime, endTime); - return etLocationLogs; + if(device == null) throw new RuntimeException("设备不存在"); + return etLocationLogMapper.selectEtLocationLogListByCreateTime(device.getMac(), startTime, endTime); } @@ -2884,40 +2884,37 @@ public class AsDeviceServiceImpl extends ServiceImpl i public boolean updateLatestLocation(String sn) { AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); if(device!=null){ - String version = device.getVersion(); - if(StrUtil.isBlank(version)){ - String token = Token.getToken(); - DataPointRes datapoints = historyDatapoints(asDeviceMapper.selectAsDeviceBySn(sn).getMac(), token); - if(datapoints.getCode() == 0){ - Data data = datapoints.getData(); - List datastreams = data.getDevices(); - for (Datastream datastream: datastreams) { - List datapointList = datastream.getDatastreams(); - if(ObjectUtil.isNotNull(datapointList)){ - for (Datapoint datapoint:datapointList) { - if(datapoint.getId().equals(IotConstants.ONENET_LOCATION)){ - String string = JSON.toJSONString(datapoint.getValue()); - String at = datapoint.getAt(); - if(StrUtil.isNotBlank(string)){ - LocationVo locationVo = JSONObject.parseObject(string, LocationVo.class); - log.info("【手动更新】: locationVo---【{}】" , JSON.toJSONString(locationVo)); - double[] doubles = CommonUtil.coordinateConvert(locationVo.getLon(), locationVo.getLat()); - BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP); - BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP); - log.info("转换后的GCJ02经纬度:" + lon + "---" + lat); - if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ - /** 计算电量和里程后更新设备*/ - int i = updateDevice(at,locationVo, device, lon, lat); - if(i > 0){ - log.info("【手动更新】===>更新设备成功"); - return true; - }else{ - log.info("【手动更新】===>更新设备失败"); - return false; - } + String token = Token.getToken(); + DataPointRes datapoints = historyDatapoints(asDeviceMapper.selectAsDeviceBySn(sn).getMac(), token); + if(datapoints.getCode() == 0){ + Data data = datapoints.getData(); + List datastreams = data.getDevices(); + for (Datastream datastream: datastreams) { + List datapointList = datastream.getDatastreams(); + if(ObjectUtil.isNotNull(datapointList)){ + for (Datapoint datapoint:datapointList) { + if(datapoint.getId().equals(IotConstants.ONENET_LOCATION)){ + String string = JSON.toJSONString(datapoint.getValue()); + String at = datapoint.getAt(); + if(StrUtil.isNotBlank(string)){ + LocationVo locationVo = JSONObject.parseObject(string, LocationVo.class); + log.info("【手动更新】: locationVo---【{}】" , JSON.toJSONString(locationVo)); + double[] doubles = CommonUtil.coordinateConvert(locationVo.getLon(), locationVo.getLat()); + BigDecimal lat = new BigDecimal(doubles[0]).setScale(8, RoundingMode.HALF_UP); + BigDecimal lon = new BigDecimal(doubles[1]).setScale(8, RoundingMode.HALF_UP); + log.info("转换后的GCJ02经纬度:" + lon + "---" + lat); + if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ + /** 计算电量和里程后更新设备*/ + int i = updateDevice(at,locationVo, device, lon, lat); + if(i > 0){ + log.info("【手动更新】===>更新设备成功"); + return true; }else{ - noLocationUpdateDevice(at,locationVo,device); + log.info("【手动更新】===>更新设备失败"); + return false; } + }else{ + noLocationUpdateDevice(at,locationVo,device); } } } diff --git a/electripper-system/src/main/resources/mapper/system/EtCommandLogMapper.xml b/electripper-system/src/main/resources/mapper/system/EtCommandLogMapper.xml index cfd8b9f..c2b7a31 100644 --- a/electripper-system/src/main/resources/mapper/system/EtCommandLogMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtCommandLogMapper.xml @@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and type like concat('%', #{type}, '%') and result like concat('%', #{result}, '%') and order_no like concat('%', #{orderNo}, '%') + and create_by like concat('%', #{createBy}, '%') and call_status = #{callStatus} order by create_time desc diff --git a/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml index a3a7eef..38a834c 100644 --- a/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml @@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"