[fix] lz适应

pull/1421/head
郭前胜 2024-04-18 16:55:49 +08:00
parent 48172dd024
commit 89adb29e97
6 changed files with 134 additions and 37 deletions

View File

@ -128,6 +128,11 @@
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.10</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>

View File

@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.RequestSendUtil;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -68,6 +69,9 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;
@Autowired
private RequestSendUtil requestSendUtil;
private final static String talkKey = "notify-request-for-catalog-task"; private final static String talkKey = "notify-request-for-catalog-task";
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
@ -122,6 +126,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.ON: case CatalogEvent.ON:
// 上线 // 上线
logger.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(1,device.getDeviceId(),channel.getChannelId());
updateChannelOnlineList.add(channel); updateChannelOnlineList.add(channel);
if (updateChannelOnlineList.size() > 300) { if (updateChannelOnlineList.size() > 300) {
executeSaveForOnline(); executeSaveForOnline();
@ -135,6 +140,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.OFF : case CatalogEvent.OFF :
// 离线 // 离线
logger.info("[收到通道离线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道离线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(2,device.getDeviceId(),channel.getChannelId());
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
}else { }else {
@ -151,6 +157,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.VLOST: case CatalogEvent.VLOST:
// 视频丢失 // 视频丢失
logger.info("[收到通道视频丢失通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道视频丢失通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(3,device.getDeviceId(),channel.getChannelId());
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
}else { }else {
@ -167,6 +174,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.DEFECT: case CatalogEvent.DEFECT:
// 故障 // 故障
logger.info("[收到通道视频故障通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道视频故障通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(4,device.getDeviceId(),channel.getChannelId());
if (userSetting.getRefuseChannelStatusChannelFormNotify()) { if (userSetting.getRefuseChannelStatusChannelFormNotify()) {
logger.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
}else { }else {
@ -183,6 +191,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.ADD: case CatalogEvent.ADD:
// 增加 // 增加
logger.info("[收到增加通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到增加通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(5,device.getDeviceId(),channel.getChannelId());
// 判断此通道是否存在 // 判断此通道是否存在
DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId()); DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId());
if (deviceChannel != null) { if (deviceChannel != null) {
@ -208,6 +217,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.DEL: case CatalogEvent.DEL:
// 删除 // 删除
logger.info("[收到删除通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到删除通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(6,device.getDeviceId(),channel.getChannelId());
deleteChannelList.add(channel); deleteChannelList.add(channel);
if (userSetting.getDeviceStatusNotify()) { if (userSetting.getDeviceStatusNotify()) {
// 发送redis消息 // 发送redis消息
@ -220,6 +230,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
case CatalogEvent.UPDATE: case CatalogEvent.UPDATE:
// 更新 // 更新
logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId());
requestSendUtil.send(7,device.getDeviceId(),channel.getChannelId());
// 判断此通道是否存在 // 判断此通道是否存在
DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId()); DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId());
if (deviceChannelForUpdate != null) { if (deviceChannelForUpdate != null) {

View File

@ -15,20 +15,22 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.bean.MediaServer;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IInviteStreamService; import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.RequestSendUtil;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree; import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
@ -39,7 +41,9 @@ import javax.sip.InvalidArgumentException;
import javax.sip.SipException; import javax.sip.SipException;
import java.text.ParseException; import java.text.ParseException;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -51,6 +55,9 @@ public class DeviceServiceImpl implements IDeviceService {
private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class); private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class);
@Value("${log}")
private String arm;
@Autowired @Autowired
private SIPCommander cmder; private SIPCommander cmder;
@ -102,9 +109,17 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired @Autowired
private AudioBroadcastManager audioBroadcastManager; private AudioBroadcastManager audioBroadcastManager;
@Autowired
private RequestSendUtil requestSendUtil;
@Override @Override
public void online(Device device, SipTransactionInfo sipTransactionInfo) { public void online(Device device, SipTransactionInfo sipTransactionInfo) {
logger.info("[设备上线] deviceId{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort()); logger.info("[设备上线] deviceId{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort());
logger.info(arm);
if ("1".equals(arm)){
requestSendUtil.send(21,device.getDeviceId(),null);
logger.info("已发送设备上线通知");
}
Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId()); Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId());
Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId());
@ -203,6 +218,12 @@ public class DeviceServiceImpl implements IDeviceService {
@Override @Override
public void offline(String deviceId, String reason) { public void offline(String deviceId, String reason) {
logger.warn("[设备离线]{}, device{}", reason, deviceId); logger.warn("[设备离线]{}, device{}", reason, deviceId);
logger.info(arm);
if ("1".equals(arm)){
requestSendUtil.send(22,deviceId,null);
logger.info("已发送设备离线通知");
}
Device device = deviceMapper.getDeviceByDeviceId(deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) { if (device == null) {
return; return;

View File

@ -0,0 +1,43 @@
package com.genersoft.iot.vmp.utils;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* @author gqs
*/
@Service
public class RequestSendUtil {
@Value("${web.ip}")
private String ip ;
@Value("${web.port}")
private String port = "8088";
public Boolean send(Integer type, String device, String channel) {
StringBuffer url = new StringBuffer();
url.append("http://");
url.append(ip);
url.append(":");
url.append(port);
url.append("/zzjp/log/info/");
url.append(type);
url.append("/");
url.append(device);
url.append("/");
url.append(channel);
HttpResponse execute = HttpUtil.createGet(url.toString()).execute();
String body = execute.body();
JSONObject entries = JSONUtil.parseObj(body);
Integer code = (Integer) entries.get("code");
if (code != 200) {
return false;
}
return true;
}
}

View File

@ -15,13 +15,13 @@ spring:
# REDIS数据库配置 # REDIS数据库配置
redis: redis:
# [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
host: 127.0.0.1 host: 10.18.38.123
# [必须修改] 端口号 # [必须修改] 端口号
port: 6379 port: 6379
# [可选] 数据库 DB # [可选] 数据库 DB
database: 7 database: 7
# [可选] 访问密码,若你的redis服务器没有设置密码就不需要用密码去连接 # [可选] 访问密码,若你的redis服务器没有设置密码就不需要用密码去连接
password: luna password: spz_2021
# [可选] 超时时间 # [可选] 超时时间
timeout: 10000 timeout: 10000
# mysql数据源 # mysql数据源
@ -32,9 +32,9 @@ spring:
master: master:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/wvp2?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true url: jdbc:mysql://10.18.38.123:3306/wvp2?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true
username: root username: dbadmin
password: root123 password: spz_2024
hikari: hikari:
connection-timeout: 20000 # 是客户端等待连接池连接的最大毫秒数 connection-timeout: 20000 # 是客户端等待连接池连接的最大毫秒数
initialSize: 50 # 连接池初始化连接数 initialSize: 50 # 连接池初始化连接数
@ -44,25 +44,21 @@ spring:
max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位)
#[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
server: server:
port: 8080 port: 8082
# [可选] HTTPS配置 默认不开启 # [可选] HTTPS配置 默认不开启
ssl: # ssl:
# [可选] 是否开启HTTPS访问 # # [可选] 是否开启HTTPS访问
enabled: false # enabled: false
# [可选] 证书文件路径放置在resource/目录下即可修改xxx为文件名 # # [可选] 证书文件路径放置在resource/目录下即可修改xxx为文件名
key-store: classpath:test.monitor.89iot.cn.jks # key-store: classpath:test.monitor.89iot.cn.jks
# [可选] 证书密码 # # [可选] 证书密码
key-store-password: gpf64qmw # key-store-password: gpf64qmw
# [可选] 证书类型, 默认为jks根据实际修改 # # [可选] 证书类型, 默认为jks根据实际修改
key-store-type: JKS # key-store-type: JKS
# 作为28181服务器的配置 # 国标服务配置
sip: sip:
# [必须修改] 本机的IP对应你的网卡监听什么ip就是使用什么网卡 ip: 10.18.38.123
# 如果要监听多张网卡可以使用逗号分隔多个IP 例如: 192.168.1.4,10.0.0.4
# 如果不明白就使用0.0.0.0,大部分情况都是可以的
# 请不要使用127.0.0.1任何包括localhost在内的域名都是不可以的。
ip: 172.19.128.50
# [可选] 28181服务监听的端口 # [可选] 28181服务监听的端口
port: 8116 port: 8116
# 根据国标6.1.2中规定domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码由省级、市级、区级、基层编号组成参照GB/T 2260-2007 # 根据国标6.1.2中规定domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码由省级、市级、区级、基层编号组成参照GB/T 2260-2007
@ -79,40 +75,61 @@ sip:
#zlm 默认服务器配置 #zlm 默认服务器配置
media: media:
id: zlmediakit-local id: zlmedia-dev
# [必须修改] zlm服务器的内网IP # [必须修改] zlm服务器的内网IP
ip: 172.19.128.50 ip: 10.18.38.123
# [必须修改] zlm服务器的http.port # [必须修改] zlm服务器的http.port
http-port: 9092 http-port: 8086
# [可选] 返回流地址时的ip置空使用 media.ip # [可选] 返回流地址时的ip置空使用 media.ip
stream-ip: 172.19.128.50 stream-ip:
# [可选] wvp在国标信令中使用的ip此ip为摄像机可以访问到的ip 置空使用 media.ip # [可选] wvp在国标信令中使用的ip此ip为摄像机可以访问到的ip 置空使用 media.ip
sdp-ip: 172.19.128.50 sdp-ip:
# [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip
hook-ip: 172.19.128.50 hook-ip:
# [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置
http-ssl-port: 1443 http-ssl-port:
# [可选] zlm服务器的hook.admin_params=secret # [可选] zlm服务器的hook.admin_params=secret
secret: 10000 secret: KBRaoeWrBK9FXXHe8h29DdpWJlU0TXBP
# 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分 点播超时建议使用多端口测试 # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分 点播超时建议使用多端口测试
rtp: rtp:
# [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
enable: true enable: true
# [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性不然自动配置此属性可能不成功 # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性不然自动配置此属性可能不成功
port-range: 50000,50300 # 端口范围 port-range: 60000,60300 # 端口范围
# [可选] 国标级联在此范围内选择端口发送媒体流, # [可选] 国标级联在此范围内选择端口发送媒体流,
send-port-range: 50000,50300 # 端口范围 send-port-range: 60301,65535 # 端口范围
# 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用
record-assist-port: 18081 record-assist-port: 18081
# [根据业务需求配置] # [根据业务需求配置]
user-settings: user-settings:
# 点播/录像回放 等待超时时间,单位:毫秒
play-timeout: 180000
# [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true
auto-apply-play: true auto-apply-play: true
# [可选] 部分设备需要扩展SDP需要打开此设置
senior-sdp: true
# 点播/录像回放 等待超时时间,单位:毫秒
play-timeout: 5000
# 等待音视频编码信息再返回, true 可以根据编码选择合适的播放器false 可以更快点播
wait-track: true
# 设备/通道状态变化时发送消息 # 设备/通道状态变化时发送消息
device-status-notify: true device-status-notify: true
# 自动配置redis 可以过期事件
redis-config: true
# 推流直播是否录制(生产环境关闭)
record-push-live: false
# (生国标是否录制产环境关闭)
record-sip: false
# 是否将日志存储进数据库
logInDatabase: true
# 使用推流状态作为推流通道状态
use-pushing-as-status: true
# 设备上线时是否自动同步通道
sync-channel-on-device-online: true
# 是否开启sip日志(生产环境关闭)
sip-log: false
# [可选] 日志配置, 一般不需要改 # [可选] 日志配置, 一般不需要改
logging: logging:
config: classpath:logback-spring.xml config: classpath:logback-spring.xml
log: 1
web:
ip: 10.18.38.123
port: 8088

View File

@ -1,5 +1,5 @@
spring: spring:
application: application:
name: wvp name: dev
profiles: profiles:
active: local active: local