Merge remote-tracking branch 'github/wvp-28181-2.0' into wvp-28181-2.0

This commit is contained in:
648540858 2022-08-22 23:01:52 +08:00
commit a931d0d5f7
96 changed files with 1300 additions and 15578 deletions

View File

@ -0,0 +1,56 @@
package com.genersoft.iot.vmp.conf;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局异常处理
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private final static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 默认异常处理
* @param e 异常
* @return 统一返回结果
*/
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public WVPResult<String> exceptionHandler(Exception e) {
logger.error("[全局异常] ", e);
return WVPResult.fail(ErrorCode.ERROR500.getCode(), e.getMessage());
}
/**
* 自定义异常处理 处理controller中返回的错误
* @param e 异常
* @return 统一返回结果
*/
@ExceptionHandler(ControllerException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public WVPResult<String> exceptionHandler(ControllerException e) {
return WVPResult.fail(e.getCode(), e.getMsg());
}
/**
* 登陆失败
* @param e 异常
* @return 统一返回结果
*/
@ExceptionHandler(BadCredentialsException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public WVPResult<String> exceptionHandler(BadCredentialsException e) {
return WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMessage());
}
}

View File

@ -0,0 +1,53 @@
package com.genersoft.iot.vmp.conf;
import com.alibaba.fastjson.JSON;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
* 全局统一返回结果
* @author lin
*/
@RestControllerAdvice
public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(@NotNull MethodParameter returnType, @NotNull Class<? extends HttpMessageConverter<?>> converterType) {
return true;
}
@Override
public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) {
// 排除api文档的接口这个接口不需要统一
String[] excludePath = {"/v3/api-docs","/api/v1","/index/hook"};
for (String path : excludePath) {
if (request.getURI().getPath().startsWith(path)) {
return body;
}
}
if (body instanceof WVPResult) {
return body;
}
if (body instanceof ErrorCode) {
ErrorCode errorCode = (ErrorCode) body;
return new WVPResult<>(errorCode.getCode(), errorCode.getMsg(), null);
}
if (body instanceof String) {
return JSON.toJSONString(WVPResult.success(body));
}
return WVPResult.success(body);
}
}

View File

@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.net.InetAddress; import java.net.InetAddress;
@ -88,7 +89,7 @@ public class MediaConfig{
} }
public String getHookIp() { public String getHookIp() {
if (StringUtils.isEmpty(hookIp)){ if (ObjectUtils.isEmpty(hookIp)){
return sipIp; return sipIp;
}else { }else {
return hookIp; return hookIp;
@ -162,7 +163,7 @@ public class MediaConfig{
} }
public String getSdpIp() { public String getSdpIp() {
if (StringUtils.isEmpty(sdpIp)){ if (ObjectUtils.isEmpty(sdpIp)){
return ip; return ip;
}else { }else {
if (isValidIPAddress(sdpIp)) { if (isValidIPAddress(sdpIp)) {
@ -181,7 +182,7 @@ public class MediaConfig{
} }
public String getStreamIp() { public String getStreamIp() {
if (StringUtils.isEmpty(streamIp)){ if (ObjectUtils.isEmpty(streamIp)){
return ip; return ip;
}else { }else {
return streamIp; return streamIp;

View File

@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -55,7 +56,7 @@ public class ProxyServletConfig {
String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString); String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString);
MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI()); MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI());
if (mediaInfo != null) { if (mediaInfo != null) {
if (!StringUtils.isEmpty(queryStr)) { if (!ObjectUtils.isEmpty(queryStr)) {
queryStr += "&secret=" + mediaInfo.getSecret(); queryStr += "&secret=" + mediaInfo.getSecret();
}else { }else {
queryStr = "secret=" + mediaInfo.getSecret(); queryStr = "secret=" + mediaInfo.getSecret();
@ -146,7 +147,7 @@ public class ProxyServletConfig {
logger.error("[ZLM服务访问代理]错误处理url信息时未找到流媒体信息=>{}", requestURI); logger.error("[ZLM服务访问代理]错误处理url信息时未找到流媒体信息=>{}", requestURI);
return url; return url;
} }
if (!StringUtils.isEmpty(mediaInfo.getId())) { if (!ObjectUtils.isEmpty(mediaInfo.getId())) {
url = url.replace(mediaInfo.getId() + "/", ""); url = url.replace(mediaInfo.getId() + "/", "");
} }
return url.replace("default/", ""); return url.replace("default/", "");
@ -173,7 +174,7 @@ public class ProxyServletConfig {
MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI()); MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI());
String remoteHost = String.format("http://%s:%s", mediaInfo.getIp(), mediaInfo.getHttpPort()); String remoteHost = String.format("http://%s:%s", mediaInfo.getIp(), mediaInfo.getHttpPort());
if (mediaInfo != null) { if (mediaInfo != null) {
if (!StringUtils.isEmpty(queryStr)) { if (!ObjectUtils.isEmpty(queryStr)) {
queryStr += "&remoteHost=" + remoteHost; queryStr += "&remoteHost=" + remoteHost;
}else { }else {
queryStr = "remoteHost=" + remoteHost; queryStr = "remoteHost=" + remoteHost;
@ -265,7 +266,7 @@ public class ProxyServletConfig {
logger.error("[录像服务访问代理]错误处理url信息时未找到流媒体信息=>{}", requestURI); logger.error("[录像服务访问代理]错误处理url信息时未找到流媒体信息=>{}", requestURI);
return url; return url;
} }
if (!StringUtils.isEmpty(mediaInfo.getId())) { if (!ObjectUtils.isEmpty(mediaInfo.getId())) {
url = url.replace(mediaInfo.getId() + "/", ""); url = url.replace(mediaInfo.getId() + "/", "");
} }
return url.replace("default/", ""); return url.replace("default/", "");

View File

@ -0,0 +1,37 @@
package com.genersoft.iot.vmp.conf.exception;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
/**
* 自定义异常controller出现错误时直接抛出异常由全局异常捕获并返回结果
*/
public class ControllerException extends RuntimeException{
private int code;
private String msg;
public ControllerException(int code, String msg) {
this.code = code;
this.msg = msg;
}
public ControllerException(ErrorCode errorCode) {
this.code = errorCode.getCode();
this.msg = errorCode.getMsg();
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}

View File

@ -91,6 +91,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/webjars/**") .antMatchers("/webjars/**")
.antMatchers("/swagger-resources/**") .antMatchers("/swagger-resources/**")
.antMatchers("/v3/api-docs/**") .antMatchers("/v3/api-docs/**")
.antMatchers("/favicon.ico")
.antMatchers("/js/**"); .antMatchers("/js/**");
List<String> interfaceAuthenticationExcludes = userSetting.getInterfaceAuthenticationExcludes(); List<String> interfaceAuthenticationExcludes = userSetting.getInterfaceAuthenticationExcludes();
for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) { for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) {

View File

@ -37,9 +37,9 @@ public class EventPublisher {
* @param platformGbId * @param platformGbId
*/ */
public void platformKeepaliveExpireEventPublish(String platformGbId){ public void platformKeepaliveExpireEventPublish(String platformGbId){
PlatformKeepaliveExpireEvent platformNotRegisterEvent = new PlatformKeepaliveExpireEvent(this); PlatformKeepaliveExpireEvent platformKeepaliveExpireEvent = new PlatformKeepaliveExpireEvent(this);
platformNotRegisterEvent.setPlatformGbID(platformGbId); platformKeepaliveExpireEvent.setPlatformGbID(platformGbId);
applicationEventPublisher.publishEvent(platformNotRegisterEvent); applicationEventPublisher.publishEvent(platformKeepaliveExpireEvent);
} }
/** /**

View File

@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
@ -58,7 +59,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
ParentPlatform parentPlatform = null; ParentPlatform parentPlatform = null;
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
if (!StringUtils.isEmpty(event.getPlatformId())) { if (!ObjectUtils.isEmpty(event.getPlatformId())) {
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
if (subscribe == null) { if (subscribe == null) {
return; return;
@ -81,7 +82,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
}else if (event.getGbStreams() != null) { }else if (event.getGbStreams() != null) {
if (platforms.size() > 0) { if (platforms.size() > 0) {
for (GbStream gbStream : event.getGbStreams()) { for (GbStream gbStream : event.getGbStreams()) {
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) { if (gbStream == null || ObjectUtils.isEmpty(gbStream.getGbId())) {
continue; continue;
} }
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);

View File

@ -60,16 +60,12 @@ public class RecordDataCatch {
// 处理录像数据 返回给前端 // 处理录像数据 返回给前端
String msgKey = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + recordInfo.getDeviceId() + recordInfo.getSn(); String msgKey = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + recordInfo.getDeviceId() + recordInfo.getSn();
WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
wvpResult.setMsg("success");
// 对数据进行排序 // 对数据进行排序
Collections.sort(recordInfo.getRecordList()); Collections.sort(recordInfo.getRecordList());
wvpResult.setData(recordInfo);
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setKey(msgKey); msg.setKey(msgKey);
msg.setData(wvpResult); msg.setData(recordInfo);
deferredResultHolder.invokeAllResult(msg); deferredResultHolder.invokeAllResult(msg);
data.remove(key); data.remove(key);
} }

View File

@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import gov.nist.javax.sip.stack.SIPDialog; import gov.nist.javax.sip.stack.SIPDialog;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -110,16 +111,16 @@ public class VideoStreamSessionManager {
public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
if (StringUtils.isEmpty(deviceId)) { if (ObjectUtils.isEmpty(deviceId)) {
deviceId ="*"; deviceId ="*";
} }
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
channelId ="*"; channelId ="*";
} }
if (StringUtils.isEmpty(callId)) { if (ObjectUtils.isEmpty(callId)) {
callId ="*"; callId ="*";
} }
if (StringUtils.isEmpty(stream)) { if (ObjectUtils.isEmpty(stream)) {
stream ="*"; stream ="*";
} }
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;
@ -131,16 +132,16 @@ public class VideoStreamSessionManager {
} }
public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){ public List<SsrcTransaction> getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){
if (StringUtils.isEmpty(deviceId)) { if (ObjectUtils.isEmpty(deviceId)) {
deviceId ="*"; deviceId ="*";
} }
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
channelId ="*"; channelId ="*";
} }
if (StringUtils.isEmpty(callId)) { if (ObjectUtils.isEmpty(callId)) {
callId ="*"; callId ="*";
} }
if (StringUtils.isEmpty(stream)) { if (ObjectUtils.isEmpty(stream)) {
stream ="*"; stream ="*";
} }
String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream;

View File

@ -3,8 +3,6 @@ package com.genersoft.iot.vmp.gb28181.transmit;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.RegisterRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd.KeepaliveNotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -14,13 +12,10 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.sip.*; import javax.sip.*;
import javax.sip.address.SipURI;
import javax.sip.address.URI;
import javax.sip.header.*; import javax.sip.header.*;
import javax.sip.message.Request; import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
@ -43,9 +38,6 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
@Autowired @Autowired
private EventPublisher eventPublisher; private EventPublisher eventPublisher;
/** /**
* 添加 request订阅 * 添加 request订阅
* @param method 方法名 * @param method 方法名

View File

@ -96,7 +96,7 @@ public class DeferredResultHolder {
if (result == null) { if (result == null) {
return; return;
} }
result.setResult(new ResponseEntity<>(msg.getData(),HttpStatus.OK)); result.setResult(msg.getData());
deferredResultMap.remove(msg.getId()); deferredResultMap.remove(msg.getId());
if (deferredResultMap.size() == 0) { if (deferredResultMap.size() == 0) {
map.remove(msg.getKey()); map.remove(msg.getKey());
@ -118,9 +118,8 @@ public class DeferredResultHolder {
if (result == null) { if (result == null) {
return; return;
} }
result.setResult(ResponseEntity.ok().body(msg.getData())); result.setResult(msg.getData());
} }
map.remove(msg.getKey()); map.remove(msg.getKey());
} }
} }

View File

@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.*; import javax.sip.*;
@ -856,7 +857,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Control>\r\n"); cmdXml.append("<Control>\r\n");
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n"); cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
@ -959,16 +960,16 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
cmdXml.append("<AlarmCmd>ResetAlarm</AlarmCmd>\r\n"); cmdXml.append("<AlarmCmd>ResetAlarm</AlarmCmd>\r\n");
if (!StringUtils.isEmpty(alarmMethod) || !StringUtils.isEmpty(alarmType)) { if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
cmdXml.append("<Info>\r\n"); cmdXml.append("<Info>\r\n");
} }
if (!StringUtils.isEmpty(alarmMethod)) { if (!ObjectUtils.isEmpty(alarmMethod)) {
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n"); cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
} }
if (!StringUtils.isEmpty(alarmType)) { if (!ObjectUtils.isEmpty(alarmType)) {
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n"); cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
} }
if (!StringUtils.isEmpty(alarmMethod) || !StringUtils.isEmpty(alarmType)) { if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
cmdXml.append("</Info>\r\n"); cmdXml.append("</Info>\r\n");
} }
cmdXml.append("</Control>\r\n"); cmdXml.append("</Control>\r\n");
@ -1002,7 +1003,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Control>\r\n"); cmdXml.append("<Control>\r\n");
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n"); cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
@ -1041,7 +1042,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Control>\r\n"); cmdXml.append("<Control>\r\n");
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n"); cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
@ -1110,13 +1111,13 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Control>\r\n"); cmdXml.append("<Control>\r\n");
cmdXml.append("<CmdType>DeviceConfig</CmdType>\r\n"); cmdXml.append("<CmdType>DeviceConfig</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
} }
cmdXml.append("<BasicParam>\r\n"); cmdXml.append("<BasicParam>\r\n");
if (!StringUtils.isEmpty(name)) { if (!ObjectUtils.isEmpty(name)) {
cmdXml.append("<Name>" + name + "</Name>\r\n"); cmdXml.append("<Name>" + name + "</Name>\r\n");
} }
if (NumericUtil.isInteger(expiration)) { if (NumericUtil.isInteger(expiration)) {
@ -1326,22 +1327,22 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<CmdType>Alarm</CmdType>\r\n"); cmdXml.append("<CmdType>Alarm</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
if (!StringUtils.isEmpty(startPriority)) { if (!ObjectUtils.isEmpty(startPriority)) {
cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n"); cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n");
} }
if (!StringUtils.isEmpty(endPriority)) { if (!ObjectUtils.isEmpty(endPriority)) {
cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n"); cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n");
} }
if (!StringUtils.isEmpty(alarmMethod)) { if (!ObjectUtils.isEmpty(alarmMethod)) {
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n"); cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
} }
if (!StringUtils.isEmpty(alarmType)) { if (!ObjectUtils.isEmpty(alarmType)) {
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n"); cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
} }
if (!StringUtils.isEmpty(startTime)) { if (!ObjectUtils.isEmpty(startTime)) {
cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n"); cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n");
} }
if (!StringUtils.isEmpty(endTime)) { if (!ObjectUtils.isEmpty(endTime)) {
cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n"); cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n");
} }
cmdXml.append("</Query>\r\n"); cmdXml.append("</Query>\r\n");
@ -1376,7 +1377,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Query>\r\n"); cmdXml.append("<Query>\r\n");
cmdXml.append("<CmdType>ConfigDownload</CmdType>\r\n"); cmdXml.append("<CmdType>ConfigDownload</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
@ -1412,7 +1413,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<Query>\r\n"); cmdXml.append("<Query>\r\n");
cmdXml.append("<CmdType>PresetQuery</CmdType>\r\n"); cmdXml.append("<CmdType>PresetQuery</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
@ -1543,22 +1544,22 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<CmdType>Alarm</CmdType>\r\n"); cmdXml.append("<CmdType>Alarm</CmdType>\r\n");
cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); cmdXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
if (!StringUtils.isEmpty(startPriority)) { if (!ObjectUtils.isEmpty(startPriority)) {
cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n"); cmdXml.append("<StartAlarmPriority>" + startPriority + "</StartAlarmPriority>\r\n");
} }
if (!StringUtils.isEmpty(endPriority)) { if (!ObjectUtils.isEmpty(endPriority)) {
cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n"); cmdXml.append("<EndAlarmPriority>" + endPriority + "</EndAlarmPriority>\r\n");
} }
if (!StringUtils.isEmpty(alarmMethod)) { if (!ObjectUtils.isEmpty(alarmMethod)) {
cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n"); cmdXml.append("<AlarmMethod>" + alarmMethod + "</AlarmMethod>\r\n");
} }
if (!StringUtils.isEmpty(alarmType)) { if (!ObjectUtils.isEmpty(alarmType)) {
cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n"); cmdXml.append("<AlarmType>" + alarmType + "</AlarmType>\r\n");
} }
if (!StringUtils.isEmpty(startTime)) { if (!ObjectUtils.isEmpty(startTime)) {
cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n"); cmdXml.append("<StartAlarmTime>" + startTime + "</StartAlarmTime>\r\n");
} }
if (!StringUtils.isEmpty(endTime)) { if (!ObjectUtils.isEmpty(endTime)) {
cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n"); cmdXml.append("<EndAlarmTime>" + endTime + "</EndAlarmTime>\r\n");
} }
cmdXml.append("</Query>\r\n"); cmdXml.append("</Query>\r\n");
@ -1639,7 +1640,7 @@ public class SIPCommander implements ISIPCommander {
dragXml.append("<Control>\r\n"); dragXml.append("<Control>\r\n");
dragXml.append("<CmdType>DeviceControl</CmdType>\r\n"); dragXml.append("<CmdType>DeviceControl</CmdType>\r\n");
dragXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); dragXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
dragXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); dragXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
} else { } else {
dragXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); dragXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");

View File

@ -24,6 +24,7 @@ import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.*; import javax.sip.*;
@ -728,10 +729,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n"); recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n");
recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n"); recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n");
recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n"); recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n");
if (!StringUtils.isEmpty(recordItem.getFileSize())) { if (!ObjectUtils.isEmpty(recordItem.getFileSize())) {
recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n"); recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n");
} }
if (!StringUtils.isEmpty(recordItem.getFilePath())) { if (!ObjectUtils.isEmpty(recordItem.getFilePath())) {
recordXml.append("<FilePath>" + recordItem.getFilePath() + "</FilePath>\r\n"); recordXml.append("<FilePath>" + recordItem.getFilePath() + "</FilePath>\r\n");
} }
} }

View File

@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -157,7 +158,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
String channelId = deviceIdElement.getTextTrim().toString(); String channelId = deviceIdElement.getTextTrim().toString();
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device != null) { if (device != null) {
if (!StringUtils.isEmpty(device.getName())) { if (!ObjectUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName()); mobilePosition.setDeviceName(device.getName());
} }
} }

View File

@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -81,7 +82,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
String deviceId = uri.getUser(); String deviceId = uri.getUser();
AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
if (authHead == null && !StringUtils.isEmpty(sipConfig.getPassword())) { if (authHead == null && !ObjectUtils.isEmpty(sipConfig.getPassword())) {
logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress); logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress);
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
@ -90,7 +91,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
} }
// 校验密码是否正确 // 校验密码是否正确
passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) || passwordCorrect = ObjectUtils.isEmpty(sipConfig.getPassword()) ||
new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword()); new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword());
if (!passwordCorrect) { if (!passwordCorrect) {
@ -132,7 +133,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
String received = viaHeader.getReceived(); String received = viaHeader.getReceived();
int rPort = viaHeader.getRPort(); int rPort = viaHeader.getRPort();
// 解析本地地址替代 // 解析本地地址替代
if (StringUtils.isEmpty(received) || rPort == -1) { if (ObjectUtils.isEmpty(received) || rPort == -1) {
received = viaHeader.getHost(); received = viaHeader.getHost();
rPort = viaHeader.getPort(); rPort = viaHeader.getPort();
} }

View File

@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.*; import javax.sip.*;
@ -64,7 +65,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
String targetGBId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser(); String targetGBId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
String channelId = getText(rootElement, "DeviceID"); String channelId = getText(rootElement, "DeviceID");
// 远程启动功能 // 远程启动功能
if (!StringUtils.isEmpty(getText(rootElement, "TeleBoot"))) { if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) {
if (parentPlatform.getServerGBId().equals(targetGBId)) { if (parentPlatform.getServerGBId().equals(targetGBId)) {
// 远程启动本平台需要在重新启动程序后先对SipStack解绑 // 远程启动本平台需要在重新启动程序后先对SipStack解绑
logger.info("执行远程启动本平台命令"); logger.info("执行远程启动本平台命令");
@ -101,7 +102,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
} }
} }
// 云台/前端控制命令 // 云台/前端控制命令
if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { if (!ObjectUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
String cmdString = getText(rootElement,"PTZCmd"); String cmdString = getText(rootElement,"PTZCmd");
Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
if (deviceForPlatform == null) { if (deviceForPlatform == null) {

View File

@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -114,7 +115,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
deviceAlarm.setLatitude(0.00); deviceAlarm.setLatitude(0.00);
} }
if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) { if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) {
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow()); mobilePosition.setCreateTime(DateUtil.getNow());
@ -157,7 +158,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
redisCatchStorage.sendMobilePositionMsg(jsonObject); redisCatchStorage.sendMobilePositionMsg(jsonObject);
} }
} }
if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) { if (!ObjectUtils.isEmpty(deviceAlarm.getDeviceId())) {
if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) {
deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType"));
} }
@ -231,7 +232,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
deviceAlarm.setLatitude(0.00); deviceAlarm.setLatitude(0.00);
} }
if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) {
if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) {
deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType"));

View File

@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -58,7 +59,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
String received = viaHeader.getReceived(); String received = viaHeader.getReceived();
int rPort = viaHeader.getRPort(); int rPort = viaHeader.getRPort();
// 解析本地地址替代 // 解析本地地址替代
if (StringUtils.isEmpty(received) || rPort == -1) { if (ObjectUtils.isEmpty(received) || rPort == -1) {
received = viaHeader.getHost(); received = viaHeader.getHost();
rPort = viaHeader.getPort(); rPort = viaHeader.getPort();
} }

View File

@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -69,7 +70,7 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
} }
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow()); mobilePosition.setCreateTime(DateUtil.getNow());
if (!StringUtils.isEmpty(device.getName())) { if (!ObjectUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName()); mobilePosition.setDeviceName(device.getName());
} }
mobilePosition.setDeviceId(device.getDeviceId()); mobilePosition.setDeviceId(device.getDeviceId());

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -88,7 +89,7 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
device.setManufacturer(getText(rootElement, "Manufacturer")); device.setManufacturer(getText(rootElement, "Manufacturer"));
device.setModel(getText(rootElement, "Model")); device.setModel(getText(rootElement, "Model"));
device.setFirmware(getText(rootElement, "Firmware")); device.setFirmware(getText(rootElement, "Firmware"));
if (StringUtils.isEmpty(device.getStreamMode())) { if (ObjectUtils.isEmpty(device.getStreamMode())) {
device.setStreamMode("UDP"); device.setStreamMode("UDP");
} }
deviceService.updateDevice(device); deviceService.updateDevice(device);

View File

@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -72,7 +73,7 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
} }
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setCreateTime(DateUtil.getNow()); mobilePosition.setCreateTime(DateUtil.getNow());
if (!StringUtils.isEmpty(device.getName())) { if (!ObjectUtils.isEmpty(device.getName())) {
mobilePosition.setDeviceName(device.getName()); mobilePosition.setDeviceName(device.getName());
} }
mobilePosition.setDeviceId(device.getDeviceId()); mobilePosition.setDeviceId(device.getDeviceId());

View File

@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.InvalidArgumentException; import javax.sip.InvalidArgumentException;
@ -93,7 +94,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
recordInfo.setName(getText(rootElementForCharset, "Name")); recordInfo.setName(getText(rootElementForCharset, "Name"));
String sumNumStr = getText(rootElementForCharset, "SumNum"); String sumNumStr = getText(rootElementForCharset, "SumNum");
int sumNum = 0; int sumNum = 0;
if (!StringUtils.isEmpty(sumNumStr)) { if (!ObjectUtils.isEmpty(sumNumStr)) {
sumNum = Integer.parseInt(sumNumStr); sumNum = Integer.parseInt(sumNumStr);
} }
recordInfo.setSumNum(sumNum); recordInfo.setSumNum(sumNum);
@ -172,16 +173,12 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
public void releaseRequest(String deviceId, String sn){ public void releaseRequest(String deviceId, String sn){
String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn;
WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
wvpResult.setMsg("success");
// 对数据进行排序 // 对数据进行排序
Collections.sort(recordDataCatch.getRecordInfo(deviceId, sn).getRecordList()); Collections.sort(recordDataCatch.getRecordInfo(deviceId, sn).getRecordList());
wvpResult.setData(recordDataCatch.getRecordInfo(deviceId, sn));
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setKey(key); msg.setKey(key);
msg.setData(wvpResult); msg.setData(recordDataCatch.getRecordInfo(deviceId, sn));
deferredResultHolder.invokeAllResult(msg); deferredResultHolder.invokeAllResult(msg);
recordDataCatch.remove(deviceId, sn); recordDataCatch.remove(deviceId, sn);
} }

View File

@ -14,6 +14,7 @@ import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.sip.RequestEvent; import javax.sip.RequestEvent;
@ -118,12 +119,12 @@ public class XmlUtil {
// 如果是属性 // 如果是属性
for (Object o : element.attributes()) { for (Object o : element.attributes()) {
Attribute attr = (Attribute) o; Attribute attr = (Attribute) o;
if (!StringUtils.isEmpty(attr.getValue())) { if (!ObjectUtils.isEmpty(attr.getValue())) {
json.put("@" + attr.getName(), attr.getValue()); json.put("@" + attr.getName(), attr.getValue());
} }
} }
List<Element> chdEl = element.elements(); List<Element> chdEl = element.elements();
if (chdEl.isEmpty() && !StringUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值 if (chdEl.isEmpty() && !ObjectUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值
json.put(element.getName(), element.getText()); json.put(element.getName(), element.getText());
} }
@ -154,7 +155,7 @@ public class XmlUtil {
} else { // 子元素没有子元素 } else { // 子元素没有子元素
for (Object o : element.attributes()) { for (Object o : element.attributes()) {
Attribute attr = (Attribute) o; Attribute attr = (Attribute) o;
if (!StringUtils.isEmpty(attr.getValue())) { if (!ObjectUtils.isEmpty(attr.getValue())) {
json.put("@" + attr.getName(), attr.getValue()); json.put("@" + attr.getName(), attr.getValue());
} }
} }
@ -197,7 +198,7 @@ public class XmlUtil {
return null; return null;
} }
String channelId = channdelIdElement.getTextTrim(); String channelId = channdelIdElement.getTextTrim();
if (StringUtils.isEmpty(channelId)) { if (ObjectUtils.isEmpty(channelId)) {
logger.warn("解析Catalog消息时发现缺少 DeviceID"); logger.warn("解析Catalog消息时发现缺少 DeviceID");
return null; return null;
} }
@ -316,7 +317,7 @@ public class XmlUtil {
// 识别自带的目录标识 // 识别自带的目录标识
String parental = XmlUtil.getText(itemDevice, "Parental"); String parental = XmlUtil.getText(itemDevice, "Parental");
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1 // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) { if (!ObjectUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
deviceChannel.setParental(0); deviceChannel.setParental(0);
}else { }else {
deviceChannel.setParental(1); deviceChannel.setParental(1);
@ -332,14 +333,14 @@ public class XmlUtil {
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay"); String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
if (StringUtils.isEmpty(safetyWay)) { if (ObjectUtils.isEmpty(safetyWay)) {
deviceChannel.setSafetyWay(0); deviceChannel.setSafetyWay(0);
} else { } else {
deviceChannel.setSafetyWay(Integer.parseInt(safetyWay)); deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
} }
String registerWay = XmlUtil.getText(itemDevice, "RegisterWay"); String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
if (StringUtils.isEmpty(registerWay)) { if (ObjectUtils.isEmpty(registerWay)) {
deviceChannel.setRegisterWay(1); deviceChannel.setRegisterWay(1);
} else { } else {
deviceChannel.setRegisterWay(Integer.parseInt(registerWay)); deviceChannel.setRegisterWay(Integer.parseInt(registerWay));

View File

@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.File; import java.io.File;
@ -49,7 +50,7 @@ public class AssistRESTfulUtils {
if (mediaServerItem == null) { if (mediaServerItem == null) {
return null; return null;
} }
if (StringUtils.isEmpty(mediaServerItem.getRecordAssistPort())) { if (ObjectUtils.isEmpty(mediaServerItem.getRecordAssistPort())) {
logger.warn("未启用Assist服务"); logger.warn("未启用Assist服务");
return null; return null;
} }

View File

@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -633,7 +634,7 @@ public class ZLMHttpHookListener {
private Map<String, String> urlParamToMap(String params) { private Map<String, String> urlParamToMap(String params) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
if (StringUtils.isEmpty(params)) { if (ObjectUtils.isEmpty(params)) {
return map; return map;
} }
String[] paramsArray = params.split("&"); String[] paramsArray = params.split("&");

View File

@ -9,6 +9,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
@ -187,7 +188,7 @@ public class ZLMRTPServerFactory {
// 使用RTPServer 功能找一个可用的端口 // 使用RTPServer 功能找一个可用的端口
String sendRtpPortRange = serverItem.getSendRtpPortRange(); String sendRtpPortRange = serverItem.getSendRtpPortRange();
if (StringUtils.isEmpty(sendRtpPortRange)) { if (ObjectUtils.isEmpty(sendRtpPortRange)) {
return null; return null;
} }
String[] portRangeStrArray = serverItem.getSendRtpPortRange().split(","); String[] portRangeStrArray = serverItem.getSendRtpPortRange().split(",");
@ -229,7 +230,7 @@ public class ZLMRTPServerFactory {
public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String app, String stream, String channelId, boolean tcp){ public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String app, String stream, String channelId, boolean tcp){
// 使用RTPServer 功能找一个可用的端口 // 使用RTPServer 功能找一个可用的端口
String sendRtpPortRange = serverItem.getSendRtpPortRange(); String sendRtpPortRange = serverItem.getSendRtpPortRange();
if (StringUtils.isEmpty(sendRtpPortRange)) { if (ObjectUtils.isEmpty(sendRtpPortRange)) {
return null; return null;
} }
String[] portRangeStrArray = serverItem.getSendRtpPortRange().split(","); String[] portRangeStrArray = serverItem.getSendRtpPortRange().split(",");

View File

@ -4,6 +4,7 @@ package com.genersoft.iot.vmp.media.zlm.dto;
import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.HashMap; import java.util.HashMap;
@ -106,9 +107,9 @@ public class MediaServerItem{
public MediaServerItem(ZLMServerConfig zlmServerConfig, String sipIp) { public MediaServerItem(ZLMServerConfig zlmServerConfig, String sipIp) {
id = zlmServerConfig.getGeneralMediaServerId(); id = zlmServerConfig.getGeneralMediaServerId();
ip = zlmServerConfig.getIp(); ip = zlmServerConfig.getIp();
hookIp = StringUtils.isEmpty(zlmServerConfig.getHookIp())? sipIp: zlmServerConfig.getHookIp(); hookIp = ObjectUtils.isEmpty(zlmServerConfig.getHookIp())? sipIp: zlmServerConfig.getHookIp();
sdpIp = StringUtils.isEmpty(zlmServerConfig.getSdpIp())? zlmServerConfig.getIp(): zlmServerConfig.getSdpIp(); sdpIp = ObjectUtils.isEmpty(zlmServerConfig.getSdpIp())? zlmServerConfig.getIp(): zlmServerConfig.getSdpIp();
streamIp = StringUtils.isEmpty(zlmServerConfig.getStreamIp())? zlmServerConfig.getIp(): zlmServerConfig.getStreamIp(); streamIp = ObjectUtils.isEmpty(zlmServerConfig.getStreamIp())? zlmServerConfig.getIp(): zlmServerConfig.getStreamIp();
httpPort = zlmServerConfig.getHttpPort(); httpPort = zlmServerConfig.getHttpPort();
httpSSlPort = zlmServerConfig.getHttpSSLport(); httpSSlPort = zlmServerConfig.getHttpSSLport();
rtmpPort = zlmServerConfig.getRtmpPort(); rtmpPort = zlmServerConfig.getRtmpPort();

View File

@ -64,7 +64,7 @@ public interface IMediaServerService {
void clearMediaServerForOnline(); void clearMediaServerForOnline();
WVPResult<String> add(MediaServerItem mediaSerItem); void add(MediaServerItem mediaSerItem);
int addToDatabase(MediaServerItem mediaSerItem); int addToDatabase(MediaServerItem mediaSerItem);
@ -72,7 +72,7 @@ public interface IMediaServerService {
void resetOnlineServerItem(MediaServerItem serverItem); void resetOnlineServerItem(MediaServerItem serverItem);
WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret); MediaServerItem checkMediaServer(String ip, int port, String secret);
boolean checkMediaRecordServer(String ip, int port); boolean checkMediaRecordServer(String ip, int port);

View File

@ -31,13 +31,13 @@ public interface IPlayService {
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString); void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
DeferredResult<ResponseEntity<String>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); DeferredResult<String> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<ResponseEntity<String>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
void zlmServerOffline(String mediaServerId); void zlmServerOffline(String mediaServerId);
DeferredResult<ResponseEntity<String>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);

View File

@ -2,12 +2,8 @@ package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
public interface IStreamProxyService { public interface IStreamProxyService {
@ -16,7 +12,7 @@ public interface IStreamProxyService {
* 保存视频代理 * 保存视频代理
* @param param * @param param
*/ */
WVPResult<StreamInfo> save(StreamProxyItem param); StreamInfo save(StreamProxyItem param);
/** /**
* 添加视频代理到zlm * 添加视频代理到zlm

View File

@ -4,14 +4,18 @@ import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import javax.sip.RequestEvent; import java.util.EventObject;
/**
* @author lin
*/
public class PlayBackResult<T> { public class PlayBackResult<T> {
private int code; private int code;
private T data; private T data;
private MediaServerItem mediaServerItem; private MediaServerItem mediaServerItem;
private JSONObject response; private JSONObject response;
private SipSubscribe.EventResult event; private SipSubscribe.EventResult<EventObject> event;
public int getCode() { public int getCode() {
return code; return code;
@ -45,11 +49,11 @@ public class PlayBackResult<T> {
this.response = response; this.response = response;
} }
public SipSubscribe.EventResult getEvent() { public SipSubscribe.EventResult<EventObject> getEvent() {
return event; return event;
} }
public void setEvent(SipSubscribe.EventResult event) { public void setEvent(SipSubscribe.EventResult<EventObject> event) {
this.event = event; this.event = event;
} }
} }

View File

@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer; import org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.Instant; import java.time.Instant;
@ -282,13 +283,13 @@ public class DeviceServiceImpl implements IDeviceService {
logger.warn("更新设备时未找到设备信息"); logger.warn("更新设备时未找到设备信息");
return; return;
} }
if (!StringUtils.isEmpty(device.getName())) { if (!ObjectUtils.isEmpty(device.getName())) {
deviceInStore.setName(device.getName()); deviceInStore.setName(device.getName());
} }
if (!StringUtils.isEmpty(device.getCharset())) { if (!ObjectUtils.isEmpty(device.getCharset())) {
deviceInStore.setCharset(device.getCharset()); deviceInStore.setCharset(device.getCharset());
} }
if (!StringUtils.isEmpty(device.getMediaServerId())) { if (!ObjectUtils.isEmpty(device.getMediaServerId())) {
deviceInStore.setMediaServerId(device.getMediaServerId()); deviceInStore.setMediaServerId(device.getMediaServerId());
} }

View File

@ -18,6 +18,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -168,7 +169,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
public void sendCatalogMsgs(List<GbStream> gbStreams, String type) { public void sendCatalogMsgs(List<GbStream> gbStreams, String type) {
if (gbStreams.size() > 0) { if (gbStreams.size() > 0) {
for (GbStream gs : gbStreams) { for (GbStream gs : gbStreams) {
if (StringUtils.isEmpty(gs.getGbId())){ if (ObjectUtils.isEmpty(gs.getGbId())){
continue; continue;
} }
List<ParentPlatform> parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream()); List<ParentPlatform> parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream());

View File

@ -8,6 +8,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -16,6 +18,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -91,7 +94,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
public void updateVmServer(List<MediaServerItem> mediaServerItemList) { public void updateVmServer(List<MediaServerItem> mediaServerItemList) {
logger.info("[zlm] 缓存初始化 "); logger.info("[zlm] 缓存初始化 ");
for (MediaServerItem mediaServerItem : mediaServerItemList) { for (MediaServerItem mediaServerItem : mediaServerItemList) {
if (StringUtils.isEmpty(mediaServerItem.getId())) { if (ObjectUtils.isEmpty(mediaServerItem.getId())) {
continue; continue;
} }
// 更新 // 更新
@ -287,8 +290,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
} }
@Override @Override
public WVPResult<String> add(MediaServerItem mediaServerItem) { public void add(MediaServerItem mediaServerItem) {
WVPResult<String> result = new WVPResult<>();
mediaServerItem.setCreateTime(DateUtil.getNow()); mediaServerItem.setCreateTime(DateUtil.getNow());
mediaServerItem.setUpdateTime(DateUtil.getNow()); mediaServerItem.setUpdateTime(DateUtil.getNow());
mediaServerItem.setHookAliveInterval(120); mediaServerItem.setHookAliveInterval(120);
@ -298,26 +300,19 @@ public class MediaServerServiceImpl implements IMediaServerService {
if (data != null && data.size() > 0) { if (data != null && data.size() > 0) {
ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) { if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(),"保存失败媒体服务ID [ " + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置");
result.setMsg("保存失败媒体服务ID [ " + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置");
return result;
} }
mediaServerItem.setId(zlmServerConfig.getGeneralMediaServerId()); mediaServerItem.setId(zlmServerConfig.getGeneralMediaServerId());
zlmServerConfig.setIp(mediaServerItem.getIp()); zlmServerConfig.setIp(mediaServerItem.getIp());
mediaServerMapper.add(mediaServerItem); mediaServerMapper.add(mediaServerItem);
zlmServerOnline(zlmServerConfig); zlmServerOnline(zlmServerConfig);
result.setCode(0);
result.setMsg("success");
}else { }else {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(),"连接失败");
result.setMsg("连接失败");
} }
}else { }else {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(),"连接失败");
result.setMsg("连接失败");
} }
return result;
} }
@Override @Override
@ -385,7 +380,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
} }
serverItem.setStatus(true); serverItem.setStatus(true);
if (StringUtils.isEmpty(serverItem.getId())) { if (ObjectUtils.isEmpty(serverItem.getId())) {
logger.warn("[未注册的zlm] serverItem缺少ID 无法接入:{}{}", zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() ); logger.warn("[未注册的zlm] serverItem缺少ID 无法接入:{}{}", zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() );
return; return;
} }
@ -520,7 +515,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
// 最多等待未初始化的Track时间单位毫秒超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流 // 最多等待未初始化的Track时间单位毫秒超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流
// 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项 // 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项
param.put("general.wait_track_ready_ms", "3000" ); param.put("general.wait_track_ready_ms", "3000" );
if (mediaServerItem.isRtpEnable() && !StringUtils.isEmpty(mediaServerItem.getRtpPortRange())) { if (mediaServerItem.isRtpEnable() && !ObjectUtils.isEmpty(mediaServerItem.getRtpPortRange())) {
param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-")); param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-"));
} }
@ -547,12 +542,9 @@ public class MediaServerServiceImpl implements IMediaServerService {
@Override @Override
public WVPResult<MediaServerItem> checkMediaServer(String ip, int port, String secret) { public MediaServerItem checkMediaServer(String ip, int port, String secret) {
WVPResult<MediaServerItem> result = new WVPResult<>();
if (mediaServerMapper.queryOneByHostAndPort(ip, port) != null) { if (mediaServerMapper.queryOneByHostAndPort(ip, port) != null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "此连接已存在");
result.setMsg("此连接已存在");
return result;
} }
MediaServerItem mediaServerItem = new MediaServerItem(); MediaServerItem mediaServerItem = new MediaServerItem();
mediaServerItem.setIp(ip); mediaServerItem.setIp(ip);
@ -560,21 +552,15 @@ public class MediaServerServiceImpl implements IMediaServerService {
mediaServerItem.setSecret(secret); mediaServerItem.setSecret(secret);
JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
if (responseJSON == null) { if (responseJSON == null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接失败");
result.setMsg("连接失败");
return result;
} }
JSONArray data = responseJSON.getJSONArray("data"); JSONArray data = responseJSON.getJSONArray("data");
ZLMServerConfig zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); ZLMServerConfig zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class);
if (zlmServerConfig == null) { if (zlmServerConfig == null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "读取配置失败");
result.setMsg("读取配置失败");
return result;
} }
if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) { if (mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId()) != null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "媒体服务ID [" + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置");
result.setMsg("媒体服务ID [" + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置");
return result;
} }
mediaServerItem.setHttpSSlPort(zlmServerConfig.getHttpPort()); mediaServerItem.setHttpSSlPort(zlmServerConfig.getHttpPort());
mediaServerItem.setRtmpPort(zlmServerConfig.getRtmpPort()); mediaServerItem.setRtmpPort(zlmServerConfig.getRtmpPort());
@ -586,10 +572,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
mediaServerItem.setHookIp(sipConfig.getIp()); mediaServerItem.setHookIp(sipConfig.getIp());
mediaServerItem.setSdpIp(ip); mediaServerItem.setSdpIp(ip);
mediaServerItem.setStreamNoneReaderDelayMS(zlmServerConfig.getGeneralStreamNoneReaderDelayMS()); mediaServerItem.setStreamNoneReaderDelayMS(zlmServerConfig.getGeneralStreamNoneReaderDelayMS());
result.setCode(0); return mediaServerItem;
result.setMsg("成功");
result.setData(mediaServerItem);
return result;
} }
@Override @Override

View File

@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@Service @Service
@ -94,7 +95,7 @@ public class MediaServiceImpl implements IMediaService {
} }
streamInfoResult.setIp(addr); streamInfoResult.setIp(addr);
streamInfoResult.setMediaServerId(mediaInfo.getId()); streamInfoResult.setMediaServerId(mediaInfo.getId());
String callIdParam = StringUtils.isEmpty(callId)?"":"?callId=" + callId; String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId;
streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam)); streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam));
if (mediaInfo.getRtmpSSlPort() != 0) { if (mediaInfo.getRtmpSSlPort() != 0) {
streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam)); streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam));
@ -121,7 +122,7 @@ public class MediaServiceImpl implements IMediaService {
streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam));
streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, StringUtils.isEmpty(callId)?"":"&callId=" + callId)); streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId));
} }
streamInfoResult.setTracks(tracks); streamInfoResult.setTracks(tracks);

View File

@ -6,12 +6,12 @@ import java.util.*;
import javax.sip.ResponseEvent; import javax.sip.ResponseEvent;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -37,7 +37,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
import com.genersoft.iot.vmp.media.zlm.dto.HookType;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
@ -52,7 +51,6 @@ import com.genersoft.iot.vmp.service.bean.PlayBackResult;
import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
@ -114,6 +112,9 @@ public class PlayServiceImpl implements IPlayService {
public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId,
ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, ZLMHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
Runnable timeoutCallback) { Runnable timeoutCallback) {
if (mediaServerItem == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
}
PlayResult playResult = new PlayResult(); PlayResult playResult = new PlayResult();
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
@ -121,18 +122,11 @@ public class PlayServiceImpl implements IPlayService {
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
msg.setId(uuid); msg.setId(uuid);
playResult.setUuid(uuid); playResult.setUuid(uuid);
DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); DeferredResult<WVPResult<String>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
playResult.setResult(result); playResult.setResult(result);
// 录像查询以channelId作为deviceId查询 // 录像查询以channelId作为deviceId查询
resultHolder.put(key, uuid, result); resultHolder.put(key, uuid, result);
if (mediaServerItem == null) {
WVPResult wvpResult = new WVPResult();
wvpResult.setCode(-1);
wvpResult.setMsg("未找到可用的zlm");
msg.setData(wvpResult);
resultHolder.invokeResult(msg);
return playResult;
}
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
playResult.setDevice(device); playResult.setDevice(device);
@ -143,17 +137,14 @@ public class PlayServiceImpl implements IPlayService {
// TODO 应该在上流时调用更好结束也可能是错误结束 // TODO 应该在上流时调用更好结束也可能是错误结束
String path = "snap"; String path = "snap";
String fileName = deviceId + "_" + channelId + ".jpg"; String fileName = deviceId + "_" + channelId + ".jpg";
ResponseEntity responseEntity = (ResponseEntity)result.getResult(); WVPResult wvpResult = (WVPResult)result.getResult();
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) { if (Objects.requireNonNull(wvpResult).getCode() == 0) {
WVPResult wvpResult = (WVPResult)responseEntity.getBody(); StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
if (Objects.requireNonNull(wvpResult).getCode() == 0) { MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); String streamUrl = streamInfoForSuccess.getFmp4();
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); // 请求截图
String streamUrl = streamInfoForSuccess.getFmp4(); logger.info("[请求截图]: " + fileName);
// 请求截图 zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
logger.info("[请求截图]: " + fileName);
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
}
} }
}); });
}); });
@ -161,7 +152,7 @@ public class PlayServiceImpl implements IPlayService {
String streamId = streamInfo.getStream(); String streamId = streamInfo.getStream();
if (streamId == null) { if (streamId == null) {
WVPResult wvpResult = new WVPResult(); WVPResult wvpResult = new WVPResult();
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("点播失败, redis缓存streamId等于null"); wvpResult.setMsg("点播失败, redis缓存streamId等于null");
msg.setData(wvpResult); msg.setData(wvpResult);
resultHolder.invokeAllResult(msg); resultHolder.invokeAllResult(msg);
@ -175,8 +166,8 @@ public class PlayServiceImpl implements IPlayService {
if (rtpInfo.getBoolean("exist")) { if (rtpInfo.getBoolean("exist")) {
WVPResult wvpResult = new WVPResult(); WVPResult wvpResult = new WVPResult();
wvpResult.setCode(0); wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg("success"); wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo); wvpResult.setData(streamInfo);
msg.setData(wvpResult); msg.setData(wvpResult);
@ -211,7 +202,7 @@ public class PlayServiceImpl implements IPlayService {
}, event -> { }, event -> {
// sip error错误 // sip error错误
WVPResult wvpResult = new WVPResult(); WVPResult wvpResult = new WVPResult();
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg)); wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
msg.setData(wvpResult); msg.setData(wvpResult);
resultHolder.invokeAllResult(msg); resultHolder.invokeAllResult(msg);
@ -221,7 +212,7 @@ public class PlayServiceImpl implements IPlayService {
}, (code, msgStr)->{ }, (code, msgStr)->{
// invite点播超时 // invite点播超时
WVPResult wvpResult = new WVPResult(); WVPResult wvpResult = new WVPResult();
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
if (code == 0) { if (code == 0) {
wvpResult.setMsg("点播超时,请稍候重试"); wvpResult.setMsg("点播超时,请稍候重试");
}else if (code == 1) { }else if (code == 1) {
@ -361,15 +352,15 @@ public class PlayServiceImpl implements IPlayService {
redisCatchStorage.startPlay(streamInfo); redisCatchStorage.startPlay(streamInfo);
WVPResult wvpResult = new WVPResult(); WVPResult wvpResult = new WVPResult();
wvpResult.setCode(0); wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg("success"); wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo); wvpResult.setData(streamInfo);
msg.setData(wvpResult); msg.setData(wvpResult);
resultHolder.invokeAllResult(msg); resultHolder.invokeAllResult(msg);
} else { } else {
logger.warn("设备预览API调用失败"); logger.warn("设备预览API调用失败");
msg.setData("设备预览API调用失败"); msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败"));
resultHolder.invokeAllResult(msg); resultHolder.invokeAllResult(msg);
} }
} }
@ -393,7 +384,7 @@ public class PlayServiceImpl implements IPlayService {
} }
@Override @Override
public DeferredResult<ResponseEntity<String>> playBack(String deviceId, String channelId, String startTime, public DeferredResult<String> playBack(String deviceId, String channelId, String startTime,
String endTime,InviteStreamCallback inviteStreamCallback, String endTime,InviteStreamCallback inviteStreamCallback,
PlayBackCallback callback) { PlayBackCallback callback) {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
@ -407,7 +398,7 @@ public class PlayServiceImpl implements IPlayService {
} }
@Override @Override
public DeferredResult<ResponseEntity<String>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, public DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
String deviceId, String channelId, String startTime, String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback infoCallBack, String endTime, InviteStreamCallback infoCallBack,
PlayBackCallback playBackCallback) { PlayBackCallback playBackCallback) {
@ -416,24 +407,21 @@ public class PlayServiceImpl implements IPlayService {
} }
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L);
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) { if (device == null) {
result.setResult(new ResponseEntity<>(HttpStatus.BAD_REQUEST)); throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在");
return result;
} }
DeferredResult<String> result = new DeferredResult<>(30000L);
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result); resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result);
RequestMessage msg = new RequestMessage(); RequestMessage requestMessage = new RequestMessage();
msg.setId(uuid); requestMessage.setId(uuid);
msg.setKey(key); requestMessage.setKey(key);
PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>(); PlayBackResult<RequestMessage> playBackResult = new PlayBackResult<>();
String playBackTimeOutTaskKey = UUID.randomUUID().toString(); String playBackTimeOutTaskKey = UUID.randomUUID().toString();
dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{ dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{
logger.warn(String.format("设备回放超时deviceId%s channelId%s", deviceId, channelId)); logger.warn(String.format("设备回放超时deviceId%s channelId%s", deviceId, channelId));
playBackResult.setCode(-1); playBackResult.setCode(-1);
playBackResult.setData(msg); playBackResult.setData(requestMessage);
playBackCallback.call(playBackResult);
SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream());
// 点播超时回复BYE 同时释放ssrc以及此次点播的资源 // 点播超时回复BYE 同时释放ssrc以及此次点播的资源
if (dialog != null) { if (dialog != null) {
@ -456,24 +444,23 @@ public class PlayServiceImpl implements IPlayService {
StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId);
if (streamInfo == null) { if (streamInfo == null) {
logger.warn("设备回放API调用失败"); logger.warn("设备回放API调用失败");
msg.setData("设备回放API调用失败");
playBackResult.setCode(-1); playBackResult.setCode(-1);
playBackResult.setData(msg);
playBackCallback.call(playBackResult); playBackCallback.call(playBackResult);
return; return;
} }
redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId()); redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId());
msg.setData(JSON.toJSONString(streamInfo)); WVPResult<StreamInfo> success = WVPResult.success(streamInfo);
requestMessage.setData(success);
playBackResult.setCode(0); playBackResult.setCode(0);
playBackResult.setData(msg); playBackResult.setData(requestMessage);
playBackResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); playBackResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem());
playBackResult.setResponse(inviteStreamInfo.getResponse()); playBackResult.setResponse(inviteStreamInfo.getResponse());
playBackCallback.call(playBackResult); playBackCallback.call(playBackResult);
}, event -> { }, event -> {
dynamicTask.stop(playBackTimeOutTaskKey); dynamicTask.stop(playBackTimeOutTaskKey);
msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)); requestMessage.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)));
playBackResult.setCode(-1); playBackResult.setCode(-1);
playBackResult.setData(msg); playBackResult.setData(requestMessage);
playBackResult.setEvent(event); playBackResult.setEvent(event);
playBackCallback.call(playBackResult); playBackCallback.call(playBackResult);
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
@ -482,7 +469,7 @@ public class PlayServiceImpl implements IPlayService {
} }
@Override @Override
public DeferredResult<ResponseEntity<String>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { public DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) { if (device == null) {
return null; return null;
@ -494,32 +481,31 @@ public class PlayServiceImpl implements IPlayService {
} }
@Override @Override
public DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { public DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
if (mediaServerItem == null || ssrcInfo == null) { if (mediaServerItem == null || ssrcInfo == null) {
return null; return null;
} }
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(30000L); DeferredResult<String> result = new DeferredResult<>(30000L);
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) { if (device == null) {
result.setResult(new ResponseEntity<>(HttpStatus.BAD_REQUEST)); throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在");
return result;
} }
resultHolder.put(key, uuid, result); resultHolder.put(key, uuid, result);
RequestMessage msg = new RequestMessage(); RequestMessage requestMessage = new RequestMessage();
msg.setId(uuid); requestMessage.setId(uuid);
msg.setKey(key); requestMessage.setKey(key);
WVPResult<StreamInfo> wvpResult = new WVPResult<>(); WVPResult<StreamInfo> wvpResult = new WVPResult<>();
msg.setData(wvpResult); requestMessage.setData(wvpResult);
PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>(); PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>();
downloadResult.setData(msg); downloadResult.setData(requestMessage);
String downLoadTimeOutTaskKey = UUID.randomUUID().toString(); String downLoadTimeOutTaskKey = UUID.randomUUID().toString();
dynamicTask.startDelay(downLoadTimeOutTaskKey, ()->{ dynamicTask.startDelay(downLoadTimeOutTaskKey, ()->{
logger.warn(String.format("录像下载请求超时deviceId%s channelId%s", deviceId, channelId)); logger.warn(String.format("录像下载请求超时deviceId%s channelId%s", deviceId, channelId));
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("录像下载请求超时"); wvpResult.setMsg("录像下载请求超时");
downloadResult.setCode(-1); downloadResult.setCode(-1);
hookCallBack.call(downloadResult); hookCallBack.call(downloadResult);
@ -545,8 +531,8 @@ public class PlayServiceImpl implements IPlayService {
streamInfo.setStartTime(startTime); streamInfo.setStartTime(startTime);
streamInfo.setEndTime(endTime); streamInfo.setEndTime(endTime);
redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId()); redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId());
wvpResult.setCode(0); wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg("success"); wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo); wvpResult.setData(streamInfo);
downloadResult.setCode(0); downloadResult.setCode(0);
downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem());
@ -555,7 +541,7 @@ public class PlayServiceImpl implements IPlayService {
}, event -> { }, event -> {
dynamicTask.stop(downLoadTimeOutTaskKey); dynamicTask.stop(downLoadTimeOutTaskKey);
downloadResult.setCode(-1); downloadResult.setCode(-1);
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg));
downloadResult.setEvent(event); downloadResult.setEvent(event);
hookCallBack.call(downloadResult); hookCallBack.call(downloadResult);
@ -616,7 +602,7 @@ public class PlayServiceImpl implements IPlayService {
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
} else { } else {
logger.warn("设备预览API调用失败"); logger.warn("设备预览API调用失败");
msg.setData("设备预览API调用失败"); msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败"));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
} }
} }

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.TreeType; import com.genersoft.iot.vmp.gb28181.bean.TreeType;
@ -24,6 +25,7 @@ import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -33,6 +35,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.net.InetAddress; import java.net.InetAddress;
@ -93,10 +96,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Override @Override
public WVPResult<StreamInfo> save(StreamProxyItem param) { public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo; MediaServerItem mediaInfo;
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
if (param.getMediaServerId() == null || "auto".equals(param.getMediaServerId())){ if (param.getMediaServerId() == null || "auto".equals(param.getMediaServerId())){
mediaInfo = mediaServerService.getMediaServerForMinimumLoad(); mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
}else { }else {
@ -104,14 +105,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
} }
if (mediaInfo == null) { if (mediaInfo == null) {
logger.warn("保存代理未找到在线的ZLM..."); logger.warn("保存代理未找到在线的ZLM...");
wvpResult.setMsg("保存失败"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "保存代理未找到在线的ZLM");
return wvpResult;
} }
String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
param.getStream() ); param.getStream() );
param.setDst_url(dstUrl); param.setDst_url(dstUrl);
StringBuffer result = new StringBuffer(); StringBuffer resultMsg = new StringBuffer();
boolean streamLive = false; boolean streamLive = false;
param.setMediaServerId(mediaInfo.getId()); param.setMediaServerId(mediaInfo.getId());
boolean saveResult; boolean saveResult;
@ -121,43 +120,47 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
}else { // 新增 }else { // 新增
saveResult = addStreamProxy(param); saveResult = addStreamProxy(param);
} }
if (saveResult) { if (!saveResult) {
result.append("保存成功"); throw new ControllerException(ErrorCode.ERROR100.getCode(),"保存失败");
if (param.isEnable()) {
JSONObject jsonObject = addStreamProxyToZlm(param);
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
streamLive = false;
result.append(", 但是启用失败,请检查流地址是否可用");
param.setEnable(false);
// 直接移除
if (param.isEnable_remove_none_reader()) {
del(param.getApp(), param.getStream());
}else {
updateStreamProxy(param);
}
}else {
streamLive = true;
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
mediaInfo, param.getApp(), param.getStream(), null, null);
wvpResult.setData(streamInfo);
}
}
}else {
result.append("保存失败");
} }
if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) { StreamInfo resultForStreamInfo = null;
resultMsg.append("保存成功");
if (param.isEnable()) {
JSONObject jsonObject = addStreamProxyToZlm(param);
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
streamLive = false;
resultMsg.append(", 但是启用失败,请检查流地址是否可用");
param.setEnable(false);
// 直接移除
if (param.isEnable_remove_none_reader()) {
del(param.getApp(), param.getStream());
}else {
updateStreamProxy(param);
}
}else {
streamLive = true;
resultForStreamInfo = mediaService.getStreamInfoByAppAndStream(
mediaInfo, param.getApp(), param.getStream(), null, null);
}
}
if ( !ObjectUtils.isEmpty(param.getPlatformGbId()) && streamLive) {
List<GbStream> gbStreams = new ArrayList<>(); List<GbStream> gbStreams = new ArrayList<>();
gbStreams.add(param); gbStreams.add(param);
if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){ if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]成功"); return resultForStreamInfo;
}else { }else {
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败"); resultMsg.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());
}
}else {
if (!streamLive) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), resultMsg.toString());
} }
} }
wvpResult.setMsg(result.toString()); return resultForStreamInfo;
return wvpResult;
} }
/** /**
@ -174,7 +177,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
streamProxyItem.setCreateTime(now); streamProxyItem.setCreateTime(now);
try { try {
if (streamProxyMapper.add(streamProxyItem) > 0) { if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.add(streamProxyItem) < 0) { if (gbStreamMapper.add(streamProxyItem) < 0) {
//事务回滚 //事务回滚
dataSourceTransactionManager.rollback(transactionStatus); dataSourceTransactionManager.rollback(transactionStatus);
@ -209,7 +212,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
streamProxyItem.setStreamType("proxy"); streamProxyItem.setStreamType("proxy");
try { try {
if (streamProxyMapper.update(streamProxyItem) > 0) { if (streamProxyMapper.update(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) { if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
//事务回滚 //事务回滚
dataSourceTransactionManager.rollback(transactionStatus); dataSourceTransactionManager.rollback(transactionStatus);

View File

@ -27,6 +27,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
@ -208,7 +209,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>(); Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>();
if (pushList.size() > 0) { if (pushList.size() > 0) {
for (StreamPushItem streamPushItem : pushList) { for (StreamPushItem streamPushItem : pushList) {
if (StringUtils.isEmpty(streamPushItem.getGbId())) { if (ObjectUtils.isEmpty(streamPushItem.getGbId())) {
pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
} }
} }
@ -492,7 +493,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
try { try {
int addStreamResult = streamPushMapper.add(stream); int addStreamResult = streamPushMapper.add(stream);
if (!StringUtils.isEmpty(stream.getGbId())) { if (!ObjectUtils.isEmpty(stream.getGbId())) {
stream.setStreamType("push"); stream.setStreamType("push");
gbStreamMapper.add(stream); gbStreamMapper.add(stream);
} }

View File

@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
@ -82,9 +83,9 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
@Override @Override
public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) { public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) {
if (StringUtils.isEmpty(streamPushExcelDto.getApp()) if (ObjectUtils.isEmpty(streamPushExcelDto.getApp())
|| StringUtils.isEmpty(streamPushExcelDto.getStream()) || ObjectUtils.isEmpty(streamPushExcelDto.getStream())
|| StringUtils.isEmpty(streamPushExcelDto.getGbId())) { || ObjectUtils.isEmpty(streamPushExcelDto.getGbId())) {
return; return;
} }
@ -130,7 +131,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
streamPushItems.add(streamPushItem); streamPushItems.add(streamPushItem);
streamPushItemForSave.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); streamPushItemForSave.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
if (!StringUtils.isEmpty(streamPushExcelDto.getPlatformId())) { if (!ObjectUtils.isEmpty(streamPushExcelDto.getPlatformId())) {
List<String[]> platformList = streamPushItemsForPlatform.get(streamPushItem.getApp() + streamPushItem.getStream()); List<String[]> platformList = streamPushItemsForPlatform.get(streamPushItem.getApp() + streamPushItem.getStream());
if (platformList == null) { if (platformList == null) {
platformList = new ArrayList<>(); platformList = new ArrayList<>();
@ -138,7 +139,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
} }
String platformId = streamPushExcelDto.getPlatformId(); String platformId = streamPushExcelDto.getPlatformId();
String catalogId = streamPushExcelDto.getCatalogId(); String catalogId = streamPushExcelDto.getCatalogId();
if (StringUtils.isEmpty(streamPushExcelDto.getCatalogId())) { if (ObjectUtils.isEmpty(streamPushExcelDto.getCatalogId())) {
catalogId = null; catalogId = null;
} }
String[] platFormInfoArray = new String[]{platformId, catalogId}; String[] platFormInfoArray = new String[]{platformId, catalogId};

View File

@ -7,6 +7,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
@ -60,7 +61,7 @@ public class UserServiceImpl implements IUserService {
@Override @Override
public boolean checkPushAuthority(String callId, String sign) { public boolean checkPushAuthority(String callId, String sign) {
if (StringUtils.isEmpty(callId)) { if (ObjectUtils.isEmpty(callId)) {
return userMapper.checkPushAuthorityByCallId(sign).size() > 0; return userMapper.checkPushAuthorityByCallId(sign).size() > 0;
}else { }else {
return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0; return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0;

View File

@ -26,6 +26,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
@ -132,7 +133,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId()); deviceChannel.setStreamId(allChannelMapInPlay.get(deviceChannel.getChannelId()).getStreamId());
} }
channels.add(deviceChannel); channels.add(deviceChannel);
if (!StringUtils.isEmpty(deviceChannel.getParentId())) { if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) { if (subContMap.get(deviceChannel.getParentId()) == null) {
subContMap.put(deviceChannel.getParentId(), 1); subContMap.put(deviceChannel.getParentId(), 1);
}else { }else {

View File

@ -0,0 +1,31 @@
package com.genersoft.iot.vmp.vmanager.bean;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 全局错误码
*/
public enum ErrorCode {
SUCCESS(0, "成功"),
ERROR100(100, "失败"),
ERROR400(400, "参数不全或者错误"),
ERROR403(403, "无权限操作"),
ERROR401(401, "请登录后重新请求"),
ERROR500(500, "系统异常");
private final int code;
private final String msg;
ErrorCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}

View File

@ -1,4 +1,4 @@
package com.genersoft.iot.vmp.vmanager.gb28181.session; package com.genersoft.iot.vmp.vmanager.bean;
public enum PlayTypeEnum { public enum PlayTypeEnum {

View File

@ -23,23 +23,21 @@ public class WVPResult<T> {
@Schema(description = "数据") @Schema(description = "数据")
private T data; private T data;
private static final Integer SUCCESS = 200;
private static final Integer FAILED = 400;
public static <T> WVPResult<T> Data(T t, String msg) { public static <T> WVPResult<T> success(T t, String msg) {
return new WVPResult<>(SUCCESS, msg, t); return new WVPResult<>(ErrorCode.SUCCESS.getCode(), msg, t);
} }
public static <T> WVPResult<T> Data(T t) { public static <T> WVPResult<T> success(T t) {
return Data(t, "成功"); return success(t, ErrorCode.SUCCESS.getMsg());
} }
public static <T> WVPResult<T> fail(int code, String msg) { public static <T> WVPResult<T> fail(int code, String msg) {
return new WVPResult<>(code, msg, null); return new WVPResult<>(code, msg, null);
} }
public static <T> WVPResult<T> fail(String msg) { public static <T> WVPResult<T> fail(ErrorCode errorCode) {
return fail(FAILED, msg); return fail(errorCode.getCode(), errorCode.getMsg());
} }
public int getCode() { public int getCode() {

View File

@ -65,7 +65,7 @@ public class MobilePositionController {
@Parameter(name = "start", description = "开始时间") @Parameter(name = "start", description = "开始时间")
@Parameter(name = "end", description = "结束时间") @Parameter(name = "end", description = "结束时间")
@GetMapping("/history/{deviceId}") @GetMapping("/history/{deviceId}")
public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId, public List<MobilePosition> positions(@PathVariable String deviceId,
@RequestParam(required = false) String channelId, @RequestParam(required = false) String channelId,
@RequestParam(required = false) String start, @RequestParam(required = false) String start,
@RequestParam(required = false) String end) { @RequestParam(required = false) String end) {
@ -76,11 +76,7 @@ public class MobilePositionController {
if (StringUtil.isEmpty(end)) { if (StringUtil.isEmpty(end)) {
end = null; end = null;
} }
WVPResult<List<MobilePosition>> wvpResult = new WVPResult<>(); return storager.queryMobilePositions(deviceId, channelId, start, end);
wvpResult.setCode(0);
List<MobilePosition> result = storager.queryMobilePositions(deviceId, channelId, start, end);
wvpResult.setData(result);
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
/** /**
@ -91,9 +87,8 @@ public class MobilePositionController {
@Operation(summary = "查询设备最新位置") @Operation(summary = "查询设备最新位置")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/latest/{deviceId}") @GetMapping("/latest/{deviceId}")
public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) { public MobilePosition latestPosition(@PathVariable String deviceId) {
MobilePosition result = storager.queryLatestPosition(deviceId); return storager.queryLatestPosition(deviceId);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
/** /**
@ -104,7 +99,7 @@ public class MobilePositionController {
@Operation(summary = "获取移动位置信息") @Operation(summary = "获取移动位置信息")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/realtime/{deviceId}") @GetMapping("/realtime/{deviceId}")
public DeferredResult<ResponseEntity<MobilePosition>> realTimePosition(@PathVariable String deviceId) { public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId;
@ -115,7 +110,7 @@ public class MobilePositionController {
msg.setData(String.format("获取移动位置信息失败,错误码: %s, %s", event.statusCode, event.msg)); msg.setData(String.format("获取移动位置信息失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
}); });
DeferredResult<ResponseEntity<MobilePosition>> result = new DeferredResult<ResponseEntity<MobilePosition>>(5*1000L); DeferredResult<MobilePosition> result = new DeferredResult<MobilePosition>(5*1000L);
result.onTimeout(()->{ result.onTimeout(()->{
logger.warn(String.format("获取移动位置信息超时")); logger.warn(String.format("获取移动位置信息超时"));
// 释放rtpserver // 释放rtpserver
@ -141,7 +136,7 @@ public class MobilePositionController {
@Parameter(name = "expires", description = "订阅超时时间", required = true) @Parameter(name = "expires", description = "订阅超时时间", required = true)
@Parameter(name = "interval", description = "上报时间间隔", required = true) @Parameter(name = "interval", description = "上报时间间隔", required = true)
@GetMapping("/subscribe/{deviceId}") @GetMapping("/subscribe/{deviceId}")
public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId, public String positionSubscribe(@PathVariable String deviceId,
@RequestParam String expires, @RequestParam String expires,
@RequestParam String interval) { @RequestParam String interval) {
String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置"; String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置";
@ -163,6 +158,6 @@ public class MobilePositionController {
result += ",失败"; result += ",失败";
} }
return new ResponseEntity<>(result, HttpStatus.OK); return result;
} }
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.vmanager.gb28181.alarm; package com.genersoft.iot.vmp.vmanager.gb28181.alarm;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@ -8,14 +9,17 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.IDeviceAlarmService; import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -55,22 +59,22 @@ public class AlarmController {
@Parameter(name = "id", description = "ID") @Parameter(name = "id", description = "ID")
@Parameter(name = "deviceIds", description = "多个设备id,逗号分隔") @Parameter(name = "deviceIds", description = "多个设备id,逗号分隔")
@Parameter(name = "time", description = "结束时间") @Parameter(name = "time", description = "结束时间")
public ResponseEntity<WVPResult<String>> delete( public Integer delete(
@RequestParam(required = false) Integer id, @RequestParam(required = false) Integer id,
@RequestParam(required = false) String deviceIds, @RequestParam(required = false) String deviceIds,
@RequestParam(required = false) String time @RequestParam(required = false) String time
) { ) {
if (StringUtils.isEmpty(id)) { if (ObjectUtils.isEmpty(id)) {
id = null; id = null;
} }
if (StringUtils.isEmpty(deviceIds)) { if (ObjectUtils.isEmpty(deviceIds)) {
deviceIds = null; deviceIds = null;
} }
if (StringUtils.isEmpty(time)) { if (ObjectUtils.isEmpty(time)) {
time = null; time = null;
} }
if (!DateUtil.verification(time, DateUtil.formatter) ){ if (!DateUtil.verification(time, DateUtil.formatter) ){
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); return null;
} }
List<String> deviceIdList = null; List<String> deviceIdList = null;
if (deviceIds != null) { if (deviceIds != null) {
@ -78,12 +82,7 @@ public class AlarmController {
deviceIdList = Arrays.asList(deviceIdArray); deviceIdList = Arrays.asList(deviceIdArray);
} }
int count = deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time); return deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time);
WVPResult wvpResult = new WVPResult();
wvpResult.setCode(0);
wvpResult.setMsg("success");
wvpResult.setData(count);
return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
} }
/** /**
@ -95,12 +94,7 @@ public class AlarmController {
@GetMapping("/test/notify/alarm") @GetMapping("/test/notify/alarm")
@Operation(summary = "测试向上级/设备发送模拟报警通知") @Operation(summary = "测试向上级/设备发送模拟报警通知")
@Parameter(name = "deviceId", description = "设备国标编号") @Parameter(name = "deviceId", description = "设备国标编号")
public ResponseEntity<WVPResult<String>> delete( public void delete(@RequestParam String deviceId) {
@RequestParam(required = false) String deviceId
) {
if (StringUtils.isEmpty(deviceId)) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Device device = storage.queryVideoDevice(deviceId); Device device = storage.queryVideoDevice(deviceId);
ParentPlatform platform = storage.queryParentPlatByServerGBId(deviceId); ParentPlatform platform = storage.queryParentPlatByServerGBId(deviceId);
DeviceAlarm deviceAlarm = new DeviceAlarm(); DeviceAlarm deviceAlarm = new DeviceAlarm();
@ -118,16 +112,9 @@ public class AlarmController {
}else if (device == null && platform != null){ }else if (device == null && platform != null){
commanderForPlatform.sendAlarmMessage(platform, deviceAlarm); commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
}else { }else {
WVPResult wvpResult = new WVPResult(); throw new ControllerException(ErrorCode.ERROR100.getCode(),"无法确定" + deviceId + "是平台还是设备");
wvpResult.setCode(0);
wvpResult.setMsg("无法确定" + deviceId + "是平台还是设备");
return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
} }
WVPResult wvpResult = new WVPResult();
wvpResult.setCode(0);
wvpResult.setMsg("success");
return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
} }
/** /**
@ -153,7 +140,7 @@ public class AlarmController {
@Parameter(name = "startTime",description = "开始时间") @Parameter(name = "startTime",description = "开始时间")
@Parameter(name = "endTime",description = "结束时间") @Parameter(name = "endTime",description = "结束时间")
@GetMapping("/all") @GetMapping("/all")
public ResponseEntity<PageInfo<DeviceAlarm>> getAll( public PageInfo<DeviceAlarm> getAll(
@RequestParam int page, @RequestParam int page,
@RequestParam int count, @RequestParam int count,
@RequestParam(required = false) String deviceId, @RequestParam(required = false) String deviceId,
@ -163,31 +150,28 @@ public class AlarmController {
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime @RequestParam(required = false) String endTime
) { ) {
if (StringUtils.isEmpty(alarmPriority)) { if (ObjectUtils.isEmpty(alarmPriority)) {
alarmPriority = null; alarmPriority = null;
} }
if (StringUtils.isEmpty(alarmMethod)) { if (ObjectUtils.isEmpty(alarmMethod)) {
alarmMethod = null; alarmMethod = null;
} }
if (StringUtils.isEmpty(alarmType)) { if (ObjectUtils.isEmpty(alarmType)) {
alarmType = null; alarmType = null;
} }
if (StringUtils.isEmpty(startTime)) { if (ObjectUtils.isEmpty(startTime)) {
startTime = null; startTime = null;
} }
if (StringUtils.isEmpty(endTime)) { if (ObjectUtils.isEmpty(endTime)) {
endTime = null; endTime = null;
} }
if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间或结束时间格式有误");
} }
PageInfo<DeviceAlarm> allAlarm = deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod, return deviceAlarmService.getAllAlarm(page, count, deviceId, alarmPriority, alarmMethod,
alarmType, startTime, endTime); alarmType, startTime, endTime);
return new ResponseEntity<>(allAlarm, HttpStatus.OK);
} }
} }

View File

@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -62,7 +63,7 @@ public class DeviceConfig {
@Parameter(name = "expiration", description = "到期时间") @Parameter(name = "expiration", description = "到期时间")
@Parameter(name = "heartBeatInterval", description = "心跳间隔") @Parameter(name = "heartBeatInterval", description = "心跳间隔")
@Parameter(name = "heartBeatCount", description = "心跳计数") @Parameter(name = "heartBeatCount", description = "心跳计数")
public DeferredResult<ResponseEntity<String>> homePositionApi(@PathVariable String deviceId, public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
String channelId, String channelId,
@RequestParam(required = false) String name, @RequestParam(required = false) String name,
@RequestParam(required = false) String expiration, @RequestParam(required = false) String expiration,
@ -81,7 +82,7 @@ public class DeviceConfig {
msg.setData(String.format("设备配置操作失败,错误码: %s, %s", event.statusCode, event.msg)); msg.setData(String.format("设备配置操作失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
}); });
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L); DeferredResult<String> result = new DeferredResult<String>(3 * 1000L);
result.onTimeout(() -> { result.onTimeout(() -> {
logger.warn(String.format("设备配置操作超时, 设备未返回应答指令")); logger.warn(String.format("设备配置操作超时, 设备未返回应答指令"));
// 释放rtpserver // 释放rtpserver
@ -111,13 +112,13 @@ public class DeviceConfig {
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "configType", description = "配置类型") @Parameter(name = "configType", description = "配置类型")
@GetMapping("/query/{deviceId}/{configType}") @GetMapping("/query/{deviceId}/{configType}")
public DeferredResult<ResponseEntity<String>> configDownloadApi(@PathVariable String deviceId, public DeferredResult<String> configDownloadApi(@PathVariable String deviceId,
@PathVariable String configType, @PathVariable String configType,
@RequestParam(required = false) String channelId) { @RequestParam(required = false) String channelId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("设备状态查询API调用"); logger.debug("设备状态查询API调用");
} }
String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (StringUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
cmder.deviceConfigQuery(device, channelId, configType, event -> { cmder.deviceConfigQuery(device, channelId, configType, event -> {
@ -127,7 +128,7 @@ public class DeviceConfig {
msg.setData(String.format("获取设备配置失败,错误码: %s, %s", event.statusCode, event.msg)); msg.setData(String.format("获取设备配置失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
}); });
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String >> (3 * 1000L); DeferredResult<String> result = new DeferredResult<String > (3 * 1000L);
result.onTimeout(()->{ result.onTimeout(()->{
logger.warn(String.format("获取设备配置超时")); logger.warn(String.format("获取设备配置超时"));
// 释放rtpserver // 释放rtpserver

View File

@ -8,12 +8,14 @@
package com.genersoft.iot.vmp.vmanager.gb28181.device; package com.genersoft.iot.vmp.vmanager.gb28181.device;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device; 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.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 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.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -22,6 +24,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -50,14 +53,10 @@ public class DeviceControl {
* *
* @param deviceId 设备ID * @param deviceId 设备ID
*/ */
// //@ApiOperation("远程启动控制命令")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "deviceId", value ="设备ID", required = true, dataTypeClass = String.class),
// })
@Operation(summary = "远程启动控制命令") @Operation(summary = "远程启动控制命令")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/teleboot/{deviceId}") @GetMapping("/teleboot/{deviceId}")
public ResponseEntity<String> teleBootApi(@PathVariable String deviceId) { public String teleBootApi(@PathVariable String deviceId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("设备远程启动API调用"); logger.debug("设备远程启动API调用");
} }
@ -67,10 +66,10 @@ public class DeviceControl {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("DeviceID", deviceId); json.put("DeviceID", deviceId);
json.put("Result", "OK"); json.put("Result", "OK");
return new ResponseEntity<>(json.toJSONString(), HttpStatus.OK); return json.toJSONString();
} else { } else {
logger.warn("设备远程启动API调用失败"); logger.warn("设备远程启动API调用失败");
return new ResponseEntity<String>("设备远程启动API调用失败", HttpStatus.INTERNAL_SERVER_ERROR); throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备远程启动API调用失败");
} }
} }
@ -255,7 +254,7 @@ public class DeviceControl {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("报警复位API调用"); logger.debug("报警复位API调用");
} }
String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
@ -17,6 +18,7 @@ import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree; import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -30,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -81,10 +84,9 @@ public class DeviceQuery {
@Operation(summary = "查询国标设备") @Operation(summary = "查询国标设备")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/devices/{deviceId}") @GetMapping("/devices/{deviceId}")
public ResponseEntity<Device> devices(@PathVariable String deviceId){ public Device devices(@PathVariable String deviceId){
Device device = storager.queryVideoDevice(deviceId); return storager.queryVideoDevice(deviceId);
return new ResponseEntity<>(device,HttpStatus.OK);
} }
/** /**
@ -123,18 +125,17 @@ public class DeviceQuery {
@Parameter(name = "online", description = "是否在线") @Parameter(name = "online", description = "是否在线")
@Parameter(name = "channelType", description = "设备/子目录-> false/true") @Parameter(name = "channelType", description = "设备/子目录-> false/true")
@Parameter(name = "catalogUnderDevice", description = "是否直属与设备的目录") @Parameter(name = "catalogUnderDevice", description = "是否直属与设备的目录")
public ResponseEntity<PageInfo> channels(@PathVariable String deviceId, public PageInfo channels(@PathVariable String deviceId,
int page, int count, int page, int count,
@RequestParam(required = false) String query, @RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online, @RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType, @RequestParam(required = false) Boolean channelType,
@RequestParam(required = false) Boolean catalogUnderDevice) { @RequestParam(required = false) Boolean catalogUnderDevice) {
if (StringUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, catalogUnderDevice, page, count); return storager.queryChannelsByDeviceId(deviceId, query, channelType, online, catalogUnderDevice, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
} }
/** /**
@ -154,11 +155,8 @@ public class DeviceQuery {
boolean status = deviceService.isSyncRunning(deviceId); boolean status = deviceService.isSyncRunning(deviceId);
// 已存在则返回进度 // 已存在则返回进度
if (status) { if (status) {
WVPResult<SyncStatus> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
wvpResult.setData(channelSyncStatus); return WVPResult.success(channelSyncStatus);
return wvpResult;
} }
deviceService.sync(device); deviceService.sync(device);
@ -176,7 +174,7 @@ public class DeviceQuery {
@Operation(summary = "移除设备") @Operation(summary = "移除设备")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@DeleteMapping("/devices/{deviceId}/delete") @DeleteMapping("/devices/{deviceId}/delete")
public ResponseEntity<String> delete(@PathVariable String deviceId){ public String delete(@PathVariable String deviceId){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("设备信息删除API调用deviceId" + deviceId); logger.debug("设备信息删除API调用deviceId" + deviceId);
@ -200,10 +198,10 @@ public class DeviceQuery {
} }
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("deviceId", deviceId); json.put("deviceId", deviceId);
return new ResponseEntity<>(json.toString(),HttpStatus.OK); return json.toString();
} else { } else {
logger.warn("设备信息删除API调用失败"); logger.warn("设备信息删除API调用失败");
return new ResponseEntity<String>("设备信息删除API调用失败", HttpStatus.INTERNAL_SERVER_ERROR); throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备信息删除API调用失败");
} }
} }
@ -402,7 +400,8 @@ public class DeviceQuery {
wvpResult.setCode(-1); wvpResult.setCode(-1);
wvpResult.setMsg("同步尚未开始"); wvpResult.setMsg("同步尚未开始");
}else { }else {
wvpResult.setCode(0); wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(channelSyncStatus); wvpResult.setData(channelSyncStatus);
if (channelSyncStatus.getErrorMsg() != null) { if (channelSyncStatus.getErrorMsg() != null) {
wvpResult.setMsg(channelSyncStatus.getErrorMsg()); wvpResult.setMsg(channelSyncStatus.getErrorMsg());

View File

@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -51,13 +52,13 @@ public class GbStreamController {
@RequestParam(required = false)String catalogId, @RequestParam(required = false)String catalogId,
@RequestParam(required = false)String query, @RequestParam(required = false)String query,
@RequestParam(required = false)String mediaServerId){ @RequestParam(required = false)String mediaServerId){
if (StringUtils.isEmpty(catalogId)) { if (ObjectUtils.isEmpty(catalogId)) {
catalogId = null; catalogId = null;
} }
if (StringUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
if (StringUtils.isEmpty(mediaServerId)) { if (ObjectUtils.isEmpty(mediaServerId)) {
mediaServerId = null; mediaServerId = null;
} }

View File

@ -1,12 +1,14 @@
package com.genersoft.iot.vmp.vmanager.gb28181.media; package com.genersoft.iot.vmp.vmanager.gb28181.media;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils; import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -51,7 +53,7 @@ public class MediaController {
@Parameter(name = "useSourceIpAsStreamIp", description = "是否使用请求IP作为返回的地址IP") @Parameter(name = "useSourceIpAsStreamIp", description = "是否使用请求IP作为返回的地址IP")
@GetMapping(value = "/stream_info_by_app_and_stream") @GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody @ResponseBody
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, public StreamInfo getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app,
@RequestParam String stream, @RequestParam String stream,
@RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String mediaServerId,
@RequestParam(required = false) String callId, @RequestParam(required = false) String callId,
@ -63,10 +65,7 @@ public class MediaController {
if (streamAuthorityInfo.getCallId().equals(callId)) { if (streamAuthorityInfo.getCallId().equals(callId)) {
authority = true; authority = true;
}else { }else {
WVPResult<StreamInfo> result = new WVPResult<>(); throw new ControllerException(ErrorCode.ERROR400);
result.setCode(401);
result.setMsg("fail");
return result;
} }
}else { }else {
// 是否登陆用户, 登陆用户返回完整信息 // 是否登陆用户, 登陆用户返回完整信息
@ -89,9 +88,7 @@ public class MediaController {
WVPResult<StreamInfo> result = new WVPResult<>(); WVPResult<StreamInfo> result = new WVPResult<>();
if (streamInfo != null){ if (streamInfo != null){
result.setCode(0); return streamInfo;
result.setMsg("scccess");
result.setData(streamInfo);
}else { }else {
//获取流失败重启拉流后重试一次 //获取流失败重启拉流后重试一次
streamProxyService.stop(app,stream); streamProxyService.stop(app,stream);
@ -110,14 +107,10 @@ public class MediaController {
streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
} }
if (streamInfo != null){ if (streamInfo != null){
result.setCode(0); return streamInfo;
result.setMsg("scccess");
result.setData(streamInfo);
}else { }else {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100);
result.setMsg("fail");
} }
} }
return result;
} }
} }

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
@ -14,6 +15,7 @@ import com.genersoft.iot.vmp.service.IPlatformChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
@ -26,6 +28,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
@ -74,13 +77,13 @@ public class PlatformController {
*/ */
@Operation(summary = "获取国标服务的配置") @Operation(summary = "获取国标服务的配置")
@GetMapping("/server_config") @GetMapping("/server_config")
public ResponseEntity<JSONObject> serverConfig() { public JSONObject serverConfig() {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("deviceIp", sipConfig.getIp()); result.put("deviceIp", sipConfig.getIp());
result.put("devicePort", sipConfig.getPort()); result.put("devicePort", sipConfig.getPort());
result.put("username", sipConfig.getId()); result.put("username", sipConfig.getId());
result.put("password", sipConfig.getPassword()); result.put("password", sipConfig.getPassword());
return new ResponseEntity<>(result, HttpStatus.OK); return result;
} }
/** /**
@ -91,18 +94,14 @@ public class PlatformController {
@Operation(summary = "获取级联服务器信息") @Operation(summary = "获取级联服务器信息")
@Parameter(name = "id", description = "平台国标编号", required = true) @Parameter(name = "id", description = "平台国标编号", required = true)
@GetMapping("/info/{id}") @GetMapping("/info/{id}")
public ResponseEntity<WVPResult<ParentPlatform>> getPlatform(@PathVariable String id) { public ParentPlatform getPlatform(@PathVariable String id) {
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(id); ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(id);
WVPResult<ParentPlatform> wvpResult = new WVPResult<>(); WVPResult<ParentPlatform> wvpResult = new WVPResult<>();
if (parentPlatform != null) { if (parentPlatform != null) {
wvpResult.setCode(0); return parentPlatform;
wvpResult.setMsg("success");
wvpResult.setData(parentPlatform);
} else { } else {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未查询到此平台");
wvpResult.setMsg("未查询到此平台");
} }
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
/** /**
@ -137,38 +136,31 @@ public class PlatformController {
@Operation(summary = "添加上级平台信息") @Operation(summary = "添加上级平台信息")
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<String>> addPlatform(@RequestBody ParentPlatform parentPlatform) { public String addPlatform(@RequestBody ParentPlatform parentPlatform) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("保存上级平台信息API调用"); logger.debug("保存上级平台信息API调用");
} }
WVPResult<String> wvpResult = new WVPResult<>(); if (ObjectUtils.isEmpty(parentPlatform.getName())
if (StringUtils.isEmpty(parentPlatform.getName()) || ObjectUtils.isEmpty(parentPlatform.getServerGBId())
|| StringUtils.isEmpty(parentPlatform.getServerGBId()) || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain())
|| StringUtils.isEmpty(parentPlatform.getServerGBDomain()) || ObjectUtils.isEmpty(parentPlatform.getServerIP())
|| StringUtils.isEmpty(parentPlatform.getServerIP()) || ObjectUtils.isEmpty(parentPlatform.getServerPort())
|| StringUtils.isEmpty(parentPlatform.getServerPort()) || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId())
|| StringUtils.isEmpty(parentPlatform.getDeviceGBId()) || ObjectUtils.isEmpty(parentPlatform.getExpires())
|| StringUtils.isEmpty(parentPlatform.getExpires()) || ObjectUtils.isEmpty(parentPlatform.getKeepTimeout())
|| StringUtils.isEmpty(parentPlatform.getKeepTimeout()) || ObjectUtils.isEmpty(parentPlatform.getTransport())
|| StringUtils.isEmpty(parentPlatform.getTransport()) || ObjectUtils.isEmpty(parentPlatform.getCharacterSet())
|| StringUtils.isEmpty(parentPlatform.getCharacterSet())
) { ) {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR400);
wvpResult.setMsg("missing parameters");
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
} }
if (parentPlatform.getServerPort() < 0 || parentPlatform.getServerPort() > 65535) { if (parentPlatform.getServerPort() < 0 || parentPlatform.getServerPort() > 65535) {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR400.getCode(), "error severPort");
wvpResult.setMsg("error severPort");
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
} }
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
if (parentPlatformOld != null) { if (parentPlatformOld != null) {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台 " + parentPlatform.getServerGBId() + " 已存在");
wvpResult.setMsg("平台 " + parentPlatform.getServerGBId() + " 已存在");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
parentPlatform.setCreateTime(DateUtil.getNow()); parentPlatform.setCreateTime(DateUtil.getNow());
parentPlatform.setUpdateTime(DateUtil.getNow()); parentPlatform.setUpdateTime(DateUtil.getNow());
@ -190,13 +182,9 @@ public class PlatformController {
} else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销 } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销
commanderForPlatform.unregister(parentPlatform, null, null); commanderForPlatform.unregister(parentPlatform, null, null);
} }
wvpResult.setCode(0); return null;
wvpResult.setMsg("success");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} else { } else {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(),"写入数据库失败");
wvpResult.setMsg("写入数据库失败");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
} }
@ -209,26 +197,23 @@ public class PlatformController {
@Operation(summary = "保存上级平台信息") @Operation(summary = "保存上级平台信息")
@PostMapping("/save") @PostMapping("/save")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<String>> savePlatform(@RequestBody ParentPlatform parentPlatform) { public String savePlatform(@RequestBody ParentPlatform parentPlatform) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("保存上级平台信息API调用"); logger.debug("保存上级平台信息API调用");
} }
WVPResult<String> wvpResult = new WVPResult<>(); if (ObjectUtils.isEmpty(parentPlatform.getName())
if (StringUtils.isEmpty(parentPlatform.getName()) || ObjectUtils.isEmpty(parentPlatform.getServerGBId())
|| StringUtils.isEmpty(parentPlatform.getServerGBId()) || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain())
|| StringUtils.isEmpty(parentPlatform.getServerGBDomain()) || ObjectUtils.isEmpty(parentPlatform.getServerIP())
|| StringUtils.isEmpty(parentPlatform.getServerIP()) || ObjectUtils.isEmpty(parentPlatform.getServerPort())
|| StringUtils.isEmpty(parentPlatform.getServerPort()) || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId())
|| StringUtils.isEmpty(parentPlatform.getDeviceGBId()) || ObjectUtils.isEmpty(parentPlatform.getExpires())
|| StringUtils.isEmpty(parentPlatform.getExpires()) || ObjectUtils.isEmpty(parentPlatform.getKeepTimeout())
|| StringUtils.isEmpty(parentPlatform.getKeepTimeout()) || ObjectUtils.isEmpty(parentPlatform.getTransport())
|| StringUtils.isEmpty(parentPlatform.getTransport()) || ObjectUtils.isEmpty(parentPlatform.getCharacterSet())
|| StringUtils.isEmpty(parentPlatform.getCharacterSet())
) { ) {
wvpResult.setCode(-1); throw new ControllerException(ErrorCode.ERROR400);
wvpResult.setMsg("missing parameters");
return new ResponseEntity<>(wvpResult, HttpStatus.BAD_REQUEST);
} }
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
@ -262,13 +247,9 @@ public class PlatformController {
// 停止订阅相关的定时任务 // 停止订阅相关的定时任务
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
} }
wvpResult.setCode(0); return null;
wvpResult.setMsg("success");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} else { } else {
wvpResult.setCode(0); throw new ControllerException(ErrorCode.ERROR100.getCode(),"写入数据库失败");
wvpResult.setMsg("写入数据库失败");
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
} }
} }
@ -282,18 +263,18 @@ public class PlatformController {
@Parameter(name = "serverGBId", description = "上级平台的国标编号") @Parameter(name = "serverGBId", description = "上级平台的国标编号")
@DeleteMapping("/delete/{serverGBId}") @DeleteMapping("/delete/{serverGBId}")
@ResponseBody @ResponseBody
public ResponseEntity<String> deletePlatform(@PathVariable String serverGBId) { public String deletePlatform(@PathVariable String serverGBId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("删除上级平台API调用"); logger.debug("删除上级平台API调用");
} }
if (StringUtils.isEmpty(serverGBId) if (ObjectUtils.isEmpty(serverGBId)
) { ) {
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400);
} }
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
if (parentPlatform == null) { if (parentPlatform == null) {
return new ResponseEntity<>("fail", HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
} }
// 发送离线消息,无论是否成功都删除缓存 // 发送离线消息,无论是否成功都删除缓存
commanderForPlatform.unregister(parentPlatform, (event -> { commanderForPlatform.unregister(parentPlatform, (event -> {
@ -317,9 +298,9 @@ public class PlatformController {
// 删除缓存的订阅信息 // 删除缓存的订阅信息
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
if (deleteResult) { if (deleteResult) {
return new ResponseEntity<>("success", HttpStatus.OK); return null;
} else { } else {
return new ResponseEntity<>("fail", HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100);
} }
} }
@ -333,10 +314,10 @@ public class PlatformController {
@Parameter(name = "serverGBId", description = "上级平台的国标编号") @Parameter(name = "serverGBId", description = "上级平台的国标编号")
@GetMapping("/exit/{serverGBId}") @GetMapping("/exit/{serverGBId}")
@ResponseBody @ResponseBody
public ResponseEntity<String> exitPlatform(@PathVariable String serverGBId) { public Boolean exitPlatform(@PathVariable String serverGBId) {
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK); return parentPlatform != null;
} }
/** /**
@ -367,13 +348,13 @@ public class PlatformController {
@RequestParam(required = false) Boolean online, @RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType) { @RequestParam(required = false) Boolean channelType) {
if (StringUtils.isEmpty(platformId)) { if (ObjectUtils.isEmpty(platformId)) {
platformId = null; platformId = null;
} }
if (StringUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
if (StringUtils.isEmpty(platformId) || StringUtils.isEmpty(catalogId)) { if (ObjectUtils.isEmpty(platformId) || ObjectUtils.isEmpty(catalogId)) {
catalogId = null; catalogId = null;
} }
PageInfo<ChannelReduce> channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, catalogId); PageInfo<ChannelReduce> channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, catalogId);
@ -390,14 +371,15 @@ public class PlatformController {
@Operation(summary = "向上级平台添加国标通道") @Operation(summary = "向上级平台添加国标通道")
@PostMapping("/update_channel_for_gb") @PostMapping("/update_channel_for_gb")
@ResponseBody @ResponseBody
public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param) { public void updateChannelForGB(@RequestBody UpdateChannelParam param) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("给上级平台添加国标通道API调用"); logger.debug("给上级平台添加国标通道API调用");
} }
int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
if (result <= 0) {
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100);
}
} }
/** /**
@ -409,14 +391,16 @@ public class PlatformController {
@Operation(summary = "从上级平台移除国标通道") @Operation(summary = "从上级平台移除国标通道")
@DeleteMapping("/del_channel_for_gb") @DeleteMapping("/del_channel_for_gb")
@ResponseBody @ResponseBody
public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param) { public void delChannelForGB(@RequestBody UpdateChannelParam param) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("给上级平台删除国标通道API调用"); logger.debug("给上级平台删除国标通道API调用");
} }
int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); if (result <= 0) {
throw new ControllerException(ErrorCode.ERROR100);
}
} }
/** /**
@ -431,25 +415,20 @@ public class PlatformController {
@Parameter(name = "parentId", description = "父级目录的国标编号", required = true) @Parameter(name = "parentId", description = "父级目录的国标编号", required = true)
@GetMapping("/catalog") @GetMapping("/catalog")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<List<PlatformCatalog>>> getCatalogByPlatform(String platformId, String parentId) { public List<PlatformCatalog> getCatalogByPlatform(String platformId, String parentId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId); logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
} }
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
if (platform == null) { if (platform == null) {
return new ResponseEntity<>(new WVPResult<>(400, "平台未找到", null), HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台未找到");
} }
if (platformId.equals(parentId)) { if (platformId.equals(parentId)) {
parentId = platform.getDeviceGBId(); parentId = platform.getDeviceGBId();
} }
List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId);
WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); return storager.getChildrenCatalogByPlatform(platformId, parentId);
result.setCode(0);
result.setMsg("success");
result.setData(platformCatalogList);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
/** /**
@ -461,28 +440,19 @@ public class PlatformController {
@Operation(summary = "添加目录") @Operation(summary = "添加目录")
@PostMapping("/catalog/add") @PostMapping("/catalog/add")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<List<PlatformCatalog>>> addCatalog(@RequestBody PlatformCatalog platformCatalog) { public void addCatalog(@RequestBody PlatformCatalog platformCatalog) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog)); logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
} }
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
if (platformCatalogInStore != null) { if (platformCatalogInStore != null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists");
result.setMsg(platformCatalog.getId() + " already exists");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
int addResult = storager.addCatalog(platformCatalog); int addResult = storager.addCatalog(platformCatalog);
if (addResult > 0) { if (addResult <= 0) {
result.setCode(0); throw new ControllerException(ErrorCode.ERROR100);
result.setMsg("success");
return new ResponseEntity<>(result, HttpStatus.OK);
} else {
result.setCode(-500);
result.setMsg("save error");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
@ -495,26 +465,19 @@ public class PlatformController {
@Operation(summary = "编辑目录") @Operation(summary = "编辑目录")
@PostMapping("/catalog/edit") @PostMapping("/catalog/edit")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<List<PlatformCatalog>>> editCatalog(@RequestBody PlatformCatalog platformCatalog) { public void editCatalog(@RequestBody PlatformCatalog platformCatalog) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog)); logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
} }
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
result.setCode(0);
if (platformCatalogInStore == null) { if (platformCatalogInStore == null) {
result.setMsg(platformCatalog.getId() + " not exists"); throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
int addResult = storager.updateCatalog(platformCatalog); int addResult = storager.updateCatalog(platformCatalog);
if (addResult > 0) { if (addResult <= 0) {
result.setMsg("success"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
return new ResponseEntity<>(result, HttpStatus.OK);
} else {
result.setMsg("save error");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
@ -530,19 +493,15 @@ public class PlatformController {
@Parameter(name = "platformId", description = "平台Id", required = true) @Parameter(name = "platformId", description = "平台Id", required = true)
@DeleteMapping("/catalog/del") @DeleteMapping("/catalog/del")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<String>> delCatalog(String id, String platformId) { public void delCatalog(String id, String platformId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("删除目录,{}", id); logger.debug("删除目录,{}", id);
} }
WVPResult<String> result = new WVPResult<>();
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(platformId)) { if (ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(platformId)) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR400);
result.setMsg("param error");
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
} }
result.setCode(0);
int delResult = storager.delCatalog(id); int delResult = storager.delCatalog(id);
// 如果删除的是默认目录则根目录设置为默认目录 // 如果删除的是默认目录则根目录设置为默认目录
@ -551,16 +510,10 @@ public class PlatformController {
// 默认节点被移除 // 默认节点被移除
if (parentPlatform == null) { if (parentPlatform == null) {
storager.setDefaultCatalog(platformId, platformId); storager.setDefaultCatalog(platformId, platformId);
result.setData(platformId);
} }
if (delResult <= 0) {
if (delResult > 0) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
result.setMsg("success");
return new ResponseEntity<>(result, HttpStatus.OK);
} else {
result.setMsg("save error");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
@ -573,21 +526,15 @@ public class PlatformController {
@Operation(summary = "删除关联") @Operation(summary = "删除关联")
@DeleteMapping("/catalog/relation/del") @DeleteMapping("/catalog/relation/del")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<List<PlatformCatalog>>> delRelation(@RequestBody PlatformCatalog platformCatalog) { public void delRelation(@RequestBody PlatformCatalog platformCatalog) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog)); logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog));
} }
int delResult = storager.delRelation(platformCatalog); int delResult = storager.delRelation(platformCatalog);
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
result.setCode(0);
if (delResult > 0) { if (delResult <= 0) {
result.setMsg("success"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
return new ResponseEntity<>(result, HttpStatus.OK);
} else {
result.setMsg("save error");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
@ -604,21 +551,15 @@ public class PlatformController {
@Parameter(name = "platformId", description = "平台Id", required = true) @Parameter(name = "platformId", description = "平台Id", required = true)
@PostMapping("/catalog/default/update") @PostMapping("/catalog/default/update")
@ResponseBody @ResponseBody
public ResponseEntity<WVPResult<String>> setDefaultCatalog(String platformId, String catalogId) { public void setDefaultCatalog(String platformId, String catalogId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("修改默认目录,{},{}", platformId, catalogId); logger.debug("修改默认目录,{},{}", platformId, catalogId);
} }
int updateResult = storager.setDefaultCatalog(platformId, catalogId); int updateResult = storager.setDefaultCatalog(platformId, catalogId);
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
if (updateResult > 0) { if (updateResult <= 0) {
result.setMsg("success"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
return new ResponseEntity<>(result, HttpStatus.OK);
} else {
result.setMsg("save error");
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }

View File

@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.play;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
@ -11,6 +12,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
@ -22,8 +24,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -78,7 +78,7 @@ public class PlayController {
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/start/{deviceId}/{channelId}") @GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, public DeferredResult<WVPResult<String>> play(@PathVariable String deviceId,
@PathVariable String channelId) { @PathVariable String channelId) {
// 获取可用的zlm // 获取可用的zlm
@ -94,169 +94,115 @@ public class PlayController {
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/stop/{deviceId}/{channelId}") @GetMapping("/stop/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String deviceId, @PathVariable String channelId) { public JSONObject playStop(@PathVariable String deviceId, @PathVariable String channelId) {
logger.debug(String.format("设备预览/回放停止API调用streamId%s_%s", deviceId, channelId )); logger.debug(String.format("设备预览/回放停止API调用streamId%s_%s", deviceId, channelId ));
String uuid = UUID.randomUUID().toString(); if (deviceId == null || channelId == null) {
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(); throw new ControllerException(ErrorCode.ERROR400);
}
// 录像查询以channelId作为deviceId查询
String key = DeferredResultHolder.CALLBACK_CMD_STOP + deviceId + channelId;
resultHolder.put(key, uuid, result);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
if (streamInfo == null) { if (streamInfo == null) {
RequestMessage msg = new RequestMessage(); throw new ControllerException(ErrorCode.ERROR100.getCode(), "点播未找到");
msg.setId(uuid);
msg.setKey(key);
msg.setData("点播未找到");
resultHolder.invokeAllResult(msg);
storager.stopPlay(deviceId, channelId);
return result;
}
cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), null, eventResult -> {
redisCatchStorage.stopPlay(streamInfo);
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
RequestMessage msgForSuccess = new RequestMessage();
msgForSuccess.setId(uuid);
msgForSuccess.setKey(key);
msgForSuccess.setData(String.format("success"));
resultHolder.invokeAllResult(msgForSuccess);
});
if (deviceId != null || channelId != null) {
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
json.put("channelId", channelId);
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
msg.setKey(key);
msg.setData(json.toString());
resultHolder.invokeAllResult(msg);
} else {
logger.warn("设备预览/回放停止API调用失败");
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
msg.setKey(key);
msg.setData("streamId null");
resultHolder.invokeAllResult(msg);
} }
// 超时处理 cmder.streamByeCmd(deviceId, channelId, streamInfo.getStream(), null, null);
result.onTimeout(()->{ redisCatchStorage.stopPlay(streamInfo);
logger.warn(String.format("设备预览/回放停止超时deviceId/channelId%s_%s ", deviceId, channelId));
redisCatchStorage.stopPlay(streamInfo); storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); JSONObject json = new JSONObject();
RequestMessage msg = new RequestMessage(); json.put("deviceId", deviceId);
msg.setId(uuid); json.put("channelId", channelId);
msg.setKey(key); return json;
msg.setData("Timeout");
resultHolder.invokeAllResult(msg);
});
return result;
} }
/** /**
* 将不是h264的视频通过ffmpeg 转码为h264 + aac * 将不是h264的视频通过ffmpeg 转码为h264 + aac
* @param streamId 流ID * @param streamId 流ID
* @return
*/ */
@Operation(summary = "将不是h264的视频通过ffmpeg 转码为h264 + aac") @Operation(summary = "将不是h264的视频通过ffmpeg 转码为h264 + aac")
@Parameter(name = "streamId", description = "视频流ID", required = true) @Parameter(name = "streamId", description = "视频流ID", required = true)
@PostMapping("/convert/{streamId}") @PostMapping("/convert/{streamId}")
public ResponseEntity<String> playConvert(@PathVariable String streamId) { public JSONObject playConvert(@PathVariable String streamId) {
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
if (streamInfo == null) { if (streamInfo == null) {
streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
} }
if (streamInfo == null) { if (streamInfo == null) {
logger.warn("视频转码API调用失败, 视频流已经停止!"); logger.warn("视频转码API调用失败, 视频流已经停止!");
return new ResponseEntity<String>("未找到视频流信息, 视频流可能已经停止", HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到视频流信息, 视频流可能已经停止");
} }
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfo.getMediaServerId()); MediaServerItem mediaInfo = mediaServerService.getOne(streamInfo.getMediaServerId());
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId); JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
if (!rtpInfo.getBoolean("exist")) { if (!rtpInfo.getBoolean("exist")) {
logger.warn("视频转码API调用失败, 视频流已停止推流!"); logger.warn("视频转码API调用失败, 视频流已停止推流!");
return new ResponseEntity<String>("推流信息在流媒体中不存在, 视频流可能已停止推流", HttpStatus.OK); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到视频流信息, 视频流可能已停止推流");
} else { } else {
String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(),
streamId ); streamId );
String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId);
JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(mediaInfo, srcUrl, dstUrl, "1000000", true, false, null); JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(mediaInfo, srcUrl, dstUrl, "1000000", true, false, null);
logger.info(jsonObject.toJSONString()); logger.info(jsonObject.toJSONString());
JSONObject result = new JSONObject();
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
result.put("code", 0);
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data != null) { if (data != null) {
result.put("key", data.getString("key")); JSONObject result = new JSONObject();
result.put("key", data.getString("key"));
StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false); StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false);
result.put("data", streamInfoResult); result.put("StreamInfo", streamInfoResult);
return result;
}else {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "转码失败");
} }
}else { }else {
result.put("code", 1); throw new ControllerException(ErrorCode.ERROR100.getCode(), "转码失败");
result.put("msg", "cover fail");
} }
return new ResponseEntity<String>( result.toJSONString(), HttpStatus.OK);
} }
} }
/** /**
* 结束转码 * 结束转码
* @param key
* @return
*/ */
@Operation(summary = "结束转码") @Operation(summary = "结束转码")
@Parameter(name = "key", description = "视频流key", required = true) @Parameter(name = "key", description = "视频流key", required = true)
@Parameter(name = "mediaServerId", description = "流媒体服务ID", required = true) @Parameter(name = "mediaServerId", description = "流媒体服务ID", required = true)
@PostMapping("/convertStop/{key}") @PostMapping("/convertStop/{key}")
public ResponseEntity<String> playConvertStop(@PathVariable String key, String mediaServerId) { public void playConvertStop(@PathVariable String key, String mediaServerId) {
JSONObject result = new JSONObject();
if (mediaServerId == null) { if (mediaServerId == null) {
result.put("code", 400); throw new ControllerException(ErrorCode.ERROR400.getCode(), "流媒体:" + mediaServerId + "不存在" );
result.put("msg", "mediaServerId is null");
return new ResponseEntity<String>( result.toJSONString(), HttpStatus.BAD_REQUEST);
} }
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo == null) { if (mediaInfo == null) {
result.put("code", 0); throw new ControllerException(ErrorCode.ERROR100.getCode(), "使用的流媒体已经停止运行" );
result.put("msg", "使用的流媒体已经停止运行");
return new ResponseEntity<String>( result.toJSONString(), HttpStatus.OK);
}else { }else {
JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(mediaInfo, key); JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(mediaInfo, key);
logger.info(jsonObject.toJSONString()); logger.info(jsonObject.toJSONString());
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
result.put("code", 0);
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data != null && data.getBoolean("flag")) { if (data == null || data.getBoolean("flag") == null || !data.getBoolean("flag")) {
result.put("code", "0"); throw new ControllerException(ErrorCode.ERROR100 );
result.put("msg", "success");
}else {
} }
}else { }else {
result.put("code", 1); throw new ControllerException(ErrorCode.ERROR100 );
result.put("msg", "delFFmpegSource fail");
} }
return new ResponseEntity<String>( result.toJSONString(), HttpStatus.OK);
} }
} }
@Operation(summary = "语音广播命令") @Operation(summary = "语音广播命令")
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@GetMapping("/broadcast/{deviceId}") @GetMapping("/broadcast/{deviceId}")
@PostMapping("/broadcast/{deviceId}") @PostMapping("/broadcast/{deviceId}")
public DeferredResult<ResponseEntity<String>> broadcastApi(@PathVariable String deviceId) { public DeferredResult<String> broadcastApi(@PathVariable String deviceId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("语音广播API调用"); logger.debug("语音广播API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L); DeferredResult<String> result = new DeferredResult<>(3 * 1000L);
String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId; String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId;
if (resultHolder.exist(key, null)) { if (resultHolder.exist(key, null)) {
result.setResult(new ResponseEntity<>("设备使用中",HttpStatus.OK)); result.setResult("设备使用中");
return result; return result;
} }
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
@ -289,7 +235,7 @@ public class PlayController {
}); });
result.onTimeout(() -> { result.onTimeout(() -> {
logger.warn(String.format("语音广播操作超时, 设备未返回应答指令")); logger.warn("语音广播操作超时, 设备未返回应答指令");
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setKey(key); msg.setKey(key);
msg.setId(uuid); msg.setId(uuid);
@ -307,7 +253,7 @@ public class PlayController {
@Operation(summary = "获取所有的ssrc") @Operation(summary = "获取所有的ssrc")
@GetMapping("/ssrc") @GetMapping("/ssrc")
public WVPResult<JSONObject> getSSRC() { public JSONObject getSSRC() {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("获取所有的ssrc"); logger.debug("获取所有的ssrc");
} }
@ -322,14 +268,10 @@ public class PlayController {
objects.add(jsonObject); objects.add(jsonObject);
} }
WVPResult<JSONObject> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("data", objects); jsonObject.put("data", objects);
jsonObject.put("count", objects.size()); jsonObject.put("count", objects.size());
result.setData(jsonObject); return jsonObject;
return result;
} }
} }

View File

@ -1,21 +1,22 @@
package com.genersoft.iot.vmp.vmanager.gb28181.play.bean; package com.genersoft.iot.vmp.vmanager.gb28181.play.bean;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
public class PlayResult { public class PlayResult {
private DeferredResult<ResponseEntity<String>> result; private DeferredResult<WVPResult<String>> result;
private String uuid; private String uuid;
private Device device; private Device device;
public DeferredResult<ResponseEntity<String>> getResult() { public DeferredResult<WVPResult<String>> getResult() {
return result; return result;
} }
public void setResult(DeferredResult<ResponseEntity<String>> result) { public void setResult(DeferredResult<WVPResult<String>> result) {
this.result = result; this.result = result;
} }

View File

@ -1,19 +1,18 @@
package com.genersoft.iot.vmp.vmanager.gb28181.playback; package com.genersoft.iot.vmp.vmanager.gb28181.playback;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.util.ObjectUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -26,6 +25,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
/**
* @author lin
*/
@Tag(name = "视频回放") @Tag(name = "视频回放")
@CrossOrigin @CrossOrigin
@RestController @RestController
@ -55,18 +57,16 @@ public class PlaybackController {
@Parameter(name = "startTime", description = "开始时间", required = true) @Parameter(name = "startTime", description = "开始时间", required = true)
@Parameter(name = "endTime", description = "结束时间", required = true) @Parameter(name = "endTime", description = "结束时间", required = true)
@GetMapping("/start/{deviceId}/{channelId}") @GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> play(@PathVariable String deviceId, @PathVariable String channelId, public DeferredResult<String> play(@PathVariable String deviceId, @PathVariable String channelId,
String startTime,String endTime) { String startTime,String endTime) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(String.format("设备回放 API调用deviceId%s channelId%s", deviceId, channelId)); logger.debug(String.format("设备回放 API调用deviceId%s channelId%s", deviceId, channelId));
} }
DeferredResult<ResponseEntity<String>> result = playService.playBack(deviceId, channelId, startTime, endTime, null, wvpResult->{
resultHolder.invokeResult(wvpResult.getData());
});
return result; return playService.playBack(deviceId, channelId, startTime, endTime, null,
playBackResult->resultHolder.invokeResult(playBackResult.getData()));
} }
@ -75,67 +75,44 @@ public class PlaybackController {
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "stream", description = "流ID", required = true) @Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/stop/{deviceId}/{channelId}/{stream}") @GetMapping("/stop/{deviceId}/{channelId}/{stream}")
public ResponseEntity<String> playStop( public void playStop(
@PathVariable String deviceId, @PathVariable String deviceId,
@PathVariable String channelId, @PathVariable String channelId,
@PathVariable String stream) { @PathVariable String stream) {
if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId) || ObjectUtils.isEmpty(stream)) {
throw new ControllerException(ErrorCode.ERROR400);
}
cmder.streamByeCmd(deviceId, channelId, stream, null); cmder.streamByeCmd(deviceId, channelId, stream, null);
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备录像回放停止 API调用deviceId/channelId%s/%s", deviceId, channelId));
}
if (StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(channelId) || StringUtils.isEmpty(stream)) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
if (deviceId != null && channelId != null) {
JSONObject json = new JSONObject();
json.put("deviceId", deviceId);
json.put("channelId", channelId);
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
} else {
logger.warn("设备录像回放停止API调用失败");
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
} }
@Operation(summary = "回放暂停") @Operation(summary = "回放暂停")
@Parameter(name = "streamId", description = "回放流ID", required = true) @Parameter(name = "streamId", description = "回放流ID", required = true)
@GetMapping("/pause/{streamId}") @GetMapping("/pause/{streamId}")
public ResponseEntity<String> playPause(@PathVariable String streamId) { public void playPause(@PathVariable String streamId) {
logger.info("playPause: "+streamId); logger.info("playPause: "+streamId);
JSONObject json = new JSONObject();
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) { if (null == streamInfo) {
json.put("msg", "streamId不存在");
logger.warn("streamId不存在!"); logger.warn("streamId不存在!");
return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
} }
Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playPauseCmd(device, streamInfo); cmder.playPauseCmd(device, streamInfo);
json.put("msg", "ok");
return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
} }
@Operation(summary = "回放恢复") @Operation(summary = "回放恢复")
@Parameter(name = "streamId", description = "回放流ID", required = true) @Parameter(name = "streamId", description = "回放流ID", required = true)
@GetMapping("/resume/{streamId}") @GetMapping("/resume/{streamId}")
public ResponseEntity<String> playResume(@PathVariable String streamId) { public void playResume(@PathVariable String streamId) {
logger.info("playResume: "+streamId); logger.info("playResume: "+streamId);
JSONObject json = new JSONObject();
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) { if (null == streamInfo) {
json.put("msg", "streamId不存在");
logger.warn("streamId不存在!"); logger.warn("streamId不存在!");
return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
} }
Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playResumeCmd(device, streamInfo); cmder.playResumeCmd(device, streamInfo);
json.put("msg", "ok");
return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
} }
@ -143,43 +120,33 @@ public class PlaybackController {
@Parameter(name = "streamId", description = "回放流ID", required = true) @Parameter(name = "streamId", description = "回放流ID", required = true)
@Parameter(name = "seekTime", description = "拖动偏移量单位s", required = true) @Parameter(name = "seekTime", description = "拖动偏移量单位s", required = true)
@GetMapping("/seek/{streamId}/{seekTime}") @GetMapping("/seek/{streamId}/{seekTime}")
public ResponseEntity<String> playSeek(@PathVariable String streamId, @PathVariable long seekTime) { public void playSeek(@PathVariable String streamId, @PathVariable long seekTime) {
logger.info("playSeek: "+streamId+", "+seekTime); logger.info("playSeek: "+streamId+", "+seekTime);
JSONObject json = new JSONObject();
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) { if (null == streamInfo) {
json.put("msg", "streamId不存在");
logger.warn("streamId不存在!"); logger.warn("streamId不存在!");
return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
} }
Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playSeekCmd(device, streamInfo, seekTime); cmder.playSeekCmd(device, streamInfo, seekTime);
json.put("msg", "ok");
return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
} }
@Operation(summary = "回放倍速播放") @Operation(summary = "回放倍速播放")
@Parameter(name = "streamId", description = "回放流ID", required = true) @Parameter(name = "streamId", description = "回放流ID", required = true)
@Parameter(name = "speed", description = "倍速0.25 0.5 1、2、4", required = true) @Parameter(name = "speed", description = "倍速0.25 0.5 1、2、4", required = true)
@GetMapping("/speed/{streamId}/{speed}") @GetMapping("/speed/{streamId}/{speed}")
public ResponseEntity<String> playSpeed(@PathVariable String streamId, @PathVariable Double speed) { public void playSpeed(@PathVariable String streamId, @PathVariable Double speed) {
logger.info("playSpeed: "+streamId+", "+speed); logger.info("playSpeed: "+streamId+", "+speed);
JSONObject json = new JSONObject();
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null); StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
if (null == streamInfo) { if (null == streamInfo) {
json.put("msg", "streamId不存在");
logger.warn("streamId不存在!"); logger.warn("streamId不存在!");
return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
} }
if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) { if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) {
json.put("msg", "不支持的speed0.25 0.5 1、2、4");
logger.warn("不支持的speed " + speed); logger.warn("不支持的speed " + speed);
return new ResponseEntity<String>(json.toString(), HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed0.25 0.5 1、2、4");
} }
Device device = storager.queryVideoDevice(streamInfo.getDeviceID()); Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
cmder.playSpeedCmd(device, streamInfo, speed); cmder.playSpeedCmd(device, streamInfo, speed);
json.put("msg", "ok");
return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
} }
} }

View File

@ -7,8 +7,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.util.ObjectUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -46,7 +45,6 @@ public class PtzController {
* @param horizonSpeed 水平移动速度 * @param horizonSpeed 水平移动速度
* @param verticalSpeed 垂直移动速度 * @param verticalSpeed 垂直移动速度
* @param zoomSpeed 缩放速度 * @param zoomSpeed 缩放速度
* @return String 控制结果
*/ */
@Operation(summary = "云台控制") @Operation(summary = "云台控制")
@ -57,7 +55,7 @@ public class PtzController {
@Parameter(name = "verticalSpeed", description = "垂直速度", required = true) @Parameter(name = "verticalSpeed", description = "垂直速度", required = true)
@Parameter(name = "zoomSpeed", description = "缩放速度", required = true) @Parameter(name = "zoomSpeed", description = "缩放速度", required = true)
@PostMapping("/control/{deviceId}/{channelId}") @PostMapping("/control/{deviceId}/{channelId}")
public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){ public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(String.format("设备云台控制 API调用deviceId%s channelId%s command%s horizonSpeed%d verticalSpeed%d zoomSpeed%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed)); logger.debug(String.format("设备云台控制 API调用deviceId%s channelId%s command%s horizonSpeed%d verticalSpeed%d zoomSpeed%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
@ -96,13 +94,11 @@ public class PtzController {
cmdCode = 32; cmdCode = 32;
break; break;
case "stop": case "stop":
cmdCode = 0;
break; break;
default: default:
break; break;
} }
cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
return new ResponseEntity<String>("success",HttpStatus.OK);
} }
@ -114,7 +110,7 @@ public class PtzController {
@Parameter(name = "parameter2", description = "数据二", required = true) @Parameter(name = "parameter2", description = "数据二", required = true)
@Parameter(name = "combindCode2", description = "组合码二", required = true) @Parameter(name = "combindCode2", description = "组合码二", required = true)
@PostMapping("/front_end_command/{deviceId}/{channelId}") @PostMapping("/front_end_command/{deviceId}/{channelId}")
public ResponseEntity<String> frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){ public void frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(String.format("设备云台控制 API调用deviceId%s channelId%s cmdCode%d parameter1%d parameter2%d",deviceId, channelId, cmdCode, parameter1, parameter2)); logger.debug(String.format("设备云台控制 API调用deviceId%s channelId%s cmdCode%d parameter1%d parameter2%d",deviceId, channelId, cmdCode, parameter1, parameter2));
@ -122,7 +118,6 @@ public class PtzController {
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2);
return new ResponseEntity<String>("success",HttpStatus.OK);
} }
@ -130,14 +125,14 @@ public class PtzController {
@Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/preset/query/{deviceId}/{channelId}") @GetMapping("/preset/query/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) { public DeferredResult<String> presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("设备预置位查询API调用"); logger.debug("设备预置位查询API调用");
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (StringUtils.isEmpty(channelId) ? deviceId : channelId); String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String >> (3 * 1000L); DeferredResult<String> result = new DeferredResult<String> (3 * 1000L);
result.onTimeout(()->{ result.onTimeout(()->{
logger.warn(String.format("获取设备预置位超时")); logger.warn(String.format("获取设备预置位超时"));
// 释放rtpserver // 释放rtpserver
@ -158,7 +153,6 @@ public class PtzController {
msg.setData(String.format("获取设备预置位失败,错误码: %s, %s", event.statusCode, event.msg)); msg.setData(String.format("获取设备预置位失败,错误码: %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
}); });
return result; return result;
} }
} }

