优化地图展示流程,已经默认统一坐标为wgs84

This commit is contained in:
lin
2025-09-25 18:06:58 +08:00
parent 6469aefe22
commit 8d6fe0c9d8
12 changed files with 102 additions and 308 deletions

View File

@@ -212,4 +212,8 @@ public class Device {
@Schema(description = "所属服务Id")
private String serverId;
public boolean isWgs84() {
return geoCoordSys.equalsIgnoreCase("WGS84");
}
}

View File

@@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.gb28181.dao.provider.DeviceChannelProvider;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -23,13 +22,13 @@ public interface DeviceChannelMapper {
"insert into wvp_device_channel " +
"(device_id, data_type, data_device_id, name, manufacturer, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"ip_address, port, password, status, longitude, latitude, gb_longitude, gb_latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
"values " +
"(#{deviceId}, #{dataType}, #{dataDeviceId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}, " +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
"#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{gbLongitude}, #{gbLatitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
"#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," +
" #{svcTimeSupportMode}, #{createTime}, #{updateTime}, #{subCount}, #{streamId}, #{hasAudio}, #{gpsTime}, #{streamIdentification}, #{channelType}) " +
"</script>")
@@ -64,6 +63,8 @@ public interface DeviceChannelMapper {
", status=#{status}" +
", longitude=#{longitude}" +
", latitude=#{latitude}" +
", gb_longitude=#{gbLongitude}" +
", gb_latitude=#{gbLatitude}" +
", ptz_type=#{ptzType}" +
", position_type=#{positionType}" +
", room_type=#{roomType}" +
@@ -199,14 +200,14 @@ public interface DeviceChannelMapper {
"insert into wvp_device_channel " +
"(device_id, data_type, data_device_id, name, manufacturer, model, owner, civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"ip_address, port, password, status, longitude, latitude, gb_longitude, gb_latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " +
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"(#{item.deviceId}, #{item.dataType}, #{item.dataDeviceId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.gbLongitude}, #{item.gbLatitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
"#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," +
" #{item.svcTimeSupportMode}, #{item.createTime}, #{item.updateTime}, #{item.subCount}, #{item.streamId}, #{item.hasAudio}, #{item.gpsTime}, #{item.streamIdentification}, #{item.channelType}) " +
"</foreach> " +
@@ -247,6 +248,8 @@ public interface DeviceChannelMapper {
", status=#{item.status}" +
", longitude=#{item.longitude}" +
", latitude=#{item.latitude}" +
", gb_longitude=#{gbLongitude}" +
", gb_latitude=#{gbLatitude}" +
", ptz_type=#{item.ptzType}" +
", position_type=#{item.positionType}" +
", room_type=#{item.roomType}" +
@@ -269,72 +272,13 @@ public interface DeviceChannelMapper {
"</script>"})
int batchUpdate(List<DeviceChannel> updateChannels);
@Update({"<script>" +
"<foreach collection='updateChannels' item='item' separator=';'>" +
" UPDATE" +
" wvp_device_channel" +
" SET update_time=#{item.updateTime}" +
", device_id=#{item.deviceId}" +
", data_type=#{item.dataType}" +
", data_device_id=#{item.dataDeviceId}" +
", name=#{item.name}" +
", manufacturer=#{item.manufacturer}" +
", model=#{item.model}" +
", owner=#{item.owner}" +
", civil_code=#{item.civilCode}" +
", block=#{item.block}" +
", address=#{item.address}" +
", parental=#{item.parental}" +
", parent_id=#{item.parentId}" +
", safety_way=#{item.safetyWay}" +
", register_way=#{item.registerWay}" +
", cert_num=#{item.certNum}" +
", certifiable=#{item.certifiable}" +
", err_code=#{item.errCode}" +
", end_time=#{item.endTime}" +
", secrecy=#{item.secrecy}" +
", ip_address=#{item.ipAddress}" +
", port=#{item.port}" +
", password=#{item.password}" +
", status=#{item.status}" +
", longitude=#{item.longitude}" +
", latitude=#{item.latitude}" +
", ptz_type=#{item.ptzType}" +
", position_type=#{item.positionType}" +
", room_type=#{item.roomType}" +
", use_type=#{item.useType}" +
", supply_light_type=#{item.supplyLightType}" +
", direction_type=#{item.directionType}" +
", resolution=#{item.resolution}" +
", business_group_id=#{item.businessGroupId}" +
", download_speed=#{item.downloadSpeed}" +
", svc_space_support_mod=#{item.svcSpaceSupportMod}" +
", svc_time_support_mode=#{item.svcTimeSupportMode}" +
", sub_count=#{item.subCount}" +
", stream_id=#{item.streamId}" +
", has_audio=#{item.hasAudio}" +
", gps_time=#{item.gpsTime}" +
", stream_identification=#{item.streamIdentification}" +
", channel_type=#{item.channelType}" +
" WHERE data_type = #{item.dataType} and data_device_id = #{item.dataDeviceId} and device_id=#{item.deviceId}" +
"</foreach>" +
"</script>"})
int batchUpdateForNotify(List<DeviceChannel> updateChannels);
@Update(" update wvp_device_channel" +
" set sub_count = (select *" +
" from (select count(0)" +
" from wvp_device_channel" +
" where data_type = 1 and data_device_id = #{dataDeviceId} and parent_id = #{channelId}) as temp)" +
" where data_type = 1 and data_device_id = #{dataDeviceId} and device_id = #{channelId}")
int updateChannelSubCount(@Param("dataDeviceId") int dataDeviceId, @Param("channelId") String channelId);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET " +
" latitude=#{latitude}, " +
" longitude=#{longitude}, " +
" gb_longitude=#{gbLongitude}, " +
" gb_latitude=#{gbLatitude}, " +
" gps_time=#{gpsTime} " +
" WHERE id=#{id} " +
" </script>"})
@@ -374,6 +318,8 @@ public interface DeviceChannelMapper {
" status,\n" +
" longitude,\n" +
" latitude,\n" +
" gb_longitude,\n" +
" gb_latitude,\n" +
" ptz_type,\n" +
" position_type,\n" +
" room_type,\n" +
@@ -429,6 +375,8 @@ public interface DeviceChannelMapper {
" SET update_time=#{item.updateTime}" +
"<if test='item.longitude != null'>, longitude=#{item.longitude}</if>" +
"<if test='item.latitude != null'>, latitude=#{item.latitude}</if>" +
"<if test='item.gbLongitude != null'>, gb_longitude=#{item.gbLongitude}</if>" +
"<if test='item.gbLatitude != null'>, gb_latitude=#{item.gbLatitude}</if>" +
"<if test='item.gpsTime != null'>, gps_time=#{item.gpsTime}</if>" +
"<if test='item.id > 0'>WHERE id=#{item.id}</if>" +
"<if test='item.id == 0'>WHERE data_type = #{item.dataType} and data_device_id=#{item.dataDeviceId} AND device_id=#{item.deviceId}</if>" +
@@ -474,6 +422,8 @@ public interface DeviceChannelMapper {
" status,\n" +
" longitude,\n" +
" latitude,\n" +
" gb_longitude,\n" +
" gb_latitude,\n" +
" ptz_type,\n" +
" position_type,\n" +
" room_type,\n" +
@@ -529,6 +479,8 @@ public interface DeviceChannelMapper {
" status,\n" +
" longitude,\n" +
" latitude,\n" +
" gb_longitude,\n" +
" gb_latitude,\n" +
" ptz_type,\n" +
" position_type,\n" +
" room_type,\n" +
@@ -556,13 +508,6 @@ public interface DeviceChannelMapper {
" </script>"})
void changeAudio(@Param("channelId") int channelId, @Param("audio") boolean audio);
@Update("<script> " +
"<foreach collection='gpsMsgInfoList' index='index' item='item' separator=';'> " +
"UPDATE wvp_device_channel SET gb_longitude = #{item.lng}, gb_latitude=#{item.lat} WHERE id = #{item.channelId}" +
"</foreach> " +
"</script>")
void updateStreamGPS(List<GPSMsgInfo> gpsMsgInfoList);
@Update("UPDATE wvp_device_channel SET status=#{status} WHERE data_type=#{dataType} and data_device_id=#{dataDeviceId} AND device_id=#{deviceId}")
void updateStatus(DeviceChannel channel);
@@ -595,6 +540,8 @@ public interface DeviceChannelMapper {
", status=#{status}" +
", longitude=#{longitude}" +
", latitude=#{latitude}" +
", gb_longitude=#{gbLongitude}" +
", gb_latitude=#{gbLatitude}" +
", ptz_type=#{ptzType}" +
", position_type=#{positionType}" +
", room_type=#{roomType}" +
@@ -652,6 +599,8 @@ public interface DeviceChannelMapper {
" status,\n" +
" longitude,\n" +
" latitude,\n" +
" gb_longitude,\n" +
" gb_latitude,\n" +
" ptz_type,\n" +
" position_type,\n" +
" room_type,\n" +

View File

@@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.common.enums.DeviceControlType;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
@@ -29,28 +28,6 @@ public interface IDeviceChannelService {
*/
ResourceBaseInfo getOverview();
/**
* 查询所有未分配的通道
* @param platformId
* @return
*/
List<ChannelReduce> queryAllChannelList(String platformId);
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
/**
* 查询通道所属的设备
*/
List<Device> getDeviceByChannelId(String channelId);
/**
* 批量删除通道
* @param deleteChannelList 待删除的通道列表
*/
int deleteChannelsForNotify(List<DeviceChannel> deleteChannelList);
int updateChannelsStatus(List<DeviceChannel> channels);
/**
* 获取一个通道
*/
@@ -58,16 +35,6 @@ public interface IDeviceChannelService {
DeviceChannel getOneForSource(String deviceId, String channelId);
/**
* 直接批量更新通道
*/
void batchUpdateChannelForNotify(List<DeviceChannel> channels);
/**
* 直接批量添加
*/
void batchAddChannel(List<DeviceChannel> deviceChannels);
/**
* 修改通道的码流类型
*/
@@ -81,10 +48,6 @@ public interface IDeviceChannelService {
void stopPlay(Integer channelId);
void batchUpdateChannelGPS(List<DeviceChannel> channelList);
void batchAddMobilePosition(List<MobilePosition> addMobilePositionList);
void online(DeviceChannel channel);
void offline(DeviceChannel channel);
@@ -125,8 +88,6 @@ public interface IDeviceChannelService {
DeviceChannel getOneBySourceId(int deviceDbId, String channelId);
List<DeviceChannel> queryChaneListByDeviceDbId(Integer deviceDbId);
List<Integer> queryChaneIdListByDeviceDbIds(List<Integer> deviceDbId);
void handlePtzCmd(@NotNull Integer dataDeviceId, @NotNull Integer gbId, Element rootElement, DeviceControlType type, ErrorCallback<String> callback);

View File

@@ -8,7 +8,6 @@ import com.genersoft.iot.vmp.common.enums.DeviceControlType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper;
@@ -210,66 +209,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return new ResourceBaseInfo(total, online);
}
@Override
public List<ChannelReduce> queryAllChannelList(String platformId) {
return channelMapper.queryChannelListInAll(null, null, null, platformId, null);
}
@Override
public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId) {
PageHelper.startPage(page, count);
List<ChannelReduce> all = channelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId);
return new PageInfo<>(all);
}
@Override
public List<Device> getDeviceByChannelId(String channelId) {
return channelMapper.getDeviceByChannelDeviceId(channelId);
}
@Override
@Transactional
public int deleteChannelsForNotify(List<DeviceChannel> channels) {
int limitCount = 1000;
int result = 0;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
result += channelMapper.batchDel(channels.subList(i, toIndex));
}
}else {
result += channelMapper.batchDel(channels);
}
}
return result;
}
@Transactional
@Override
public int updateChannelsStatus(List<DeviceChannel> channels) {
int limitCount = 1000;
int result = 0;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
result += channelMapper.batchUpdateStatus(channels.subList(i, toIndex));
}
}else {
result += channelMapper.batchUpdateStatus(channels);
}
}
return result;
}
@Override
public void online(DeviceChannel channel) {
channelMapper.online(channel.getId());
@@ -313,58 +252,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return channelMapper.getOneBySourceChannelId(deviceDbId, channelId);
}
@Override
@Transactional
public synchronized void batchUpdateChannelForNotify(List<DeviceChannel> channels) {
String now = DateUtil.getNow();
for (DeviceChannel channel : channels) {
channel.setUpdateTime(now);
}
int limitCount = 1000;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
channelMapper.batchUpdateForNotify(channels.subList(i, toIndex));
}
}else {
channelMapper.batchUpdateForNotify(channels);
}
}
}
@Override
@Transactional
public void batchAddChannel(List<DeviceChannel> channels) {
String now = DateUtil.getNow();
for (DeviceChannel channel : channels) {
channel.setUpdateTime(now);
channel.setCreateTime(now);
}
int limitCount = 1000;
if (!channels.isEmpty()) {
if (channels.size() > limitCount) {
for (int i = 0; i < channels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > channels.size()) {
toIndex = channels.size();
}
channelMapper.batchAdd(channels.subList(i, toIndex));
}
}else {
channelMapper.batchAdd(channels);
}
}
for (DeviceChannel channel : channels) {
if (channel.getParentId() != null) {
channelMapper.updateChannelSubCount(channel.getDataDeviceId(), channel.getParentId());
}
}
}
@Override
public void updateChannelStreamIdentification(DeviceChannel channel) {
Assert.hasLength(channel.getStreamIdentification(), "码流标识必须存在");
@@ -390,11 +277,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
return channelMapper.queryChannelsByDeviceDbId(device.getId());
}
@Override
public List<DeviceChannel> queryChaneListByDeviceDbId(Integer deviceDbId) {
return channelMapper.queryChannelsByDeviceDbId(deviceDbId);
}
@Override
public List<Integer> queryChaneIdListByDeviceDbIds(List<Integer> deviceDbIds) {
return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds);
@@ -509,49 +391,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelMapper.stopPlayById(channelId);
}
@Override
@Transactional
public void batchUpdateChannelGPS(List<DeviceChannel> channelList) {
for (DeviceChannel deviceChannel : channelList) {
deviceChannel.setUpdateTime(DateUtil.getNow());
if (deviceChannel.getGpsTime() == null) {
deviceChannel.setGpsTime(DateUtil.getNow());
}
}
int count = 1000;
if (channelList.size() > count) {
for (int i = 0; i < channelList.size(); i+=count) {
int toIndex = i+count;
if ( i + count > channelList.size()) {
toIndex = channelList.size();
}
List<DeviceChannel> channels = channelList.subList(i, toIndex);
channelMapper.batchUpdatePosition(channels);
}
}else {
channelMapper.batchUpdatePosition(channelList);
}
}
@Override
@Transactional
public void batchAddMobilePosition(List<MobilePosition> mobilePositions) {
// int count = 500;
// if (mobilePositions.size() > count) {
// for (int i = 0; i < mobilePositions.size(); i+=count) {
// int toIndex = i+count;
// if ( i + count > mobilePositions.size()) {
// toIndex = mobilePositions.size();
// }
// List<MobilePosition> mobilePositionsSub = mobilePositions.subList(i, toIndex);
// deviceMobilePositionMapper.batchadd(mobilePositionsSub);
// }
// }else {
// deviceMobilePositionMapper.batchadd(mobilePositions);
// }
deviceMobilePositionMapper.batchadd(mobilePositions);
}
@Override
public void cleanChannelsForDevice(int deviceId) {
channelMapper.cleanChannelsByDeviceId(deviceId);

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.Coordtransform;
import com.genersoft.iot.vmp.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;
@@ -116,6 +117,17 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
continue;
}
catalogChannelEvent.getChannel().setDataDeviceId(device.getId());
if (catalogChannelEvent.getChannel().getLongitude() > 0
&& catalogChannelEvent.getChannel().getLatitude() > 0) {
if (device.isWgs84()) {
catalogChannelEvent.getChannel().setGbLongitude(catalogChannelEvent.getChannel().getLongitude());
catalogChannelEvent.getChannel().setGbLatitude(catalogChannelEvent.getChannel().getLatitude());
}else {
Double[] wgs84Position = Coordtransform.GCJ02ToWGS84(catalogChannelEvent.getChannel().getLongitude(), catalogChannelEvent.getChannel().getLatitude());
catalogChannelEvent.getChannel().setGbLongitude(wgs84Position[0]);
catalogChannelEvent.getChannel().setGbLatitude(wgs84Position[1]);
}
}
} catch (InvocationTargetException | NoSuchMethodException | InstantiationException |
IllegalAccessException e) {
log.error("[解析CatalogChannelEvent]失败,", e);

View File

@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.session.CatalogDataManager;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.utils.Coordtransform;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;
@@ -158,6 +159,11 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
channel.setChannelType(2);
groupList.add(group);
}
if (channel.getLongitude() > 0 && channel.getLatitude() > 0) {
Double[] wgs84Position = Coordtransform.GCJ02ToWGS84(channel.getLongitude(), channel.getLatitude());
channel.setGbLongitude(wgs84Position[0]);
channel.setGbLatitude(wgs84Position[1]);
}
}
channelList.add(channel);
}

