pull/484/head
krehizi 2022-05-31 10:58:15 +08:00
commit b769512052
28 changed files with 196 additions and 134 deletions

View File

@ -163,6 +163,7 @@ QQ私信一般不回, 精力有限.欢迎大家在群里讨论.觉得项目对
[hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen)
[chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb)
[ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666)
[mk1990](https://github.com/mk1990)
ps: 刚增加了这个名单,肯定遗漏了一些大佬,欢迎大佬联系我添加。 ps: 刚增加了这个名单,肯定遗漏了一些大佬,欢迎大佬联系我添加。

View File

@ -159,9 +159,10 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.73</version> <version>1.2.83</version>
</dependency> </dependency>
<!-- okhttp --> <!-- okhttp -->
<dependency> <dependency>
<groupId>com.squareup.okhttp3</groupId> <groupId>com.squareup.okhttp3</groupId>

View File

@ -11,6 +11,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
/**
* @author lin
*/
@Component @Component
public class LoginSuccessHandler implements AuthenticationSuccessHandler { public class LoginSuccessHandler implements AuthenticationSuccessHandler {

View File

@ -20,6 +20,7 @@ import java.util.List;
/** /**
* Spring Security * Spring Security
* @author lin
*/ */
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
@ -132,15 +133,19 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.anyRequest().authenticated() .anyRequest().authenticated()
// 异常处理(权限拒绝、登录失效等) // 异常处理(权限拒绝、登录失效等)
.and().exceptionHandling() .and().exceptionHandling()
.authenticationEntryPoint(anonymousAuthenticationEntryPoint)//匿名用户访问无权限资源时的异常处理 //匿名用户访问无权限资源时的异常处理
.authenticationEntryPoint(anonymousAuthenticationEntryPoint)
// .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源 // .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源
// 登入 // 登入 允许所有用户
.and().formLogin().permitAll()//允许所有用户 .and().formLogin().permitAll()
.successHandler(loginSuccessHandler)//登录成功处理逻辑 //登录成功处理逻辑
.failureHandler(loginFailureHandler)//登录失败处理逻辑 .successHandler(loginSuccessHandler)
//登录失败处理逻辑
.failureHandler(loginFailureHandler)
// 登出 // 登出
.and().logout().logoutUrl("/api/user/logout").permitAll()//允许所有用户 .and().logout().logoutUrl("/api/user/logout").permitAll()
.logoutSuccessHandler(logoutHandler)//登出成功处理逻辑 //登出成功处理逻辑
.logoutSuccessHandler(logoutHandler)
.deleteCookies("JSESSIONID") .deleteCookies("JSESSIONID")
// 会话管理 // 会话管理
// .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理 // .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理

View File

@ -99,8 +99,8 @@ public class VideoStreamSessionManager {
return dialog; return dialog;
} }
public SIPDialog getDialogByCallId(String deviceId, String channelId, String callID){ public SIPDialog getDialogByCallId(String deviceId, String channelId, String callId){
SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callID, null); SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null);
if (ssrcTransaction == null) { if (ssrcTransaction == null) {
return null; return null;
} }
@ -108,11 +108,17 @@ public class VideoStreamSessionManager {
if (dialogByteArray == null) { if (dialogByteArray == null) {
return null; return null;
} }
SIPDialog dialog = (SIPDialog)SerializeUtils.deSerialize(dialogByteArray); return (SIPDialog)SerializeUtils.deSerialize(dialogByteArray);
return dialog;
} }
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)) {
deviceId ="*";
}
if (StringUtils.isEmpty(channelId)) {
channelId ="*";
}
if (StringUtils.isEmpty(callId)) { if (StringUtils.isEmpty(callId)) {
callId ="*"; callId ="*";
} }
@ -179,7 +185,7 @@ public class VideoStreamSessionManager {
public List<SsrcTransaction> getAllSsrc() { public List<SsrcTransaction> getAllSsrc() {
List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId() + "_" )); List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId()));
List<SsrcTransaction> result= new ArrayList<>(); List<SsrcTransaction> result= new ArrayList<>();
for (int i = 0; i < ssrcTransactionKeys.size(); i++) { for (int i = 0; i < ssrcTransactionKeys.size(); i++) {
String key = (String)ssrcTransactionKeys.get(i); String key = (String)ssrcTransactionKeys.get(i);

View File

@ -708,22 +708,22 @@ public class SIPCommander implements ISIPCommander {
} }
SIPDialog dialog; SIPDialog dialog;
if (callId != null) { if (callId != null) {
dialog = streamSession.getDialogByCallId(deviceId, channelId, callId); dialog = streamSession.getDialogByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), callId);
}else { }else {
if (stream == null) { if (stream == null && ssrcTransaction == null && ssrcTransaction.getStream() == null) {
return; return;
} }
dialog = streamSession.getDialogByStream(deviceId, channelId, stream); dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
} }
if (ssrcTransaction != null) { if (ssrcTransaction != null) {
MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId()); MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
mediaServerService.closeRTPServer(deviceId, channelId, ssrcTransaction.getStream()); mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
streamSession.remove(deviceId, channelId, ssrcTransaction.getStream()); streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
} }
if (dialog == null) { if (dialog == null) {
logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", deviceId, channelId); logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
return; return;
} }
SipStack sipStack = udpSipProvider.getSipStack(); SipStack sipStack = udpSipProvider.getSipStack();

