定位bug
This commit is contained in:
parent
6ba777ab8e
commit
66336eeed4
|
@ -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.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.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.orderUserPhone != null and query.orderUserPhone != ''">and suo.user_name like concat('%', #{query.orderUserPhone}, '%')</if>
|
||||||
<if test="query.lastTimeEnd != null">and bd.last_location_time <= #{query.lastTimeEnd}</if>
|
<if test="query.lastTimeEnd != null">and bd.last_time <= #{query.lastTimeEnd}</if>
|
||||||
<if test="query.lastTimeStart != null">and bd.last_location_time >= #{query.lastTimeStart}</if>
|
<if test="query.lastTimeStart != null">and bd.last_time >= #{query.lastTimeStart}</if>
|
||||||
<if test="query.locationType != null and query.locationType != ''">and bd.location_type = #{query.locationType}</if>
|
<if test="query.locationType != null and query.locationType != ''">and bd.location_type = #{query.locationType}</if>
|
||||||
<if test="query.keyword != null and query.keyword != ''">
|
<if test="query.keyword != null and query.keyword != ''">
|
||||||
and (
|
and (
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.constants.ServiceCode;
|
import com.ruoyi.common.constants.ServiceCode;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.core.redis.RedisLock;
|
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.MathUtils;
|
||||||
import com.ruoyi.common.utils.ServiceUtil;
|
import com.ruoyi.common.utils.ServiceUtil;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
@ -287,17 +288,17 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 异步发送命令,强制设备上报数据
|
// 异步发送命令,强制设备上报数据
|
||||||
scheduledExecutorService.execute(() -> {
|
// scheduledExecutorService.execute(() -> {
|
||||||
for (DeviceVO device : deviceList) {
|
// for (DeviceVO device : deviceList) {
|
||||||
try {
|
// try {
|
||||||
if (onlineType != null) {
|
// if (onlineType != null) {
|
||||||
iotService.getOnlineStatus(device, onlineType);
|
// iotService.getOnlineStatus(device, onlineType);
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
log.error("强制设备{}上报数据失败", device.getSn(), e);
|
// log.error("强制设备{}上报数据失败", device.getSn(), e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnlineStatus(DeviceVO device, String onlineStatus) {
|
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);
|
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) {
|
if (DeviceUtil.validLocation(device.getLongitude(), device.getLatitude())) {
|
||||||
device.setLastLocationTime(LocalDateTime.now());
|
|
||||||
LocationLog locationLog = locationLogConverter.toPo(device);
|
LocationLog locationLog = locationLogConverter.toPo(device);
|
||||||
if (locationLog != null) {
|
if (locationLog != null) {
|
||||||
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
|
redisCache.rightPush(CacheConstants.LOCATION_LOG_QUEUE, locationLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rows;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,7 @@ public class LocationLogQuery extends LocationLogVO {
|
||||||
|
|
||||||
@ApiModelProperty("订单ID列表")
|
@ApiModelProperty("订单ID列表")
|
||||||
private List<Long> orderIds;
|
private List<Long> orderIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("定位是否有效")
|
||||||
|
private Boolean valid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</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)
|
${@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")
|
.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)
|
.areaAlias("bo.area_id", query.areaPermissions)
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class LocationLogServiceImpl implements LocationLogService
|
||||||
}
|
}
|
||||||
LocationLogQuery query = new LocationLogQuery();
|
LocationLogQuery query = new LocationLogQuery();
|
||||||
query.setOrderId(orderId);
|
query.setOrderId(orderId);
|
||||||
|
query.setValid(true);
|
||||||
return locationLogMapper.selectPositionList(query);
|
return locationLogMapper.selectPositionList(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
|
||||||
* @param device
|
* @param device
|
||||||
*/
|
*/
|
||||||
private void updateDeviceIot(DeviceVO 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) {
|
if (lock) {
|
||||||
int update = deviceIotService.updateIot(device);
|
int update = deviceIotService.updateIot(device);
|
||||||
if (update != 1) {
|
if (update != 1) {
|
||||||
|
|
|
@ -291,7 +291,7 @@ public class IotServiceImpl implements IotService {
|
||||||
redisCache.setCacheObject(this.getOnlineCacheKey(deviceName), status, 10, TimeUnit.SECONDS);
|
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 ) {
|
if (lock ) {
|
||||||
scheduledExecutorService.execute(() -> {
|
scheduledExecutorService.execute(() -> {
|
||||||
int update = deviceService.updateOnlineStatusByMac(deviceName, status);
|
int update = deviceService.updateOnlineStatusByMac(deviceName, status);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user