View File

@@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import java.util.List;
@@ -19,6 +18,4 @@ public interface IMobilePositionService {
MobilePosition queryLatestPosition(String deviceId);
void updateStreamGPS(List<GPSMsgInfo> gpsMsgInfoList);
}

View File

@@ -43,7 +43,7 @@ public class MapServiceImplForSy implements IMapService {
}
// 卫星地图
MapConfig mapConfigForSatellited = readConfig("FRAGMENTIMG_SERVER", configObject);
MapConfig mapConfigForSatellited = readConfig("SATELLITE_FRAGMENTIMG_SERVER", configObject);
if (mapConfigForSatellited != null) {
mapConfigForSatellited.setName("卫星地图");
configList.add(mapConfigForSatellited);

View File

@@ -4,11 +4,11 @@ import com.genersoft.iot.vmp.conf.UserSetting;
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.PlatformMapper;
import com.genersoft.iot.vmp.service.IMobilePositionService;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMobilePositionMapper;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.service.IMobilePositionService;
import com.genersoft.iot.vmp.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -88,11 +88,6 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
return mobilePositionMapper.queryLatestPositionByDevice(deviceId);
}
@Override
public void updateStreamGPS(List<GPSMsgInfo> gpsMsgInfoList) {
channelMapper.updateStreamGPS(gpsMsgInfoList);
}
@Scheduled(fixedDelay = 1000)
@Transactional
public void executeTaskQueue() {
@@ -114,6 +109,11 @@ public class MobilePositionServiceImpl implements IMobilePositionService {
deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel.setUpdateTime(DateUtil.getNow());
if (mobilePosition.getLongitude() > 0 || mobilePosition.getLatitude() > 0) {
Double[] wgs84Position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
deviceChannel.setGbLongitude(wgs84Position[0]);
deviceChannel.setGbLatitude(wgs84Position[1]);
}
updateChannelMap.put(mobilePosition.getDeviceId() + mobilePosition.getChannelId(), deviceChannel);
}
List<DeviceChannel> channels = new ArrayList<>(updateChannelMap.values());

View File

@@ -17,7 +17,7 @@ import View from 'ol/View'
import Feature from 'ol/Feature'
import Overlay from 'ol/Overlay'
import { Point, LineString } from 'ol/geom'
import { get as getProj } from 'ol/proj'
import { get as getProj, toLonLat as projToLonLat } from 'ol/proj'
import { containsCoordinate } from 'ol/extent'
import {
defaults as defaultInteractions
@@ -27,9 +27,9 @@ import { fromLonLat, toLonLat } from './map/TransformLonLat'
import { v4 } from 'uuid'
import { getUid } from 'ol'
import gcoord from 'gcoord'
let olMap = null
let olMap, tileLayer = null
export default {
name: 'MapComponent',
props: [],
@@ -72,6 +72,7 @@ export default {
},
initMap(){
let center = fromLonLat([116.41020, 39.915119])
window.coordinateSystem = this.mapTileList[this.mapTileIndex].coordinateSystem
if (window.mapParam.center) {
center = fromLonLat(window.mapParam.center)
}
@@ -82,7 +83,7 @@ export default {
maxZoom: window.mapParam.maxZoom || 19,
minZoom: window.mapParam.minZoom || 1
})
let tileLayer = null
if (this.mapTileList.length > 0 && this.mapTileList[this.mapTileIndex].tilesUrl) {
tileLayer = new Tile({
source: new XYZ({
@@ -231,7 +232,7 @@ export default {
}
},
/**
* 添加图层
* 添加图层 数据坐标系由控件内完成输入和输出永远是wgs84
* @param data
* [
* {
@@ -287,7 +288,6 @@ export default {
}
},
updateLayer(layer, data, postponement) {
console.log(layer)
layer.getSource().clear(true)
const features = []
for (let i = 0; i < data.length; i++) {
@@ -374,6 +374,19 @@ export default {
},
getCurrentCoordinateSystem() {
return this.mapTileList[this.mapTileIndex].coordinateSystem
},
changeMapTile(index) {
let center = this.getCenter()
let mapTileConfig = this.mapTileList[this.mapTileIndex]
this.mapTileIndex = index
window.coordinateSystem = this.mapTileList[this.mapTileIndex].coordinateSystem
tileLayer.getSource().setUrl(this.mapTileList[index].tilesUrl)
if (mapTileConfig.coordinateSystem !== this.mapTileList[this.mapTileIndex].coordinateSystem) {
// 发送通知
this.$emit('coordinateSystemChange', this.mapTileList[this.mapTileIndex].coordinateSystem)
// 修正地图的中心点
olMap.getView().setCenter(fromLonLat(center))
}
}
}
}

View File

@@ -2,8 +2,16 @@ import { fromLonLat as projFromLonLat, toLonLat as projToLonLat } from 'ol/proj'
import gcoord from 'gcoord'
export function fromLonLat(coordinate) {
return projFromLonLat(gcoord.transform(coordinate, gcoord.WGS84, gcoord.GCJ02))
if (window.coordinateSystem === 'GCJ02') {
return projFromLonLat(gcoord.transform(coordinate, gcoord.WGS84, gcoord.GCJ02))
}else {
return projFromLonLat(coordinate)
}
}
export function toLonLat(coordinate) {
return gcoord.transform(projToLonLat(coordinate), gcoord.GCJ02, gcoord.WGS84)
if (window.coordinateSystem === 'GCJ02') {
return gcoord.transform(projToLonLat(coordinate), gcoord.GCJ02, gcoord.WGS84)
}else {
return projToLonLat(coordinate)
}
}

View File

@@ -2,13 +2,19 @@
<div id="devicePosition" style="height: calc(100vh - 84px);width: 100%;">
<div style="height: 100%; display: grid; grid-template-columns: 360px auto">
<DeviceTree ref="deviceTree" @clickEvent="treeChannelClickEvent" :showPosition="true" :contextmenu="getContextmenu()"/>
<MapComponent ref="mapComponent" @loaded="initChannelLayer"></MapComponent>
<MapComponent ref="mapComponent" @loaded="initChannelLayer" @coordinateSystemChange="initChannelLayer"></MapComponent>
</div>
<div class="map-tool-box">
<div class="map-tool-btn-group">
<div class="map-tool-btn" @click="initChannelLayer">
<i class="iconfont icon-tuceng"></i>
</div>
<el-dropdown placement="top" @command="changeMapTile">
<div class="el-dropdown-link map-tool-btn">
<i class="iconfont icon-tuceng"></i>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(item,index) in mapTileList" :key="index" :command="index">{{item.name}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div class="map-tool-btn-group">
<div class="map-tool-btn" @click="initChannelLayer">
@@ -89,10 +95,12 @@ export default {
},
isLoging: false,
longitudeStr: 'longitude',
latitudeStr: 'latitude'
latitudeStr: 'latitude',
mapTileList: []
}
},
created() {
},
destroyed() {
@@ -151,10 +159,12 @@ export default {
},
showChannelInfo: function(data) {
this.channel = data
this.infoBoxId = this.$refs.mapComponent.openInfoBox([data.gbLongitude, data.gbLatitude], this.$refs.infobox, [0, -50])
let position = [data.gbLongitude, data.gbLatitude]
this.infoBoxId = this.$refs.mapComponent.openInfoBox(position, this.$refs.infobox, [0, -50])
},
initChannelLayer: function () {
this.mapTileList = this.$refs.mapComponent.mapTileList
// 获取所有有位置的通道
this.closeInfoBox()
this.$store.dispatch('commonChanel/getAllForMap', {}).then(data => {
@@ -163,12 +173,9 @@ export default {
let item = data[i]
if (item.gbLongitude && item.gbLatitude) {
let position = [item.gbLongitude, item.gbLatitude]
let gcj02Position = gcoord.transform(position, gcoord.WGS84, gcoord.GCJ02)
item.gbLongitude = gcj02Position[0]
item.gbLatitude = gcj02Position[1]
array.push({
id: item.gbId,
position: gcj02Position,
position: position,
data: item,
image: {
anchor: [0.5, 1],
@@ -180,6 +187,9 @@ export default {
this.updateChannelLayer(array)
})
},
changeMapTile: function (index) {
this.$refs.mapComponent.changeMapTile(index)
},
updateChannelLayer: function(array) {
if (this.channelLayer) {
this.channelLayer = this.$refs.mapComponent.updateLayer(this.channelLayer, array, true)
@@ -300,11 +310,6 @@ export default {
},
submitEdit: function(channel) {
let position = [channel.gbLongitude, channel.gbLatitude]
if (this.$refs.mapComponent.getCurrentCoordinateSystem() === 'GCJ02') {
let wgs84Position = gcoord.transform(position, gcoord.GCJ02, gcoord.WGS84)
channel.gbLongitude = wgs84Position[0]
channel.gbLatitude = wgs84Position[1]
}
this.$store.dispatch('commonChanel/update', channel)
.then(data => {
this.$message.success({