调整移动位置订阅发送逻辑

2.7.1
lin 2025-02-08 16:29:54 +08:00
parent c331f02f6b
commit e59b300c2e
2 changed files with 20 additions and 17 deletions

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.service.IMobilePositionService; import com.genersoft.iot.vmp.service.IMobilePositionService;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMobilePositionMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMobilePositionMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -83,9 +84,14 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
for (MobilePosition mobilePosition : mobilePositions) { for (MobilePosition mobilePosition : mobilePositions) {
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(mobilePosition.getDeviceId()); deviceChannel.setDeviceId(mobilePosition.getDeviceId());
deviceChannel.setChannelId(mobilePosition.getChannelId());
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setUpdateTime(DateUtil.getNow());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel.setGpsSpeed(mobilePosition.getSpeed());
deviceChannel.setGpsDirection(mobilePosition.getDirection() + "");
deviceChannel.setGpsAltitude(mobilePosition.getAltitude() + "");
updateChannelMap.put(mobilePosition.getDeviceId() + mobilePosition.getChannelId(), deviceChannel); updateChannelMap.put(mobilePosition.getDeviceId() + mobilePosition.getChannelId(), deviceChannel);
} }
List<DeviceChannel> channels = new ArrayList<>(updateChannelMap.values()); List<DeviceChannel> channels = new ArrayList<>(updateChannelMap.values());

View File

@ -433,24 +433,21 @@ public class PlatformServiceImpl implements IPlatformService {
for (DeviceChannel deviceChannel : deviceChannelList) { for (DeviceChannel deviceChannel : deviceChannelList) {
String gbId = deviceChannel.getChannelId(); String gbId = deviceChannel.getChannelId();
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
// 无最新位置则发送当前位置 // 无最新位置则发送当前位置
if (gpsMsgInfo != null) { if (gpsMsgInfo != null && (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0)) {
// 经纬度都为0不发送 gpsMsgInfo = null;
if (gpsMsgInfo.getLng() == 0 || gpsMsgInfo.getLat() == 0) { }
gpsMsgInfo.setLng(deviceChannel.getLongitude());
gpsMsgInfo.setLat(deviceChannel.getLatitude()); if (gpsMsgInfo == null && !userSetting.isSendPositionOnDemand()){
} gpsMsgInfo = new GPSMsgInfo();
}else { gpsMsgInfo.setId(deviceChannel.getChannelId());
if (!userSetting.isSendPositionOnDemand()) { gpsMsgInfo.setLng(deviceChannel.getLongitude());
gpsMsgInfo = new GPSMsgInfo(); gpsMsgInfo.setLat(deviceChannel.getLatitude());
gpsMsgInfo.setId(deviceChannel.getChannelId()); gpsMsgInfo.setAltitude(deviceChannel.getGpsAltitude());
gpsMsgInfo.setLng(deviceChannel.getLongitude()); gpsMsgInfo.setSpeed(deviceChannel.getGpsSpeed());
gpsMsgInfo.setLat(deviceChannel.getLatitude()); gpsMsgInfo.setDirection(deviceChannel.getGpsDirection());
gpsMsgInfo.setAltitude(deviceChannel.getGpsAltitude()); gpsMsgInfo.setTime(deviceChannel.getGpsTime());
gpsMsgInfo.setSpeed(deviceChannel.getGpsSpeed());
gpsMsgInfo.setDirection(deviceChannel.getGpsDirection());
gpsMsgInfo.setTime(deviceChannel.getGpsTime());
}
} }
if (gpsMsgInfo != null) { if (gpsMsgInfo != null) {
// 发送GPS消息 // 发送GPS消息