支持下载多个云端录像的zip压缩包
parent
b57dbeac13
commit
186b00e9b3
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<groupId>com.genersoft</groupId>
|
<groupId>com.genersoft</groupId>
|
||||||
<artifactId>wvp-pro</artifactId>
|
<artifactId>wvp-pro</artifactId>
|
||||||
<version>2.7.0</version>
|
<version>2.7.1</version>
|
||||||
<name>web video platform</name>
|
<name>web video platform</name>
|
||||||
<description>国标28181视频平台</description>
|
<description>国标28181视频平台</description>
|
||||||
<packaging>${project.packaging}</packaging>
|
<packaging>${project.packaging}</packaging>
|
||||||
|
|
|
@ -168,6 +168,7 @@ public class SIPRequestHeaderProvider {
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||||
|
// viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||||
|
|
|
@ -18,7 +18,7 @@ public interface ICloudRecordService {
|
||||||
/**
|
/**
|
||||||
* 分页回去云端录像列表
|
* 分页回去云端录像列表
|
||||||
*/
|
*/
|
||||||
PageInfo<CloudRecordItem> getList(int page, int count, String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems);
|
PageInfo<CloudRecordItem> getList(int page, int count, String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems, String callId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据hook消息增加一条记录
|
* 根据hook消息增加一条记录
|
||||||
|
@ -56,4 +56,6 @@ public interface ICloudRecordService {
|
||||||
* 获取播放地址
|
* 获取播放地址
|
||||||
*/
|
*/
|
||||||
DownloadFileInfo getPlayUrlPath(Integer recordId);
|
DownloadFileInfo getPlayUrlPath(Integer recordId);
|
||||||
|
|
||||||
|
List<CloudRecordItem> getAllList(String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems, String callId, List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
private VideoStreamSessionManager streamSession;
|
private VideoStreamSessionManager streamSession;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageInfo<CloudRecordItem> getList(int page, int count, String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems) {
|
public PageInfo<CloudRecordItem> getList(int page, int count, String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems, String callId) {
|
||||||
// 开始时间和结束时间在数据库中都是以秒为单位的
|
// 开始时间和结束时间在数据库中都是以秒为单位的
|
||||||
Long startTimeStamp = null;
|
Long startTimeStamp = null;
|
||||||
Long endTimeStamp = null;
|
Long endTimeStamp = null;
|
||||||
|
@ -71,7 +71,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
}
|
}
|
||||||
PageHelper.startPage(page, count);
|
PageHelper.startPage(page, count);
|
||||||
List<CloudRecordItem> all = cloudRecordServiceMapper.getList(query, app, stream, startTimeStamp, endTimeStamp,
|
List<CloudRecordItem> all = cloudRecordServiceMapper.getList(query, app, stream, startTimeStamp, endTimeStamp,
|
||||||
null, mediaServerItems);
|
callId, mediaServerItems, null);
|
||||||
return new PageInfo<>(all);
|
return new PageInfo<>(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
long startTimeStamp = startDate.atStartOfDay().toInstant(ZoneOffset.ofHours(8)).getEpochSecond();
|
long startTimeStamp = startDate.atStartOfDay().toInstant(ZoneOffset.ofHours(8)).getEpochSecond();
|
||||||
long endTimeStamp = endDate.atStartOfDay().toInstant(ZoneOffset.ofHours(8)).getEpochSecond();
|
long endTimeStamp = endDate.atStartOfDay().toInstant(ZoneOffset.ofHours(8)).getEpochSecond();
|
||||||
List<CloudRecordItem> cloudRecordItemList = cloudRecordServiceMapper.getList(null, app, stream, startTimeStamp,
|
List<CloudRecordItem> cloudRecordItemList = cloudRecordServiceMapper.getList(null, app, stream, startTimeStamp,
|
||||||
endTimeStamp, null, mediaServerItems);
|
endTimeStamp, null, mediaServerItems, null);
|
||||||
if (cloudRecordItemList.isEmpty()) {
|
if (cloudRecordItemList.isEmpty()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CloudRecordItem> all = cloudRecordServiceMapper.getList(null, app, stream, startTimeStamp, endTimeStamp,
|
List<CloudRecordItem> all = cloudRecordServiceMapper.getList(null, app, stream, startTimeStamp, endTimeStamp,
|
||||||
callId, mediaServerItems);
|
callId, mediaServerItems, null);
|
||||||
if (all.isEmpty()) {
|
if (all.isEmpty()) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到待收藏的视频");
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到待收藏的视频");
|
||||||
}
|
}
|
||||||
|
@ -232,4 +232,27 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
MediaServerItem mediaServerItem = mediaServerService.getOne(recordItem.getMediaServerId());
|
MediaServerItem mediaServerItem = mediaServerService.getOne(recordItem.getMediaServerId());
|
||||||
return CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath);
|
return CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CloudRecordItem> getAllList(String query, String app, String stream, String startTime, String endTime, List<MediaServerItem> mediaServerItems, String callId, List<Integer> ids) {
|
||||||
|
// 开始时间和结束时间在数据库中都是以秒为单位的
|
||||||
|
Long startTimeStamp = null;
|
||||||
|
Long endTimeStamp = null;
|
||||||
|
if (startTime != null ) {
|
||||||
|
if (!DateUtil.verification(startTime, DateUtil.formatter)) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "开始时间格式错误,正确格式为: " + DateUtil.formatter);
|
||||||
|
}
|
||||||
|
startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(startTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (endTime != null ) {
|
||||||
|
if (!DateUtil.verification(endTime, DateUtil.formatter)) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "结束时间格式错误,正确格式为: " + DateUtil.formatter);
|
||||||
|
}
|
||||||
|
endTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestampMs(endTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
return cloudRecordServiceMapper.getList(query, app, stream, startTimeStamp, endTimeStamp,
|
||||||
|
callId, mediaServerItems, ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,15 @@ public interface CloudRecordServiceMapper {
|
||||||
" <if test= 'mediaServerItemList != null ' > and media_server_id in " +
|
" <if test= 'mediaServerItemList != null ' > and media_server_id in " +
|
||||||
" <foreach collection='mediaServerItemList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
" <foreach collection='mediaServerItemList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||||
" </if>" +
|
" </if>" +
|
||||||
|
" <if test= 'ids != null ' > and id in " +
|
||||||
|
" <foreach collection='ids' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||||
|
" </if>" +
|
||||||
" order by start_time DESC" +
|
" order by start_time DESC" +
|
||||||
|
|
||||||
" </script>")
|
" </script>")
|
||||||
List<CloudRecordItem> getList(@Param("query") String query, @Param("app") String app, @Param("stream") String stream,
|
List<CloudRecordItem> getList(@Param("query") String query, @Param("app") String app, @Param("stream") String stream,
|
||||||
@Param("startTimeStamp")Long startTimeStamp, @Param("endTimeStamp")Long endTimeStamp,
|
@Param("startTimeStamp")Long startTimeStamp, @Param("endTimeStamp")Long endTimeStamp,
|
||||||
@Param("callId")String callId, List<MediaServerItem> mediaServerItemList);
|
@Param("callId")String callId, List<MediaServerItem> mediaServerItemList,
|
||||||
|
List<Integer> ids);
|
||||||
|
|
||||||
|
|
||||||
@Select(" <script>" +
|
@Select(" <script>" +
|
||||||
|
|
|
@ -106,6 +106,14 @@ public class DateUtil {
|
||||||
return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
|
return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间戳 转 yyyy_MM_dd_HH_mm_ss
|
||||||
|
*/
|
||||||
|
public static String timestampMsToUrlToyyyy_MM_dd_HH_mm_ss(long timestamp) {
|
||||||
|
Instant instant = Instant.ofEpochMilli(timestamp);
|
||||||
|
return urlFormatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* yyyy_MM_dd_HH_mm_ss 转时间戳(毫秒)
|
* yyyy_MM_dd_HH_mm_ss 转时间戳(毫秒)
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,7 +8,9 @@ import com.genersoft.iot.vmp.service.ICloudRecordService;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
||||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||||
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.cloudRecord.bean.CloudRecordUrl;
|
||||||
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;
|
||||||
|
@ -21,9 +23,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Tag(name = "云端录像接口")
|
@Tag(name = "云端录像接口")
|
||||||
|
@ -96,6 +104,7 @@ public class CloudRecordController {
|
||||||
@Parameter(name = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
@Parameter(name = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
||||||
@Parameter(name = "endTime", description = "结束时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
@Parameter(name = "endTime", description = "结束时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
||||||
@Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false)
|
@Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false)
|
||||||
|
@Parameter(name = "callId", description = "每次录像的唯一标识,置空则查询全部流媒体", required = false)
|
||||||
public PageInfo<CloudRecordItem> openRtpServer(
|
public PageInfo<CloudRecordItem> openRtpServer(
|
||||||
@RequestParam(required = false) String query,
|
@RequestParam(required = false) String query,
|
||||||
@RequestParam(required = false) String app,
|
@RequestParam(required = false) String app,
|
||||||
|
@ -104,11 +113,12 @@ public class CloudRecordController {
|
||||||
@RequestParam int count,
|
@RequestParam int count,
|
||||||
@RequestParam(required = false) String startTime,
|
@RequestParam(required = false) String startTime,
|
||||||
@RequestParam(required = false) String endTime,
|
@RequestParam(required = false) String endTime,
|
||||||
@RequestParam(required = false) String mediaServerId
|
@RequestParam(required = false) String mediaServerId,
|
||||||
|
@RequestParam(required = false) String callId
|
||||||
|
|
||||||
) {
|
) {
|
||||||
logger.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}",
|
logger.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||||
app, stream, mediaServerId, page, count, startTime, endTime);
|
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||||
|
|
||||||
List<MediaServerItem> mediaServerItems;
|
List<MediaServerItem> mediaServerItems;
|
||||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||||
|
@ -139,7 +149,10 @@ public class CloudRecordController {
|
||||||
if (endTime != null && ObjectUtils.isEmpty(endTime.trim())) {
|
if (endTime != null && ObjectUtils.isEmpty(endTime.trim())) {
|
||||||
endTime = null;
|
endTime = null;
|
||||||
}
|
}
|
||||||
return cloudRecordService.getList(page, count, query, app, stream, startTime, endTime, mediaServerItems);
|
if (callId != null && ObjectUtils.isEmpty(callId.trim())) {
|
||||||
|
callId = null;
|
||||||
|
}
|
||||||
|
return cloudRecordService.getList(page, count, query, app, stream, startTime, endTime, mediaServerItems, callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -265,4 +278,212 @@ public class CloudRecordController {
|
||||||
){
|
){
|
||||||
return cloudRecordService.getPlayUrlPath(recordId);
|
return cloudRecordService.getPlayUrlPath(recordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************* 以下这些接口只适合wvp和zlm部署在同一台服务器的情况,且wvp只有一个zlm节点的情况 ***************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载指定录像文件的压缩包
|
||||||
|
* @param query 检索内容
|
||||||
|
* @param app 应用名
|
||||||
|
* @param stream 流ID
|
||||||
|
* @param startTime 开始时间(yyyy-MM-dd HH:mm:ss)
|
||||||
|
* @param endTime 结束时间(yyyy-MM-dd HH:mm:ss)
|
||||||
|
* @param mediaServerId 流媒体ID,置空则查询全部流媒体
|
||||||
|
* @param callId 每次录像的唯一标识,置空则查询全部流媒体
|
||||||
|
* @param ids 指定的Id
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/zip")
|
||||||
|
public void downloadZipFile(
|
||||||
|
HttpServletResponse response,
|
||||||
|
@RequestParam(required = false) String query,
|
||||||
|
@RequestParam(required = false) String app,
|
||||||
|
@RequestParam(required = false) String stream,
|
||||||
|
@RequestParam(required = false) String startTime,
|
||||||
|
@RequestParam(required = false) String endTime,
|
||||||
|
@RequestParam(required = false) String mediaServerId,
|
||||||
|
@RequestParam(required = false) String callId,
|
||||||
|
@RequestParam(required = false) List<Integer> ids
|
||||||
|
|
||||||
|
) {
|
||||||
|
logger.info("[下载指定录像文件的压缩包] 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||||
|
app, stream, mediaServerId, startTime, endTime, callId);
|
||||||
|
|
||||||
|
List<MediaServerItem> mediaServerItems;
|
||||||
|
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||||
|
mediaServerItems = new ArrayList<>();
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||||
|
if (mediaServerItem == null) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId);
|
||||||
|
}
|
||||||
|
mediaServerItems.add(mediaServerItem);
|
||||||
|
} else {
|
||||||
|
mediaServerItems = mediaServerService.getAll();
|
||||||
|
}
|
||||||
|
if (mediaServerItems.isEmpty()) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "当前无流媒体");
|
||||||
|
}
|
||||||
|
if (query != null && ObjectUtils.isEmpty(query.trim())) {
|
||||||
|
query = null;
|
||||||
|
}
|
||||||
|
if (app != null && ObjectUtils.isEmpty(app.trim())) {
|
||||||
|
app = null;
|
||||||
|
}
|
||||||
|
if (stream != null && ObjectUtils.isEmpty(stream.trim())) {
|
||||||
|
stream = null;
|
||||||
|
}
|
||||||
|
if (startTime != null && ObjectUtils.isEmpty(startTime.trim())) {
|
||||||
|
startTime = null;
|
||||||
|
}
|
||||||
|
if (endTime != null && ObjectUtils.isEmpty(endTime.trim())) {
|
||||||
|
endTime = null;
|
||||||
|
}
|
||||||
|
if (callId != null && ObjectUtils.isEmpty(callId.trim())) {
|
||||||
|
callId = null;
|
||||||
|
}
|
||||||
|
if (stream != null && callId != null) {
|
||||||
|
response.addHeader( "Content-Disposition", "attachment;filename=" + stream + "_" + callId + ".zip" );
|
||||||
|
}
|
||||||
|
List<CloudRecordItem> cloudRecordItemList = cloudRecordService.getAllList(query, app, stream, startTime, endTime, mediaServerItems, callId, ids);
|
||||||
|
if (ObjectUtils.isEmpty(cloudRecordItemList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
|
||||||
|
for (CloudRecordItem cloudRecordItem : cloudRecordItemList) {
|
||||||
|
zos.putNextEntry(new ZipEntry(DateUtil.timestampMsToUrlToyyyy_MM_dd_HH_mm_ss(cloudRecordItem.getStartTime()) + ".mp4"));
|
||||||
|
File file = new File(cloudRecordItem.getFilePath());
|
||||||
|
if (!file.exists() || file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FileInputStream fis = new FileInputStream(cloudRecordItem.getFilePath());
|
||||||
|
byte[] buf = new byte[2*1024];
|
||||||
|
int len;
|
||||||
|
while ((len = fis.read(buf)) != -1){
|
||||||
|
zos.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
zos.closeEntry();
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
zos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("[下载指定录像文件的压缩包] 失败: 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||||
|
app, stream, mediaServerId, startTime, endTime, callId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param query 检索内容
|
||||||
|
* @param app 应用名
|
||||||
|
* @param stream 流ID
|
||||||
|
* @param startTime 开始时间(yyyy-MM-dd HH:mm:ss)
|
||||||
|
* @param endTime 结束时间(yyyy-MM-dd HH:mm:ss)
|
||||||
|
* @param mediaServerId 流媒体ID,置空则查询全部流媒体
|
||||||
|
* @param callId 每次录像的唯一标识,置空则查询全部流媒体
|
||||||
|
* @param remoteHost 拼接播放地址时使用的远程地址
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/list-url")
|
||||||
|
@Operation(summary = "分页查询云端录像", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "query", description = "检索内容", required = false)
|
||||||
|
@Parameter(name = "app", description = "应用名", required = false)
|
||||||
|
@Parameter(name = "stream", description = "流ID", required = false)
|
||||||
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
|
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||||
|
@Parameter(name = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
||||||
|
@Parameter(name = "endTime", description = "结束时间(yyyy-MM-dd HH:mm:ss)", required = false)
|
||||||
|
@Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false)
|
||||||
|
@Parameter(name = "callId", description = "每次录像的唯一标识,置空则查询全部流媒体", required = false)
|
||||||
|
public PageInfo<CloudRecordUrl> getListWithUrl(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@RequestParam(required = false) String query,
|
||||||
|
@RequestParam(required = false) String app,
|
||||||
|
@RequestParam(required = false) String stream,
|
||||||
|
@RequestParam int page,
|
||||||
|
@RequestParam int count,
|
||||||
|
@RequestParam(required = false) String startTime,
|
||||||
|
@RequestParam(required = false) String endTime,
|
||||||
|
@RequestParam(required = false) String mediaServerId,
|
||||||
|
@RequestParam(required = false) String callId,
|
||||||
|
@RequestParam(required = false) String remoteHost
|
||||||
|
|
||||||
|
) {
|
||||||
|
logger.info("[云端录像] 查询URL app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||||
|
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||||
|
|
||||||
|
List<MediaServerItem> mediaServerItems;
|
||||||
|
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||||
|
mediaServerItems = new ArrayList<>();
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||||
|
if (mediaServerItem == null) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId);
|
||||||
|
}
|
||||||
|
mediaServerItems.add(mediaServerItem);
|
||||||
|
} else {
|
||||||
|
mediaServerItems = mediaServerService.getAll();
|
||||||
|
}
|
||||||
|
if (mediaServerItems.isEmpty()) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "当前无流媒体");
|
||||||
|
}
|
||||||
|
if (query != null && ObjectUtils.isEmpty(query.trim())) {
|
||||||
|
query = null;
|
||||||
|
}
|
||||||
|
if (app != null && ObjectUtils.isEmpty(app.trim())) {
|
||||||
|
app = null;
|
||||||
|
}
|
||||||
|
if (stream != null && ObjectUtils.isEmpty(stream.trim())) {
|
||||||
|
stream = null;
|
||||||
|
}
|
||||||
|
if (startTime != null && ObjectUtils.isEmpty(startTime.trim())) {
|
||||||
|
startTime = null;
|
||||||
|
}
|
||||||
|
if (endTime != null && ObjectUtils.isEmpty(endTime.trim())) {
|
||||||
|
endTime = null;
|
||||||
|
}
|
||||||
|
if (callId != null && ObjectUtils.isEmpty(callId.trim())) {
|
||||||
|
callId = null;
|
||||||
|
}
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||||
|
if (mediaServerItem == null) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体节点");
|
||||||
|
}
|
||||||
|
if (remoteHost == null) {
|
||||||
|
remoteHost = request.getScheme() + "://" + request.getLocalAddr() + ":" +
|
||||||
|
(request.getScheme().equals("https")? mediaServerItem.getHttpSSlPort() : mediaServerItem.getHttpPort());
|
||||||
|
}
|
||||||
|
PageInfo<CloudRecordItem> cloudRecordItemPageInfo = cloudRecordService.getList(page, count, query, app, stream, startTime, endTime, mediaServerItems, callId);
|
||||||
|
PageInfo<CloudRecordUrl> cloudRecordUrlPageInfo = new PageInfo<>();
|
||||||
|
if (!ObjectUtils.isEmpty(cloudRecordItemPageInfo)) {
|
||||||
|
cloudRecordUrlPageInfo.setPageNum(cloudRecordItemPageInfo.getPageNum());
|
||||||
|
cloudRecordUrlPageInfo.setPageSize(cloudRecordItemPageInfo.getPageSize());
|
||||||
|
cloudRecordUrlPageInfo.setSize(cloudRecordItemPageInfo.getSize());
|
||||||
|
cloudRecordUrlPageInfo.setEndRow(cloudRecordItemPageInfo.getEndRow());
|
||||||
|
cloudRecordUrlPageInfo.setStartRow(cloudRecordItemPageInfo.getStartRow());
|
||||||
|
cloudRecordUrlPageInfo.setPages(cloudRecordItemPageInfo.getPages());
|
||||||
|
cloudRecordUrlPageInfo.setPrePage(cloudRecordItemPageInfo.getPrePage());
|
||||||
|
cloudRecordUrlPageInfo.setNextPage(cloudRecordItemPageInfo.getNextPage());
|
||||||
|
cloudRecordUrlPageInfo.setIsFirstPage(cloudRecordItemPageInfo.isIsFirstPage());
|
||||||
|
cloudRecordUrlPageInfo.setIsLastPage(cloudRecordItemPageInfo.isIsLastPage());
|
||||||
|
cloudRecordUrlPageInfo.setHasPreviousPage(cloudRecordItemPageInfo.isHasPreviousPage());
|
||||||
|
cloudRecordUrlPageInfo.setHasNextPage(cloudRecordItemPageInfo.isHasNextPage());
|
||||||
|
cloudRecordUrlPageInfo.setNavigatePages(cloudRecordItemPageInfo.getNavigatePages());
|
||||||
|
cloudRecordUrlPageInfo.setNavigateFirstPage(cloudRecordItemPageInfo.getNavigateFirstPage());
|
||||||
|
cloudRecordUrlPageInfo.setNavigateLastPage(cloudRecordItemPageInfo.getNavigateLastPage());
|
||||||
|
cloudRecordUrlPageInfo.setNavigatepageNums(cloudRecordItemPageInfo.getNavigatepageNums());
|
||||||
|
cloudRecordUrlPageInfo.setTotal(cloudRecordItemPageInfo.getTotal());
|
||||||
|
List<CloudRecordUrl> cloudRecordUrlList = new ArrayList<>(cloudRecordItemPageInfo.getList().size());
|
||||||
|
List<CloudRecordItem> cloudRecordItemList = cloudRecordItemPageInfo.getList();
|
||||||
|
for (CloudRecordItem cloudRecordItem : cloudRecordItemList) {
|
||||||
|
CloudRecordUrl cloudRecordUrl = new CloudRecordUrl();
|
||||||
|
cloudRecordUrl.setId(cloudRecordItem.getId());
|
||||||
|
cloudRecordUrl.setDownloadUrl(remoteHost + "/index/api/downloadFile?file_path=" + cloudRecordItem.getFilePath()
|
||||||
|
+ "&save_name=" + cloudRecordItem.getStream() + "_" + cloudRecordItem.getCallId() + "_" + DateUtil.timestampMsToUrlToyyyy_MM_dd_HH_mm_ss(cloudRecordItem.getStartTime()) );
|
||||||
|
cloudRecordUrl.setPlayUrl(remoteHost + "/index/api/downloadFile?file_path=" + cloudRecordItem.getFilePath());
|
||||||
|
cloudRecordUrlList.add(cloudRecordUrl);
|
||||||
|
}
|
||||||
|
cloudRecordUrlPageInfo.setList(cloudRecordUrlList);
|
||||||
|
}
|
||||||
|
return cloudRecordUrlPageInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.genersoft.iot.vmp.vmanager.cloudRecord.bean;
|
||||||
|
|
||||||
|
public class CloudRecordUrl {
|
||||||
|
|
||||||
|
private String playUrl;
|
||||||
|
private String downloadUrl;
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
public String getPlayUrl() {
|
||||||
|
return playUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayUrl(String playUrl) {
|
||||||
|
this.playUrl = playUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDownloadUrl() {
|
||||||
|
return downloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownloadUrl(String downloadUrl) {
|
||||||
|
this.downloadUrl = downloadUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue