From b86f0aaae2f0212bc01ddfd3e5d646c22eb1d8c0 Mon Sep 17 00:00:00 2001
From: panll <m18010473990@163.com>
Date: 星期五, 08 三月 2024 09:33:38 +0800
Subject: [PATCH] !28 语音对讲合并 语音对讲合并
---
src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java | 174 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 117 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
old mode 100644
new mode 100755
index 3ea207a..8202bf5
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java
@@ -3,27 +3,33 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
+import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.conf.UserSetting;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
+import com.genersoft.iot.vmp.conf.security.JwtUtils;
+import com.genersoft.iot.vmp.conf.security.SecurityUtils;
+import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
+import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler;
-import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
+import com.genersoft.iot.vmp.vmanager.bean.*;
import com.github.pagehelper.PageInfo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.poi.sl.usermodel.Sheet;
+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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;
@@ -35,9 +41,9 @@
import java.util.Map;
import java.util.UUID;
-@Api(tags = "鎺ㄦ祦淇℃伅绠$悊")
+@Tag(name = "鎺ㄦ祦淇℃伅绠$悊")
@Controller
-@CrossOrigin
+
@RequestMapping(value = "/api/push")
public class StreamPushController {
@@ -52,68 +58,79 @@
@Autowired
private DeferredResultHolder resultHolder;
- @ApiOperation("鎺ㄦ祦鍒楄〃鏌ヨ")
- @ApiImplicitParams({
- @ApiImplicitParam(name="page", value = "褰撳墠椤�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name="count", value = "姣忛〉鏌ヨ鏁伴噺", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name="query", value = "鏌ヨ鍐呭", dataTypeClass = String.class),
- @ApiImplicitParam(name="online", value = "鏄惁鍦ㄧ嚎", dataTypeClass = Boolean.class),
- })
+ @Autowired
+ private IMediaService mediaService;
+
+ @Autowired
+ private UserSetting userSetting;
+
@GetMapping(value = "/list")
@ResponseBody
+ @Operation(summary = "鎺ㄦ祦鍒楄〃鏌ヨ", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ @Parameter(name = "page", description = "褰撳墠椤�")
+ @Parameter(name = "count", description = "姣忛〉鏌ヨ鏁伴噺")
+ @Parameter(name = "query", description = "鏌ヨ鍐呭")
+ @Parameter(name = "pushing", description = "鏄惁姝e湪鎺ㄦ祦")
+ @Parameter(name = "mediaServerId", description = "娴佸獟浣揑D")
public PageInfo<StreamPushItem> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count,
@RequestParam(required = false)String query,
- @RequestParam(required = false)Boolean online ){
+ @RequestParam(required = false)Boolean pushing,
+ @RequestParam(required = false)String mediaServerId ){
- PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page, count);
+ if (ObjectUtils.isEmpty(query)) {
+ query = null;
+ }
+ if (ObjectUtils.isEmpty(mediaServerId)) {
+ mediaServerId = null;
+ }
+ PageInfo<StreamPushItem> pushList = streamPushService.getPushList(page, count, query, pushing, mediaServerId);
return pushList;
}
- @ApiOperation("灏嗘帹娴佹坊鍔犲埌鍥芥爣")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "stream", value = "鐩存挱娴佸叧鑱斿浗鏍囧钩鍙�", dataTypeClass = GbStream.class),
- })
@PostMapping(value = "/save_to_gb")
@ResponseBody
- public Object saveToGB(@RequestBody GbStream stream){
- if (streamPushService.saveToGB(stream)){
- return "success";
- }else {
- return "fail";
+ @Operation(summary = "灏嗘帹娴佹坊鍔犲埌鍥芥爣", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ public void saveToGB(@RequestBody GbStream stream){
+ if (!streamPushService.saveToGB(stream)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
- @ApiOperation("灏嗘帹娴佺Щ鍑哄埌鍥芥爣")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "stream", value = "鐩存挱娴佸叧鑱斿浗鏍囧钩鍙�", dataTypeClass = GbStream.class),
- })
@DeleteMapping(value = "/remove_form_gb")
@ResponseBody
- public Object removeFormGB(@RequestBody GbStream stream){
- if (streamPushService.removeFromGB(stream)){
- return "success";
- }else {
- return "fail";
+ @Operation(summary = "灏嗘帹娴佺Щ鍑哄埌鍥芥爣", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ public void removeFormGB(@RequestBody GbStream stream){
+ if (!streamPushService.removeFromGB(stream)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
- @ApiOperation("涓涓�涓帹娴�")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "app", value = "搴旂敤鍚�", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "streamId", value = "娴両D", required = true, dataTypeClass = String.class),
- })
@PostMapping(value = "/stop")
@ResponseBody
- public Object removeFormGB(@RequestParam(required = true)String app, @RequestParam(required = true)String streamId){
- if (streamPushService.stop(app, streamId)){
- return "success";
- }else {
- return "fail";
+ @Operation(summary = "涓涓�涓帹娴�", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
+ @Parameter(name = "stream", description = "娴乮d", required = true)
+ public void stop(String app, String streamId){
+ if (!streamPushService.stop(app, streamId)){
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
+
+ @DeleteMapping(value = "/batchStop")
+ @ResponseBody
+ @Operation(summary = "涓澶氫釜鎺ㄦ祦", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ public void batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){
+ if (batchGBStreamParam.getGbStreams().size() == 0) {
+ throw new ControllerException(ErrorCode.ERROR100);
+ }
+ if (!streamPushService.batchStop(batchGBStreamParam.getGbStreams())){
+ throw new ControllerException(ErrorCode.ERROR100);
+ }
+ }
+
@PostMapping(value = "upload")
@ResponseBody
public DeferredResult<ResponseEntity<WVPResult<Object>>> uploadChannelFile(@RequestParam(value = "file") MultipartFile file){
@@ -139,16 +156,6 @@
result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult));
return result;
}
-// if (!file.getContentType().endsWith(".xls")
-// && !file.getContentType().endsWith(".csv")
-// && !file.getContentType().endsWith(".xlsx") ) {
-// logger.warn("閫氶亾瀵煎叆鏂囦欢绫诲瀷閿欒: {}",file.getContentType() );
-// WVPResult<Object> wvpResult = new WVPResult<>();
-// wvpResult.setCode(-1);
-// wvpResult.setMsg("鏂囦欢绫诲瀷閿欒锛岃浣跨敤");
-// result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult));
-// return result;
-// }
// 鍚屾椂鍙鐞嗕竴涓枃浠�
if (resultHolder.exist(key, null)) {
logger.warn("宸叉湁瀵煎叆浠诲姟姝e湪鎵ц");
@@ -176,7 +183,7 @@
String name = file.getName();
inputStream = file.getInputStream();
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("鏈鐞嗙殑寮傚父 ", e);
}
try {
//浼犲叆鍙傛暟
@@ -218,5 +225,58 @@
return result;
}
+ /**
+ * 鑾峰彇鎺ㄦ祦鎾斁鍦板潃
+ * @param app 搴旂敤鍚�
+ * @param stream 娴乮d
+ * @return
+ */
+ @GetMapping(value = "/getPlayUrl")
+ @ResponseBody
+ @Operation(summary = "鑾峰彇鎺ㄦ祦鎾斁鍦板潃", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ @Parameter(name = "app", description = "搴旂敤鍚�", required = true)
+ @Parameter(name = "stream", description = "娴乮d", required = true)
+ @Parameter(name = "mediaServerId", description = "濯掍綋鏈嶅姟鍣╥d")
+ public StreamContent getPlayUrl(@RequestParam String app, @RequestParam String stream,
+ @RequestParam(required = false) String mediaServerId){
+ boolean authority = false;
+ // 鏄惁鐧婚檰鐢ㄦ埛, 鐧婚檰鐢ㄦ埛杩斿洖瀹屾暣淇℃伅
+ LoginUser userInfo = SecurityUtils.getUserInfo();
+ if (userInfo!= null) {
+ authority = true;
+ }
+ StreamPushItem push = streamPushService.getPush(app, stream);
+ if (push != null && !push.isSelf()) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�");
+ }
+ StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority);
+ if (streamInfo == null){
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鑾峰彇鎾斁鍦板潃澶辫触");
+ }
+ return new StreamContent(streamInfo);
+ }
+ /**
+ * 娣诲姞鎺ㄦ祦淇℃伅
+ * @param stream 鎺ㄦ祦淇℃伅
+ * @return
+ */
+ @PostMapping(value = "/add")
+ @ResponseBody
+ @Operation(summary = "娣诲姞鎺ㄦ祦淇℃伅", security = @SecurityRequirement(name = JwtUtils.HEADER))
+ public void add(@RequestBody StreamPushItem stream){
+ if (ObjectUtils.isEmpty(stream.getGbId())) {
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "鍥芥爣ID涓嶅彲涓虹┖");
+ }
+ if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) {
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "app鎴杝tream涓嶅彲涓虹┖");
+ }
+ stream.setStatus(false);
+ stream.setPushIng(false);
+ stream.setAliveSecond(0L);
+ stream.setTotalReaderCount("0");
+ if (!streamPushService.add(stream)) {
+ throw new ControllerException(ErrorCode.ERROR100);
+ }
+ }
}
--
Gitblit v1.8.0