Merge branch 'master' into 重构/1078
# Conflicts: # pom.xml # src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java # src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java # src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
package com.genersoft.iot.vmp.vmanager;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.InviteSessionType;
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/test")
|
||||
@@ -19,13 +24,42 @@ public class TestController {
|
||||
@Autowired
|
||||
private HookSubscribe subscribe;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
@GetMapping("/hook/list")
|
||||
@Operation(summary = "查询角色", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public List<Hook> all(){
|
||||
return subscribe.getAll();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/redis")
|
||||
public List<InviteInfo> redis(){
|
||||
InviteSessionType type = InviteSessionType.PLAY;
|
||||
String channelId = null;
|
||||
String stream = null;
|
||||
|
||||
String key = VideoManagerConstants.INVITE_PREFIX;
|
||||
String keyPattern = (type != null ? type : "*") +
|
||||
":" + (channelId != null ? channelId : "*") +
|
||||
":" + (stream != null ? stream : "*")
|
||||
+ ":*";
|
||||
ScanOptions options = ScanOptions.scanOptions().match(keyPattern).count(20).build();
|
||||
Cursor<Map.Entry<Object, Object>> cursor = redisTemplate.opsForHash().scan(key, options);
|
||||
List<InviteInfo> result = new ArrayList<>();
|
||||
try {
|
||||
while (cursor.hasNext()) {
|
||||
System.out.println(cursor.next().getKey());
|
||||
result.add((InviteInfo) cursor.next().getValue());
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
||||
}finally {
|
||||
cursor.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public ServletRegistrationBean<StatViewServlet> druidStatViewServlet() {
|
||||
// ServletRegistrationBean<StatViewServlet> registrationBean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*");
|
||||
|
||||
@@ -3,8 +3,9 @@ package com.genersoft.iot.vmp.vmanager.bean;
|
||||
import com.genersoft.iot.vmp.common.VersionPo;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.VersionInfo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SystemConfigInfo {
|
||||
|
||||
private int serverPort;
|
||||
@@ -12,36 +13,5 @@ public class SystemConfigInfo {
|
||||
private UserSetting addOn;
|
||||
private VersionPo version;
|
||||
|
||||
public int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public SipConfig getSip() {
|
||||
return sip;
|
||||
}
|
||||
|
||||
public void setSip(SipConfig sip) {
|
||||
this.sip = sip;
|
||||
}
|
||||
|
||||
public UserSetting getAddOn() {
|
||||
return addOn;
|
||||
}
|
||||
|
||||
public void setAddOn(UserSetting addOn) {
|
||||
this.addOn = addOn;
|
||||
}
|
||||
|
||||
public VersionPo getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(VersionPo version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.genersoft.iot.vmp.vmanager.cloudRecord;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.gb28181.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -55,16 +55,10 @@ public class CloudRecordController {
|
||||
@Parameter(name = "year", description = "年,置空则查询当年", required = false)
|
||||
@Parameter(name = "month", description = "月,置空则查询当月", required = false)
|
||||
@Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部", required = false)
|
||||
public List<String> openRtpServer(
|
||||
@RequestParam(required = true) String app,
|
||||
@RequestParam(required = true) String stream,
|
||||
@RequestParam(required = false) int year,
|
||||
@RequestParam(required = false) int month,
|
||||
@RequestParam(required = false) String mediaServerId
|
||||
public List<String> openRtpServer(@RequestParam(required = true) String app, @RequestParam(required = true) String stream, @RequestParam(required = false) Integer year, @RequestParam(required = false) Integer month, @RequestParam(required = false) String mediaServerId
|
||||
|
||||
) {
|
||||
log.info("[云端录像] 查询存在云端录像的日期 app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}",
|
||||
app, stream, mediaServerId, year, month);
|
||||
log.info("[云端录像] 查询存在云端录像的日期 app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}", app, stream, mediaServerId, year, month);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (ObjectUtils.isEmpty(year)) {
|
||||
year = calendar.get(Calendar.YEAR);
|
||||
@@ -102,20 +96,10 @@ public class CloudRecordController {
|
||||
@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<CloudRecordItem> openRtpServer(
|
||||
@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
|
||||
public PageInfo<CloudRecordItem> openRtpServer(@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
|
||||
|
||||
) {
|
||||
log.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
log.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}", app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||
@@ -162,25 +146,16 @@ public class CloudRecordController {
|
||||
@Parameter(name = "endTime", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "callId", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "remoteHost", description = "返回地址时的远程地址", required = false)
|
||||
public String addTask(
|
||||
HttpServletRequest request,
|
||||
@RequestParam(required = false) String app,
|
||||
@RequestParam(required = false) String stream,
|
||||
@RequestParam(required = false) String mediaServerId,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) String remoteHost
|
||||
){
|
||||
public String addTask(HttpServletRequest request, @RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String callId, @RequestParam(required = false) String remoteHost) {
|
||||
MediaServer mediaServer;
|
||||
if (mediaServerId == null) {
|
||||
mediaServer = mediaServerService.getDefaultMediaServer();
|
||||
}else {
|
||||
} else {
|
||||
mediaServer = mediaServerService.getOne(mediaServerId);
|
||||
}
|
||||
if (mediaServer == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体");
|
||||
}else {
|
||||
} else {
|
||||
if (remoteHost == null) {
|
||||
remoteHost = request.getScheme() + "://" + mediaServer.getIp() + ":" + mediaServer.getRecordAssistPort();
|
||||
}
|
||||
@@ -194,20 +169,12 @@ public class CloudRecordController {
|
||||
@Parameter(name = "taskId", description = "任务Id", required = false)
|
||||
@Parameter(name = "mediaServerId", description = "流媒体ID", required = false)
|
||||
@Parameter(name = "isEnd", description = "是否结束", required = false)
|
||||
public JSONArray queryTaskList(
|
||||
HttpServletRequest request,
|
||||
@RequestParam(required = false) String app,
|
||||
@RequestParam(required = false) String stream,
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) String taskId,
|
||||
@RequestParam(required = false) String mediaServerId,
|
||||
@RequestParam(required = false) Boolean isEnd
|
||||
){
|
||||
if (ObjectUtils.isEmpty(mediaServerId)) {
|
||||
mediaServerId = null;
|
||||
}
|
||||
public JSONArray queryTaskList(HttpServletRequest request, @RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String callId, @RequestParam(required = false) String taskId, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) Boolean isEnd) {
|
||||
if (ObjectUtils.isEmpty(mediaServerId)) {
|
||||
mediaServerId = null;
|
||||
}
|
||||
|
||||
return cloudRecordService.queryTask(app, stream, callId, taskId, mediaServerId, isEnd, request.getScheme());
|
||||
return cloudRecordService.queryTask(app, stream, callId, taskId, mediaServerId, isEnd, request.getScheme());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@@ -220,20 +187,11 @@ public class CloudRecordController {
|
||||
@Parameter(name = "endTime", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "callId", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "recordId", description = "录像记录的ID,用于精准收藏一个视频文件", required = false)
|
||||
public int addCollect(
|
||||
@RequestParam(required = false) String app,
|
||||
@RequestParam(required = false) String stream,
|
||||
@RequestParam(required = false) String mediaServerId,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) Integer recordId
|
||||
){
|
||||
log.info("[云端录像] 添加收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
public int addCollect(@RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String callId, @RequestParam(required = false) Integer recordId) {
|
||||
log.info("[云端录像] 添加收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}", app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
if (recordId != null) {
|
||||
return cloudRecordService.changeCollectById(recordId, true);
|
||||
}else {
|
||||
} else {
|
||||
return cloudRecordService.changeCollect(true, app, stream, mediaServerId, startTime, endTime, callId);
|
||||
}
|
||||
}
|
||||
@@ -248,20 +206,11 @@ public class CloudRecordController {
|
||||
@Parameter(name = "endTime", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "callId", description = "鉴权ID", required = false)
|
||||
@Parameter(name = "recordId", description = "录像记录的ID,用于精准精准移除一个视频文件的收藏", required = false)
|
||||
public int deleteCollect(
|
||||
@RequestParam(required = false) String app,
|
||||
@RequestParam(required = false) String stream,
|
||||
@RequestParam(required = false) String mediaServerId,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime,
|
||||
@RequestParam(required = false) String callId,
|
||||
@RequestParam(required = false) Integer recordId
|
||||
){
|
||||
log.info("[云端录像] 移除收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
public int deleteCollect(@RequestParam(required = false) String app, @RequestParam(required = false) String stream, @RequestParam(required = false) String mediaServerId, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String callId, @RequestParam(required = false) Integer recordId) {
|
||||
log.info("[云端录像] 移除收藏,app={},stream={},mediaServerId={},startTime={},endTime={},callId={},recordId={}", app, stream, mediaServerId, startTime, endTime, callId, recordId);
|
||||
if (recordId != null) {
|
||||
return cloudRecordService.changeCollectById(recordId, false);
|
||||
}else {
|
||||
} else {
|
||||
return cloudRecordService.changeCollect(false, app, stream, mediaServerId, startTime, endTime, callId);
|
||||
}
|
||||
}
|
||||
@@ -270,9 +219,7 @@ public class CloudRecordController {
|
||||
@GetMapping("/play/path")
|
||||
@Operation(summary = "获取播放地址")
|
||||
@Parameter(name = "recordId", description = "录像记录的ID", required = true)
|
||||
public DownloadFileInfo getPlayUrlPath(
|
||||
@RequestParam(required = true) Integer recordId
|
||||
){
|
||||
public DownloadFileInfo getPlayUrlPath(@RequestParam(required = true) Integer recordId) {
|
||||
return cloudRecordService.getPlayUrlPath(recordId);
|
||||
}
|
||||
|
||||
@@ -291,20 +238,10 @@ public class CloudRecordController {
|
||||
*/
|
||||
@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
|
||||
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
|
||||
|
||||
) {
|
||||
log.info("[下载指定录像文件的压缩包] 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId);
|
||||
log.info("[下载指定录像文件的压缩包] 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}", app, stream, mediaServerId, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||
@@ -339,7 +276,7 @@ public class CloudRecordController {
|
||||
callId = null;
|
||||
}
|
||||
if (stream != null && callId != null) {
|
||||
response.addHeader( "Content-Disposition", "attachment;filename=" + stream + "_" + callId + ".zip" );
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + stream + "_" + callId + ".zip");
|
||||
}
|
||||
List<CloudRecordItem> cloudRecordItemList = cloudRecordService.getAllList(query, app, stream, startTime, endTime, mediaServers, callId, ids);
|
||||
if (ObjectUtils.isEmpty(cloudRecordItemList)) {
|
||||
@@ -354,9 +291,9 @@ public class CloudRecordController {
|
||||
continue;
|
||||
}
|
||||
FileInputStream fis = new FileInputStream(cloudRecordItem.getFilePath());
|
||||
byte[] buf = new byte[2*1024];
|
||||
byte[] buf = new byte[2 * 1024];
|
||||
int len;
|
||||
while ((len = fis.read(buf)) != -1){
|
||||
while ((len = fis.read(buf)) != -1) {
|
||||
zos.write(buf, 0, len);
|
||||
}
|
||||
zos.closeEntry();
|
||||
@@ -364,8 +301,7 @@ public class CloudRecordController {
|
||||
}
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
log.error("[下载指定录像文件的压缩包] 失败: 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, startTime, endTime, callId, e);
|
||||
log.error("[下载指定录像文件的压缩包] 失败: 查询 app->{}, stream->{}, mediaServerId->{}, startTime->{}, endTime->{}, callId->{}", app, stream, mediaServerId, startTime, endTime, callId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,22 +328,10 @@ public class CloudRecordController {
|
||||
@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
|
||||
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
|
||||
|
||||
) {
|
||||
log.info("[云端录像] 查询URL app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}",
|
||||
app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
log.info("[云端录像] 查询URL app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}, callId->{}", app, stream, mediaServerId, page, count, startTime, endTime, callId);
|
||||
|
||||
List<MediaServer> mediaServers;
|
||||
if (!ObjectUtils.isEmpty(mediaServerId)) {
|
||||
@@ -446,8 +370,7 @@ public class CloudRecordController {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体节点");
|
||||
}
|
||||
if (remoteHost == null) {
|
||||
remoteHost = request.getScheme() + "://" + request.getLocalAddr() + ":" +
|
||||
(request.getScheme().equals("https")? mediaServer.getHttpSSlPort() : mediaServer.getHttpPort());
|
||||
remoteHost = request.getScheme() + "://" + request.getLocalAddr() + ":" + (request.getScheme().equals("https") ? mediaServer.getHttpSSlPort() : mediaServer.getHttpPort());
|
||||
}
|
||||
PageInfo<CloudRecordItem> cloudRecordItemPageInfo = cloudRecordService.getList(page, count, query, app, stream, startTime, endTime, mediaServers, callId);
|
||||
PageInfo<CloudRecordUrl> cloudRecordUrlPageInfo = new PageInfo<>();
|
||||
@@ -474,8 +397,7 @@ public class CloudRecordController {
|
||||
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.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);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,49 @@
|
||||
package com.genersoft.iot.vmp.vmanager.log;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.core.rolling.RollingFileAppender;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.gb28181.service.ICloudRecordService;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.ILogService;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
|
||||
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
|
||||
import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
|
||||
import com.genersoft.iot.vmp.service.bean.LogFileInfo;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.cloudRecord.bean.CloudRecordUrl;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "日志管理")
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "日志文件查询接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/log")
|
||||
@@ -27,77 +52,48 @@ public class LogController {
|
||||
@Autowired
|
||||
private ILogService logService;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param query 查询内容
|
||||
* @param page 当前页
|
||||
* @param count 每页查询数量
|
||||
* @param type 类型
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
@Operation(summary = "分页查询日志", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "query", description = "查询内容", required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||
@Parameter(name = "type", description = "类型", required = true)
|
||||
@Parameter(name = "startTime", description = "开始时间", required = true)
|
||||
@Parameter(name = "endTime", description = "结束时间", required = true)
|
||||
public PageInfo<LogDto> getAll(
|
||||
@RequestParam int page,
|
||||
@RequestParam int count,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) String type,
|
||||
@RequestParam(required = false) String startTime,
|
||||
@RequestParam(required = false) String endTime
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查询日志文件", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "query", description = "检索内容", 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)
|
||||
public List<LogFileInfo> queryList(@RequestParam(required = false) String query, @RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime
|
||||
|
||||
) {
|
||||
if (ObjectUtils.isEmpty(query)) {
|
||||
query = null;
|
||||
}
|
||||
|
||||
if (!userSetting.getLogInDatabase()) {
|
||||
log.warn("自动记录日志功能已关闭,查询结果可能不完整。");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(startTime)) {
|
||||
startTime = null;
|
||||
}else if (!DateUtil.verification(startTime, DateUtil.formatter) ){
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "startTime格式为" + DateUtil.PATTERN);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(endTime)) {
|
||||
endTime = null;
|
||||
}else if (!DateUtil.verification(endTime, DateUtil.formatter) ){
|
||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "endTime格式为" + DateUtil.PATTERN);
|
||||
}
|
||||
|
||||
return logService.getAll(page, count, query, type, startTime, endTime);
|
||||
return logService.queryList(query, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空日志
|
||||
*
|
||||
* 下载指定日志文件
|
||||
*/
|
||||
@Operation(summary = "清空日志", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@DeleteMapping("/clear")
|
||||
public void clear() {
|
||||
logService.clear();
|
||||
@ResponseBody
|
||||
@GetMapping("/file/{fileName}")
|
||||
public void downloadFile(HttpServletResponse response, @PathVariable String fileName) {
|
||||
try {
|
||||
File file = logService.getFileByName(fileName);
|
||||
if (file == null || !file.exists() || !file.isFile()) {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
}
|
||||
final InputStream in = Files.newInputStream(file.toPath());
|
||||
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
IOUtils.copy(in, response.getOutputStream());
|
||||
in.close();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RedisRpcConfig redisRpcConfig;
|
||||
|
||||
@GetMapping("/test/count")
|
||||
public Object count() {
|
||||
return redisRpcConfig.getCallbackCount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
@@ -28,9 +28,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -48,7 +46,7 @@ public class PsController {
|
||||
private IMediaServerService mediaServerService;
|
||||
|
||||
@Autowired
|
||||
private SendRtpPortManager sendRtpPortManager;
|
||||
private ISendRtpServerService sendRtpServerService;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
@@ -133,7 +131,7 @@ public class PsController {
|
||||
if (isSend != null && isSend) {
|
||||
String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId;
|
||||
// 预创建发流信息
|
||||
int port = sendRtpPortManager.getNextPort(mediaServer);
|
||||
int port = sendRtpServerService.getNextPort(mediaServer);
|
||||
|
||||
otherPsSendInfo.setSendLocalIp(mediaServer.getSdpIp());
|
||||
otherPsSendInfo.setSendLocalPort(port);
|
||||
@@ -249,11 +247,6 @@ public class PsController {
|
||||
if (sendInfo == null){
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未开启发流");
|
||||
}
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("vhost","__defaultVhost__");
|
||||
param.put("app",sendInfo.getPushApp());
|
||||
param.put("stream",sendInfo.getPushStream());
|
||||
param.put("ssrc",sendInfo.getPushSSRC());
|
||||
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
|
||||
boolean result = mediaServerService.stopSendRtp(mediaServerItem, sendInfo.getPushApp(), sendInfo.getStream(), sendInfo.getPushSSRC());
|
||||
if (!result) {
|
||||
@@ -283,6 +276,6 @@ public class PsController {
|
||||
// }).start();
|
||||
// }
|
||||
|
||||
return sendRtpPortManager.getNextPort(defaultMediaServer);
|
||||
return sendRtpServerService.getNextPort(defaultMediaServer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
@@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class RtpController {
|
||||
|
||||
@Autowired
|
||||
private SendRtpPortManager sendRtpPortManager;
|
||||
private ISendRtpServerService sendRtpServerService;
|
||||
|
||||
@Autowired
|
||||
private HookSubscribe hookSubscribe;
|
||||
@@ -130,8 +130,8 @@ public class RtpController {
|
||||
redisTemplate.opsForValue().set(receiveKey, otherRtpSendInfo);
|
||||
if (isSend != null && isSend) {
|
||||
// 预创建发流信息
|
||||
int portForVideo = sendRtpPortManager.getNextPort(mediaServer);
|
||||
int portForAudio = sendRtpPortManager.getNextPort(mediaServer);
|
||||
int portForVideo = sendRtpServerService.getNextPort(mediaServer);
|
||||
int portForAudio = sendRtpServerService.getNextPort(mediaServer);
|
||||
|
||||
otherRtpSendInfo.setSendLocalIp(mediaServer.getSdpIp());
|
||||
otherRtpSendInfo.setSendLocalPortForVideo(portForVideo);
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
@@ -25,13 +25,24 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.NetworkIF;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Tag(name = "服务控制")
|
||||
@@ -75,7 +86,6 @@ public class ServerController {
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
|
||||
|
||||
@GetMapping(value = "/media_server/list")
|
||||
@ResponseBody
|
||||
@Operation(summary = "流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@@ -139,7 +149,11 @@ public class ServerController {
|
||||
@DeleteMapping(value = "/media_server/delete")
|
||||
@ResponseBody
|
||||
public void deleteMediaServer(@RequestParam String id) {
|
||||
mediaServerService.delete(id);
|
||||
MediaServer mediaServer = mediaServerService.getOne(id);
|
||||
if (mediaServer == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "流媒体不存在");
|
||||
}
|
||||
mediaServerService.delete(mediaServer);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,9 +180,11 @@ public class ServerController {
|
||||
// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||
// }
|
||||
// });
|
||||
};
|
||||
}
|
||||
|
||||
@Operation(summary = "获取系统信息信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
;
|
||||
|
||||
@Operation(summary = "获取系统配置信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@GetMapping(value = "/system/configInfo")
|
||||
@ResponseBody
|
||||
public SystemConfigInfo getConfigInfo() {
|
||||
@@ -228,9 +244,9 @@ public class ServerController {
|
||||
public List<MediaServerLoad> getMediaLoad() {
|
||||
List<MediaServerLoad> result = new ArrayList<>();
|
||||
List<MediaServer> allOnline = mediaServerService.getAllOnline();
|
||||
if (allOnline.size() == 0) {
|
||||
if (allOnline.isEmpty()) {
|
||||
return result;
|
||||
}else {
|
||||
} else {
|
||||
for (MediaServer mediaServerItem : allOnline) {
|
||||
result.add(mediaServerService.getLoad(mediaServerItem));
|
||||
}
|
||||
@@ -254,4 +270,80 @@ public class ServerController {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/info")
|
||||
@ResponseBody
|
||||
@Operation(summary = "获取系统信息")
|
||||
public Map<String, Map<String, String>> getInfo() {
|
||||
Map<String, Map<String, String>> result = new LinkedHashMap<>();
|
||||
Map<String, String> hardwareMap = new LinkedHashMap<>();
|
||||
result.put("硬件信息", hardwareMap);
|
||||
|
||||
SystemInfo systemInfo = new SystemInfo();
|
||||
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||
// 获取CPU信息
|
||||
CentralProcessor.ProcessorIdentifier processorIdentifier = hardware.getProcessor().getProcessorIdentifier();
|
||||
hardwareMap.put("CPU", processorIdentifier.getName());
|
||||
// 获取内存
|
||||
GlobalMemory memory = hardware.getMemory();
|
||||
hardwareMap.put("内存", formatByte(memory.getTotal() - memory.getAvailable()) + "/" + formatByte(memory.getTotal()));
|
||||
hardwareMap.put("制造商", systemInfo.getHardware().getComputerSystem().getManufacturer());
|
||||
hardwareMap.put("产品名称", systemInfo.getHardware().getComputerSystem().getModel());
|
||||
// 网卡
|
||||
List<NetworkIF> networkIFs = hardware.getNetworkIFs();
|
||||
StringBuilder ips = new StringBuilder();
|
||||
for (int i = 0; i < networkIFs.size(); i++) {
|
||||
NetworkIF networkIF = networkIFs.get(i);
|
||||
String ipsStr = StringUtils.join(networkIF.getIPv4addr());
|
||||
if (ObjectUtils.isEmpty(ipsStr)) {
|
||||
continue;
|
||||
}
|
||||
ips.append(ipsStr);
|
||||
if (i < networkIFs.size() - 1) {
|
||||
ips.append(",");
|
||||
}
|
||||
}
|
||||
hardwareMap.put("网卡", ips.toString());
|
||||
|
||||
Map<String, String> operatingSystemMap = new LinkedHashMap<>();
|
||||
result.put("操作系统", operatingSystemMap);
|
||||
OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
|
||||
operatingSystemMap.put("名称", operatingSystem.getFamily() + " " + operatingSystem.getVersionInfo().getVersion());
|
||||
operatingSystemMap.put("类型", operatingSystem.getManufacturer());
|
||||
|
||||
Map<String, String> platformMap = new LinkedHashMap<>();
|
||||
result.put("平台信息", platformMap);
|
||||
VersionPo version = versionInfo.getVersion();
|
||||
platformMap.put("版本", version.getVersion());
|
||||
platformMap.put("构建日期", version.getBUILD_DATE());
|
||||
platformMap.put("GIT分支", version.getGIT_BRANCH());
|
||||
platformMap.put("GIT地址", version.getGIT_URL());
|
||||
platformMap.put("GIT日期", version.getGIT_DATE());
|
||||
platformMap.put("GIT版本", version.getGIT_Revision_SHORT());
|
||||
platformMap.put("DOCKER环境", new File("/.dockerenv").exists()?"是":"否");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位转换
|
||||
*/
|
||||
private static String formatByte(long byteNumber) {
|
||||
//换算单位
|
||||
double FORMAT = 1024.0;
|
||||
double kbNumber = byteNumber / FORMAT;
|
||||
if (kbNumber < FORMAT) {
|
||||
return new DecimalFormat("#.##KB").format(kbNumber);
|
||||
}
|
||||
double mbNumber = kbNumber / FORMAT;
|
||||
if (mbNumber < FORMAT) {
|
||||
return new DecimalFormat("#.##MB").format(mbNumber);
|
||||
}
|
||||
double gbNumber = mbNumber / FORMAT;
|
||||
if (gbNumber < FORMAT) {
|
||||
return new DecimalFormat("#.##GB").format(gbNumber);
|
||||
}
|
||||
double tbNumber = gbNumber / FORMAT;
|
||||
return new DecimalFormat("#.##TB").format(tbNumber);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user