View File

@ -18,6 +18,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
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.redis.RedisUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
@ -188,6 +189,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) { if (device == null) {
responseAck(evt, Response.NOT_FOUND, "device is not found");
return; return;
} }
rootElement = getRootElement(evt, device.getCharset()); rootElement = getRootElement(evt, device.getCharset());
@ -195,7 +197,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
deviceAlarm.setDeviceId(deviceId); deviceAlarm.setDeviceId(deviceId);
deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority")); deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority"));
deviceAlarm.setAlarmMethod(XmlUtil.getText(rootElement, "AlarmMethod")); deviceAlarm.setAlarmMethod(XmlUtil.getText(rootElement, "AlarmMethod"));
deviceAlarm.setAlarmTime(XmlUtil.getText(rootElement, "AlarmTime")); String alarmTime = XmlUtil.getText(rootElement, "AlarmTime");
if (alarmTime == null) {
responseAck(evt, Response.BAD_REQUEST, "AlarmTime cannot be null");
return;
}
deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime));
if (XmlUtil.getText(rootElement, "AlarmDescription") == null) { if (XmlUtil.getText(rootElement, "AlarmDescription") == null) {
deviceAlarm.setAlarmDescription(""); deviceAlarm.setAlarmDescription("");
} else { } else {

View File

@ -1,17 +1,13 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
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.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.RequestEventExt; import gov.nist.javax.sip.RequestEventExt;
import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.AddressImpl;
@ -50,15 +46,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private IVideoManagerStorage storager;
@Autowired
private EventPublisher publisher;
@Autowired @Autowired
private SIPProcessorObserver sipProcessorObserver; private SIPProcessorObserver sipProcessorObserver;
@ -86,7 +73,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME);
Response response = null; Response response = null;
boolean passwordCorrect = false; boolean passwordCorrect = false;
// 注册标志 0未携带授权头或者密码错误 1注册成功 2注销成功 // 注册标志
boolean registerFlag = false; boolean registerFlag = false;
FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
AddressImpl address = (AddressImpl) fromHeader.getAddress(); AddressImpl address = (AddressImpl) fromHeader.getAddress();
@ -105,7 +92,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
// 校验密码是否正确 // 校验密码是否正确
passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) || passwordCorrect = StringUtils.isEmpty(sipConfig.getPassword()) ||
new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword()); new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, sipConfig.getPassword());
// 未携带授权头或者密码错误 回复401
if (!passwordCorrect) { if (!passwordCorrect) {
// 注册失败 // 注册失败

View File

@ -72,7 +72,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
// 先从会话内查找 // 先从会话内查找
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, null, callIdHeader.getCallId()); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题 if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题
deviceId = ssrcTransaction.getDeviceId(); deviceId = ssrcTransaction.getDeviceId();
} }

