1. 优化经纬度相同的定位,不插入
This commit is contained in:
parent
bea016d61c
commit
ec1af23e89
|
@ -76,4 +76,10 @@ public interface EtLocationLogMapper
|
||||||
*/
|
*/
|
||||||
int deleteLocationLogByCreateTime();
|
int deleteLocationLogByCreateTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最后一条消息
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
String getLastMsg(String mac);
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,9 +549,11 @@ public class EtTask {
|
||||||
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
|
log.info("logEntry转换后的对象: logEntry---【{}】" , JSON.toJSONString(logEntry));
|
||||||
LogEntry.LocationValue value = logEntry.getValue();
|
LogEntry.LocationValue value = logEntry.getValue();
|
||||||
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
|
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
|
||||||
log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device));
|
if(!isRepeatMsg(msg,logEntry.getDevName())){
|
||||||
if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){
|
log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device));
|
||||||
updateLocationHandle(msg, logEntry, value, 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+ " 毫秒");
|
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分钟一次
|
* 更新设备的定位和电压 5分钟一次
|
||||||
* cron: 0 20 0 * * ?
|
* cron: 0 20 0 * * ?
|
||||||
|
|
|
@ -51,6 +51,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where location_id = #{locationId}
|
where location_id = #{locationId}
|
||||||
</select>
|
</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 id="insertEtLocationLog" parameterType="EtLocationLog" useGeneratedKeys="true" keyProperty="locationId">
|
||||||
insert into et_location_log
|
insert into et_location_log
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user