1. 优化经纬度相同的定位,不插入
This commit is contained in:
parent
bea016d61c
commit
ec1af23e89
|
@ -76,4 +76,10 @@ public interface EtLocationLogMapper
|
|||
*/
|
||||
int deleteLocationLogByCreateTime();
|
||||
|
||||
/**
|
||||
* 获取最后一条消息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
String getLastMsg(String mac);
|
||||
}
|
||||
|
|
|
@ -549,16 +549,28 @@ public class EtTask {
|
|||
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
|
||||
LogEntry.LocationValue value = logEntry.getValue();
|
||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 计算执行时间(以毫秒为单位)
|
||||
long duration = (System.nanoTime() - startTime) / 1_000_000;
|
||||
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 * * ?
|
||||
|
|
|
@ -51,6 +51,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where location_id = #{locationId}
|
||||
</select>
|
||||
|
||||
<select id="getLastMsg" resultType="java.lang.String">
|
||||
SELECT onenet_msg
|
||||
FROM et_location_log
|
||||
WHERE mac = #{mac}
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertEtLocationLog" parameterType="EtLocationLog" useGeneratedKeys="true" keyProperty="locationId">
|
||||
insert into et_location_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
Loading…
Reference in New Issue
Block a user