Showing
3 changed files
with
94 additions
and
36 deletions
1 | +package com.yoho.ufo.util; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.constants.QNliveConstants; | ||
4 | +import org.apache.commons.lang3.StringUtils; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by li.ma on 2019/4/15. | ||
8 | + */ | ||
9 | +public class OrderVideoUrlUtil { | ||
10 | + public static final String LIVE_VIDEO_DOMAIN = QNliveConstants.LIVE_VIDEO_DOMAIN; | ||
11 | + public static final String MP4_FILEKEY_PRE = QNliveConstants.MP4_FILEKEY_PRE; // mp4文件路径 | ||
12 | + | ||
13 | + public static String makeLiveVideoUrl(String filename) { | ||
14 | + if (StringUtils.isBlank(filename)) { | ||
15 | + return null; | ||
16 | + } | ||
17 | + | ||
18 | + if (filename.startsWith("http")) { // 如果数据库存放的是绝对路径,则直接返回 | ||
19 | + return filename; | ||
20 | + } | ||
21 | + | ||
22 | + return LIVE_VIDEO_DOMAIN + MP4_FILEKEY_PRE + filename; | ||
23 | + } | ||
24 | + | ||
25 | + | ||
26 | + public static String makeLiveVideoUrl(String videoName, String filename) { | ||
27 | + if (StringUtils.isNotBlank(videoName)) { // 优先取新的鉴定视频链接 | ||
28 | + return videoName; | ||
29 | + } | ||
30 | + | ||
31 | + return makeLiveVideoUrl(filename); | ||
32 | + } | ||
33 | + | ||
34 | + public static boolean filterVideoValid(Integer status) { | ||
35 | + return 1 == status; | ||
36 | + } | ||
37 | + | ||
38 | + public static boolean filterVideoValid(String videoName, Integer status) { | ||
39 | + return StringUtils.isNotBlank(videoName) || 1 == status; | ||
40 | + } | ||
41 | +} |
@@ -19,14 +19,12 @@ import com.yoho.ufo.dal.ProductMapper; | @@ -19,14 +19,12 @@ import com.yoho.ufo.dal.ProductMapper; | ||
19 | import com.yoho.ufo.dal.model.IdentifyRecords; | 19 | import com.yoho.ufo.dal.model.IdentifyRecords; |
20 | import com.yoho.ufo.dal.model.Product; | 20 | import com.yoho.ufo.dal.model.Product; |
21 | import com.yoho.ufo.order.constant.Constant; | 21 | import com.yoho.ufo.order.constant.Constant; |
22 | +import com.yoho.ufo.order.constant.OrderConfigConstant; | ||
22 | import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest; | 23 | import com.yoho.ufo.order.request.SaveQualityCheckInfoRequest; |
23 | import com.yoho.ufo.order.service.IBuyerOrderService; | 24 | import com.yoho.ufo.order.service.IBuyerOrderService; |
24 | import com.yoho.ufo.service.impl.UserHelper; | 25 | import com.yoho.ufo.service.impl.UserHelper; |
25 | import com.yoho.ufo.service.model.PageResponseBO; | 26 | import com.yoho.ufo.service.model.PageResponseBO; |
26 | -import com.yoho.ufo.util.DateUtil; | ||
27 | -import com.yoho.ufo.util.ImagesConstant; | ||
28 | -import com.yoho.ufo.util.ImagesHelper; | ||
29 | -import com.yoho.ufo.util.MobileHelper; | 27 | +import com.yoho.ufo.util.*; |
30 | import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo; | 28 | import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo; |
31 | import com.yohobuy.ufo.model.order.common.EnumExpressType; | 29 | import com.yohobuy.ufo.model.order.common.EnumExpressType; |
32 | import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus; | 30 | import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus; |
@@ -129,6 +127,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -129,6 +127,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
129 | @Autowired | 127 | @Autowired |
130 | private OrderConfigMapper orderConfigMapper; | 128 | private OrderConfigMapper orderConfigMapper; |
131 | 129 | ||
130 | + @Autowired | ||
131 | + private UfoLiveService ufoLiveService; | ||
132 | + | ||
133 | + @Autowired | ||
134 | + private OrderConfigConstant orderConfigConstant; | ||
135 | + | ||
132 | private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address"; | 136 | private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address"; |
133 | 137 | ||
134 | private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address"; | 138 | private static final String SELLER_ORDER_META_KEY_BACK_DELIVERY_ADDRESS = "back_delivery_address"; |
@@ -473,7 +477,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -473,7 +477,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
473 | List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(orderCodeList); | 477 | List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(orderCodeList); |
474 | 478 | ||
475 | Set<String> containOrderCodeSet = new HashSet<>(); | 479 | Set<String> containOrderCodeSet = new HashSet<>(); |
476 | - qiniuLiveRecords.stream().forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode()))); | 480 | + if (orderConfigConstant.getVedioConfig()) { |
481 | + qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getStatus())) | ||
482 | + .forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode()))); | ||
483 | + } else { | ||
484 | + qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getVedioUrl(), item.getStatus())) | ||
485 | + .forEach(item -> containOrderCodeSet.add(String.valueOf(item.getOrderCode()))); | ||
486 | + } | ||
477 | 487 | ||
478 | respList.forEach(item -> item.setContainMp4Flag(containOrderCodeSet.contains(item.getOrderCode()))); | 488 | respList.forEach(item -> item.setContainMp4Flag(containOrderCodeSet.contains(item.getOrderCode()))); |
479 | } | 489 | } |
@@ -1927,20 +1937,15 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | @@ -1927,20 +1937,15 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { | ||
1927 | } | 1937 | } |
1928 | 1938 | ||
1929 | private String getVedioUrl(String orderCode) { | 1939 | private String getVedioUrl(String orderCode) { |
1930 | - List<QiniuLiveRecord> liveRecordList = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(Long.valueOf(orderCode))); | 1940 | + return ufoLiveService.queryMp4Vedio(Long.valueOf(orderCode)); |
1941 | + | ||
1942 | +/* | ||
1931 | if(CollectionUtils.isNotEmpty(liveRecordList)) { | 1943 | if(CollectionUtils.isNotEmpty(liveRecordList)) { |
1932 | String filename = liveRecordList.get(0).getVedioFileUrl(); | 1944 | String filename = liveRecordList.get(0).getVedioFileUrl(); |
1933 | - if (StringUtils.isBlank(filename)) { | ||
1934 | - return ""; | ||
1935 | - } | ||
1936 | - if (filename.startsWith("http")) { | ||
1937 | - return filename; | ||
1938 | - }else { | ||
1939 | - return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + filename; | ||
1940 | - } | 1945 | + return OrderVideoUrlUtil.makeLiveVideoUrl(filename); |
1941 | } | 1946 | } |
1942 | 1947 | ||
1943 | - return ""; | 1948 | + return "";*/ |
1944 | } | 1949 | } |
1945 | 1950 | ||
1946 | public Map<String,Object> queryExpressListAndAddressInfo(String orderCode, String expressType){ | 1951 | public Map<String,Object> queryExpressListAndAddressInfo(String orderCode, String expressType){ |
@@ -21,11 +21,13 @@ import com.yoho.order.model.QiniuLiveRecord; | @@ -21,11 +21,13 @@ import com.yoho.order.model.QiniuLiveRecord; | ||
21 | import com.yoho.order.model.UserCameraRecord; | 21 | import com.yoho.order.model.UserCameraRecord; |
22 | import com.yoho.ufo.constants.RedisKeyConstants; | 22 | import com.yoho.ufo.constants.RedisKeyConstants; |
23 | import com.yoho.ufo.exception.PlatformException; | 23 | import com.yoho.ufo.exception.PlatformException; |
24 | +import com.yoho.ufo.order.constant.OrderConfigConstant; | ||
24 | import com.yoho.ufo.order.service.event.QiniuLiveRecordEvent; | 25 | import com.yoho.ufo.order.service.event.QiniuLiveRecordEvent; |
25 | import com.yoho.ufo.service.impl.QNLiveUtilBackService; | 26 | import com.yoho.ufo.service.impl.QNLiveUtilBackService; |
26 | import com.yoho.ufo.service.impl.QNLiveUtilService; | 27 | import com.yoho.ufo.service.impl.QNLiveUtilService; |
27 | import com.yoho.ufo.service.impl.UserHelper; | 28 | import com.yoho.ufo.service.impl.UserHelper; |
28 | import com.yoho.ufo.util.DateUtil; | 29 | import com.yoho.ufo.util.DateUtil; |
30 | +import com.yoho.ufo.util.OrderVideoUrlUtil; | ||
29 | import com.yohobuy.ufo.model.order.constants.QNliveConstants; | 31 | import com.yohobuy.ufo.model.order.constants.QNliveConstants; |
30 | import com.yohobuy.ufo.model.order.req.QNliveReq; | 32 | import com.yohobuy.ufo.model.order.req.QNliveReq; |
31 | 33 | ||
@@ -39,11 +41,9 @@ import org.springframework.context.ApplicationContext; | @@ -39,11 +41,9 @@ import org.springframework.context.ApplicationContext; | ||
39 | import org.springframework.context.ApplicationContextAware; | 41 | import org.springframework.context.ApplicationContextAware; |
40 | import org.springframework.stereotype.Service; | 42 | import org.springframework.stereotype.Service; |
41 | 43 | ||
42 | -import java.util.ArrayList; | ||
43 | -import java.util.Date; | ||
44 | -import java.util.List; | ||
45 | -import java.util.Objects; | 44 | +import java.util.*; |
46 | import java.util.concurrent.TimeUnit; | 45 | import java.util.concurrent.TimeUnit; |
46 | +import java.util.stream.Collectors; | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Created by li.ma on 2018/12/13. | 49 | * Created by li.ma on 2018/12/13. |
@@ -76,6 +76,9 @@ public class UfoLiveService { | @@ -76,6 +76,9 @@ public class UfoLiveService { | ||
76 | @Autowired | 76 | @Autowired |
77 | private ConfigReader configReader; | 77 | private ConfigReader configReader; |
78 | 78 | ||
79 | + @Autowired | ||
80 | + private OrderConfigConstant orderConfigConstant; | ||
81 | + | ||
79 | @Database(ForceMaster = true) | 82 | @Database(ForceMaster = true) |
80 | public void generateMp4(QiniuLiveRecord req) throws PlatformException { | 83 | public void generateMp4(QiniuLiveRecord req) throws PlatformException { |
81 | LOGGER.info("method UfoLiveService.generateMp4 in, QNliveReq is {}", req); | 84 | LOGGER.info("method UfoLiveService.generateMp4 in, QNliveReq is {}", req); |
@@ -138,36 +141,45 @@ public class UfoLiveService { | @@ -138,36 +141,45 @@ public class UfoLiveService { | ||
138 | record.setNotInId(record.getId()); | 141 | record.setNotInId(record.getId()); |
139 | } | 142 | } |
140 | 143 | ||
141 | - public String queryMp4Vedio(QNliveReq req) throws PlatformException { | ||
142 | - List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(req.getOrderCode())); | 144 | + public String queryMp4Vedio(QNliveReq req) { |
145 | + return queryMp4Vedio(req.getOrderCode()); | ||
146 | + } | ||
147 | + | ||
148 | + public String queryMp4Vedio(Long orderCode) { | ||
149 | + List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(orderCode)); | ||
143 | if (CollectionUtils.isEmpty(qiniuLiveRecords)) { | 150 | if (CollectionUtils.isEmpty(qiniuLiveRecords)) { |
144 | - throw new PlatformException("记录已不存在", 400); | 151 | + return ""; |
145 | } | 152 | } |
146 | - QiniuLiveRecord qiniuLiveRecord = qiniuLiveRecords.get(qiniuLiveRecords.size() - 1); | ||
147 | 153 | ||
148 | - if (Integer.valueOf(1).equals(qiniuLiveRecord.getStatus())) { // 如果已经转码成功,直接返回视频连接 | ||
149 | - return getVedioFileUrl(qiniuLiveRecord); | 154 | + if (orderConfigConstant.getVedioConfig()) { |
155 | + List<String> urlList = qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getStatus())) | ||
156 | + .map(QiniuLiveRecord::getVedioFileUrl).collect(Collectors.toList()); | ||
157 | + | ||
158 | + return CollectionUtils.isEmpty(urlList) ? null : OrderVideoUrlUtil.makeLiveVideoUrl(urlList.get(0)); | ||
159 | + } else { | ||
160 | + List<QiniuLiveRecord> cordList = qiniuLiveRecords.stream().filter(item -> OrderVideoUrlUtil.filterVideoValid(item.getVedioUrl(), item.getStatus())) | ||
161 | + .collect(Collectors.toList()); | ||
162 | + | ||
163 | + return CollectionUtils.isEmpty(cordList) ? null : OrderVideoUrlUtil.makeLiveVideoUrl(cordList.get(0).getVedioUrl(), cordList.get(0).getVedioFileUrl()); | ||
150 | } | 164 | } |
151 | 165 | ||
152 | - if ("success".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { // 如果主动查询转码已成功,则更新状态 | 166 | + /*QiniuLiveRecord qiniuLiveRecord = qiniuLiveRecords.get(qiniuLiveRecords.size() - 1); |
167 | + | ||
168 | + if (Integer.valueOf(1).equals(qiniuLiveRecord.getStatus())) { // 如果已经转码成功,直接返回视频连接 | ||
169 | + return OrderVideoUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()); | ||
170 | + }*/ | ||
171 | + | ||
172 | + /*if ("success".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { // 如果主动查询转码已成功,则更新状态 | ||
153 | qiniuLiveRecordMapper.updateStatusBySkup(req.getSkup(), 1); | 173 | qiniuLiveRecordMapper.updateStatusBySkup(req.getSkup(), 1); |
154 | 174 | ||
155 | - return getVedioFileUrl(qiniuLiveRecord); | 175 | + return OrderVideoUrlUtil.makeLiveVideoUrl(qiniuLiveRecord.getVedioFileUrl()); |
156 | } else if ("fail".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { | 176 | } else if ("fail".equals(qNliveUtilService.queryPrefopStatus(qiniuLiveRecord.getPersistId()))) { |
157 | throw new PlatformException("上传失败,请重新录制", 400); | 177 | throw new PlatformException("上传失败,请重新录制", 400); |
158 | } | 178 | } |
159 | 179 | ||
160 | - return null; | 180 | + return null;*/ |
161 | } | 181 | } |
162 | 182 | ||
163 | - private String getVedioFileUrl(QiniuLiveRecord qiniuLiveRecord) { | ||
164 | - //http://yhb-img01.qiniudn.com/ufo/live/mp4/9817910304768_1544775266.mp4 | ||
165 | - if (qiniuLiveRecord.getVedioFileUrl().startsWith("http")) { | ||
166 | - return qiniuLiveRecord.getVedioFileUrl(); | ||
167 | - } | ||
168 | - | ||
169 | - return QNliveConstants.LIVE_VIDEO_DOMAIN + QNliveConstants.MP4_FILEKEY_PRE + qiniuLiveRecord.getVedioFileUrl(); | ||
170 | - } | ||
171 | 183 | ||
172 | // type 为1代表备用 0 代表默认的摄像源 | 184 | // type 为1代表备用 0 代表默认的摄像源 |
173 | public String queryM3u8Url(Integer cameraCode, int type) throws PlatformException { | 185 | public String queryM3u8Url(Integer cameraCode, int type) throws PlatformException { |
-
Please register or login to post a comment