修复上报的坐标未按照坐标系转换的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>" + "</foreach>" +
"</script>"}) "</script>"})
void batchUpdate(List<Device> devices); 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.time.Duration; import java.time.Duration;
@@ -844,27 +843,27 @@ public class GbChannelServiceImpl implements IGbChannelService {
} }
// 此处来源默认为WGS84, 所以直接入库 // 此处来源默认为WGS84, 所以直接入库
commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList); commonGBChannelMapper.updateGpsByDeviceId(gpsMsgInfoList);
//
Map<String, GPSMsgInfo> gpsMsgInfoMap = new ConcurrentReferenceHashMap<>(); // Map<String, GPSMsgInfo> gpsMsgInfoMap = new ConcurrentReferenceHashMap<>();
for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) { // for (GPSMsgInfo gpsMsgInfo : gpsMsgInfoList) {
gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo); // gpsMsgInfoMap.put(gpsMsgInfo.getId(), gpsMsgInfo);
} // }
//
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(new ArrayList<>(gpsMsgInfoMap.keySet())); // List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(new ArrayList<>(gpsMsgInfoMap.keySet()));
if (channelList.isEmpty()) { // if (channelList.isEmpty()) {
return; // return;
} // }
channelList.forEach(commonGBChannel -> { // channelList.forEach(commonGBChannel -> {
MobilePosition mobilePosition = new MobilePosition(); // MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId()); // mobilePosition.setDeviceId(commonGBChannel.getGbDeviceId());
mobilePosition.setChannelId(commonGBChannel.getGbId()); // mobilePosition.setChannelId(commonGBChannel.getGbId());
mobilePosition.setDeviceName(commonGBChannel.getGbName()); // mobilePosition.setDeviceName(commonGBChannel.getGbName());
mobilePosition.setCreateTime(DateUtil.getNow()); // mobilePosition.setCreateTime(DateUtil.getNow());
mobilePosition.setTime(DateUtil.getNow()); // mobilePosition.setTime(DateUtil.getNow());
mobilePosition.setLongitude(commonGBChannel.getGbLongitude()); // mobilePosition.setLongitude(commonGBChannel.getGbLongitude());
mobilePosition.setLatitude(commonGBChannel.getGbLatitude()); // mobilePosition.setLatitude(commonGBChannel.getGbLatitude());
eventPublisher.mobilePositionEventPublish(mobilePosition); // eventPublisher.mobilePositionEventPublish(mobilePosition);
}); // });
} }
@Transactional @Transactional

View File

@@ -540,7 +540,6 @@ public class PlatformServiceImpl implements IPlatformService, CommandLineRunner
} }
for (CommonGBChannel channel : channelList) { for (CommonGBChannel channel : channelList) {
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(channel.getGbDeviceId()); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(channel.getGbDeviceId());
// 无最新位置则发送当前位置 // 无最新位置则发送当前位置
if (gpsMsgInfo != null && (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0)) { if (gpsMsgInfo != null && (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0)) {
gpsMsgInfo = null; gpsMsgInfo = null;

View File

@@ -356,6 +356,7 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform {
if (parentPlatform == null) { if (parentPlatform == null) {
return; return;
} }
log.info("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat()); log.debug("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
} }

View File

@@ -228,7 +228,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
@Override @Override
public MediaInfo getMediaInfo(MediaServer mediaServer, String app, String stream) { public MediaInfo getMediaInfo(MediaServer mediaServer, String app, String stream) {
ZLMResult<JSONObject> zlmResult = zlmresTfulUtils.getMediaInfo(mediaServer, app, "rtsp", 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 null;
} }
return MediaInfo.getInstance(zlmResult.getData(), mediaServer, userSetting.getServerId()); return MediaInfo.getInstance(zlmResult.getData(), mediaServer, userSetting.getServerId());

View File

@@ -1,10 +1,12 @@
package com.genersoft.iot.vmp.service.impl; package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.conf.UserSetting; 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.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper; 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.DeviceMobilePositionMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper; import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
@@ -26,6 +28,9 @@ import java.util.Map;
@Service @Service
public class MobilePositionServiceImpl implements IMobilePositionService { public class MobilePositionServiceImpl implements IMobilePositionService {
@Autowired
private DeviceMapper deviceMapper;
@Autowired @Autowired
private DeviceChannelMapper channelMapper; private DeviceChannelMapper channelMapper;
@@ -100,7 +105,7 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
mobilePositionMapper.batchadd(mobilePositions); mobilePositionMapper.batchadd(mobilePositions);
} }
log.info("[移动位置订阅]更新通道位置: {}", mobilePositions.size()); log.info("[移动位置订阅]更新通道位置: {}", mobilePositions.size());
Map<String, DeviceChannel> updateChannelMap = new HashMap<>(); Map<String, Map<Integer, DeviceChannel>> updateChannelMap = new HashMap<>();
for (MobilePosition mobilePosition : mobilePositions) { for (MobilePosition mobilePosition : mobilePositions) {
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setId(mobilePosition.getChannelId()); deviceChannel.setId(mobilePosition.getChannelId());
@@ -114,10 +119,24 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
deviceChannel.setGbLongitude(wgs84Position[0]); deviceChannel.setGbLongitude(wgs84Position[0]);
deviceChannel.setGbLatitude(wgs84Position[1]); 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);
} }
} }