修复上报的坐标未按照坐标系转换的BUG

This commit is contained in:
lin
2025-11-05 11:34:59 +08:00
parent bf5af5779f
commit 826b251544
6 changed files with 89 additions and 28 deletions

View File

@@ -459,4 +459,47 @@ public interface DeviceMapper {
"</foreach>" +
"</script>"})
void batchUpdate(List<Device> devices);
@Update(value = {" <script>" +
"SELECT " +
"coalesce(custom_name, name) as name, " +
"id" +
",device_id" +
",manufacturer" +
",model" +
",firmware" +
",transport" +
",stream_mode" +
",on_line" +
",register_time" +
",keepalive_time" +
",ip" +
",create_time" +
",update_time" +
",port" +
",expires" +
",subscribe_cycle_for_catalog" +
",subscribe_cycle_for_mobile_position" +
",mobile_position_submission_interval" +
",subscribe_cycle_for_alarm" +
",host_address" +
",charset" +
",ssrc_check" +
",geo_coord_sys" +
",media_server_id" +
",sdp_ip" +
",local_ip" +
",password" +
",as_message_channel" +
",heart_beat_interval" +
",heart_beat_count" +
",position_capability" +
",broadcast_push_after_ack" +
",server_id" +
" FROM wvp_device" +
" WHERE device_id in"+
"<foreach collection='deviceIds' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
" </script>"})
List<Device> queryByDeviceIds(List<String> deviceIds);
}

View File

@@ -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<String, GPSMsgInfo> gpsMsgInfoMap = new ConcurrentReferenceHashMap<>();
for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) {
gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo);
}
List<CommonGBChannel> 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<String, GPSMsgInfo> gpsMsgInfoMap = new ConcurrentReferenceHashMap<>();
// for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) {
// gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo);
// }
//
// List<CommonGBChannel> 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

View File

@@ -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;

View File

@@ -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());
}

View File

@@ -228,7 +228,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
@Override
public MediaInfo getMediaInfo(MediaServer mediaServer, String app, String stream) {
ZLMResult<JSONObject> 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());

View File

@@ -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<String, DeviceChannel> updateChannelMap = new HashMap<>();
Map<String, Map<Integer, DeviceChannel>> 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<String> deviceIds = new ArrayList<>(updateChannelMap.keySet());
List<Device> deviceList = deviceMapper.queryByDeviceIds(deviceIds);
for (Device device : deviceList) {
Map<Integer, DeviceChannel> 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<DeviceChannel> channels = new ArrayList<>(updateChannelMap.values());
channelMapper.batchUpdatePosition(channels);
}
}