[1078] 去除ftp配置中的ip配置 从连接中获取
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@@ -9,17 +10,14 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ServiceInfo implements ApplicationListener<WebServerInitializedEvent> {
|
||||
|
||||
@Getter
|
||||
private static int serverPort;
|
||||
|
||||
public static int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(WebServerInitializedEvent event) {
|
||||
// 项目启动获取启动的端口号
|
||||
ServiceInfo.serverPort = event.getWebServer().getPort();
|
||||
log.info("项目启动获取启动的端口号: " + ServiceInfo.serverPort);
|
||||
log.info("项目启动获取启动的端口号: {}", ServiceInfo.serverPort);
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
|
||||
@@ -16,7 +16,6 @@ public class FtpSetting {
|
||||
|
||||
private Boolean enable = Boolean.FALSE;
|
||||
|
||||
private String ip;
|
||||
private int port = 21;
|
||||
private String username = "admin";
|
||||
private String password = "admin";
|
||||
|
||||
@@ -25,6 +25,7 @@ public class Ftplet extends DefaultFtplet {
|
||||
|
||||
@Override
|
||||
public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
||||
System.out.println("beforeCommand");
|
||||
if (request.getCommand().equalsIgnoreCase("USER") && !username.equals(request.getArgument())) {
|
||||
return FtpletResult.DISCONNECT;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class UserManager implements org.apache.ftpserver.ftplet.UserManager {
|
||||
|
||||
@Override
|
||||
public User getUserByName(String username) throws FtpException {
|
||||
System.out.println("getUserByName");
|
||||
if (!username.equals(this.username)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
|
||||
|
||||
private void play(JTDevice device, JTChannel channel, int type, CommonCallback<WVPResult<StreamInfo>> callback) {
|
||||
String phoneNumber = device.getPhoneNumber();
|
||||
int channelId = channel.getId();
|
||||
int channelId = channel.getChannelId();
|
||||
String app = "1078";
|
||||
String stream = phoneNumber + "_" + channelId;
|
||||
// 检查流是否已经存在,存在则返回
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.genersoft.iot.vmp.jt1078.event.RegisterEvent;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.*;
|
||||
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||
import com.genersoft.iot.vmp.jt1078.session.FtpDownloadManager;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import com.genersoft.iot.vmp.jt1078.session.SessionManager;
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
|
||||
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -43,6 +45,7 @@ import javax.servlet.ServletOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
@@ -198,14 +201,18 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
dynamicTask.startDelay(filePath, ()->{
|
||||
fileSystemFactory.removeOutputStream(filePath);
|
||||
}, 2*60*60*1000);
|
||||
log.info("[JT-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {},等待上传文件路径: {} ",
|
||||
phoneNumber, channelId, startTime, endTime, filePath);
|
||||
Session session = SessionManager.INSTANCE.get(phoneNumber);
|
||||
Assert.notNull(session, "连接不存在");
|
||||
InetSocketAddress socketAddress = session.getLoadAddress();
|
||||
String hostName = socketAddress.getHostName();
|
||||
log.info("[JT-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {} 上传IP: {} 等待上传文件路径: {} ",
|
||||
phoneNumber, channelId, startTime, endTime, hostName, filePath);
|
||||
// 发送停止命令
|
||||
J9206 j92026 = new J9206();
|
||||
j92026.setChannelId(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.setServerIp(hostName);
|
||||
j92026.setPort(ftpSetting.getPort());
|
||||
j92026.setUsername(ftpSetting.getUsername());
|
||||
j92026.setPassword(ftpSetting.getPassword());
|
||||
@@ -721,14 +728,19 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
||||
public String getRecordTempUrl(String phoneNumber, Integer channelId, String startTime, String endTime, Integer alarmSign, Integer mediaType, Integer streamType, Integer storageType) {
|
||||
String filePath = UUID.randomUUID().toString();
|
||||
|
||||
log.info("[JT-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {},等待上传文件路径: {} ",
|
||||
phoneNumber, channelId, startTime, endTime, filePath);
|
||||
Session session = SessionManager.INSTANCE.get(phoneNumber);
|
||||
Assert.notNull(session, "连接不存在");
|
||||
InetSocketAddress socketAddress = session.getLoadAddress();
|
||||
String hostName = socketAddress.getHostName();
|
||||
|
||||
log.info("[JT-录像] 下载,设备:{}, 通道: {}, 开始时间: {}, 结束时间: {} 上传IP: {} 等待上传文件路径: {} ",
|
||||
phoneNumber, channelId, startTime, endTime, hostName, filePath);
|
||||
// 文件上传指令
|
||||
J9206 j9206 = new J9206();
|
||||
j9206.setChannelId(channelId);
|
||||
j9206.setStartTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime));
|
||||
j9206.setEndTime(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime));
|
||||
j9206.setServerIp(ftpSetting.getIp());
|
||||
j9206.setServerIp(hostName);
|
||||
j9206.setPort(ftpSetting.getPort());
|
||||
j9206.setUsername(ftpSetting.getUsername());
|
||||
j9206.setPassword(ftpSetting.getPassword());
|
||||
|
||||
@@ -7,6 +7,8 @@ import io.netty.util.AttributeKey;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -96,4 +98,8 @@ public class Session {
|
||||
channel.close();
|
||||
SessionManager.INSTANCE.remove(this.phoneNumber);
|
||||
}
|
||||
|
||||
public InetSocketAddress getLoadAddress() {
|
||||
return (InetSocketAddress)channel.localAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,6 @@
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="records" :disabled="device == null || !device.status">
|
||||
设备录像</el-dropdown-item>
|
||||
<el-dropdown-item command="talk" :disabled="device == null || !device.status">
|
||||
对讲</el-dropdown-item>
|
||||
<el-dropdown-item command="cloudRecords" :disabled="device == null || !device.status">
|
||||
云端录像</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
@@ -248,8 +246,6 @@ export default {
|
||||
this.queryRecords(itemData)
|
||||
} else if (command === 'cloudRecords') {
|
||||
this.queryCloudRecords(itemData)
|
||||
} else if (command === 'talk') {
|
||||
this.talk(itemData)
|
||||
} else {
|
||||
this.$message.info('尚不支持')
|
||||
}
|
||||
@@ -262,11 +258,6 @@ export default {
|
||||
const channelId = itemData.channelId
|
||||
this.$router.push(`/cloudRecord/detail/rtp/jt_${deviceId}_${channelId}`)
|
||||
},
|
||||
talk: function(itemData) {
|
||||
const deviceId = this.device.phoneNumber
|
||||
const channelId = itemData.channelId
|
||||
|
||||
},
|
||||
stopDevicePush: function(itemData) {
|
||||
this.$store.dispatch('jtDevice/stopPlay', {
|
||||
phoneNumber: this.device.phoneNumber,
|
||||
|
||||
Reference in New Issue
Block a user