支持从第三方读取地图配置

This commit is contained in:
lin
2025-09-25 15:27:30 +08:00
parent bee911fa09
commit 6469aefe22
20 changed files with 417 additions and 24 deletions

View File

@@ -75,6 +75,16 @@ public class VideoManagerConstants {
*/
public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE";
/**
* 请求同步三方组织结构
*/
public static final String VM_MSG_GROUP_LIST_REQUEST = "VM_MSG_GROUP_LIST_REQUEST";
/**
* 同步三方组织结构回复
*/
public static final String VM_MSG_GROUP_LIST_RESPONSE = "VM_MSG_GROUP_LIST_RESPONSE";
/**
* redis 消息通知设备推流到平台
*/

View File

@@ -42,4 +42,5 @@ public class RedisTemplateConfig {
redisTemplate.setConnectionFactory(redisConnectionFactory);
return redisTemplate;
}
}

View File

@@ -83,7 +83,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
// TODO 处理各个状态
switch (jwtUser.getStatus()){
case EXPIRED:
response.setStatus(400);
response.setStatus(401);
chain.doFilter(request, response);
// 异常
return;

View File

@@ -122,7 +122,6 @@ public class DeviceChannel extends CommonGBChannel {
@Schema(description = "经度 WGS-84坐标系")
private Double longitude;
@MessageElementForCatalog("Latitude")
@Schema(description = ",纬度 WGS-84坐标系")
private Double latitude;

View File

@@ -0,0 +1,48 @@
package com.genersoft.iot.vmp.gb28181.bean;
import com.alibaba.fastjson2.JSON;
import lombok.Data;
@Data
public class RedisGroupMessage {
/**
* 分组国标ID
*/
private String groupGbId;
/**
* 分组别名
*/
private String groupAlias;
/**
* 分组名称
*/
private String groupName;
/**
* 分组所属的行政区划
*/
private String groupCivilCode;
/**
* 分组所属父分组国标ID
*/
private String parentGroupGbId;
/**
* 分组所属父分组别名
*/
private String parentGAlias;
public static void main(String[] args) {
RedisGroupMessage redisGroupMessage = new RedisGroupMessage();
redisGroupMessage.setGroupAlias("100000001");
redisGroupMessage.setGroupName("消防大队");
System.out.println(JSON.toJSONString(redisGroupMessage));
}
}

View File

@@ -24,6 +24,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.Coordtransform;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
@@ -434,6 +435,17 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) {
if (device.getGeoCoordSys().equalsIgnoreCase("GCJ02")) {
Double[] wgs84Position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitude(wgs84Position[0]);
mobilePosition.setLatitude(wgs84Position[1]);
Double[] wgs84PositionForChannel = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setGbLongitude(wgs84PositionForChannel[0]);
deviceChannel.setGbLatitude(wgs84PositionForChannel[1]);
}
if (userSetting.getSavePositionHistory()) {
deviceMobilePositionMapper.insertNewPosition(mobilePosition);
}

View File

@@ -0,0 +1,9 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.vmanager.bean.MapConfig;
import java.util.List;
public interface IMapService {
List<MapConfig> getConfig();
}

View File

@@ -0,0 +1,76 @@
package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.service.IMapService;
import com.genersoft.iot.vmp.vmanager.bean.MapConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 第三方地图适配
*/
@Service
public class MapServiceImplForSy implements IMapService {
@Autowired
private RedisTemplate<Object, Object> redisTemplate;
@Override
public List<MapConfig> getConfig() {
List<MapConfig> configList = new ArrayList<>();
JSONObject configObject = (JSONObject)redisTemplate.opsForValue().get("interfaceConfig1");
if (configObject == null) {
return configList;
}
// 浅色地图
MapConfig mapConfigForDefault = readConfig("FRAGMENTIMG_SERVER", configObject);
if (mapConfigForDefault != null) {
mapConfigForDefault.setName("浅色地图");
configList.add(mapConfigForDefault);
}
// 深色地图
MapConfig mapConfigForDark = readConfig("POLARNIGHTBLUE_FRAGMENTIMG_SERVER", configObject);
if (mapConfigForDark != null) {
mapConfigForDark.setName("深色地图");
configList.add(mapConfigForDark);
}
// 卫星地图
MapConfig mapConfigForSatellited = readConfig("FRAGMENTIMG_SERVER", configObject);
if (mapConfigForSatellited != null) {
mapConfigForSatellited.setName("卫星地图");
configList.add(mapConfigForSatellited);
}
return configList;
}
private MapConfig readConfig(String key, JSONObject jsonObject) {
JSONArray fragmentimgServerArray = jsonObject.getJSONArray(key);
if (fragmentimgServerArray == null || fragmentimgServerArray.isEmpty()) {
return null;
}
JSONObject fragmentimgServer = fragmentimgServerArray.getJSONObject(0);
// 坐标系
String geoCoordSys = fragmentimgServer.getString("csysType").toUpperCase();
// 获取地址
String path = fragmentimgServer.getString("path");
String ip = fragmentimgServer.getString("ip");
JSONObject portJson = fragmentimgServer.getJSONObject("port");
JSONObject httpPortJson = portJson.getJSONObject("httpPort");
String protocol = httpPortJson.getString("portType");
Integer port = httpPortJson.getInteger("port");
String tileUrl = String.format("%s://%s:%s%s", protocol, ip, port, path);
MapConfig mapConfig = new MapConfig();
mapConfig.setCoordinateSystem(geoCoordSys);
mapConfig.setTilesUrl(tileUrl);
return mapConfig;
}
}

View File

@@ -10,6 +10,10 @@ public class RedisPushStreamMessage {
private String stream;
private String name;
private boolean status;
// 终端所属的虚拟组织
private String groupGbId;
// 终端所属的虚拟组织别名 可选可作为地方同步组织结构到wvp时的关联关系
private String groupAlias;
public StreamPush buildstreamPush() {
StreamPush push = new StreamPush();

View File

@@ -0,0 +1,16 @@
package com.genersoft.iot.vmp.vmanager.bean;
import lombok.Data;
@Data
public class MapConfig {
private String name;
private String coordinateSystem;
private String tilesUrl;
private Integer tileSize;
private Integer zoom;
private Double[] center;
private Integer maxZoom;
private Integer minZoom;
}

View File

@@ -16,18 +16,17 @@ import com.genersoft.iot.vmp.media.bean.MediaInfo;
import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerChangeEvent;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMapService;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
import com.genersoft.iot.vmp.streamPush.service.IStreamPushService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo;
import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo;
import com.genersoft.iot.vmp.vmanager.bean.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,7 +41,6 @@ import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF;
import oshi.software.os.OperatingSystem;
import jakarta.servlet.http.HttpServletRequest;
import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -85,6 +83,10 @@ public class ServerController {
@Autowired
private IStreamProxyService proxyService;
@Autowired
private IMapService mapService;
@Value("${server.port}")
private int serverPort;
@@ -362,4 +364,11 @@ public class ServerController {
double tbNumber = gbNumber / FORMAT;
return new DecimalFormat("#.##TB").format(tbNumber);
}
@GetMapping(value = "/map/config")
@ResponseBody
@Operation(summary = "获取地图配置", security = @SecurityRequirement(name = JwtUtils.HEADER))
public List<MapConfig> getMapConfig() {
return mapService.getConfig();
}
}