From 676a722241116fd53e9f6063484a966dcabe5b48 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 16 八月 2023 01:56:34 +0800
Subject: [PATCH] 修复心跳异常,支持通道列表,推流列表,拉流代理列表直接查看对应的云端录像,兼容大于INT的ssrc的格式化

---
 src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java |  145 +++++++++++++++++++++++++++++
 src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java                     |   99 +++++++++++++++++++
 src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java                   |   53 ++++++++++
 3 files changed, 297 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java
new file mode 100755
index 0000000..8894191
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java
@@ -0,0 +1,99 @@
+package com.genersoft.iot.vmp.vmanager.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageInfo<T> {
+    //褰撳墠椤�
+    private int pageNum;
+    //姣忛〉鐨勬暟閲�
+    private int pageSize;
+    //褰撳墠椤电殑鏁伴噺
+    private int size;
+    //鎬婚〉鏁�
+    private int pages;
+    //鎬绘暟
+    private int total;
+
+    private List<T> resultData;
+
+    private List<T> list;
+
+    public PageInfo(List<T> resultData) {
+        this.resultData = resultData;
+    }
+
+    public PageInfo() {
+    }
+
+    public void startPage(int page, int count) {
+        if (count <= 0) count = 10;
+        if (page <= 0) page = 1;
+        this.pageNum = page;
+        this.pageSize = count;
+        this.total = resultData.size();
+
+        this.pages = total % count == 0 ? total / count : total / count + 1;
+        int fromIndx = (page - 1) * count;
+        if (fromIndx > this.total - 1) {
+            this.list = new ArrayList<>();
+            this.size = 0;
+            return;
+        }
+
+        int toIndx = page * count;
+        if (toIndx > this.total) {
+            toIndx = this.total;
+        }
+        this.list = this.resultData.subList(fromIndx, toIndx);
+        this.size = this.list.size();
+    }
+
+    public int getPageNum() {
+        return pageNum;
+    }
+
+    public void setPageNum(int pageNum) {
+        this.pageNum = pageNum;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public int getPages() {
+        return pages;
+    }
+
+    public void setPages(int pages) {
+        this.pages = pages;
+    }
+
+    public int getTotal() {
+        return total;
+    }
+
+    public void setTotal(int total) {
+        this.total = total;
+    }
+
+    public List<T> getList() {
+        return list;
+    }
+
+    public void setList(List<T> list) {
+        this.list = list;
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java
new file mode 100755
index 0000000..72d6561
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java
@@ -0,0 +1,53 @@
+package com.genersoft.iot.vmp.vmanager.bean;
+
+public class RecordFile {
+    private String app;
+    private String stream;
+
+    private String fileName;
+
+    private String mediaServerId;
+
+    private String date;
+
+
+    public String getApp() {
+        return app;
+    }
+
+    public void setApp(String app) {
+        this.app = app;
+    }
+
+    public String getStream() {
+        return stream;
+    }
+
+    public void setStream(String stream) {
+        this.stream = stream;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String getMediaServerId() {
+        return mediaServerId;
+    }
+
+    public void setMediaServerId(String mediaServerId) {
+        this.mediaServerId = mediaServerId;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java
new file mode 100755
index 0000000..0f37a7d
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java
@@ -0,0 +1,145 @@
+package com.genersoft.iot.vmp.vmanager.cloudRecord;
+
+import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
+import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager;
+import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
+import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
+import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
+import com.genersoft.iot.vmp.service.IMediaServerService;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
+import com.genersoft.iot.vmp.vmanager.bean.RecordFile;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.commons.lang3.ObjectUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+@SuppressWarnings("rawtypes")
+@Tag(name = "浜戠褰曞儚鎺ュ彛")
+
+@RestController
+@RequestMapping("/api/cloud/record")
+public class CloudRecordController {
+
+    @Autowired
+    private ZLMServerFactory zlmServerFactory;
+
+    @Autowired
+    private SendRtpPortManager sendRtpPortManager;
+
+    private final static Logger logger = LoggerFactory.getLogger(CloudRecordController.class);
+
+    @Autowired
+    private ZlmHttpHookSubscribe hookSubscribe;
+
+    @Autowired
+    private IMediaServerService mediaServerService;
+
+    @Autowired
+    private UserSetting userSetting;
+
+    @Autowired
+    private DynamicTask dynamicTask;
+
+    @Autowired
+    private RedisTemplate<Object, Object> redisTemplate;
+
+    @ResponseBody
+    @GetMapping("/date/list")
+    @Operation(summary = "鏌ヨ瀛樺湪浜戠褰曞儚鐨勬棩鏈�")
+    @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
+    @Parameter(name = "stream", description = "娴両D", required = true)
+    @Parameter(name = "year", description = "骞达紝缃┖鍒欐煡璇㈠綋骞�", required = false)
+    @Parameter(name = "month", description = "鏈堬紝缃┖鍒欐煡璇㈠綋鏈�", required = false)
+    @Parameter(name = "mediaServerId", description = "娴佸獟浣揑D锛岀疆绌哄垯鏌ヨ鍏ㄩ儴", required = false)
+    public List<String> openRtpServer(
+            @RequestParam String app,
+            @RequestParam String stream,
+            @RequestParam(required = false) int year,
+            @RequestParam(required = false) int month,
+            @RequestParam(required = false) String mediaServerId
+
+    ) {
+        logger.info("[浜戠褰曞儚] 鏌ヨ瀛樺湪浜戠褰曞儚鐨勬棩鏈� app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}",
+                app, stream, mediaServerId, year, month);
+        Calendar calendar = Calendar.getInstance();
+        if (ObjectUtils.isEmpty(year)) {
+            year = calendar.get(Calendar.YEAR);
+        }
+        if (ObjectUtils.isEmpty(month)) {
+            month = calendar.get(Calendar.MONTH) + 1;
+        }
+        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()) {
+            return new ArrayList<>();
+        }
+
+        return mediaServerService.getRecordDates(app, stream, year, month, mediaServerItems);
+    }
+
+    @ResponseBody
+    @GetMapping("/list")
+    @Operation(summary = "鍒嗛〉鏌ヨ浜戠褰曞儚")
+    @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
+    @Parameter(name = "stream", description = "娴両D", required = true)
+    @Parameter(name = "page", description = "褰撳墠椤�", required = false)
+    @Parameter(name = "count", description = "姣忛〉鏌ヨ鏁伴噺", required = false)
+    @Parameter(name = "startTime", description = "寮�濮嬫椂闂�(yyyy-MM-dd HH:mm:ss)", required = true)
+    @Parameter(name = "endTime", description = "缁撴潫鏃堕棿(yyyy-MM-dd HH:mm:ss)", required = true)
+    @Parameter(name = "mediaServerId", description = "娴佸獟浣揑D锛岀疆绌哄垯鏌ヨ鍏ㄩ儴娴佸獟浣�", required = false)
+    public PageInfo<RecordFile> openRtpServer(
+            @RequestParam String app,
+            @RequestParam String stream,
+            @RequestParam int page,
+            @RequestParam int count,
+            @RequestParam String startTime,
+            @RequestParam String endTime,
+            @RequestParam(required = false) String mediaServerId
+
+    ) {
+        logger.info("[浜戠褰曞儚] 鏌ヨ app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}",
+                app, stream, mediaServerId, page, count, startTime, endTime);
+
+        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()) {
+            return new PageInfo<>();
+        }
+        List<RecordFile> records = mediaServerService.getRecords(app, stream, startTime, endTime, mediaServerItems);
+        PageInfo<RecordFile> pageInfo = new PageInfo<>(records);
+        pageInfo.startPage(page, count);
+        return pageInfo;
+    }
+
+
+}

--
Gitblit v1.8.0