修改 report 时间 字段类型
This commit is contained in:
parent
dda2d2fc07
commit
d1829901bf
@ -1,14 +1,9 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.report;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ -26,23 +21,18 @@ public class ReportReq {
|
||||
@Schema(description = "点播时长")
|
||||
private TimeRange timeRange;
|
||||
|
||||
@DateTimeFormat(pattern= DatePattern.NORM_DATETIME_PATTERN)
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||
@Schema(description = "日志记录时间")
|
||||
private Date logTime;
|
||||
private String logTime;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class TimeRange {
|
||||
@DateTimeFormat(pattern= DatePattern.NORM_DATETIME_PATTERN)
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||
@Schema(description = "开始时间")
|
||||
private Date startTime;
|
||||
@DateTimeFormat(pattern= DatePattern.NORM_DATETIME_PATTERN)
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
private Date endTime;
|
||||
private String endTime;
|
||||
}
|
||||
|
||||
@Schema(description = "文件大小, 未知大小为 -1")
|
||||
|
@ -27,7 +27,6 @@ import cn.skcks.docking.gb28181.service.ssrc.SsrcService;
|
||||
import cn.skcks.docking.gb28181.wvp.config.MediaRtmpConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.ProxySipConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.report.ReportReq;
|
||||
import cn.skcks.docking.gb28181.wvp.executor.DefaultVideoExecutor;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
|
||||
@ -232,7 +231,7 @@ public class Gb28181DownloadService {
|
||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||
} else if (wvpProxyConfig.getUseFfmpeg()) {
|
||||
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), new ReportReq.TimeRange(startTime, endTime), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), startTime, endTime, DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
DateTime end = DateUtil.date();
|
||||
asyncContext.complete();
|
||||
log.info("下载总耗时: {}, deviceCode {}, startTime {}, endTime {}", DateUtil.between(start, end, DateUnit.SECOND), deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
@ -377,7 +376,7 @@ public class Gb28181DownloadService {
|
||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||
} else if(wvpProxyConfig.getUseFfmpeg()){
|
||||
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), new ReportReq.TimeRange(startTime, endTime), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
videoService.ffmpegRecord(request, asyncResponse, videoInfo.getUrl(), startTime, endTime, DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||
DateTime end = DateUtil.date();
|
||||
asyncContext.complete();
|
||||
log.info("下载总耗时: {}, deviceCode {}, startTime {}, endTime {}", DateUtil.between(start, end, DateUnit.SECOND), deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||
|
@ -31,8 +31,8 @@ public class ReportService {
|
||||
device.getDeviceCode(),
|
||||
device.getGbDeviceChannelId(),
|
||||
DateUtil.formatBetween(startTime, endTime, BetweenFormatter.Level.SECOND),
|
||||
new ReportReq.TimeRange(startTime, endTime),
|
||||
DateUtil.date(),
|
||||
new ReportReq.TimeRange(DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime)),
|
||||
DateUtil.now(),
|
||||
DataSizeUtil.format(fileSize));
|
||||
LinkedMultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
reportConfig.getCustomHeaders().forEach(headers::add);
|
||||
|
@ -8,7 +8,6 @@ import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
|
||||
import cn.skcks.docking.gb28181.wvp.config.FfmpegConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.ProxySipConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.report.ReportReq;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
|
||||
import cn.skcks.docking.gb28181.wvp.service.docking.DockingService;
|
||||
@ -36,6 +35,7 @@ import org.bytedeco.javacv.FrameGrabber;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@ -234,7 +234,7 @@ public class VideoService {
|
||||
* @param time 录制时长 (单位: 秒)
|
||||
*/
|
||||
@SneakyThrows
|
||||
public void ffmpegRecord(HttpServletRequest request, ServletResponse response, String url, ReportReq.TimeRange timeRange, long time, WvpProxyDevice device, String callId){
|
||||
public void ffmpegRecord(HttpServletRequest request, ServletResponse response, String url, Date startTime, Date endTime, long time, WvpProxyDevice device, String callId){
|
||||
String tmpDir = ffmpegConfig.getTmpDir();
|
||||
String fileName = callId + ".mp4";
|
||||
File file = new File(tmpDir, fileName);
|
||||
@ -259,7 +259,7 @@ public class VideoService {
|
||||
}
|
||||
}
|
||||
|
||||
DateTime startTime = DateUtil.date();
|
||||
DateTime start = DateUtil.date();
|
||||
log.info("开始录制 {}", url);
|
||||
ScheduledFuture<?> schedule = scheduledExecutorService.schedule(() -> {
|
||||
log.info("到达结束时间, 结束录制 {}", url);
|
||||
@ -268,8 +268,8 @@ public class VideoService {
|
||||
}, time + 60, TimeUnit.SECONDS);
|
||||
executeResultHandler.waitFor();
|
||||
schedule.cancel(true);
|
||||
DateTime endTime = DateUtil.date();
|
||||
log.info("录制进程结束 {}, 录制耗时: {}", url, DateUtil.between(startTime,endTime, DateUnit.SECOND));
|
||||
DateTime end = DateUtil.date();
|
||||
log.info("录制进程结束 {}, 录制耗时: {}", url, DateUtil.between(start,end, DateUnit.SECOND));
|
||||
|
||||
if(ffmpegConfig.getUseTmpFile()) {
|
||||
ServletOutputStream servletOutputStream = response.getOutputStream();
|
||||
@ -277,9 +277,9 @@ public class VideoService {
|
||||
log.info("临时文件 {}(大小 {})", file.getAbsolutePath(), file.length());
|
||||
IoUtil.copy(new FileInputStream(file), servletOutputStream);
|
||||
response.flushBuffer();
|
||||
reportService.report(request, device, timeRange.getStartTime(), timeRange.getEndTime(), file.length());
|
||||
reportService.report(request, device, startTime, endTime, file.length());
|
||||
} catch (Exception e){
|
||||
reportService.report(request, device, timeRange.getStartTime(), timeRange.getEndTime(), -1);
|
||||
reportService.report(request, device, startTime, endTime, -1);
|
||||
log.error("写入 http 响应异常: {}", e.getMessage());
|
||||
} finally {
|
||||
System.gc();
|
||||
|
Loading…
Reference in New Issue
Block a user