|
@@ -1,6 +1,6 @@
|
|
package com.qmth.themis.admin.api;
|
|
package com.qmth.themis.admin.api;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.qmth.themis.admin.config.DictionaryConfig;
|
|
import com.qmth.themis.admin.config.DictionaryConfig;
|
|
import com.qmth.themis.business.bean.admin.TencentEventBean;
|
|
import com.qmth.themis.business.bean.admin.TencentEventBean;
|
|
@@ -30,6 +30,7 @@ import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.tencentcloudapi.common.Sign;
|
|
import com.tencentcloudapi.common.Sign;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
|
+import org.apache.http.client.utils.DateUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -104,6 +105,8 @@ public class TENotifyController {
|
|
//说明是录制视频回调成功
|
|
//说明是录制视频回调成功
|
|
if (Objects.nonNull(eventType) && Objects.equals(eventType, "100")) {
|
|
if (Objects.nonNull(eventType) && Objects.equals(eventType, "100")) {
|
|
String streamId = String.valueOf(jsonObject.get("stream_id"));
|
|
String streamId = String.valueOf(jsonObject.get("stream_id"));
|
|
|
|
+ Long startTime = jsonObject.getLong("start_time");
|
|
|
|
+ Long endTime = jsonObject.getLong("end_time");
|
|
String videoSource = SystemConstant.getMonitorRecordStreamId(streamId);
|
|
String videoSource = SystemConstant.getMonitorRecordStreamId(streamId);
|
|
boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource, SystemConstant.REDIS_LOCK_TENCENT_VIDEO_TIME_OUT);
|
|
boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource, SystemConstant.REDIS_LOCK_TENCENT_VIDEO_TIME_OUT);
|
|
if (lock) {
|
|
if (lock) {
|
|
@@ -112,34 +115,8 @@ public class TENotifyController {
|
|
if (Objects.nonNull(streamId)) {
|
|
if (Objects.nonNull(streamId)) {
|
|
String[] str = streamId.split("_");
|
|
String[] str = streamId.split("_");
|
|
recordId = Long.parseLong(str[2]);
|
|
recordId = Long.parseLong(str[2]);
|
|
- String tencentVideoUrl = ExamRecordCacheUtil.getTencentVideoUrl(recordId);
|
|
|
|
- if (Objects.nonNull(tencentVideoUrl)) {//说明缓存还在
|
|
|
|
- JSONArray jsonArrayDb = JSONArray.parseArray(tencentVideoUrl);
|
|
|
|
- int count = jsonArrayDb.size();
|
|
|
|
- JSONArray jsonArray = this.getVideoUrl(tencentVideoUrl, videoSource, jsonObject);
|
|
|
|
- if (Objects.nonNull(jsonArray) && jsonArray.size() > 0 && count != jsonArray.size()) {
|
|
|
|
- if (Objects.nonNull(ExamRecordCacheUtil.getTencentVideoUrl(recordId)) && Objects.equals(tencentVideoUrl, ExamRecordCacheUtil.getTencentVideoUrl(recordId))) {
|
|
|
|
- ExamRecordCacheUtil.setTencentVideoUrl(recordId, jsonArray.toJSONString());
|
|
|
|
- tOeExamRecordService.sendExamRecordDataSaveMqNotIp(recordId, System.currentTimeMillis());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- TOeExamRecord tOeExamRecord = SystemConstant.getExamRecord(recordId);
|
|
|
|
- int count = 0;
|
|
|
|
- JSONArray jsonArrayDb = null;
|
|
|
|
- if (Objects.nonNull(tOeExamRecord.getTencentVideoUrl())) {
|
|
|
|
- jsonArrayDb = JSONArray.parseArray(tOeExamRecord.getTencentVideoUrl());
|
|
|
|
- count = jsonArrayDb.size();
|
|
|
|
- }
|
|
|
|
- JSONArray jsonArray = this.getVideoUrl(tOeExamRecord.getTencentVideoUrl(), videoSource, jsonObject);
|
|
|
|
- if (Objects.nonNull(jsonArray) && jsonArray.size() > 0 && count != jsonArray.size()) {
|
|
|
|
- tOeExamRecord.setTencentVideoUrl(jsonArray.toJSONString());
|
|
|
|
- tOeExamRecordService.updateById(tOeExamRecord);
|
|
|
|
-
|
|
|
|
- TMTencentVideoMessage tencentVideoMessage = new TMTencentVideoMessage(SystemConstant.getUuid(), jsonObject.toJSONString());
|
|
|
|
- tencentVideoMessageService.save(tencentVideoMessage);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ TMTencentVideoMessage tencentVideoMessage = new TMTencentVideoMessage(SystemConstant.getUuid(), jsonObject.toJSONString(), recordId, videoSource, startTime * 1000, endTime * 1000, String.valueOf(jsonObject.get("video_url")));
|
|
|
|
+ tencentVideoMessageService.save(tencentVideoMessage);
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource);
|
|
redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource);
|
|
@@ -149,37 +126,6 @@ public class TENotifyController {
|
|
return ResultUtil.ok(true);
|
|
return ResultUtil.ok(true);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取视频源地址
|
|
|
|
- *
|
|
|
|
- * @param tencentVideoUrl
|
|
|
|
- * @param videoSource
|
|
|
|
- * @param jsonObject
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private JSONArray getVideoUrl(String tencentVideoUrl, String videoSource, JSONObject jsonObject) {
|
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
- JSONArray jsonArray = null;
|
|
|
|
- if (Objects.isNull(tencentVideoUrl)) {
|
|
|
|
- jsonArray = new JSONArray();
|
|
|
|
- } else {
|
|
|
|
- jsonArray = JSONArray.parseArray(tencentVideoUrl);
|
|
|
|
- }
|
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
- JSONObject json = (JSONObject) jsonArray.get(i);
|
|
|
|
- String videoSourceTemp = SystemConstant.getMonitorRecordStreamId((String) json.get(SystemConstant.VIDEO_SOURCE));
|
|
|
|
- map.put(videoSourceTemp, videoSourceTemp);
|
|
|
|
- }
|
|
|
|
- if (Objects.isNull(map.get(videoSource))) {
|
|
|
|
- String videoUrl = String.valueOf(jsonObject.get("video_url"));
|
|
|
|
- JSONObject json = new JSONObject();
|
|
|
|
- json.put(SystemConstant.VIDEO_SOURCE, videoSource);
|
|
|
|
- json.put(SystemConstant.VIDEO_URL, videoUrl);
|
|
|
|
- jsonArray.add(json);
|
|
|
|
- }
|
|
|
|
- return jsonArray;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@ApiOperation(value = "腾讯云状态事件接口回调")
|
|
@ApiOperation(value = "腾讯云状态事件接口回调")
|
|
@RequestMapping(value = "/status/tencent", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/status/tencent", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
|