From 845ce5331322b18f1514c476c86a0e352f79dde9 Mon Sep 17 00:00:00 2001 From: lovemen <50255147@qq.com> Date: Thu, 23 Feb 2023 15:35:42 +0800 Subject: [PATCH 01/68] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8A=E7=BA=A7?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=82=B9=E6=92=ADproxy=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=B5=81=E6=97=B6=E6=9C=AA=E6=90=BA=E5=B8=A6SSRC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF,gbStream=E9=87=87=E7=94=A8=E9=BB=98=E8=AE=A4000000000?= =?UTF-8?q?0=E4=BD=9C=E4=B8=BASSRC=E6=97=A0=E6=B3=95=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=E4=BB=A5=E5=8F=8A=E4=B8=8A=E7=BA=A7?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=82=B9=E6=92=ADproxy=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=B5=81=E6=97=B6=E5=9B=9E=E5=A4=8D=E7=9A=84SDP=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E7=AB=AF=E5=8F=A3=E5=8F=B7=E4=B8=BA0=E4=B8=8D?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 81dd8d810..fd9e0c606 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; +import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; @@ -492,6 +493,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } } else if (gbStream != null) { + if(ssrc.equals(ssrcDefault)) + { + SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); + if(ssrcConfig != null) + { + ssrc = ssrcConfig.getPlaySsrc(); + ssrcConfig.releaseSsrc(ssrc); + } + } if("push".equals(gbStream.getStreamType())) { if (streamPushItem != null && streamPushItem.isPushIng()) { // 推流状态 @@ -818,7 +828,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements content.append("s=Play\r\n"); content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); content.append("t=0 0\r\n"); - content.append("m=video " + sendRtpItem.getLocalPort() + " RTP/AVP 96\r\n"); + // 非严格模式端口不统一, 增加兼容性,修改为一个不为0的端口 + int localPort = sendRtpItem.getLocalPort(); + if(localPort == 0) + { + localPort = new Random().nextInt(65535) + 1; + } + content.append("m=video " + localPort + " RTP/AVP 96\r\n"); content.append("a=sendonly\r\n"); content.append("a=rtpmap:96 PS/90000\r\n"); if (sendRtpItem.isTcp()) { From 6afcd5176b89e213fed5d5904279c4095bfada9a Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Fri, 3 Mar 2023 20:59:10 +0800 Subject: [PATCH 02/68] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E4=B8=8B=E8=BD=BD=E5=A2=9E=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86ssrc=E4=B8=8E?= =?UTF-8?q?=E4=B8=8B=E7=BA=A7=E4=B8=8D=E4=B8=80=E8=87=B4=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/cmd/ISIPCommander.java | 106 +++++++++--------- .../transmit/cmd/impl/SIPCommander.java | 71 ++++++------ .../iot/vmp/service/impl/PlayServiceImpl.java | 67 ++++++++++- 3 files changed, 152 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 1f1d10a65..6aa20e4da 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -15,26 +15,26 @@ import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; -/** - * @description:设备能力接口,用于定义设备的控制、查询能力 +/** + * @description:设备能力接口,用于定义设备的控制、查询能力 * @author: swwheihei - * @date: 2020年5月3日 下午9:16:34 + * @date: 2020年5月3日 下午9:16:34 */ public interface ISIPCommander { /** * 云台方向放控制,使用配置文件中的默认镜头移动速度 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 */ void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台方向放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 @@ -42,28 +42,28 @@ public interface ISIPCommander { * @param moveSpeed 镜头移动速度 */ void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台缩放控制,使用配置文件中的默认镜头缩放速度 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 */ void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台缩放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 */ void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台控制,支持方向与缩放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 @@ -73,10 +73,10 @@ public interface ISIPCommander { * @param zoomSpeed 镜头缩放速度 */ void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException; - + /** * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param cmdCode 指令码 @@ -85,7 +85,7 @@ public interface ISIPCommander { * @param combineCode2 组合码2 */ void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException; - + /** * 前端控制指令(用于转发上级指令) * @param device 控制设备 @@ -103,7 +103,7 @@ public interface ISIPCommander { /** * 请求回放视频流 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss @@ -113,16 +113,16 @@ public interface ISIPCommander { /** * 请求历史媒体下载 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss * @param downloadSpeed 下载倍速参数 - */ + */ void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, - SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; + SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; /** * 视频流停止 @@ -150,7 +150,7 @@ public interface ISIPCommander { * 回放倍速播放 */ void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException; - + /** * 回放控制 * @param device @@ -162,55 +162,55 @@ public interface ISIPCommander { /** * 语音广播 - * + * * @param device 视频设备 * @param channelId 预览通道 */ void audioBroadcastCmd(Device device,String channelId); - + /** * 语音广播 - * + * * @param device 视频设备 */ void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException; - + /** * 音视频录像控制 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param recordCmdStr 录像命令:Record / StopRecord */ void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 远程启动控制命令 - * + * * @param device 视频设备 */ void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException; /** * 报警布防/撤防命令 - * + * * @param device 视频设备 */ void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 报警复位命令 - * + * * @param device 视频设备 * @param alarmMethod 报警方式(可选) * @param alarmType 报警类型(可选) */ void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧 - * + * * @param device 视频设备 * @param channelId 预览通道 */ @@ -230,58 +230,58 @@ public interface ISIPCommander { /** * 设备配置命令 - * + * * @param device 视频设备 */ void deviceConfigCmd(Device device); - + /** * 设备配置命令:basicParam - * + * * @param device 视频设备 * @param channelId 通道编码(可选) * @param name 设备/通道名称(可选) * @param expiration 注册过期时间(可选) * @param heartBeatInterval 心跳间隔时间(可选) * @param heartBeatCount 心跳超时次数(可选) - */ + */ void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; /** * 查询设备状态 - * + * * @param device 视频设备 */ void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备信息 - * + * * @param device 视频设备 - * @return + * @return */ void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询目录列表 - * + * * @param device 视频设备 */ void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException; - + /** * 查询录像信息 - * + * * @param device 视频设备 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss * @param sn */ void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询报警信息 - * + * * @param device 视频设备 * @param startPriority 报警起始级别(可选) * @param endPriority 报警终止级别(可选) @@ -293,33 +293,33 @@ public interface ISIPCommander { */ void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod, String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备配置 - * + * * @param device 视频设备 * @param channelId 通道编码(可选) * @param configType 配置类型: */ void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备预置位置 - * + * * @param device 视频设备 */ void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询移动设备位置数据 - * + * * @param device 视频设备 */ void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; /** * 订阅、取消订阅移动位置 - * + * * @param device 视频设备 * @return true = 命令发送成功 */ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index fbd9ececd..0d1bf2a8c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import javax.sip.InvalidArgumentException; import javax.sip.ResponseEvent; @@ -57,7 +56,7 @@ public class SIPCommander implements ISIPCommander { @Autowired private SIPSender sipSender; - + @Autowired private SIPRequestHeaderProvider headerProvider; @@ -181,7 +180,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); @@ -244,8 +243,8 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); - - + + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent); @@ -365,7 +364,8 @@ public class SIPCommander implements ISIPCommander { */ @Override public void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, + String startTime, String endTime, + InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { @@ -411,7 +411,8 @@ public class SIPCommander implements ISIPCommander { content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } - } else { + } else + { if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { @@ -471,8 +472,9 @@ public class SIPCommander implements ISIPCommander { */ @Override public void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, int downloadSpeed, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, - SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { + String startTime, String endTime, int downloadSpeed, + InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, + SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getIp(), ssrcInfo.getPort()); String sdpIp; @@ -541,10 +543,11 @@ public class SIPCommander implements ISIPCommander { content.append("a=downloadspeed:" + downloadSpeed + "\r\n"); content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId()); // 添加订阅 - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { + subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> + { hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); subscribe.removeSubscribe(hookSubscribe); hookSubscribe.getContent().put("regist", false); @@ -567,10 +570,11 @@ public class SIPCommander implements ISIPCommander { inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); } - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent -> { - ResponseEvent responseEvent = (ResponseEvent) okEvent.event; + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { + ResponseEvent responseEvent = (ResponseEvent) event.event; SIPResponse response = (SIPResponse) responseEvent.getResponse(); streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); + okEvent.response(event); }); } @@ -628,7 +632,7 @@ public class SIPCommander implements ISIPCommander { broadcastXml.append("" + device.getDeviceId() + "\r\n"); broadcastXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -648,7 +652,7 @@ public class SIPCommander implements ISIPCommander { broadcastXml.append("" + device.getDeviceId() + "\r\n"); broadcastXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -679,7 +683,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("" + recordCmdStr + "\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -703,7 +707,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("Boot\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -762,7 +766,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -791,7 +795,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("Send\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -802,7 +806,6 @@ public class SIPCommander implements ISIPCommander { * * @param device 视频设备 * @param channelId 通道id,非通道则是设备本身 - * @param frontCmd 上级平台的指令,如果存在则直接下发 * @param enabled 看守位使能:1 = 开启,0 = 关闭 * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s) * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255 @@ -840,7 +843,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -903,7 +906,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -926,7 +929,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -950,7 +953,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -975,7 +978,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append(" " + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1020,7 +1023,7 @@ public class SIPCommander implements ISIPCommander { } recordInfoXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1071,7 +1074,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1101,7 +1104,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("" + configType + "\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1128,7 +1131,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1152,7 +1155,7 @@ public class SIPCommander implements ISIPCommander { mobilePostitionXml.append("60\r\n"); mobilePostitionXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1237,7 +1240,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -1287,14 +1290,14 @@ public class SIPCommander implements ISIPCommander { } dragXml.append(cmdString); dragXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); logger.debug("拉框信令: " + request.toString()); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); } - + /** @@ -1398,7 +1401,7 @@ public class SIPCommander implements ISIPCommander { deviceStatusXml.append("\r\n"); deviceStatusXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index b8e7c8e56..96027d4c5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -258,7 +258,8 @@ public class PlayServiceImpl implements IPlayService { return; } try { - cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { + cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> + { logger.info("收到订阅消息: " + response.toJSONString()); dynamicTask.stop(timeOutTaskKey); @@ -273,7 +274,8 @@ public class PlayServiceImpl implements IPlayService { logger.info("[请求截图]: " + fileName); zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); - }, (event) -> { + }, (event) -> + { ResponseEvent responseEvent = (ResponseEvent) event.event; String contentString = new String(responseEvent.getResponse().getRawContent()); // 获取ssrc @@ -322,7 +324,8 @@ public class PlayServiceImpl implements IPlayService { } } - }, (event) -> { + }, (event) -> + { dynamicTask.stop(timeOutTaskKey); mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); // 释放ssrc @@ -513,7 +516,8 @@ public class PlayServiceImpl implements IPlayService { try { cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, - hookEvent, eventResult -> { + hookEvent, eventResult -> + { if (eventResult.type == SipSubscribe.EventResultType.response) { ResponseEvent responseEvent = (ResponseEvent) eventResult.event; String contentString = new String(responseEvent.getResponse().getRawContent()); @@ -582,6 +586,7 @@ public class PlayServiceImpl implements IPlayService { if (device == null) { return; } + //获取录像下载的服务,配置文件中的record-assist-port不为0 MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device); if (newMediaServerItem == null) { PlayBackResult downloadResult = new PlayBackResult<>(); @@ -651,7 +656,59 @@ public class PlayServiceImpl implements IPlayService { downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); downloadResult.setResponse(inviteStreamInfo.getResponse()); hookCallBack.call(downloadResult); - }, errorEvent); + }, errorEvent, eventResult -> + { + if (eventResult.type == SipSubscribe.EventResultType.response) { + ResponseEvent responseEvent = (ResponseEvent) eventResult.event; + String contentString = new String(responseEvent.getResponse().getRawContent()); + // 获取ssrc + int ssrcIndex = contentString.indexOf("y="); + // 检查是否有y字段 + if (ssrcIndex >= 0) { + //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 TODO 后续对不规范的非10位ssrc兼容 + String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); + // 查询到ssrc不一致且开启了ssrc校验则需要针对处理 + if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { + return; + } + logger.info("[回放消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); + if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) { + logger.info("[回放消息] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); + + if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) { + // ssrc 不可用 + // 释放ssrc + mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); + streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); + eventResult.msg = "下级自定义了ssrc,但是此ssrc不可用"; + eventResult.statusCode = 400; + errorEvent.response(eventResult); + return; + } + + // 单端口模式streamId也有变化,需要重新设置监听 + if (!mediaServerItem.isRtpEnable()) { + // 添加订阅 + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); + subscribe.removeSubscribe(hookSubscribe); + hookSubscribe.getContent().put("stream", String.format("%08x", Integer.parseInt(ssrcInResponse)).toUpperCase()); + subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> { + logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); + dynamicTask.stop(downLoadTimeOutTaskKey); + // hook响应,TODO 此处待处理 +// onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, playBackCallback); +// hookCallBack.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream())); + }); + } + // 关闭rtp server + mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); + // 重新开启ssrc server + mediaServerService.openRTPServer(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse, device.isSsrcCheck(), true, ssrcInfo.getPort()); + } + } + } + + }); } catch (InvalidArgumentException | SipException | ParseException e) { logger.error("[命令发送失败] 录像下载: {}", e.getMessage()); From 9c349789633a27ec0cecc2499933012492807642 Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Fri, 3 Mar 2023 20:59:56 +0800 Subject: [PATCH 03/68] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=80=9A=E9=81=93=E7=9B=AE=E5=BD=95=E6=97=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 83f933433..9e2b1b7d0 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -316,10 +316,10 @@ public interface DeviceChannelMapper { "select * " + "from device_channel " + "where deviceId=#{deviceId}" + - " and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} and length(channelId)=#{length} " + + " and parentId = #{parentId} or left(channelId, LENGTH(#{parentId})) = #{parentId} and length(channelId)=#{length} " + " and parentId = #{parentId} or length(channelId)=#{length} " + " and parentId = #{parentId} " + - " and parentId = #{parentId} or left(channelId, #{parentId.length()}) = #{parentId} " + + " and parentId = #{parentId} or left(channelId, LENGTH(#{parentId})) = #{parentId} " + " "}) List getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length); From a0cdc7c59d37aedc2538bfb6db8559286e4969b5 Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Fri, 3 Mar 2023 21:01:43 +0800 Subject: [PATCH 04/68] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E5=BD=95=E5=83=8F=E6=97=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/cmd/RecordInfoResponseMessageHandler.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 6d8d8f56e..9d28ec527 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -94,7 +94,8 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent recordInfo.setCount(sumNum); eventPublisher.recordEndEventPush(recordInfo); releaseRequest(device.getDeviceId(), sn,recordInfo); - } else { + } else + { Iterator recordListIterator = recordListElement.elementIterator(); if (recordListIterator != null) { List recordList = new ArrayList<>(); @@ -162,9 +163,12 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent public void releaseRequest(String deviceId, String sn,RecordInfo recordInfo){ String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; + if(null!=recordInfo.getRecordList()){ + Collections.sort(recordInfo.getRecordList()); + }else{ + recordInfo.setRecordList(new ArrayList<>()); + } // 对数据进行排序 - Collections.sort(recordInfo.getRecordList()); - RequestMessage msg = new RequestMessage(); msg.setKey(key); msg.setData(recordInfo); From c662a530989706b705142743e0095d5b7f331751 Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Sat, 4 Mar 2023 20:47:48 +0800 Subject: [PATCH 05/68] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E4=B8=8B=E8=BD=BD=E5=A2=9E=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86ssrc=E4=B8=8E?= =?UTF-8?q?=E4=B8=8B=E7=BA=A7=E4=B8=8D=E4=B8=80=E8=87=B4=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/transmit/cmd/ISIPCommander.java | 105 +++++++++--------- .../transmit/cmd/impl/SIPCommander.java | 59 +++++----- .../iot/vmp/service/impl/PlayServiceImpl.java | 13 +-- 3 files changed, 84 insertions(+), 93 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 6aa20e4da..fdd2288f9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -15,26 +15,26 @@ import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; -/** - * @description:设备能力接口,用于定义设备的控制、查询能力 +/** + * @description:设备能力接口,用于定义设备的控制、查询能力 * @author: swwheihei - * @date: 2020年5月3日 下午9:16:34 + * @date: 2020年5月3日 下午9:16:34 */ public interface ISIPCommander { /** * 云台方向放控制,使用配置文件中的默认镜头移动速度 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 */ void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台方向放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 @@ -42,28 +42,28 @@ public interface ISIPCommander { * @param moveSpeed 镜头移动速度 */ void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台缩放控制,使用配置文件中的默认镜头缩放速度 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 */ void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台缩放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 */ void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - + /** * 云台控制,支持方向与缩放控制 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 @@ -73,10 +73,10 @@ public interface ISIPCommander { * @param zoomSpeed 镜头缩放速度 */ void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException; - + /** * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 - * + * * @param device 控制设备 * @param channelId 预览通道 * @param cmdCode 指令码 @@ -85,7 +85,7 @@ public interface ISIPCommander { * @param combineCode2 组合码2 */ void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException; - + /** * 前端控制指令(用于转发上级指令) * @param device 控制设备 @@ -103,7 +103,7 @@ public interface ISIPCommander { /** * 请求回放视频流 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss @@ -113,13 +113,13 @@ public interface ISIPCommander { /** * 请求历史媒体下载 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss * @param downloadSpeed 下载倍速参数 - */ + */ void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; @@ -150,7 +150,7 @@ public interface ISIPCommander { * 回放倍速播放 */ void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException; - + /** * 回放控制 * @param device @@ -162,55 +162,55 @@ public interface ISIPCommander { /** * 语音广播 - * + * * @param device 视频设备 * @param channelId 预览通道 */ void audioBroadcastCmd(Device device,String channelId); - + /** * 语音广播 - * + * * @param device 视频设备 */ void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException; - + /** * 音视频录像控制 - * + * * @param device 视频设备 * @param channelId 预览通道 * @param recordCmdStr 录像命令:Record / StopRecord */ void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 远程启动控制命令 - * + * * @param device 视频设备 */ void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException; /** * 报警布防/撤防命令 - * + * * @param device 视频设备 */ void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 报警复位命令 - * + * * @param device 视频设备 * @param alarmMethod 报警方式(可选) * @param alarmType 报警类型(可选) */ void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧 - * + * * @param device 视频设备 * @param channelId 预览通道 */ @@ -221,7 +221,6 @@ public interface ISIPCommander { * * @param device 视频设备 * @param channelId 通道id,非通道则是设备本身 - * @param frontCmd 上级平台的指令,如果存在则直接下发 * @param enabled 看守位使能:1 = 开启,0 = 关闭 * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s) * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255 @@ -230,58 +229,58 @@ public interface ISIPCommander { /** * 设备配置命令 - * + * * @param device 视频设备 */ void deviceConfigCmd(Device device); - + /** * 设备配置命令:basicParam - * + * * @param device 视频设备 * @param channelId 通道编码(可选) * @param name 设备/通道名称(可选) * @param expiration 注册过期时间(可选) * @param heartBeatInterval 心跳间隔时间(可选) * @param heartBeatCount 心跳超时次数(可选) - */ + */ void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; /** * 查询设备状态 - * + * * @param device 视频设备 */ void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备信息 - * + * * @param device 视频设备 - * @return + * @return */ void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询目录列表 - * + * * @param device 视频设备 */ void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException; - + /** * 查询录像信息 - * + * * @param device 视频设备 * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss * @param sn */ void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询报警信息 - * + * * @param device 视频设备 * @param startPriority 报警起始级别(可选) * @param endPriority 报警终止级别(可选) @@ -293,33 +292,33 @@ public interface ISIPCommander { */ void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod, String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备配置 - * + * * @param device 视频设备 * @param channelId 通道编码(可选) * @param configType 配置类型: */ void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询设备预置位置 - * + * * @param device 视频设备 */ void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - + /** * 查询移动设备位置数据 - * + * * @param device 视频设备 */ void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; /** * 订阅、取消订阅移动位置 - * + * * @param device 视频设备 * @return true = 命令发送成功 */ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 0d1bf2a8c..5fd88282b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -56,7 +56,7 @@ public class SIPCommander implements ISIPCommander { @Autowired private SIPSender sipSender; - + @Autowired private SIPRequestHeaderProvider headerProvider; @@ -180,7 +180,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); @@ -243,8 +243,8 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); - - + + Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent); @@ -364,8 +364,7 @@ public class SIPCommander implements ISIPCommander { */ @Override public void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, - InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, + String startTime, String endTime, InviteStreamCallback inviteStreamCallback, InviteStreamCallback hookEvent, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { @@ -411,8 +410,7 @@ public class SIPCommander implements ISIPCommander { content.append("a=setup:active\r\n"); content.append("a=connection:new\r\n"); } - } else - { + } else { if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { @@ -543,11 +541,10 @@ public class SIPCommander implements ISIPCommander { content.append("a=downloadspeed:" + downloadSpeed + "\r\n"); content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - + HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId()); // 添加订阅 - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> - { + subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); subscribe.removeSubscribe(hookSubscribe); hookSubscribe.getContent().put("regist", false); @@ -632,7 +629,7 @@ public class SIPCommander implements ISIPCommander { broadcastXml.append("" + device.getDeviceId() + "\r\n"); broadcastXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -652,7 +649,7 @@ public class SIPCommander implements ISIPCommander { broadcastXml.append("" + device.getDeviceId() + "\r\n"); broadcastXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -683,7 +680,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("" + recordCmdStr + "\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -707,7 +704,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("Boot\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -766,7 +763,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -795,7 +792,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("Send\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -843,7 +840,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); @@ -906,7 +903,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -929,7 +926,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -953,7 +950,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -978,7 +975,7 @@ public class SIPCommander implements ISIPCommander { catalogXml.append(" " + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1023,7 +1020,7 @@ public class SIPCommander implements ISIPCommander { } recordInfoXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1074,7 +1071,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1104,7 +1101,7 @@ public class SIPCommander implements ISIPCommander { cmdXml.append("" + configType + "\r\n"); cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1131,7 +1128,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); @@ -1155,7 +1152,7 @@ public class SIPCommander implements ISIPCommander { mobilePostitionXml.append("60\r\n"); mobilePostitionXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); @@ -1240,7 +1237,7 @@ public class SIPCommander implements ISIPCommander { } cmdXml.append("\r\n"); - + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); @@ -1290,14 +1287,14 @@ public class SIPCommander implements ISIPCommander { } dragXml.append(cmdString); dragXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); logger.debug("拉框信令: " + request.toString()); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); } - + /** @@ -1401,7 +1398,7 @@ public class SIPCommander implements ISIPCommander { deviceStatusXml.append("\r\n"); deviceStatusXml.append("\r\n"); - + Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 96027d4c5..c03ab62e9 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -258,8 +258,7 @@ public class PlayServiceImpl implements IPlayService { return; } try { - cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> - { + cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { logger.info("收到订阅消息: " + response.toJSONString()); dynamicTask.stop(timeOutTaskKey); @@ -274,8 +273,7 @@ public class PlayServiceImpl implements IPlayService { logger.info("[请求截图]: " + fileName); zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); - }, (event) -> - { + }, (event) -> { ResponseEvent responseEvent = (ResponseEvent) event.event; String contentString = new String(responseEvent.getResponse().getRawContent()); // 获取ssrc @@ -324,8 +322,7 @@ public class PlayServiceImpl implements IPlayService { } } - }, (event) -> - { + }, (event) -> { dynamicTask.stop(timeOutTaskKey); mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); // 释放ssrc @@ -516,8 +513,7 @@ public class PlayServiceImpl implements IPlayService { try { cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, - hookEvent, eventResult -> - { + hookEvent, eventResult -> { if (eventResult.type == SipSubscribe.EventResultType.response) { ResponseEvent responseEvent = (ResponseEvent) eventResult.event; String contentString = new String(responseEvent.getResponse().getRawContent()); @@ -586,7 +582,6 @@ public class PlayServiceImpl implements IPlayService { if (device == null) { return; } - //获取录像下载的服务,配置文件中的record-assist-port不为0 MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device); if (newMediaServerItem == null) { PlayBackResult downloadResult = new PlayBackResult<>(); From 2177e9dbf988188297b416dc78b0a4a587b0fdd7 Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Sat, 4 Mar 2023 20:55:48 +0800 Subject: [PATCH 06/68] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E5=BD=95=E5=83=8F=E6=97=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/response/cmd/RecordInfoResponseMessageHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 9d28ec527..817455fc8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -94,8 +94,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent recordInfo.setCount(sumNum); eventPublisher.recordEndEventPush(recordInfo); releaseRequest(device.getDeviceId(), sn,recordInfo); - } else - { + } else { Iterator recordListIterator = recordListElement.elementIterator(); if (recordListIterator != null) { List recordList = new ArrayList<>(); From a7c3cf531640bb59aa90cb476b8c21db97f41ddb Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 5 Mar 2023 09:53:26 +0800 Subject: [PATCH 07/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=A8=E5=9F=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=94=AF=E6=8C=81=E5=90=8C=E5=9F=9F?= =?UTF-8?q?=E7=9A=84=E5=89=8D=E5=90=8E=E7=AB=AF=E5=88=86=E7=A6=BB=E9=83=A8?= =?UTF-8?q?=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_content/ability/gis.md | 2 +- .../genersoft/iot/vmp/conf/ApiAccessFilter.java | 11 ++++++++--- .../AnonymousAuthenticationEntryPoint.java | 6 ++++-- .../iot/vmp/media/zlm/ZLMHttpHookListener.java | 2 ++ .../MobilePosition/MobilePositionController.java | 2 +- .../gb28181/SseController/SseController.java | 2 +- .../vmanager/gb28181/alarm/AlarmController.java | 8 +------- .../vmanager/gb28181/device/DeviceConfig.java | 5 +---- .../vmanager/gb28181/device/DeviceControl.java | 2 +- .../vmp/vmanager/gb28181/device/DeviceQuery.java | 2 +- .../gb28181/gbStream/GbStreamController.java | 2 +- .../vmanager/gb28181/media/MediaController.java | 2 +- .../gb28181/platform/PlatformController.java | 2 +- .../vmanager/gb28181/play/PlayController.java | 2 +- .../gb28181/playback/PlaybackController.java | 2 +- .../vmp/vmanager/gb28181/ptz/PtzController.java | 16 +++++++--------- .../gb28181/record/GBRecordController.java | 2 +- .../iot/vmp/vmanager/log/LogController.java | 9 +-------- .../vmp/vmanager/record/RecordController.java | 2 +- .../vmp/vmanager/server/ServerController.java | 12 +++--------- .../streamProxy/StreamProxyController.java | 2 +- .../streamPush/StreamPushController.java | 2 +- .../iot/vmp/vmanager/user/RoleController.java | 6 +----- .../iot/vmp/vmanager/user/UserController.java | 2 +- .../vmp/web/gb28181/ApiControlController.java | 2 +- .../iot/vmp/web/gb28181/ApiController.java | 3 +-- .../iot/vmp/web/gb28181/ApiDeviceController.java | 2 +- .../iot/vmp/web/gb28181/ApiStreamController.java | 2 +- .../iot/vmp/web/gb28181/AuthController.java | 2 +- web_src/build/utils.js | 3 +-- web_src/config/index.js | 10 +++++----- web_src/index.html | 2 +- web_src/src/components/CloudRecord.vue | 4 ++-- web_src/src/components/CloudRecordDetail.vue | 10 +++++----- web_src/src/components/DeviceList.vue | 10 +++++----- web_src/src/components/GBRecordDetail.vue | 16 ++++++++-------- web_src/src/components/Login.vue | 2 +- web_src/src/components/ParentPlatformList.vue | 4 ++-- web_src/src/components/PushVideoList.vue | 10 +++++----- web_src/src/components/StreamProxyList.vue | 12 ++++++------ web_src/src/components/UserManager.vue | 4 ++-- web_src/src/components/channelList.vue | 12 ++++++------ web_src/src/components/console.vue | 8 ++++---- .../src/components/dialog/MediaServerEdit.vue | 2 +- .../src/components/dialog/StreamProxyEdit.vue | 8 ++++---- .../components/dialog/SyncChannelProgress.vue | 2 +- web_src/src/components/dialog/addUser.vue | 4 ++-- web_src/src/components/dialog/catalogEdit.vue | 2 +- web_src/src/components/dialog/changePassword.vue | 2 +- .../components/dialog/changePasswordForAdmin.vue | 2 +- web_src/src/components/dialog/changePushKey.vue | 2 +- .../src/components/dialog/channelMapInfobox.vue | 2 +- web_src/src/components/dialog/chooseChannel.vue | 2 +- .../dialog/chooseChannelForCatalog.vue | 8 ++++---- .../src/components/dialog/chooseChannelForGb.vue | 10 +++++----- .../components/dialog/chooseChannelForStream.vue | 10 +++++----- web_src/src/components/dialog/deviceEdit.vue | 2 +- web_src/src/components/dialog/devicePlayer.vue | 14 +++++++------- web_src/src/components/dialog/getCatalog.vue | 4 ++-- web_src/src/components/dialog/importChannel.vue | 2 +- web_src/src/components/dialog/onvifEdit.vue | 2 +- web_src/src/components/dialog/platformEdit.vue | 6 +++--- web_src/src/components/dialog/pushStreamEdit.vue | 6 +++--- web_src/src/components/dialog/queryTrace.vue | 2 +- web_src/src/components/dialog/recordDownload.vue | 8 ++++---- web_src/src/components/live.vue | 2 +- web_src/src/components/map.vue | 2 +- web_src/src/components/service/DeviceService.js | 10 +++++----- web_src/src/components/service/MediaServer.js | 14 +++++++------- web_src/src/main.js | 8 ++++---- web_src/static/js/{mapConfig.js => config.js} | 3 +++ 71 files changed, 173 insertions(+), 191 deletions(-) rename web_src/static/js/{mapConfig.js => config.js} (96%) diff --git a/doc/_content/ability/gis.md b/doc/_content/ability/gis.md index 8796dba05..f77a428c0 100644 --- a/doc/_content/ability/gis.md +++ b/doc/_content/ability/gis.md @@ -14,7 +14,7 @@ WVP提供了简单的电子地图用于设备的定位以及移动设备的轨 PS: 目前的底图仅用用作演示和学习,商用情况请自行购买授权使用。 ### 更换底图以及底图配置 -目前WVP支持使用了更换底图,配置文件在web_src/static/js/mapConfig.js,请修改后重新编译前端文件。 +目前WVP支持使用了更换底图,配置文件在web_src/static/js/config.js,请修改后重新编译前端文件。 ```javascript window.mapParam = { // 开启/关闭地图功能 diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java b/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java index 7133e14eb..e30b6db31 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java @@ -48,6 +48,13 @@ public class ApiAccessFilter extends OncePerRequestFilter { long start = System.currentTimeMillis(); // 请求进入时间 String uriName = ApiSaveConstant.getVal(servletRequest.getRequestURI()); + String origin = servletRequest.getHeader("Origin"); + servletResponse.setContentType("application/json;charset=UTF-8"); + servletResponse.setHeader("Access-Control-Allow-Origin", origin != null ? origin : "*"); + servletResponse.setHeader("Access-Control-Allow-Credentials", "true"); + servletResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT"); + servletResponse.setHeader("Access-Control-Max-Age", "3600"); + servletResponse.setHeader("Access-Control-Allow-Headers", "token,Content-Type,Content-Length, Authorization, Accept,X-Requested-With,domain,zdy"); filterChain.doFilter(servletRequest, servletResponse); if (uriName != null && userSetting != null && userSetting.getLogInDatebase() != null && userSetting.getLogInDatebase()) { @@ -65,9 +72,7 @@ public class ApiAccessFilter extends OncePerRequestFilter { logDto.setUri(servletRequest.getRequestURI()); logDto.setCreateTime(DateUtil.getNow()); logService.add(logDto); -// logger.warn("[Api Access] [{}] [{}] [{}] [{}] [{}] {}ms", -// uriName, servletRequest.getMethod(), servletRequest.getRequestURI(), servletRequest.getRemoteAddr(), HttpStatus.valueOf(servletResponse.getStatus()), -// System.currentTimeMillis() - start); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java index cd5042088..35c68d5d9 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.conf.security; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import org.apache.poi.hssf.eventmodel.ERFListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.AuthenticationException; @@ -25,7 +24,10 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoi @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { // 允许跨域 - response.setHeader("Access-Control-Allow-Origin", "*"); + String origin = request.getHeader("Origin"); + response.setHeader("Access-Control-Allow-Credentials", "true"); + response.setHeader("Access-Control-Allow-Origin", origin != null ? origin : "*"); + response.setHeader("Access-Control-Allow-Methods", "PUT,POST, GET,DELETE,OPTIONS"); // 允许自定义请求头token(允许head跨域) response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified"); response.setHeader("Content-type", "application/json;charset=UTF-8"); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index a795e77bb..a07a47cdc 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -112,6 +112,7 @@ public class ZLMHttpHookListener { * 服务器定时上报时间,上报间隔可配置,默认10s上报一次 */ @ResponseBody + @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) { @@ -135,6 +136,7 @@ public class ZLMHttpHookListener { * 播放器鉴权事件,rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件。 */ @ResponseBody + @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8") public HookResult onPlay(@RequestBody OnPlayHookParam param) { if (logger.isDebugEnabled()) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java index 305d488a9..5046faa09 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java @@ -30,7 +30,7 @@ import java.util.UUID; * 位置信息管理 */ @Tag(name = "位置信息管理") -@CrossOrigin + @RestController @RequestMapping("/api/position") public class MobilePositionController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/SseController/SseController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/SseController/SseController.java index d58d43146..b1ad3b9f5 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/SseController/SseController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/SseController/SseController.java @@ -17,7 +17,7 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; * @data: 2021-01-20 */ @Tag(name = "SSE推送") -@CrossOrigin + @Controller @RequestMapping("/api") public class SseController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java index e030b1769..00155308a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java @@ -6,24 +6,18 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookListener; import com.genersoft.iot.vmp.service.IDeviceAlarmService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.sip.InvalidArgumentException; @@ -34,7 +28,7 @@ import java.util.Arrays; import java.util.List; @Tag(name = "报警信息管理") -@CrossOrigin + @RestController @RequestMapping("/api/alarm") public class AlarmController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java index 651d9ac51..eac68ca41 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java @@ -14,7 +14,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; - import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -22,9 +21,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; @@ -34,7 +31,7 @@ import java.text.ParseException; import java.util.UUID; @Tag(name = "国标设备配置") -@CrossOrigin + @RestController @RequestMapping("/api/device/config") public class DeviceConfig { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java index ff0d8b4f3..bf0acb5ab 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java @@ -32,7 +32,7 @@ import java.text.ParseException; import java.util.UUID; @Tag(name = "国标设备控制") -@CrossOrigin + @RestController @RequestMapping("/api/device/control") public class DeviceControl { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index c15d771a2..7a8732c8c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -46,7 +46,7 @@ import java.util.*; @Tag(name = "国标设备查询", description = "国标设备查询") @SuppressWarnings("rawtypes") -@CrossOrigin + @RestController @RequestMapping("/api/device/query") public class DeviceQuery { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java index 447944a7f..5e673729b 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java @@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @Tag(name = "视频流关联到级联平台") -@CrossOrigin + @RestController @RequestMapping("/api/gbStream") public class GbStreamController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java index d135fa2f3..8e0e2012f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java @@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest; @Tag(name = "媒体流相关") @Controller -@CrossOrigin + @RequestMapping(value = "/api/media") public class MediaController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 40b65c33b..7628f7ca8 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -37,7 +37,7 @@ import java.util.List; * 级联平台管理 */ @Tag(name = "级联平台管理") -@CrossOrigin + @RestController @RequestMapping("/api/platform") public class PlatformController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index c94dbf2cf..958cc6895 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.UUID; @Tag(name = "国标设备点播") -@CrossOrigin + @RestController @RequestMapping("/api/play") public class PlayController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index eb6f997d1..8bab3fd0c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -40,7 +40,7 @@ import java.util.UUID; * @author lin */ @Tag(name = "视频回放") -@CrossOrigin + @RestController @RequestMapping("/api/playback") public class PlaybackController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java index 171f57ca9..e9ea457db 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java @@ -1,7 +1,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.ptz; - + import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; +import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -10,23 +15,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; - import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; import java.util.UUID; @Tag(name = "云台控制") -@CrossOrigin + @RestController @RequestMapping("/api/ptz") public class PtzController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java index c3b9c7814..093b32408 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java @@ -36,7 +36,7 @@ import java.text.ParseException; import java.util.UUID; @Tag(name = "国标录像") -@CrossOrigin + @RestController @RequestMapping("/api/gb_record") public class GBRecordController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java index 42efbb1a1..3cabb99fd 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java @@ -6,25 +6,18 @@ import com.genersoft.iot.vmp.service.ILogService; import com.genersoft.iot.vmp.storager.dao.dto.LogDto; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; -import java.text.ParseException; - @Tag(name = "日志管理") -@CrossOrigin + @RestController @RequestMapping("/api/log") public class LogController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java index ec88b5075..6e2aca37a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java @@ -14,7 +14,7 @@ //import org.springframework.web.bind.annotation.*; // //@Tag(name = "云端录像") -//@CrossOrigin +// //@RestController //@RequestMapping("/api/record") //public class RecordController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index 6b8550db7..ad2c13b6c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.vmanager.server; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.VManageBootstrap; import com.genersoft.iot.vmp.common.SystemAllInfo; import com.genersoft.iot.vmp.common.VersionPo; import com.genersoft.iot.vmp.conf.SipConfig; @@ -15,13 +14,10 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.bean.MediaServerLoad; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.utils.SpringBeanFactory; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo; -import gov.nist.javax.sip.SipStackImpl; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -31,14 +27,12 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; -import javax.sip.ListeningPoint; -import javax.sip.ObjectInUseException; -import javax.sip.SipProvider; -import java.util.*; +import java.util.ArrayList; +import java.util.List; @SuppressWarnings("rawtypes") @Tag(name = "服务控制") -@CrossOrigin + @RestController @RequestMapping("/api/server") public class ServerController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java index 65ec3d339..4a8522b6e 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java @@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.*; */ @Tag(name = "拉流代理", description = "") @Controller -@CrossOrigin + @RequestMapping(value = "/api/proxy") public class StreamProxyController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java index 7506433f9..662256884 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java @@ -41,7 +41,7 @@ import java.util.UUID; @Tag(name = "推流信息管理") @Controller -@CrossOrigin + @RequestMapping(value = "/api/push") public class StreamPushController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java index 769dca001..f34f1c4b4 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/RoleController.java @@ -6,20 +6,16 @@ import com.genersoft.iot.vmp.service.IRoleService; import com.genersoft.iot.vmp.storager.dao.dto.Role; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @Tag(name = "角色管理") -@CrossOrigin + @RestController @RequestMapping("/api/role") public class RoleController { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 157cb7511..127e83b8a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -24,7 +24,7 @@ import javax.security.sasl.AuthenticationException; import java.util.List; @Tag(name = "用户管理") -@CrossOrigin + @RestController @RequestMapping("/api/user") public class UserController { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java index be2bbc192..6f2fe544e 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java @@ -18,7 +18,7 @@ import java.text.ParseException; /** * API兼容:设备控制 */ -@CrossOrigin + @RestController @RequestMapping(value = "/api/v1/control") public class ApiControlController { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java index e6286d603..bd5d5ef3f 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiController.java @@ -6,7 +6,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -14,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody; * API兼容:系统接口 */ @Controller -@CrossOrigin + @RequestMapping(value = "/api/v1") public class ApiController { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index e5f422728..5065523e8 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -20,7 +20,7 @@ import java.util.List; * API兼容:设备信息 */ @SuppressWarnings("unchecked") -@CrossOrigin + @RestController @RequestMapping(value = "/api/v1/device") public class ApiDeviceController { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java index 5381a3aec..72a1b5da8 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java @@ -26,7 +26,7 @@ import java.text.ParseException; * API兼容:实时直播 */ @SuppressWarnings(value = {"rawtypes", "unchecked"}) -@CrossOrigin + @RestController @RequestMapping(value = "/api/v1/stream") public class ApiStreamController { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java index abefa42bf..d503f1531 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/AuthController.java @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.storager.dao.dto.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -@CrossOrigin + @RestController @RequestMapping(value = "/auth") public class AuthController { diff --git a/web_src/build/utils.js b/web_src/build/utils.js index bc98c135e..e534fb0fd 100644 --- a/web_src/build/utils.js +++ b/web_src/build/utils.js @@ -47,8 +47,7 @@ exports.cssLoaders = function (options) { if (options.extract) { return ExtractTextPlugin.extract({ use: loaders, - fallback: 'vue-style-loader', - publicPath: '../../' + fallback: 'vue-style-loader' }) } else { return ['vue-style-loader'].concat(loaders) diff --git a/web_src/config/index.js b/web_src/config/index.js index 6f0ca8bb1..b1e1cbe14 100644 --- a/web_src/config/index.js +++ b/web_src/config/index.js @@ -8,18 +8,18 @@ module.exports = { dev: { // Paths - assetsSubDirectory: './static', - assetsPublicPath: './', + assetsSubDirectory: 'static', + assetsPublicPath: '/', proxyTable: { '/debug': { - target: 'http://localhost:38080', + target: 'http://localhost:18080', changeOrigin: true, pathRewrite: { '^/debug': '/' } }, '/static/snap': { - target: 'http://localhost:38080', + target: 'http://localhost:18080', changeOrigin: true, // pathRewrite: { // '^/static/snap': '/static/snap' @@ -61,7 +61,7 @@ module.exports = { // Paths assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'), assetsSubDirectory: './static', - assetsPublicPath: './', + assetsPublicPath: '/', /** * Source Maps diff --git a/web_src/index.html b/web_src/index.html index e338faad8..778591ed2 100644 --- a/web_src/index.html +++ b/web_src/index.html @@ -13,7 +13,7 @@ - +
diff --git a/web_src/src/components/CloudRecord.vue b/web_src/src/components/CloudRecord.vue index bd374fc8f..b046fc917 100644 --- a/web_src/src/components/CloudRecord.vue +++ b/web_src/src/components/CloudRecord.vue @@ -133,7 +133,7 @@ let that = this; this.$axios({ method: 'get', - url:`./record_proxy/${that.mediaServerId}/api/record/list`, + url:`/record_proxy/${that.mediaServerId}/api/record/list`, params: { page: that.currentPage, count: that.count @@ -185,7 +185,7 @@ let that = this; this.$axios({ method: 'delete', - url:`./record_proxy/api/record/delete`, + url:`/record_proxy/api/record/delete`, params: { page: that.currentPage, count: that.count diff --git a/web_src/src/components/CloudRecordDetail.vue b/web_src/src/components/CloudRecordDetail.vue index 8b3f4c808..40c21b6ac 100644 --- a/web_src/src/components/CloudRecordDetail.vue +++ b/web_src/src/components/CloudRecordDetail.vue @@ -241,7 +241,7 @@ let that = this; that.$axios({ method: 'get', - url:`./record_proxy/${that.mediaServerId}/api/record/file/list`, + url:`/record_proxy/${that.mediaServerId}/api/record/file/list`, params: { app: that.recordFile.app, stream: that.recordFile.stream, @@ -340,7 +340,7 @@ let that = this; this.$axios({ method: 'delete', - url:`./record_proxy/${that.mediaServerId}/api/record/delete`, + url:`/record_proxy/${that.mediaServerId}/api/record/delete`, params: { page: that.currentPage, count: that.count @@ -359,7 +359,7 @@ that.dateFilesObj = {}; this.$axios({ method: 'get', - url:`./record_proxy/${that.mediaServerId}/api/record/date/list`, + url:`/record_proxy/${that.mediaServerId}/api/record/date/list`, params: { app: that.recordFile.app, stream: that.recordFile.stream @@ -408,7 +408,7 @@ let that = this; this.$axios({ method: 'get', - url:`./record_proxy/${that.mediaServerId}/api/record/file/download/task/add`, + url:`/record_proxy/${that.mediaServerId}/api/record/file/download/task/add`, params: { app: that.recordFile.app, stream: that.recordFile.stream, @@ -433,7 +433,7 @@ let that = this; this.$axios({ method: 'get', - url:`./record_proxy/${that.mediaServerId}/api/record/file/download/task/list`, + url:`/record_proxy/${that.mediaServerId}/api/record/file/download/task/list`, params: { isEnd: isEnd, } diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 5f2495e36..29e049daf 100644 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -152,7 +152,7 @@ export default { this.getDeviceListLoading = true; this.$axios({ method: 'get', - url: `./api/device/query/devices`, + url: `/api/device/query/devices`, params: { page: this.currentPage, count: this.count @@ -182,7 +182,7 @@ export default { }).then(() => { this.$axios({ method: 'delete', - url: `./api/device/query/devices/${row.deviceId}/delete` + url: `/api/device/query/devices/${row.deviceId}/delete` }).then((res) => { this.getDeviceList(); }).catch((error) => { @@ -208,7 +208,7 @@ export default { let that = this; this.$axios({ method: 'get', - url: './api/device/query/devices/' + itemData.deviceId + '/sync' + url: '/api/device/query/devices/' + itemData.deviceId + '/sync' }).then((res) => { console.log("刷新设备结果:" + JSON.stringify(res)); if (res.data.code !== 0) { @@ -242,7 +242,7 @@ export default { await this.$axios({ method: 'get', async: false, - url: `./api/device/query/${deviceId}/sync_status/`, + url: `/api/device/query/${deviceId}/sync_status/`, }).then((res) => { if (res.data.code == 0) { if (res.data.data.errorMsg !== null) { @@ -261,7 +261,7 @@ export default { let that = this; this.$axios({ method: 'post', - url: './api/device/query/transport/' + row.deviceId + '/' + row.streamMode + url: '/api/device/query/transport/' + row.deviceId + '/' + row.streamMode }).then(function (res) { }).catch(function (e) { diff --git a/web_src/src/components/GBRecordDetail.vue b/web_src/src/components/GBRecordDetail.vue index 938792a62..6fe29a893 100644 --- a/web_src/src/components/GBRecordDetail.vue +++ b/web_src/src/components/GBRecordDetail.vue @@ -197,7 +197,7 @@ this.detailFiles = []; this.$axios({ method: 'get', - url: './api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + this.startTime + '&endTime=' + this.endTime + url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + this.startTime + '&endTime=' + this.endTime }).then((res)=>{ this.recordsLoading = false; if(res.data.code === 0) { @@ -249,7 +249,7 @@ } else { this.$axios({ method: 'get', - url: './api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + this.startTime + '&endTime=' + + url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + this.startTime + '&endTime=' + this.endTime }).then((res)=> { if (res.data.code === 0) { @@ -273,7 +273,7 @@ console.log('前端控制:播放'); this.$axios({ method: 'get', - url: './api/playback/resume/' + this.streamId + url: '/api/playback/resume/' + this.streamId }).then((res)=> { this.$refs["recordVideoPlayer"].play(this.videoUrl) }); @@ -282,14 +282,14 @@ console.log('前端控制:暂停'); this.$axios({ method: 'get', - url: './api/playback/pause/' + this.streamId + url: '/api/playback/pause/' + this.streamId }).then(function (res) {}); }, gbScale(command){ console.log('前端控制:倍速 ' + command); this.$axios({ method: 'get', - url: `./api/playback/speed/${this.streamId }/${command}` + url: `/api/playback/speed/${this.streamId }/${command}` }).then(function (res) {}); }, downloadRecord: function (row) { @@ -311,7 +311,7 @@ }else { this.$axios({ method: 'get', - url: './api/gb_record/download/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' + + url: '/api/gb_record/download/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' + row.endTime + '&downloadSpeed=4' }).then( (res)=> { if (res.data.code === 0) { @@ -332,7 +332,7 @@ this.videoUrl = ''; this.$axios({ method: 'get', - url: './api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.streamId + url: '/api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.streamId }).then((res)=> { if (callback) callback(res) }); @@ -342,7 +342,7 @@ this.videoUrl = ''; this.$axios({ method: 'get', - url: './api/playback/stop/' + this.deviceId + "/" + this.channelId + "/" + this.streamId + url: '/api/playback/stop/' + this.deviceId + "/" + this.channelId + "/" + this.streamId }).then(function (res) { if (callback) callback() }); diff --git a/web_src/src/components/Login.vue b/web_src/src/components/Login.vue index 6346950d4..37c8a83a4 100644 --- a/web_src/src/components/Login.vue +++ b/web_src/src/components/Login.vue @@ -81,7 +81,7 @@ export default { this.$axios({ method: 'get', - url:"./api/user/login", + url:"/api/user/login", params: loginParam }).then(function (res) { window.clearTimeout(timeoutTask) diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index 262bddac0..61e93fc89 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -128,7 +128,7 @@ export default { var that = this; that.$axios({ method: 'delete', - url:`./api/platform/delete/${platform.serverGBId}` + url:`/api/platform/delete/${platform.serverGBId}` }).then(function (res) { if (res.data.code === 0) { that.$message({ @@ -162,7 +162,7 @@ export default { this.$axios({ method: 'get', - url:`./api/platform/query/${that.count}/${that.currentPage}` + url:`/api/platform/query/${that.count}/${that.currentPage}` }).then(function (res) { if (res.data.code === 0) { that.total = res.data.data.total; diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index 5ca7194c3..6aed98a30 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -171,7 +171,7 @@ export default { this.getDeviceListLoading = true; this.$axios({ method: 'get', - url: `./api/push/list`, + url: `/api/push/list`, params: { page: that.currentPage, count: that.count, @@ -197,7 +197,7 @@ export default { this.getListLoading = true; this.$axios({ method: 'get', - url: './api/push/getPlayUrl', + url: '/api/push/getPlayUrl', params: { app: row.app, stream: row.stream, @@ -223,7 +223,7 @@ export default { let that = this; that.$axios({ method: "post", - url: "./api/push/stop", + url: "/api/push/stop", params: { app: row.app, streamId: row.stream @@ -247,7 +247,7 @@ export default { let that = this; that.$axios({ method: "delete", - url: "./api/push/remove_form_gb", + url: "/api/push/remove_form_gb", data: row }).then((res) => { if (res.data.code === 0) { @@ -274,7 +274,7 @@ export default { let that = this; that.$axios({ method: "delete", - url: "./api/push/batchStop", + url: "/api/push/batchStop", data: { gbStreams: this.multipleSelection } diff --git a/web_src/src/components/StreamProxyList.vue b/web_src/src/components/StreamProxyList.vue index f0cb77773..47ccde8b6 100644 --- a/web_src/src/components/StreamProxyList.vue +++ b/web_src/src/components/StreamProxyList.vue @@ -167,7 +167,7 @@ let that = this; this.$axios({ method: 'get', - url:`./api/proxy/list`, + url:`/api/proxy/list`, params: { page: that.currentPage, count: that.count @@ -190,7 +190,7 @@ addOnvif: function(){ this.$axios({ method: 'get', - url:`./api/onvif/search?timeout=3000`, + url:`/api/onvif/search?timeout=3000`, }).then((res) =>{ if (res.data.code === 0 ){ if (res.data.data.length > 0) { @@ -218,7 +218,7 @@ let that = this; this.$axios({ method: 'get', - url:`./api/push/getPlayUrl`, + url:`/api/push/getPlayUrl`, params: { app: row.app, stream: row.stream, @@ -247,7 +247,7 @@ let that = this; that.$axios({ method:"delete", - url:"./api/proxy/del", + url:"/api/proxy/del", params:{ app: row.app, stream: row.stream @@ -263,7 +263,7 @@ this.$set(row, 'startBtnLoading', true) this.$axios({ method: 'get', - url:`./api/proxy/start`, + url:`/api/proxy/start`, params: { app: row.app, stream: row.stream @@ -295,7 +295,7 @@ let that = this; this.$axios({ method: 'get', - url:`./api/proxy/stop`, + url:`/api/proxy/stop`, params: { app: row.app, stream: row.stream diff --git a/web_src/src/components/UserManager.vue b/web_src/src/components/UserManager.vue index d012b1354..c0fa695a4 100644 --- a/web_src/src/components/UserManager.vue +++ b/web_src/src/components/UserManager.vue @@ -99,7 +99,7 @@ export default { this.getUserListLoading = true; this.$axios({ method: 'get', - url: `./api/user/users`, + url: `/api/user/users`, params: { page: that.currentPage, count: that.count @@ -141,7 +141,7 @@ export default { }).then(() => { this.$axios({ method: 'delete', - url: `./api/user/delete?id=${row.id}` + url: `/api/user/delete?id=${row.id}` }).then((res) => { this.getUserList(); }).catch((error) => { diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index e324bdc4e..f020f345e 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -206,7 +206,7 @@ export default { if (typeof (this.$route.params.deviceId) == "undefined") return; this.$axios({ method: 'get', - url: `./api/device/query/devices/${this.$route.params.deviceId}/channels`, + url: `/api/device/query/devices/${this.$route.params.deviceId}/channels`, params: { page: that.currentPage, count: that.count, @@ -238,7 +238,7 @@ export default { let that = this; this.$axios({ method: 'get', - url: './api/play/start/' + deviceId + '/' + channelId + url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { console.log(res) that.isLoging = false; @@ -278,7 +278,7 @@ export default { var that = this; this.$axios({ method: 'get', - url: './api/play/stop/' + this.deviceId + "/" + itemData.channelId + url: '/api/play/stop/' + this.deviceId + "/" + itemData.channelId }).then(function (res) { that.initData(); }).catch(function (error) { @@ -334,7 +334,7 @@ export default { if (!this.showTree) { this.$axios({ method: 'get', - url: `./api/device/query/sub_channels/${this.deviceId}/${this.parentChannelId}/channels`, + url: `/api/device/query/sub_channels/${this.deviceId}/${this.parentChannelId}/channels`, params: { page: this.currentPage, count: this.count, @@ -358,7 +358,7 @@ export default { }else { this.$axios({ method: 'get', - url: `./api/device/query/tree/channel/${this.deviceId}`, + url: `/api/device/query/tree/channel/${this.deviceId}`, params: { parentId: this.parentChannelId, page: this.currentPage, @@ -387,7 +387,7 @@ export default { updateChannel: function (row) { this.$axios({ method: 'post', - url: `./api/device/query/channel/update/${this.deviceId}`, + url: `/api/device/query/channel/update/${this.deviceId}`, params: row }).then(function (res) { console.log(JSON.stringify(res)); diff --git a/web_src/src/components/console.vue b/web_src/src/components/console.vue index 2f5bb55e8..e192fb1b7 100644 --- a/web_src/src/components/console.vue +++ b/web_src/src/components/console.vue @@ -114,7 +114,7 @@ export default { getSystemInfo: function (){ this.$axios({ method: 'get', - url: `./api/server/system/info`, + url: `/api/server/system/info`, }).then( (res)=> { if (res.data.code === 0) { this.$refs.consoleCPU.setData(res.data.data.cpu) @@ -128,7 +128,7 @@ export default { getLoad: function (){ this.$axios({ method: 'get', - url: `./api/server/media_server/load`, + url: `/api/server/media_server/load`, }).then( (res)=> { if (res.data.code === 0) { this.$refs.consoleNodeLoad.setData(res.data.data) @@ -139,7 +139,7 @@ export default { getResourceInfo: function (){ this.$axios({ method: 'get', - url: `./api/server/resource/info`, + url: `/api/server/resource/info`, }).then( (res)=> { if (res.data.code === 0) { this.$refs.consoleResource.setData(res.data.data) @@ -151,7 +151,7 @@ export default { this.$axios({ method: 'get', - url: `./api/server/system/configInfo`, + url: `/api/server/system/configInfo`, }).then( (res)=> { console.log(res) if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/MediaServerEdit.vue b/web_src/src/components/dialog/MediaServerEdit.vue index edb4ff67b..9353a8116 100644 --- a/web_src/src/components/dialog/MediaServerEdit.vue +++ b/web_src/src/components/dialog/MediaServerEdit.vue @@ -335,7 +335,7 @@ export default { var that = this; await that.$axios({ method: 'get', - url:`./api/platform/exit/${deviceGbId}` + url:`/api/platform/exit/${deviceGbId}` }).then(function (res) { result = res.data; }).catch(function (error) { diff --git a/web_src/src/components/dialog/StreamProxyEdit.vue b/web_src/src/components/dialog/StreamProxyEdit.vue index c8efc140b..76011fac3 100644 --- a/web_src/src/components/dialog/StreamProxyEdit.vue +++ b/web_src/src/components/dialog/StreamProxyEdit.vue @@ -195,7 +195,7 @@ export default { let that = this; this.$axios({ method: 'get', - url:`./api/platform/query/10000/1` + url:`/api/platform/query/10000/1` }).then(function (res) { that.platformList = res.data.data.list; }).catch(function (error) { @@ -212,7 +212,7 @@ export default { if (that.proxyParam.mediaServerId !== "auto"){ that.$axios({ method: 'get', - url:`./api/proxy/ffmpeg_cmd/list`, + url:`/api/proxy/ffmpeg_cmd/list`, params: { mediaServerId: that.proxyParam.mediaServerId } @@ -230,7 +230,7 @@ export default { this.noneReaderHandler(); this.$axios({ method: 'post', - url:`./api/proxy/save`, + url:`/api/proxy/save`, data: this.proxyParam }).then((res)=> { this.dialogLoading = false; @@ -261,7 +261,7 @@ export default { var that = this; await that.$axios({ method: 'get', - url:`./api/platform/exit/${deviceGbId}` + url:`/api/platform/exit/${deviceGbId}` }).then(function (res) { result = res.data; }).catch(function (error) { diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue index 6f4544b3e..e1c9fe01b 100644 --- a/web_src/src/components/dialog/SyncChannelProgress.vue +++ b/web_src/src/components/dialog/SyncChannelProgress.vue @@ -55,7 +55,7 @@ export default { getProgress(){ this.$axios({ method: 'get', - url:`./api/device/query/${this.deviceId}/sync_status/`, + url:`/api/device/query/${this.deviceId}/sync_status/`, }).then((res) => { if (res.data.code === 0) { if (!this.syncFlag) { diff --git a/web_src/src/components/dialog/addUser.vue b/web_src/src/components/dialog/addUser.vue index 9ac38aaa9..8dc56827a 100644 --- a/web_src/src/components/dialog/addUser.vue +++ b/web_src/src/components/dialog/addUser.vue @@ -100,7 +100,7 @@ export default { onSubmit: function () { this.$axios({ method: 'post', - url: "./api/user/add", + url: "/api/user/add", params: { username: this.username, password: this.password, @@ -139,7 +139,7 @@ export default { this.$axios({ method: 'get', - url: "./api/role/all" + url: "/api/role/all" }).then((res) => { this.loading = true; if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue index da2cc3060..e1cd8d268 100644 --- a/web_src/src/components/dialog/catalogEdit.vue +++ b/web_src/src/components/dialog/catalogEdit.vue @@ -116,7 +116,7 @@ export default { console.log(this.form); this.$axios({ method:"post", - url:`./api/platform/catalog/${!this.isEdit? "add":"edit"}`, + url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`, data: this.form }).then((res)=> { if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/changePassword.vue b/web_src/src/components/dialog/changePassword.vue index 9b53b929e..77e1d2a8f 100644 --- a/web_src/src/components/dialog/changePassword.vue +++ b/web_src/src/components/dialog/changePassword.vue @@ -90,7 +90,7 @@ export default { onSubmit: function () { this.$axios({ method: 'post', - url:"./api/user/changePassword", + url:"/api/user/changePassword", params: { oldPassword: crypto.createHash('md5').update(this.oldPassword, "utf8").digest('hex'), password: this.newPassword diff --git a/web_src/src/components/dialog/changePasswordForAdmin.vue b/web_src/src/components/dialog/changePasswordForAdmin.vue index 9c17d5692..5b9135778 100644 --- a/web_src/src/components/dialog/changePasswordForAdmin.vue +++ b/web_src/src/components/dialog/changePasswordForAdmin.vue @@ -85,7 +85,7 @@ export default { onSubmit: function () { this.$axios({ method: 'post', - url:"./api/user/changePasswordForAdmin", + url:"/api/user/changePasswordForAdmin", params: { password: this.newPassword, userId: this.form.id, diff --git a/web_src/src/components/dialog/changePushKey.vue b/web_src/src/components/dialog/changePushKey.vue index 9cc1684e7..0b9834ef8 100644 --- a/web_src/src/components/dialog/changePushKey.vue +++ b/web_src/src/components/dialog/changePushKey.vue @@ -65,7 +65,7 @@ export default { onSubmit: function () { this.$axios({ method: 'post', - url:"./api/user/changePushKey", + url:"/api/user/changePushKey", params: { pushKey: this.newPushKey, userId: this.form.id, diff --git a/web_src/src/components/dialog/channelMapInfobox.vue b/web_src/src/components/dialog/channelMapInfobox.vue index 83040680e..2ef0e5295 100644 --- a/web_src/src/components/dialog/channelMapInfobox.vue +++ b/web_src/src/components/dialog/channelMapInfobox.vue @@ -44,7 +44,7 @@ export default { let that = this; this.$axios({ method: 'get', - url: './api/play/start/' + deviceId + '/' + channelId + url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { that.isLoging = false; if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/chooseChannel.vue b/web_src/src/components/dialog/chooseChannel.vue index e89183913..e0e79c3a3 100644 --- a/web_src/src/components/dialog/chooseChannel.vue +++ b/web_src/src/components/dialog/chooseChannel.vue @@ -98,7 +98,7 @@ export default { this.$axios({ method:"post", - url:"./api/platform/update_channel_for_gb", + url:"/api/platform/update_channel_for_gb", data:{ platformId: that.platformId, channelReduces: that.chooseData diff --git a/web_src/src/components/dialog/chooseChannelForCatalog.vue b/web_src/src/components/dialog/chooseChannelForCatalog.vue index 82d1f58eb..c634b77da 100644 --- a/web_src/src/components/dialog/chooseChannelForCatalog.vue +++ b/web_src/src/components/dialog/chooseChannelForCatalog.vue @@ -82,7 +82,7 @@ export default { let that = this; this.$axios({ method:"get", - url:`./api/platform/catalog`, + url:`/api/platform/catalog`, params: { platformId: that.platformId, parentId: parentId @@ -134,7 +134,7 @@ export default { removeCatalog: function (id, node){ this.$axios({ method:"delete", - url:`./api/platform/catalog/del`, + url:`/api/platform/catalog/del`, params: { id: id, platformId: this.platformId, @@ -156,7 +156,7 @@ export default { setDefaultCatalog: function (id){ this.$axios({ method:"post", - url:`./api/platform/catalog/default/update`, + url:`/api/platform/catalog/default/update`, params: { platformId: this.platformId, catalogId: id, @@ -201,7 +201,7 @@ export default { onClick: () => { this.$axios({ method:"delete", - url:"./api/platform/catalog/relation/del", + url:"/api/platform/catalog/relation/del", data: data }).then((res)=>{ console.log("移除成功") diff --git a/web_src/src/components/dialog/chooseChannelForGb.vue b/web_src/src/components/dialog/chooseChannelForGb.vue index 270bcdaf2..fc97b4ce9 100644 --- a/web_src/src/components/dialog/chooseChannelForGb.vue +++ b/web_src/src/components/dialog/chooseChannelForGb.vue @@ -121,7 +121,7 @@ export default { this.getCatalogFromUser((catalogId)=> { this.$axios({ method:"post", - url:"./api/platform/update_channel_for_gb", + url:"/api/platform/update_channel_for_gb", data:{ platformId: this.platformId, all: all, @@ -149,7 +149,7 @@ export default { this.$axios({ method:"delete", - url:"./api/platform/del_channel_for_gb", + url:"/api/platform/del_channel_for_gb", data:{ platformId: this.platformId, all: all, @@ -248,7 +248,7 @@ export default { this.$axios({ method:"get", - url:`./api/platform/channel_list`, + url:`/api/platform/channel_list`, params: { page: that.currentPage, count: that.count, @@ -290,7 +290,7 @@ export default { }).then(() => { this.$axios({ method:"delete", - url:"./api/platform/del_channel_for_gb", + url:"/api/platform/del_channel_for_gb", data:{ platformId: this.platformId, channelReduces: this.multipleSelection @@ -310,7 +310,7 @@ export default { this.$axios({ method: "post", - url: "./api/platform/update_channel_for_gb", + url: "/api/platform/update_channel_for_gb", data: { platformId: this.platformId, channelReduces: this.multipleSelection, diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue index fbf313383..6c4653b59 100644 --- a/web_src/src/components/dialog/chooseChannelForStream.vue +++ b/web_src/src/components/dialog/chooseChannelForStream.vue @@ -134,7 +134,7 @@ export default { this.getCatalogFromUser((catalogId)=>{ this.$axios({ method:"post", - url:"./api/gbStream/add", + url:"/api/gbStream/add", data:{ platformId: this.platformId, catalogId: catalogId, @@ -163,7 +163,7 @@ export default { this.$axios({ method:"delete", - url:"./api/gbStream/del", + url:"/api/gbStream/del", data:{ platformId: this.platformId, all: all, @@ -186,7 +186,7 @@ export default { this.$axios({ method: 'get', - url:`./api/gbStream/list`, + url:`/api/gbStream/list`, params: { page: that.currentPage, count: that.count, @@ -222,7 +222,7 @@ export default { }).then(() => { this.$axios({ method:"delete", - url:"./api/gbStream/del", + url:"/api/gbStream/del", data:{ platformId: this.platformId, gbStreams: this.multipleSelection, @@ -242,7 +242,7 @@ export default { this.getCatalogFromUser((catalogId)=>{ this.$axios({ method:"post", - url:"./api/gbStream/add", + url:"/api/gbStream/add", data:{ platformId: this.platformId, catalogId: catalogId, diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue index 9cacc3627..8a5f9d13b 100644 --- a/web_src/src/components/dialog/deviceEdit.vue +++ b/web_src/src/components/dialog/deviceEdit.vue @@ -131,7 +131,7 @@ export default { this.form.mobilePositionSubmissionInterval = this.form.mobilePositionSubmissionInterval||0 this.$axios({ method: 'post', - url:`./api/device/query/device/${this.isEdit?'update':'add'}/`, + url:`/api/device/query/device/${this.isEdit?'update':'add'}/`, params: this.form }).then((res) => { console.log(res.data) diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index c7fde47d6..e83a29c55 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -320,7 +320,7 @@ export default { if (tab.name === "codec") { this.$axios({ method: 'get', - url: './zlm/' +this.mediaServerId+ '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtsp&app='+ this.app +'&stream='+ this.streamId + url: '/zlm/' +this.mediaServerId+ '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtsp&app='+ this.app +'&stream='+ this.streamId }).then(function (res) { that.tracksLoading = false; if (res.data.code == 0 && res.data.tracks) { @@ -397,7 +397,7 @@ export default { this.$refs[this.activePlayer].pause() that.$axios({ method: 'post', - url: './api/play/convert/' + that.streamId + url: '/api/play/convert/' + that.streamId }).then(function (res) { if (res.data.code === 0) { that.convertKey = res.data.key; @@ -434,7 +434,7 @@ export default { that.$refs.videoPlayer.pause() this.$axios({ method: 'post', - url: './api/play/convertStop/' + this.convertKey + url: '/api/play/convertStop/' + this.convertKey }).then(function (res) { if (res.data.code == 0) { console.log(res.data.msg) @@ -494,7 +494,7 @@ export default { let that = this; this.$axios({ method: 'post', - url: './api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed + url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed }).then(function (res) {}); }, //////////////////////播放器事件处理////////////////////////// @@ -506,7 +506,7 @@ export default { let that = this; this.$axios({ method: 'post', - url: './api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=0¶meter2=' + presetPos + '&combindCode2=0' + url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=0¶meter2=' + presetPos + '&combindCode2=0' }).then(function (res) {}); }, setSpeedOrTime: function (cmdCode, groupNum, parameter) { @@ -516,7 +516,7 @@ export default { console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16)); this.$axios({ method: 'post', - url: './api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter2 + '&combindCode2=' + combindCode2 + url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter2 + '&combindCode2=' + combindCode2 }).then(function (res) {}); }, setCommand: function (cmdCode, groupNum, parameter) { @@ -524,7 +524,7 @@ export default { console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0'); this.$axios({ method: 'post', - url: './api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter + '&combindCode2=0' + url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '¶meter1=' + groupNum + '¶meter2=' + parameter + '&combindCode2=0' }).then(function (res) {}); }, copyUrl: function (dropdownItem){ diff --git a/web_src/src/components/dialog/getCatalog.vue b/web_src/src/components/dialog/getCatalog.vue index 3aae99d32..fdc26de16 100644 --- a/web_src/src/components/dialog/getCatalog.vue +++ b/web_src/src/components/dialog/getCatalog.vue @@ -89,7 +89,7 @@ export default { let that = this; this.$axios({ method:"get", - url:`./api/platform/catalog`, + url:`/api/platform/catalog`, params: { platformId: that.platformId, parentId: parentId @@ -111,7 +111,7 @@ export default { if (node.level === 0) { this.$axios({ method:"get", - url:`./api/platform/info/` + this.platformId, + url:`/api/platform/info/` + this.platformId, }) .then((res)=> { if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/importChannel.vue b/web_src/src/components/dialog/importChannel.vue index d511fe8bb..91611e80c 100644 --- a/web_src/src/components/dialog/importChannel.vue +++ b/web_src/src/components/dialog/importChannel.vue @@ -60,7 +60,7 @@ export default { console.log(this.form); this.$axios({ method:"post", - url:`./api/platform/catalog/${!this.isEdit? "add":"edit"}`, + url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`, data: this.form }) .then((res)=> { diff --git a/web_src/src/components/dialog/onvifEdit.vue b/web_src/src/components/dialog/onvifEdit.vue index 8a68b20fa..f36ce4a0d 100644 --- a/web_src/src/components/dialog/onvifEdit.vue +++ b/web_src/src/components/dialog/onvifEdit.vue @@ -81,7 +81,7 @@ export default { console.log(this.form); this.$axios({ method: 'get', - url:`./api/onvif/rtsp`, + url:`/api/onvif/rtsp`, params: { hostname: this.form.hostName, timeout: 3000, diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index a6ced30f6..763823249 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -138,7 +138,7 @@ export default { showDialog: false, isLoging: false, onSubmit_text: "立即创建", - saveUrl: "./api/platform/save", + saveUrl: "/api/platform/save", platform: { id: null, @@ -192,7 +192,7 @@ export default { this.saveUrl = "/api/platform/add"; this.$axios({ method: 'get', - url:`./api/platform/server_config` + url:`/api/platform/server_config` }).then(function (res) { console.log(res); if (res.data.code === 0) { @@ -315,7 +315,7 @@ export default { var that = this; await that.$axios({ method: 'get', - url:`./api/platform/exit/${deviceGbId}`}) + url:`/api/platform/exit/${deviceGbId}`}) .then(function (res) { if (res.data.code === 0) { result = res.data.data; diff --git a/web_src/src/components/dialog/pushStreamEdit.vue b/web_src/src/components/dialog/pushStreamEdit.vue index 2e632b5e5..de4e7bcc8 100644 --- a/web_src/src/components/dialog/pushStreamEdit.vue +++ b/web_src/src/components/dialog/pushStreamEdit.vue @@ -109,7 +109,7 @@ export default { if (this.edit) { this.$axios({ method:"post", - url:`./api/push/save_to_gb`, + url:`/api/push/save_to_gb`, data: this.proxyParam }).then( (res) => { if (res.data.code === 0) { @@ -129,7 +129,7 @@ export default { }else { this.$axios({ method:"post", - url:`./api/push/add`, + url:`/api/push/add`, data: this.proxyParam }).then( (res) => { if (res.data.code === 0) { @@ -159,7 +159,7 @@ export default { var that = this; await that.$axios({ method:"get", - url:`./api/platform/exit/${deviceGbId}` + url:`/api/platform/exit/${deviceGbId}` }).then(function (res) { result = res.data; }).catch(function (error) { diff --git a/web_src/src/components/dialog/queryTrace.vue b/web_src/src/components/dialog/queryTrace.vue index fcd1c1077..5063ad4e7 100644 --- a/web_src/src/components/dialog/queryTrace.vue +++ b/web_src/src/components/dialog/queryTrace.vue @@ -72,7 +72,7 @@ export default { onSubmit: function () { console.log("onSubmit"); this.isLoging = true; - let url = `./api/position/history/${this.channel.deviceId}?start=${this.searchFrom}&end=${this.searchTo}`; + let url = `/api/position/history/${this.channel.deviceId}?start=${this.searchFrom}&end=${this.searchTo}`; if (this.channel.channelId) { url+="&channelId=${this.channel.channelId}" } diff --git a/web_src/src/components/dialog/recordDownload.vue b/web_src/src/components/dialog/recordDownload.vue index 46774876c..3e8c42713 100644 --- a/web_src/src/components/dialog/recordDownload.vue +++ b/web_src/src/components/dialog/recordDownload.vue @@ -71,7 +71,7 @@ export default { getProgress: function (callback){ this.$axios({ method: 'get', - url: `./api/gb_record/download/progress/${this.deviceId}/${this.channelId}/${this.stream}` + url: `/api/gb_record/download/progress/${this.deviceId}/${this.channelId}/${this.stream}` }).then((res)=> { console.log(res) if (res.data.code === 0) { @@ -124,7 +124,7 @@ export default { stopDownloadRecord: function (callback) { this.$axios({ method: 'get', - url: './api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.stream + url: '/api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.stream }).then((res)=> { if (callback) callback(res) }); @@ -132,7 +132,7 @@ export default { getFileDownload: function (){ this.$axios({ method: 'get', - url:`./record_proxy/${this.mediaServerId}/api/record/file/download/task/add`, + url:`/record_proxy/${this.mediaServerId}/api/record/file/download/task/add`, params: { app: this.app, stream: this.stream, @@ -164,7 +164,7 @@ export default { getProgressForFile: function (callback){ this.$axios({ method: 'get', - url:`./record_proxy/${this.mediaServerId}/api/record/file/download/task/list`, + url:`/record_proxy/${this.mediaServerId}/api/record/file/download/task/list`, params: { app: this.app, stream: this.stream, diff --git a/web_src/src/components/live.vue b/web_src/src/components/live.vue index a69141850..4a7af491e 100644 --- a/web_src/src/components/live.vue +++ b/web_src/src/components/live.vue @@ -135,7 +135,7 @@ export default { this.loading = true this.$axios({ method: 'get', - url: './api/play/start/' + deviceId + '/' + channelId + url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { if (res.data.code === 0 && res.data.data) { let videoUrl; diff --git a/web_src/src/components/map.vue b/web_src/src/components/map.vue index 20adff0e9..2aa17f632 100644 --- a/web_src/src/components/map.vue +++ b/web_src/src/components/map.vue @@ -298,7 +298,7 @@ export default { let that = this; this.$axios({ method: 'get', - url: './api/play/start/' + deviceId + '/' + channelId + url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { that.isLoging = false; if (res.data.code === 0) { diff --git a/web_src/src/components/service/DeviceService.js b/web_src/src/components/service/DeviceService.js index 61314fe35..85d36f8b3 100644 --- a/web_src/src/components/service/DeviceService.js +++ b/web_src/src/components/service/DeviceService.js @@ -9,7 +9,7 @@ class DeviceService{ getDeviceList(currentPage, count, callback, errorCallback){ this.$axios({ method: 'get', - url:`./api/device/query/devices`, + url:`/api/device/query/devices`, params: { page: currentPage, count: count @@ -25,7 +25,7 @@ class DeviceService{ getDevice(deviceId, callback, errorCallback){ this.$axios({ method: 'get', - url:`./api/device/query/devices/${deviceId}`, + url:`/api/device/query/devices/${deviceId}`, }).then((res) => { if (typeof (callback) == "function") callback(res.data) }).catch((error) => { @@ -82,7 +82,7 @@ class DeviceService{ getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, callback, errorCallback) { this.$axios({ method: 'get', - url: `./api/device/query/devices/${deviceId}/channels`, + url: `/api/device/query/devices/${deviceId}/channels`, params:{ page: currentPage, count: count, @@ -121,7 +121,7 @@ class DeviceService{ getSubChannel(isCatalog, deviceId, channelId, currentPage, count, callback, errorCallback) { this.$axios({ method: 'get', - url: `./api/device/query/sub_channels/${deviceId}/${channelId}/channels`, + url: `/api/device/query/sub_channels/${deviceId}/${channelId}/channels`, params:{ page: currentPage, count: count, @@ -161,7 +161,7 @@ class DeviceService{ } this.$axios({ method: 'get', - url: `./api/device/query/tree/${deviceId}`, + url: `/api/device/query/tree/${deviceId}`, params:{ page: currentPage, count: count, diff --git a/web_src/src/components/service/MediaServer.js b/web_src/src/components/service/MediaServer.js index a2f306ce0..d4446f06f 100644 --- a/web_src/src/components/service/MediaServer.js +++ b/web_src/src/components/service/MediaServer.js @@ -9,7 +9,7 @@ class MediaServer{ getOnlineMediaServerList(callback){ this.$axios({ method: 'get', - url:`./api/server/media_server/online/list`, + url:`/api/server/media_server/online/list`, }).then((res) => { if (typeof (callback) == "function") callback(res.data) }).catch((error) => { @@ -19,7 +19,7 @@ class MediaServer{ getMediaServerList(callback){ this.$axios({ method: 'get', - url:`./api/server/media_server/list`, + url:`/api/server/media_server/list`, }).then(function (res) { if (typeof (callback) == "function") callback(res.data) }).catch(function (error) { @@ -30,7 +30,7 @@ class MediaServer{ getMediaServer(id, callback){ this.$axios({ method: 'get', - url:`./api/server/media_server/one/` + id, + url:`/api/server/media_server/one/` + id, }).then(function (res) { if (typeof (callback) == "function") callback(res.data) }).catch(function (error) { @@ -41,7 +41,7 @@ class MediaServer{ checkServer(param, callback){ this.$axios({ method: 'get', - url:`./api/server/media_server/check`, + url:`/api/server/media_server/check`, params: { ip: param.ip, port: param.httpPort, @@ -57,7 +57,7 @@ class MediaServer{ checkRecordServer(param, callback){ this.$axios({ method: 'get', - url:`./api/server/media_server/record/check`, + url:`/api/server/media_server/record/check`, params: { ip: param.ip, port: param.recordAssistPort @@ -72,7 +72,7 @@ class MediaServer{ addServer(param, callback){ this.$axios({ method: 'post', - url:`./api/server/media_server/save`, + url:`/api/server/media_server/save`, data: param }).then(function (res) { if (typeof (callback) == "function") callback(res.data) @@ -84,7 +84,7 @@ class MediaServer{ delete(id, callback) { this.$axios({ method: 'delete', - url:`./api/server/media_server/delete`, + url:`/api/server/media_server/delete`, params: { id: id } diff --git a/web_src/src/main.js b/web_src/src/main.js index e800718e8..91bbd4751 100644 --- a/web_src/src/main.js +++ b/web_src/src/main.js @@ -37,13 +37,13 @@ Vue.use(VueClipboard); Vue.use(ElementUI); Vue.use(VueCookies); Vue.use(VueClipboards); -Vue.prototype.$axios = axios; + Vue.prototype.$notify = Notification; Vue.use(Contextmenu); Vue.use(VCharts); -axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : ""; - +axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl?window.baseUrl:""); +axios.defaults.withCredentials = true; // api 返回401自动回登陆页面 axios.interceptors.response.use(function (response) { // 对响应数据做点什么 @@ -56,7 +56,7 @@ axios.interceptors.response.use(function (response) { } return Promise.reject(error); }); - +Vue.prototype.$axios = axios; Vue.prototype.$cookies.config(60*30); new Vue({ diff --git a/web_src/static/js/mapConfig.js b/web_src/static/js/config.js similarity index 96% rename from web_src/static/js/mapConfig.js rename to web_src/static/js/config.js index 60427e889..94a105690 100644 --- a/web_src/static/js/mapConfig.js +++ b/web_src/static/js/config.js @@ -1,3 +1,6 @@ + +window.baseUrl = "" + // map组件全局参数, 注释此内容可以关闭地图功能 window.mapParam = { // 开启/关闭地图功能 From 048a6ce07205960156c61df12ca75e20fbca8736 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 11:42:28 +0800 Subject: [PATCH 08/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 2 +- .../iot/vmp/service/redisMsg/RedisAlarmMsgListener.java | 2 +- .../iot/vmp/vmanager/gb28181/alarm/AlarmController.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index ddb96a6f0..b14d497ba 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -414,7 +414,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("" + deviceAlarm.getAlarmPriority() + "\r\n") .append("" + deviceAlarm.getAlarmMethod() + "\r\n") .append("" + deviceAlarm.getAlarmTime() + "\r\n") - .append("" + deviceAlarm.getAlarmDescription() + "\r\n") + .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmDescription()) + "\r\n") .append("" + deviceAlarm.getLongitude() + "\r\n") .append("" + deviceAlarm.getLatitude() + "\r\n") .append("\r\n") diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 2e18db39d..1cc754d21 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -69,7 +69,7 @@ public class RedisAlarmMsgListener implements MessageListener { deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn()); deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType()); deviceAlarm.setAlarmPriority("1"); - deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); + deviceAlarm.setAlarmTime(DateUtil.getNow()); deviceAlarm.setLongitude(0); deviceAlarm.setLatitude(0); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java index 00155308a..d84fb795d 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java @@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.*; import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; -import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; @@ -104,7 +103,7 @@ public class AlarmController { deviceAlarm.setAlarmDescription("test"); deviceAlarm.setAlarmMethod("1"); deviceAlarm.setAlarmPriority("1"); - deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now())); + deviceAlarm.setAlarmTime(DateUtil.getNow()); deviceAlarm.setAlarmType("1"); deviceAlarm.setLongitude(115.33333); deviceAlarm.setLatitude(39.33333); From c5ff8113780960c55de98c0b9f3b1f895dd828e2 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 13:28:54 +0800 Subject: [PATCH 09/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/web/gb28181/ApiDeviceController.java | 6 - .../web/gb28181/dto/DeviceChannelExtent.java | 577 ++++++++++++++++++ 2 files changed, 577 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index 5065523e8..57c797991 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -109,12 +109,6 @@ public class ApiDeviceController { // } JSONObject result = new JSONObject(); // 查询设备是否存在 - Device device = storager.queryVideoDevice(serial); - if (device == null) { - result.put("ChannelCount", 0); - result.put("ChannelList", "[]"); - return result; - } List deviceChannels; List channelIds = null; if (!StringUtils.isEmpty(code)) { diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java new file mode 100644 index 000000000..94943524b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java @@ -0,0 +1,577 @@ +package com.genersoft.iot.vmp.web.gb28181.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "通道信息") +public class DeviceChannelExtent { + + + /** + * 数据库自增ID + */ + @Schema(description = "数据库自增ID") + private int id; + + /** + * 通道国标编号 + */ + @Schema(description = "通道国标编号") + private String channelId; + + /** + * 设备国标编号 + */ + @Schema(description = "设备国标编号") + private String deviceId; + + /** + * 通道名 + */ + @Schema(description = "名称") + private String name; + + /** + * 生产厂商 + */ + @Schema(description = "生产厂商") + private String manufacture; + + /** + * 型号 + */ + @Schema(description = "型号") + private String model; + + /** + * 设备归属 + */ + @Schema(description = "设备归属") + private String owner; + + /** + * 行政区域 + */ + @Schema(description = "行政区域") + private String civilCode; + + /** + * 警区 + */ + @Schema(description = "警区") + private String block; + + /** + * 安装地址 + */ + @Schema(description = "安装地址") + private String address; + + /** + * 是否有子设备 1有, 0没有 + */ + @Schema(description = "是否有子设备 1有, 0没有") + private int parental; + + /** + * 父级id + */ + @Schema(description = "父级id") + private String parentId; + + /** + * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 + */ + @Schema(description = "信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式") + private int safetyWay; + + /** + * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 + */ + @Schema(description = "注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式") + private int registerWay; + + /** + * 证书序列号 + */ + @Schema(description = "证书序列号") + private String certNum; + + /** + * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 + */ + @Schema(description = "证书有效标识 缺省为0;证书有效标识:0:无效1: 有效") + private int certifiable; + + /** + * 证书无效原因码 + */ + @Schema(description = "证书无效原因码") + private int errCode; + + /** + * 证书终止有效期 + */ + @Schema(description = "证书终止有效期") + private String endTime; + + /** + * 保密属性 缺省为0; 0:不涉密, 1:涉密 + */ + @Schema(description = "保密属性 缺省为0; 0:不涉密, 1:涉密") + private String secrecy; + + /** + * IP地址 + */ + @Schema(description = "IP地址") + private String ipAddress; + + /** + * 端口号 + */ + @Schema(description = "端口号") + private int port; + + /** + * 密码 + */ + @Schema(description = "密码") + private String password; + + /** + * 云台类型 + */ + @Schema(description = "云台类型") + private int PTZType; + + /** + * 云台类型描述字符串 + */ + @Schema(description = "云台类型描述字符串") + private String PTZTypeText; + + /** + * 创建时间 + */ + @Schema(description = "创建时间") + private String createTime; + + /** + * 更新时间 + */ + @Schema(description = "更新时间") + private String updateTime; + + /** + * 在线/离线 + * 1在线,0离线 + * 默认在线 + * 信令: + * ON + * OFF + * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF + */ + @Schema(description = "在线/离线, 1在线,0离线") + private int status; + + /** + * 经度 + */ + @Schema(description = "经度") + private double longitude; + + /** + * 纬度 + */ + @Schema(description = "纬度") + private double latitude; + + /** + * 经度 GCJ02 + */ + @Schema(description = "GCJ02坐标系经度") + private double longitudeGcj02; + + /** + * 纬度 GCJ02 + */ + @Schema(description = "GCJ02坐标系纬度") + private double latitudeGcj02; + + /** + * 经度 WGS84 + */ + @Schema(description = "WGS84坐标系经度") + private double longitudeWgs84; + + /** + * 纬度 WGS84 + */ + @Schema(description = "WGS84坐标系纬度") + private double latitudeWgs84; + + /** + * 子设备数 + */ + @Schema(description = "子设备数") + private int subCount; + + /** + * 流唯一编号,存在表示正在直播 + */ + @Schema(description = "流唯一编号,存在表示正在直播") + private String streamId; + + /** + * 是否含有音频 + */ + @Schema(description = "是否含有音频") + private boolean hasAudio; + + /** + * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 + */ + @Schema(description = "标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划") + private int channelType; + + /** + * 业务分组 + */ + @Schema(description = "业务分组") + private String businessGroupId; + + /** + * GPS的更新时间 + */ + @Schema(description = "GPS的更新时间") + private String gpsTime; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public void setPTZType(int PTZType) { + this.PTZType = PTZType; + switch (PTZType) { + case 0: + this.PTZTypeText = "未知"; + break; + case 1: + this.PTZTypeText = "球机"; + break; + case 2: + this.PTZTypeText = "半球"; + break; + case 3: + this.PTZTypeText = "固定枪机"; + break; + case 4: + this.PTZTypeText = "遥控枪机"; + break; + } + } + + public String getChannelId() { + return channelId; + } + + public void setChannelId(String channelId) { + this.channelId = channelId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getManufacture() { + return manufacture; + } + + public void setManufacture(String manufacture) { + this.manufacture = manufacture; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getCivilCode() { + return civilCode; + } + + public void setCivilCode(String civilCode) { + this.civilCode = civilCode; + } + + public String getBlock() { + return block; + } + + public void setBlock(String block) { + this.block = block; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public int getParental() { + return parental; + } + + public void setParental(int parental) { + this.parental = parental; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public int getSafetyWay() { + return safetyWay; + } + + public void setSafetyWay(int safetyWay) { + this.safetyWay = safetyWay; + } + + public int getRegisterWay() { + return registerWay; + } + + public void setRegisterWay(int registerWay) { + this.registerWay = registerWay; + } + + public String getCertNum() { + return certNum; + } + + public void setCertNum(String certNum) { + this.certNum = certNum; + } + + public int getCertifiable() { + return certifiable; + } + + public void setCertifiable(int certifiable) { + this.certifiable = certifiable; + } + + public int getErrCode() { + return errCode; + } + + public void setErrCode(int errCode) { + this.errCode = errCode; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getSecrecy() { + return secrecy; + } + + public void setSecrecy(String secrecy) { + this.secrecy = secrecy; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getPTZType() { + return PTZType; + } + + public String getPTZTypeText() { + return PTZTypeText; + } + + public void setPTZTypeText(String PTZTypeText) { + this.PTZTypeText = PTZTypeText; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitudeGcj02() { + return longitudeGcj02; + } + + public void setLongitudeGcj02(double longitudeGcj02) { + this.longitudeGcj02 = longitudeGcj02; + } + + public double getLatitudeGcj02() { + return latitudeGcj02; + } + + public void setLatitudeGcj02(double latitudeGcj02) { + this.latitudeGcj02 = latitudeGcj02; + } + + public double getLongitudeWgs84() { + return longitudeWgs84; + } + + public void setLongitudeWgs84(double longitudeWgs84) { + this.longitudeWgs84 = longitudeWgs84; + } + + public double getLatitudeWgs84() { + return latitudeWgs84; + } + + public void setLatitudeWgs84(double latitudeWgs84) { + this.latitudeWgs84 = latitudeWgs84; + } + + public int getSubCount() { + return subCount; + } + + public void setSubCount(int subCount) { + this.subCount = subCount; + } + + public boolean isHasAudio() { + return hasAudio; + } + + public void setHasAudio(boolean hasAudio) { + this.hasAudio = hasAudio; + } + + public String getStreamId() { + return streamId; + } + + public void setStreamId(String streamId) { + this.streamId = streamId; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public int getChannelType() { + return channelType; + } + + public void setChannelType(int channelType) { + this.channelType = channelType; + } + + public String getBusinessGroupId() { + return businessGroupId; + } + + public void setBusinessGroupId(String businessGroupId) { + this.businessGroupId = businessGroupId; + } + + public String getGpsTime() { + return gpsTime; + } + + public void setGpsTime(String gpsTime) { + this.gpsTime = gpsTime; + } +} From cefdce5e0a34743e6d9784f858265120e75179a1 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 14:46:18 +0800 Subject: [PATCH 10/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/storager/IVideoManagerStorage.java | 6 +- .../vmp/storager/dao/DeviceChannelMapper.java | 74 +++++++++++++------ .../impl/VideoManagerStorageImpl.java | 10 ++- .../vmp/web/gb28181/ApiDeviceController.java | 70 ++++++++++-------- ...elExtent.java => DeviceChannelExtend.java} | 68 ++++++----------- 5 files changed, 126 insertions(+), 102 deletions(-) rename src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/{DeviceChannelExtent.java => DeviceChannelExtend.java} (78%) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 938f669be..5965678e8 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageInfo; import java.util.List; @@ -58,7 +59,7 @@ public interface IVideoManagerStorage { */ public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count); - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); /** @@ -374,4 +375,7 @@ public interface IVideoManagerStorage { void cleanContentForPlatform(String serverGBId); List queryChannelWithCatalog(String serverGBId); + + List queryChannelsByDeviceId(String serial, List channelIds, Boolean online); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 83f933433..e33a63eda 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @@ -82,7 +83,56 @@ public interface DeviceChannelMapper { " " + "ORDER BY dc.channelId " + " "}) - List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online,List channelIds); + List queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List channelIds); + + @Select(value = {" "}) + List queryChannelsWithDeviceInfo(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, List channelIds); + + + @Select(value = {" "}) + List queryChannelsByDeviceIdWithStartAndLimit(String deviceId,List channelIds, String parentChannelId, String query, + Boolean hasSubChannel, Boolean online, int start, int limit); @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND channelId=#{channelId}") DeviceChannel queryChannel(String deviceId, String channelId); @@ -245,28 +295,6 @@ public interface DeviceChannelMapper { int batchUpdate(List updateChannels); - @Select(value = {" "}) - List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, - Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds); - @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1") List queryOnlineChannelsByDeviceId(String deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 8eefd396b..9475abcd8 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -366,8 +367,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } @Override - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit,List channelIds) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit,channelIds); + public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { + return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, channelIds, null, query, hasSubChannel, online, start, limit); } @@ -376,6 +377,11 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); } + @Override + public List queryChannelsByDeviceId(String deviceId, List channelIds, Boolean online) { + return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); + } + @Override public PageInfo querySubChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int page, int count) { PageHelper.startPage(page, count); diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index 57c797991..99989608e 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -3,15 +3,17 @@ package com.genersoft.iot.vmp.web.gb28181; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; import java.util.List; @@ -96,8 +98,8 @@ public class ApiDeviceController { @RequestMapping(value = "/channellist") public JSONObject channellist( String serial, - @RequestParam(required = false)String code, @RequestParam(required = false)String channel_type, + @RequestParam(required = false)String code , @RequestParam(required = false)String dir_serial , @RequestParam(required = false)Integer start, @RequestParam(required = false)Integer limit, @@ -109,54 +111,60 @@ public class ApiDeviceController { // } JSONObject result = new JSONObject(); // 查询设备是否存在 - List deviceChannels; +// Device device = storager.queryVideoDevice(serial); +// if (device == null) { +// result.put("ChannelCount", 0); +// result.put("ChannelList", "[]"); +// return result; +// } + List deviceChannels; List channelIds = null; if (!StringUtils.isEmpty(code)) { String[] split = code.trim().split(","); channelIds = Arrays.asList(split); } - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,online,channelIds); + List allDeviceChannelList = storager.queryChannelsByDeviceId(serial,channelIds,online); if (start == null || limit ==null) { deviceChannels = allDeviceChannelList; result.put("ChannelCount", deviceChannels.size()); }else { - deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, null, null, online,start, limit,channelIds); + deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial,channelIds, null, null, online,start, limit); int total = allDeviceChannelList.size(); result.put("ChannelCount", total); } JSONArray channleJSONList = new JSONArray(); - for (DeviceChannel deviceChannel : deviceChannels) { + for (DeviceChannelExtend deviceChannelExtend : deviceChannels) { JSONObject deviceJOSNChannel = new JSONObject(); - deviceJOSNChannel.put("ID", deviceChannel.getChannelId()); - deviceJOSNChannel.put("DeviceID", device.getDeviceId()); - deviceJOSNChannel.put("DeviceName", device.getName()); - deviceJOSNChannel.put("DeviceOnline", device.getOnline() == 1); - deviceJOSNChannel.put("Channel", 0); // 自定义序号 - deviceJOSNChannel.put("Name", deviceChannel.getName()); + deviceJOSNChannel.put("ID", deviceChannelExtend.getChannelId()); + deviceJOSNChannel.put("DeviceID", deviceChannelExtend.getDeviceId()); + deviceJOSNChannel.put("DeviceName", deviceChannelExtend.getDeviceName()); + deviceJOSNChannel.put("DeviceOnline", deviceChannelExtend.getDeviceOnline() == 1); + deviceJOSNChannel.put("Channel", 0); // TODO 自定义序号 + deviceJOSNChannel.put("Name", deviceChannelExtend.getName()); deviceJOSNChannel.put("Custom", false); deviceJOSNChannel.put("CustomName", ""); - deviceJOSNChannel.put("SubCount", deviceChannel.getSubCount()); // 子节点数, SubCount > 0 表示该通道为子目录 + deviceJOSNChannel.put("SubCount", deviceChannelExtend.getSubCount()); // TODO ? 子节点数, SubCount > 0 表示该通道为子目录 deviceJOSNChannel.put("SnapURL", ""); - deviceJOSNChannel.put("Manufacturer ", deviceChannel.getManufacture()); - deviceJOSNChannel.put("Model", deviceChannel.getModel()); - deviceJOSNChannel.put("Owner", deviceChannel.getOwner()); - deviceJOSNChannel.put("CivilCode", deviceChannel.getCivilCode()); - deviceJOSNChannel.put("Address", deviceChannel.getAddress()); - deviceJOSNChannel.put("Parental", deviceChannel.getParental()); // 当为通道设备时, 是否有通道子设备, 1-有,0-没有 - deviceJOSNChannel.put("ParentID", deviceChannel.getParentId()); // 直接上级编号 - deviceJOSNChannel.put("Secrecy", deviceChannel.getSecrecy()); + deviceJOSNChannel.put("Manufacturer ", deviceChannelExtend.getManufacture()); + deviceJOSNChannel.put("Model", deviceChannelExtend.getModel()); + deviceJOSNChannel.put("Owner", deviceChannelExtend.getOwner()); + deviceJOSNChannel.put("CivilCode", deviceChannelExtend.getCivilCode()); + deviceJOSNChannel.put("Address", deviceChannelExtend.getAddress()); + deviceJOSNChannel.put("Parental", deviceChannelExtend.getParental()); // 当为通道设备时, 是否有通道子设备, 1-有,0-没有 + deviceJOSNChannel.put("ParentID", deviceChannelExtend.getParentId()); // 直接上级编号 + deviceJOSNChannel.put("Secrecy", deviceChannelExtend.getSecrecy()); deviceJOSNChannel.put("RegisterWay", 1); // 注册方式, 缺省为1, 允许值: 1, 2, 3 - // 1-IETF RFC3261, - // 2-基于口令的双向认证, - // 3-基于数字证书的双向认证 - deviceJOSNChannel.put("Status", deviceChannel.getStatus() == 1 ? "ON":"OFF"); - deviceJOSNChannel.put("Longitude", deviceChannel.getLongitude()); - deviceJOSNChannel.put("Latitude", deviceChannel.getLatitude()); - deviceJOSNChannel.put("PTZType ", deviceChannel.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球, - // 3 - 固定枪机, 4 - 遥控枪机 + // 1-IETF RFC3261, + // 2-基于口令的双向认证, + // 3-基于数字证书的双向认证 + deviceJOSNChannel.put("Status", deviceChannelExtend.getStatus() == 1 ? "ON":"OFF"); + deviceJOSNChannel.put("Longitude", deviceChannelExtend.getLongitude()); + deviceJOSNChannel.put("Latitude", deviceChannelExtend.getLatitude()); + deviceJOSNChannel.put("PTZType ", deviceChannelExtend.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球, + // 3 - 固定枪机, 4 - 遥控枪机 deviceJOSNChannel.put("CustomPTZType", ""); - deviceJOSNChannel.put("StreamID", deviceChannel.getStreamId()); // StreamID 直播流ID, 有值表示正在直播 + deviceJOSNChannel.put("StreamID", deviceChannelExtend.getStreamId()); // StreamID 直播流ID, 有值表示正在直播 deviceJOSNChannel.put("NumOutputs ", -1); // 直播在线人数 channleJSONList.add(deviceJOSNChannel); } diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java similarity index 78% rename from src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java rename to src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java index 94943524b..972d1a6a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtent.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java @@ -1,165 +1,140 @@ package com.genersoft.iot.vmp.web.gb28181.dto; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "通道信息") -public class DeviceChannelExtent { +public class DeviceChannelExtend { /** * 数据库自增ID */ - @Schema(description = "数据库自增ID") private int id; /** - * 通道国标编号 + * 通道id */ - @Schema(description = "通道国标编号") private String channelId; /** - * 设备国标编号 + * 设备id */ - @Schema(description = "设备国标编号") private String deviceId; /** * 通道名 */ - @Schema(description = "名称") private String name; + + private String deviceName; + + private int deviceOnline; /** * 生产厂商 */ - @Schema(description = "生产厂商") private String manufacture; /** * 型号 */ - @Schema(description = "型号") private String model; /** * 设备归属 */ - @Schema(description = "设备归属") private String owner; /** * 行政区域 */ - @Schema(description = "行政区域") private String civilCode; /** * 警区 */ - @Schema(description = "警区") private String block; /** * 安装地址 */ - @Schema(description = "安装地址") private String address; /** * 是否有子设备 1有, 0没有 */ - @Schema(description = "是否有子设备 1有, 0没有") private int parental; /** * 父级id */ - @Schema(description = "父级id") private String parentId; /** * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 */ - @Schema(description = "信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式") private int safetyWay; /** * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 */ - @Schema(description = "注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式") private int registerWay; /** * 证书序列号 */ - @Schema(description = "证书序列号") private String certNum; /** * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 */ - @Schema(description = "证书有效标识 缺省为0;证书有效标识:0:无效1: 有效") private int certifiable; /** * 证书无效原因码 */ - @Schema(description = "证书无效原因码") private int errCode; /** * 证书终止有效期 */ - @Schema(description = "证书终止有效期") private String endTime; /** * 保密属性 缺省为0; 0:不涉密, 1:涉密 */ - @Schema(description = "保密属性 缺省为0; 0:不涉密, 1:涉密") private String secrecy; /** * IP地址 */ - @Schema(description = "IP地址") private String ipAddress; /** * 端口号 */ - @Schema(description = "端口号") private int port; /** * 密码 */ - @Schema(description = "密码") private String password; /** * 云台类型 */ - @Schema(description = "云台类型") private int PTZType; /** * 云台类型描述字符串 */ - @Schema(description = "云台类型描述字符串") private String PTZTypeText; /** * 创建时间 */ - @Schema(description = "创建时间") private String createTime; /** * 更新时间 */ - @Schema(description = "更新时间") private String updateTime; /** @@ -171,79 +146,66 @@ public class DeviceChannelExtent { * OFF * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF */ - @Schema(description = "在线/离线, 1在线,0离线") private int status; /** * 经度 */ - @Schema(description = "经度") private double longitude; /** * 纬度 */ - @Schema(description = "纬度") private double latitude; /** * 经度 GCJ02 */ - @Schema(description = "GCJ02坐标系经度") private double longitudeGcj02; /** * 纬度 GCJ02 */ - @Schema(description = "GCJ02坐标系纬度") private double latitudeGcj02; /** * 经度 WGS84 */ - @Schema(description = "WGS84坐标系经度") private double longitudeWgs84; /** * 纬度 WGS84 */ - @Schema(description = "WGS84坐标系纬度") private double latitudeWgs84; /** * 子设备数 */ - @Schema(description = "子设备数") private int subCount; /** * 流唯一编号,存在表示正在直播 */ - @Schema(description = "流唯一编号,存在表示正在直播") private String streamId; /** * 是否含有音频 */ - @Schema(description = "是否含有音频") private boolean hasAudio; /** * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 */ - @Schema(description = "标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划") private int channelType; /** * 业务分组 */ - @Schema(description = "业务分组") private String businessGroupId; /** * GPS的更新时间 */ - @Schema(description = "GPS的更新时间") private String gpsTime; public int getId() { @@ -574,4 +536,20 @@ public class DeviceChannelExtent { public void setGpsTime(String gpsTime) { this.gpsTime = gpsTime; } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public int getDeviceOnline() { + return deviceOnline; + } + + public void setDeviceOnline(int deviceOnline) { + this.deviceOnline = deviceOnline; + } } From b16923d175812707e2e6db5f1ebfc7c6a7fc39ab Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 15:50:11 +0800 Subject: [PATCH 11/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 3 +-- .../gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index fbd9ececd..dabe1c873 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; import javax.sip.InvalidArgumentException; import javax.sip.ResponseEvent; @@ -1389,7 +1388,7 @@ public class SIPCommander implements ISIPCommander { deviceStatusXml.append("" + deviceAlarm.getChannelId() + "\r\n"); deviceStatusXml.append("" + deviceAlarm.getAlarmPriority() + "\r\n"); deviceStatusXml.append("" + deviceAlarm.getAlarmMethod() + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getAlarmTime() + "\r\n"); + deviceStatusXml.append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmTime()) + "\r\n"); deviceStatusXml.append("" + deviceAlarm.getAlarmDescription() + "\r\n"); deviceStatusXml.append("" + deviceAlarm.getLongitude() + "\r\n"); deviceStatusXml.append("" + deviceAlarm.getLatitude() + "\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index b14d497ba..64152415f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -413,8 +413,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("" + deviceAlarm.getChannelId() + "\r\n") .append("" + deviceAlarm.getAlarmPriority() + "\r\n") .append("" + deviceAlarm.getAlarmMethod() + "\r\n") - .append("" + deviceAlarm.getAlarmTime() + "\r\n") - .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmDescription()) + "\r\n") + .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmTime()) + "\r\n") + .append("" + deviceAlarm.getAlarmDescription() + "\r\n") .append("" + deviceAlarm.getLongitude() + "\r\n") .append("" + deviceAlarm.getLatitude() + "\r\n") .append("\r\n") From ec90519c90925accf157434130bcf4ac7958c17d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 8 Mar 2023 16:57:07 +0800 Subject: [PATCH 12/68] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/event/device/RequestTimeoutEventImpl.java | 5 +---- .../java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java | 2 +- .../event/request/impl/RegisterRequestProcessor.java | 2 +- .../message/notify/cmd/KeepaliveNotifyMessageHandler.java | 2 +- .../response/cmd/DeviceStatusResponseMessageHandler.java | 5 +---- .../java/com/genersoft/iot/vmp/service/IDeviceService.java | 2 +- .../genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 6 +++--- 7 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java index bffa4cb98..2008f22e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.event.device; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.service.IDeviceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; @@ -9,8 +8,6 @@ import org.springframework.stereotype.Component; import javax.sip.ClientTransaction; import javax.sip.address.SipURI; -import javax.sip.header.CallIdHeader; -import javax.sip.header.ToHeader; import javax.sip.message.Request; /** @@ -34,7 +31,7 @@ public class RequestTimeoutEventImpl implements ApplicationListener{}" ,deviceId, requestAddress); - deviceService.offline(deviceId); + deviceService.offline(deviceId, "主动注销"); } } catch (SipException | NoSuchAlgorithmException | ParseException e) { e.printStackTrace(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java index 98c1a96f2..b6c27abcf 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -94,7 +94,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp // 刷新过期任务 String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId(); // 如果三次心跳失败,则设置设备离线 - dynamicTask.startDelay(registerExpireTaskKey, ()-> deviceService.offline(device.getDeviceId()), device.getKeepaliveIntervalTime()*1000*3); + dynamicTask.startDelay(registerExpireTaskKey, ()-> deviceService.offline(device.getDeviceId(), "三次心跳失败"), device.getKeepaliveIntervalTime()*1000*3); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java index 0c0c71fb7..7dee8dcae 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java @@ -1,10 +1,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; @@ -26,7 +24,6 @@ import javax.sip.RequestEvent; import javax.sip.SipException; import javax.sip.message.Response; import java.text.ParseException; -import java.util.Objects; @Component public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { @@ -76,7 +73,7 @@ public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParen if ("ONLINE".equalsIgnoreCase(text.trim())) { deviceService.online(device); }else { - deviceService.offline(device.getDeviceId()); + deviceService.offline(device.getDeviceId(), "设备状态查询结果:" + text.trim()); } RequestMessage msg = new RequestMessage(); msg.setKey(DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + device.getDeviceId()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index 072519bd5..5ef4ef453 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -24,7 +24,7 @@ public interface IDeviceService { * 设备下线 * @param deviceId 设备编号 */ - void offline(String deviceId); + void offline(String deviceId, String reason); /** * 添加目录订阅 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index d1e7c0b40..91b4805ed 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -156,12 +156,12 @@ public class DeviceServiceImpl implements IDeviceService { // 刷新过期任务 String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId(); // 如果第一次注册那么必须在60 * 3时间内收到一个心跳,否则设备离线 - dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getKeepaliveIntervalTime() * 1000 * 3); + dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "首次注册后未能收到心跳"), device.getKeepaliveIntervalTime() * 1000 * 3); } @Override - public void offline(String deviceId) { - logger.error("[设备离线], device:{}", deviceId); + public void offline(String deviceId, String reason) { + logger.error("[设备离线],{}, device:{}", reason, deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId); if (device == null) { return; From 14c4a3c7e81e9a3898a3f301b9303c381a806932 Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: Thu, 9 Mar 2023 10:22:49 +0800 Subject: [PATCH 13/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=BD=95=E5=83=8F=E4=B8=8B=E8=BD=BD=EF=BC=8C=E7=9B=AE=E5=89=8D?= =?UTF-8?q?=E5=B7=B2=E6=B5=8B=E8=AF=95=E5=A4=A7=E5=8D=8E=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transmit/cmd/impl/SIPCommander.java | 23 ++++++++---- .../iot/vmp/service/impl/PlayServiceImpl.java | 36 +++++++++---------- .../storager/impl/RedisCatchStorageImpl.java | 12 ++++--- .../iot/vmp/utils/redis/RedisUtil.java | 8 ++++- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 5fd88282b..889b8bb2d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -541,11 +541,14 @@ public class SIPCommander implements ISIPCommander { content.append("a=downloadspeed:" + downloadSpeed + "\r\n"); content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - + logger.debug("此时请求下载信令的ssrc===>{}",ssrcInfo.getSsrc()); HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId()); // 添加订阅 + CallIdHeader newCallIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); + String callId=newCallIdHeader.getCallId(); subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { - hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); + logger.debug("sipc 添加订阅===callId {}",callId); + hookEvent.call(new InviteStreamInfo(mediaServerItem, json,callId, "rtp", ssrcInfo.getStream())); subscribe.removeSubscribe(hookSubscribe); hookSubscribe.getContent().put("regist", false); hookSubscribe.getContent().put("schema", "rtsp"); @@ -554,7 +557,7 @@ public class SIPCommander implements ISIPCommander { (MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> { logger.info("[录像]下载结束, 发送BYE"); try { - streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId()); + streamByeCmd(device, channelId, ssrcInfo.getStream(),callId); } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); @@ -562,15 +565,23 @@ public class SIPCommander implements ISIPCommander { }); }); - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); + Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,newCallIdHeader, ssrcInfo.getSsrc()); if (inviteStreamCallback != null) { - inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream())); + inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,callId, "rtp", ssrcInfo.getStream())); } sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { ResponseEvent responseEvent = (ResponseEvent) event.event; SIPResponse response = (SIPResponse) responseEvent.getResponse(); - streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); + String contentString =new String(response.getRawContent()); + int ssrcIndex = contentString.indexOf("y="); + String ssrc=ssrcInfo.getSsrc(); + if (ssrcIndex >= 0) { + ssrc = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); + } + logger.debug("接收到的下载响应ssrc====>{}",ssrcInfo.getSsrc()); + logger.debug("接收到的下载响应ssrc====>{}",ssrc); + streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), ssrcInfo.getStream(), ssrc, mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download); okEvent.response(event); }); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index c03ab62e9..8b460861b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -635,23 +635,23 @@ public class PlayServiceImpl implements IPlayService { hookCallBack.call(downloadResult); streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); }; - + InviteStreamCallback hookEvent = (InviteStreamInfo inviteStreamInfo) -> { + logger.info("收到订阅消息: " + inviteStreamInfo.getCallId()); + dynamicTask.stop(downLoadTimeOutTaskKey); + StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); + streamInfo.setStartTime(startTime); + streamInfo.setEndTime(endTime); + redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId()); + downloadResult.setCode(ErrorCode.SUCCESS.getCode()); + downloadResult.setMsg(ErrorCode.SUCCESS.getMsg()); + downloadResult.setData(streamInfo); + downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); + downloadResult.setResponse(inviteStreamInfo.getResponse()); + hookCallBack.call(downloadResult); + }; try { cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack, - inviteStreamInfo -> { - logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString()); - dynamicTask.stop(downLoadTimeOutTaskKey); - StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); - streamInfo.setStartTime(startTime); - streamInfo.setEndTime(endTime); - redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId()); - downloadResult.setCode(ErrorCode.SUCCESS.getCode()); - downloadResult.setMsg(ErrorCode.SUCCESS.getMsg()); - downloadResult.setData(streamInfo); - downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); - downloadResult.setResponse(inviteStreamInfo.getResponse()); - hookCallBack.call(downloadResult); - }, errorEvent, eventResult -> + hookEvent, errorEvent, eventResult -> { if (eventResult.type == SipSubscribe.EventResultType.response) { ResponseEvent responseEvent = (ResponseEvent) eventResult.event; @@ -690,9 +690,9 @@ public class PlayServiceImpl implements IPlayService { subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject response) -> { logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); dynamicTask.stop(downLoadTimeOutTaskKey); - // hook响应,TODO 此处待处理 -// onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, playBackCallback); -// hookCallBack.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream())); + // hook响应 + onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, hookCallBack); + hookEvent.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream())); }); } // 关闭rtp server diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 4f229d786..0997fe117 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -177,12 +177,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public boolean startDownload(StreamInfo stream, String callId) { boolean result; + String key=String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, + userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId); if (stream.getProgress() == 1) { - result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); + logger.debug("添加下载缓存==已完成下载=》{}",key); + result = RedisUtil.set(key, stream); }else { - result = RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetting.getServerId(), stream.getMediaServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60); + logger.debug("添加下载缓存==未完成下载=》{}",key); + result = RedisUtil.set(key, stream, 60*60); } return result; } @@ -617,7 +619,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { stream, callId ); - List streamInfoScan = RedisUtil.scan(key); + List streamInfoScan = RedisUtil.scan2(key); if (streamInfoScan.size() > 0) { return (StreamInfo) RedisUtil.get((String) streamInfoScan.get(0)); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java index a50553d4a..e54ed5391 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java @@ -881,7 +881,13 @@ public class RedisUtil { return new ArrayList<>(resultKeys); } - + public static List scan2(String query) { + if (redisTemplate == null) { + redisTemplate = SpringBeanFactory.getBean("redisTemplate"); + } + Set keys = redisTemplate.keys(query); + return new ArrayList<>(keys); + } // ============================== 消息发送与订阅 ============================== public static void convertAndSend(String channel, JSONObject msg) { if (redisTemplate == null) { From 273b282af6f74403a0b13d2694beb4b7f48edaf6 Mon Sep 17 00:00:00 2001 From: "gaoxun250@sina.com" Date: Fri, 10 Mar 2023 10:33:48 +0800 Subject: [PATCH 14/68] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=9B=9E=E6=94=BE?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E6=8A=A5=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/cmd/RecordInfoResponseMessageHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 6d8d8f56e..ddfff46ac 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -163,8 +163,9 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent public void releaseRequest(String deviceId, String sn,RecordInfo recordInfo){ String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; // 对数据进行排序 - Collections.sort(recordInfo.getRecordList()); - + if(recordInfo!=null && recordInfo.getRecordList()!=null) { + Collections.sort(recordInfo.getRecordList()); + } RequestMessage msg = new RequestMessage(); msg.setKey(key); msg.setData(recordInfo); From 95688e400b6974953505c159f8fbf9d65784c724 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 13 Mar 2023 09:45:00 +0800 Subject: [PATCH 15/68] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=BF=94=E5=9B=9Etoken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 15 +- .../AnonymousAuthenticationEntryPoint.java | 16 +- .../DefaultUserDetailsServiceImpl.java | 15 +- .../conf/security/InvalidSessionHandler.java | 24 --- .../security/JwtAuthenticationFilter.java | 65 +++++++++ .../iot/vmp/conf/security/JwtUtils.java | 138 ++++++++++++++++++ .../conf/security/LoginSuccessHandler.java | 13 +- .../iot/vmp/conf/security/SecurityUtils.java | 25 +++- .../vmp/conf/security/WebSecurityConfig.java | 95 +++++++----- .../iot/vmp/conf/security/dto/JwtUser.java | 53 +++++++ .../iot/vmp/vmanager/user/UserController.java | 8 +- 11 files changed, 378 insertions(+), 89 deletions(-) delete mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java create mode 100644 src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java diff --git a/pom.xml b/pom.xml index bcc3c36ae..a675c6ffc 100644 --- a/pom.xml +++ b/pom.xml @@ -216,8 +216,6 @@ 4.10.0 - - io.github.rburgst @@ -226,10 +224,17 @@ + + + + + + + - net.sf.kxml - kxml2 - 2.3.0 + org.bitbucket.b_c + jose4j + 0.9.3 diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java index 35c68d5d9..7a178d9e2 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java @@ -1,10 +1,11 @@ package com.genersoft.iot.vmp.conf.security; import com.alibaba.fastjson2.JSONObject; +import com.genersoft.iot.vmp.conf.security.dto.JwtUser; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; @@ -17,12 +18,17 @@ import java.io.IOException; * @author lin */ @Component -public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint { - - private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class); +public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { + System.err.println(e.getMessage()); + String jwt = request.getHeader(JwtUtils.getHeader()); + JwtUser jwtUser = JwtUtils.verifyToken(jwt); + String username = jwtUser.getUserName(); + UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, jwtUser.getPassword() ); + SecurityContextHolder.getContext().setAuthentication(token); + System.out.println(jwt); // 允许跨域 String origin = request.getHeader("Origin"); response.setHeader("Access-Control-Allow-Credentials", "true"); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java index 509a1e038..0cda4a5cd 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/DefaultUserDetailsServiceImpl.java @@ -1,7 +1,9 @@ package com.genersoft.iot.vmp.conf.security; -import java.time.LocalDateTime; - +import com.alibaba.excel.util.StringUtils; +import com.genersoft.iot.vmp.conf.security.dto.LoginUser; +import com.genersoft.iot.vmp.service.IUserService; +import com.genersoft.iot.vmp.storager.dao.dto.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -10,10 +12,7 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Component; -import com.alibaba.excel.util.StringUtils; -import com.genersoft.iot.vmp.conf.security.dto.LoginUser; -import com.genersoft.iot.vmp.service.IUserService; -import com.genersoft.iot.vmp.storager.dao.dto.User; +import java.time.LocalDateTime; /** * 用户登录认证逻辑 @@ -45,4 +44,8 @@ public class DefaultUserDetailsServiceImpl implements UserDetailsService { } + + + + } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java deleted file mode 100644 index f3fd06852..000000000 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/InvalidSessionHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.genersoft.iot.vmp.conf.security; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.web.session.InvalidSessionStrategy; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * 登录超时的处理 - */ -public class InvalidSessionHandler implements InvalidSessionStrategy { - - private final static Logger logger = LoggerFactory.getLogger(InvalidSessionHandler.class); - - @Override - public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse httpServletResponse) throws IOException, ServletException { - String username = request.getParameter("username"); - logger.info("[登录超时] - [{}]", username); - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java new file mode 100644 index 000000000..91709aa7c --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtAuthenticationFilter.java @@ -0,0 +1,65 @@ +package com.genersoft.iot.vmp.conf.security; + +import com.genersoft.iot.vmp.conf.security.dto.JwtUser; +import org.apache.commons.lang3.StringUtils; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; + +/** + * jwt token 过滤器 + */ + +@Component +public class JwtAuthenticationFilter extends OncePerRequestFilter { + + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { + String jwt = request.getHeader(JwtUtils.getHeader()); + // 这里如果没有jwt,继续往后走,因为后面还有鉴权管理器等去判断是否拥有身份凭证,所以是可以放行的 + // 没有jwt相当于匿名访问,若有一些接口是需要权限的,则不能访问这些接口 + if (StringUtils.isBlank(jwt)) { + chain.doFilter(request, response); + return; + } + + + JwtUser jwtUser = JwtUtils.verifyToken(jwt); + String username = jwtUser.getUserName(); + // TODO 处理各个状态 + switch (jwtUser.getStatus()){ + case EXPIRED: + response.setStatus(400); + chain.doFilter(request, response); + // 异常 + return; + case EXCEPTION: + // 过期 + response.setStatus(400); + chain.doFilter(request, response); + return; + case EXPIRING_SOON: + // 即将过期 +// return; + default: + } + +// String password = SecurityUtils.encryptPassword(jwtUser.getPassword()); +// user.setPassword(password); + + // 构建UsernamePasswordAuthenticationToken,这里密码为null,是因为提供了正确的JWT,实现自动登录 + UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, jwtUser.getPassword(), new ArrayList<>() ); + SecurityContextHolder.getContext().setAuthentication(token); + chain.doFilter(request, response); + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java new file mode 100644 index 000000000..378e5d640 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java @@ -0,0 +1,138 @@ +package com.genersoft.iot.vmp.conf.security; + +import com.genersoft.iot.vmp.conf.security.dto.JwtUser; +import org.jose4j.json.JsonUtil; +import org.jose4j.jwk.RsaJsonWebKey; +import org.jose4j.jws.AlgorithmIdentifiers; +import org.jose4j.jws.JsonWebSignature; +import org.jose4j.jwt.JwtClaims; +import org.jose4j.jwt.NumericDate; +import org.jose4j.jwt.consumer.ErrorCodes; +import org.jose4j.jwt.consumer.InvalidJwtException; +import org.jose4j.jwt.consumer.JwtConsumer; +import org.jose4j.jwt.consumer.JwtConsumerBuilder; +import org.jose4j.lang.JoseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.security.PrivateKey; +import java.time.LocalDateTime; +import java.time.ZoneOffset; + +public class JwtUtils { + + private static final Logger logger = LoggerFactory.getLogger(JwtUtils.class); + + private static final String HEADER = "Access-Token"; + private static final String AUDIENCE = "Audience"; + + private static final long EXPIRED_THRESHOLD = 10 * 60; + + private static final String keyId = "3e79646c4dbc408383a9eed09f2b85ae"; + private static final String privateKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\",\"d\":\"ed7U_k3rJ4yTk70JtRSIfjKGiEb67BO1TabcymnljKO7RU8nage84zZYuSu_XpQsHk6P1f0Gzxkicghm_Er-FrfVn2pp70Xu52z3yRd6BJUgWLDFk97ngScIyw5OiULKU9SrZk2frDpftNCSUcIgb50F8m0QAnBa_CdPsQKbuuhLv8V8tBAV7F_lAwvSBgu56wRo3hPz5dWH8YeXM7XBfQ9viFMNEKd21sP_j5C7ueUnXT66nBxe3ZJEU3iuMYM6D6dB_KW2GfZC6WmTgvGhhxJD0h7aYmfjkD99MDleB7SkpbvoODOqiQ5Epb7Nyh6kv5u4KUv2CJYtATLZkUeMkQ\",\"p\":\"uBUjWPWtlGksmOqsqCNWksfqJvMcnP_8TDYN7e4-WnHL4N-9HjRuPDnp6kHvCIEi9SEfxm7gNxlRcWegvNQr3IZCz7TnCTexXc5NOklB9OavWFla6u-s3Thn6Tz45-EUjpJr0VJMxhO-KxGmuTwUXBBp4vN6K2qV6rQNFmgkWzk\",\"q\":\"tW_i7cCec56bHkhITL_79dXHz_PLC_f7xlynmlZJGU_d6mqOKmLBNBbTMLnYW8uAFiFzWxDeDHh1o5uF0mSQR-Z1Fg35OftnpbWpy0Cbc2la5WgXQjOwtG1eLYIY2BD3-wQ1VYDBCvowr4FDi-sngxwLqvwmrJ0xjhi99O-Gzcs\",\"dp\":\"q1d5jE85Hz_6M-eTh_lEluEf0NtPEc-vvhw-QO4V-cecNpbrCBdTWBmr4dE3NdpFeJc5ZVFEv-SACyei1MBEh0ItI_pFZi4BmMfy2ELh8ptaMMkTOESYyVy8U7veDq9RnBcr5i1Nqr0rsBkA77-9T6gzdvycBZdzLYAkAmwzEvk\",\"dq\":\"q29A2K08Crs-jmp2Bi8Q_8QzvIX6wSBbwZ4ir24AO-5_HNP56IrPS0yV2GCB0pqCOGb6_Hz_koDvhtuYoqdqvMVAtMoXR3YJBUaVXPt65p4RyNmFwIPe31zHs_BNUTsXVRMw4c16mci03-Af1sEm4HdLfxAp6sfM3xr5wcnhcek\",\"qi\":\"rHPgVTyHUHuYzcxfouyBfb1XAY8nshwn0ddo81o1BccD4Z7zo5It6SefDHjxCAbcmbiCcXBSooLcY-NF5FMv3fg19UE21VyLQltHcVjRRp2tRs4OHcM8yaXIU2x6N6Z6BP2tOksHb9MOBY1wAQzFOAKg_G4Sxev6-_6ud6RISuc\"}"; + private static final String publicKeyStr = "{\"kty\":\"RSA\",\"kid\":\"3e79646c4dbc408383a9eed09f2b85ae\",\"alg\":\"RS256\",\"n\":\"gndmVdiOTSJ5et2HIeTM5f1m61x5ojLUi5HDfvr-jRrESQ5kbKuySGHVwR4QhwinpY1wQqBnwc80tx7cb_6SSqsTOoGln6T_l3k2Pb54ClVnGWiW_u1kmX78V2TZOsVmZmwtdZCMi-2zWIyAdIEXE-gncIehoAgEoq2VAhaCURbJWro_EwzzQwNmCTkDodLAx4npXRd_qSu0Ayp0txym9OFovBXBULRvk4DPiy3i_bPUmCDxzC46pTtFOe9p82uybTehZfULZtXXqRm85FL9n5zkrsTllPNAyEGhgb0RK9sE5nK1m_wNNysDyfLC4EFf1VXTrKm14XNVjc2vqLb7Mw\",\"e\":\"AQAB\"}"; + + /** + * token过期时间(分钟) + */ + public static final long expirationTime = 30; + + public static String createToken(String username, String password) { + try { + /** + * “iss” (issuer) 发行人 + * + * “sub” (subject) 主题 + * + * “aud” (audience) 接收方 用户 + * + * “exp” (expiration time) 到期时间 + * + * “nbf” (not before) 在此之前不可用 + * + * “iat” (issued at) jwt的签发时间 + */ + //Payload + JwtClaims claims = new JwtClaims(); + claims.setGeneratedJwtId(); + claims.setIssuedAtToNow(); + // 令牌将过期的时间 分钟 + claims.setExpirationTimeMinutesInTheFuture(expirationTime); + claims.setNotBeforeMinutesInThePast(0); + claims.setSubject("login"); + claims.setAudience(AUDIENCE); + //添加自定义参数,必须是字符串类型 + claims.setClaim("username", username); + claims.setClaim("password", password); + + //jws + JsonWebSignature jws = new JsonWebSignature(); + //签名算法RS256 + jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.RSA_USING_SHA256); + jws.setKeyIdHeaderValue(keyId); + jws.setPayload(claims.toJson()); + + PrivateKey privateKey = new RsaJsonWebKey(JsonUtil.parseJson(privateKeyStr)).getPrivateKey(); + jws.setKey(privateKey); + + //get token + String idToken = jws.getCompactSerialization(); + return idToken; + } catch (JoseException e) { + logger.error("[Token生成失败]: {}", e.getMessage()); + } + + return null; + } + + public static String getHeader() { + return HEADER; + } + + + public static JwtUser verifyToken(String token) { + + JwtUser jwtUser = new JwtUser(); + + try { + JwtConsumer consumer = new JwtConsumerBuilder() + .setRequireExpirationTime() + .setMaxFutureValidityInMinutes(5256000) + .setAllowedClockSkewInSeconds(30) + .setRequireSubject() + //.setExpectedIssuer("") + .setExpectedAudience(AUDIENCE) + .setVerificationKey(new RsaJsonWebKey(JsonUtil.parseJson(publicKeyStr)).getPublicKey()) + .build(); + + JwtClaims claims = consumer.processToClaims(token); + NumericDate expirationTime = claims.getExpirationTime(); + // 判断是否即将过期, 默认剩余时间小于5分钟未即将过期 + // 剩余时间 (秒) + long timeRemaining = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)) - expirationTime.getValue(); + if (timeRemaining < 5 * 60) { + jwtUser.setStatus(JwtUser.TokenStatus.EXPIRING_SOON); + }else { + jwtUser.setStatus(JwtUser.TokenStatus.NORMAL); + } + + String username = (String) claims.getClaimValue("username"); + String password = (String) claims.getClaimValue("password"); + jwtUser.setUserName(username); + jwtUser.setPassword(password); + + return jwtUser; + } catch (InvalidJwtException e) { + if (e.hasErrorCode(ErrorCodes.EXPIRED)) { + jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); + }else { + jwtUser.setStatus(JwtUser.TokenStatus.EXCEPTION); + } + return jwtUser; + }catch (Exception e) { + logger.error("[Token解析失败]: {}", e.getMessage()); + jwtUser.setStatus(JwtUser.TokenStatus.EXPIRED); + return jwtUser; + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java b/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java index 2d7e8a1b0..d26342ef5 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/LoginSuccessHandler.java @@ -21,7 +21,16 @@ public class LoginSuccessHandler implements AuthenticationSuccessHandler { @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { - String username = request.getParameter("username"); - logger.info("[登录成功] - [{}]", username); +// String username = request.getParameter("username"); +// httpServletResponse.setContentType("application/json;charset=UTF-8"); +// // 生成JWT,并放置到请求头中 +// String jwt = JwtUtils.createToken(authentication.getName(), ); +// httpServletResponse.setHeader(JwtUtils.getHeader(), jwt); +// ServletOutputStream outputStream = httpServletResponse.getOutputStream(); +// outputStream.write(JSON.toJSONString(ErrorCode.SUCCESS).getBytes(StandardCharsets.UTF_8)); +// outputStream.flush(); +// outputStream.close(); + +// logger.info("[登录成功] - [{}]", username); } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java index fd29d1128..76f116204 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/SecurityUtils.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.conf.security; import com.genersoft.iot.vmp.conf.security.dto.LoginUser; +import com.genersoft.iot.vmp.storager.dao.dto.User; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -9,6 +10,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import javax.security.sasl.AuthenticationException; +import java.time.LocalDateTime; public class SecurityUtils { @@ -25,10 +27,16 @@ public class SecurityUtils { public static LoginUser login(String username, String password, AuthenticationManager authenticationManager) throws AuthenticationException { //使用security框架自带的验证token生成器 也可以自定义。 UsernamePasswordAuthenticationToken token =new UsernamePasswordAuthenticationToken(username,password); - Authentication authenticate = authenticationManager.authenticate(token); - SecurityContextHolder.getContext().setAuthentication(authenticate); - LoginUser user = (LoginUser) authenticate.getPrincipal(); - return user; +// Authentication authenticate = authenticationManager.authenticate(token); +// SecurityContextHolder.getContext().setAuthentication(authenticate); + SecurityContextHolder.getContext().setAuthentication(token); + + +// LoginUser user = (LoginUser) authenticate.getPrincipal(); + User user = new User(); + user.setUsername(username); + LoginUser loginUser = new LoginUser(user, LocalDateTime.now()); + return loginUser; } /** @@ -49,8 +57,13 @@ public class SecurityUtils { if(authentication!=null){ Object principal = authentication.getPrincipal(); if(principal!=null && !"anonymousUser".equals(principal)){ - LoginUser user = (LoginUser) authentication.getPrincipal(); - return user; +// LoginUser user = (LoginUser) authentication.getPrincipal(); + + String username = (String) principal; + User user = new User(); + user.setUsername(username); + LoginUser loginUser = new LoginUser(user, LocalDateTime.now()); + return loginUser; } } return null; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java index cce0d11c5..c700b8c1b 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java @@ -15,7 +15,9 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import java.util.List; @@ -56,22 +58,14 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { */ @Autowired private AnonymousAuthenticationEntryPoint anonymousAuthenticationEntryPoint; -// /** -// * 超时处理 -// */ -// @Autowired -// private InvalidSessionHandler invalidSessionHandler; + @Autowired + private JwtAuthenticationFilter jwtAuthenticationFilter; -// /** -// * 顶号处理 -// */ -// @Autowired -// private SessionInformationExpiredHandler sessionInformationExpiredHandler; -// /** -// * 登录用户没有权限访问资源 -// */ -// @Autowired -// private LoginUserAccessDeniedHandler accessDeniedHandler; +// @Bean +// JwtAuthenticationFilter jwtAuthenticationFilter() throws Exception { +// JwtAuthenticationFilter jwtAuthenticationFilter = new JwtAuthenticationFilter(authenticationManager()); +// return jwtAuthenticationFilter; +// } /** @@ -126,35 +120,56 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http.cors().and().csrf().disable(); - // 设置允许添加静态文件 - http.headers().contentTypeOptions().disable(); - http.authorizeRequests() - // 放行接口 + http.headers().contentTypeOptions().disable() + .and().cors() + .and().csrf().disable() + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS) + + // 配置拦截规则 + .and() + .authorizeRequests() .antMatchers("/api/user/login","/index/hook/**").permitAll() - // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() - // 异常处理(权限拒绝、登录失效等) - .and().exceptionHandling() - //匿名用户访问无权限资源时的异常处理 + // 异常处理器 + .and() + .exceptionHandling() .authenticationEntryPoint(anonymousAuthenticationEntryPoint) -// .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源 - // 登入 允许所有用户 - .and().formLogin().permitAll() - //登录成功处理逻辑 - .successHandler(loginSuccessHandler) - //登录失败处理逻辑 - .failureHandler(loginFailureHandler) - // 登出 - .and().logout().logoutUrl("/api/user/logout").permitAll() - //登出成功处理逻辑 - .logoutSuccessHandler(logoutHandler) - .deleteCookies("JSESSIONID") - // 会话管理 -// .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理 -// .maximumSessions(1)//同一账号同时登录最大用户数 -// .expiredSessionStrategy(sessionInformationExpiredHandler) // 顶号处理 +// .accessDeniedHandler(jwtAccessDeniedHandler) + // 配置自定义的过滤器 +// .and() +// .addFilter(jwtAuthenticationFilter) + // 验证码过滤器放在UsernamePassword过滤器之前 +// .addFilterBefore(captchaFilter, UsernamePasswordAuthenticationFilter.class) ; + http.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); +// // 设置允许添加静态文件 +// http.headers().contentTypeOptions().disable(); +// http.authorizeRequests() +// // 放行接口 +// .antMatchers("/api/user/login","/index/hook/**").permitAll() +// // 除上面外的所有请求全部需要鉴权认证 +// .anyRequest().authenticated() +// // 禁用session +// .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) +// // 异常处理(权限拒绝、登录失效等) +// .and().exceptionHandling() +// // 匿名用户访问无权限资源时的异常处理 +// .authenticationEntryPoint(anonymousAuthenticationEntryPoint) +// // 登录 允许所有用户 +// .and().formLogin() +// // 登录成功处理逻辑 在这里给出JWT +// .successHandler(loginSuccessHandler) +// // 登录失败处理逻辑 +// .failureHandler(loginFailureHandler) +// // 登出 +// .and().logout().logoutUrl("/api/user/logout").permitAll() +// // 登出成功处理逻辑 +// .logoutSuccessHandler(logoutHandler) +// // 配置自定义的过滤器 +// .and() +// .addFilter(jwtAuthenticationFilter()) +// ; } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java new file mode 100644 index 000000000..1639d1fc2 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/JwtUser.java @@ -0,0 +1,53 @@ +package com.genersoft.iot.vmp.conf.security.dto; + +public class JwtUser { + + public enum TokenStatus{ + /** + * 正常的使用状态 + */ + NORMAL, + /** + * 过期而失效 + */ + EXPIRED, + /** + * 即将过期 + */ + EXPIRING_SOON, + /** + * 异常 + */ + EXCEPTION + } + + private String userName; + + private String password; + + private TokenStatus status; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public TokenStatus getStatus() { + return status; + } + + public void setStatus(TokenStatus status) { + this.status = status; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 127e83b8a..826dd51e7 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.vmanager.user; import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.conf.security.JwtUtils; import com.genersoft.iot.vmp.conf.security.SecurityUtils; import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.service.IRoleService; @@ -21,6 +22,8 @@ import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import javax.security.sasl.AuthenticationException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; @Tag(name = "用户管理") @@ -43,7 +46,7 @@ public class UserController { @Operation(summary = "登录") @Parameter(name = "username", description = "用户名", required = true) @Parameter(name = "password", description = "密码(32位md5加密)", required = true) - public LoginUser login(@RequestParam String username, @RequestParam String password){ + public LoginUser login(HttpServletRequest request, HttpServletResponse response, @RequestParam String username, @RequestParam String password){ LoginUser user = null; try { user = SecurityUtils.login(username, password, authenticationManager); @@ -52,6 +55,9 @@ public class UserController { } if (user == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误"); + }else { + String jwt = JwtUtils.createToken(username, password); + response.setHeader(JwtUtils.getHeader(), jwt); } return user; } From bdcd006a7ee9fd4637c7ad467df7dabee1853101 Mon Sep 17 00:00:00 2001 From: xiaoQQya Date: Mon, 13 Mar 2023 17:42:39 +0800 Subject: [PATCH 16/68] =?UTF-8?q?fix(jessibuca):=20=E4=BF=AE=E5=A4=8D=20je?= =?UTF-8?q?ssibuca=20=E7=BB=84=E4=BB=B6=E6=88=AA=E5=9B=BE=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/common/jessibuca.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web_src/src/components/common/jessibuca.vue b/web_src/src/components/common/jessibuca.vue index 4049721c0..a681729a3 100644 --- a/web_src/src/components/common/jessibuca.vue +++ b/web_src/src/components/common/jessibuca.vue @@ -12,7 +12,7 @@ {{ kBps }} kb/s - @@ -243,6 +243,11 @@ export default { this.err = ""; this.performance = ""; }, + screenshot: function () { + if (jessibucaPlayer[this._uid]) { + jessibucaPlayer[this._uid].screenshot(); + } + }, mute: function () { if (jessibucaPlayer[this._uid]) { jessibucaPlayer[this._uid].mute(); From 84595e0c8402f4ce83f6a2c3431a671462ddeebb Mon Sep 17 00:00:00 2001 From: xiaoQQya Date: Mon, 13 Mar 2023 17:53:50 +0800 Subject: [PATCH 17/68] =?UTF-8?q?perf(jessibuca):=20=E5=8D=87=E7=BA=A7=20j?= =?UTF-8?q?essibuca=202023-03-8=20v3.1.28=20=E7=89=88=E6=9C=AC,=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20jessibuca=20=E5=8F=82=E6=95=B0=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=A1=AC=E8=A7=A3=E7=A0=81=E4=BC=98=E5=8C=96=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E9=BB=91=E5=B1=8F=E9=97=AE=E9=A2=98,=20https=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E4=BD=BF=E7=94=A8=20WCS=20=E7=A1=AC?= =?UTF-8?q?=E8=A7=A3=E7=A0=81,=20http=20=E7=8E=AF=E5=A2=83=E4=B8=8B?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20MSE=20=E7=A1=AC=E8=A7=A3=E7=A0=81,=20H265?= =?UTF-8?q?=20=E8=A7=86=E9=A2=91=E8=87=AA=E5=8A=A8=E4=BD=BF=E7=94=A8=20was?= =?UTF-8?q?m=20=E8=BD=AF=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/common/jessibuca.vue | 55 ++++++++++++++------ web_src/static/js/jessibuca/decoder.js | 2 +- web_src/static/js/jessibuca/decoder.wasm | Bin 1228067 -> 1050314 bytes web_src/static/js/jessibuca/jessibuca.d.ts | 4 +- web_src/static/js/jessibuca/jessibuca.js | 2 +- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/web_src/src/components/common/jessibuca.vue b/web_src/src/components/common/jessibuca.vue index a681729a3..771507614 100644 --- a/web_src/src/components/common/jessibuca.vue +++ b/web_src/src/components/common/jessibuca.vue @@ -1,5 +1,6 @@ diff --git a/web_src/src/main.js b/web_src/src/main.js index 91bbd4751..a6c6e1bf7 100644 --- a/web_src/src/main.js +++ b/web_src/src/main.js @@ -1,5 +1,6 @@ import Vue from 'vue'; import App from './App.vue'; + Vue.config.productionTip = false; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; @@ -10,15 +11,16 @@ import echarts from 'echarts'; import VCharts from 'v-charts'; import VueClipboard from 'vue-clipboard2'; -import { Notification } from 'element-ui'; +import {Notification} from 'element-ui'; import Fingerprint2 from 'fingerprintjs2'; import VueClipboards from 'vue-clipboards'; import Contextmenu from "vue-contextmenujs" +import userService from "./components/service/UserService" // 生成唯一ID -Fingerprint2.get(function(components) { - const values = components.map(function(component,index) { +Fingerprint2.get(function (components) { + const values = components.map(function (component, index) { if (index === 0) { //把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样 return component.value.replace(/\bNetType\/\w+\b/, ''); } @@ -42,13 +44,17 @@ Vue.prototype.$notify = Notification; Vue.use(Contextmenu); Vue.use(VCharts); -axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl?window.baseUrl:""); +axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl ? window.baseUrl : ""); axios.defaults.withCredentials = true; // api 返回401自动回登陆页面 -axios.interceptors.response.use(function (response) { +axios.interceptors.response.use((response) => { // 对响应数据做点什么 + let token = response.headers["access-token"]; + if (token) { + userService.setToken(token) + } return response; -}, function (error) { +}, (error) => { // 对响应错误做点什么 if (error.response.status === 401) { console.log("Received 401 Response") @@ -56,10 +62,22 @@ axios.interceptors.response.use(function (response) { } return Promise.reject(error); }); +axios.interceptors.request.use( + config => { + if (userService.getToken() != null && config.url !== "/api/user/login") { + config.headers['access-token'] = `${userService.getToken()}`; + } + return config; + }, + error => { + return Promise.reject(error); + } +); + Vue.prototype.$axios = axios; Vue.prototype.$cookies.config(60*30); new Vue({ - router: router, - render: h => h(App), + router: router, + render: h => h(App), }).$mount('#app') From efbc3a31c07e87f4d74b1fbbc28c3ab16aaa650a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 15 Mar 2023 22:56:47 +0800 Subject: [PATCH 21/68] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E4=B8=AD=E6=90=BA=E5=B8=A6token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++-- doc/_content/introduction/deployment.md | 23 +++++++++++++++---- .../AnonymousAuthenticationEntryPoint.java | 1 - .../iot/vmp/conf/security/dto/LoginUser.java | 9 ++++++++ .../iot/vmp/vmanager/user/UserController.java | 23 ++++--------------- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index eb6859b22..bb8161159 100644 --- a/README.md +++ b/README.md @@ -99,15 +99,16 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 支持接口鉴权 - [X] 云端录像,推流/代理/国标视频均可以录制在云端服务器,支持预览和下载 - [X] 支持打包可执行jar和war +- [X] 支持跨域请求,支持前后端分离部署 # 遇到问题如何解决 国标最麻烦的地方在于设备的兼容性,所以需要大量的设备来测试,目前作者手里的设备有限,再加上作者水平有限,所以遇到问题在所难免; -1. 查看wiki,仔细的阅读可以帮你避免几乎所有的问题 +1. 查看文档网站,仔细的阅读可以帮你避免几乎所有的问题 2. 搜索issues,这里有大部分的答案 3. 加QQ群(901799015),这里有大量热心的小伙伴,但是前提新希望你已经仔细阅读了wiki和搜索了issues。 4. 你可以请作者为你解答,但是我不是免费的。 -5. 你可以把遇到问题的设备寄给我,可以更容易的复现问题。 +5. 你可以把遇到问题的设备寄给我,可以更容易的兼容设备和解决问题。 # 使用帮助 QQ群: 901799015, ZLM使用文档[https://github.com/ZLMediaKit/ZLMediaKit](https://github.com/ZLMediaKit/ZLMediaKit) diff --git a/doc/_content/introduction/deployment.md b/doc/_content/introduction/deployment.md index 0ee803d87..804c9fc1f 100644 --- a/doc/_content/introduction/deployment.md +++ b/doc/_content/introduction/deployment.md @@ -21,19 +21,34 @@ 4. WVP-PRO与ZLM支持分开部署,但是wvp-pro-assist必须与zlm部署在同一台主机; 5. 生产环境按需开放端口,但是建议修改默认端口,尤其是5060端口,易受到攻击; 6. zlm使用docker部署的情况,要求端口映射一致,比如映射5060,应将外部端口也映射为5060端口; -7. 启动服务,以linux为例 -**启动WVP-PRO** -jar包: +7. 启动服务,以linux为例 +### 启动WVP-PRO +**jar包:** ```shell nohup java -jar wvp-pro-*.jar & ``` -war包: +**war包:** 下载Tomcat后将war包放入webapps中,启动Tomcat以解压war包,停止Tomcat后,删除ROOT目录以及war包,将解压后的war包目录重命名为ROOT,将配置文件中的Server.port配置为与Tomcat端口一致 然后启动Tomcat。 **启动ZLM** ```shell nohup ./MediaServer -d -m 3 & ``` +### 前后端分离部署 +前后端部署目前在最新的版本已经支持,请使用3月15日之后的版本部署 +前端编译后的文件在`src/main/resources/static`中,将此目录下的文件部署。 +前后端分离部署最大的问题是跨域的解决,之前版本使用cookie完成登录流程,而cookie是不可以在复杂跨域中使用的。所以当前版本使用JWT生成的TOKEN作为认证凭据, +部署前端后需要在wvp中配置前端访问的地址以完成跨域流程。 +加入你的服务有公网域名为xxx.com,公网IP为11.11.11.11, 那么你可以在wvp中这样配置: +```yaml +user-settings: + # 跨域配置,配置你访问前端页面的地址即可, 可以配置多个 + allowed-origins: + - http://xxx.com:8008 + - http://11.11.11.11:8008 +``` +配置不是必须的,你使用哪个ip/域名访问就配置哪个即可。修改配置后重启wvp以使配置生效。 + [接入设备](./_content/ability/device.md) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java index 3f70b794f..7d617cc30 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/AnonymousAuthenticationEntryPoint.java @@ -22,7 +22,6 @@ public class AnonymousAuthenticationEntryPoint implements AuthenticationEntry @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { - System.err.println(e.getMessage()); String jwt = request.getHeader(JwtUtils.getHeader()); JwtUser jwtUser = JwtUtils.verifyToken(jwt); String username = jwtUser.getUserName(); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java index 45e03bc79..61bd6fa6f 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java @@ -19,6 +19,8 @@ public class LoginUser implements UserDetails, CredentialsContainer { */ private User user; + private String accessToken; + /** * 登录时间 @@ -99,4 +101,11 @@ public class LoginUser implements UserDetails, CredentialsContainer { } + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 035f3807b..d23b03c49 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -42,7 +42,9 @@ public class UserController { @GetMapping("/login") @PostMapping("/login") - @Operation(summary = "登录") + @Operation(summary = "登录", description = "登录成功后返回AccessToken, 可以从返回值获取到也可以从响应头中获取到," + + "后续的请求需要添加请求头 'access-token'或者放在参数里") + @Parameter(name = "username", description = "用户名", required = true) @Parameter(name = "password", description = "密码(32位md5加密)", required = true) public LoginUser login(HttpServletRequest request, HttpServletResponse response, @RequestParam String username, @RequestParam String password){ @@ -57,28 +59,11 @@ public class UserController { }else { String jwt = JwtUtils.createToken(username, password); response.setHeader(JwtUtils.getHeader(), jwt); + user.setAccessToken(jwt); } return user; } -// @GetMapping("/logout") -// @PostMapping("/logout") -// @Operation(summary = "登出") -// public LoginUser logout(){ -// LoginUser user; -// try { -// user = SecurityUtils.login(username, password, authenticationManager); -// } catch (AuthenticationException e) { -// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); -// } -// if (user == null) { -// throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误"); -// }else { -// String jwt = JwtUtils.createToken(username, password); -// response.setHeader(JwtUtils.getHeader(), jwt); -// } -// return user; -// } @PostMapping("/changePassword") @Operation(summary = "修改密码") From bb3f219a61862fe0eb6ee6f79139108c2073a6d8 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 15 Mar 2023 23:28:22 +0800 Subject: [PATCH 22/68] =?UTF-8?q?=E5=9B=BD=E6=A0=87=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E7=9B=AE=E5=BD=95=E6=95=B0=E6=8D=AE=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=91=E5=8F=B0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index b9d2c4cf0..96859353d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -225,6 +225,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { catalogXml.append("" + channel.getIpAddress() + "\r\n"); catalogXml.append("" + channel.getPort() + "\r\n"); catalogXml.append("" + channel.getPort() + "\r\n"); + catalogXml.append("" + channel.getPTZType() + "\r\n"); catalogXml.append("" + (channel.getStatus() == 1?"ON":"OFF") + "\r\n"); catalogXml.append("" + (channel.getLongitudeWgs84() != 0? channel.getLongitudeWgs84():channel.getLongitude()) From 71cf9852ecc5d77b956d6d3050a7670a46cf3915 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 16 Mar 2023 09:18:27 +0800 Subject: [PATCH 23/68] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=88=86=E7=A6=BB=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_content/introduction/deployment.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/_content/introduction/deployment.md b/doc/_content/introduction/deployment.md index 804c9fc1f..127454f5e 100644 --- a/doc/_content/introduction/deployment.md +++ b/doc/_content/introduction/deployment.md @@ -38,8 +38,9 @@ nohup ./MediaServer -d -m 3 & 前后端部署目前在最新的版本已经支持,请使用3月15日之后的版本部署 前端编译后的文件在`src/main/resources/static`中,将此目录下的文件部署。 前后端分离部署最大的问题是跨域的解决,之前版本使用cookie完成登录流程,而cookie是不可以在复杂跨域中使用的。所以当前版本使用JWT生成的TOKEN作为认证凭据, -部署前端后需要在wvp中配置前端访问的地址以完成跨域流程。 -加入你的服务有公网域名为xxx.com,公网IP为11.11.11.11, 那么你可以在wvp中这样配置: +部署前端后需要在wvp中配置前端访问的地址以完成跨域流程。 +**配置前端服务器** +1. 假如你的服务有公网域名为xxx.com,公网IP为11.11.11.11, 那么你可以在wvp中这样配置: ```yaml user-settings: # 跨域配置,配置你访问前端页面的地址即可, 可以配置多个 @@ -48,7 +49,10 @@ user-settings: - http://11.11.11.11:8008 ``` 配置不是必须的,你使用哪个ip/域名访问就配置哪个即可。修改配置后重启wvp以使配置生效。 - +2. 在`src/main/resources/static/static/js/config.js`下配置服务器的地址,也就是wvp服务的地址 +```javascript +window.baseUrl = "http://192.168.1.234:18080" +``` [接入设备](./_content/ability/device.md) From 5cd3e0e919d427c68d2e21be20f27af9b24622b0 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 16 Mar 2023 09:32:21 +0800 Subject: [PATCH 24/68] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=88=86=E7=A6=BB=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_content/introduction/deployment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/_content/introduction/deployment.md b/doc/_content/introduction/deployment.md index 127454f5e..76ef78925 100644 --- a/doc/_content/introduction/deployment.md +++ b/doc/_content/introduction/deployment.md @@ -38,7 +38,7 @@ nohup ./MediaServer -d -m 3 & 前后端部署目前在最新的版本已经支持,请使用3月15日之后的版本部署 前端编译后的文件在`src/main/resources/static`中,将此目录下的文件部署。 前后端分离部署最大的问题是跨域的解决,之前版本使用cookie完成登录流程,而cookie是不可以在复杂跨域中使用的。所以当前版本使用JWT生成的TOKEN作为认证凭据, -部署前端后需要在wvp中配置前端访问的地址以完成跨域流程。 +部署前端后需要在wvp中配置前端访问的地址以完成跨域流程。 **配置前端服务器** 1. 假如你的服务有公网域名为xxx.com,公网IP为11.11.11.11, 那么你可以在wvp中这样配置: ```yaml From 85c5fafda53f21697499ff0587ff6dc0f2b00f0a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 16 Mar 2023 09:34:20 +0800 Subject: [PATCH 25/68] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=88=86=E7=A6=BB=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/_content/introduction/deployment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/_content/introduction/deployment.md b/doc/_content/introduction/deployment.md index 76ef78925..188efb049 100644 --- a/doc/_content/introduction/deployment.md +++ b/doc/_content/introduction/deployment.md @@ -51,8 +51,8 @@ user-settings: 配置不是必须的,你使用哪个ip/域名访问就配置哪个即可。修改配置后重启wvp以使配置生效。 2. 在`src/main/resources/static/static/js/config.js`下配置服务器的地址,也就是wvp服务的地址 ```javascript -window.baseUrl = "http://192.168.1.234:18080" +window.baseUrl = "http://xxx.com:18080" ``` - +`这里的地址是需要客户电脑能访问到的,因为请求是客户端电脑发起,与代理不同` [接入设备](./_content/ability/device.md) From eec4e347d74d8f876d1edff837038d7ad313580d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 16 Mar 2023 20:19:00 +0800 Subject: [PATCH 26/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E4=BF=9D=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java index c7105698f..9bf1a3ade 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java @@ -257,8 +257,10 @@ public class ZLMRTPServerFactory { logger.info("[上级点播] {}->监听端口到期继续保持监听", ssrc); keepPort(serverItem, ssrc); }); + logger.info("[上级点播] {}->监听端口: {}", ssrc, localPort); + }else { + logger.info("[上级点播] 监听端口失败: {}", ssrc); } - logger.info("[上级点播] {}->监听端口: {}", ssrc, localPort); return localPort; } From 72b9239c5a1028ffb3f388169ba34cd21f40d71d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 16 Mar 2023 20:32:22 +0800 Subject: [PATCH 27/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java | 2 +- .../iot/vmp/service/redisMsg/RedisAlarmMsgListener.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java index 9bf1a3ade..c627215ec 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java @@ -221,7 +221,7 @@ public class ZLMRTPServerFactory { if (localPort == 0) { return null; } - } + }alarm SendRtpItem sendRtpItem = new SendRtpItem(); sendRtpItem.setIp(ip); sendRtpItem.setPort(port); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 43528eccf..6eacd3947 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -85,6 +85,7 @@ public class RedisAlarmMsgListener implements MessageListener { if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { try { + deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); @@ -97,6 +98,7 @@ public class RedisAlarmMsgListener implements MessageListener { if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { try { + deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); @@ -110,6 +112,7 @@ public class RedisAlarmMsgListener implements MessageListener { if (devices.size() > 0) { for (Device device : devices) { try { + deviceAlarm.setChannelId(device.getDeviceId()); commander.sendAlarmMessage(device, deviceAlarm); } catch (InvalidArgumentException | SipException | ParseException e) { logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); From c3ce2bc5d069ba57309567aee4ae418bc0cf75ed Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 17 Mar 2023 13:22:05 +0800 Subject: [PATCH 28/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BB=A5=E5=8F=8A=E7=BA=A7=E8=81=94=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/common/StreamInfo.java | 2 +- .../transmit/cmd/impl/SIPCommander.java | 2 - .../cmd/impl/SIPCommanderFroPlatform.java | 22 ++++++-- .../request/SIPRequestProcessorParent.java | 4 +- .../request/impl/InviteRequestProcessor.java | 36 ++++++------- .../request/impl/NotifyRequestProcessor.java | 8 +-- .../impl/RegisterRequestProcessor.java | 2 +- .../impl/SubscribeRequestProcessor.java | 6 +-- .../notify/cmd/AlarmNotifyMessageHandler.java | 9 +++- .../MobilePositionNotifyMessageHandler.java | 5 +- .../cmd/DeviceInfoQueryMessageHandler.java | 17 ++++-- .../cmd/CatalogResponseMessageHandler.java | 3 +- .../MobilePositionResponseMessageHandler.java | 2 +- .../cmd/RecordInfoResponseMessageHandler.java | 3 +- .../vmp/media/zlm/ZLMRTPServerFactory.java | 2 +- .../service/impl/StreamProxyServiceImpl.java | 2 +- .../redisMsg/RedisAlarmMsgListener.java | 3 +- .../redisMsg/RedisGbPlayMsgListener.java | 3 +- .../service/redisMsg/RedisGpsMsgListener.java | 3 +- .../RedisPushStreamResponseListener.java | 3 +- .../RedisPushStreamStatusListMsgListener.java | 3 +- .../RedisPushStreamStatusMsgListener.java | 3 +- .../redisMsg/RedisStreamMsgListener.java | 3 +- .../impl/VideoManagerStorageImpl.java | 4 +- .../iot/vmp/utils/redis/RedisUtil.java | 52 +++++++++---------- .../streamPush/StreamPushController.java | 2 +- .../src/components/dialog/platformEdit.vue | 2 +- 27 files changed, 117 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java index 8311745c2..42ff5bada 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java @@ -520,7 +520,7 @@ public class StreamInfo implements Serializable, Cloneable{ try{ instance = (StreamInfo)super.clone(); }catch(CloneNotSupportedException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return instance; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index ecd23202e..8a55cceaf 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -937,8 +937,6 @@ public class SIPCommander implements ISIPCommander { catalogXml.append("" + device.getDeviceId() + "\r\n"); catalogXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index 96859353d..dc5c31ad5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.utils.GitUtil; import gov.nist.javax.sip.message.MessageFactoryImpl; import gov.nist.javax.sip.message.SIPRequest; import org.slf4j.Logger; @@ -65,6 +66,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @Autowired private DynamicTask dynamicTask; + @Autowired + private GitUtil gitUtil; + @Override public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { register(parentPlatform, null, null, errorEvent, okEvent, false, true); @@ -266,6 +270,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { String callId = request.getCallIdHeader().getCallId(); + logger.info("[命令发送] 国标级联{} 目录查询回复: 共{}条,已发送{}条", parentPlatform.getServerGBId(), + channels.size(), Math.min(index + parentPlatform.getCatalogGroup(), channels.size())); + logger.debug(catalogXml); if (sendAfterResponse) { // 默认按照收到200回复后发送下一条, 如果超时收不到回复,就以30毫秒的间隔直接发送。 dynamicTask.startDelay(timeoutTaskKey, ()->{ @@ -317,17 +324,22 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { if (parentPlatform == null) { return; } + String deviceId = device == null ? parentPlatform.getDeviceGBId() : device.getDeviceId(); + String deviceName = device == null ? parentPlatform.getName() : device.getName(); + String manufacturer = device == null ? "WVP-28181-PRO" : device.getManufacturer(); + String model = device == null ? "platform" : device.getModel(); + String firmware = device == null ? gitUtil.getBuildVersion() : device.getFirmware(); String characterSet = parentPlatform.getCharacterSet(); StringBuffer deviceInfoXml = new StringBuffer(600); deviceInfoXml.append("\r\n"); deviceInfoXml.append("\r\n"); deviceInfoXml.append("DeviceInfo\r\n"); deviceInfoXml.append("" +sn + "\r\n"); - deviceInfoXml.append("" + device.getDeviceId() + "\r\n"); - deviceInfoXml.append("" + device.getName() + "\r\n"); - deviceInfoXml.append("" + device.getManufacturer() + "\r\n"); - deviceInfoXml.append("" + device.getModel() + "\r\n"); - deviceInfoXml.append("" + device.getFirmware() + "\r\n"); + deviceInfoXml.append("" + deviceId + "\r\n"); + deviceInfoXml.append("" + deviceName + "\r\n"); + deviceInfoXml.append("" + manufacturer + "\r\n"); + deviceInfoXml.append("" + model + "\r\n"); + deviceInfoXml.append("" + firmware + "\r\n"); deviceInfoXml.append("OK\r\n"); deviceInfoXml.append("\r\n"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 55c98febe..0a7eb2c9a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -45,7 +45,7 @@ public abstract class SIPRequestProcessorParent { try { return SipFactory.getInstance().createHeaderFactory(); } catch (PeerUnavailableException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return null; } @@ -54,7 +54,7 @@ public abstract class SIPRequestProcessorParent { try { return SipFactory.getInstance().createMessageFactory(); } catch (PeerUnavailableException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return null; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index fd9e0c606..1a6358b03 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -406,12 +406,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements }, 60 * 1000); responseSdpAck(request, content.toString(), platform); - } catch (SipException e) { - e.printStackTrace(); - } catch (InvalidArgumentException e) { - e.printStackTrace(); - } catch (ParseException e) { - e.printStackTrace(); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 国标级联 回复SdpAck", e); } }; SipSubscribe.Event errorEvent = ((event) -> { @@ -420,7 +416,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); } catch (ParseException | SipException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } }); sendRtpItem.setApp("rtp"); @@ -531,7 +527,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } catch (SdpParseException e) { logger.error("sdp解析错误", e); } catch (SdpException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } @@ -686,11 +682,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); responseAck(request, Response.REQUEST_TIMEOUT); // 超时 } catch (SipException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (InvalidArgumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } }, userSetting.getPlatformPlayTimeout()); // 添加监听 @@ -709,11 +705,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.BUSY_HERE); } catch (SipException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (InvalidArgumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return; } @@ -771,11 +767,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { responseAck(request, Response.BUSY_HERE); } catch (SipException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (InvalidArgumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return; } @@ -851,11 +847,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements try { return responseSdpAck(request, content.toString(), platform); } catch (SipException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (InvalidArgumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } return null; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index b79b8002a..7366f3002 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -93,7 +93,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements try { responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); }catch (SipException | InvalidArgumentException | ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } boolean runed = !taskQueue.isEmpty(); taskQueue.offer(new HandlerCatchData(evt, null, null)); @@ -225,7 +225,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements jsonObject.put("speed", mobilePosition.getSpeed()); redisCatchStorage.sendMobilePositionMsg(jsonObject); } catch (DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } @@ -335,7 +335,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements publisher.deviceAlarmEventPublish(deviceAlarm); } } catch (DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } @@ -428,7 +428,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } } } catch (DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index 80744c0bf..d307941fa 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -185,7 +185,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen deviceService.offline(deviceId, "主动注销"); } } catch (SipException | NoSuchAlgorithmException | ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index d32d194f5..52a0f5d50 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -96,7 +96,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); } } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } @@ -149,7 +149,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } } catch (SipException | InvalidArgumentException | ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } @@ -195,7 +195,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); } } catch (SipException | InvalidArgumentException | ParseException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index e89e88abe..ddbad1da8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -186,9 +186,13 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme // 发送给平台的报警信息。 发送redis通知 logger.info("[发送给平台的报警信息]内容:{}", JSONObject.toJSONString(deviceAlarm)); AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); - alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); + if (deviceAlarm.getAlarmMethod() != null) { + alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); + } alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); - alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); + if (deviceAlarm.getAlarmType() != null) { + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); + } alarmChannelMessage.setGbId(channelId); redisCatchStorage.sendAlarmMsg(alarmChannelMessage); continue; @@ -204,6 +208,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme publisher.deviceAlarmEventPublish(deviceAlarm); } }catch (Exception e) { + logger.error("未处理的异常 ", e); logger.warn("[收到报警通知] 发现未处理的异常, {}\r\n{}",e.getMessage(), evt.getRequest()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index 40d1dcc90..1f0bdf142 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -149,9 +149,10 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen redisCatchStorage.sendMobilePositionMsg(jsonObject); } catch (DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } catch (Exception e) { - logger.warn("[移动位置通知] 发现未处理的异常, {}\r\n{}",e.getMessage(), evt.getRequest()); + logger.warn("[移动位置通知] 发现未处理的异常, \r\n{}", evt.getRequest()); + logger.error("[移动位置通知] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java index 0faf29452..8b774e100 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java @@ -60,17 +60,24 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp return; } String sn = rootElement.element("SN").getText(); + /*根据WVP原有的数据结构,设备和通道是分开放置,设备信息都是存放在设备表里,通道表里的设备信息不可作为真实信息处理 大部分NVR/IPC设备对他的通道信息实现都是返回默认的值没有什么参考价值。NVR/IPC通道我们统一使用设备表的设备信息来作为返回。 我们这里使用查询数据库的方式来实现这个设备信息查询的功能,在其他地方对设备信息更新达到正确的目的。*/ + String channelId = getText(rootElement, "DeviceID"); - Device device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); - if (device ==null){ - logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); - return; + // 查询这是通道id还是设备id + Device device = null; + // 如果id指向平台的国标编号,那么就是查询平台的信息 + if (!parentPlatform.getDeviceGBId().equals(channelId)) { + device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); + if (device ==null){ + logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); + return; + } } try { - cmderFroPlatform.deviceInfoResponse(parentPlatform,device, sn, fromHeader.getTag()); + cmderFroPlatform.deviceInfoResponse(parentPlatform, device, sn, fromHeader.getTag()); } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); } 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 a90799919..eb8555a4f 100644 --- 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 @@ -131,7 +131,8 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } }catch (Exception e) { - logger.warn("[收到通道] 发现未处理的异常, {}\r\n{}",e.getMessage(), evt.getRequest()); + logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); + logger.error("[收到通道] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java index 226799a4c..332f3635a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java @@ -142,7 +142,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar } } catch (DocumentException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java index 93c9d2f73..a667c67d8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java @@ -150,7 +150,8 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent } } } catch (Exception e) { - logger.error("[国标录像] 发现未处理的异常, "+e.getMessage(), e); + logger.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); + logger.error("[国标录像] 异常内容: ", e); } }); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java index c627215ec..9bf1a3ade 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java @@ -221,7 +221,7 @@ public class ZLMRTPServerFactory { if (localPort == 0) { return null; } - }alarm + } SendRtpItem sendRtpItem = new SendRtpItem(); sendRtpItem.setIp(ip); sendRtpItem.setPort(port); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index ea0fd5013..02f4f914b 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -207,7 +207,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { dataSourceTransactionManager.commit(transactionStatus); //手动提交 result = true; }catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); dataSourceTransactionManager.rollback(transactionStatus); } return result; diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 6eacd3947..194e90fb9 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -55,7 +55,7 @@ public class RedisAlarmMsgListener implements MessageListener { boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(message); if (isEmpty) { - logger.info("[线程池信息]活动线程数:{}, 最大线程数: {}", taskExecutor.getActiveCount(), taskExecutor.getMaxPoolSize()); +// logger.info("[线程池信息]活动线程数:{}, 最大线程数: {}", taskExecutor.getActiveCount(), taskExecutor.getMaxPoolSize()); taskExecutor.execute(() -> { while (!taskQueue.isEmpty()) { Message msg = taskQueue.poll(); @@ -140,6 +140,7 @@ public class RedisAlarmMsgListener implements MessageListener { } } }catch (Exception e) { + logger.error("未处理的异常 ", e); logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java index 35ed99e45..c37264785 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java @@ -202,7 +202,8 @@ public class RedisGbPlayMsgListener implements MessageListener { } }catch (Exception e) { - logger.warn("[RedisGbPlayMsg] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[RedisGbPlayMsg] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[RedisGbPlayMsg] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java index 0c99707ed..4e81a591d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java @@ -53,7 +53,8 @@ public class RedisGpsMsgListener implements MessageListener { // 只是放入redis缓存起来 redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[REDIS的ALARM通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[REDIS的ALARM通知] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java index 33eae1eb6..c90771be8 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java @@ -58,7 +58,8 @@ public class RedisPushStreamResponseListener implements MessageListener { responseEvents.get(response.getApp() + response.getStream()).run(response); } }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[REDIS消息-请求推流结果] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[REDIS消息-请求推流结果] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java index d8ed1a010..cb34ff591 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java @@ -95,7 +95,8 @@ public class RedisPushStreamStatusListMsgListener implements MessageListener { gbStreamService.updateGbIdOrName(streamPushItemForUpdate); } }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[REDIS消息-推流设备列表更新] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[REDIS消息-推流设备列表更新] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java index 96ff8e830..d7e02f594 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java @@ -79,7 +79,8 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); } }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[REDIS消息-推流设备状态变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[REDIS消息-推流设备状态变化] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java index 1cdc527a7..f5f29487e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java @@ -82,7 +82,8 @@ public class RedisStreamMsgListener implements MessageListener { zlmMediaListManager.removeMedia(app, stream); } }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); + logger.warn("[REDIS消息-流变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); + logger.error("[REDIS消息-流变化] 异常内容: ", e); } } }); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 3920fc7ec..1ce01df3b 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -197,7 +197,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { dataSourceTransactionManager.commit(transactionStatus); //手动提交 return true; }catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); dataSourceTransactionManager.rollback(transactionStatus); return false; } @@ -313,7 +313,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } return true; }catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); dataSourceTransactionManager.rollback(transactionStatus); return false; } diff --git a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java index e54ed5391..d8270f184 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java @@ -38,7 +38,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -66,7 +66,7 @@ public class RedisUtil { try { return redisTemplate.hasKey(key); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -91,7 +91,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -124,7 +124,7 @@ public class RedisUtil { redisTemplate.opsForValue().set(key, value); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -148,7 +148,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -226,7 +226,7 @@ public class RedisUtil { redisTemplate.opsForHash().putAll(key, map); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -249,7 +249,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -269,7 +269,7 @@ public class RedisUtil { redisTemplate.opsForHash().put(key, item, value); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -293,7 +293,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -365,7 +365,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().members(key); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return null; } } @@ -383,7 +383,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().isMember(key, value); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -401,7 +401,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().add(key, values); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -424,7 +424,7 @@ public class RedisUtil { } return count; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -441,7 +441,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().size(key); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -459,7 +459,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().remove(key, values); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -625,7 +625,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().range(key, start, end); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return null; } } @@ -642,7 +642,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().size(key); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -662,7 +662,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().index(key, index); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return null; } } @@ -681,7 +681,7 @@ public class RedisUtil { redisTemplate.opsForList().rightPush(key, value); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -704,7 +704,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -723,7 +723,7 @@ public class RedisUtil { redisTemplate.opsForList().rightPushAll(key, values); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -746,7 +746,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -766,7 +766,7 @@ public class RedisUtil { redisTemplate.opsForList().set(key, index, value); return true; } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return false; } } @@ -787,7 +787,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().remove(key, count, value); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return 0; } } @@ -829,7 +829,7 @@ public class RedisUtil { Set set = redisTemplate.keys(key); return new ArrayList<>(set); } catch (Exception e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); return null; } } @@ -854,7 +854,7 @@ public class RedisUtil { // //关闭cursor // cursor.close(); // } catch (Exception e) { -// e.printStackTrace(); +// logger.error("未处理的异常 ", e); // } // return result; // } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java index 662256884..5c8bf3679 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java @@ -181,7 +181,7 @@ public class StreamPushController { String name = file.getName(); inputStream = file.getInputStream(); } catch (IOException e) { - e.printStackTrace(); + logger.error("未处理的异常 ", e); } try { //传入参数 diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 2844fccb6..0298ee73a 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -215,7 +215,7 @@ export default { this.platform.enable = platform.enable; this.platform.ptz = platform.ptz; this.platform.rtcp = platform.rtcp; - this.platform.rtcpasMessageChannel = platform.asMessageChannel; + this.platform.asMessageChannel = platform.asMessageChannel; this.platform.name = platform.name; this.platform.serverGBId = platform.serverGBId; this.platform.serverGBDomain = platform.serverGBDomain; From 22a205e8fc77feb02d70b01329886c6dc9261516 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 17 Mar 2023 14:02:16 +0800 Subject: [PATCH 29/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/common/StreamInfo.java | 2 +- .../impl/SubscribeRequestProcessor.java | 12 ++--- .../iot/vmp/utils/redis/RedisUtil.java | 52 +++++++++---------- .../src/components/dialog/platformEdit.vue | 2 +- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java index 42ff5bada..8311745c2 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java +++ b/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java @@ -520,7 +520,7 @@ public class StreamInfo implements Serializable, Cloneable{ try{ instance = (StreamInfo)super.clone(); }catch(CloneNotSupportedException e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); } return instance; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 52a0f5d50..4ff4e980f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -1,24 +1,16 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CmdType; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; -import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.SipProviderImpl; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; import org.dom4j.DocumentException; @@ -29,7 +21,9 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.sip.*; +import javax.sip.InvalidArgumentException; +import javax.sip.RequestEvent; +import javax.sip.SipException; import javax.sip.header.ExpiresHeader; import javax.sip.message.Response; import java.text.ParseException; diff --git a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java index d8270f184..e54ed5391 100644 --- a/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java @@ -38,7 +38,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -66,7 +66,7 @@ public class RedisUtil { try { return redisTemplate.hasKey(key); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -91,7 +91,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -124,7 +124,7 @@ public class RedisUtil { redisTemplate.opsForValue().set(key, value); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -148,7 +148,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -226,7 +226,7 @@ public class RedisUtil { redisTemplate.opsForHash().putAll(key, map); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -249,7 +249,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -269,7 +269,7 @@ public class RedisUtil { redisTemplate.opsForHash().put(key, item, value); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -293,7 +293,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -365,7 +365,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().members(key); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return null; } } @@ -383,7 +383,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().isMember(key, value); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -401,7 +401,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().add(key, values); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -424,7 +424,7 @@ public class RedisUtil { } return count; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -441,7 +441,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().size(key); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -459,7 +459,7 @@ public class RedisUtil { try { return redisTemplate.opsForSet().remove(key, values); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -625,7 +625,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().range(key, start, end); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return null; } } @@ -642,7 +642,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().size(key); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -662,7 +662,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().index(key, index); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return null; } } @@ -681,7 +681,7 @@ public class RedisUtil { redisTemplate.opsForList().rightPush(key, value); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -704,7 +704,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -723,7 +723,7 @@ public class RedisUtil { redisTemplate.opsForList().rightPushAll(key, values); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -746,7 +746,7 @@ public class RedisUtil { } return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -766,7 +766,7 @@ public class RedisUtil { redisTemplate.opsForList().set(key, index, value); return true; } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return false; } } @@ -787,7 +787,7 @@ public class RedisUtil { try { return redisTemplate.opsForList().remove(key, count, value); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return 0; } } @@ -829,7 +829,7 @@ public class RedisUtil { Set set = redisTemplate.keys(key); return new ArrayList<>(set); } catch (Exception e) { - logger.error("未处理的异常 ", e); + e.printStackTrace(); return null; } } @@ -854,7 +854,7 @@ public class RedisUtil { // //关闭cursor // cursor.close(); // } catch (Exception e) { -// logger.error("未处理的异常 ", e); +// e.printStackTrace(); // } // return result; // } diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 0298ee73a..2a41e6ac7 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -331,7 +331,7 @@ export default { return result; }, checkExpires: function() { - if (this.platform.enable && this.platform.expires == "0") { + if (this.platform.enable && this.platform.expires === "0") { this.platform.expires = "300"; } }, From d3027b066831437e18ce42ce7d8f0b3d428c4893 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 17 Mar 2023 15:14:00 +0800 Subject: [PATCH 30/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/notify/cmd/AlarmNotifyMessageHandler.java | 9 ++++++--- .../iot/vmp/storager/impl/RedisCatchStorageImpl.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index ddbad1da8..9268e9b51 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -269,12 +269,15 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme if (channelId.equals(parentPlatform.getDeviceGBId())) { // 发送给平台的报警信息。 发送redis通知 AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); - alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); + if (deviceAlarm.getAlarmMethod() != null) { + alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); + } alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); alarmChannelMessage.setGbId(channelId); - alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); + if (deviceAlarm.getAlarmType() != null) { + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); + } redisCatchStorage.sendAlarmMsg(alarmChannelMessage); - return; } } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 0997fe117..f9e0c0682 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -857,7 +857,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void sendAlarmMsg(AlarmChannelMessage msg) { - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE; + String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM; logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg)); RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); } From 782300452cdc5ff9a8d02f0488fbb76d9d3fc92c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 17 Mar 2023 17:08:37 +0800 Subject: [PATCH 31/68] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=B9=E6=B5=B7?= =?UTF-8?q?=E5=BA=B7=E5=B9=B3=E5=8F=B0=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/UserSetting.java | 12 ++++++++++++ .../event/request/impl/NotifyRequestProcessor.java | 12 ++++++++++-- .../iot/vmp/storager/impl/RedisCatchStorageImpl.java | 1 + src/main/resources/all-application.yml | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index 130d147d1..d72d255b3 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -50,6 +50,8 @@ public class UserSetting { private Boolean sipLog = Boolean.FALSE; private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE; + private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE; + private String serverId = "000000"; private String thirdPartyGBIdReg = "[\\s\\S]*"; @@ -237,4 +239,14 @@ public class UserSetting { public void setSendToPlatformsWhenIdLost(Boolean sendToPlatformsWhenIdLost) { this.sendToPlatformsWhenIdLost = sendToPlatformsWhenIdLost; } + + public Boolean getRefuseChannelStatusChannelFormNotify() { + return refuseChannelStatusChannelFormNotify; + } + + public void setRefuseChannelStatusChannelFormNotify(Boolean refuseChannelStatusChannelFormNotify) { + this.refuseChannelStatusChannelFormNotify = refuseChannelStatusChannelFormNotify; + } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 7366f3002..990da3a00 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -393,12 +393,20 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements case CatalogEvent.OFF : // 离线 logger.info("[收到通道离线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - storager.deviceChannelOffline(deviceId, channel.getChannelId()); + if (userSetting.getRefuseChannelStatusChannelFormNotify()) { + storager.deviceChannelOffline(deviceId, channel.getChannelId()); + }else { + logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); + } break; case CatalogEvent.VLOST: // 视频丢失 logger.info("[收到通道视频丢失通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - storager.deviceChannelOffline(deviceId, channel.getChannelId()); + if (userSetting.getRefuseChannelStatusChannelFormNotify()) { + storager.deviceChannelOffline(deviceId, channel.getChannelId()); + }else { + logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); + } break; case CatalogEvent.DEFECT: // 故障 diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index f9e0c0682..8902641cd 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -857,6 +857,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void sendAlarmMsg(AlarmChannelMessage msg) { + // 此消息用于对接第三方服务下级来的消息内容 String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM; logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg)); RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 8b9b7b030..8bc4d957e 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -201,6 +201,8 @@ user-settings: sip-log: true # 消息通道功能-缺少国标ID是否给所有上级发送消息 send-to-platforms-when-id-lost: true + # 保持通道状态,不接受notify通道状态变化, 兼容海康平台发送错误消息 + refuse-channel-status-channel-form-notify: false # 跨域配置,配置你访问前端页面的地址即可, 可以配置多个 allowed-origins: - http://localhost:8008 From eb173b1b24d95ec1b6660deea390747ed5a3c76e Mon Sep 17 00:00:00 2001 From: StreamLuna <122618144+StreamLuna@users.noreply.github.com> Date: Mon, 20 Mar 2023 10:58:44 +0800 Subject: [PATCH 32/68] =?UTF-8?q?fix:=20=E6=A0=B9=E6=8D=AE=E5=9B=BD?= =?UTF-8?q?=E6=A0=87=E8=AE=BE=E5=A4=87=E7=BC=96=E5=8F=B7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=B2=A1=E6=9C=89=E8=BF=94=E5=9B=9E=E9=80=9A?= =?UTF-8?q?=E9=81=93=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index 8f158e296..b30ca19b5 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -42,7 +42,8 @@ public interface DeviceMapper { "asMessageChannel," + "geoCoordSys," + "treeType," + - "online" + + "online," + + "(SELECT count(0) FROM device_channel WHERE deviceId=device.deviceId) as channelCount "+ " FROM device WHERE deviceId = #{deviceId}") Device getDeviceByDeviceId(String deviceId); From b5efaa7baad6eb93ec0c6e5a087667df8ff2bade Mon Sep 17 00:00:00 2001 From: xiaoQQya Date: Mon, 20 Mar 2023 13:21:22 +0800 Subject: [PATCH 33/68] =?UTF-8?q?perf(jessibuca):=20=E4=BC=98=E5=8C=96=20v?= =?UTF-8?q?ideoInfo=20=E9=87=8D=E5=A4=8D=20log=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/common/jessibuca.vue | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/web_src/src/components/common/jessibuca.vue b/web_src/src/components/common/jessibuca.vue index 771507614..c02960e6c 100644 --- a/web_src/src/components/common/jessibuca.vue +++ b/web_src/src/components/common/jessibuca.vue @@ -167,13 +167,7 @@ export default { _this.isNotMute = !msg; }); jessibuca.on("audioInfo", function (msg) { - // console.log("audioInfo", msg); - }); - - jessibuca.on("videoInfo", function (msg) { - // this.videoInfo = msg; - console.log("videoInfo", msg); - + console.log("audioInfo", msg); }); jessibuca.on("bps", function (bps) { From 7bfaaf883858c9569dd0106d02cf877c1ec0d83a Mon Sep 17 00:00:00 2001 From: xiaoQQya Date: Mon, 20 Mar 2023 13:22:01 +0800 Subject: [PATCH 34/68] =?UTF-8?q?fix(=E5=9B=BD=E6=A0=87=E8=AE=BE=E5=A4=87)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BA=91=E5=8F=B0=E7=B1=BB=E5=9E=8B=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/channelList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index f020f345e..563f43f3d 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -69,7 +69,7 @@ - +