|
@@ -20,7 +20,6 @@ import com.qmth.themis.business.templete.TaskImportTemplete;
|
|
|
import com.qmth.themis.business.templete.impl.*;
|
|
|
import com.qmth.themis.business.util.*;
|
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
|
-import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.SimpleBeanUtil;
|
|
|
import com.qmth.themis.mq.service.MqLogicService;
|
|
@@ -34,6 +33,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
@@ -123,6 +123,9 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
|
@Resource
|
|
|
TOeExamRecordService tOeExamRecordService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TGErrorService tgErrorService;
|
|
|
+
|
|
|
/**
|
|
|
* mq最大重试次数逻辑
|
|
|
*
|
|
@@ -303,13 +306,45 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
|
streamIds[i] = SystemConstant.setStreamId(monitorUtil.getMonitorDomain().getPrefix(), recordId, MonitorVideoSourceEnum.convertToName(monitorRecordList.get(i)));
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> resultMap = tencentYunUtil.tencentVodSdk(tencentYunUtil.getTencentYunDomain().getSecretId(),
|
|
|
- tencentYunUtil.getTencentYunDomain().getSecretKey(),
|
|
|
- tencentYunUtil.getTencentYunDomain().getQueryUrl(),
|
|
|
- tencentYunUtil.getTencentYunDomain().getVodAppId(),
|
|
|
- streamIds);
|
|
|
+ Map<String, Object> resultMap = null;
|
|
|
+ boolean lockStreamIds = false;
|
|
|
+ for (int i = 0; i < SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT; i++) {
|
|
|
+ lockStreamIds = redisUtil.lock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString(),
|
|
|
+ SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_TIME_OUT);
|
|
|
+ if (lockStreamIds) {
|
|
|
+ try {
|
|
|
+ resultMap = tencentYunUtil.tencentVodSdk(tencentYunUtil.getTencentYunDomain().getSecretId(),
|
|
|
+ tencentYunUtil.getTencentYunDomain().getSecretKey(),
|
|
|
+ tencentYunUtil.getTencentYunDomain().getQueryUrl(),
|
|
|
+ tencentYunUtil.getTencentYunDomain().getVodAppId(),
|
|
|
+ streamIds);
|
|
|
+ break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求出错", e);
|
|
|
+ if (i == SystemConstant.MAX_TENCENT_VIDEO_STREAM_ID_COUNT - 1) {
|
|
|
+ tgErrorService.saveExamTgError(recordId, "execMqTencentVideoLogic");
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ Thread.sleep(3000);
|
|
|
+ } catch (InterruptedException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ if (Objects.nonNull(streamIds)) {
|
|
|
+ redisUtil.releaseLock(SystemConstant.REDIS_LOCK_TENCENT_VIDEO_STREAM_ID_PREFIX + streamIds.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (Objects.nonNull(resultMap) && resultMap.size() > 0) {
|
|
|
+ if (!CollectionUtils.isEmpty(resultMap)) {
|
|
|
SearchMediaResponse response = (SearchMediaResponse) resultMap.get("object");
|
|
|
if (Objects.nonNull(response) && response.getTotalCount().intValue() > 0) {
|
|
|
Map<String, String> map = new HashMap<>();
|