1. 相差一分钟以上的消息不做处理

This commit is contained in:
邱贞招 2024-08-31 16:19:13 +08:00
parent 67ef07c021
commit c115f0ef62
2 changed files with 16 additions and 1 deletions

View File

@ -169,7 +169,9 @@ public class ReceiveController {
log.info("转换后的GCJ02经纬度" + lon + "---" + lat); log.info("转换后的GCJ02经纬度" + lon + "---" + lat);
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId());
if(ObjectUtil.isNotNull(area)){ // 相差一分钟以上的消息不做处理
boolean oneMinuteDifference = DateUtils.oneMinuteDifference(logEntry.getAt(), System.currentTimeMillis());
if(ObjectUtil.isNotNull(area) && !oneMinuteDifference){
/** 2. 判断是否在禁行区内 如果在, 根据配置‘禁行区内断电配置’进行断电 **/ /** 2. 判断是否在禁行区内 如果在, 根据配置‘禁行区内断电配置’进行断电 **/
String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁0-1- String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁0-1-
boolean noRidingArea = isNoRidingArea(value, asDevice, area, isAdminUnlocking); boolean noRidingArea = isNoRidingArea(value, asDevice, area, isAdminUnlocking);

View File

@ -321,4 +321,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime zonedDateTime = offsetDateTime.toZonedDateTime(); ZonedDateTime zonedDateTime = offsetDateTime.toZonedDateTime();
return Date.from(zonedDateTime.toInstant()); 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;
}
} }