From c115f0ef626d9e10c88796d0ba34f208f72e238c Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Sat, 31 Aug 2024 16:19:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=9B=B8=E5=B7=AE=E4=B8=80=E5=88=86?= =?UTF-8?q?=E9=92=9F=E4=BB=A5=E4=B8=8A=E7=9A=84=E6=B6=88=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E5=81=9A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/iot/receive/ReceiveController.java | 4 +++- .../main/java/com/ruoyi/common/utils/DateUtils.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 f14e26e..0b5a2cf 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 @@ -169,7 +169,9 @@ public class ReceiveController { log.info("转换后的GCJ02经纬度:" + lon + "---" + lat); EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); - if(ObjectUtil.isNotNull(area)){ + // 相差一分钟以上的消息不做处理 + boolean oneMinuteDifference = DateUtils.oneMinuteDifference(logEntry.getAt(), System.currentTimeMillis()); + if(ObjectUtil.isNotNull(area) && !oneMinuteDifference){ /** 2. 判断是否在禁行区内 如果在, 根据配置‘禁行区内断电配置’进行断电 **/ String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是 boolean noRidingArea = isNoRidingArea(value, asDevice, area, isAdminUnlocking); diff --git a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index ad2c212..8ad0186 100644 --- a/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/electripper-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -321,4 +321,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ZonedDateTime zonedDateTime = offsetDateTime.toZonedDateTime(); return Date.from(zonedDateTime.toInstant()); } + + /** + * 是否相差一分钟 + * * @param at 第一个时间戳,毫秒级 + * * @param currentTimeMillis 第二个时间戳,毫秒级 + * * @return 如果两个时间戳相差超过一分钟,则返回 true,否则返回 false + */ + public static boolean oneMinuteDifference(long at, long currentTimeMillis) { + // 计算两个时间戳的差值,取绝对值 + long difference = Math.abs(currentTimeMillis - at); + // 判断是否大于 60,000 毫秒(1 分钟) + return difference > 60_000; + } }