View File

@ -11,10 +11,12 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.service.IDeviceAlarmService; import com.genersoft.iot.vmp.service.IDeviceAlarmService;
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 okhttp3.*; import okhttp3.*;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.dom4j.Element; import org.dom4j.Element;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -94,7 +96,11 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
deviceAlarm.setChannelId(channelId); deviceAlarm.setChannelId(channelId);
deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority"));
deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod"));
deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); String alarmTime = XmlUtil.getText(rootElement, "AlarmTime");
if (alarmTime == null) {
return;
}
deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime));
String alarmDescription = getText(rootElement, "AlarmDescription"); String alarmDescription = getText(rootElement, "AlarmDescription");
if (alarmDescription == null) { if (alarmDescription == null) {
deviceAlarm.setAlarmDescription(""); deviceAlarm.setAlarmDescription("");
@ -187,7 +193,11 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
deviceAlarm.setChannelId(channelId); deviceAlarm.setChannelId(channelId);
deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority"));
deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod"));
deviceAlarm.setAlarmTime(getText(rootElement, "AlarmTime")); String alarmTime = XmlUtil.getText(rootElement, "AlarmTime");
if (alarmTime == null) {
return;
}
deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime));
String alarmDescription = getText(rootElement, "AlarmDescription"); String alarmDescription = getText(rootElement, "AlarmDescription");
if (alarmDescription == null) { if (alarmDescription == null) {
deviceAlarm.setAlarmDescription(""); deviceAlarm.setAlarmDescription("");

View File

@ -64,16 +64,14 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
} }
device.setKeepaliveTime(DateUtil.getNow()); device.setKeepaliveTime(DateUtil.getNow());
// 回复200 OK
responseAck(evt, Response.OK);
if (device.getOnline() == 1) { if (device.getOnline() == 1) {
// 回复200 OK
responseAck(evt, Response.OK);
deviceService.updateDevice(device); deviceService.updateDevice(device);
}else { }else {
// 对于已经离线的设备判断他的注册是否已经过期 // 对于已经离线的设备判断他的注册是否已经过期
if (!deviceService.expire(device)){ if (!deviceService.expire(device)){
deviceService.online(device); deviceService.online(device);
// 回复200 OK
responseAck(evt, Response.OK);
} }
} }
} catch (SipException e) { } catch (SipException e) {

View File

@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
@ -39,6 +41,9 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired
private VideoStreamSessionManager sessionManager;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
notifyMessageHandler.addHandler(cmdType, this); notifyMessageHandler.addHandler(cmdType, this);
@ -61,13 +66,19 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
String NotifyType =getText(rootElement, "NotifyType"); String NotifyType =getText(rootElement, "NotifyType");
if (NotifyType.equals("121")){ if (NotifyType.equals("121")){
logger.info("[录像流]推送完毕,收到关流通知"); logger.info("[录像流]推送完毕,收到关流通知");
String channelId =getText(rootElement, "DeviceID");
// 查询是设备 // 查询是设备
StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); StreamInfo streamInfo = redisCatchStorage.queryDownload(null, null, null, callIdHeader.getCallId());
// 设置进度100% if (streamInfo != null) {
streamInfo.setProgress(1); // 设置进度100%
redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId()); streamInfo.setProgress(1);
cmder.streamByeCmd(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId());
}
// 先从会话内查找
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题
cmder.streamByeCmd(device.getDeviceId(), ssrcTransaction.getChannelId(), null, callIdHeader.getCallId());
}
// TODO 如果级联播放,需要给上级发送此通知 // TODO 如果级联播放,需要给上级发送此通知
} }

View File