View File

@ -2,10 +2,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.record;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -58,28 +60,17 @@ public class GBRecordController {
@Parameter(name = "startTime", description = "开始时间", required = true) @Parameter(name = "startTime", description = "开始时间", required = true)
@Parameter(name = "endTime", description = "结束时间", required = true) @Parameter(name = "endTime", description = "结束时间", required = true)
@GetMapping("/query/{deviceId}/{channelId}") @GetMapping("/query/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<WVPResult<RecordInfo>>> recordinfo(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime){ public DeferredResult<WVPResult<RecordInfo>> recordinfo(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime){
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(String.format("录像信息查询 API调用deviceId%s startTime%s endTime%s",deviceId, startTime, endTime)); logger.debug(String.format("录像信息查询 API调用deviceId%s startTime%s endTime%s",deviceId, startTime, endTime));
} }
DeferredResult<ResponseEntity<WVPResult<RecordInfo>>> result = new DeferredResult<>(); DeferredResult<WVPResult<RecordInfo>> result = new DeferredResult<>();
if (!DateUtil.verification(startTime, DateUtil.formatter)){ if (!DateUtil.verification(startTime, DateUtil.formatter)){
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); throw new ControllerException(ErrorCode.ERROR100.getCode(), "startTime error, format is " + DateUtil.PATTERN);
wvpResult.setCode(-1);
wvpResult.setMsg("startTime error, format is " + DateUtil.PATTERN);
ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
result.setResult(resultResponseEntity);
return result;
} }
if (!DateUtil.verification(endTime, DateUtil.formatter)){ if (!DateUtil.verification(endTime, DateUtil.formatter)){
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); throw new ControllerException(ErrorCode.ERROR100.getCode(), "endTime error, format is " + DateUtil.PATTERN);
wvpResult.setCode(-1);
wvpResult.setMsg("endTime error, format is " + DateUtil.PATTERN);
ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
result.setResult(resultResponseEntity);
return result;
} }
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
@ -92,7 +83,7 @@ public class GBRecordController {
msg.setKey(key); msg.setKey(key);
cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, null, null, null, (eventResult -> { cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, null, null, null, (eventResult -> {
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg); wvpResult.setMsg("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg);
msg.setData(wvpResult); msg.setData(wvpResult);
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
@ -103,7 +94,7 @@ public class GBRecordController {
result.onTimeout(()->{ result.onTimeout(()->{
msg.setData("timeout"); msg.setData("timeout");
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(-1); wvpResult.setCode(ErrorCode.ERROR100.getCode());
wvpResult.setMsg("timeout"); wvpResult.setMsg("timeout");
msg.setData(wvpResult); msg.setData(wvpResult);
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
@ -119,59 +110,14 @@ public class GBRecordController {
@Parameter(name = "endTime", description = "结束时间", required = true) @Parameter(name = "endTime", description = "结束时间", required = true)
@Parameter(name = "downloadSpeed", description = "下载倍速", required = true) @Parameter(name = "downloadSpeed", description = "下载倍速", required = true)
@GetMapping("/download/start/{deviceId}/{channelId}") @GetMapping("/download/start/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> download(@PathVariable String deviceId, @PathVariable String channelId, public DeferredResult<String> download(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime, String downloadSpeed) { String startTime, String endTime, String downloadSpeed) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug(String.format("历史媒体下载 API调用deviceId%schannelId%sdownloadSpeed%s", deviceId, channelId, downloadSpeed)); logger.debug(String.format("历史媒体下载 API调用deviceId%schannelId%sdownloadSpeed%s", deviceId, channelId, downloadSpeed));
} }
// String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
// String uuid = UUID.randomUUID().toString();
// DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(30000L);
// // 超时处理
// result.onTimeout(()->{
// logger.warn(String.format("设备下载响应超时deviceId%s channelId%s", deviceId, channelId));
// RequestMessage msg = new RequestMessage();
// msg.setId(uuid);
// msg.setKey(key);
// msg.setData("Timeout");
// resultHolder.invokeAllResult(msg);
// });
// if(resultHolder.exist(key, null)) {
// return result;
// }
// resultHolder.put(key, uuid, result);
// Device device = storager.queryVideoDevice(deviceId);
//
// MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
// if (newMediaServerItem == null) {
// logger.warn(String.format("设备下载响应超时deviceId%s channelId%s", deviceId, channelId));
// RequestMessage msg = new RequestMessage();
// msg.setId(uuid);
// msg.setKey(key);
// msg.setData("Timeout");
// resultHolder.invokeAllResult(msg);
// return result;
// }
//
// SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true);
//
// cmder.downloadStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, (InviteStreamInfo inviteStreamInfo) -> {
// logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());
// playService.onPublishHandlerForDownload(inviteStreamInfo, deviceId, channelId, uuid);
// }, event -> {
// RequestMessage msg = new RequestMessage();
// msg.setId(uuid);
// msg.setKey(key);
// msg.setData(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg));
// resultHolder.invokeAllResult(msg);
// });
if (logger.isDebugEnabled()) { DeferredResult<String> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{
logger.debug(String.format("设备回放 API调用deviceId%s channelId%s", deviceId, channelId));
}
DeferredResult<ResponseEntity<String>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{
resultHolder.invokeResult(hookCallBack.getData()); resultHolder.invokeResult(hookCallBack.getData());
}); });
@ -183,7 +129,7 @@ public class GBRecordController {
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "stream", description = "流ID", required = true) @Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/download/stop/{deviceId}/{channelId}/{stream}") @GetMapping("/download/stop/{deviceId}/{channelId}/{stream}")
public ResponseEntity<String> playStop(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { public void playStop(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
cmder.streamByeCmd(deviceId, channelId, stream, null); cmder.streamByeCmd(deviceId, channelId, stream, null);
@ -191,14 +137,8 @@ public class GBRecordController {
logger.debug(String.format("设备历史媒体下载停止 API调用deviceId/channelId%s_%s", deviceId, channelId)); logger.debug(String.format("设备历史媒体下载停止 API调用deviceId/channelId%s_%s", deviceId, channelId));
} }
if (deviceId != null && channelId != null) { if (deviceId == null || channelId == null) {
JSONObject json = new JSONObject(); throw new ControllerException(ErrorCode.ERROR100);
json.put("deviceId", deviceId);
json.put("channelId", channelId);
return new ResponseEntity<String>(json.toString(), HttpStatus.OK);
} else {
logger.warn("设备历史媒体下载停止API调用失败");
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
@ -207,9 +147,7 @@ public class GBRecordController {
@Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "stream", description = "流ID", required = true) @Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/download/progress/{deviceId}/{channelId}/{stream}") @GetMapping("/download/progress/{deviceId}/{channelId}/{stream}")
public ResponseEntity<StreamInfo> getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { public StreamInfo getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
return playService.getDownLoadInfo(deviceId, channelId, stream);
StreamInfo streamInfo = playService.getDownLoadInfo(deviceId, channelId, stream);
return new ResponseEntity<>(streamInfo, HttpStatus.OK);
} }
} }

View File

@ -1,9 +1,11 @@
package com.genersoft.iot.vmp.vmanager.log; package com.genersoft.iot.vmp.vmanager.log;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.service.ILogService; import com.genersoft.iot.vmp.service.ILogService;
import com.genersoft.iot.vmp.storager.dao.dto.LogDto; import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -15,6 +17,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -53,7 +56,7 @@ public class LogController {
@Parameter(name = "type", description = "类型", required = true) @Parameter(name = "type", description = "类型", required = true)
@Parameter(name = "startTime", description = "开始时间", required = true) @Parameter(name = "startTime", description = "开始时间", required = true)
@Parameter(name = "endTime", description = "结束时间", required = true) @Parameter(name = "endTime", description = "结束时间", required = true)
public ResponseEntity<PageInfo<LogDto>> getAll( public PageInfo<LogDto> getAll(
@RequestParam int page, @RequestParam int page,
@RequestParam int count, @RequestParam int count,
@RequestParam(required = false) String query, @RequestParam(required = false) String query,
@ -61,13 +64,13 @@ public class LogController {
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime @RequestParam(required = false) String endTime
) { ) {
if (StringUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
if (StringUtils.isEmpty(startTime)) { if (ObjectUtils.isEmpty(startTime)) {
startTime = null; startTime = null;
} }
if (StringUtils.isEmpty(endTime)) { if (ObjectUtils.isEmpty(endTime)) {
endTime = null; endTime = null;
} }
if (!userSetting.getLogInDatebase()) { if (!userSetting.getLogInDatebase()) {
@ -75,11 +78,10 @@ public class LogController {
} }
if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){ if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); throw new ControllerException(ErrorCode.ERROR400);
} }
PageInfo<LogDto> allLog = logService.getAll(page, count, query, type, startTime, endTime); return logService.getAll(page, count, query, type, startTime, endTime);
return new ResponseEntity<>(allLog, HttpStatus.OK);
} }
/** /**
@ -88,14 +90,8 @@ public class LogController {
*/ */
@Operation(summary = "停止视频回放") @Operation(summary = "停止视频回放")
@DeleteMapping("/clear") @DeleteMapping("/clear")
public ResponseEntity<WVPResult<String>> clear() { public void clear() {
logService.clear();
int count = logService.clear();
WVPResult wvpResult = new WVPResult();
wvpResult.setCode(0);
wvpResult.setMsg("success");
wvpResult.setData(count);
return new ResponseEntity<WVPResult<String>>(wvpResult, HttpStatus.OK);
} }
} }

View File

@ -4,24 +4,27 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.VManageBootstrap; import com.genersoft.iot.vmp.VManageBootstrap;
import com.genersoft.iot.vmp.common.VersionPo; import com.genersoft.iot.vmp.common.VersionPo;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.VersionInfo; import com.genersoft.iot.vmp.conf.VersionInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.utils.SpringBeanFactory; import com.genersoft.iot.vmp.utils.SpringBeanFactory;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import gov.nist.javax.sip.SipStackImpl; import gov.nist.javax.sip.SipStackImpl;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.ehcache.xml.model.ThreadPoolsType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,7 +33,6 @@ import javax.sip.ObjectInUseException;
import javax.sip.SipProvider; import javax.sip.SipProvider;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Tag(name = "服务控制") @Tag(name = "服务控制")
@ -54,45 +56,34 @@ public class ServerController {
@Autowired @Autowired
private UserSetting userSetting; private UserSetting userSetting;
@Autowired
private DynamicTask dynamicTask;
@Value("${server.port}") @Value("${server.port}")
private int serverPort; private int serverPort;
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
@GetMapping(value = "/media_server/list") @GetMapping(value = "/media_server/list")
@ResponseBody @ResponseBody
@Operation(summary = "流媒体服务列表") @Operation(summary = "流媒体服务列表")
public WVPResult<List<MediaServerItem>> getMediaServerList() { public List<MediaServerItem> getMediaServerList() {
WVPResult<List<MediaServerItem>> result = new WVPResult<>(); return mediaServerService.getAll();
result.setCode(0);
result.setMsg("success");
result.setData(mediaServerService.getAll());
return result;
} }
@GetMapping(value = "/media_server/online/list") @GetMapping(value = "/media_server/online/list")
@ResponseBody @ResponseBody
@Operation(summary = "在线流媒体服务列表") @Operation(summary = "在线流媒体服务列表")
public WVPResult<List<MediaServerItem>> getOnlineMediaServerList() { public List<MediaServerItem> getOnlineMediaServerList() {
WVPResult<List<MediaServerItem>> result = new WVPResult<>(); return mediaServerService.getAllOnline();
result.setCode(0);
result.setMsg("success");
result.setData(mediaServerService.getAllOnline());
return result;
} }
@GetMapping(value = "/media_server/one/{id}") @GetMapping(value = "/media_server/one/{id}")
@ResponseBody @ResponseBody
@Operation(summary = "停止视频回放") @Operation(summary = "停止视频回放")
@Parameter(name = "id", description = "流媒体服务ID", required = true) @Parameter(name = "id", description = "流媒体服务ID", required = true)
public WVPResult<MediaServerItem> getMediaServer(@PathVariable String id) { public MediaServerItem getMediaServer(@PathVariable String id) {
WVPResult<MediaServerItem> result = new WVPResult<>(); return mediaServerService.getOne(id);
result.setCode(0);
result.setMsg("success");
result.setData(mediaServerService.getOne(id));
return result;
} }
@Operation(summary = "测试流媒体服务") @Operation(summary = "测试流媒体服务")
@ -101,7 +92,7 @@ public class ServerController {
@Parameter(name = "secret", description = "流媒体服务secret", required = true) @Parameter(name = "secret", description = "流媒体服务secret", required = true)
@GetMapping(value = "/media_server/check") @GetMapping(value = "/media_server/check")
@ResponseBody @ResponseBody
public WVPResult<MediaServerItem> checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret) { public MediaServerItem checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret) {
return mediaServerService.checkMediaServer(ip, port, secret); return mediaServerService.checkMediaServer(ip, port, secret);
} }
@ -110,122 +101,87 @@ public class ServerController {
@Parameter(name = "port", description = "流媒体服务HTT端口", required = true) @Parameter(name = "port", description = "流媒体服务HTT端口", required = true)
@GetMapping(value = "/media_server/record/check") @GetMapping(value = "/media_server/record/check")
@ResponseBody @ResponseBody
public WVPResult<String> checkMediaRecordServer(@RequestParam String ip, @RequestParam int port) { public void checkMediaRecordServer(@RequestParam String ip, @RequestParam int port) {
boolean checkResult = mediaServerService.checkMediaRecordServer(ip, port); boolean checkResult = mediaServerService.checkMediaRecordServer(ip, port);
WVPResult<String> result = new WVPResult<>(); if (!checkResult) {
if (checkResult) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接失败");
result.setCode(0);
result.setMsg("success");
} else {
result.setCode(-1);
result.setMsg("连接失败");
} }
return result;
} }
@Operation(summary = "保存流媒体服务") @Operation(summary = "保存流媒体服务")
@Parameter(name = "mediaServerItem", description = "流媒体信息", required = true) @Parameter(name = "mediaServerItem", description = "流媒体信息", required = true)
@PostMapping(value = "/media_server/save") @PostMapping(value = "/media_server/save")
@ResponseBody @ResponseBody
public WVPResult<String> saveMediaServer(@RequestBody MediaServerItem mediaServerItem) { public void saveMediaServer(@RequestBody MediaServerItem mediaServerItem) {
MediaServerItem mediaServerItemInDatabase = mediaServerService.getOne(mediaServerItem.getId()); MediaServerItem mediaServerItemInDatabase = mediaServerService.getOne(mediaServerItem.getId());
if (mediaServerItemInDatabase != null) { if (mediaServerItemInDatabase != null) {
if (StringUtils.isEmpty(mediaServerItemInDatabase.getSendRtpPortRange()) && StringUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) { if (ObjectUtils.isEmpty(mediaServerItemInDatabase.getSendRtpPortRange()) && ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) {
mediaServerItem.setSendRtpPortRange("30000,30500"); mediaServerItem.setSendRtpPortRange("30000,30500");
} }
mediaServerService.update(mediaServerItem); mediaServerService.update(mediaServerItem);
} else { } else {
if (StringUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) { if (ObjectUtils.isEmpty(mediaServerItem.getSendRtpPortRange())) {
mediaServerItem.setSendRtpPortRange("30000,30500"); mediaServerItem.setSendRtpPortRange("30000,30500");
} }
return mediaServerService.add(mediaServerItem); mediaServerService.add(mediaServerItem);
} }
WVPResult<String> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
return result;
} }
@Operation(summary = "移除流媒体服务") @Operation(summary = "移除流媒体服务")
@Parameter(name = "id", description = "流媒体ID", required = true) @Parameter(name = "id", description = "流媒体ID", required = true)
@DeleteMapping(value = "/media_server/delete") @DeleteMapping(value = "/media_server/delete")
@ResponseBody @ResponseBody
public WVPResult<String> deleteMediaServer(@RequestParam String id) { public void deleteMediaServer(@RequestParam String id) {
if (mediaServerService.getOne(id) != null) { if (mediaServerService.getOne(id) == null) {
mediaServerService.delete(id); throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到此节点");
mediaServerService.deleteDb(id);
} else {
WVPResult<String> result = new WVPResult<>();
result.setCode(-1);
result.setMsg("未找到此节点");
return result;
} }
WVPResult<String> result = new WVPResult<>(); mediaServerService.delete(id);
result.setCode(0); mediaServerService.deleteDb(id);
result.setMsg("success");
return result;
} }
@Operation(summary = "重启服务") @Operation(summary = "重启服务")
@GetMapping(value = "/restart") @GetMapping(value = "/restart")
@ResponseBody @ResponseBody
public Object restart() { public void restart() {
Thread restartThread = new Thread(new Runnable() { taskExecutor.execute(()-> {
@Override try {
public void run() { Thread.sleep(3000);
try { SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
Thread.sleep(3000); SipStackImpl stack = (SipStackImpl) up.getSipStack();
SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); stack.stop();
SipStackImpl stack = (SipStackImpl) up.getSipStack(); Iterator listener = stack.getListeningPoints();
stack.stop(); while (listener.hasNext()) {
Iterator listener = stack.getListeningPoints(); stack.deleteListeningPoint((ListeningPoint) listener.next());
while (listener.hasNext()) {
stack.deleteListeningPoint((ListeningPoint) listener.next());
}
Iterator providers = stack.getSipProviders();
while (providers.hasNext()) {
stack.deleteSipProvider((SipProvider) providers.next());
}
VManageBootstrap.restart();
} catch (InterruptedException ignored) {
} catch (ObjectInUseException e) {
e.printStackTrace();
} }
Iterator providers = stack.getSipProviders();
while (providers.hasNext()) {
stack.deleteSipProvider((SipProvider) providers.next());
}
VManageBootstrap.restart();
} catch (InterruptedException | ObjectInUseException e) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
} }
}); });
};
restartThread.setDaemon(false);
restartThread.start();
return "success";
}
@Operation(summary = "获取版本信息") @Operation(summary = "获取版本信息")
@GetMapping(value = "/version") @GetMapping(value = "/version")
@ResponseBody @ResponseBody
public WVPResult<VersionPo> getVersion() { public VersionPo VersionPogetVersion() {
WVPResult<VersionPo> result = new WVPResult<>(); return versionInfo.getVersion();
result.setCode(0);
result.setMsg("success");
result.setData(versionInfo.getVersion());
return result;
} }
@GetMapping(value = "/config") @GetMapping(value = "/config")
@Operation(summary = "获取配置信息") @Operation(summary = "获取配置信息")
@Parameter(name = "type", description = "配置类型sip, base", required = true) @Parameter(name = "type", description = "配置类型sip, base", required = true)
@ResponseBody @ResponseBody
public WVPResult<JSONObject> getVersion(String type) { public JSONObject getVersion(String type) {
WVPResult<JSONObject> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("server.port", serverPort); jsonObject.put("server.port", serverPort);
if (StringUtils.isEmpty(type)) { if (ObjectUtils.isEmpty(type)) {
jsonObject.put("sip", JSON.toJSON(sipConfig)); jsonObject.put("sip", JSON.toJSON(sipConfig));
jsonObject.put("base", JSON.toJSON(userSetting)); jsonObject.put("base", JSON.toJSON(userSetting));
} else { } else {
@ -240,50 +196,13 @@ public class ServerController {
break; break;
} }
} }
result.setData(jsonObject); return jsonObject;
return result;
} }
@GetMapping(value = "/hooks") @GetMapping(value = "/hooks")
@ResponseBody @ResponseBody
@Operation(summary = "获取当前所有hook") @Operation(summary = "获取当前所有hook")
public WVPResult<List<IHookSubscribe>> getHooks() { public List<IHookSubscribe> getHooks() {
WVPResult<List<IHookSubscribe>> result = new WVPResult<>(); return zlmHttpHookSubscribe.getAll();
result.setCode(0);
result.setMsg("success");
List<IHookSubscribe> all = zlmHttpHookSubscribe.getAll();
result.setData(all);
return result;
} }
// //@ApiOperation("当前进行中的动态任务")
// @GetMapping(value = "/dynamicTask")
// @ResponseBody
// public WVPResult<JSONObject> getDynamicTask(){
// WVPResult<JSONObject> result = new WVPResult<>();
// result.setCode(0);
// result.setMsg("success");
//
// JSONObject jsonObject = new JSONObject();
//
// Set<String> allKeys = dynamicTask.getAllKeys();
// jsonObject.put("server.port", serverPort);
// if (StringUtils.isEmpty(type)) {
// jsonObject.put("sip", JSON.toJSON(sipConfig));
// jsonObject.put("base", JSON.toJSON(userSetting));
// }else {
// switch (type){
// case "sip":
// jsonObject.put("sip", sipConfig);
// break;
// case "base":
// jsonObject.put("base", userSetting);
// break;
// default:
// break;
// }
// }
// result.setData(jsonObject);
// return result;
// }
} }

View File

@ -2,12 +2,14 @@ package com.genersoft.iot.vmp.vmanager.streamProxy;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -18,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -33,10 +36,6 @@ public class StreamProxyController {
private final static Logger logger = LoggerFactory.getLogger(StreamProxyController.class); private final static Logger logger = LoggerFactory.getLogger(StreamProxyController.class);
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired @Autowired
private IMediaServerService mediaServerService; private IMediaServerService mediaServerService;
@ -64,35 +63,32 @@ public class StreamProxyController {
}) })
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ResponseBody @ResponseBody
public WVPResult save(@RequestBody StreamProxyItem param){ public StreamInfo save(@RequestBody StreamProxyItem param){
logger.info("添加代理: " + JSONObject.toJSONString(param)); logger.info("添加代理: " + JSONObject.toJSONString(param));
if (StringUtils.isEmpty(param.getMediaServerId())) { if (ObjectUtils.isEmpty(param.getMediaServerId())) {
param.setMediaServerId("auto"); param.setMediaServerId("auto");
} }
if (StringUtils.isEmpty(param.getType())) { if (ObjectUtils.isEmpty(param.getType())) {
param.setType("default"); param.setType("default");
} }
if (StringUtils.isEmpty(param.getGbId())) { if (ObjectUtils.isEmpty(param.getGbId())) {
param.setGbId(null); param.setGbId(null);
} }
WVPResult<StreamInfo> result = streamProxyService.save(param); return streamProxyService.save(param);
return result;
} }
@GetMapping(value = "/ffmpeg_cmd/list") @GetMapping(value = "/ffmpeg_cmd/list")
@ResponseBody @ResponseBody
@Operation(summary = "获取ffmpeg.cmd模板") @Operation(summary = "获取ffmpeg.cmd模板")
@Parameter(name = "mediaServerId", description = "流媒体ID", required = true) @Parameter(name = "mediaServerId", description = "流媒体ID", required = true)
public WVPResult getFFmpegCMDs(@RequestParam String mediaServerId){ public JSONObject getFFmpegCMDs(@RequestParam String mediaServerId){
logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId ); logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId );
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
JSONObject data = streamProxyService.getFFmpegCMDs(mediaServerItem); if (mediaServerItem == null) {
WVPResult<JSONObject> result = new WVPResult<>(); throw new ControllerException(ErrorCode.ERROR100.getCode(), "流媒体: " + mediaServerId + "未找到");
result.setCode(0); }
result.setMsg("success"); return streamProxyService.getFFmpegCMDs(mediaServerItem);
result.setData(data);
return result;
} }
@DeleteMapping(value = "/del") @DeleteMapping(value = "/del")
@ -100,18 +96,13 @@ public class StreamProxyController {
@Operation(summary = "移除代理") @Operation(summary = "移除代理")
@Parameter(name = "app", description = "应用名", required = true) @Parameter(name = "app", description = "应用名", required = true)
@Parameter(name = "stream", description = "流id", required = true) @Parameter(name = "stream", description = "流id", required = true)
public WVPResult del(@RequestParam String app, @RequestParam String stream){ public void del(@RequestParam String app, @RequestParam String stream){
logger.info("移除代理: " + app + "/" + stream); logger.info("移除代理: " + app + "/" + stream);
WVPResult<Object> result = new WVPResult<>();
if (app == null || stream == null) { if (app == null || stream == null) {
result.setCode(400); throw new ControllerException(ErrorCode.ERROR400.getCode(), app == null ?"app不能为null":"stream不能为null");
result.setMsg(app == null ?"app不能为null":"stream不能为null");
}else { }else {
streamProxyService.del(app, stream); streamProxyService.del(app, stream);
result.setCode(0);
result.setMsg("success");
} }
return result;
} }
@GetMapping(value = "/start") @GetMapping(value = "/start")
@ -119,13 +110,13 @@ public class StreamProxyController {
@Operation(summary = "启用代理") @Operation(summary = "启用代理")
@Parameter(name = "app", description = "应用名", required = true) @Parameter(name = "app", description = "应用名", required = true)
@Parameter(name = "stream", description = "流id", required = true) @Parameter(name = "stream", description = "流id", required = true)
public Object start(String app, String stream){ public void start(String app, String stream){
logger.info("启用代理: " + app + "/" + stream); logger.info("启用代理: " + app + "/" + stream);
boolean result = streamProxyService.start(app, stream); boolean result = streamProxyService.start(app, stream);
if (!result) { if (!result) {
logger.info("启用代理失败: " + app + "/" + stream); logger.info("启用代理失败: " + app + "/" + stream);
throw new ControllerException(ErrorCode.ERROR100);
} }
return result?"success":"fail";
} }
@GetMapping(value = "/stop") @GetMapping(value = "/stop")
@ -133,9 +124,12 @@ public class StreamProxyController {
@Operation(summary = "停用代理") @Operation(summary = "停用代理")
@Parameter(name = "app", description = "应用名", required = true) @Parameter(name = "app", description = "应用名", required = true)
@Parameter(name = "stream", description = "流id", required = true) @Parameter(name = "stream", description = "流id", required = true)
public Object stop(String app, String stream){ public void stop(String app, String stream){
logger.info("停用代理: " + app + "/" + stream); logger.info("停用代理: " + app + "/" + stream);
boolean result = streamProxyService.stop(app, stream); boolean result = streamProxyService.stop(app, stream);
return result?"success":"fail"; if (!result) {
logger.info("停用代理失败: " + app + "/" + stream);
throw new ControllerException(ErrorCode.ERROR100);
}
} }
} }

View File

@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -81,10 +82,10 @@ public class StreamPushController {
@RequestParam(required = false)Boolean pushing, @RequestParam(required = false)Boolean pushing,
@RequestParam(required = false)String mediaServerId ){ @RequestParam(required = false)String mediaServerId ){
if (StringUtils.isEmpty(query)) { if (ObjectUtils.isEmpty(query)) {
query = null; query = null;
} }
if (StringUtils.isEmpty(mediaServerId)) { if (ObjectUtils.isEmpty(mediaServerId)) {
mediaServerId = null; mediaServerId = null;
} }
PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page, count, query, pushing, mediaServerId); PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page, count, query, pushing, mediaServerId);
@ -285,11 +286,11 @@ public class StreamPushController {
@ResponseBody @ResponseBody
@Operation(summary = "停止视频回放") @Operation(summary = "停止视频回放")
public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){ public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){
if (StringUtils.isEmpty(stream.getGbId())) { if (ObjectUtils.isEmpty(stream.getGbId())) {
return new WVPResult<>(400, "国标ID不可为空", null); return new WVPResult<>(400, "国标ID不可为空", null);
} }
if (StringUtils.isEmpty(stream.getApp()) && StringUtils.isEmpty(stream.getStream())) { if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) {
return new WVPResult<>(400, "app或stream不可为空", null); return new WVPResult<>(400, "app或stream不可为空", null);
} }
stream.setStatus(false); stream.setStatus(false);

