设备定位更新
This commit is contained in:
parent
9c830759b3
commit
00c453b552
|
@ -50,4 +50,7 @@ public class DeviceCacheInfo {
|
||||||
// 最后在线时间
|
// 最后在线时间
|
||||||
private LocalDateTime lastOnlineTime;
|
private LocalDateTime lastOnlineTime;
|
||||||
|
|
||||||
|
// 定位类型
|
||||||
|
private String locationType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,6 +361,9 @@ public class DeviceIotServiceImpl implements DeviceIotService {
|
||||||
if (device.getSoftwareVersion() != null) {
|
if (device.getSoftwareVersion() != null) {
|
||||||
info.setSoftwareVersion(device.getSoftwareVersion());
|
info.setSoftwareVersion(device.getSoftwareVersion());
|
||||||
}
|
}
|
||||||
|
if (device.getLocationType() != null) {
|
||||||
|
info.setLocationType(device.getLocationType());
|
||||||
|
}
|
||||||
|
|
||||||
String key = CacheConstants.DEVICE_CACHE_INFO + device.getMac();
|
String key = CacheConstants.DEVICE_CACHE_INFO + device.getMac();
|
||||||
redisCache.setCacheObject(key, info);
|
redisCache.setCacheObject(key, info);
|
||||||
|
|
|
@ -134,6 +134,9 @@ public class DeviceUtil {
|
||||||
if (info.getSoftwareVersion() != null) {
|
if (info.getSoftwareVersion() != null) {
|
||||||
device.setSoftwareVersion(info.getSoftwareVersion());
|
device.setSoftwareVersion(info.getSoftwareVersion());
|
||||||
}
|
}
|
||||||
|
if (info.getLocationType() != null) {
|
||||||
|
device.setLocationType(info.getLocationType());
|
||||||
|
}
|
||||||
|
|
||||||
// 在线状态
|
// 在线状态
|
||||||
if (info.getOnlineStatus() != null) {
|
if (info.getOnlineStatus() != null) {
|
||||||
|
|
|
@ -494,26 +494,28 @@ public class OrderServiceImpl implements OrderService {
|
||||||
|
|
||||||
// 异步使用手机定位更新设备定位
|
// 异步使用手机定位更新设备定位
|
||||||
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
|
private void handleDeviceLocationAsync(DeviceVO device, BigDecimal lon, BigDecimal lat) {
|
||||||
if (device != null && device.getId() != null && DeviceUtil.isLowSatelliteSignal(device) && DeviceUtil.validLocation(lon, lat)) {
|
if (device != null && device.getId() != null && StringUtils.isNotBlank(device.getMac()) && DeviceUtil.validLocation(lon, lat)) {
|
||||||
scheduledExecutorService.execute(() -> {
|
scheduledExecutorService.execute(() -> {
|
||||||
device.setLongitude(lon);
|
device.setLongitude(lon);
|
||||||
device.setLatitude(lat);
|
device.setLatitude(lat);
|
||||||
device.setLocationType(DeviceLocationType.PHONE.getCode());
|
device.setLocationType(DeviceLocationType.PHONE.getCode());
|
||||||
device.setLastLocationTime(LocalDateTime.now());
|
device.setLastLocationTime(LocalDateTime.now());
|
||||||
|
|
||||||
// 更新设备定位
|
// 若卫星信号弱,则更新设备定位
|
||||||
|
if (DeviceUtil.isLowSatelliteSignal(device)) {
|
||||||
Device data = new Device();
|
Device data = new Device();
|
||||||
data.setId(device.getId());
|
data.setMac(device.getMac());
|
||||||
data.setLongitude(device.getLongitude());
|
data.setLongitude(device.getLongitude());
|
||||||
data.setLatitude(device.getLatitude());
|
data.setLatitude(device.getLatitude());
|
||||||
data.setLocationType(device.getLocationType());
|
data.setLocationType(device.getLocationType());
|
||||||
data.setLastLocationTime(LocalDateTime.now());
|
data.setLastLocationTime(LocalDateTime.now());
|
||||||
int rows = deviceService.updateDevice(data);
|
int rows = deviceIotService.updateIot(data);
|
||||||
if (rows != 1) {
|
if (rows != 1) {
|
||||||
log.error("通过手机定位修改设备定位失败deviceId={}", device.getId());
|
log.error("通过手机定位修改设备定位失败deviceMac={}", device.getMac());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转为定位日志
|
// 直接保存定位日志
|
||||||
LocationLog locationLog = locationLogConverter.toPo(device);
|
LocationLog locationLog = locationLogConverter.toPo(device);
|
||||||
if (locationLog == null) {
|
if (locationLog == null) {
|
||||||
log.error("通过手机定位转换定位日志失败: {}", device.getMac());
|
log.error("通过手机定位转换定位日志失败: {}", device.getMac());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user