@ -70,15 +70,20 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
rootElement = getRootElement(evt, device.getCharset()); rootElement = getRootElement(evt, device.getCharset());
String sn = getText(rootElement, "SN"); String sn = getText(rootElement, "SN");
RecordInfo recordInfo = new RecordInfo();
recordInfo.setDeviceId(device.getDeviceId());
recordInfo.setSn(sn);
recordInfo.setName(getText(rootElement, "Name"));
String sumNumStr = getText(rootElement, "SumNum"); String sumNumStr = getText(rootElement, "SumNum");
int sumNum = 0; int sumNum = 0;
if (!StringUtils.isEmpty(sumNumStr)) { if (!StringUtils.isEmpty(sumNumStr)) {
sumNum = Integer.parseInt(sumNumStr); sumNum = Integer.parseInt(sumNumStr);
} }
recordInfo.setSumNum(sumNum);
Element recordListElement = rootElement.element("RecordList"); Element recordListElement = rootElement.element("RecordList");
if (recordListElement == null || sumNum == 0) { if (recordListElement == null || sumNum == 0) {
logger.info("无录像数据"); logger.info("无录像数据");
eventPublisher.recordEndEventPush(recordInfo);
recordDataCatch.put(device.getDeviceId(), sn, sumNum, new ArrayList<>()); recordDataCatch.put(device.getDeviceId(), sn, sumNum, new ArrayList<>());
releaseRequest(device.getDeviceId(), sn); releaseRequest(device.getDeviceId(), sn);
} else { } else {
@ -112,6 +117,9 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent
record.setRecorderId(getText(itemRecord, "RecorderID")); record.setRecorderId(getText(itemRecord, "RecorderID"));
recordList.add(record); recordList.add(record);
} }
recordInfo.setRecordList(recordList);
// 发送消息,如果是上级查询此录像,则会通过这里通知给上级
eventPublisher.recordEndEventPush(recordInfo);
int count = recordDataCatch.put(device.getDeviceId(), sn, sumNum, recordList); int count = recordDataCatch.put(device.getDeviceId(), sn, sumNum, recordList);
logger.info("[国标录像] {}->{}: {}/{}", device.getDeviceId(), sn, count, sumNum); logger.info("[国标录像] {}->{}: {}/{}", device.getDeviceId(), sn, count, sumNum);
} }

View File

@ -11,7 +11,6 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.media.zlm.dto.*; import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.service.*; import com.genersoft.iot.vmp.service.*;

View File

@ -42,7 +42,7 @@ public class ZLMStatusEventListener {
logger.info("[ZLM] 上线 ID" + event.getMediaServerId()); logger.info("[ZLM] 上线 ID" + event.getMediaServerId());
streamPushService.zlmServerOnline(event.getMediaServerId()); streamPushService.zlmServerOnline(event.getMediaServerId());
streamProxyService.zlmServerOnline(event.getMediaServerId()); streamProxyService.zlmServerOnline(event.getMediaServerId());
playService.zlmServerOnline(event.getMediaServerId());
} }
@Async @Async

View File

@ -40,4 +40,6 @@ public interface IPlayService {
DeferredResult<ResponseEntity<String>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,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);
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);
void zlmServerOnline(String mediaServerId);
} }

View File

