定位bug

This commit is contained in:
磷叶 2025-05-16 13:49:44 +08:00
parent 6ba777ab8e
commit 66336eeed4
7 changed files with 38 additions and 19 deletions

View File

@ -128,8 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.modelName != null and query.modelName != ''">and bm.name like concat('%', #{query.modelName}, '%')</if>
<if test="query.orderUserName != null and query.orderUserName != ''">and suo.nick_name like concat('%', #{query.orderUserName}, '%')</if>
<if test="query.orderUserPhone != null and query.orderUserPhone != ''">and suo.user_name like concat('%', #{query.orderUserPhone}, '%')</if>
<if test="query.lastTimeEnd != null">and bd.last_location_time &lt;= #{query.lastTimeEnd}</if>
<if test="query.lastTimeStart != null">and bd.last_location_time &gt;= #{query.lastTimeStart}</if>
<if test="query.lastTimeEnd != null">and bd.last_time &lt;= #{query.lastTimeEnd}</if>
<if test="query.lastTimeStart != null">and bd.last_time &gt;= #{query.lastTimeStart}</if>
<if test="query.locationType != null and query.locationType != ''">and bd.location_type = #{query.locationType}</if>
<if test="query.keyword != null and query.keyword != ''">
and (

View File

@ -32,6 +32,7 @@ import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constants.ServiceCode;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
@ -287,17 +288,17 @@ public class DeviceIotServiceImpl implements DeviceIotService {
}
// 异步发送命令强制设备上报数据
scheduledExecutorService.execute(() -> {
for (DeviceVO device : deviceList) {
try {
if (onlineType != null) {
iotService.getOnlineStatus(device, onlineType);
}
} catch (Exception e) {
log.error("强制设备{}上报数据失败", device.getSn(), e);
}
}
});
// scheduledExecutorService.execute(() -> {
// for (DeviceVO device : deviceList) {
// try {
// if (onlineType != null) {
// iotService.getOnlineStatus(device, onlineType);
// }
// } catch (Exception e) {
// log.error("强制设备{}上报数据失败", device.getSn(), e);
// }
// }
// });
}
private void setOnlineStatus(DeviceVO device, String onlineStatus) {
@ -455,17 +456,25 @@ public class DeviceIotServiceImpl implements DeviceIotService {
// 更新设备信息
DeviceUtil.setIotSysInfo(device, dto.getSys(), LocalDateTime.now(), true, DeviceLocationType.PHONE);
int rows = this.updateIot(device);
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, device.getMac(), 60L);
if (lock) {
int update = this.updateIot(device);
if (update != 1) {
log.error("更新设备信息失败: {}", device.getMac());
}
} else {
log.info("设备{}更新太频繁,跳过本次更新", device.getMac());
}
// 创建定位日志
if (rows > 0) {
device.setLastLocationTime(LocalDateTime.now());
if (DeviceUtil.validLocation(device.getLongitude(), device.getLatitude())) {
LocationLog locationLog = locationLogConverter.toPo(device);
if (locationLog != null) {
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
}
}
return rows;
return 1;
}
}

View File

@ -31,4 +31,7 @@ public class LocationLogQuery extends LocationLogVO {
@ApiModelProperty("订单ID列表")
private List<Long> orderIds;
@ApiModelProperty("定位是否有效")
private Boolean valid;
}

View File

@ -66,6 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="query.valid != null and query.valid">
and bll.longitude is not null
and bll.latitude is not null
and bll.longitude != 0
and bll.latitude != 0
</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.userSetAlias("su.user_id,su.agent_id,bo.area_user_id,bo.area_agent_id,bod.device_mch_id")
.areaAlias("bo.area_id", query.areaPermissions)

View File

@ -116,6 +116,7 @@ public class LocationLogServiceImpl implements LocationLogService
}
LocationLogQuery query = new LocationLogQuery();
query.setOrderId(orderId);
query.setValid(true);
return locationLogMapper.selectPositionList(query);
}
}

View File

@ -152,7 +152,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
* @param device
*/
private void updateDeviceIot(DeviceVO device) {
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, device.getMac(), 20L);
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, device.getMac(), 60L);
if (lock) {
int update = deviceIotService.updateIot(device);
if (update != 1) {

View File

@ -291,7 +291,7 @@ public class IotServiceImpl implements IotService {
redisCache.setCacheObject(this.getOnlineCacheKey(deviceName), status, 10, TimeUnit.SECONDS);
// 异步更新设备在线状态
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, deviceName, 20L);
boolean lock = redisLock.lock(RedisLockKey.DEVICE_UPDATE_IOT_LOCK, deviceName, 60L);
if (lock ) {
scheduledExecutorService.execute(() -> {
int update = deviceService.updateOnlineStatusByMac(deviceName, status);