diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java index 871289d77..9de69f07c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceMapper.java @@ -459,4 +459,47 @@ public interface DeviceMapper { "" + ""}) void batchUpdate(List devices); + + + @Update(value = {" "}) + List queryByDeviceIds(List deviceIds); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index e8d67bfc9..791e9982e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -35,7 +35,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; -import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ObjectUtils; import java.time.Duration; @@ -844,27 +843,27 @@ public class GbChannelServiceImpl implements IGbChannelService { } // 此处来源默认为WGS84, 所以直接入库 commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList); - - Map gpsMsgInfoMap = new ConcurrentReferenceHashMap<>(); - for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) { - gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo); - } - - List channelList = commonGBChannelMapper.queryByGbDeviceIds(new ArrayList<>(gpsMsgInfoMap.keySet())); - if (channelList.isEmpty()) { - return; - } - channelList.forEach(commonGBChannel -> { - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId()); - mobilePosition.setChannelId(commonGBChannel.getGbId()); - mobilePosition.setDeviceName(commonGBChannel.getGbName()); - mobilePosition.setCreateTime(DateUtil.getNow()); - mobilePosition.setTime(DateUtil.getNow()); - mobilePosition.setLongitude(commonGBChannel.getGbLongitude()); - mobilePosition.setLatitude(commonGBChannel.getGbLatitude()); - eventPublisher.mobilePositionEventPublish(mobilePosition); - }); +// +// Map gpsMsgInfoMap = new ConcurrentReferenceHashMap<>(); +// for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) { +// gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo); +// } +// +// List channelList = commonGBChannelMapper.queryByGbDeviceIds(new ArrayList<>(gpsMsgInfoMap.keySet())); +// if (channelList.isEmpty()) { +// return; +// } +// channelList.forEach(commonGBChannel -> { +// MobilePosition mobilePosition = new MobilePosition(); +// mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId()); +// mobilePosition.setChannelId(commonGBChannel.getGbId()); +// mobilePosition.setDeviceName(commonGBChannel.getGbName()); +// mobilePosition.setCreateTime(DateUtil.getNow()); +// mobilePosition.setTime(DateUtil.getNow()); +// mobilePosition.setLongitude(commonGBChannel.getGbLongitude()); +// mobilePosition.setLatitude(commonGBChannel.getGbLatitude()); +// eventPublisher.mobilePositionEventPublish(mobilePosition); +// }); } @Transactional diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java index 2c983773b..7d827c569 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java @@ -540,7 +540,6 @@ public class PlatformServiceImpl implements IPlatformService, CommandLineRunner } for (CommonGBChannel channel : channelList) { GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(channel.getGbDeviceId()); - // 无最新位置则发送当前位置 if (gpsMsgInfo != null && (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0)) { gpsMsgInfo = null; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java index d7d374400..1df382403 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java @@ -356,6 +356,7 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform { if (parentPlatform == null) { return; } + log.info("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat()); if (log.isDebugEnabled()) { log.debug("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat()); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index 5949848a7..628ee2035 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -228,7 +228,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService { @Override public MediaInfo getMediaInfo(MediaServer mediaServer, String app, String stream) { ZLMResult zlmResult = zlmresTfulUtils.getMediaInfo(mediaServer, app, "rtsp", stream); - if (zlmResult.getCode() != 0) { + if (zlmResult.getCode() != 0 || zlmResult.getData() == null || zlmResult.getData().getString("app") == null ) { return null; } return MediaInfo.getInstance(zlmResult.getData(), mediaServer, userSetting.getServerId()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java index 3ba2fa228..0450dcd71 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MobilePositionServiceImpl.java @@ -1,10 +1,12 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; +import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper; import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper; import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; @@ -26,6 +28,9 @@ import java.util.Map; @Service public class MobilePositionServiceImpl implements IMobilePositionService { + @Autowired + private DeviceMapper deviceMapper; + @Autowired private DeviceChannelMapper channelMapper; @@ -100,7 +105,7 @@ public class MobilePositionServiceImpl implements IMobilePositionService { mobilePositionMapper.batchadd(mobilePositions); } log.info("[移动位置订阅]更新通道位置: {}", mobilePositions.size()); - Map updateChannelMap = new HashMap<>(); + Map> updateChannelMap = new HashMap<>(); for (MobilePosition mobilePosition : mobilePositions) { DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setId(mobilePosition.getChannelId()); @@ -114,10 +119,24 @@ public class MobilePositionServiceImpl implements IMobilePositionService { deviceChannel.setGbLongitude(wgs84Position[0]); deviceChannel.setGbLatitude(wgs84Position[1]); } - updateChannelMap.put(mobilePosition.getDeviceId() + mobilePosition.getChannelId(), deviceChannel); + if (!updateChannelMap.containsKey(mobilePosition.getDeviceId())) { + updateChannelMap.put(mobilePosition.getDeviceId(), new HashMap<>()); + } + updateChannelMap.get(mobilePosition.getDeviceId()).put(mobilePosition.getChannelId(), deviceChannel); + } + List deviceIds = new ArrayList<>(updateChannelMap.keySet()); + List deviceList = deviceMapper.queryByDeviceIds(deviceIds); + for (Device device : deviceList) { + Map channelMap = updateChannelMap.get(device.getDeviceId()); + if (device.getGeoCoordSys().equalsIgnoreCase("GCJ02")) { + channelMap.values().forEach(channel -> { + Double[] wgs84Position = Coordtransform.GCJ02ToWGS84(channel.getLongitude(), channel.getLatitude()); + channel.setGbLongitude(wgs84Position[0]); + channel.setGbLatitude(wgs84Position[1]); + }); + } + channelMapper.batchUpdatePosition(new ArrayList<>(channelMap.values())); } - List channels = new ArrayList<>(updateChannelMap.values()); - channelMapper.batchUpdatePosition(channels); } }