From 8b0662ebfeecad2b646689aacb4d7d6a45973eb4 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 10 一月 2023 11:36:54 +0800
Subject: [PATCH] 优化国标录像下载错误提示
---
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 44 ++++++++++++++++-----
web_src/src/components/dialog/recordDownload.vue | 30 +++++++--------
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 28 ++++++++++++-
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java | 6 --
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 2
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java | 5 ++
6 files changed, 79 insertions(+), 36 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
index f8d5869..1233455 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
@@ -1,16 +1,12 @@
package com.genersoft.iot.vmp.service;
-import com.alibaba.fastjson2.JSONObject;
-import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
-import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import java.util.List;
-import java.util.Map;
/**
* 濯掍綋鏈嶅姟鑺傜偣
@@ -41,7 +37,7 @@
*/
void zlmServerOffline(String mediaServerId);
- MediaServerItem getMediaServerForMinimumLoad();
+ MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist);
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
index c04965a..ad59cb6 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
@@ -31,6 +31,11 @@
MediaServerItem getNewMediaServerItem(Device device);
+ /**
+ * 鑾峰彇鍖呭惈assist鏈嶅姟鐨勮妭鐐�
+ */
+ MediaServerItem getNewMediaServerItemHasAssist(Device device);
+
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
void playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
index db4d7b3..64105a6 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
@@ -487,7 +487,7 @@
* @return MediaServerItem
*/
@Override
- public MediaServerItem getMediaServerForMinimumLoad() {
+ public MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist) {
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
if (RedisUtil.zSize(key) == null || RedisUtil.zSize(key) == 0) {
@@ -500,9 +500,31 @@
// 鑾峰彇鍒嗘暟鏈�浣庣殑锛屽強骞跺彂鏈�浣庣殑
Set<Object> objects = RedisUtil.zRange(key, 0, -1);
ArrayList<Object> mediaServerObjectS = new ArrayList<>(objects);
+ MediaServerItem mediaServerItem = null;
+ if (hasAssist == null) {
+ String mediaServerId = (String)mediaServerObjectS.get(0);
+ mediaServerItem = getOne(mediaServerId);
+ }else if (hasAssist) {
+ for (Object mediaServerObject : mediaServerObjectS) {
+ String mediaServerId = (String)mediaServerObject;
+ MediaServerItem serverItem = getOne(mediaServerId);
+ if (serverItem.getRecordAssistPort() > 0) {
+ mediaServerItem = serverItem;
+ break;
+ }
+ }
+ }else if (!hasAssist) {
+ for (Object mediaServerObject : mediaServerObjectS) {
+ String mediaServerId = (String)mediaServerObject;
+ MediaServerItem serverItem = getOne(mediaServerId);
+ if (serverItem.getRecordAssistPort() == 0) {
+ mediaServerItem = serverItem;
+ break;
+ }
+ }
+ }
- String mediaServerId = (String)mediaServerObjectS.get(0);
- return getOne(mediaServerId);
+ return mediaServerItem;
}
/**
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
index 123c8dd..b8e7c8e 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -39,8 +39,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -102,10 +100,6 @@
@Autowired
private ZlmHttpHookSubscribe subscribe;
-
- @Qualifier("taskExecutor")
- @Autowired
- private ThreadPoolTaskExecutor taskExecutor;
@Override
public void play(MediaServerItem mediaServerItem, String deviceId, String channelId,
@@ -412,12 +406,29 @@
}
MediaServerItem mediaServerItem;
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
- mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
+ mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
} else {
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
if (mediaServerItem == null) {
logger.warn("鐐规挱鏃舵湭鎵惧埌鍙娇鐢ㄧ殑ZLM...");
+ }
+ return mediaServerItem;
+ }
+
+ @Override
+ public MediaServerItem getNewMediaServerItemHasAssist(Device device) {
+ if (device == null) {
+ return null;
+ }
+ MediaServerItem mediaServerItem;
+ if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
+ mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(true);
+ } else {
+ mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
+ }
+ if (mediaServerItem == null) {
+ logger.warn("[鑾峰彇鍙敤鐨刏LM鑺傜偣]鏈壘鍒板彲浣跨敤鐨刏LM...");
}
return mediaServerItem;
}
@@ -566,16 +577,24 @@
@Override
- public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
+ public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return;
}
- MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
+ MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device);
+ if (newMediaServerItem == null) {
+ PlayBackResult<StreamInfo> downloadResult = new PlayBackResult<>();
+ downloadResult.setCode(ErrorCode.ERROR100.getCode());
+ downloadResult.setMsg("鏈壘鍒癮ssist鏈嶅姟");
+ playBackCallback.call(downloadResult);
+ return;
+ }
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, device.isSsrcCheck(), true);
- download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, hookCallBack);
+ download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, playBackCallback);
}
+
@Override
public void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
@@ -659,7 +678,10 @@
}
if (mediaServerItem.getRecordAssistPort() > 0) {
JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, streamInfo.getApp(), streamInfo.getStream(), null);
- if (jsonObject != null && jsonObject.getInteger("code") == 0) {
+ if (jsonObject == null) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "杩炴帴Assist鏈嶅姟澶辫触");
+ }
+ if (jsonObject.getInteger("code") == 0) {
long duration = jsonObject.getLong("data");
if (duration == 0) {
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
index a2fd088..ea0fd50 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -96,7 +96,7 @@
public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo;
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
- mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
+ mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null);
}else {
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
}
diff --git a/web_src/src/components/dialog/recordDownload.vue b/web_src/src/components/dialog/recordDownload.vue
index b0b8fea..3e8c427 100644
--- a/web_src/src/components/dialog/recordDownload.vue
+++ b/web_src/src/components/dialog/recordDownload.vue
@@ -6,18 +6,6 @@
<el-progress :percentage="percentage"></el-progress>
</el-col>
<el-col :span="6" >
-<!-- <el-dropdown size="mini" title="鎾斁鍊嶉��" style="margin-left: 1px;" @command="gbScale">-->
-<!-- <el-button-group>-->
-<!-- <el-button size="mini" style="width: 100%">-->
-<!-- {{scale}}鍊嶉�� <i class="el-icon-arrow-down el-icon--right"></i>-->
-<!-- </el-button>-->
-<!-- </el-button-group>-->
-<!-- <el-dropdown-menu slot="dropdown">-->
-<!-- <el-dropdown-item command="1">1鍊嶉��</el-dropdown-item>-->
-<!-- <el-dropdown-item command="2">2鍊嶉��</el-dropdown-item>-->
-<!-- <el-dropdown-item command="4">4鍊嶉��</el-dropdown-item>-->
-<!-- </el-dropdown-menu>-->
-<!-- </el-dropdown>-->
<el-button icon="el-icon-download" v-if="percentage < 100" size="mini" title="鐐瑰嚮涓嬭浇鍙皢浠ョ紦瀛橀儴鍒嗕笅杞藉埌鏈湴" @click="download()">鍋滄缂撳瓨骞朵笅杞�</el-button>
</el-col>
</el-row>
@@ -51,6 +39,7 @@
taskId: null,
getProgressRun: false,
getProgressForFileRun: false,
+ timer: null
};
},
@@ -66,7 +55,7 @@
this.percentage = 0.0;
this.getProgressTimer()
},
- getProgressTimer(){
+ getProgressTimer: function (){
if (!this.getProgressRun) {
return;
}
@@ -93,15 +82,24 @@
this.percentage = (parseFloat(res.data.data.progress)*100).toFixed(1);
}
if (callback)callback();
+ }else {
+ this.$message({
+ showClose: true,
+ message: res.data.msg,
+ type: "error",
+ });
+ this.close();
}
}).catch((e) =>{
-
+ console.log(e)
});
},
close: function (){
- if (this.streamInfo.progress < 100) {
- this.stopDownloadRecord();
+ this.stopDownloadRecord();
+ if (this.timer !== null) {
+ window.clearTimeout(this.timer);
+ this.timer = null;
}
this.showDialog=false;
this.getProgressRun = false;
--
Gitblit v1.8.0