...
|
...
|
@@ -2,7 +2,9 @@ package com.yoho.ufo.order.service.impl; |
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.dal.datasource.annotation.Database;
|
|
|
import com.yoho.order.dal.CameraRecordMapper;
|
|
|
import com.yoho.order.dal.QiniuLiveRecordMapper;
|
|
|
import com.yoho.order.model.CameraRecord;
|
|
|
import com.yoho.order.model.QiniuLiveRecord;
|
|
|
import com.yoho.ufo.exception.PlatformException;
|
|
|
import com.yoho.ufo.order.service.event.QiniuLiveRecordEvent;
|
...
|
...
|
@@ -11,6 +13,7 @@ import com.yoho.ufo.service.impl.UserHelper; |
|
|
import com.yoho.ufo.util.DateUtil;
|
|
|
import com.yohobuy.ufo.model.order.req.QNliveReq;
|
|
|
|
|
|
import com.yohobuy.ufo.model.order.resp.CameraRecordResp;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -20,6 +23,7 @@ import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -37,6 +41,9 @@ public class UfoLiveService implements ApplicationContextAware { |
|
|
|
|
|
private ApplicationContext context;
|
|
|
|
|
|
@Autowired
|
|
|
private CameraRecordMapper cameraRecordMapper;
|
|
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) {
|
|
|
this.context = applicationContext;
|
|
|
}
|
...
|
...
|
@@ -47,7 +54,9 @@ public class UfoLiveService implements ApplicationContextAware { |
|
|
|
|
|
String fileName = String.valueOf(req.getOrderCode()) + "_" + String.valueOf(req.getStartTime());
|
|
|
|
|
|
qNliveUtil.fetch(fileName, req.getDepotNo(), String.valueOf(req.getStartTime()), String.valueOf(req.getEndTime()));
|
|
|
String m3u8Url = queryM3u8Url(req.getCameraCode());
|
|
|
|
|
|
qNliveUtil.fetch(fileName, m3u8Url, String.valueOf(req.getStartTime()), String.valueOf(req.getEndTime()));
|
|
|
|
|
|
String persistId = qNliveUtil.transfer(fileName, fileName);
|
|
|
|
...
|
...
|
@@ -74,6 +83,7 @@ public class UfoLiveService implements ApplicationContextAware { |
|
|
record.setStartTime(req.getStartTime());
|
|
|
record.setStatus(0);
|
|
|
record.setVedioFileUrl(fileName + ".mp4");
|
|
|
record.setCameraCode(req.getCameraCode());
|
|
|
qiniuLiveRecordMapper.insert(record);
|
|
|
|
|
|
record.setNotInId(record.getId());
|
...
|
...
|
@@ -105,4 +115,24 @@ public class UfoLiveService implements ApplicationContextAware { |
|
|
//http://yhb-img01.qiniudn.com/ufo/live/mp4/9817910304768_1544775266.mp4
|
|
|
return QNliveUtil.LIVE_VEDIO_DOMAIN + QNliveUtil.MP4_FILEKEY_PRE + qiniuLiveRecord.getVedioFileUrl();
|
|
|
}
|
|
|
|
|
|
public String queryM3u8Url(Integer cameraCode) throws PlatformException {
|
|
|
List<CameraRecord> cameraRecordList = cameraRecordMapper.queryAllCameraRecord();
|
|
|
|
|
|
for (CameraRecord item : cameraRecordList) {
|
|
|
if (item.getCameraCode().equals(cameraCode)) {
|
|
|
return item.getVedioFileUrl();
|
|
|
}
|
|
|
}
|
|
|
throw new PlatformException(400);
|
|
|
}
|
|
|
|
|
|
public List<CameraRecordResp> queryCameraRecord(QNliveReq req) {
|
|
|
List<CameraRecord> cameraRecordList = cameraRecordMapper.queryAllCameraRecord();
|
|
|
|
|
|
List<CameraRecordResp> cameraRecordResps = new ArrayList<>();
|
|
|
cameraRecordList.stream().forEach(item -> cameraRecordResps.add(new CameraRecordResp(item.getCameraCode(), item.getCameraName())));
|
|
|
|
|
|
return cameraRecordResps;
|
|
|
}
|
|
|
} |
...
|
...
|
|