View File

@ -1,9 +1,11 @@
package com.genersoft.iot.vmp.vmanager.user; package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils; import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.service.IRoleService; import com.genersoft.iot.vmp.service.IRoleService;
import com.genersoft.iot.vmp.storager.dao.dto.Role; import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -29,16 +31,13 @@ public class RoleController {
@Operation(summary = "添加角色") @Operation(summary = "添加角色")
@Parameter(name = "name", description = "角色名", required = true) @Parameter(name = "name", description = "角色名", required = true)
@Parameter(name = "authority", description = "权限(自行定义内容,目前未使用)", required = true) @Parameter(name = "authority", description = "权限(自行定义内容,目前未使用)", required = true)
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String name, public void add(@RequestParam String name,
@RequestParam(required = false) String authority){ @RequestParam(required = false) String authority){
WVPResult<Integer> result = new WVPResult<>();
// 获取当前登录用户id // 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
if (currenRoleId != 1) { if (currenRoleId != 1) {
// 只用角色id为1才可以删除和添加用户 // 只用角色id为1才可以删除和添加用户
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR403);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
} }
Role role = new Role(); Role role = new Role();
@ -48,42 +47,33 @@ public class RoleController {
role.setUpdateTime(DateUtil.getNow()); role.setUpdateTime(DateUtil.getNow());
int addResult = roleService.add(role); int addResult = roleService.add(role);
if (addResult <= 0) {
result.setCode(addResult > 0 ? 0 : -1); throw new ControllerException(ErrorCode.ERROR100);
result.setMsg(addResult > 0 ? "success" : "fail"); }
result.setData(addResult);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除角色") @Operation(summary = "删除角色")
@Parameter(name = "id", description = "用户Id", required = true) @Parameter(name = "id", description = "用户Id", required = true)
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ public void delete(@RequestParam Integer id){
// 获取当前登录用户id // 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
WVPResult<String> result = new WVPResult<>();
if (currenRoleId != 1) { if (currenRoleId != 1) {
// 只用角色id为0才可以删除和添加用户 // 只用角色id为0才可以删除和添加用户
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR403);
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
} }
int deleteResult = roleService.delete(id); int deleteResult = roleService.delete(id);
result.setCode(deleteResult>0? 0 : -1); if (deleteResult <= 0) {
result.setMsg(deleteResult>0? "success" : "fail"); throw new ControllerException(ErrorCode.ERROR100);
return new ResponseEntity<>(result, HttpStatus.OK); }
} }
@GetMapping("/all") @GetMapping("/all")
@Operation(summary = "查询角色") @Operation(summary = "查询角色")
public ResponseEntity<WVPResult<List<Role>>> all(){ public List<Role> all(){
// 获取当前登录用户id // 获取当前登录用户id
List<Role> allRoles = roleService.getAll(); List<Role> allRoles = roleService.getAll();
WVPResult<List<Role>> result = new WVPResult<>(); return roleService.getAll();
result.setCode(0);
result.setMsg("success");
result.setData(allRoles);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.vmanager.user; package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.SecurityUtils; import com.genersoft.iot.vmp.conf.security.SecurityUtils;
import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.service.IRoleService; import com.genersoft.iot.vmp.service.IRoleService;
@ -7,6 +8,7 @@ import com.genersoft.iot.vmp.service.IUserService;
import com.genersoft.iot.vmp.storager.dao.dto.Role; import com.genersoft.iot.vmp.storager.dao.dto.Role;
import com.genersoft.iot.vmp.storager.dao.dto.User; import com.genersoft.iot.vmp.storager.dao.dto.User;
import com.genersoft.iot.vmp.utils.DateUtil; 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.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -18,6 +20,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -43,25 +46,17 @@ public class UserController {
@Operation(summary = "登录") @Operation(summary = "登录")
@Parameter(name = "username", description = "用户名", required = true) @Parameter(name = "username", description = "用户名", required = true)
@Parameter(name = "password", description = "密码32位md5加密", required = true) @Parameter(name = "password", description = "密码32位md5加密", required = true)
public WVPResult<LoginUser> login(@RequestParam String username, @RequestParam String password){ public LoginUser login(@RequestParam String username, @RequestParam String password){
LoginUser user = null; LoginUser user = null;
WVPResult<LoginUser> result = new WVPResult<>();
try { try {
user = SecurityUtils.login(username, password, authenticationManager); user = SecurityUtils.login(username, password, authenticationManager);
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
e.printStackTrace(); throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
result.setCode(-1);
result.setMsg("fail");
} }
if (user != null) { if (user == null) {
result.setCode(0); throw new ControllerException(ErrorCode.ERROR100.getCode(), "用户名或密码错误");
result.setMsg("success");
result.setData(user);
}else {
result.setCode(-1);
result.setMsg("fail");
} }
return result; return user;
} }
@PostMapping("/changePassword") @PostMapping("/changePassword")
@ -69,27 +64,27 @@ public class UserController {
@Parameter(name = "username", description = "用户名", required = true) @Parameter(name = "username", description = "用户名", required = true)
@Parameter(name = "oldpassword", description = "旧密码已md5加密的密码", required = true) @Parameter(name = "oldpassword", description = "旧密码已md5加密的密码", required = true)
@Parameter(name = "password", description = "新密码未md5加密的密码", required = true) @Parameter(name = "password", description = "新密码未md5加密的密码", required = true)
public String changePassword(@RequestParam String oldPassword, @RequestParam String password){ public void changePassword(@RequestParam String oldPassword, @RequestParam String password){
// 获取当前登录用户id // 获取当前登录用户id
LoginUser userInfo = SecurityUtils.getUserInfo(); LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo== null) { if (userInfo== null) {
return "fail"; throw new ControllerException(ErrorCode.ERROR100);
} }
String username = userInfo.getUsername(); String username = userInfo.getUsername();
LoginUser user = null; LoginUser user = null;
try { try {
user = SecurityUtils.login(username, oldPassword, authenticationManager); user = SecurityUtils.login(username, oldPassword, authenticationManager);
if (user != null) { if (user == null) {
int userId = SecurityUtils.getUserId(); throw new ControllerException(ErrorCode.ERROR100);
boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes())); }
if (result) { int userId = SecurityUtils.getUserId();
return "success"; boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
} if (!result) {
throw new ControllerException(ErrorCode.ERROR100);
} }
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
e.printStackTrace(); throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
} }
return "fail";
} }
@ -98,22 +93,17 @@ public class UserController {
@Parameter(name = "username", description = "用户名", required = true) @Parameter(name = "username", description = "用户名", required = true)
@Parameter(name = "password", description = "密码未md5加密的密码", required = true) @Parameter(name = "password", description = "密码未md5加密的密码", required = true)
@Parameter(name = "roleId", description = "角色ID", required = true) @Parameter(name = "roleId", description = "角色ID", required = true)
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String username, public void add(@RequestParam String username,
@RequestParam String password, @RequestParam String password,
@RequestParam Integer roleId){ @RequestParam Integer roleId){
WVPResult<Integer> result = new WVPResult<>(); if (ObjectUtils.isEmpty(username) || ObjectUtils.isEmpty(password) || roleId == null) {
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || roleId == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "参数不可为空");
result.setCode(-1);
result.setMsg("参数不可为空");
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
} }
// 获取当前登录用户id // 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
if (currenRoleId != 1) { if (currenRoleId != 1) {
// 只用角色id为1才可以删除和添加用户 // 只用角色id为1才可以删除和添加用户
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR400.getCode(), "用户无权限");
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
} }
User user = new User(); User user = new User();
user.setUsername(username); user.setUsername(username);
@ -123,53 +113,38 @@ public class UserController {
Role role = roleService.getRoleById(roleId); Role role = roleService.getRoleById(roleId);
if (role == null) { if (role == null) {
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR400.getCode(), "角色不存在");
result.setMsg("roleId is not found");
// 角色不存在
return new ResponseEntity<>(result, HttpStatus.OK);
} }
user.setRole(role); user.setRole(role);
user.setCreateTime(DateUtil.getNow()); user.setCreateTime(DateUtil.getNow());
user.setUpdateTime(DateUtil.getNow()); user.setUpdateTime(DateUtil.getNow());
int addResult = userService.addUser(user); int addResult = userService.addUser(user);
if (addResult <= 0) {
throw new ControllerException(ErrorCode.ERROR100);
result.setCode(addResult > 0 ? 0 : -1); }
result.setMsg(addResult > 0 ? "success" : "fail");
result.setData(addResult);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
@DeleteMapping("/删除用户") @DeleteMapping("/删除用户")
@Operation(summary = "停止视频回放") @Operation(summary = "停止视频回放")
@Parameter(name = "id", description = "用户Id", required = true) @Parameter(name = "id", description = "用户Id", required = true)
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ public void delete(@RequestParam Integer id){
// 获取当前登录用户id // 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
WVPResult<String> result = new WVPResult<>();
if (currenRoleId != 1) { if (currenRoleId != 1) {
// 只用角色id为0才可以删除和添加用户 // 只用角色id为0才可以删除和添加用户
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR400.getCode(), "用户无权限");
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
} }
int deleteResult = userService.deleteUser(id); int deleteResult = userService.deleteUser(id);
if (deleteResult <= 0) {
result.setCode(deleteResult>0? 0 : -1); throw new ControllerException(ErrorCode.ERROR100);
result.setMsg(deleteResult>0? "success" : "fail"); }
return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/all") @GetMapping("/all")
@Operation(summary = "查询用户") @Operation(summary = "查询用户")
public ResponseEntity<WVPResult<List<User>>> all(){ public List<User> all(){
// 获取当前登录用户id // 获取当前登录用户id
List<User> allUsers = userService.getAllUsers(); return userService.getAllUsers();
WVPResult<List<User>> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");
result.setData(allUsers);
return new ResponseEntity<>(result, HttpStatus.OK);
} }
/** /**
@ -191,21 +166,18 @@ public class UserController {
@Operation(summary = "修改pushkey") @Operation(summary = "修改pushkey")
@Parameter(name = "userId", description = "用户Id", required = true) @Parameter(name = "userId", description = "用户Id", required = true)
@Parameter(name = "pushKey", description = "新的pushKey", required = true) @Parameter(name = "pushKey", description = "新的pushKey", required = true)
public ResponseEntity<WVPResult<String>> changePushKey(@RequestParam Integer userId,@RequestParam String pushKey) { public void changePushKey(@RequestParam Integer userId,@RequestParam String pushKey) {
// 获取当前登录用户id // 获取当前登录用户id
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); int currenRoleId = SecurityUtils.getUserInfo().getRole().getId();
WVPResult<String> result = new WVPResult<>(); WVPResult<String> result = new WVPResult<>();
if (currenRoleId != 1) { if (currenRoleId != 1) {
// 只用角色id为0才可以删除和添加用户 // 只用角色id为0才可以删除和添加用户
result.setCode(-1); throw new ControllerException(ErrorCode.ERROR400.getCode(), "用户无权限");
result.setMsg("用户无权限");
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN);
} }
int resetPushKeyResult = userService.changePushKey(userId,pushKey); int resetPushKeyResult = userService.changePushKey(userId,pushKey);
if (resetPushKeyResult <= 0) {
result.setCode(resetPushKeyResult > 0 ? 0 : -1); throw new ControllerException(ErrorCode.ERROR100);
result.setMsg(resetPushKeyResult > 0 ? "success" : "fail"); }
return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/changePasswordForAdmin") @PostMapping("/changePasswordForAdmin")
@ -213,20 +185,18 @@ public class UserController {
@Parameter(name = "adminId", description = "管理员id", required = true) @Parameter(name = "adminId", description = "管理员id", required = true)
@Parameter(name = "userId", description = "用户id", required = true) @Parameter(name = "userId", description = "用户id", required = true)
@Parameter(name = "password", description = "新密码未md5加密的密码", required = true) @Parameter(name = "password", description = "新密码未md5加密的密码", required = true)
public String changePasswordForAdmin(@RequestParam int userId, @RequestParam String password) { public void changePasswordForAdmin(@RequestParam int userId, @RequestParam String password) {
// 获取当前登录用户id // 获取当前登录用户id
LoginUser userInfo = SecurityUtils.getUserInfo(); LoginUser userInfo = SecurityUtils.getUserInfo();
if (userInfo == null) { if (userInfo == null) {
return "fail"; throw new ControllerException(ErrorCode.ERROR100);
} }
Role role = userInfo.getRole(); Role role = userInfo.getRole();
if (role != null && role.getId() == 1) { if (role != null && role.getId() == 1) {
boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes())); boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
if (result) { if (!result) {
return "success"; throw new ControllerException(ErrorCode.ERROR100);
} }
} }
return "fail";
} }
} }

14432
web_src/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -125,8 +125,10 @@
} }
}).then(function (res) { }).then(function (res) {
console.log(res) console.log(res)
that.total = res.data.data.total; if (res.data.code === 0) {
that.recordList = res.data.data.list; that.total = res.data.data.total;
that.recordList = res.data.data.list;
}
that.loading = false; that.loading = false;
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
@ -174,8 +176,10 @@
} }
}).then(function (res) { }).then(function (res) {
console.log(res) console.log(res)
that.total = res.data.data.total; if (res.data.code === 0) {
that.recordList = res.data.data.list; that.total = res.data.data.total;
that.recordList = res.data.data.list;
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });

View File

@ -15,7 +15,6 @@
<i class="el-icon-video-camera" ></i> <i class="el-icon-video-camera" ></i>
{{ item.substring(0,17)}} {{ item.substring(0,17)}}
</el-tag> </el-tag>
<!-- <a class="el-icon-download" style="color: #409EFF;font-weight: 600;margin-left: 10px;" :href="`${basePath}/${mediaServerId}/record/${recordFile.app}/${recordFile.stream}/${chooseDate}/${item}`" download />-->
<a class="el-icon-download" style="color: #409EFF;font-weight: 600;margin-left: 10px;" :href="`${basePath}/download.html?url=record/${recordFile.app}/${recordFile.stream}/${chooseDate}/${item}`" target="_blank" /> <a class="el-icon-download" style="color: #409EFF;font-weight: 600;margin-left: 10px;" :href="`${basePath}/download.html?url=record/${recordFile.app}/${recordFile.stream}/${chooseDate}/${item}`" target="_blank" />
</li> </li>
</ul> </ul>
@ -250,8 +249,10 @@
count: that.count count: that.count
} }
}).then(function (res) { }).then(function (res) {
that.total = res.data.data.total; if (res.data.code === 0) {
that.detailFiles = that.detailFiles.concat(res.data.data.list); that.total = res.data.data.total;
that.detailFiles = that.detailFiles.concat(res.data.data.list);
}
that.loading = false; that.loading = false;
if (callback) callback(); if (callback) callback();
}).catch(function (error) { }).catch(function (error) {
@ -320,7 +321,7 @@
count: that.count count: that.count
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code == 0) { if (res.data.code === 0) {
that.total = res.data.data.total; that.total = res.data.data.total;
that.recordList = res.data.data.list; that.recordList = res.data.data.list;
} }
@ -390,7 +391,7 @@
endTime: moment(this.taskTimeRange[1]).format('YYYY-MM-DD HH:mm:ss'), endTime: moment(this.taskTimeRange[1]).format('YYYY-MM-DD HH:mm:ss'),
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code === 0 && res.data.msg === "success") { if (res.data.code === 0 ) {
that.showTaskBox = false that.showTaskBox = false
that.getTaskList(false); that.getTaskList(false);
}else { }else {
@ -412,7 +413,7 @@
isEnd: isEnd, isEnd: isEnd,
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code == 0) { if (res.data.code === 0) {
if (isEnd){ if (isEnd){
that.taskListEnded = res.data.data; that.taskListEnded = res.data.data;
}else { }else {

View File

@ -146,22 +146,23 @@ export default {
this.getDeviceList(); this.getDeviceList();
}, },
getDeviceList: function () { getDeviceList: function () {
let that = this;
this.getDeviceListLoading = true; this.getDeviceListLoading = true;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: `/api/device/query/devices`, url: `/api/device/query/devices`,
params: { params: {
page: that.currentPage, page: this.currentPage,
count: that.count count: this.count
} }
}).then(function (res) { }).then( (res)=> {
that.total = res.data.total; if (res.data.code === 0) {
that.deviceList = res.data.list; this.total = res.data.data.total;
that.getDeviceListLoading = false; this.deviceList = res.data.data.list;
}).catch(function (error) { }
this.getDeviceListLoading = false;
}).catch( (error)=> {
console.error(error); console.error(error);
that.getDeviceListLoading = false; this.getDeviceListLoading = false;
}); });
}, },

View File

@ -85,7 +85,7 @@ export default {
params: loginParam params: loginParam
}).then(function (res) { }).then(function (res) {
console.log(JSON.stringify(res)); console.log(JSON.stringify(res));
if (res.data.code == 0 && res.data.msg == "success") { if (res.data.code === 0 ) {
that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ; that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ;
// //
that.cancelEnterkeyDefaultAction(); that.cancelEnterkeyDefaultAction();

View File

@ -127,10 +127,10 @@ export default {
deletePlatformCommit: function(platform) { deletePlatformCommit: function(platform) {
var that = this; var that = this;
that.$axios({ that.$axios({
method: 'delete', method: 'delete',
url:`/api/platform/delete/${platform.serverGBId}` url:`/api/platform/delete/${platform.serverGBId}`
}).then(function (res) { }).then(function (res) {
if (res.data == "success") { if (res.data.code === 0) {
that.$message({ that.$message({
showClose: true, showClose: true,
message: '删除成功', message: '删除成功',
@ -163,8 +163,11 @@ export default {
method: 'get', method: 'get',
url:`/api/platform/query/${that.count}/${that.currentPage}` url:`/api/platform/query/${that.count}/${that.currentPage}`
}).then(function (res) { }).then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
that.platformList = res.data.list; that.total = res.data.data.total;
that.platformList = res.data.data.list;
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });

View File

@ -180,8 +180,11 @@ export default {
mediaServerId: that.mediaServerId, mediaServerId: that.mediaServerId,
} }
}).then(function (res) { }).then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
that.pushList = res.data.list; that.total = res.data.data.total;
that.pushList = res.data.data.list;
}
that.getDeviceListLoading = false; that.getDeviceListLoading = false;
}).catch(function (error) { }).catch(function (error) {
console.error(error); console.error(error);
@ -226,7 +229,7 @@ export default {
streamId: row.stream streamId: row.stream
} }
}).then((res) => { }).then((res) => {
if (res.data == "success") { if (res.data.code === 0) {
that.initData() that.initData()
} }
}).catch(function (error) { }).catch(function (error) {
@ -247,7 +250,7 @@ export default {
url: "/api/push/remove_form_gb", url: "/api/push/remove_form_gb",
data: row data: row
}).then((res) => { }).then((res) => {
if (res.data == "success") { if (res.data.code === 0) {
that.initData() that.initData()
} }
}).catch(function (error) { }).catch(function (error) {

View File

@ -168,12 +168,14 @@
count: that.count count: that.count
} }
}).then(function (res) { }).then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
for (let i = 0; i < res.data.list.length; i++) { that.total = res.data.data.total;
res.data.list[i]["startBtnLoading"] = false; for (let i = 0; i < res.data.data.list.length; i++) {
res.data.data.list[i]["startBtnLoading"] = false;
}
that.streamProxyList = res.data.data.list;
} }
that.streamProxyList = res.data.list; that.getListLoading = false;
that.getListLoading = false;
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
that.getListLoading = false; that.getListLoading = false;
@ -190,7 +192,7 @@
url:`/api/onvif/search?timeout=3000`, url:`/api/onvif/search?timeout=3000`,
}).then((res) =>{ }).then((res) =>{
this.getListLoading = false; this.getListLoading = false;
if (res.data.code == 0 ){ if (res.data.code === 0 ){
if (res.data.data.length > 0) { if (res.data.data.length > 0) {
this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{ this.$refs.onvifEdit.openDialog(res.data.data, (url)=>{
if (url != null) { if (url != null) {
@ -277,7 +279,7 @@
}).then(function (res) { }).then(function (res) {
that.getListLoading = false; that.getListLoading = false;
that.$set(row, 'startBtnLoading', false) that.$set(row, 'startBtnLoading', false)
if (res.data == "success"){ if (res.data.code === 0){
that.initData() that.initData()
}else { }else {
that.$message({ that.$message({

View File

@ -105,8 +105,10 @@ export default {
count: that.count count: that.count
} }
}).then(function (res) { }).then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
that.userList = res.data.list; that.total = res.data.data.total;
that.userList = res.data.data.list;
}
that.getUserListLoading = false; that.getUserListLoading = false;
}).catch(function (error) { }).catch(function (error) {
that.getUserListLoading = false; that.getUserListLoading = false;

View File

@ -215,12 +215,15 @@ export default {
channelType: that.channelType channelType: that.channelType
} }
}).then(function (res) { }).then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
that.deviceChannelList = res.data.list; that.total = res.data.data.total;
// that.deviceChannelList = res.data.data.list;
that.$nextTick(() => { //
that.$refs.channelListTable.doLayout(); that.$nextTick(() => {
}) that.$refs.channelListTable.doLayout();
})
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });
@ -339,12 +342,15 @@ export default {
channelType: this.channelType channelType: this.channelType
} }
}).then( (res) =>{ }).then( (res) =>{
this.total = res.data.total; if (res.data.code === 0) {
this.deviceChannelList = res.data.list; this.total = res.data.data.total;
// this.deviceChannelList = res.data.data.list;
this.$nextTick(() => { //
this.$refs.channelListTable.doLayout(); this.$nextTick(() => {
}) this.$refs.channelListTable.doLayout();
})
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });
@ -358,12 +364,14 @@ export default {
count: this.count, count: this.count,
} }
}).then((res)=> { }).then((res)=> {
this.total = res.data.total; if (res.data.code === 0) {
this.deviceChannelList = res.data.list; this.total = res.data.total;
// this.deviceChannelList = res.data.list;
this.$nextTick(() => { //
this.$refs.channelListTable.doLayout(); this.$nextTick(() => {
}) this.$refs.channelListTable.doLayout();
})
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });

View File

@ -0,0 +1,327 @@
<template>
<div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #000000;margin:0 auto;">
<div class="buttons-box" id="buttonsBox">
<div class="buttons-box-left">
<i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
<i v-if="playing" class="iconfont icon-pause jessibuca-btn" @click="pause"></i>
<i class="iconfont icon-stop jessibuca-btn" @click="destroy"></i>
<i v-if="isNotMute" class="iconfont icon-audio-high jessibuca-btn" @click="mute()"></i>
<i v-if="!isNotMute" class="iconfont icon-audio-mute jessibuca-btn" @click="cancelMute()"></i>
</div>
<div class="buttons-box-right">
<span class="jessibuca-btn">{{ kBps }} kb/s</span>
<!-- <i class="iconfont icon-file-record1 jessibuca-btn"></i>-->
<!-- <i class="iconfont icon-xiangqing2 jessibuca-btn" ></i>-->
<i class="iconfont icon-camera1196054easyiconnet jessibuca-btn" @click="jessibuca.screenshot('截图','png',0.5)"
style="font-size: 1rem !important"></i>
<i class="iconfont icon-shuaxin11 jessibuca-btn" @click="playBtnClick"></i>
<i v-if="!fullscreen" class="iconfont icon-weibiaoti10 jessibuca-btn" @click="fullscreenSwich"></i>
<i v-if="fullscreen" class="iconfont icon-weibiaoti11 jessibuca-btn" @click="fullscreenSwich"></i>
</div>
</div>
</div>
</template>
<script>
let jessibucaPlayer = {};
export default {
name: 'jessibuca',
data() {
return {
playing: false,
isNotMute: false,
quieting: false,
fullscreen: false,
loaded: false, // mute
speed: 0,
performance: "", //
kBps: 0,
btnDom: null,
videoInfo: null,
volume: 1,
rotate: 0,
vod: true, //
forceNoOffscreen: false,
};
},
props: ['videoUrl', 'error', 'hasAudio', 'height'],
mounted() {
window.onerror = (msg) => {
// console.error(msg)
};
console.log(this._uid)
let paramUrl = decodeURIComponent(this.$route.params.url)
this.$nextTick(() => {
this.updatePlayerDomSize()
window.onresize = () => {
this.updatePlayerDomSize()
}
if (typeof (this.videoUrl) == "undefined") {
this.videoUrl = paramUrl;
}
this.btnDom = document.getElementById("buttonsBox");
console.log("初始化时的地址为: " + this.videoUrl)
this.play(this.videoUrl)
})
},
watch: {
videoUrl(newData, oldData) {
this.play(newData)
},
immediate: true
},
methods: {
updatePlayerDomSize() {
let dom = this.$refs.container;
let width = dom.parentNode.clientWidth
let height = (9 / 16) * width
const clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight)
if (height > clientHeight) {
height = clientHeight
width = (16 / 9) * height
}
dom.style.width = width + 'px';
dom.style.height = height + "px";
},
create() {
let options = {};
console.log("hasAudio " + this.hasAudio)
jessibucaPlayer[this._uid] = new window.Jessibuca(Object.assign(
{
container: this.$refs.container,
videoBuffer: 0.2, //
isResize: true,
decoder: "static/js/jessibuca/decoder.js",
useMSE: false,
showBandwidth: false,
isFlv: true,
// text: "WVP-PRO",
// background: "static/images/zlm-logo.png",
loadingText: "加载中",
hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio,
debug: false,
supportDblclickFullscreen: false, //
operateBtns: {
fullscreen: false,
screenshot: false,
play: false,
audio: false,
recorder: false,
},
record: "record",
vod: this.vod,
forceNoOffscreen: this.forceNoOffscreen,
isNotMute: this.isNotMute,
},
options
));
let jessibuca = jessibucaPlayer[this._uid];
let _this = this;
jessibuca.on("load", function () {
console.log("on load init");
});
jessibuca.on("log", function (msg) {
console.log("on log", msg);
});
jessibuca.on("record", function (msg) {
console.log("on record:", msg);
});
jessibuca.on("pause", function () {
_this.playing = false;
});
jessibuca.on("play", function () {
_this.playing = true;
});
jessibuca.on("fullscreen", function (msg) {
console.log("on fullscreen", msg);
_this.fullscreen = msg
});
jessibuca.on("mute", function (msg) {
console.log("on mute", msg);
_this.isNotMute = !msg;
});
jessibuca.on("audioInfo", function (msg) {
// console.log("audioInfo", msg);
});
jessibuca.on("videoInfo", function (msg) {
// this.videoInfo = msg;
console.log("videoInfo", msg);
});
jessibuca.on("bps", function (bps) {
// console.log('bps', bps);
});
let _ts = 0;
jessibuca.on("timeUpdate", function (ts) {
// console.log('timeUpdate,old,new,timestamp', _ts, ts, ts - _ts);
_ts = ts;
});
jessibuca.on("videoInfo", function (info) {
console.log("videoInfo", info);
});
jessibuca.on("error", function (error) {
console.log("error", error);
});
jessibuca.on("timeout", function () {
console.log("timeout");
});
jessibuca.on('start', function () {
console.log('start');
})
jessibuca.on("performance", function (performance) {
let show = "卡顿";
if (performance === 2) {
show = "非常流畅";
} else if (performance === 1) {
show = "流畅";
}
_this.performance = show;
});
jessibuca.on('buffer', function (buffer) {
// console.log('buffer', buffer);
})
jessibuca.on('stats', function (stats) {
// console.log('stats', stats);
})
jessibuca.on('kBps', function (kBps) {
_this.kBps = Math.round(kBps);
});
// PTS
jessibuca.on('videoFrame', function () {
})
//
jessibuca.on('metadata', function () {
});
},
playBtnClick: function (event) {
this.play(this.videoUrl)
},
play: function (url) {
console.log(url)
if (jessibucaPlayer[this._uid]) {
this.destroy();
}
this.create();
jessibucaPlayer[this._uid].on("play", () => {
this.playing = true;
this.loaded = true;
this.quieting = jessibuca.quieting;
});
if (jessibucaPlayer[this._uid].hasLoaded()) {
jessibucaPlayer[this._uid].play(url);
} else {
jessibucaPlayer[this._uid].on("load", () => {
console.log("load 播放")
jessibucaPlayer[this._uid].play(url);
});
}
},
pause: function () {
if (jessibucaPlayer[this._uid]) {
jessibucaPlayer[this._uid].pause();
}
this.playing = false;
this.err = "";
this.performance = "";
},
mute: function () {
if (jessibucaPlayer[this._uid]) {
jessibucaPlayer[this._uid].mute();
}
},
cancelMute: function () {
if (jessibucaPlayer[this._uid]) {
jessibucaPlayer[this._uid].cancelMute();
}
},
destroy: function () {
if (jessibucaPlayer[this._uid]) {
jessibucaPlayer[this._uid].destroy();
}
if (document.getElementById("buttonsBox") == null) {
this.$refs.container.appendChild(this.btnDom)
}
jessibucaPlayer[this._uid] = null;
this.playing = false;
this.err = "";
this.performance = "";
},
eventcallbacK: function (type, message) {
// console.log("player ")
// console.log(type)
// console.log(message)
},
fullscreenSwich: function () {
let isFull = this.isFullscreen()
jessibucaPlayer[this._uid].setFullscreen(!isFull)
this.fullscreen = !isFull;
},
isFullscreen: function () {
return document.fullscreenElement ||
document.msFullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement || false;
}
},
destroyed() {
if (jessibucaPlayer[this._uid]) {
jessibucaPlayer[this._uid].destroy();
}
this.playing = false;
this.loaded = false;
this.performance = "";
},
}
</script>
<style>
.buttons-box {
width: 100%;
height: 28px;
background-color: rgba(43, 51, 63, 0.7);
position: absolute;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
left: 0;
bottom: 0;
user-select: none;
z-index: 10;
}
.jessibuca-btn {
width: 20px;
color: rgb(255, 255, 255);
line-height: 27px;
margin: 0px 10px;
padding: 0px 2px;
cursor: pointer;
text-align: center;
font-size: 0.8rem !important;
}
.buttons-box-right {
position: absolute;
right: 0;
}
</style>

View File

@ -329,7 +329,7 @@ export default {
method: 'get', method: 'get',
url: '/zlm/' + that.mediaServerChoose + '/index/api/getThreadsLoad' url: '/zlm/' + that.mediaServerChoose + '/index/api/getThreadsLoad'
}).then(function (res) { }).then(function (res) {
if (res.data.code == 0) { if (res.data.code === 0) {
that.tableOption.xAxis.data.push(new Date().toLocaleTimeString('chinese', { that.tableOption.xAxis.data.push(new Date().toLocaleTimeString('chinese', {
hour12: false hour12: false
})); }));
@ -554,7 +554,7 @@ export default {
url: '/zlm/' + that.mediaServerChoose + '/index/api/restartServer' url: '/zlm/' + that.mediaServerChoose + '/index/api/restartServer'
}).then(function (res) { }).then(function (res) {
that.getAllSession(); that.getAllSession();
if (res.data.code == 0) { if (res.data.code === 0) {
that.$message({ that.$message({
type: 'success', type: 'success',
message: '操作完成' message: '操作完成'

View File

@ -200,7 +200,7 @@ export default {
method: 'get', method: 'get',
url:`/api/platform/query/10000/1` url:`/api/platform/query/10000/1`
}).then(function (res) { }).then(function (res) {
that.platformList = res.data.list; that.platformList = res.data.data.list;
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });

View File

@ -57,7 +57,7 @@ export default {
method: 'get', method: 'get',
url:`/api/device/query/${this.deviceId}/sync_status/`, url:`/api/device/query/${this.deviceId}/sync_status/`,
}).then((res) => { }).then((res) => {
if (res.data.code == 0) { if (res.data.code === 0) {
if (!this.syncFlag) { if (!this.syncFlag) {
this.syncFlag = true; this.syncFlag = true;
} }

View File

@ -142,13 +142,8 @@ export default {
url: "/api/role/all" url: "/api/role/all"
}).then((res) => { }).then((res) => {
this.loading = true; this.loading = true;
console.info(res)
res.data
console.info(res.data.code)
if (res.data.code === 0) { if (res.data.code === 0) {
console.info(res.data.data)
this.options=res.data.data this.options=res.data.data
} }
}).catch((error) => { }).catch((error) => {
console.error(error) console.error(error)

View File

@ -118,8 +118,7 @@ export default {
method:"post", method:"post",
url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`, url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`,
data: this.form data: this.form
}) }).then((res)=> {
.then((res)=> {
if (res.data.code === 0) { if (res.data.code === 0) {
if (this.submitCallback)this.submitCallback(this.form) if (this.submitCallback)this.submitCallback(this.form)
}else { }else {

View File

@ -96,7 +96,7 @@ export default {
password: this.newPassword password: this.newPassword
} }
}).then((res)=> { }).then((res)=> {
if (res.data === "success"){ if (res.data.code === 0) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '修改成功,请重新登录', message: '修改成功,请重新登录',

View File

@ -91,7 +91,7 @@ export default {
userId: this.form.id, userId: this.form.id,
} }
}).then((res)=> { }).then((res)=> {
if (res.data === "success"){ if (res.data.code === 0) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: '修改成功', message: '修改成功',

View File

@ -71,8 +71,7 @@ export default {
userId: this.form.id, userId: this.form.id,
} }
}).then((res)=> { }).then((res)=> {
console.log(res.data) if (res.data.code === 0) {
if (res.data.msg === "success"){
this.$message({ this.$message({
showClose: true, showClose: true,
message: '修改成功', message: '修改成功',

View File

@ -101,7 +101,7 @@ export default {
channelReduces: that.chooseData channelReduces: that.chooseData
} }
}).then((res)=>{ }).then((res)=>{
if (res.data == true) { if (res.data.code === 0) {
that.$message({ that.$message({
showClose: true, showClose: true,
message: '保存成功,', message: '保存成功,',

View File

@ -87,8 +87,7 @@ export default {
platformId: that.platformId, platformId: that.platformId,
parentId: parentId parentId: parentId
} }
}) }).then((res)=> {
.then((res)=> {
if (res.data.code === 0) { if (res.data.code === 0) {
if (typeof(callback) === 'function') { if (typeof(callback) === 'function') {
callback(res.data.data) callback(res.data.data)
@ -140,8 +139,7 @@ export default {
id: id, id: id,
platformId: this.platformId, platformId: this.platformId,
} }
}) }).then((res) => {
.then((res) => {
if (res.data.code === 0) { if (res.data.code === 0) {
console.log("移除成功") console.log("移除成功")
node.parent.loaded = false node.parent.loaded = false
@ -163,8 +161,7 @@ export default {
platformId: this.platformId, platformId: this.platformId,
catalogId: id, catalogId: id,
} }
}) }).then((res)=> {
.then((res)=> {
if (res.data.code === 0) { if (res.data.code === 0) {
this.defaultCatalogIdSign = id; this.defaultCatalogIdSign = id;
} }

View File

@ -243,15 +243,16 @@ export default {
} }
}) })
.then(function (res) { .then(function (res) {
that.total = res.data.total; if (res.data.code === 0 ) {
that.gbChannels = res.data.list; that.total = res.data.data.total;
that.gbChannels = res.data.data.list;
that.gbChoosechannel = {}; that.gbChoosechannel = {};
// }
that.$nextTick(() => { //
that.$refs.gbChannelsTable.doLayout(); that.$nextTick(() => {
that.eventEnable = true; that.$refs.gbChannelsTable.doLayout();
}) that.eventEnable = true;
console.log(that.gbChoosechannel) })
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);

View File

@ -180,15 +180,17 @@ export default {
} }
}) })
.then(function (res) { .then(function (res) {
that.total = res.data.total; if (res.data.code === 0) {
that.gbStreams = res.data.list; that.total = res.data.data.total;
that.gbChoosechannel = {}; that.gbStreams = res.data.data.list;
// that.gbChoosechannel = {};
that.$nextTick(() => { //
that.$nextTick(() => {
that.$refs.gbStreamsTable.doLayout(); that.$refs.gbStreamsTable.doLayout();
// //
that.eventEnable = true; that.eventEnable = true;
}) })
}
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);

View File

@ -122,7 +122,7 @@ export default {
params: this.form params: this.form
}).then((res) => { }).then((res) => {
console.log(res.data) console.log(res.data)
if (res.data.code == 0) { if (res.data.code === 0) {
this.listChangeCallback() this.listChangeCallback()
}else { }else {
this.$message({ this.$message({

View File

@ -438,6 +438,7 @@ export default {
this.playFromStreamInfo(false, streamInfo) this.playFromStreamInfo(false, streamInfo)
}, },
getUrlByStreamInfo(){ getUrlByStreamInfo(){
console.log(this.streamInfo)
if (location.protocol === "https:") { if (location.protocol === "https:") {
this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]] this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]]
}else { }else {
@ -452,9 +453,9 @@ export default {
this.$refs[this.activePlayer].pause() this.$refs[this.activePlayer].pause()
that.$axios({ that.$axios({
method: 'post', method: 'post',
url: '/api/gb_record/convert/' + that.streamId url: '/api/play/convert/' + that.streamId
}).then(function (res) { }).then(function (res) {
if (res.data.code == 0) { if (res.data.code === 0) {
that.convertKey = res.data.key; that.convertKey = res.data.key;
setTimeout(()=>{ setTimeout(()=>{
that.isLoging = false; that.isLoging = false;
@ -605,13 +606,15 @@ export default {
url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' + url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
row.endTime row.endTime
}).then(function (res) { }).then(function (res) {
that.streamInfo = res.data; if (res.data.code === 0) {
that.streamInfo = res.data.data;
that.app = that.streamInfo.app; that.app = that.streamInfo.app;
that.streamId = that.streamInfo.stream; that.streamId = that.streamInfo.stream;
that.mediaServerId = that.streamInfo.mediaServerId; that.mediaServerId = that.streamInfo.mediaServerId;
that.ssrc = that.streamInfo.ssrc; that.ssrc = that.streamInfo.ssrc;
that.videoUrl = that.getUrlByStreamInfo(); that.videoUrl = that.getUrlByStreamInfo();
that.recordPlay = true; }
that.recordPlay = true;
}); });
} }
}, },

View File

@ -90,7 +90,7 @@ export default {
} }
}).then((res) => { }).then((res) => {
console.log(res.data) console.log(res.data)
if (res.data.code == 0) { if (res.data.code === 0) {
if (res.data.data != null) { if (res.data.data != null) {
this.listChangeCallback(res.data.data) this.listChangeCallback(res.data.data)
}else { }else {

View File

@ -194,13 +194,16 @@ export default {
url:`/api/platform/server_config` url:`/api/platform/server_config`
}).then(function (res) { }).then(function (res) {
console.log(res); console.log(res);
that.platform.deviceGBId = res.data.username; if (res.data.code === 0) {
that.platform.deviceIp = res.data.deviceIp; that.platform.deviceGBId = res.data.data.username;
that.platform.devicePort = res.data.devicePort; that.platform.deviceIp = res.data.data.deviceIp;
that.platform.username = res.data.username; that.platform.devicePort = res.data.data.devicePort;
that.platform.password = res.data.password; that.platform.username = res.data.data.username;
that.platform.treeType = "BusinessGroup"; that.platform.password = res.data.data.password;
that.platform.administrativeDivision = res.data.username.substr(0, 6); that.platform.treeType = "BusinessGroup";
that.platform.administrativeDivision = res.data.data.username.substr(0, 6);
}
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });
@ -328,7 +331,9 @@ export default {
method: 'post', method: 'post',
url:`/api/platform/exit/${deviceGbId}`}) url:`/api/platform/exit/${deviceGbId}`})
.then(function (res) { .then(function (res) {
result = res.data; if (res.data.code === 0) {
result = res.data.data;
}
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);

View File

@ -112,7 +112,7 @@ export default {
url:`/api/push/save_to_gb`, url:`/api/push/save_to_gb`,
data: this.proxyParam data: this.proxyParam
}).then( (res) => { }).then( (res) => {
if (res.data == "success") { if (res.data.code === 0) {
this.$message({ this.$message({
showClose: true, showClose: true,
message: "保存成功", message: "保存成功",

View File

@ -84,15 +84,16 @@ export default {
method: 'get', 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)=> { }).then((res)=> {
console.log(res) if (res.data.code === 0) {
console.log(res.data.progress) this.streamInfo = res.data.data;
this.streamInfo = res.data; if (parseFloat(res.data.progress) == 1) {
if (parseFloat(res.data.progress) == 1) { this.percentage = 100;
this.percentage = 100; }else {
}else { this.percentage = (res.data.progress*100).toFixed(1);
this.percentage = (res.data.progress*100).toFixed(1); }
if (callback)callback();
} }
if (callback)callback();
}).catch((e) =>{ }).catch((e) =>{
}); });
@ -140,7 +141,7 @@ export default {
endTime: null, endTime: null,
} }
}).then((res) =>{ }).then((res) =>{
if (res.data.code === 0 && res.data.msg === "success") { if (res.data.code === 0 ) {
// //
this.title = "录像文件处理中..." this.title = "录像文件处理中..."
this.taskId = res.data.data; this.taskId = res.data.data;
@ -173,7 +174,7 @@ export default {
} }
}).then((res) => { }).then((res) => {
console.log(res) console.log(res)
if (res.data.code == 0) { if (res.data.code === 0) {
this.percentage = parseFloat(res.data.data.percentage)*100 this.percentage = parseFloat(res.data.data.percentage)*100
if (res.data.data[0].percentage === '1') { if (res.data.data[0].percentage === '1') {
this.getProgressForFileRun = false; this.getProgressForFileRun = false;

View File

@ -137,10 +137,7 @@ export default {
method: 'get', method: 'get',
url: '/api/play/start/' + deviceId + '/' + channelId url: '/api/play/start/' + deviceId + '/' + channelId
}).then(function (res) { }).then(function (res) {
// that.isLoging = false; if (res.data.code === 0 && res.data.data) {
console.log('=====----=====')
console.log(res)
if (res.data.code == 0 && res.data.data) {
itemData.playUrl = res.data.data.httpsFlv itemData.playUrl = res.data.data.httpsFlv
that.setPlayUrl(res.data.data.ws_flv, idxTmp) that.setPlayUrl(res.data.data.ws_flv, idxTmp)
} else { } else {

View File

@ -302,7 +302,6 @@ export default {
}).then(function (res) { }).then(function (res) {
that.isLoging = false; that.isLoging = false;
if (res.data.code === 0) { if (res.data.code === 0) {
that.$refs.devicePlayer.openDialog("media", deviceId, channelId, { that.$refs.devicePlayer.openDialog("media", deviceId, channelId, {
streamInfo: res.data.data, streamInfo: res.data.data,
hasAudio: channel.hasAudio hasAudio: channel.hasAudio

View File

@ -43,10 +43,10 @@ class DeviceService{
getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) { getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) {
this.getDeviceList(currentPage, count, (data) => { this.getDeviceList(currentPage, count, (data) => {
if (data.list) { if (data.code === 0 && data.data.list) {
if (typeof (callback) == "function") callback(data.list) if (typeof (callback) == "function") callback(data.data.list)
deviceList = deviceList.concat(data.list); deviceList = deviceList.concat(data.data.list);
if (deviceList.length < data.total) { if (deviceList.length < data.data.total) {
currentPage ++ currentPage ++
this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
}else { }else {
@ -134,10 +134,6 @@ class DeviceService{
}).catch(errorCallback); }).catch(errorCallback);
} }
getTree(deviceId, id, param3, param4) {
}
getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) { getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) {
let currentPage = 1; let currentPage = 1;
let count = 100; let count = 100;
@ -147,10 +143,10 @@ class DeviceService{
getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) { getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) {
this.getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, (data) => { this.getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, (data) => {
if (data.list) { if (data.code === 0 && data.data.list) {
if (typeof (callback) == "function") callback(data.list) if (typeof (callback) == "function") callback(data.data.list)
catalogList = catalogList.concat(data.list); catalogList = catalogList.concat(data.data.list);
if (catalogList.length < data.total) { if (catalogList.length < data.data.total) {
currentPage ++ currentPage ++
this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback)
}else { }else {