|
@@ -6,20 +6,15 @@ import com.ozs.common.config.BaseConfig;
|
|
|
import com.ozs.common.exception.base.BaseException;
|
|
|
import com.ozs.common.utils.DateUtils;
|
|
|
import com.ozs.common.utils.http.HttpUtils;
|
|
|
-import com.ozs.framework.config.ServerConfig;
|
|
|
import com.ozs.web.core.config.CaneraConfig;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
-import springfox.documentation.spring.web.json.Json;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.io.*;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -36,45 +31,20 @@ public class CameraUtil {
|
|
|
@Autowired
|
|
|
private CaneraConfig caneraConfig;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 历史回放
|
|
|
*
|
|
|
- * @param channel
|
|
|
- * @param startTm
|
|
|
- * @param endTm
|
|
|
+ * @param fromVideoFileList
|
|
|
+ * @param ph
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public static String historyPlay(String channel, Date startTm, Date endTm) throws IOException {
|
|
|
- if (StringUtils.isBlank(channel)
|
|
|
- || ObjectUtils.isEmpty(startTm)
|
|
|
- || ObjectUtils.isEmpty(endTm)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- // 调用视频服务返回参数
|
|
|
- String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
|
- String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
|
- String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
|
- String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
|
-
|
|
|
- // 视频拼接
|
|
|
- if (!StringUtils.isBlank(s)) {
|
|
|
- List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
|
- // 视频服务映射路径
|
|
|
- String NewfilePath = BaseConfig.getProfile() + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
|
- List<String> fromVideoFileList = new ArrayList();
|
|
|
- for (Map<String, Object> map : maps) {
|
|
|
- Object path = map.get("Path");
|
|
|
- if (!ObjectUtils.isEmpty(path)) {
|
|
|
- fromVideoFileList.add(mappingUrl + path);
|
|
|
- }
|
|
|
- }
|
|
|
- convetor(fromVideoFileList, NewfilePath);
|
|
|
- return null;
|
|
|
-// return systemUrl + "/profile" + "/" + channel + "/" + startTime + "/" + endTime + ".flv";
|
|
|
- }
|
|
|
- // http://47.106.159.135/record/flv/34020000001320000002/20230304_183122_183222-d98df13f-ba77-11ed-aeb9-00163e06a5f3.flv
|
|
|
- return null;
|
|
|
+ public static String historyPlay(List<String> fromVideoFileList, String ph) throws IOException {
|
|
|
+ // 视频服务映射路径
|
|
|
+ String NewfilePath = BaseConfig.getProfile() + ph;
|
|
|
+ convetor(fromVideoFileList, NewfilePath);
|
|
|
+ return "/profile" + ph;
|
|
|
}
|
|
|
|
|
|
public static String getPlayFlv(String cameraCode, String channel) {
|
|
@@ -96,16 +66,21 @@ public class CameraUtil {
|
|
|
return HttpUtils.sendGet(url + "/gb28181/api/records", param);
|
|
|
}
|
|
|
|
|
|
- public static List<String> historyPlayList(String channel, Date startTm, Date endTm) {
|
|
|
+
|
|
|
+ public static String historyPlayList(String channel, Date startTm, Date endTm) {
|
|
|
if (StringUtils.isBlank(channel)
|
|
|
|| ObjectUtils.isEmpty(startTm)
|
|
|
|| ObjectUtils.isEmpty(endTm)) {
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
List<String> ls = new ArrayList<>();
|
|
|
// 调用视频服务返回参数
|
|
|
String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
|
String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
|
+ String ph = "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
|
+ + "/" + channel + "/" + startTime + "/" + endTime + "/"
|
|
|
+ + UUID.randomUUID().toString() + ".flv";
|
|
|
String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
|
String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
|
|
|
// 视频拼接
|
|
@@ -114,11 +89,43 @@ public class CameraUtil {
|
|
|
for (Map<String, Object> map : maps) {
|
|
|
Object path = map.get("Path");
|
|
|
if (!ObjectUtils.isEmpty(path)) {
|
|
|
- ls.add(mappingUrl + path.toString());
|
|
|
+ String s1 = path.toString();
|
|
|
+ String substring = s1.substring(s1.lastIndexOf("/") + 1, s1.length());
|
|
|
+ String substring1 = substring.substring(0, substring.indexOf("-"));
|
|
|
+ String[] s2 = substring1.split("_");
|
|
|
+ if (!ObjectUtils.isEmpty(s2)) {
|
|
|
+ String s3 = s2[0] + s2[1];
|
|
|
+ String s4 = s2[0] + s2[2];
|
|
|
+ Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
|
|
|
+ Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
|
|
|
+ /* s | e | */
|
|
|
+ if (sdate.compareTo(startTm) <= 0 && edate.compareTo(startTm) > 0) {
|
|
|
+ ls.add(mappingUrl + path.toString());
|
|
|
+
|
|
|
+ /* | s e | */
|
|
|
+ } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) <= 0) {
|
|
|
+ ls.add(mappingUrl + path.toString());
|
|
|
+
|
|
|
+ /* | s | e */
|
|
|
+ } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) >= 0) {
|
|
|
+ ls.add(mappingUrl + path.toString());
|
|
|
+
|
|
|
+ /* s| | e */
|
|
|
+ } else if (sdate.compareTo(startTm) <= 0 && edate.compareTo(endTm) >= 0) {
|
|
|
+ ls.add(mappingUrl + path.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return ls;
|
|
|
+ if (!ObjectUtils.isEmpty(ls)) {
|
|
|
+ try {
|
|
|
+ return historyPlay(ls, ph);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|