Authored by mali

鉴定视频,无需再次覆盖视频的场景优化

@@ -43,6 +43,9 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv @@ -43,6 +43,9 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
43 @Autowired 43 @Autowired
44 private UfoLiveService ufoLiveService; 44 private UfoLiveService ufoLiveService;
45 45
  46 + @Autowired
  47 + private LiveRecordHelper liveRecordHelper;
  48 +
46 /** 49 /**
47 * seller_order_code = #{sellerOrderCode,jdbcType=BIGINT}, 50 * seller_order_code = #{sellerOrderCode,jdbcType=BIGINT},
48 update_time = #{updateTime,jdbcType=INTEGER}, 51 update_time = #{updateTime,jdbcType=INTEGER},
@@ -61,6 +64,10 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv @@ -61,6 +64,10 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
61 return; 64 return;
62 } 65 }
63 66
  67 + if (liveRecordHelper.noNeddGenerate(record.getOrderCode(), record.getStartTime())) {
  68 + return;
  69 + }
  70 +
64 if (record.getEndTime() - record.getStartTime() > 300) { 71 if (record.getEndTime() - record.getStartTime() > 300) {
65 record.setEndTime(record.getStartTime() + 300); 72 record.setEndTime(record.getStartTime() + 300);
66 } 73 }
  1 +package com.yoho.ufo.order.service.event;
  2 +
  3 +import com.google.common.collect.Lists;
  4 +import com.yoho.order.dal.QiniuLiveRecordMapper;
  5 +import com.yoho.order.model.QiniuLiveRecord;
  6 +import org.apache.commons.collections.CollectionUtils;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import java.util.Collections;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * Created by li.ma on 2019/5/20.
  17 + */
  18 +@Service
  19 +public class LiveRecordHelper {
  20 + private static final Logger LOGGER = LoggerFactory.getLogger(LiveRecordHelper.class);
  21 +
  22 + @Autowired
  23 + private QiniuLiveRecordMapper qiniuLiveRecordMapper;
  24 +
  25 + /**
  26 + * 如果已经存在视频,且开始时间一致,则无需再生成视频
  27 + * @param orderCode
  28 + * @param startTime
  29 + * @return true 无需再次生成
  30 + */
  31 + public boolean noNeddGenerate(Long orderCode, Integer startTime) {
  32 + if (null == startTime || null == orderCode) {
  33 + LOGGER.error("method noNeddGenerate wrong, orderCode is {}, startTime is {}", orderCode, startTime);
  34 + return false;
  35 + }
  36 +
  37 + boolean reslut = false;
  38 +
  39 + List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(orderCode));
  40 +
  41 + if (CollectionUtils.isNotEmpty(qiniuLiveRecords) && startTime.equals(qiniuLiveRecords.get(0).getStartTime())) {
  42 + reslut = true;
  43 + }
  44 +
  45 + LOGGER.info("method noNeddGenerate run. reslut is {}, orderCode is {}, startTime is {}", orderCode, startTime, reslut);
  46 +
  47 + return reslut;
  48 + }
  49 +}