@ -73,7 +73,6 @@ public class DeviceServiceImpl implements IDeviceService {
if (deviceInRedis != null && deviceInDb == null) { if (deviceInRedis != null && deviceInDb == null) {
// redis 存在脏数据 // redis 存在脏数据
redisCatchStorage.clearCatchByDeviceId(device.getDeviceId()); redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
} }
device.setUpdateTime(now); device.setUpdateTime(now);
device.setOnline(1); device.setOnline(1);
@ -82,13 +81,15 @@ public class DeviceServiceImpl implements IDeviceService {
if (device.getCreateTime() == null) { if (device.getCreateTime() == null) {
device.setCreateTime(now); device.setCreateTime(now);
logger.info("[设备上线,首次注册]: {},查询设备信息以及通道信息", device.getDeviceId()); logger.info("[设备上线,首次注册]: {},查询设备信息以及通道信息", device.getDeviceId());
deviceMapper.add(device);
redisCatchStorage.updateDevice(device);
commander.deviceInfoQuery(device); commander.deviceInfoQuery(device);
sync(device); sync(device);
deviceMapper.add(device);
}else { }else {
deviceMapper.update(device); deviceMapper.update(device);
redisCatchStorage.updateDevice(device);
} }
redisCatchStorage.updateDevice(device);
// 上线添加订阅 // 上线添加订阅
if (device.getSubscribeCycleForCatalog() > 0) { if (device.getSubscribeCycleForCatalog() > 0) {
// 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅

View File

@ -6,6 +6,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.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.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
@ -35,7 +36,9 @@ import org.springframework.util.StringUtils;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *
@ -189,6 +192,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
public void clearRTPServer(MediaServerItem mediaServerItem) { public void clearRTPServer(MediaServerItem mediaServerItem) {
mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain())); mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain()));
redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0); redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0);
} }
@ -229,11 +233,10 @@ public class MediaServerServiceImpl implements IMediaServerService {
} }
result.sort((serverItem1, serverItem2)->{ result.sort((serverItem1, serverItem2)->{
int sortResult = 0; int sortResult = 0;
try { LocalDateTime localDateTime1 = LocalDateTime.parse(serverItem1.getCreateTime(), DateUtil.formatter);
sortResult = DateUtil.format.parse(serverItem1.getCreateTime()).compareTo(DateUtil.format.parse(serverItem2.getCreateTime())); LocalDateTime localDateTime2 = LocalDateTime.parse(serverItem2.getCreateTime(), DateUtil.formatter);
} catch (ParseException e) {
e.printStackTrace(); sortResult = localDateTime1.compareTo(localDateTime2);
}
return sortResult; return sortResult;
}); });
return result; return result;

View File

@ -19,17 +19,16 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; 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.service.IMediaService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
import com.genersoft.iot.vmp.service.bean.PlayBackCallback; import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
import com.genersoft.iot.vmp.service.bean.PlayBackResult; 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.redis.RedisUtil;
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.IPlayService;
import gov.nist.javax.sip.stack.SIPDialog; import gov.nist.javax.sip.stack.SIPDialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -43,6 +42,7 @@ import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.ResponseEvent; import javax.sip.ResponseEvent;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
@SuppressWarnings(value = {"rawtypes", "unchecked"}) @SuppressWarnings(value = {"rawtypes", "unchecked"})
@ -63,9 +63,6 @@ public class PlayServiceImpl implements IPlayService {
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired
private RedisUtil redis;
@Autowired @Autowired
private DeferredResultHolder resultHolder; private DeferredResultHolder resultHolder;
@ -591,7 +588,7 @@ public class PlayServiceImpl implements IPlayService {
BigDecimal currentCount = new BigDecimal(duration/1000); BigDecimal currentCount = new BigDecimal(duration/1000);
BigDecimal totalCount = new BigDecimal(end-start); BigDecimal totalCount = new BigDecimal(end-start);
BigDecimal divide = currentCount.divide(totalCount,2, BigDecimal.ROUND_HALF_UP); BigDecimal divide = currentCount.divide(totalCount,2, RoundingMode.HALF_UP);
double process = divide.doubleValue(); double process = divide.doubleValue();
streamInfo.setProgress(process); streamInfo.setProgress(process);
} }
@ -651,4 +648,9 @@ public class PlayServiceImpl implements IPlayService {
} }
} }
} }
@Override
public void zlmServerOnline(String mediaServerId) {
// 似乎没啥需要做的
}
} }

View File

@ -315,6 +315,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
List<DeviceChannel> all; List<DeviceChannel> all;
if (catalogUnderDevice != null && catalogUnderDevice) { if (catalogUnderDevice != null && catalogUnderDevice) {
all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online); all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online);
// 海康设备的parentId是SIP id
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online);
all.addAll(deviceChannels);
}else { }else {
all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online); all = deviceChannelMapper.queryChannels(deviceId, null, query, hasSubChannel, online);
} }

View File

