From 8d6fe0c9d8daa1fef37e2000f6b24dbfa75f53d0 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Thu, 25 Sep 2025 18:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=B0=E5=9B=BE=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=B7=B2=E7=BB=8F=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=BB=9F=E4=B8=80=E5=9D=90=E6=A0=87=E4=B8=BAwgs84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/Device.java | 4 + .../vmp/gb28181/dao/DeviceChannelMapper.java | 95 +++-------- .../service/IDeviceChannelService.java | 39 ----- .../impl/DeviceChannelServiceImpl.java | 161 ------------------ .../NotifyRequestForCatalogProcessor.java | 12 ++ .../cmd/CatalogResponseMessageHandler.java | 6 + .../vmp/service/IMobilePositionService.java | 3 - .../vmp/service/impl/MapServiceImplForSy.java | 2 +- .../impl/MobilePositionServiceImpl.java | 16 +- web/src/views/common/MapComponent.vue | 25 ++- web/src/views/common/map/TransformLonLat.js | 12 +- web/src/views/map/index.vue | 35 ++-- 12 files changed, 102 insertions(+), 308 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index 5a5cc0c77..4c9618da1 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java @@ -212,4 +212,8 @@ public class Device { @Schema(description = "所属服务Id") private String serverId; + + public boolean isWgs84() { + return geoCoordSys.equalsIgnoreCase("WGS84"); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index b696e2347..2fc890736 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -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}) " + "") @@ -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 " + " " + "(#{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}) " + " " + @@ -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 { ""}) int batchUpdate(List updateChannels); - - @Update({""}) - int batchUpdateForNotify(List 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 = {" "}) @@ -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}" + ", longitude=#{item.longitude}" + ", latitude=#{item.latitude}" + + ", gb_longitude=#{item.gbLongitude}" + + ", gb_latitude=#{item.gbLatitude}" + ", gps_time=#{item.gpsTime}" + "WHERE id=#{item.id}" + "WHERE data_type = #{item.dataType} and data_device_id=#{item.dataDeviceId} AND device_id=#{item.deviceId}" + @@ -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 { " "}) void changeAudio(@Param("channelId") int channelId, @Param("audio") boolean audio); - @Update("") - void updateStreamGPS(List 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" + diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index a290f21de..69b6d350c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -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 queryAllChannelList(String platformId); - - PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - - /** - * 查询通道所属的设备 - */ - List getDeviceByChannelId(String channelId); - - /** - * 批量删除通道 - * @param deleteChannelList 待删除的通道列表 - */ - int deleteChannelsForNotify(List deleteChannelList); - - int updateChannelsStatus(List channels); - /** * 获取一个通道 */ @@ -58,16 +35,6 @@ public interface IDeviceChannelService { DeviceChannel getOneForSource(String deviceId, String channelId); - /** - * 直接批量更新通道 - */ - void batchUpdateChannelForNotify(List channels); - - /** - * 直接批量添加 - */ - void batchAddChannel(List deviceChannels); - /** * 修改通道的码流类型 */ @@ -81,10 +48,6 @@ public interface IDeviceChannelService { void stopPlay(Integer channelId); - void batchUpdateChannelGPS(List channelList); - - void batchAddMobilePosition(List addMobilePositionList); - void online(DeviceChannel channel); void offline(DeviceChannel channel); @@ -125,8 +88,6 @@ public interface IDeviceChannelService { DeviceChannel getOneBySourceId(int deviceDbId, String channelId); - List queryChaneListByDeviceDbId(Integer deviceDbId); - List queryChaneIdListByDeviceDbIds(List deviceDbId); void handlePtzCmd(@NotNull Integer dataDeviceId, @NotNull Integer gbId, Element rootElement, DeviceControlType type, ErrorCallback callback); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 64bb2915b..4304152ca 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -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 queryAllChannelList(String platformId) { - return channelMapper.queryChannelListInAll(null, null, null, platformId, null); - } - - @Override - public PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId) { - PageHelper.startPage(page, count); - List all = channelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId); - return new PageInfo<>(all); - } - - @Override - public List getDeviceByChannelId(String channelId) { - return channelMapper.getDeviceByChannelDeviceId(channelId); - } - - @Override - @Transactional - public int deleteChannelsForNotify(List 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 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 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 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 queryChaneListByDeviceDbId(Integer deviceDbId) { - return channelMapper.queryChannelsByDeviceDbId(deviceDbId); - } - @Override public List queryChaneIdListByDeviceDbIds(List deviceDbIds) { return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds); @@ -509,49 +391,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { channelMapper.stopPlayById(channelId); } - @Override - @Transactional - public void batchUpdateChannelGPS(List 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 channels = channelList.subList(i, toIndex); - channelMapper.batchUpdatePosition(channels); - } - }else { - channelMapper.batchUpdatePosition(channelList); - } - } - - @Override - @Transactional - public void batchAddMobilePosition(List 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 mobilePositionsSub = mobilePositions.subList(i, toIndex); -// deviceMobilePositionMapper.batchadd(mobilePositionsSub); -// } -// }else { -// deviceMobilePositionMapper.batchadd(mobilePositions); -// } - deviceMobilePositionMapper.batchadd(mobilePositions); - } - @Override public void cleanChannelsForDevice(int deviceId) { channelMapper.cleanChannelsByDeviceId(deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java index 8861282f8..d0eb43ade 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java @@ -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); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 8c645a437..4545c8390 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -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); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java index bbfe7a7e1..1643ad7e5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMobilePositionService.java @@ -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 gpsMsgInfoList); - } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MapServiceImplForSy.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MapServiceImplForSy.java index 1704d3279..68c8b6f66 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MapServiceImplForSy.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MapServiceImplForSy.java @@ -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); 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 1f20ffa1c..3ba2fa228 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 @@ -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 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 channels = new ArrayList<>(updateChannelMap.values()); diff --git a/web/src/views/common/MapComponent.vue b/web/src/views/common/MapComponent.vue index 5f8f2ed9b..1766d44c5 100755 --- a/web/src/views/common/MapComponent.vue +++ b/web/src/views/common/MapComponent.vue @@ -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)) + } } } } diff --git a/web/src/views/common/map/TransformLonLat.js b/web/src/views/common/map/TransformLonLat.js index 94161fc22..8d25ecaa6 100644 --- a/web/src/views/common/map/TransformLonLat.js +++ b/web/src/views/common/map/TransformLonLat.js @@ -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) + } } diff --git a/web/src/views/map/index.vue b/web/src/views/map/index.vue index cc82600f1..a8a8419de 100755 --- a/web/src/views/map/index.vue +++ b/web/src/views/map/index.vue @@ -2,13 +2,19 @@
- +
-
- -
+ + + + {{item.name}} + + +
@@ -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({