From 36dabe0e3034e3b739898eb96d0000d015edc648 Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Tue, 18 Jun 2024 17:11:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=BC=82=E6=AD=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/receive/ReceiveController.java | 19 +++++++++++++++++++ .../java/com/ruoyi/system/task/EtTask.java | 1 + 2 files changed, 20 insertions(+) diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java index 356cfaa..0c0388e 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive/ReceiveController.java @@ -129,6 +129,9 @@ public class ReceiveController { String msg = (String) obj.getMsg(); log.info("receive方法-获取到消息体: msg---" +msg); JSONObject jsonObject = JSONObject.parseObject(msg, JSONObject.class); + String devName = (String)jsonObject.get("dev_name"); + /*异步更新在线状态*/ + asynchronousUpdateOnlineStatus(devName); if(IotConstants.ONENET_LOCATION.equals(jsonObject.get("ds_id")) && ObjectUtil.isNotNull(jsonObject.get("value"))){ LogEntry logEntry = JSONObject.parseObject(msg, LogEntry.class); log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry)); @@ -314,6 +317,22 @@ public class ReceiveController { } } + /** + * 异步更新在线状态 + */ + private void asynchronousUpdateOnlineStatus(String mac) { + AsDevice device = asDeviceService.selectAsDeviceByMac(mac); + //开异步线程保存回调参数 + scheduledExecutorService.schedule(() -> { + log.info("【接收onenet推送】异步更新在线状态"+JSON.toJSONString(device)); + device.setOnlineStatus(ServiceConstants.VEHICLE_STATUS_ONLINE); + int i = asDeviceService.updateAsDevice(device); + if(i>0){ + log.info("【接收onenet推送】异步保存在线状态成功"); + } + }, 0, TimeUnit.SECONDS); + } + private boolean isLastPointSame(JSONArray jsonArray, BigDecimal lon, BigDecimal lat) { if (jsonArray.size() > 0) { JSONArray lastPoint = (JSONArray) jsonArray.get(jsonArray.size() - 1); diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index 385d224..67c33d3 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -102,6 +102,7 @@ public class EtTask { * ②根据用户查询最后一次押金充值记录 */ List orders = etOrderMapper.selectUserListFinishOrder(); + log.info("已完成的订单未退还押金的的订单 = " + JSON.toJSONString(orders)); for(EtOrder order:orders){ EtFeeRule rule = etFeeRuleService.selectEtFeeRuleByRuleId(order.getRuleId()); if(ObjectUtil.isNull(rule)){