@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.utils; package com.genersoft.iot.vmp.utils;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -18,35 +17,61 @@ import java.util.Locale;
*/ */
public class DateUtil { public class DateUtil {
private static final String yyyy_MM_dd_T_HH_mm_ss_SSSXXX = "yyyy-MM-dd'T'HH:mm:ss"; /**
public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss"; * iso8601
*/
private static final String ISO8601_COMPATIBLE_PATTERN = "yyyy-M-d'T'H:m:s";
public static final SimpleDateFormat formatISO8601 = new SimpleDateFormat(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()); /**
public static final SimpleDateFormat format = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()); * iso8601
*/
private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(yyyy_MM_dd_T_HH_mm_ss_SSSXXX, Locale.getDefault()).withZone(ZoneId.systemDefault()); /**
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(yyyy_MM_dd_HH_mm_ss, Locale.getDefault()).withZone(ZoneId.systemDefault()); * wvp
*/
public static final String PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.systemDefault());
public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) { public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) {
return formatterISO8601.format(formatter.parse(formatTime)); return formatterISO8601.format(formatter.parse(formatTime));
} }
public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) { public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) {
return formatter.format(formatterISO8601.parse(formatTime)); return formatter.format(formatterCompatibleISO8601.parse(formatTime));
} }
/**
* yyyy_MM_dd_HH_mm_ss
* @param formatTime
* @return
*/
public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) { public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) {
TemporalAccessor temporalAccessor = formatter.parse(formatTime); TemporalAccessor temporalAccessor = formatter.parse(formatTime);
Instant instant = Instant.from(temporalAccessor); Instant instant = Instant.from(temporalAccessor);
return instant.getEpochSecond(); return instant.getEpochSecond();
} }
/**
*
* @return
*/
public static String getNow() { public static String getNow() {
LocalDateTime nowDateTime = LocalDateTime.now(); LocalDateTime nowDateTime = LocalDateTime.now();
return formatter.format(nowDateTime); return formatter.format(nowDateTime);
} }
/**
*
* @param timeStr
* @param dateTimeFormatter
* @return
*/
public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) { public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) {
try { try {
LocalDate.parse(timeStr, dateTimeFormatter); LocalDate.parse(timeStr, dateTimeFormatter);

View File

@ -24,6 +24,7 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -68,8 +69,8 @@ public class AlarmController {
@ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="alarmMethod", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="alarmType", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="alarmType", value = "查询内容" ,dataTypeClass = String.class),
@ApiImplicitParam(name="startTime", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="startTime", value = "开始时间" ,dataTypeClass = String.class),
@ApiImplicitParam(name="endTime", value = "查询内容" ,dataTypeClass = String.class), @ApiImplicitParam(name="endTime", value = "结束时间" ,dataTypeClass = String.class),
}) })
public ResponseEntity<PageInfo<DeviceAlarm>> getAll( public ResponseEntity<PageInfo<DeviceAlarm>> getAll(
@RequestParam int page, @RequestParam int page,
@ -98,14 +99,7 @@ public class AlarmController {
} }
try { if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
if (startTime != null) {
DateUtil.format.parse(startTime);
}
if (endTime != null) {
DateUtil.format.parse(endTime);
}
} catch (ParseException e) {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
} }
@ -144,11 +138,7 @@ public class AlarmController {
if (StringUtils.isEmpty(time)) { if (StringUtils.isEmpty(time)) {
time = null; time = null;
} }
try { if (!DateUtil.verification(time, DateUtil.formatter) ){
if (time != null) {
DateUtil.format.parse(time);
}
} catch (ParseException e) {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
} }
List<String> deviceIdList = null; List<String> deviceIdList = null;
@ -189,7 +179,7 @@ public class AlarmController {
deviceAlarm.setAlarmDescription("test"); deviceAlarm.setAlarmDescription("test");
deviceAlarm.setAlarmMethod("1"); deviceAlarm.setAlarmMethod("1");
deviceAlarm.setAlarmPriority("1"); deviceAlarm.setAlarmPriority("1");
deviceAlarm.setAlarmTime(DateUtil.formatISO8601.format(System.currentTimeMillis())); deviceAlarm.setAlarmTime(DateUtil.formatterISO8601.format(LocalDateTime.now()));
deviceAlarm.setAlarmType("1"); deviceAlarm.setAlarmType("1");
deviceAlarm.setLongitude(115.33333); deviceAlarm.setLongitude(115.33333);
deviceAlarm.setLatitude(39.33333); deviceAlarm.setLatitude(39.33333);

View File

@ -72,7 +72,7 @@ public class GBRecordController {
if (!DateUtil.verification(startTime, DateUtil.formatter)){ if (!DateUtil.verification(startTime, DateUtil.formatter)){
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(-1); wvpResult.setCode(-1);
wvpResult.setMsg("startTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); wvpResult.setMsg("startTime error, format is " + DateUtil.PATTERN);
ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
result.setResult(resultResponseEntity); result.setResult(resultResponseEntity);
@ -81,7 +81,7 @@ public class GBRecordController {
if (!DateUtil.verification(endTime, DateUtil.formatter)){ if (!DateUtil.verification(endTime, DateUtil.formatter)){
WVPResult<RecordInfo> wvpResult = new WVPResult<>(); WVPResult<RecordInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(-1); wvpResult.setCode(-1);
wvpResult.setMsg("endTime error, format is " + DateUtil.yyyy_MM_dd_HH_mm_ss); wvpResult.setMsg("endTime error, format is " + DateUtil.PATTERN);
ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK); ResponseEntity<WVPResult<RecordInfo>> resultResponseEntity = new ResponseEntity<>(wvpResult, HttpStatus.OK);
result.setResult(resultResponseEntity); result.setResult(resultResponseEntity);
return result; return result;

View File

@ -76,14 +76,7 @@ public class LogController {
logger.warn("自动记录日志功能已关闭,查询结果可能不完整。"); logger.warn("自动记录日志功能已关闭,查询结果可能不完整。");
} }
try { if (!DateUtil.verification(startTime, DateUtil.formatter) || !DateUtil.verification(endTime, DateUtil.formatter)){
if (startTime != null) {
DateUtil.format.parse(startTime);
}
if (endTime != null) {
DateUtil.format.parse(endTime);
}
} catch (ParseException e) {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
} }

View File

@ -8,6 +8,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.TemporalAccessor;
import java.util.Date; import java.util.Date;
@ -64,8 +68,8 @@ class DeviceAlarmServiceImplTest {
* * 7;12 - * * 7;12 -
*/ */
deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + ""); deviceAlarm.setAlarmMethod((int)(Math.random()*7 + 1) + "");
Date date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00"); Instant date = randomDate("2021-01-01 00:00:00", "2021-06-01 00:00:00");
deviceAlarm.setAlarmTime(DateUtil.format.format(date)); deviceAlarm.setAlarmTime(DateUtil.formatter.format(date));
/** /**
* , 1, 2, 3, 4 - * , 1, 2, 3, 4 -
*/ */
@ -85,17 +89,20 @@ class DeviceAlarmServiceImplTest {
private Date randomDate(String beginDate, String endDate) { private Instant randomDate(String beginDate, String endDate) {
try { try {
Date start = DateUtil.format.parse(beginDate);//构造开始日期 //构造开始日期
Date end = DateUtil.format.parse(endDate);//构造结束日期 LocalDateTime start = LocalDateTime.parse(beginDate, DateUtil.formatter);
//构造结束日期
LocalDateTime end = LocalDateTime.parse(endDate, DateUtil.formatter);
//getTime()表示返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。 //getTime()表示返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。
if (start.getTime() >= end.getTime()) { if (start.isAfter(end)) {
return null; return null;
} }
long date = random(start.getTime(), end.getTime()); long date = random(start.toInstant(ZoneOffset.of("+8")).toEpochMilli(), end.toInstant(ZoneOffset.of("+8")).toEpochMilli());
return new Date(date); return Instant.ofEpochMilli(date);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -52,7 +52,7 @@
"postcss-url": "^7.2.1", "postcss-url": "^7.2.1",
"rimraf": "^2.6.0", "rimraf": "^2.6.0",
"semver": "^5.3.0", "semver": "^5.3.0",
"shelljs": "^0.7.6", "shelljs": "^0.8.5",
"uglifyjs-webpack-plugin": "^1.1.1", "uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8", "url-loader": "^0.5.8",
"vue-loader": "^13.3.0", "vue-loader": "^13.3.0",

View File

@ -605,12 +605,12 @@ 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) {
var streamInfo = res.data; that.streamInfo = res.data;
that.app = streamInfo.app; that.app = that.streamInfo.app;
that.streamId = streamInfo.stream; that.streamId = that.streamInfo.stream;
that.mediaServerId = streamInfo.mediaServerId; that.mediaServerId = that.streamInfo.mediaServerId;
that.ssrc = streamInfo.ssrc; that.ssrc = that.streamInfo.ssrc;
that.videoUrl = that.getUrlByStreamInfo(streamInfo); that.videoUrl = that.getUrlByStreamInfo();
that.recordPlay = true; that.recordPlay = true;
}); });
} }

View File

@ -21,47 +21,47 @@ class DeviceService{
if (typeof (errorCallback) == "function") errorCallback(error) if (typeof (errorCallback) == "function") errorCallback(error)
}); });
} }
getAllDeviceList(callback, errorCallback) { getAllDeviceList(callback,endCallback, errorCallback) {
let currentPage = 1; let currentPage = 1;
let count = 100; let count = 100;
let deviceList = [] let deviceList = []
this.getAllDeviceListIteration(deviceList, currentPage, count, (data) => { this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
if (typeof (callback) == "function") callback(data)
}, errorCallback)
} }
getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) { getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) {
this.getDeviceList(currentPage, count, (data) => { this.getDeviceList(currentPage, count, (data) => {
if (data.list) { if (data.list) {
if (typeof (callback) == "function") callback(data.list)
deviceList = deviceList.concat(data.list); deviceList = deviceList.concat(data.list);
if (deviceList.length < data.total) { if (deviceList.length < data.total) {
currentPage ++ currentPage ++
this.getAllDeviceListIteration(deviceList, currentPage, count, callback, errorCallback) this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
}else { }else {
if (typeof (callback) == "function") callback(deviceList) if (typeof (endCallback) == "function") endCallback(deviceList)
} }
} }
}, errorCallback) }, errorCallback)
} }
getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, errorCallback) { getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) {
let currentPage = 1; let currentPage = 1;
let count = 100; let count = 100;
let catalogList = [] let catalogList = []
this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback)
} }
getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) { getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => { this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => {
if (data.list) { if (data.list) {
if (typeof (callback) == "function") callback(data.list)
catalogList = catalogList.concat(data.list); catalogList = catalogList.concat(data.list);
if (catalogList.length < data.total) { if (catalogList.length < data.total) {
currentPage ++ currentPage ++
this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback) this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback)
}else { }else {
console.log(1) console.log(1)
if (typeof (callback) == "function") callback(catalogList) if (typeof (endCallback) == "function") endCallback(catalogList)
} }
} }
}, errorCallback) }, errorCallback)
@ -84,22 +84,23 @@ class DeviceService{
} }
getAllSubChannel(isCatalog, deviceId, channelId, callback, errorCallback) { getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) {
let currentPage = 1; let currentPage = 1;
let count = 100; let count = 100;
let catalogList = [] let catalogList = []
this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
} }
getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, errorCallback) { getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => { this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => {
if (data.list) { if (data.list) {
if (typeof (callback) == "function") callback(data.list)
catalogList = catalogList.concat(data.list); catalogList = catalogList.concat(data.list);
if (catalogList.length < data.total) { if (catalogList.length < data.total) {
currentPage ++ currentPage ++
this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, errorCallback) this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
}else { }else {
if (typeof (callback) == "function") callback(catalogList) if (typeof (endCallback) == "function") endCallback(catalogList)
} }
} }
}, errorCallback) }, errorCallback)