From ec1af23e89311327e7dd2c6f80de67279c79ef54 Mon Sep 17 00:00:00 2001
From: 18650502300 <18650502300@163.com>
Date: Tue, 3 Sep 2024 17:25:46 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E4=BC=98=E5=8C=96=E7=BB=8F=E7=BA=AC?=
=?UTF-8?q?=E5=BA=A6=E7=9B=B8=E5=90=8C=E7=9A=84=E5=AE=9A=E4=BD=8D=EF=BC=8C?=
=?UTF-8?q?=E4=B8=8D=E6=8F=92=E5=85=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/mapper/EtLocationLogMapper.java | 6 ++++++
.../java/com/ruoyi/system/task/EtTask.java | 18 +++++++++++++++---
.../mapper/system/EtLocationLogMapper.xml | 8 ++++++++
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java
index 079ee04..6837fb3 100644
--- a/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java
+++ b/electripper-system/src/main/java/com/ruoyi/system/mapper/EtLocationLogMapper.java
@@ -76,4 +76,10 @@ public interface EtLocationLogMapper
*/
int deleteLocationLogByCreateTime();
+ /**
+ * 获取最后一条消息
+ *
+ * @return 结果
+ */
+ String getLastMsg(String mac);
}
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 1e9718e..3e444b1 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
@@ -549,9 +549,11 @@ public class EtTask {
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
LogEntry.LocationValue value = logEntry.getValue();
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
- log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device));
- if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){
- updateLocationHandle(msg, logEntry, value, device);
+ if(!isRepeatMsg(msg,logEntry.getDevName())){
+ log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device));
+ if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){
+ updateLocationHandle(msg, logEntry, value, device);
+ }
}
}
// 计算执行时间(以毫秒为单位)
@@ -559,6 +561,16 @@ public class EtTask {
log.info("-------------------【定时任务10秒一次】更新设备的定位和电压----结束---------------"+duration+ " 毫秒");
}
+ private boolean isRepeatMsg(String msg,String mac){
+ // 获取最后一条消息
+ String lastMsg = etLocationLogMapper.getLastMsg(mac);
+ if(ObjectUtil.isNotNull(lastMsg) && msg.equals(lastMsg)){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
/**
* 更新设备的定位和电压 5分钟一次
* cron: 0 20 0 * * ?
diff --git a/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml
index 7193ae7..6450e06 100644
--- a/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml
+++ b/electripper-system/src/main/resources/mapper/system/EtLocationLogMapper.xml
@@ -51,6 +51,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where location_id = #{locationId}
+
+
insert into et_location_log