调整移动位置订阅发送逻辑
parent
c331f02f6b
commit
e59b300c2e
|
@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
|||
import com.genersoft.iot.vmp.service.IMobilePositionService;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceMobilePositionMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -83,9 +84,14 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
|
|||
for (MobilePosition mobilePosition : mobilePositions) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(mobilePosition.getDeviceId());
|
||||
deviceChannel.setChannelId(mobilePosition.getChannelId());
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
deviceChannel.setGpsSpeed(mobilePosition.getSpeed());
|
||||
deviceChannel.setGpsDirection(mobilePosition.getDirection() + "");
|
||||
deviceChannel.setGpsAltitude(mobilePosition.getAltitude() + "");
|
||||
updateChannelMap.put(mobilePosition.getDeviceId() + mobilePosition.getChannelId(), deviceChannel);
|
||||
}
|
||||
List<DeviceChannel> channels = new ArrayList<>(updateChannelMap.values());
|
||||
|
|
|
@ -433,24 +433,21 @@ public class PlatformServiceImpl implements IPlatformService {
|
|||
for (DeviceChannel deviceChannel : deviceChannelList) {
|
||||
String gbId = deviceChannel.getChannelId();
|
||||
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
|
||||
|
||||
// 无最新位置则发送当前位置
|
||||
if (gpsMsgInfo != null) {
|
||||
// 经纬度都为0不发送
|
||||
if (gpsMsgInfo.getLng() == 0 || gpsMsgInfo.getLat() == 0) {
|
||||
gpsMsgInfo.setLng(deviceChannel.getLongitude());
|
||||
gpsMsgInfo.setLat(deviceChannel.getLatitude());
|
||||
}
|
||||
}else {
|
||||
if (!userSetting.isSendPositionOnDemand()) {
|
||||
gpsMsgInfo = new GPSMsgInfo();
|
||||
gpsMsgInfo.setId(deviceChannel.getChannelId());
|
||||
gpsMsgInfo.setLng(deviceChannel.getLongitude());
|
||||
gpsMsgInfo.setLat(deviceChannel.getLatitude());
|
||||
gpsMsgInfo.setAltitude(deviceChannel.getGpsAltitude());
|
||||
gpsMsgInfo.setSpeed(deviceChannel.getGpsSpeed());
|
||||
gpsMsgInfo.setDirection(deviceChannel.getGpsDirection());
|
||||
gpsMsgInfo.setTime(deviceChannel.getGpsTime());
|
||||
}
|
||||
if (gpsMsgInfo != null && (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0)) {
|
||||
gpsMsgInfo = null;
|
||||
}
|
||||
|
||||
if (gpsMsgInfo == null && !userSetting.isSendPositionOnDemand()){
|
||||
gpsMsgInfo = new GPSMsgInfo();
|
||||
gpsMsgInfo.setId(deviceChannel.getChannelId());
|
||||
gpsMsgInfo.setLng(deviceChannel.getLongitude());
|
||||
gpsMsgInfo.setLat(deviceChannel.getLatitude());
|
||||
gpsMsgInfo.setAltitude(deviceChannel.getGpsAltitude());
|
||||
gpsMsgInfo.setSpeed(deviceChannel.getGpsSpeed());
|
||||
gpsMsgInfo.setDirection(deviceChannel.getGpsDirection());
|
||||
gpsMsgInfo.setTime(deviceChannel.getGpsTime());
|
||||
}
|
||||
if (gpsMsgInfo != null) {
|
||||
// 发送GPS消息
|
||||
|
|
Loading…
Reference in New Issue