12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775 |
- package com.ozs.utils;
- import com.alibaba.fastjson2.JSON;
- import com.alibaba.fastjson2.JSONArray;
- import com.alibaba.fastjson2.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.hikvision.artemis.sdk.ArtemisHttpUtil;
- import com.hikvision.artemis.sdk.config.ArtemisConfig;
- import com.ozs.common.config.BaseConfig;
- import com.ozs.common.constant.Constants;
- import com.ozs.common.core.domain.AjaxResult;
- import com.ozs.common.core.domain.entity.SysDictData;
- import com.ozs.common.core.redis.RedisCache;
- import com.ozs.common.exception.base.BaseException;
- import com.ozs.common.utils.DateUtils;
- import com.ozs.common.utils.HttpClientUtil;
- import com.ozs.common.utils.http.HttpUtils;
- import com.ozs.entity.BaseCameraManagement;
- import com.ozs.entity.BaseTerminal;
- import com.ozs.entity.BaseTerminalLog;
- import com.ozs.entity.MsgHeartbeatAlarmMessage;
- import com.ozs.entity.response.BaseCameraManagementResponse;
- import com.ozs.entity.vo.CamerasVo;
- import com.ozs.entity.vo.PlaybackVo;
- import com.ozs.framework.config.ServerConfig;
- import com.ozs.service.BaseCameraManagementService;
- import com.ozs.service.BaseTerminalLogService;
- import com.ozs.service.BaseTerminalService;
- import com.ozs.service.MsgHeartbeatAlarmMessageService;
- import com.ozs.system.mapper.SysDictDataMapper;
- import com.ozs.system.service.ISysDictTypeService;
- import lombok.SneakyThrows;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.util.ObjectUtils;
- import javax.annotation.PostConstruct;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileFilter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.OutputStreamWriter;
- import java.io.PrintWriter;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.time.Duration;
- import java.time.Instant;
- import java.time.LocalDateTime;
- import java.time.OffsetDateTime;
- import java.time.ZoneOffset;
- import java.time.ZonedDateTime;
- import java.time.format.DateTimeFormatter;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.Random;
- import java.util.Set;
- import java.util.UUID;
- import java.util.concurrent.Callable;
- import java.util.concurrent.CompletableFuture;
- import java.util.concurrent.ExecutionException;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.TimeUnit;
- import java.util.concurrent.TimeoutException;
- import java.util.stream.Collectors;
- /**
- * 相机工具
- */
- @Configuration
- @Slf4j
- public class CameraUtil {
- private static final ExecutorService executor = Executors.newFixedThreadPool(20);
- private static String historyUrl;
- private static String ffmpegPath;
- private static String filePath;
- private static String transcribeFilePath;
- private static String webUrl;
- private static String bakUrl;
- private static String bakUrlRtsp;
- private static String wsUrl;
- private static String wsUrls;
- private static String httpUrl;
- private static String httpUrls;
- private static CmdCameraUtil cUtil;
- private static RedisCache rc;
- private static ServerConfig sc;
- private static String recordUrl;
- private static String hkUrl;
- private static String host;
- private static String appKey;
- private static String appSecret;
- private static String rtmpUrl;
- @Autowired
- private CaneraConfig caneraConfig;
- @Autowired
- private CmdCameraUtil cmdCameraUtil;
- @Autowired
- private SysDictDataMapper dictDataMapper;
- @Autowired
- private RedisCache redisCache;
- @Autowired
- private ServerConfig serverConfig;
- @Autowired
- private BaseTerminalService baseTerminalService;
- @Autowired
- private MsgHeartbeatAlarmMessageService msgHeartbeatAlarmMessageService;
- @Autowired
- private ISysDictTypeService dictTypeService;
- @Autowired
- private RtspToMP4 rtspToMP4;
- @Autowired
- private BaseCameraManagementService baseCameraManagementService;
- @Autowired
- private BaseTerminalLogService baseTerminalLogService;
- private Map<String, Process> map = new HashMap<>();
- public final static String tsFilekey = "mergeVideoTsFile";
- /**
- * 历史回放
- *
- * @param fromVideoFileList
- * @param ph
- * @return
- * @throws IOException
- */
- public static String historyPlay(List<String> fromVideoFileList, String ph, boolean flay) {
- // 视频服务映射路径
- String NewfilePath = BaseConfig.getProfile() + "/" + ph;
- log.info("NewfilePath:{}", NewfilePath);
- log.info("fromVideoFileList:{}", fromVideoFileList);
- if (ObjectUtils.isEmpty(fromVideoFileList) || fromVideoFileList.size() <= 0) {
- throw new BaseException("当前相机无视频录像");
- }
- executor.submit(new Runnable() {
- @Override
- public void run() {
- try {
- txConvetor(fromVideoFileList, NewfilePath, flay);
- } catch (IOException e) {
- log.error(e.getMessage());
- e.printStackTrace();
- }
- }
- });
- // executor.shutdown();
- return Constants.RESOURCE_PREFIX + "/" + ph;
- }
- @SneakyThrows
- public static void txConvetor(List<String> fromVideoFileList,
- String newfilePath,
- boolean fly) throws IOException {
- /*
- * ffmpeg -i 20230411_155847_155947-d4c2265d-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 1.ts
- ffmpeg -i 20230411_155948_160048-f91fea03-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 2.ts
- ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
- * */
- File file = new File(newfilePath);
- boolean flay = false;
- if (!file.getParentFile().exists()) {
- boolean mkdirs = file.getParentFile().mkdirs();
- log.info("创建文件夹:{}", file.getParentFile().getPath());
- log.info("创建文件夹结果:{}", mkdirs);
- flay = true;
- }
- cUtil.cmd("chomd -R 777 " + file.getParentFile().getPath());
- log.info("newfilePath:{}", newfilePath);
- StringBuffer sm = new StringBuffer(ffmpegPath + " -i \"concat:");
- List<String> fileTs = new ArrayList<>();
- for (int t = 0; t < fromVideoFileList.size(); t++) {
- File ft = new File(fromVideoFileList.get(t));
- if (ft.exists()) {
- log.info("file:{}", fromVideoFileList.get(t));
- String substring = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("."));
- int x;//定义两变量
- Random ne = new Random();//实例化一个random的对象ne
- x = ne.nextInt(9999 - 1000 + 1) + 1000;//为变量赋随机值1000-9999
- substring = substring + x;//定义两变量
- String cmdstr = ffmpegPath + " -i " + fromVideoFileList.get(t) + " -c:v copy " + substring + ".ts";
- log.info("转换命令:{}", cmdstr);
- cUtil.cmd(cmdstr);
- fileTs.add(substring + ".ts");
- if (t != fromVideoFileList.size() - 1) {
- sm.append(substring + ".ts|");
- } else {
- sm.append(substring + ".ts\" ");
- }
- }
- }
- if (fileTs.size() > 0) {
- Map<String, Object> mergeVideoTsFile = rc.getCacheMap(tsFilekey);
- if (ObjectUtils.isEmpty(mergeVideoTsFile)) {
- mergeVideoTsFile = new HashMap<>();
- }
- if (!flay) {
- // 如果没有解除,把生成的文件放入要删除的定时任务 redis key 中
- fileTs.add(newfilePath);
- }
- mergeVideoTsFile.put(System.currentTimeMillis() + "", fileTs);
- rc.deleteObject(tsFilekey);
- if (mergeVideoTsFile.size() > 0) {
- rc.setCacheMap(tsFilekey, mergeVideoTsFile);
- }
- sm.append("-c copy " + newfilePath);
- log.info("合并命令:{}", sm.toString());
- cUtil.cmd(sm.toString());
- }
- }
- /**
- * 实时播放的拼接流
- *
- * @param cameraCode 相机编码
- * @param channel 相机通道
- * @return
- */
- public static String getPlayFlv(String cameraCode, String channel, boolean flay, String state) {
- log.info("getPlayFlv----master---------" + wsUrl);
- return wsUrl + "/ws/" + cameraCode + "/" + channel + ".flv";
- // if (!flay) {
- // return bakUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- // }
- // return webUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- }
- public static String getPlayFlv(String cameraCode, String channel, boolean flay) {
- if (!flay) {
- return bakUrl + "/hdl/" + cameraCode + "/" + channel + ".flv";
- }
- return wsUrl + "/ws/" + cameraCode + "/" + channel + ".flv";
- // if (!flay) {
- // return bakUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- // }
- // return webUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- }
- /**
- * Rtsp实时播放的拼接流 心跳接口使用
- *
- * @param cameraCode 相机编码
- * @param channel 相机通道
- * @return
- */
- public static String getPlayFlvRtsp(String cameraCode, String channel, boolean flay, String url) {
- log.info("---------getPlayFlvRtsp----url--" + url);
- if (url.contains("10.48.31.84")) {
- log.info("-----getPlayFlvRtsp------11------>" + bakUrlRtsp + "/master/hdl/" + cameraCode + "/" + channel + ".flv");
- return bakUrlRtsp + "/master/hdl/" + cameraCode + "/" + channel + "/h264_720.flv";
- } else {
- log.info("-------getPlayFlvRtsp----22------>" + bakUrlRtsp + "/slave/hdl/" + cameraCode + "/" + channel + ".flv");
- return bakUrlRtsp + "/slave/hdl/" + cameraCode + "/" + channel + "/h264_720.flv";
- }
- // if (!flay) {
- // return bakUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- // }
- // return webUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- }
- /**
- * 点播的时候使用
- *
- * @param cameraCode
- * @param channel
- * @param flay
- * @return
- */
- public static String getPlayFlvRtsps(String cameraCode, String channel, boolean flay) {
- if (!flay) {
- log.info("-----getPlayFlvRtsps------11------>" + bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv");
- return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv";
- }
- log.info("-------getPlayFlvRtsps----22------>" + bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv");
- return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv";
- // if (!flay) {
- // return bakUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- // }
- // return webUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
- }
- /**
- * web页面实时流接口
- *
- * @param cameraCode
- * @param channel
- * @return
- */
- public String getPlayFlv(String cameraCode, String channel) {
- int maxRetries = 3;
- int retryCount = 0;
- boolean success = false;
- JSONArray jsonArray = null;
- List<String> pathList = new ArrayList<>();
- String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
- if (StringUtils.isNotEmpty(data)) {
- log.info("---------------data---" + data);
- while (!success && retryCount < maxRetries) {
- try {
- jsonArray = JSONArray.parseArray(data);
- success = true;
- } catch (Exception e) {
- e.printStackTrace();
- log.info("Exception caught: " + e.getMessage());
- // 增加重试计数
- retryCount++;
- }
- }
- log.info("---------------jsonArray---" + jsonArray);
- if (!ObjectUtils.isEmpty(jsonArray)) {
- for (int i = 0; i < jsonArray.size(); i++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- String name = jsonObject.getString("Path");
- pathList.add(name);
- }
- boolean contains = pathList.contains(cameraCode + "/" + channel);
- if (contains) {
- String cacheObject = redisCache.getCacheObject(cameraCode);
- return getPlayFlv(cameraCode, channel, true, cacheObject);
- } else {
- /**
- * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
- * jsonBody.put("streamType", 0);
- * jsonBody.put("protocol","rtsp");
- * jsonBody.put("transmode", 1);
- * jsonBody.put("expand","streamform=rtp");
- */
- CamerasVo camerasVo = new CamerasVo();
- camerasVo.setCameraIndexCode(cameraCode);
- String urLs = previewURLs(camerasVo, channel, httpUrl);
- log.info("web实时流---" + urLs);
- if (!urLs.contains("无视频")) {
- return getPlayFlv(cameraCode, channel, true, urLs);
- } else {
- return urLs;
- }
- }
- } else {
- CamerasVo camerasVo = new CamerasVo();
- camerasVo.setCameraIndexCode(cameraCode);
- String urLs = previewURLs(camerasVo, channel, httpUrl);
- log.info("web实时流---" + urLs);
- if (!urLs.contains("无视频")) {
- return getPlayFlv(cameraCode, channel, true, urLs);
- } else {
- return urLs;
- }
- }
- } else {
- CamerasVo camerasVo = new CamerasVo();
- camerasVo.setCameraIndexCode(cameraCode);
- String urLs = previewURLs(camerasVo, channel, httpUrl);
- if (!urLs.contains("无视频")) {
- return getPlayFlv(cameraCode, channel, true, urLs);
- } else {
- return urLs;
- }
- }
- }
- public String heartbeatgetPlayFlv(String cameraCode, String channel, boolean type) {
- int maxRetries = 3;
- int retryCount = 0;
- boolean success = false;
- JSONArray jsonArray = null;
- List<String> pathList = new ArrayList<>();
- //从redis中获取该相机的IP地址
- String cacheObject = redisCache.getCacheObject(cameraCode);
- if (StringUtils.isEmpty(cacheObject)) {
- cacheObject = httpUrl;
- }
- while (!success && retryCount < maxRetries) {
- try {
- String data = HttpUtils.sendGet(cacheObject + "/rtsp/api/list");
- log.info("data------------------>" + data);
- if (StringUtils.isNotEmpty(data)) {
- jsonArray = JSONArray.parseArray(data);
- success = true;
- }
- } catch (Exception e) {
- log.info("Exception caught: " + e.getMessage());
- // 增加重试计数
- retryCount++;
- }
- }
- log.info("jsonArray------------------>" + jsonArray);
- if (!ObjectUtils.isEmpty(jsonArray)) {
- for (int i = 0; i < jsonArray.size(); i++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- String name = jsonObject.getString("Path");
- pathList.add(name);
- }
- boolean contains = pathList.contains(cameraCode + "/" + channel);
- if (!contains) {
- return null;
- } else {
- return getPlayFlvRtsp(cameraCode, channel, type, cacheObject);
- }
- }
- return null;
- }
- public List<String> rtspApiList() {
- List<String> pathList = new ArrayList<>();
- String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
- log.info("data------------------>" + data);
- if (StringUtils.isNotEmpty(data)) {
- JSONArray jsonArray = JSONArray.parseArray(data);
- log.info("jsonArray------------------>" + jsonArray);
- if (!ObjectUtils.isEmpty(jsonArray)) {
- for (int i = 0; i < jsonArray.size(); i++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- String name = jsonObject.getString("Path");
- pathList.add(name);
- }
- return pathList;
- }
- return null;
- }
- return null;
- }
- public String heartbeatgetUrl(String cameraCode, String channel, boolean type, String url) throws Exception {
- CamerasVo camerasVo = new CamerasVo();
- camerasVo.setCameraIndexCode(cameraCode);
- String s = previewURLs(camerasVo, channel, url);
- log.info("-------heartbeatgetUrl---------" + s);
- if (s.contains("无视频")) {
- log.info("-------无视频---------");
- return s;
- } else {
- log.info("-------getPlayFlvRtsp---------" + getPlayFlvRtsp(cameraCode, channel, type, url));
- return getPlayFlvRtsp(cameraCode, channel, type, url);
- }
- }
- public String heartbeatgetUrls(String cameraCode, String channel, boolean type) throws Exception {
- CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
- CamerasVo camerasVo = new CamerasVo();
- camerasVo.setCameraIndexCode(cameraCode);
- String s = previewURLs(camerasVo, channel, httpUrl);
- if (s.contains("无视频")) {
- return s;
- } else {
- return getPlayFlvRtsps(cameraCode, channel, type);
- }
- });
- return future.get();
- }
- public static String invite(String cameraCode, String channel) {
- String result = null;
- String url = bakUrl + "/api/gb28181/invite?id=" + cameraCode + "&channel=" + channel;
- try {
- result = HttpClientUtil.get(url);
- log.info("result:{}", result);
- } catch (Exception e) {
- log.info(e.getMessage());
- e.printStackTrace();
- }
- return result;
- }
- /**
- * 开启录制功能
- *
- * @param cameraCode 相机编码
- * @param channel 相机通道
- * @return
- */
- public static String startRecording(String cameraCode, String channel) {
- log.info("-----startRecording------" + historyUrl + "/recordpro/api/start?streamPath=" + cameraCode + "/" + channel + "&type=mp4");
- return historyUrl + "/recordpro/api/start?streamPath=" + cameraCode + "/" + channel + "&type=mp4";
- }
- /**
- * 关闭录制功能
- *
- * @param taskId 录像接口返回的任务ID
- * @return
- */
- public static String endRecording(String taskId) {
- return historyUrl + "/recordpro/api/stop?id=" + taskId;
- }
- /**
- * 历史回放流(获取)
- *
- * @param channel 相机通道
- * @param startTm 开始时间
- * @param endTm 结束时间
- * @return
- */
- public static String historyPlayListStr(String channel, Date startTm, Date endTm, boolean flay) {
- List<String> list = filterPlayList(channel, startTm, endTm, filePath);
- String uuid = UUID.randomUUID().toString();
- String ph = "record/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
- + "/" + channel + "/"
- + uuid + ".mp4";
- if (!ObjectUtils.isEmpty(list)) {
- try {
- return historyPlay(list, ph, flay);
- } catch (Exception e) {
- log.error(e.getMessage());
- e.printStackTrace();
- }
- } else {
- throw new BaseException("当前相机无视频录像");
- }
- return null;
- }
- /**
- * 过滤符合条件的视频
- *
- * @param channel
- * @param startTm
- * @param endTm
- * @param mappingUrl
- * @return
- */
- public static List<String> filterPlayList(String channel, Date startTm, Date endTm, String mappingUrl) {
- if (StringUtils.isBlank(channel)
- || ObjectUtils.isEmpty(startTm)
- || ObjectUtils.isEmpty(endTm)) {
- return null;
- }
- List<String> ls = new ArrayList<>();
- Map<Date, String> m = new HashMap<>();
- // 调用视频服务返回参数
- String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
- String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
- String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
- String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
- // 视频拼接
- if (!StringUtils.isBlank(s) && !"null".equals(s) && !s.startsWith("<!DOCTYPE html>")) {
- List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
- if (ObjectUtils.isEmpty(maps)) {
- return null;
- }
- for (Map<String, Object> map : maps) {
- Object path = map.get("Path");
- if (!ObjectUtils.isEmpty(path)) {
- 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);
- if (s2[1].startsWith("23") && s2[2].startsWith("00")) {
- sdate = DateUtils.addDays(sdate, -1);
- }
- Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
- /* sdate |startTm| edate |endTm| */
- if (startTm.compareTo(sdate) >= 0
- && startTm.compareTo(edate) <= 0
- && endTm.compareTo(edate) >= 0) {
- m.put(sdate, mappingUrl + path.toString());
- /* |startTm| sdate edate |endTm| */
- } else if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) >= 0) {
- m.put(sdate, mappingUrl + path.toString());
- /* |startTm| sdate |endTm| edate */
- } else if (startTm.compareTo(sdate) <= 0
- && endTm.compareTo(sdate) >= 0
- && endTm.compareTo(edate) <= 0) {
- m.put(sdate, mappingUrl + path.toString());
- /* sdate |startTm| |endTm| edate */
- } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) <= 0) {
- m.put(sdate, mappingUrl + path.toString());
- }
- }
- }
- }
- }
- if (!ObjectUtils.isEmpty(m) && m.size() > 0) {
- Set<Date> dates = m.keySet();
- // 排序
- dates.stream().parallel().collect(Collectors.toList()).stream().sorted().forEach(d -> {
- ls.add(m.get(d));
- });
- return ls;
- }
- return null;
- }
- /**
- * 合并视频(转化文件)
- *
- * @param fromVideoFileList 视频路径
- * @param newfilePath 生产新的视频文件路径
- * @throws IOException
- */
- public static Map<String, String> myConvetor(List<String> fromVideoFileList,
- String newfilePath,
- String uuid) throws IOException {
- /*
- * for f in *.flv; do echo "file '$f'" >> mylist.txt; done
- ffmpeg -f concat -i mylist.txt -c copy output.flv
- * */
- File file = new File(newfilePath);
- boolean flay = false;
- if (!file.getParentFile().exists()) {
- file.getParentFile().mkdirs();
- log.info("创建文件夹:{}", file.getParentFile().getPath());
- flay = true;
- }
- log.info("newfilePath:{}", newfilePath);
- StringBuffer sm = new StringBuffer("for f in ");
- String pathStr = null;
- for (int t = 0; t < fromVideoFileList.size(); t++) {
- File ft = new File(fromVideoFileList.get(t));
- if (ft.exists()) {
- if (t != fromVideoFileList.size() - 1) {
- // sm.append(fromVideoFileList.get(t) + " ");
- sm.append(fromVideoFileList.get(t).substring(fromVideoFileList.get(t).lastIndexOf("/") + 1, fromVideoFileList.get(t).length()) + " ");
- } else {
- // sm.append(fromVideoFileList.get(t));
- sm.append(fromVideoFileList.get(t).substring(fromVideoFileList.get(t).lastIndexOf("/") + 1, fromVideoFileList.get(t).length()));
- pathStr = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("/"));
- }
- }
- }
- // String substring = newfilePath.substring(0, newfilePath.lastIndexOf("."));
- // substring = substring + ".txt";
- String substring = uuid + ".txt";
- log.info("临时转化的文件:{}", substring);
- sm.append("; do echo \"file '$f'\" >> " + substring + "; done");
- String commit = sm.toString();
- log.info("合并转化文件的命令:{}", commit);
- Process proc = Runtime.getRuntime().exec("/bin/bash", null, null);
- BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);
- try {
- String commit1 = ffmpegPath + " -f concat -safe 0 -i " + pathStr + "/" + substring + " -c copy " + newfilePath;
- log.info("合并视频命令:{}", commit1);
- List<String> commands = new ArrayList<>();
- if (flay) {
- commands.add("chomd -R 777 " + file.getParentFile().getPath());
- }
- //
- commands.add("cd " + pathStr);
- // 合并成一个临时文件
- commands.add(commit);
- // 临时文件转化为 flv
- // commands.add(commit1);
- log.info("录像视频命令:{}", commands);
- for (String line : commands) {
- log.info("命令:{}", line);
- out.println(line);
- }
- out.println("exit");// 这个命令必须执行,否则in流不结束。
- log.info("命令:{}", "exit");
- String rspLine = "";
- while ((rspLine = in.readLine()) != null) {
- log.info("*****:{}", rspLine);
- }
- proc.waitFor();
- Map<String, String> map = new HashMap<>();
- map.put("cmd", commit1);
- map.put("path", pathStr + "/" + substring);
- return map;
- } catch (InterruptedException e) {
- log.error(e.getMessage());
- e.printStackTrace();
- } finally {
- in.close();
- out.close();
- proc.destroy();
- }
- return null;
- }
- @PostConstruct
- public void init() {
- historyUrl = caneraConfig.getHistoryUrl();
- ffmpegPath = caneraConfig.getFfmpegPath();
- filePath = caneraConfig.getFilePath();
- transcribeFilePath = caneraConfig.getTranscribeFilePath();
- webUrl = caneraConfig.getWebUrl();
- bakUrl = caneraConfig.getBakUrl();
- bakUrlRtsp = caneraConfig.getBakUrlRtsp();
- rc = redisCache;
- cUtil = cmdCameraUtil;
- sc = serverConfig;
- wsUrl = caneraConfig.getWsUrl();
- wsUrls = caneraConfig.getWsUrls();
- httpUrl = caneraConfig.getHttpUrl();
- httpUrls = caneraConfig.getHttpUrls();
- recordUrl = caneraConfig.getRecordUrl();
- hkUrl = caneraConfig.getHkUrl();
- host = caneraConfig.getHost();
- appKey = caneraConfig.getAppKey();
- appSecret = caneraConfig.getAppSecret();
- rtmpUrl = caneraConfig.getRtmpUrl();
- }
- /**
- * 定时任务参数flv文件
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void deleteFlv() throws IOException, InterruptedException {
- SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
- Date date = new Date();
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- calendar.add(Calendar.DATE, -1); //把日期往后增加一天,整数 往后推,负数往前移动
- date = calendar.getTime(); //这个时间就是日期往后推一天的结果
- String path = BaseConfig.getProfile() + "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
- File file = new File(path);
- if (file.exists()) {
- List<String> rspList = new ArrayList<String>();
- Process proc = Runtime.getRuntime().exec("/bin/bash", null, null);
- BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
- PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);
- String commit = " rm -rf " + path;
- List<String> commands = new ArrayList<>();
- // 删除
- commands.add(commit);
- log.info("删除昨天的录像视频命令:{}", commands);
- for (String line : commands) {
- out.println(line);
- }
- out.println("exit");// 这个命令必须执行,否则in流不结束。
- String rspLine = "";
- while ((rspLine = in.readLine()) != null) {
- System.out.println(rspLine);
- rspList.add(rspLine);
- }
- int i = proc.waitFor();
- log.info("执行结果:{}", i);
- in.close();
- out.close();
- proc.destroy();
- }
- }
- /**
- * 定时任务:删除超过配置时长的录制视频
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void deleteFlvExceed() throws IOException, InterruptedException, ParseException {
- //字典中设置的值
- List<SysDictData> sysCameraRecordTime = dictDataMapper.selectDictDataByType("sys_camera_record_time");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
- Date date = new Date();
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- //正数,日期天数加
- //负数,日期天数减 提前45天
- if (!ObjectUtils.isEmpty(sysCameraRecordTime)) {
- String dictValue = sysCameraRecordTime.get(0).getDictValue();
- calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt("-" + dictValue));
- } else {
- calendar.add(Calendar.DAY_OF_YEAR, -45);
- }
- date = calendar.getTime();
- //遍历每个进行视频录制的摄像头
- File file = new File(transcribeFilePath);
- log.info("file.Name()======================================" + file.getName());
- log.info("file.exists()======================================" + file.exists());
- if (file.exists() && file.isDirectory()) {
- //获取文件夹中所有的子文件夹和文件
- File[] files = file.listFiles();
- if (!ObjectUtils.isEmpty(files) && files.length > 0) {
- for (File file1 : files) {
- // file1=/opt/streams/record/flv/34020000001320000167
- log.info("file1.Name()======================================" + file1.getName());
- if (file1.exists() && file1.isDirectory()) {
- //相机文件
- File[] fs = file1.listFiles();
- if (!ObjectUtils.isEmpty(fs) && fs.length > 0) {
- for (File f : fs) {
- // f=/opt/streams/record/flv/34020000001320000167/20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
- //fName=20230328_192033_192037-91509173-cd5a-11ed-8a42-fa163e4e1e9f.flv
- String fName = f.getName();
- log.info("fName======================================" + fName);
- String[] split = fName.split("_");
- if (split.length > 0) {
- //20230328
- String s = split[0];
- Date parse = sdf.parse(s);
- long fTime = parse.getTime();
- long dateTime = date.getTime();
- //删除过期文件
- if (fTime < dateTime) {
- f.delete();
- }
- }
- }
- }
- }
- }
- }
- }
- }
- public static File[] getCurFilesList(String filePath) {
- File path = new File(filePath);
- File[] listFiles = path.listFiles(new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- if (pathname.isFile()) {
- return true;
- } else {
- return false;
- }
- }
- });
- return listFiles;
- }
- public static void execute(String command) {
- try {
- ProcessBuilder process = new ProcessBuilder(command);
- process.inheritIO().start().waitFor();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * web页面视频回放接口
- *
- * @param code
- * @param startTm
- * @param endTm
- * @return
- */
- public static String getRecordList(String code, Date startTm, Date endTm, String channel) {
- PlaybackVo playbackVo = new PlaybackVo();
- playbackVo.setCameraIndexCode(code);
- // 将 Date 转换为 Instant
- Instant startInstant = startTm.toInstant();
- Instant endInstant = endTm.toInstant();
- // 将 Instant 转换为 OffsetDateTime
- OffsetDateTime startOffsetDateTime = startInstant.atOffset(ZoneOffset.UTC);
- OffsetDateTime endOffsetDateTime = endInstant.atOffset(ZoneOffset.UTC);
- // 格式化为字符串
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
- String formattedStartTime = startOffsetDateTime.format(formatter);
- String formattedEndTime = endOffsetDateTime.format(formatter);
- // 将格式化后的时间设置到 playbackVo 中
- playbackVo.setBeginTime(formattedStartTime);
- playbackVo.setEndTime(formattedEndTime);
- playbackVo.setProtocol("rtsp");
- playbackVo.setExpand("streamform=rtp");
- //对象转换json字符串
- String body = JSONObject.toJSONString(playbackVo);
- //调用天网接口
- String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
- if (StringUtils.isEmpty(playbackURLs)) {
- return "调用天网接口失败";
- }
- JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
- log.info("outJson-------->" + outJson);
- if ("0".equals(outJson.getString("code"))) {
- JSONObject data = outJson.getJSONObject("data");
- String urls = data.getString("url");
- log.info("urls----------->" + urls);
- try {
- TimeUnit.SECONDS.sleep(3);
- String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/" + channel + "&save=0");
- log.info("msg---------->" + msg);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return getPlayFlv(code, channel, true, "master");
- } else {
- return "调用天网接口失败";
- }
- // return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "profile/");
- }
- /**
- * HTTP流转RTSP流
- */
- public String streamConversion(String code) {
- ExecutorService executor = Executors.newSingleThreadExecutor();
- Callable<String> task = new Callable<String>() {
- @Override
- public String call() throws Exception {
- // 执行网络请求...
- log.info(ffmpegPath + " -re -i /opt/streams/map/70b0bd685b0d4df1b4faf74ff5c1e7fd.mp4 -c:v copy -c:a copy -f flv rtmp://10.48.36.47:1935/live/70b0bd685b0d4df1b4faf74ff5c1e7fd");
- cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/map/" + code + ".mp4 -c:v copy -c:a copy -f flv " + rtmpUrl + "/live/" + code);
- return "Response";
- }
- };
- try {
- String result = executor.submit(task).get(5, TimeUnit.SECONDS); // 设置5秒超时时间
- System.out.println("Response: " + result);
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- // 请求超时处理逻辑
- System.out.println("Request timeout");
- }
- executor.shutdown();
- return bakUrlRtsp + "/live/" + code + ".flv";
- }
- /**
- * RTSP流视频压缩
- */
- public void videoCompression(String code) {
- // 执行网络请求...
- /**
- * /usr/bin/ffmpeg -i /opt/streams/map/70b0bd685b0d4df1b4faf74ff5c1e7fd.mp4 -c:v libx264 -s 640x480 -c:a aac -ar 44100 /opt/streams/compress/70b0bd685b0d4df1b4faf74ff5c1e7fd.mp4
- */
- log.info(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a aac -ar 44100 /opt/streams/compress/" + code + ".mp4");
- cmdCameraUtil.cmd(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a aac -ar 44100 /opt/streams/compress/" + code + ".mp4");
- }
- public static List<Map<String, Object>> filterRecordList(String channel,
- Date startTm,
- Date endTm,
- String mappingUrl,
- String wUrl) {
- List<Map<String, Object>> rmaps = new ArrayList<>();
- if (StringUtils.isBlank(channel)
- || ObjectUtils.isEmpty(startTm)
- || ObjectUtils.isEmpty(endTm)) {
- return null;
- }
- Map<Date, Map<String, Object>> m = new HashMap<>();
- // 调用视频服务返回参数
- String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
- String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
- String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
- // /api/record/flv/list
- String s = HttpUtils.sendGet(webUrl + "/recordpro/api/list", param);
- // 视频拼接
- if (!StringUtils.isBlank(s) || "null".equals(s)) {
- List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
- if (ObjectUtils.isEmpty(maps)) {
- return null;
- }
- for (Map<String, Object> map : maps) {
- Object path = map.get("Path");
- Object size = map.get("Size");
- Object duration = map.get("Duration");
- if (!ObjectUtils.isEmpty(path)) {
- 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)) {
- Map<String, Object> mo = new HashMap<>();
- String s3 = s2[0] + s2[1];
- String s4 = s2[0] + s2[2];
- Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
- if (s2[1].startsWith("23") && s2[2].startsWith("00")) {
- sdate = DateUtils.addDays(sdate, -1);
- }
- Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
- mo.put("startTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sdate));
- mo.put("entTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, edate));
- mo.put("url", wUrl + path.toString());
- mo.put("path", mappingUrl + path.toString());
- mo.put("fileName", substring);
- mo.put("size", size);
- mo.put("duration", duration);
- /* sdate |startTm| edate |endTm| */
- if (startTm.compareTo(sdate) >= 0
- && startTm.compareTo(edate) <= 0
- && endTm.compareTo(edate) >= 0) {
- m.put(sdate, mo);
- /* |startTm| sdate edate |endTm| */
- } else if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) >= 0) {
- m.put(sdate, mo);
- /* |startTm| sdate |endTm| edate */
- } else if (startTm.compareTo(sdate) <= 0
- && endTm.compareTo(sdate) >= 0
- && endTm.compareTo(edate) <= 0) {
- m.put(sdate, mo);
- /* sdate |startTm| |endTm| edate */
- } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) <= 0) {
- m.put(sdate, mo);
- }
- }
- }
- }
- }
- if (!ObjectUtils.isEmpty(m) && m.size() > 0) {
- Set<Date> dates = m.keySet();
- // 排序
- dates.stream().parallel().collect(Collectors.toList()).stream().sorted().forEach(d -> {
- rmaps.add(m.get(d));
- });
- log.info("rmaps:{}", rmaps);
- return rmaps;
- }
- return null;
- }
- /**
- * 机车状态修改
- */
- public void heartbeat() {
- log.info("机车状态修改---------------执行了");
- List<BaseTerminal> list = baseTerminalService.list();
- for (BaseTerminal baseTerminal : list) {
- QueryWrapper<BaseTerminalLog> wrapper = new QueryWrapper<>();
- wrapper.eq("terminal_code", baseTerminal.getTerminalCode());
- wrapper.orderByDesc("create_time");
- wrapper.last("limit 1");
- BaseTerminalLog baseTerminalLog = baseTerminalLogService.getOne(wrapper);
- if (ObjectUtils.isEmpty(baseTerminalLog)) {
- baseTerminal.setStatus(2);
- baseTerminalService.updateById(baseTerminal);
- } else {
- List<SysDictData> heartbeat = dictTypeService.selectDictDataByType("heartbeat");
- long timeNow = System.currentTimeMillis();
- long createTime = baseTerminalLog.getCreateTime().getTime();
- int times = Integer.parseInt(heartbeat.get(0).getDictValue());
- long thereHourMillis = 60 * 1000 * 3 * times;
- long timeNew = timeNow - thereHourMillis;
- if (timeNew > createTime) {
- baseTerminal.setStatus(2);
- baseTerminalService.updateById(baseTerminal);
- } else {
- baseTerminal.setStatus(1);
- baseTerminalService.updateById(baseTerminal);
- }
- }
- }
- }
- public static String getCameraPreviewURL() {
- /**
- * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
- */
- ArtemisConfig.host = host; // 平台的ip端口
- ArtemisConfig.appKey = appKey; // 密钥appkey
- ArtemisConfig.appSecret = appSecret;// 密钥appSecret
- /**
- * STEP2:设置OpenAPI接口的上下文
- */
- final String ARTEMIS_PATH = "/artemis";
- /**
- * STEP3:设置接口的URI地址
- */
- final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/camera/advance/cameraList";
- Map<String, String> path = new HashMap<String, String>(2) {
- {
- put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
- }
- };
- /**
- * STEP4:设置参数提交方式
- */
- String contentType = "application/json";
- /**
- * STEP5:组装请求参数
- */
- JSONObject jsonBody = new JSONObject();
- jsonBody.put("pageNo", 1);
- jsonBody.put("pageSize", 999);
- String body = jsonBody.toJSONString();
- /**
- * STEP6:调用接口
- */
- String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null);// post请求application/json类型参数
- log.info("GetCameraPreviewURL----->" + result);
- return result;
- }
- /**
- * 天网接口
- *
- * @return
- */
- public static String getPreviewURLs(String url, String body) {
- long begin = System.currentTimeMillis();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- log.info("天网接口请求时间: " + sdf.format(new Date(begin)));
- /**
- * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
- */
- ArtemisConfig.host = host; // 平台的ip端口
- ArtemisConfig.appKey = appKey; // 密钥appkey
- ArtemisConfig.appSecret = appSecret;// 密钥appSecret
- /**
- * STEP2:设置OpenAPI接口的上下文
- */
- final String ARTEMIS_PATH = "/artemis";
- /**
- * STEP3:设置接口的URI地址
- */
- final String previewURLsApi = ARTEMIS_PATH + url;
- log.info("天网url:{}" + previewURLsApi);
- Map<String, String> path = new HashMap<String, String>(2) {
- {
- put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
- }
- };
- /**
- * STEP4:设置参数提交方式
- */
- String contentType = "application/json";
- /**
- * STEP6:调用接口
- */
- String result = null;// post请求application/json类型参数
- try {
- result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null);
- } catch (Exception e) {
- log.info("天网异常信息----->" + e.getMessage());
- }
- log.info("GetCameraPreviewURL----->" + result);
- long end = System.currentTimeMillis();
- log.info("接受天网接口相应时间: " + sdf.format(new Date(end)));
- log.info("天网接口请求用时时间:" + (end - begin) + "毫秒");
- return result;
- }
- /**
- * 车载终端实时流调用的远程天网接口
- *
- * @param camerasVo
- */
- public String apiPreviewURLs(CamerasVo camerasVo) {
- long begin = System.currentTimeMillis();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- StringBuilder stringBuilder = new StringBuilder();
- /**
- * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
- * jsonBody.put("streamType", 0);
- * jsonBody.put("protocol","rtsp");
- * jsonBody.put("transmode", 1);
- * jsonBody.put("expand","streamform=rtp");
- */
- camerasVo.setStreamType(0);
- camerasVo.setProtocol("rtsp");
- camerasVo.setTransmode(0);
- camerasVo.setExpand("streamform=rtp");
- String body = JSONObject.toJSONString(camerasVo);
- String previewURLs = getPreviewURLs("/api/video/v1/cameras/previewURLs", body);
- log.info("-------------------------------->>>>>previewURLs" + previewURLs);
- log.info("天网接口请求参数:{}" + camerasVo);
- if (StringUtils.isEmpty(previewURLs)) {
- log.info("天网接口异常");
- return "天网接口异常";
- } else {
- long end = System.currentTimeMillis();
- JSONObject outJson = JSONObject.parse(previewURLs);
- // stringBuilder.append("测试结果:" + ("0".equals(outJson.getString("code")) ? "成功" : "失败") + "\t");
- // stringBuilder.append("调用时间:" + sdf.format(new Date(begin)) + "\t");
- // stringBuilder.append("数据返回时间:" + sdf.format(new Date(end)) + "\t");
- // stringBuilder.append("延迟:" + (end - begin) + "毫秒");
- stringBuilder.append("结果:" + previewURLs);
- return stringBuilder.toString();
- }
- }
- public String stopStream(String cameraIndexCode, String channel) {
- try {
- //http://10.48.36.47:9080/api/gateway/stop?stream=0235538f5ec241abad7c29cb423f16bb/1
- log.info("code-----1111----->" + httpUrl + "/api/gateway/stop?stream=" + cameraIndexCode + "/" + channel + "/h264_720");
- String code = HttpClientUtil.getURL(httpUrl + "/api/gateway/stop?stream=" + cameraIndexCode + "/" + channel + "/h264_720");
- log.info("code---111111------->" + code);
- return code;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- public String hostStopStream(String straem) {
- try {
- //http://10.48.36.47:9080/api/gateway/stop?stream=0235538f5ec241abad7c29cb423f16bb/1
- log.info("code-----1111----->" + httpUrl + "/api/gateway/stop?stream=" + straem);
- String code = HttpClientUtil.getURL(httpUrl + "/api/gateway/stop?stream=" + straem);
- log.info("code---111111------->" + code);
- return code;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- /**
- * web页面实时流调用的远程天网接口
- *
- * @param camerasVo
- * @param channel
- */
- public static String previewURLs(CamerasVo camerasVo, String channel, String url) {
- /**
- * jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
- * jsonBody.put("streamType", 0);
- * jsonBody.put("protocol","rtsp");
- * jsonBody.put("transmode", 1);
- * jsonBody.put("expand","streamform=rtp");
- */
- camerasVo.setStreamType(0);
- camerasVo.setProtocol("rtsp");
- camerasVo.setTransmode(0);
- camerasVo.setExpand("streamform=rtp");
- String body = JSONObject.toJSONString(camerasVo);
- String previewURLs = getPreviewURLs("/api/video/v1/cameras/previewURLs", body);
- if (StringUtils.isEmpty(previewURLs)) {
- return "天网无视频-" + camerasVo.getCameraIndexCode();
- }
- log.info("-------------------------------->>>>>previewURLs" + previewURLs);
- log.info("-------------------------------->>>>>天网接口参数:{}" + camerasVo);
- JSONObject outJson = JSONObject.parse(previewURLs);
- if ("0".equals(outJson.getString("code"))) {
- log.info("outJson----->" + outJson);
- JSONObject data = outJson.getJSONObject("data");
- String urls = data.getString("url");
- log.info("urls----->" + urls);
- try {
- log.info("httpUrl---------->" + url + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
- long begin = System.currentTimeMillis();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- log.info("流媒体开始调用: " + sdf.format(new Date(begin)));
- String msg = HttpUtils.sendGet(url + "/rtsp/api/pull?target=" + urls + "&streamPath=" + camerasVo.getCameraIndexCode() + "/" + channel + "&save=0");
- long end = System.currentTimeMillis();
- log.info("流媒体结束调用: " + sdf.format(new Date(end)));
- log.info("流媒体请求用时时间:" + (end - begin) + "毫秒");
- log.info("msg---------->" + msg);
- if (!msg.contains("ok")) {
- return "暂无视频-" + camerasVo.getCameraIndexCode();
- }
- rc.setCacheObject(camerasVo.getCameraIndexCode(), url);
- return "ok";
- } catch (Exception e) {
- return "暂无视频-" + camerasVo.getCameraIndexCode();
- }
- } else {
- return "天网无视频-" + camerasVo.getCameraIndexCode();
- }
- }
- /**
- * 报警回放本地测试
- * 从天网拉回放流,然后根据url把流下载下来变成文件,然后进行视频压缩
- *
- * @param list
- * @param alarmPlayTimeValue
- */
- public String playbackURLs(String code, String frontValue, String laterValue) {
- try {
- log.info("--------------->playbackURLs-----异步开始-");
- log.info("frontValue------------->" + frontValue);
- log.info("laterValue------------->" + laterValue);
- TimeUnit.SECONDS.sleep(65 * Integer.parseInt(laterValue));
- log.info("--------------->playbackURLs");
- PlaybackVo playbackVo = new PlaybackVo();
- playbackVo.setCameraIndexCode(code);
- // 获取当前时间
- OffsetDateTime currentTime = OffsetDateTime.now();
- log.info("currentTime------------->" + currentTime);
- // 获取报警前的时间
- OffsetDateTime beforeTenMinutes = currentTime.minusMinutes(Long.parseLong(frontValue));
- log.info("beforeTenMinutes------------->" + beforeTenMinutes);
- // 获取报警后的时间
- OffsetDateTime afterTenMinutes = currentTime.plusMinutes(Long.parseLong(laterValue));
- log.info("afterTenMinutes------------->" + afterTenMinutes);
- // 格式化时间
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
- playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
- log.info("playbackVo.getBeginTime()------------->" + playbackVo.getBeginTime());
- playbackVo.setEndTime(afterTenMinutes.format(formatter));
- log.info("playbackVo.getEndTime()------------->" + playbackVo.getEndTime());
- // jsonBody.put("protocol","rtsp");
- // jsonBody.put("expand","streamform=rtp");
- playbackVo.setProtocol("rtsp");
- playbackVo.setExpand("streamform=rtp");
- //对象转换json字符串
- String body = JSONObject.toJSONString(playbackVo);
- //调用天网接口
- log.info("body----->" + body);
- //获取回放视频的url
- String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
- if (StringUtils.isEmpty(playbackURLs)) {
- return "天网无视频-" + code;
- }
- log.info("playbackURLs----->" + playbackURLs);
- JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
- if ("0".equals(outJson.getString("code"))) {
- log.info("outJson----->" + outJson);
- JSONObject data = outJson.getJSONObject("data");
- String urls = data.getString("url");
- log.info("--------------->urls::" + urls);
- //向流媒体推报警回放视频
- log.info("msg---------->" + httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- log.info("msg---------->" + msg);
- if (!msg.equals("ok")) {
- return "暂无视频-" + code;
- }
- /**
- * //两个流媒体的个数
- * //第一个是性能高的
- * int urlCount = urlCount(httpUrl);
- * //第二个是性能低的
- * int urlCounts = urlCount(httpUrls);
- * //向流媒体推报警回放视频
- * if (urlCount == 0) {
- * log.info("msg---------->" + httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * log.info("msg---------->" + msg);
- * if (!msg.equals("ok")) {
- * return "暂无视频-" + code;
- * }
- * return "master";
- * } else {
- * if (urlCounts * 2 > urlCount) {
- * log.info("msg---------->" + httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * log.info("msg---------->" + msg);
- * if (!msg.equals("ok")) {
- * return "暂无视频-" + code;
- * }
- * return "master";
- * } else {
- * log.info("msg---------->" + httpUrls + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * String msg = HttpUtils.sendGet(httpUrls + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
- * log.info("msg---------->" + msg);
- * if (!msg.equals("ok")) {
- * return "暂无视频-" + code;
- * }
- * return "slave";
- * }
- * }
- */
- // String FilePath = "/opt/streams/map/" + code + ".mp4";
- // Process process = rtspToMP4.StartRecord(ffmpegPath, urls, FilePath);
- // log.info("------playbackURLs----->>>>:" + process);
- // if (null != process) {
- // map.put(code, process);
- // }
- // try {
- // TimeUnit.SECONDS.sleep(204 * Integer.parseInt(alarmPlayTimeValue));
- // } catch (InterruptedException e) {
- // e.printStackTrace();
- // }
- // log.info("------videoCompression----->>>>:");
- // videoCompression(code);
- } else {
- return "天网无视频-" + code;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "正常";
- }
- public AjaxResult stop(String id) {
- if (map.containsKey(id)) {
- Process process = map.get(id);
- log.info("-----stop------>>>" + process);
- if (null != process) {
- rtspToMP4.stopRecord(process);
- return AjaxResult.success();
- }
- }
- return AjaxResult.error();
- }
- public static void main(String[] args) throws InterruptedException, ParseException, IOException {
- // CameraUtil cameraUtil = new CameraUtil();
- // cameraUtil.closeRecording();
- // String s = "/opt/streams/record/flv/42010001541320001116/20230403_235506_000506-22e1523b-d170-11ed-8a42-fa163e4e1e9f.flv";
- // String fileStr = s.substring(s.lastIndexOf("/") + 1, s.length());
- // String pathStr = s.substring(0, s.lastIndexOf("/"));
- // System.out.println(fileStr);
- // System.out.println(pathStr);
- String s = "20230403235512";
- Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s);
- sdate = DateUtils.addDays(sdate, -1);
- System.out.println(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, sdate));
- }
- public List<BaseCameraManagementResponse> heartbeatGetPlayFlv() {
- int maxRetries = 5;
- int retryCount = 0;
- boolean success = false;
- JSONArray streamArray = null;
- List<BaseCameraManagementResponse> baseCameraManagementResponseList = new ArrayList<>();
- while (!success && retryCount < maxRetries) {
- try {
- String data = HttpClientUtil.gets(webUrl + "/api/summary");
- log.info("data------------------>" + data);
- if (StringUtils.isNotEmpty(data)) {
- JSONObject jsonObject = JSONObject.parseObject(data);
- streamArray = jsonObject.getJSONArray("Streams");
- success = true;
- }
- } catch (Exception e) {
- // 增加重试计数
- retryCount++;
- }
- }
- for (int i = 0; i < streamArray.size(); i++) {
- BaseCameraManagementResponse baseCameraManagementResponse = new BaseCameraManagementResponse();
- JSONObject subObj = streamArray.getJSONObject(i);
- String subValue = subObj.getString("Subscribers");
- String PathValue = subObj.getString("Path");
- String type = subObj.getString("Type");
- String timestampString = subObj.getString("StartTime");
- ZonedDateTime givenTime = ZonedDateTime.parse(timestampString);
- // 当前时间
- Instant currentTime = Instant.now();
- // 将给定时间转换为Instant对象
- Instant givenInstant = givenTime.toInstant();
- // 计算时间差
- Duration duration = Duration.between(givenInstant, currentTime);
- //封装
- // 获取小时差
- baseCameraManagementResponse.setStartTime(duration.toHours() + "小时前");
- baseCameraManagementResponse.setStreamPath(PathValue);
- baseCameraManagementResponse.setSubscribers(subValue);
- baseCameraManagementResponse.setType(type);
- // 寻找第一个斜杠的位置
- int slashIndex = PathValue.indexOf("/");
- if (slashIndex != -1) {
- BaseCameraManagementResponse response = new BaseCameraManagementResponse();
- String result = PathValue.substring(0, slashIndex);
- BaseCameraManagement cameraManagement = baseCameraManagementService.getOne(new LambdaQueryWrapper<BaseCameraManagement>()
- .eq(BaseCameraManagement::getCameraCode, result));
- if (!ObjectUtils.isEmpty(cameraManagement)) {
- baseCameraManagementResponse.setCameraCode(cameraManagement.getCameraCode());
- baseCameraManagementResponse.setInstallMile(cameraManagement.getInstallMile());
- }
- }
- //取出AudioTracks
- JSONArray audioJson = subObj.getJSONArray("AudioTracks");
- if (audioJson != null && audioJson.size() > 0) {
- for (int v = 0; v < audioJson.size(); v++) {
- BaseCameraManagementResponse.AudioTracks audioTracks = new BaseCameraManagementResponse.AudioTracks();
- JSONObject arrayJSONObject = audioJson.getJSONObject(v);
- String name = arrayJSONObject.getString("Name");
- String sampleRate = arrayJSONObject.getString("SampleRate");
- String channels = arrayJSONObject.getString("Channels");
- String bps = arrayJSONObject.getString("BPS");
- audioTracks.setBps(bps);
- audioTracks.setChannels(channels);
- audioTracks.setName(name);
- audioTracks.setSampleRate(sampleRate);
- baseCameraManagementResponse.setAudioTracks(audioTracks);
- }
- }
- //取出VideoTracks
- JSONArray videoJson = subObj.getJSONArray("VideoTracks");
- if (videoJson != null && videoJson.size() > 0) {
- for (int v = 0; v < videoJson.size(); v++) {
- BaseCameraManagementResponse.VideoTracks videoTracks = new BaseCameraManagementResponse.VideoTracks();
- JSONObject arrayJSONObject = videoJson.getJSONObject(v);
- String name = arrayJSONObject.getString("Name");
- String width = arrayJSONObject.getString("Width");
- String height = arrayJSONObject.getString("Height");
- String resolution = width + "*" + height;
- String gop = arrayJSONObject.getString("GOP");
- String bps = arrayJSONObject.getString("BPS");
- videoTracks.setBps(bps);
- videoTracks.setGop(gop);
- videoTracks.setName(name);
- videoTracks.setResolution(resolution);
- baseCameraManagementResponse.setVideoTracks(videoTracks);
- }
- }
- baseCameraManagementResponseList.add(baseCameraManagementResponse);
- }
- return baseCameraManagementResponseList;
- }
- public void removePlayFlv(Integer lineDir, Integer currentMile, Integer visualDistance) {
- LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<>();
- if (lineDir == 1) {
- wrapper.gt(BaseCameraManagement::getEndMile, currentMile + visualDistance)
- .in(BaseCameraManagement::getMonitoringDirection, 1, 3);
- } else if (lineDir == 2) {
- wrapper.lt(BaseCameraManagement::getBeginMile, currentMile - visualDistance)
- .in(BaseCameraManagement::getMonitoringDirection, 2, 3);
- }
- wrapper.eq(BaseCameraManagement::getEnableOrNot, 1);
- //获取应该注销的相机
- List<BaseCameraManagement> list = baseCameraManagementService.list(wrapper);
- ArrayList<String> codeList = new ArrayList<>();
- if (!ObjectUtils.isEmpty(list)) {
- for (BaseCameraManagement baseCameraManagement : list) {
- codeList.add(baseCameraManagement.getCameraCode() + "/" + baseCameraManagement.getGraphicsCard());
- }
- }
- String data = HttpUtils.sendGet(webUrl + "/api/summary");
- log.info("data------------------>" + data);
- ArrayList<String> arrayList = new ArrayList();
- if (StringUtils.isNotEmpty(data)) {
- JSONObject jsonObject = JSONObject.parseObject(data);
- log.info("jsonObject------------------>" + jsonObject);
- JSONArray streamArray = jsonObject.getJSONArray("Streams");
- log.info("streamArray------------------>" + streamArray);
- if (!ObjectUtils.isEmpty(streamArray)) {
- for (int i = 0; i < streamArray.size(); i++) {
- JSONObject subObj = streamArray.getJSONObject(i);
- log.info("subObj------------------>" + subObj);
- String subValue = subObj.getString("Subscribers");
- String pathValue = subObj.getString("Path");
- //从缓存取出预拉的流的集合
- log.info("subValue------------------>" + subValue);
- log.info("pathValue------------------>" + pathValue);
- //判断主码流是否订阅者是2
- if (subValue.equals("0")) {
- arrayList.add(pathValue);
- }
- }
- }
- }
- if (!ObjectUtils.isEmpty(codeList) && !ObjectUtils.isEmpty(arrayList)) {
- codeList.retainAll(arrayList);
- if (!ObjectUtils.isEmpty(codeList)) {
- for (String pathValue : codeList) {
- hostStopStream(pathValue);
- }
- }
- }
- }
- /**
- * 根据相机ID找出分组并排序
- *
- * @param baseCameraManagement
- */
- public List<BaseCameraManagement> getBaseCameraManagementList(Long id, Integer line) {
- //根据ID获取当前相机的信息
- BaseCameraManagement baseCameraManagement = baseCameraManagementService.getById(id);
- if (!ObjectUtils.isEmpty(baseCameraManagement)) {
- LambdaQueryWrapper<BaseCameraManagement> wrapper = new LambdaQueryWrapper<>();
- //找出同一分组的相机
- wrapper.eq(BaseCameraManagement::getGrou, baseCameraManagement.getGrou());
- if (line == 1) {
- wrapper.orderByAsc(BaseCameraManagement::getSort);
- } else if (line == 2) {
- wrapper.orderByDesc(BaseCameraManagement::getSort);
- }
- List<BaseCameraManagement> list = baseCameraManagementService.list(wrapper);
- if (!ObjectUtils.isEmpty(list)) {
- return list;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
- /**
- * 根据设备id和通道ID和日期获取设备录像文件
- *
- * @param baseCameraManagement
- */
- public String getQueryRecords(String streamPath, String date, String type, String start,String end) {
- log.info("-----getQueryRecords------streamPath-----" + streamPath);
- log.info("-----getQueryRecords-------date----" + date);
- log.info("-----getQueryRecords-------type----" + type);
- try {
- TimeUnit.SECONDS.sleep(60 * (Integer.parseInt(start)+Integer.parseInt(end)));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- String param = "{\n" +
- " \"streamPath\":\"" + streamPath + "\",\n" +
- " \"date\":\"" + date + "\",\n" +
- " \"type\":\"" + type + "\"\n" +
- "}";
- String jsonStr = HttpUtils.sendPost(httpUrl + "/recordpro/api/query/records", param);
- log.info("-----getQueryRecords-------jsonStr----" + jsonStr);
- JSONObject jsonObj = JSON.parseObject(jsonStr);
- log.info("-----getQueryRecords-------jsonObj----" + jsonObj);
- JSONArray resultArray = jsonObj.getJSONArray("result");
- log.info("-----getQueryRecords-------resultArray----" + resultArray);
- if (!ObjectUtils.isEmpty(resultArray)) {
- ArrayList<String> list = new ArrayList<>();
- for (int i = 0; i < resultArray.size(); i++) {
- JSONObject subObj = resultArray.getJSONObject(i);
- String size = subObj.getString("Size");
- String path = subObj.getString("Path");
- Object created = subObj.get("Created");
- //从缓存取出预拉的流的集合
- log.info("size------------------>" + size);
- log.info("path------------------>" + path);
- log.info("created------------------>" + created);
- //判断主码流是否订阅者是2
- if (Integer.valueOf(size) > 1000) {
- list.add(created + "=" + path);
- }
- }
- String records = records(list);
- log.info("-----getQueryRecords-------records----" + records);
- String[] split = records.split("=");
- return caneraConfig.getRecordUrl() + Constants.RESOURCE_PREFIX + split[1];
- }
- return null;
- }
- public String records(List<String> objects) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXX");
- OffsetDateTime maxTime = null;
- for (String timeString : objects) {
- String[] split = timeString.split("=");
- OffsetDateTime time = OffsetDateTime.parse(split[0], formatter);
- if (maxTime == null || time.isAfter(maxTime)) {
- maxTime = time;
- }
- }
- Iterator<String> iter = objects.iterator();
- while (iter.hasNext()) {
- String timeString = iter.next();
- String[] split = timeString.split("=");
- OffsetDateTime time = OffsetDateTime.parse(split[0], formatter);
- if (!time.isEqual(maxTime)) {
- iter.remove();
- }
- }
- return objects.get(0);
- }
- /**
- * 流媒体的条数
- *
- * @return
- */
- // public static int urlCount(String url) {
- // long begin = System.currentTimeMillis();
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- // log.info("urlCountf方法开始时间: " + sdf.format(new Date(begin)));
- // int maxRetries = 5;
- // int retryCount = 0;
- // int count = 0;
- // boolean success = false;
- // JSONArray streamArray = null;
- // while (!success && retryCount < maxRetries) {
- // try {
- // String data = HttpClientUtil.gets(url + "/api/summary");
- // log.info("data------------------>" + data);
- // if (StringUtils.isNotEmpty(data)) {
- // JSONObject jsonObject = JSONObject.parseObject(data);
- // streamArray = jsonObject.getJSONArray("Streams");
- // success = true;
- // }
- // } catch (Exception e) {
- // log.info("Exception caught: " + e.getMessage());
- // // 增加重试计数
- // retryCount++;
- // }
- // }
- // long zhong = System.currentTimeMillis();
- // log.info("urlCountf方法循环时间: " + sdf.format(new Date(zhong)));
- // if (!ObjectUtils.isEmpty(streamArray)) {
- //// for (int i = 0; i < streamArray.size(); i++) {
- //// JSONObject subObj = streamArray.getJSONObject(i);
- //// String PathValue = subObj.getString("Path");
- //// if (PathValue.contains("/h264_720")) {
- //// count++;
- //// }
- //// }
- // long end = System.currentTimeMillis();
- // log.info("urlCountf方法结束时间: " + sdf.format(new Date(end)));
- // return streamArray.size();
- // } else {
- // long end = System.currentTimeMillis();
- // log.info("urlCountf方法结束时间: " + sdf.format(new Date(end)));
- // return count;
- // }
- // }
- }
|