Authored by mali

鉴定视频优化

package com.yoho.ufo.util;
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
import org.apache.commons.lang3.StringUtils;
/**
* Created by li.ma on 2019/4/15.
*/
public class OrderVideoUrlUtil {
public static final String LIVE_VIDEO_DOMAIN = QNliveConstants.LIVE_VIDEO_DOMAIN;
public static final String MP4_FILEKEY_PRE = QNliveConstants.MP4_FILEKEY_PRE; // mp4文件路径
public static String makeLiveVideoUrl(String filename) {
if (StringUtils.isBlank(filename)) {
return null;
}
if (filename.startsWith("http")) { // 如果数据库存放的是绝对路径,则直接返回
return filename;
}
return LIVE_VIDEO_DOMAIN + MP4_FILEKEY_PRE + filename;
}
public static String makeLiveVideoUrl(String videoName, String filename) {
if (StringUtils.isNotBlank(videoName)) { // 优先取新的鉴定视频链接
return videoName;
}
return makeLiveVideoUrl(filename);
}
public static boolean filterVideoValid(Integer status) {
return 1 == status;
}
public static boolean filterVideoValid(String videoName, Integer status) {
return StringUtils.isNotBlank(videoName) || 1 == status;
}
}
... ...
... ... @@ -19,14 +19,12 @@ import com.yoho.ufo.dal.ProductMapper;
import com.yoho.ufo.dal.model.IdentifyRecords;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.order.constant.Constant;
import com.yoho.ufo.order.constant.OrderConfigConstant;
import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.DateUtil;
import com.yoho.ufo.util.ImagesConstant;
import com.yoho.ufo.util.ImagesHelper;
import com.yoho.ufo.util.MobileHelper;
import com.yoho.ufo.util.*;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.EnumExpressType;
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
... ... @@ -129,6 +127,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private OrderConfigMapper orderConfigMapper;
@Autowired
private UfoLiveService ufoLiveService;
@Autowired
private OrderConfigConstant orderConfigConstant;
private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address";
... ... @@ -473,7 +477,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(orderCodeList);
Set<String> containOrderCodeSet = new HashSet<>();
qiniuLiveRecords.stream().forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode())));
if (orderConfigConstant.getVedioConfig()) {
qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getStatus()))
.forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode())));
} else {
qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getVedioUrl(), item.getStatus()))
.forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode())));
}
respList.forEach(item -> item.setContainMp4Flag(containOrderCodeSet.contains(item.getOrderCode())));
}
... ... @@ -1927,20 +1937,15 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
}
private String getVedioUrl(String orderCode) {
List<QiniuLiveRecord> liveRecordList = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(Long.valueOf(orderCode)));
return ufoLiveService.queryMp4Vedio(Long.valueOf(orderCode));
/*
if(CollectionUtils.isNotEmpty(liveRecordList)) {
String filename = liveRecordList.get(0).getVedioFileUrl();
if (StringUtils.isBlank(filename)) {
return "";
}
if (filename.startsWith("http")) {
return filename;
}else {
return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + filename;
}
return OrderVideoUrlUtil.makeLiveVideoUrl(filename);
}
return "";
return "";*/
}
public Map<String,Object> queryExpressListAndAddressInfo(String orderCode, String expressType){
... ...
... ... @@ -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 {
... ...