From cb5afce55eec2badda5090c27564e43f201ac9af Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 12 三月 2024 23:55:00 +0800
Subject: [PATCH] 优化语音对讲定时任务的删除
---
src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java | 109 +++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
index 5af3d64..f160aac 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
@@ -2,9 +2,8 @@
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
-import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@@ -13,23 +12,25 @@
import com.genersoft.iot.vmp.service.ICloudRecordService;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
+import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper;
+import com.genersoft.iot.vmp.utils.CloudRecordUtils;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
+import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import org.springframework.util.unit.DataUnit;
import java.time.*;
-import java.time.temporal.TemporalAccessor;
import java.util.*;
@Service
+@DS("share")
public class CloudRecordServiceImpl implements ICloudRecordService {
private final static Logger logger = LoggerFactory.getLogger(CloudRecordServiceImpl.class);
@@ -110,22 +111,13 @@
}
@Override
- public String addTask(String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String remoteHost) {
+ public String addTask(String app, String stream, MediaServerItem mediaServerItem, String startTime, String endTime,
+ String callId, String remoteHost, boolean filterMediaServer) {
// 鍙傛暟鏍¢獙
assert app != null;
assert stream != null;
- MediaServerItem mediaServerItem = null;
- if (mediaServerId == null) {
- mediaServerItem = mediaServerService.getDefaultMediaServer();
- }else {
- mediaServerItem = mediaServerService.getOne(mediaServerId);
- }
- if (mediaServerItem == null) {
- throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒板彲鐢ㄧ殑娴佸獟浣�");
- }else {
- if (remoteHost == null) {
- remoteHost = "http://" + mediaServerItem.getStreamIp() + ":" + mediaServerItem.getRecordAssistPort();
- }
+ if (mediaServerItem.getRecordAssistPort() == 0) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "涓洪厤缃瓵ssist鏈嶅姟");
}
Long startTimeStamp = null;
Long endTimeStamp = null;
@@ -139,7 +131,8 @@
List<MediaServerItem> mediaServers = new ArrayList<>();
mediaServers.add(mediaServerItem);
// 妫�绱㈢浉鍏崇殑褰曞儚鏂囦欢
- List<String> filePathList = cloudRecordServiceMapper.queryRecordFilePathList(app, stream, startTimeStamp, endTimeStamp, callId, mediaServers);
+ List<String> filePathList = cloudRecordServiceMapper.queryRecordFilePathList(app, stream, startTimeStamp,
+ endTimeStamp, callId, filterMediaServer ? mediaServers : null);
if (filePathList == null || filePathList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈绱㈠埌瑙嗛鏂囦欢");
}
@@ -151,7 +144,8 @@
}
@Override
- public JSONArray queryTask(String taskId, String mediaServerId, Boolean isEnd) {
+ public JSONArray queryTask(String app, String stream, String callId, String taskId, String mediaServerId,
+ Boolean isEnd, String scheme) {
MediaServerItem mediaServerItem = null;
if (mediaServerId == null) {
mediaServerItem = mediaServerService.getDefaultMediaServer();
@@ -161,10 +155,81 @@
if (mediaServerItem == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒板彲鐢ㄧ殑娴佸獟浣�");
}
- JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, taskId, isEnd);
- if (result.getInteger("code") != 0) {
- throw new ControllerException(result.getInteger("code"), result.getString("msg"));
+
+ JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd, scheme);
+ if (result == null || result.getInteger("code") != 0) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), result == null ? "鏌ヨ浠诲姟鍒楄〃澶辫触" : result.getString("msg"));
}
return result.getJSONArray("data");
}
+
+ @Override
+ public int changeCollect(boolean result, String app, String stream, String mediaServerId, String startTime, String endTime, String callId) {
+ // 寮�濮嬫椂闂村拰缁撴潫鏃堕棿鍦ㄦ暟鎹簱涓兘鏄互绉掍负鍗曚綅鐨�
+ Long startTimeStamp = null;
+ Long endTimeStamp = null;
+ if (startTime != null ) {
+ if (!DateUtil.verification(startTime, DateUtil.formatter)) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "寮�濮嬫椂闂存牸寮忛敊璇紝姝g‘鏍煎紡涓猴細 " + DateUtil.formatter);
+ }
+ startTimeStamp = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(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_ssToTimestamp(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 = null;
+ }
+
+ List<CloudRecordItem> all = cloudRecordServiceMapper.getList(null, app, stream, startTimeStamp, endTimeStamp,
+ callId, mediaServerItems);
+ if (all.isEmpty()) {
+ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鏈壘鍒板緟鏀惰棌鐨勮棰�");
+ }
+ int limitCount = 50;
+ int resultCount = 0;
+ if (all.size() > limitCount) {
+ for (int i = 0; i < all.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > all.size()) {
+ toIndex = all.size();
+ }
+ resultCount += cloudRecordServiceMapper.updateCollectList(result, all.subList(i, toIndex));
+
+ }
+ }else {
+ resultCount = cloudRecordServiceMapper.updateCollectList(result, all);
+ }
+ return resultCount;
+ }
+
+ @Override
+ public int changeCollectById(Integer recordId, boolean result) {
+ return cloudRecordServiceMapper.changeCollectById(result, recordId);
+ }
+
+ @Override
+ public DownloadFileInfo getPlayUrlPath(Integer recordId) {
+ CloudRecordItem recordItem = cloudRecordServiceMapper.queryOne(recordId);
+ if (recordItem == null) {
+ throw new ControllerException(ErrorCode.ERROR400.getCode(), "璧勬簮涓嶅瓨鍦�");
+ }
+ String filePath = recordItem.getFilePath();
+ MediaServerItem mediaServerItem = mediaServerService.getOne(recordItem.getMediaServerId());
+ return CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath);
+ }
}
--
Gitblit v1.8.0