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