...
|
...
|
@@ -21,11 +21,13 @@ import com.yoho.order.model.QiniuLiveRecord; |
|
|
import com.yoho.order.model.UserCameraRecord;
|
|
|
import com.yoho.ufo.constants.RedisKeyConstants;
|
|
|
import com.yoho.ufo.exception.PlatformException;
|
|
|
import com.yoho.ufo.order.constant.OrderConfigConstant;
|
|
|
import com.yoho.ufo.order.service.event.QiniuLiveRecordEvent;
|
|
|
import com.yoho.ufo.service.impl.QNLiveUtilBackService;
|
|
|
import com.yoho.ufo.service.impl.QNLiveUtilService;
|
|
|
import com.yoho.ufo.service.impl.UserHelper;
|
|
|
import com.yoho.ufo.util.DateUtil;
|
|
|
import com.yoho.ufo.util.OrderVideoUrlUtil;
|
|
|
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
|
|
|
import com.yohobuy.ufo.model.order.req.QNliveReq;
|
|
|
|
...
|
...
|
@@ -39,11 +41,9 @@ import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by li.ma on 2018/12/13.
|
...
|
...
|
@@ -76,6 +76,9 @@ public class UfoLiveService { |
|
|
@Autowired
|
|
|
private ConfigReader configReader;
|
|
|
|
|
|
@Autowired
|
|
|
private OrderConfigConstant orderConfigConstant;
|
|
|
|
|
|
@Database(ForceMaster = true)
|
|
|
public void generateMp4(QiniuLiveRecord req) throws PlatformException {
|
|
|
LOGGER.info("method UfoLiveService.generateMp4 in, QNliveReq is {}", req);
|
...
|
...
|
@@ -138,36 +141,45 @@ public class UfoLiveService { |
|
|
record.setNotInId(record.getId());
|
|
|
}
|
|
|
|
|
|
public String queryMp4Vedio(QNliveReq req) throws PlatformException {
|
|
|
List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(req.getOrderCode()));
|
|
|
public String queryMp4Vedio(QNliveReq req) {
|
|
|
return queryMp4Vedio(req.getOrderCode());
|
|
|
}
|
|
|
|
|
|
public String queryMp4Vedio(Long orderCode) {
|
|
|
List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(orderCode));
|
|
|
if (CollectionUtils.isEmpty(qiniuLiveRecords)) {
|
|
|
throw new PlatformException("记录已不存在", 400);
|
|
|
return "";
|
|
|
}
|
|
|
QiniuLiveRecord qiniuLiveRecord = qiniuLiveRecords.get(qiniuLiveRecords.size() - 1);
|
|
|
|
|
|
if (Integer.valueOf(1).equals(qiniuLiveRecord.getStatus())) { // 如果已经转码成功,直接返回视频连接
|
|
|
return getVedioFileUrl(qiniuLiveRecord);
|
|
|
if (orderConfigConstant.getVedioConfig()) {
|
|
|
List<String> urlList = qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getStatus()))
|
|
|
.map(QiniuLiveRecord::getVedioFileUrl).collect(Collectors.toList());
|
|
|
|
|
|
return CollectionUtils.isEmpty(urlList) ? null : OrderVideoUrlUtil.makeLiveVideoUrl(urlList.get(0));
|
|
|
} else {
|
|
|
List<QiniuLiveRecord> cordList = qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getVedioUrl(), item.getStatus()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
return CollectionUtils.isEmpty(cordList) ? null : OrderVideoUrlUtil.makeLiveVideoUrl(cordList.get(0).getVedioUrl(), cordList.get(0).getVedioFileUrl());
|
|
|
}
|
|
|
|
|
|
if ("success".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { // 如果主动查询转码已成功,则更新状态
|
|
|
/*QiniuLiveRecord qiniuLiveRecord = qiniuLiveRecords.get(qiniuLiveRecords.size() - 1);
|
|
|
|
|
|
if (Integer.valueOf(1).equals(qiniuLiveRecord.getStatus())) { // 如果已经转码成功,直接返回视频连接
|
|
|
return OrderVideoUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl());
|
|
|
}*/
|
|
|
|
|
|
/*if ("success".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { // 如果主动查询转码已成功,则更新状态
|
|
|
qiniuLiveRecordMapper.updateStatusBySkup(req.getSkup(), 1);
|
|
|
|
|
|
return getVedioFileUrl(qiniuLiveRecord);
|
|
|
return OrderVideoUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl());
|
|
|
} else if ("fail".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) {
|
|
|
throw new PlatformException("上传失败,请重新录制", 400);
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
return null;*/
|
|
|
}
|
|
|
|
|
|
private String getVedioFileUrl(QiniuLiveRecord qiniuLiveRecord) {
|
|
|
//http://yhb-img01.qiniudn.com/ufo/live/mp4/9817910304768_1544775266.mp4
|
|
|
if (qiniuLiveRecord.getVedioFileUrl().startsWith("http")) {
|
|
|
return qiniuLiveRecord.getVedioFileUrl();
|
|
|
}
|
|
|
|
|
|
return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + qiniuLiveRecord.getVedioFileUrl();
|
|
|
}
|
|
|
|
|
|
// type 为1代表备用 0 代表默认的摄像源
|
|
|
public String queryM3u8Url(Integer cameraCode, int type) throws PlatformException {
|
...
|
...
|
|