mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-26 15:07:49 +08:00
1078-添加录像上传
This commit is contained in:
parent
e8d832d0a5
commit
3728219177
@ -21,7 +21,7 @@ public class FtpServerConfig {
|
|||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FtpPlet ftpPlet;
|
private ftplet ftpPlet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ftp server init
|
* ftp server init
|
||||||
|
|||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.genersoft.iot.vmp.conf.ftpServer;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置文件 user-settings 映射的配置信息
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "ftp", ignoreInvalidFields = true)
|
||||||
|
@Order(0)
|
||||||
|
public class FtpSetting {
|
||||||
|
|
||||||
|
private Boolean enable = Boolean.FALSE;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
private int port = 21;
|
||||||
|
private String username = "admin";
|
||||||
|
private String password = "admin";
|
||||||
|
|
||||||
|
public Boolean getEnable() {
|
||||||
|
return enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnable(Boolean enable) {
|
||||||
|
this.enable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,8 @@ package com.genersoft.iot.vmp.conf.ftpServer;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.jt1078.event.FtpUploadEvent;
|
import com.genersoft.iot.vmp.jt1078.event.FtpUploadEvent;
|
||||||
import org.apache.ftpserver.ftplet.*;
|
import org.apache.ftpserver.ftplet.*;
|
||||||
import org.apache.ftpserver.impl.DefaultFtpSession;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
@ -12,9 +13,9 @@ import java.io.IOException;
|
|||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class FtpPlet extends DefaultFtplet {
|
public class ftplet extends DefaultFtplet {
|
||||||
|
|
||||||
private FtpletContext ftpletContext;
|
private final Logger logger = LoggerFactory.getLogger(ftplet.class);
|
||||||
|
|
||||||
@Value("${ftp.username}")
|
@Value("${ftp.username}")
|
||||||
private String username;
|
private String username;
|
||||||
@ -28,22 +29,26 @@ public class FtpPlet extends DefaultFtplet {
|
|||||||
return FtpletResult.DISCONNECT;
|
return FtpletResult.DISCONNECT;
|
||||||
}
|
}
|
||||||
super.beforeCommand(session, request);
|
super.beforeCommand(session, request);
|
||||||
// if (request.getCommand().equalsIgnoreCase("STOR") ) {
|
|
||||||
// FtpUploadEvent ftpUploadEvent = new FtpUploadEvent(this);
|
|
||||||
// ftpUploadEvent.setFileName(request.getArgument());
|
|
||||||
// applicationEventPublisher.publishEvent(ftpUploadEvent);
|
|
||||||
// }
|
|
||||||
return FtpletResult.DEFAULT;
|
return FtpletResult.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FtpletResult onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
||||||
DefaultFtpSession ftpSession = (DefaultFtpSession) session;
|
FtpUploadEvent event = new FtpUploadEvent(this);
|
||||||
return super.onUploadStart(session, request);
|
event.setFileName(session.getFileSystemView().getFile(request.getArgument()).getAbsolutePath());
|
||||||
|
applicationEventPublisher.publishEvent(event);
|
||||||
|
|
||||||
|
logger.info("[文件已上传]: {}", session.getFileSystemView().getFile(request.getArgument()).getAbsolutePath());
|
||||||
|
return super.onUploadEnd(session, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
public FtpletResult onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
||||||
|
FtpUploadEvent event = new FtpUploadEvent(this);
|
||||||
|
event.setFileName(session.getFileSystemView().getFile(request.getArgument()).getAbsolutePath());
|
||||||
|
applicationEventPublisher.publishEvent(event);
|
||||||
|
|
||||||
|
logger.info("[文件已上传]: {}", session.getFileSystemView().getFile(request.getArgument()).getAbsolutePath());
|
||||||
return super.onUploadEnd(session, request);
|
return super.onUploadEnd(session, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,6 +1,8 @@
|
|||||||
package com.genersoft.iot.vmp.jt1078.controller;
|
package com.genersoft.iot.vmp.jt1078.controller;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.conf.ftpServer.FtpSetting;
|
||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||||
import com.genersoft.iot.vmp.jt1078.controller.bean.*;
|
import com.genersoft.iot.vmp.jt1078.controller.bean.*;
|
||||||
@ -29,8 +31,11 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -53,6 +58,9 @@ public class JT1078Controller {
|
|||||||
@Autowired
|
@Autowired
|
||||||
UserSetting userSetting;
|
UserSetting userSetting;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FtpSetting ftpSetting;
|
||||||
|
|
||||||
@Qualifier("taskExecutor")
|
@Qualifier("taskExecutor")
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThreadPoolTaskExecutor taskExecutor;
|
private ThreadPoolTaskExecutor taskExecutor;
|
||||||
@ -252,7 +260,7 @@ public class JT1078Controller {
|
|||||||
return WVPResult.success(recordList);
|
return WVPResult.success(recordList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Operation(summary = "1078-开始回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-录像-开始回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||||
@Parameter(name = "startTime", description = "开始时间,格式: yyyy-MM-dd HH:mm:ss", required = true)
|
@Parameter(name = "startTime", description = "开始时间,格式: yyyy-MM-dd HH:mm:ss", required = true)
|
||||||
@ -321,7 +329,7 @@ public class JT1078Controller {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "1078-回放控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-录像-回放控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||||
@Parameter(name = "command", description = "0:开始回放; 1:暂停回放; 2:结束回放; 3:快进回放; 4:关键帧快退回放; 5:拖动回放; 6:关键帧播放", required = true)
|
@Parameter(name = "command", description = "0:开始回放; 1:暂停回放; 2:结束回放; 3:快进回放; 4:关键帧快退回放; 5:拖动回放; 6:关键帧播放", required = true)
|
||||||
@ -338,7 +346,7 @@ public class JT1078Controller {
|
|||||||
service.playbackControl(deviceId, channelId, command, playbackSpeed,time);
|
service.playbackControl(deviceId, channelId, command, playbackSpeed,time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "1078-结束回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-录像-结束回放", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||||
@GetMapping("/playback/stop")
|
@GetMapping("/playback/stop")
|
||||||
@ -351,6 +359,33 @@ public class JT1078Controller {
|
|||||||
service.stopPlayback(deviceId, channelId);
|
service.stopPlayback(deviceId, channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "1078-录像-下载", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
|
@Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true)
|
||||||
|
@Parameter(name = "startTime", description = "开始时间,格式: yyyy-MM-dd HH:mm:ss", required = true)
|
||||||
|
@Parameter(name = "endTime", description = "结束时间,格式: yyyy-MM-dd HH:mm:ss", required = true)
|
||||||
|
@Parameter(name = "type", description = "0.音视频 1.音频 2.视频 3.视频或音视频", required = true)
|
||||||
|
@Parameter(name = "rate", description = "0.所有码流 1.主码流 2.子码流(如果此通道只传输音频,此字段置0)", required = true)
|
||||||
|
@GetMapping("/playback/download")
|
||||||
|
public void recordDownload(HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
@Parameter(required = true) String deviceId,
|
||||||
|
@Parameter(required = false) String channelId,
|
||||||
|
@Parameter(required = true) String startTime,
|
||||||
|
@Parameter(required = true) String endTime,
|
||||||
|
@Parameter(required = false) Integer type,
|
||||||
|
@Parameter(required = false) Integer rate
|
||||||
|
|
||||||
|
) throws IOException {
|
||||||
|
logger.info("[1078-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {}, 音视频类型: {}, 码流类型: {}, ",
|
||||||
|
deviceId, channelId, startTime, endTime, type, rate);
|
||||||
|
if (!ftpSetting.getEnable()) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未启用ftp服务,无法下载录像");
|
||||||
|
}
|
||||||
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
service.recordDownload(deviceId, channelId, startTime, endTime, type, rate, outputStream);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "1078-分页查询部标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "1078-分页查询部标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "page", description = "当前页", required = true)
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
@Parameter(name = "count", description = "每页查询数量", required = true)
|
@Parameter(name = "count", description = "每页查询数量", required = true)
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.util.CharsetUtil;
|
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ public class J9206 extends Rs {
|
|||||||
// 服务器端口
|
// 服务器端口
|
||||||
private int port;
|
private int port;
|
||||||
// 用户名
|
// 用户名
|
||||||
private String user;
|
private String username;
|
||||||
// 密码
|
// 密码
|
||||||
private String password;
|
private String password;
|
||||||
// 文件上传路径
|
// 文件上传路径
|
||||||
@ -62,9 +61,9 @@ public class J9206 extends Rs {
|
|||||||
|
|
||||||
buffer.writeByte(serverIp.getBytes(Charset.forName("GBK")).length);
|
buffer.writeByte(serverIp.getBytes(Charset.forName("GBK")).length);
|
||||||
buffer.writeCharSequence(serverIp, Charset.forName("GBK"));
|
buffer.writeCharSequence(serverIp, Charset.forName("GBK"));
|
||||||
buffer.writeByte(port);
|
buffer.writeShort(port);
|
||||||
buffer.writeByte(user.getBytes(Charset.forName("GBK")).length);
|
buffer.writeByte(username.getBytes(Charset.forName("GBK")).length);
|
||||||
buffer.writeCharSequence(user, Charset.forName("GBK"));
|
buffer.writeCharSequence(username, Charset.forName("GBK"));
|
||||||
buffer.writeByte(password.getBytes(Charset.forName("GBK")).length);
|
buffer.writeByte(password.getBytes(Charset.forName("GBK")).length);
|
||||||
buffer.writeCharSequence(password, Charset.forName("GBK"));
|
buffer.writeCharSequence(password, Charset.forName("GBK"));
|
||||||
buffer.writeByte(path.getBytes(Charset.forName("GBK")).length);
|
buffer.writeByte(path.getBytes(Charset.forName("GBK")).length);
|
||||||
@ -77,7 +76,6 @@ public class J9206 extends Rs {
|
|||||||
buffer.writeByte(streamType);
|
buffer.writeByte(streamType);
|
||||||
buffer.writeByte(storageType);
|
buffer.writeByte(storageType);
|
||||||
buffer.writeByte(taskConditions);
|
buffer.writeByte(taskConditions);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +96,12 @@ public class J9206 extends Rs {
|
|||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser() {
|
public String getUsername() {
|
||||||
return user;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(String user) {
|
public void setUsername(String username) {
|
||||||
this.user = user;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
@ -187,7 +185,7 @@ public class J9206 extends Rs {
|
|||||||
return "J9206{" +
|
return "J9206{" +
|
||||||
"serverIp='" + serverIp + '\'' +
|
"serverIp='" + serverIp + '\'' +
|
||||||
", port=" + port +
|
", port=" + port +
|
||||||
", user='" + user + '\'' +
|
", user='" + username + '\'' +
|
||||||
", password='" + password + '\'' +
|
", password='" + password + '\'' +
|
||||||
", path='" + path + '\'' +
|
", path='" + path + '\'' +
|
||||||
", channelId=" + channelId +
|
", channelId=" + channelId +
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.jt1078.bean.*;
|
|||||||
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Ijt1078Service {
|
public interface Ijt1078Service {
|
||||||
@ -115,4 +116,6 @@ public interface Ijt1078Service {
|
|||||||
void changeStreamType(String deviceId, String channelId, Integer streamType);
|
void changeStreamType(String deviceId, String channelId, Integer streamType);
|
||||||
|
|
||||||
void playbackControl(String deviceId, String channelId, Integer command, Integer playbackSpeed, String time);
|
void playbackControl(String deviceId, String channelId, Integer command, Integer playbackSpeed, String time);
|
||||||
|
|
||||||
|
void recordDownload(String deviceId, String channelId, String startTime, String endTime, Integer type, Integer rate, ServletOutputStream outputStream);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,19 +5,19 @@ import com.genersoft.iot.vmp.common.GeneralCallback;
|
|||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||||
|
import com.genersoft.iot.vmp.conf.ftpServer.FtpSetting;
|
||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.*;
|
import com.genersoft.iot.vmp.jt1078.bean.*;
|
||||||
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
|
import com.genersoft.iot.vmp.jt1078.bean.common.ConfigAttribute;
|
||||||
import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
|
import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
|
||||||
import com.genersoft.iot.vmp.jt1078.dao.JTDeviceMapper;
|
import com.genersoft.iot.vmp.jt1078.dao.JTDeviceMapper;
|
||||||
import com.genersoft.iot.vmp.jt1078.event.CallbackManager;
|
import com.genersoft.iot.vmp.jt1078.event.CallbackManager;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.event.FtpUploadEvent;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
import com.genersoft.iot.vmp.jt1078.proc.request.J1205;
|
||||||
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
||||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||||
import com.genersoft.iot.vmp.jt1078.util.SSRCUtil;
|
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||||
@ -35,22 +35,19 @@ import com.genersoft.iot.vmp.utils.DateUtil;
|
|||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.sip.InvalidArgumentException;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.sip.SipException;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.text.ParseException;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -91,6 +88,9 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FtpSetting ftpSetting;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JTDevice getDevice(String terminalId) {
|
public JTDevice getDevice(String terminalId) {
|
||||||
@ -424,6 +424,67 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
playbackControl(deviceId, channelId, 2, null, String.valueOf(0));
|
playbackControl(deviceId, channelId, 2, null, String.valueOf(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, ServletOutputStream> fileUploadMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void onApplicationEvent(FtpUploadEvent event) {
|
||||||
|
if (fileUploadMap.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fileUploadMap.keySet().forEach(key -> {
|
||||||
|
if (!event.getFileName().contains(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ServletOutputStream servletOutputStream = fileUploadMap.get(event.getFileName());
|
||||||
|
String filePath = "ftp" + event.getFileName();
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
logger.warn("[下载录像] 收到通知时未找到录像文件: {}", filePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(file);
|
||||||
|
IOUtils.copy(fileInputStream, servletOutputStream);
|
||||||
|
fileInputStream.close();
|
||||||
|
servletOutputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn("[下载录像] 读取文件异常: {}", filePath, e);
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
servletOutputStream.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recordDownload(String deviceId, String channelId, String startTime, String endTime, Integer type, Integer rate, ServletOutputStream outputStream) {
|
||||||
|
String filePath = UUID.randomUUID().toString();
|
||||||
|
fileUploadMap.put(filePath, outputStream);
|
||||||
|
logger.info("[1078-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {},等待上传文件路径: {} ",
|
||||||
|
deviceId, channelId, startTime, endTime, filePath);
|
||||||
|
// 发送停止命令
|
||||||
|
J9206 j92026 = new J9206();
|
||||||
|
j92026.setChannelId(Integer.parseInt(channelId));
|
||||||
|
j92026.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime));
|
||||||
|
j92026.setEndTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime));
|
||||||
|
j92026.setServerIp(ftpSetting.getIp());
|
||||||
|
j92026.setPort(ftpSetting.getPort());
|
||||||
|
j92026.setUsername(ftpSetting.getUsername());
|
||||||
|
j92026.setPassword(ftpSetting.getPassword());
|
||||||
|
j92026.setPath(filePath);
|
||||||
|
|
||||||
|
if (type != null) {
|
||||||
|
j92026.setMediaType(type);
|
||||||
|
}
|
||||||
|
if (rate != null) {
|
||||||
|
j92026.setStreamType(rate);
|
||||||
|
}
|
||||||
|
jt1078Template.fileUpload(deviceId, j92026, 7200);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ptzControl(String deviceId, String channelId, String command, int speed) {
|
public void ptzControl(String deviceId, String channelId, String command, int speed) {
|
||||||
// 发送停止命令
|
// 发送停止命令
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user