|
@@ -1,5 +1,6 @@
|
|
package com.qmth.themis.admin.api;
|
|
package com.qmth.themis.admin.api;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.google.common.reflect.TypeToken;
|
|
import com.google.common.reflect.TypeToken;
|
|
@@ -15,12 +16,14 @@ import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.UploadFileEnum;
|
|
import com.qmth.themis.business.enums.UploadFileEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
-import com.qmth.themis.business.util.OssUtil;
|
|
|
|
-import com.qmth.themis.business.util.ServletUtil;
|
|
|
|
|
|
+import com.qmth.themis.business.util.*;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.models.MediaBasicInfo;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.models.MediaInfo;
|
|
|
|
+import com.tencentcloudapi.vod.v20180717.models.SearchMediaResponse;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -86,6 +89,18 @@ public class SysController {
|
|
@Resource
|
|
@Resource
|
|
CacheService cacheService;
|
|
CacheService cacheService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TencentYunUtil tencentYunUtil;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TMTencentVideoMessageService tencentVideoMessageService;
|
|
|
|
+
|
|
@ApiOperation(value = "菜单查询接口")
|
|
@ApiOperation(value = "菜单查询接口")
|
|
@RequestMapping(value = "/getMenu", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/getMenu", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "菜单信息", response = TBPrivilege.class)})
|
|
@@ -412,4 +427,74 @@ public class SysController {
|
|
}
|
|
}
|
|
return ResultUtil.ok(teExamQueryDtoList);
|
|
return ResultUtil.ok(teExamQueryDtoList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "获取腾讯视频接口")
|
|
|
|
+ @RequestMapping(value = "/get_tencent_video", method = RequestMethod.POST)
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "腾讯视频接口", response = Result.class)})
|
|
|
|
+ @Transactional
|
|
|
|
+ public Result getTencentVideo(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) {
|
|
|
|
+ QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamId, examId)
|
|
|
|
+ .isNull(TOeExamRecord::getTencentVideoUrl);
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
|
|
|
|
+ for (TOeExamRecord t : tOeExamRecordList) {
|
|
|
|
+ Map<String, Object> resultMap = tencentYunUtil.callTencentVideo(t.getId());
|
|
|
|
+ if (!CollectionUtils.isEmpty(resultMap)) {
|
|
|
|
+ SearchMediaResponse response = (SearchMediaResponse) resultMap.get("object");
|
|
|
|
+ if (Objects.nonNull(response) && response.getTotalCount().intValue() > 0) {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ JSONArray jsonArray = null;
|
|
|
|
+ int countDb = 0;
|
|
|
|
+ if (Objects.nonNull(t.getTencentVideoUrl())) {
|
|
|
|
+ jsonArray = JSONArray.parseArray(t.getTencentVideoUrl());
|
|
|
|
+ countDb = jsonArray.size();
|
|
|
|
+ for (int i = 0; i < countDb; i++) {
|
|
|
|
+ JSONObject jsonObject = (JSONObject) jsonArray.get(i);
|
|
|
|
+ String videoSource = SystemConstant.getMonitorRecordStreamId((String) jsonObject.get(SystemConstant.VIDEO_SOURCE));
|
|
|
|
+ map.put(videoSource, videoSource);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ jsonArray = new JSONArray();
|
|
|
|
+ }
|
|
|
|
+ MediaInfo[] mediaInfos = response.getMediaInfoSet();
|
|
|
|
+ for (int i = 0; i < mediaInfos.length; i++) {
|
|
|
|
+ MediaBasicInfo mediaBasicInfo = mediaInfos[i].getBasicInfo();
|
|
|
|
+ String videoSource = SystemConstant.getMonitorRecordStreamId(mediaBasicInfo.getName());
|
|
|
|
+ boolean lock = false;
|
|
|
|
+ for (int y = 0; y < SystemConstant.CONSUME_MESSAGE_BATCH_MAX_SIZE; y++) {
|
|
|
|
+ lock = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource, SystemConstant.REDIS_LOCK_TENCENT_VIDEO_TIME_OUT);
|
|
|
|
+ if (lock && Objects.isNull(map.get(videoSource))) {
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put(SystemConstant.VIDEO_SOURCE, videoSource);
|
|
|
|
+ jsonObject.put(SystemConstant.VIDEO_URL, mediaBasicInfo.getMediaUrl());
|
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
|
+ break;
|
|
|
|
+ } finally {
|
|
|
|
+ redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_PREFIX + videoSource);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(500);
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(jsonArray) && jsonArray.size() > 0 && countDb != jsonArray.size()) {
|
|
|
|
+ t.setTencentVideoUrl(jsonArray.toJSONString());
|
|
|
|
+ tOeExamRecordService.updateById(t);
|
|
|
|
+
|
|
|
|
+ TMTencentVideoMessage tencentVideoMessage = new TMTencentVideoMessage(response.getRequestId(), JacksonUtil.parseJson(response));
|
|
|
|
+ tencentVideoMessageService.save(tencentVideoMessage);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResultUtil.ok(true);
|
|
|
|
+ }
|
|
}
|
|
}
|