Commit f27bd7614d0cf4136f8084179f5b6fcd01ff07d1

Authored by 王鑫
1 parent ff6c5ef5

fix():

src/main/java/com/genersoft/iot/vmp/TCPClient.java
@@ -13,17 +13,10 @@ public class TCPClient { @@ -13,17 +13,10 @@ public class TCPClient {
13 //获取输入流 13 //获取输入流
14 InputStream is = socket.getInputStream(); 14 InputStream is = socket.getInputStream();
15 // 将要传递给server的字符串参数转换称byte数组,并将数组写入到输出流中 15 // 将要传递给server的字符串参数转换称byte数组,并将数组写入到输出流中
16 - os.write(new String("hello world").getBytes());  
17 - int ch = 0;  
18 - byte[] buff = new byte[1024];  
19 - // buff主要用来读取输入的内容,存成byte数组,ch主要用来获取读取数组的长度(与服务端作用相同)  
20 - ch = is.read(buff);  
21 - //将接收流的byte数组转换成字符串,这里是从服务端回发的字符串参数的长度  
22 - String content = new String(buff,0,ch);  
23 - System.out.println(content);  
24 - //一定要关闭输入输出流及socket  
25 - is.close();  
26 - os.close();  
27 - socket.close(); 16 + while(true){
  17 + os.write(new String("hello world").getBytes());
  18 + os.flush();
  19 + Thread.sleep(1000);
  20 + }
28 } 21 }
29 } 22 }
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.common.InviteSessionType; @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.common.InviteSessionType;
7 import com.genersoft.iot.vmp.common.StreamInfo; 7 import com.genersoft.iot.vmp.common.StreamInfo;
8 import com.genersoft.iot.vmp.common.VideoManagerConstants; 8 import com.genersoft.iot.vmp.common.VideoManagerConstants;
9 import com.genersoft.iot.vmp.conf.UserSetting; 9 import com.genersoft.iot.vmp.conf.UserSetting;
  10 +import com.genersoft.iot.vmp.conf.exception.ServiceException;
10 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; 11 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
11 import com.genersoft.iot.vmp.gb28181.bean.*; 12 import com.genersoft.iot.vmp.gb28181.bean.*;
12 import com.genersoft.iot.vmp.gb28181.event.EventPublisher; 13 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -684,7 +685,11 @@ public class ZLMHttpHookListener { @@ -684,7 +685,11 @@ public class ZLMHttpHookListener {
684 if (object == null) { 685 if (object == null) {
685 String[] split = param.getStream().split("_"); 686 String[] split = param.getStream().split("_");
686 if (split != null && split.length == 2) { 687 if (split != null && split.length == 2) {
687 - jt1078OfCarController.clearMap(split[1],split[0]); 688 + try {
  689 + jt1078OfCarController.clearMap(split[1],split[0]);
  690 + } catch (ServiceException e) {
  691 + throw new RuntimeException(e);
  692 + }
688 } 693 }
689 } 694 }
690 } 695 }
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/Jt1078OfCarController.java
@@ -12,6 +12,7 @@ import com.alibaba.fastjson2.JSONObject; @@ -12,6 +12,7 @@ import com.alibaba.fastjson2.JSONObject;
12 import com.genersoft.iot.vmp.conf.MediaConfig; 12 import com.genersoft.iot.vmp.conf.MediaConfig;
13 import com.genersoft.iot.vmp.conf.StreamProxyTask; 13 import com.genersoft.iot.vmp.conf.StreamProxyTask;
14 import com.genersoft.iot.vmp.conf.exception.ControllerException; 14 import com.genersoft.iot.vmp.conf.exception.ControllerException;
  15 +import com.genersoft.iot.vmp.conf.exception.ServiceException;
15 import com.genersoft.iot.vmp.conf.security.JwtUtils; 16 import com.genersoft.iot.vmp.conf.security.JwtUtils;
16 import com.genersoft.iot.vmp.conf.security.dto.JwtUser; 17 import com.genersoft.iot.vmp.conf.security.dto.JwtUser;
17 import com.genersoft.iot.vmp.jtt1078.app.VideoServerApp; 18 import com.genersoft.iot.vmp.jtt1078.app.VideoServerApp;
@@ -149,6 +150,20 @@ public class Jt1078OfCarController { @@ -149,6 +150,20 @@ public class Jt1078OfCarController {
149 } 150 }
150 151
151 152
  153 + @GetMapping("/history/uploading/{stream}")
  154 + public void uploading(@PathVariable String stream) {
  155 + try {
  156 + String url = StringUtils.replace(jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getHistoryUpload());
  157 + String msg = jt1078ConfigBean.formatMessageHistoryUpload(stream);
  158 + HttpClientPostEntity httpClientPost = this.httpClientUtil.doPost(url, msg, (String) null);
  159 + chooseEntity(httpClientPost, url, false);
  160 +
  161 + } catch (Exception e) {
  162 + throw new RuntimeException(e);
  163 + }
  164 + }
  165 +
  166 +
152 /** 167 /**
153 * redis清除在线车辆 168 * redis清除在线车辆
154 */ 169 */
@@ -349,7 +364,6 @@ public class Jt1078OfCarController { @@ -349,7 +364,6 @@ public class Jt1078OfCarController {
349 * @param stream 流唯一标识 364 * @param stream 流唯一标识
350 */ 365 */
351 public void sendIORequest(String stream) { 366 public void sendIORequest(String stream) {
352 -  
353 threadPoolExecutor.execute(() -> { 367 threadPoolExecutor.execute(() -> {
354 String msg = null; 368 String msg = null;
355 // http://192.168.168.241:8100/device/{0} 指令下发地址 369 // http://192.168.168.241:8100/device/{0} 指令下发地址
@@ -669,7 +683,7 @@ public class Jt1078OfCarController { @@ -669,7 +683,7 @@ public class Jt1078OfCarController {
669 @PathVariable @NotBlank(message = "channel 不能为空") String channel, 683 @PathVariable @NotBlank(message = "channel 不能为空") String channel,
670 @PathVariable @NotBlank(message = "开始时间不能为空") String startTime, 684 @PathVariable @NotBlank(message = "开始时间不能为空") String startTime,
671 @PathVariable @NotBlank(message = "结束时间不能为空") String endTime, 685 @PathVariable @NotBlank(message = "结束时间不能为空") String endTime,
672 - String channelMapping, HttpServletRequest request) { 686 + @PathVariable String channelMapping, HttpServletRequest request) throws ServiceException {
673 String header = request.getHeader("access-token"); 687 String header = request.getHeader("access-token");
674 JwtUser jwtUser = JwtUtils.verifyToken(header); 688 JwtUser jwtUser = JwtUtils.verifyToken(header);
675 String key = StringUtils.join(new String[]{"history:", sim, "-", channel}); 689 String key = StringUtils.join(new String[]{"history:", sim, "-", channel});
@@ -685,7 +699,6 @@ public class Jt1078OfCarController { @@ -685,7 +699,6 @@ public class Jt1078OfCarController {
685 Integer historyPort = createHistoryPort(channelMapping); 699 Integer historyPort = createHistoryPort(channelMapping);
686 channelMapping = StringUtils.join(new String[]{channelMapping,"_", String.valueOf(historyPort)}); 700 channelMapping = StringUtils.join(new String[]{channelMapping,"_", String.valueOf(historyPort)});
687 this.redisTemplate.opsForValue().set(key, channelMapping, 1L, TimeUnit.HOURS); 701 this.redisTemplate.opsForValue().set(key, channelMapping, 1L, TimeUnit.HOURS);
688 -// PublishManager.getInstance().open(channelMapping);  
689 StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{channelMapping})); 702 StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{channelMapping}));
690 if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) { 703 if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) {
691 resultMap.put("code", "1"); 704 resultMap.put("code", "1");
@@ -698,8 +711,7 @@ public class Jt1078OfCarController { @@ -698,8 +711,7 @@ public class Jt1078OfCarController {
698 String msg = null; 711 String msg = null;
699 String url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getPlayHistoryPort()); 712 String url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getPlayHistoryPort());
700 try { 713 try {
701 - Integer httpPort = this.jt1078ConfigBean.getHttpPort();  
702 - HttpClientPostEntity entity = this.createServerLister(channelMapping, historyPort, httpPort); 714 + HttpClientPostEntity entity = this.createServerLister(channelMapping, historyPort, historyPort);
703 if (Objects.isNull(entity)) { 715 if (Objects.isNull(entity)) {
704 resultMap.put("code", "-20"); 716 resultMap.put("code", "-20");
705 resultMap.put("msg", "新建链接错误,请稍后再试"); 717 resultMap.put("msg", "新建链接错误,请稍后再试");
@@ -763,7 +775,7 @@ public class Jt1078OfCarController { @@ -763,7 +775,7 @@ public class Jt1078OfCarController {
763 * 遍历Map,寻找第一个不包含指定string的Set<String>, 775 * 遍历Map,寻找第一个不包含指定string的Set<String>,
764 * 将该string添加到Set中并返回对应的key,如果没有找到则返回null。 776 * 将该string添加到Set中并返回对应的key,如果没有找到则返回null。
765 */ 777 */
766 - private Integer addStringToFirstNonContainingSet(String targetString) { 778 + private Integer addStringToFirstNonContainingSet(String targetString) throws ServiceException {
767 // 使用entrySet()方法直接获取键值对进行迭代,效率更高 779 // 使用entrySet()方法直接获取键值对进行迭代,效率更高
768 for (Map.Entry<Integer, Set<String>> entry : map.entrySet()) { 780 for (Map.Entry<Integer, Set<String>> entry : map.entrySet()) {
769 Set<String> set = entry.getValue(); 781 Set<String> set = entry.getValue();
@@ -774,11 +786,10 @@ public class Jt1078OfCarController { @@ -774,11 +786,10 @@ public class Jt1078OfCarController {
774 String secondDashValue = getSecondDashValue(targetString); 786 String secondDashValue = getSecondDashValue(targetString);
775 String findSet = getFindSet(set, secondDashValue); 787 String findSet = getFindSet(set, secondDashValue);
776 set.add(targetString); 788 set.add(targetString);
777 - if (secondDashValue != null && findSet == null) {  
778 - return entry.getKey(); // 立即返回对应的key,不再继续查找  
779 - } else { 789 + if (secondDashValue == null || findSet != null) {
780 clearMap(String.valueOf(entry.getKey()), findSet); 790 clearMap(String.valueOf(entry.getKey()), findSet);
781 } 791 }
  792 + return entry.getKey(); // 立即返回对应的key,不再继续查找
782 } 793 }
783 return null; // 如果所有Set都包含目标字符串,则返回null 794 return null; // 如果所有Set都包含目标字符串,则返回null
784 } 795 }
@@ -786,7 +797,7 @@ public class Jt1078OfCarController { @@ -786,7 +797,7 @@ public class Jt1078OfCarController {
786 /** 797 /**
787 * 清理map中的值 798 * 清理map中的值
788 */ 799 */
789 - public void clearMap(String key, String value) { 800 + public void clearMap(String key, String value) throws ServiceException {
790 if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(value)) { 801 if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(value)) {
791 Set<String> strings = map.get(Integer.valueOf(key)); 802 Set<String> strings = map.get(Integer.valueOf(key));
792 if (strings == null) { 803 if (strings == null) {
@@ -800,7 +811,15 @@ public class Jt1078OfCarController { @@ -800,7 +811,15 @@ public class Jt1078OfCarController {
800 throw new RuntimeException(e); 811 throw new RuntimeException(e);
801 } 812 }
802 String[] split = value.split("-"); 813 String[] split = value.split("-");
803 - stopHistory(split[1], split[0]); 814 + Map<String, Object> stringObjectMap = stopHistory(split[1], split[0]);
  815 + while (true){
  816 + if (stringObjectMap.get("code").equals("1")){
  817 + log.info("{} 历史视频断流成功",value);
  818 + break;
  819 + }else {
  820 + throw new ServiceException(String.format(" %s 历史视频断流失败",value));
  821 + }
  822 + }
804 strings.remove(value); 823 strings.remove(value);
805 } 824 }
806 } else { 825 } else {
@@ -813,7 +832,7 @@ public class Jt1078OfCarController { @@ -813,7 +832,7 @@ public class Jt1078OfCarController {
813 * 832 *
814 * @param key 通道唯一值 833 * @param key 通道唯一值
815 */ 834 */
816 - public Integer createHistoryPort(String key) { 835 + public Integer createHistoryPort(String key) throws ServiceException {
817 Integer port = addStringToFirstNonContainingSet(key); 836 Integer port = addStringToFirstNonContainingSet(key);
818 if (port == null) { 837 if (port == null) {
819 throw new RuntimeException(String.format("[ %s ]通道观看人数太多,请等待 !!!", key)); 838 throw new RuntimeException(String.format("[ %s ]通道观看人数太多,请等待 !!!", key));
@@ -879,7 +898,6 @@ public class Jt1078OfCarController { @@ -879,7 +898,6 @@ public class Jt1078OfCarController {
879 898
880 /** 899 /**
881 * 获取视频播放地址 900 * 获取视频播放地址
882 - *  
883 * @param stream 流名称 901 * @param stream 流名称
884 * @return 流信息 902 * @return 流信息
885 */ 903 */
@@ -1007,7 +1025,6 @@ public class Jt1078OfCarController { @@ -1007,7 +1025,6 @@ public class Jt1078OfCarController {
1007 } 1025 }
1008 1026
1009 private void chooseEntity(HttpClientPostEntity entity, String url, boolean flag) { 1027 private void chooseEntity(HttpClientPostEntity entity, String url, boolean flag) {
1010 - Map<String, Object> result = new HashMap();  
1011 if (Objects.isNull(entity)) { 1028 if (Objects.isNull(entity)) {
1012 throw new ControllerException(ErrorCode.ERROR301); 1029 throw new ControllerException(ErrorCode.ERROR301);
1013 } else { 1030 } else {
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/FtpConfigBean.java
@@ -15,35 +15,37 @@ import org.springframework.context.annotation.Configuration; @@ -15,35 +15,37 @@ import org.springframework.context.annotation.Configuration;
15 @Configuration 15 @Configuration
16 @ConfigurationProperties(prefix = "ftp") 16 @ConfigurationProperties(prefix = "ftp")
17 public class FtpConfigBean { 17 public class FtpConfigBean {
18 -  
19 - private String basePath; 18 + /**
  19 + * 基础地址
  20 + */
  21 + private String basePath = "/wvp-local";
20 /** 22 /**
21 * ftp地址 23 * ftp地址
22 */ 24 */
23 - private String host;  
24 - private String httpPath; 25 + private String host = "192.168.169.100";
  26 + private String httpPath = "ftp://192.168.169.100";
25 /** 27 /**
26 * 28 *
27 */ 29 */
28 - private String filePathPrefix; 30 + private String filePathPrefix = "http://192.168.169.100:10021/wvp-local";
29 /** 31 /**
30 * 密码 32 * 密码
31 */ 33 */
32 - private String password; 34 + private String password = "ftp@123";
33 /** 35 /**
34 * 端口 36 * 端口
35 */ 37 */
36 - private Integer port; 38 + private Integer port = 10021;
37 /** 39 /**
38 * 用户名 40 * 用户名
39 */ 41 */
40 - private String username; 42 + private String username = "ftpadmin";
41 /** 43 /**
42 * 失败重试次数 -1为一直重试 44 * 失败重试次数 -1为一直重试
43 */ 45 */
44 - private Integer retryTimes; 46 + private Integer retryTimes = 5;
45 /** 47 /**
46 * 失败重试间隔时间 48 * 失败重试间隔时间
47 */ 49 */
48 - private Integer retryWaitTimes; 50 + private Integer retryWaitTimes = 3000;
49 } 51 }
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/Jt1078ConfigBean.java
1 -package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.Jt1078OfCarController; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.wss}") private String wss; @Value("${tuohua.bsth.jt1078.downloadFLV}") private String downloadFlv; @Value("${tuohua.bsth.jt1078.port}") private Integer port; @Value("${tuohua.bsth.jt1078.httpPort}") private Integer httpPort; @Value("${spring.profiles.active}") private String profilesActive; @Value("${media.pushKey}") private String pushKey; @Resource private RedisTemplate<String, Integer> redisTemplate; public Integer getPort() { if (port == null) { return 30000; } return port; } public Integer getHttpPort() { if (httpPort == null) { return 30000; } return httpPort; } private Integer getIntPort() { return profilesActive.equals("wx-local") ? 10000 : 0; } @PostConstruct public void initMap() { Set<String> historyPortKeys = redisTemplate.keys("history:port:*"); Set<String> keys = redisTemplate.keys("tag:*"); Set<String> patrolKeys = redisTemplate.keys("patrol:stream:*"); if (!historyPortKeys.isEmpty()) { keys.addAll(historyPortKeys); } if (!patrolKeys.isEmpty()) { keys.addAll(patrolKeys); } if (keys != null) { redisTemplate.delete(keys); } Map<Integer, Set<String>> hashMap = new HashMap<>(); for (int number = getStart1078Port(); number <= getEnd1078Port(); number++) { hashMap.put(number, new HashSet<>()); } Jt1078OfCarController.map.putAll(hashMap); } private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":1,\"storageType\":0,\"channelNo\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageHistoryStopRTSP(String sim, String channel, RtspConfigBean configBean) { String msg = StringUtils.replace("{\"playbackMode\":2,\"channelNo\":{channelNo},\"playbackSpeed\":0,\"clientId\":\"{sim}\"}", "{sim}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatVideoURL(String stream) { String url = StringUtils.replace(getGetURL(), "{stream}", stream); if (!StringUtils.endsWith(url, ".flv")) { url = url + ".flv"; } return url; } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getPushKey(){ if (Objects.isNull(this.pushKey)){ this.pushKey = "?callId=41db35390ddad33f83944f44b8b75ded"; } return "?callId="+this.pushKey; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } public String getDownloadFlv() { return downloadFlv; } public String getPortsOf1078() { return portsOf1078; } }  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.Jt1078OfCarController; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; @Data @Component public class Jt1078ConfigBean { @Value("${tuohua.bsth.jt1078.url}") private String jt1078Url; @Value("${tuohua.bsth.jt1078.sendPort}") private String jt1078SendPort; @Value("${tuohua.bsth.jt1078.stopSendPort}") private String stopSendPort; @Value("${tuohua.bsth.jt1078.historyListPort}") private String historyListPort; @Value("${tuohua.bsth.jt1078.history_upload}") private String historyUpload = "9206"; @Value("${tuohua.bsth.jt1078.playHistoryPort}") private String playHistoryPort; @Value("${tuohua.bsth.jt1078.ports}") private String portsOf1078; @Value("${tuohua.bsth.jt1078.pushURL}") private String pushURL; @Value("${tuohua.bsth.jt1078.stopPushURL}") private String stopPUshURL; private Integer start1078Port; private Integer end1078Port; @Value("${tuohua.bsth.jt1078.get.url}") private String getURL; @Value("${tuohua.bsth.jt1078.addPortVal}") private Integer addPort; @Value("${tuohua.bsth.jt1078.ws}") private String ws; @Value("${tuohua.bsth.jt1078.wss}") private String wss; @Value("${tuohua.bsth.jt1078.downloadFLV}") private String downloadFlv; @Value("${tuohua.bsth.jt1078.port}") private Integer port; @Value("${tuohua.bsth.jt1078.httpPort}") private Integer httpPort; @Value("${spring.profiles.active}") private String profilesActive; @Value("${media.pushKey}") private String pushKey; @Resource private RedisTemplate<String, Integer> redisTemplate; @Resource private FtpConfigBean ftpConfigBean; public Integer getPort() { if (port == null) { return 30000; } return port; } public Integer getHttpPort() { if (httpPort == null) { return 30000; } return httpPort; } private Integer getIntPort() { return profilesActive.equals("wx-local") ? 10000 : 0; } @PostConstruct public void initMap() { Set<String> historyPortKeys = redisTemplate.keys("history:port:*"); Set<String> keys = redisTemplate.keys("tag:*"); Set<String> patrolKeys = redisTemplate.keys("patrol:stream:*"); if (!historyPortKeys.isEmpty()) { keys.addAll(historyPortKeys); } if (!patrolKeys.isEmpty()) { keys.addAll(patrolKeys); } if (keys != null) { redisTemplate.delete(keys); } Map<Integer, Set<String>> hashMap = new HashMap<>(); for (int number = getStart1078Port(); number <= getEnd1078Port(); number++) { hashMap.put(number, new HashSet<>()); } Jt1078OfCarController.map.putAll(hashMap); } private static final String SEND_IO_MESSAGE_RTSP = "{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}"; private static final String SEND_IO_MESSAGE_RTSP_STOP = "{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}"; private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}"; private static final String SEND_IO_PLAY_RTSP = "{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}"; public String formatMessageId(String sim, String channel, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{ \"messageId\": 37121, \"properties\": 0, \"clientId\": \"{clientId}\", \"serialNo\": \"1\", \"ip\": \"{ip}\", \"tcpPort\": \"{tcpPort}\", \"udpPort\": \"{udpPort}\", \"channelNo\": \"{channelNo}\", \"mediaType\": \"1\", \"streamType\": \"1\"}", "{clientId}", sim); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{channelNo}", channel); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageStop(String sim, String channel) { String msg = StringUtils.replace("{\"messageId\": 37122,\"properties\": 0,\"clientId\": \"{clientId}\",\"serialNo\": \"1\",\"channelNo\": \"{channelNo}\",\"command\": \"0\",\"closeType\": \"0\",\"streamType\": \"1\"}", "{clientId}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) { String msg = StringUtils.replace("{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":1,\"storageType\":0,\"channelNo\":{channelNo}}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean, Integer port) { String msg = StringUtils.replace("{\"ip\":\"{ip}\",\"tcpPort\":{tcpPort},\"udpPort\":{udpPort},\"channelNo\":\"{channelNo}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"playbackType\":0,\"playbackSpeed\":1,\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"clientId\":\"{sim}\",\"messageId\":37377}", "{clientId}", sim); msg = StringUtils.replace(msg, "{startTime}", startTime); msg = StringUtils.replace(msg, "{endTime}", endTime); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{tcpPort}", (port.intValue() + getIntPort() +getAddPort()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getIntPort() + getAddPort()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } public String formatMessageHistoryUpload(String stream) { if (StringUtils.isBlank(stream)) { throw new RuntimeException("上传参数不能为空"); } String[] split = stream.split("_"); if (split.length < 4){ throw new RuntimeException("上传参数异常, 请联系管理员"); } String sim = split[0]; String channel = split[1]; String startTime = split[2]; String endTime = split[3]; String msg = StringUtils.replace("{\n" + " \"clientId\": \"{clientId}\",\n" + " \"ip\": \"{ip}\",\n" + " \"port\": {port},\n" + " \"username\": \"{username}\",\n" + " \"password\": \"{password}\",\n" + " \"path\": \"{path}\",\n" + " \"channelNo\": {channel},\n" + " \"startTime\": \"{startTime}\",\n" + " \"endTime\": \"{endTime}\",\n" + " \"mediaType\": 0,\n" + " \"streamType\": 1,\n" + " \"storageType\": 1,\n" + " \"condition\": 6\n" + "}","{clientId}",sim); msg = StringUtils.replace(msg, "{ip}", ftpConfigBean.getHost()); msg = StringUtils.replace(msg, "{port}", ftpConfigBean.getPort().toString()); msg = StringUtils.replace(msg, "{username}", channel); msg = StringUtils.replace(msg, "{password}", ftpConfigBean.getPassword()); msg = StringUtils.replace(msg, "{path}", StringUtils.join(ftpConfigBean.getBasePath(),"/",sim,"/channel_",channel)); msg = StringUtils.replace(msg, "{channelNo}", channel); msg = StringUtils.replace(msg, "{startTime}", startTime); return StringUtils.replace(msg, "{endTime}", endTime); } public String formatMessageHistoryStopRTSP(String sim, String channel, RtspConfigBean configBean) { String msg = StringUtils.replace("{\"playbackMode\":2,\"channelNo\":{channelNo},\"playbackSpeed\":0,\"clientId\":\"{sim}\"}", "{sim}", sim); return StringUtils.replace(msg, "{channelNo}", channel); } public String formatPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.pushURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatStopPushURL(String pushKey, int port, int httpPort) { String msg = StringUtils.replace(this.stopPUshURL, "{pushKey}", pushKey); msg = StringUtils.replace(msg, "{port}", String.valueOf(port)); return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort)); } public String formatVideoURL(String stream) { String url = StringUtils.replace(getGetURL(), "{stream}", stream); if (!StringUtils.endsWith(url, ".flv")) { url = url + ".flv"; } return url; } public String getJt1078Url() { return this.jt1078Url; } public String getJt1078SendPort() { return this.jt1078SendPort; } public String getStopSendPort() { return this.stopSendPort; } public String getHistoryListPort() { return this.historyListPort; } public String getPlayHistoryPort() { return this.playHistoryPort; } public String getPushURL() { return this.pushURL; } public Integer getStart1078Port() { if (Objects.isNull(this.start1078Port)) this.start1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringBefore(this.portsOf1078, ","))); return this.start1078Port; } public Integer getEnd1078Port() { if (Objects.isNull(this.end1078Port)) this.end1078Port = Integer.valueOf(Integer.parseInt(StringUtils.substringAfter(this.portsOf1078, ","))); return this.end1078Port; } public String getPushKey(){ if (Objects.isNull(this.pushKey)){ this.pushKey = "?callId=41db35390ddad33f83944f44b8b75ded"; } return "?callId="+this.pushKey; } public String getStopPUshURL() { return this.stopPUshURL; } public String getGetURL() { return this.getURL; } public Integer getAddPort() { return this.addPort; } public String getWs() { return this.ws; } public String getWss() { return this.wss; } public String getDownloadFlv() { return downloadFlv; } public String getPortsOf1078() { return portsOf1078; } }
3 \ No newline at end of file 3 \ No newline at end of file
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/TuohuaConfigBean.java
@@ -159,14 +159,18 @@ public class TuohuaConfigBean { @@ -159,14 +159,18 @@ public class TuohuaConfigBean {
159 } 159 }
160 return (List<HashMap>) JSON.parseArray(postEntity.getResultStr(), HashMap.class); 160 return (List<HashMap>) JSON.parseArray(postEntity.getResultStr(), HashMap.class);
161 } 161 }
162 - 162 + /**
  163 + * 修改测试号
  164 + * @param json
  165 + */
163 public void setMap(String json){ 166 public void setMap(String json){
164 List<CarData> carData = JSON.parseArray(json, CarData.class); 167 List<CarData> carData = JSON.parseArray(json, CarData.class);
165 int count = 1; 168 int count = 1;
166 if (CollectionUtils.isNotEmpty(carData)) { 169 if (CollectionUtils.isNotEmpty(carData)) {
167 if (StringUtils.equals(profileActive, "wx-local")) { 170 if (StringUtils.equals(profileActive, "wx-local")) {
168 CarData value = carData.get(0); 171 CarData value = carData.get(0);
169 - value.setSim("123456789011"); 172 + value.setSim("13800009998");
  173 +// value.setSim("123456789011");
170 map.put(value.getSim(), value); 174 map.put(value.getSim(), value);
171 }else { 175 }else {
172 for (CarData carDatum : carData) { 176 for (CarData carDatum : carData) {
@@ -315,10 +319,9 @@ public class TuohuaConfigBean { @@ -315,10 +319,9 @@ public class TuohuaConfigBean {
315 hashMap.put("abnormalStatus",abnormalStatus); 319 hashMap.put("abnormalStatus",abnormalStatus);
316 320
317 if (StringUtils.equals(profileActive, "wx-local")) { 321 if (StringUtils.equals(profileActive, "wx-local")) {
318 - hashMap.put("sim","123456789011");  
319 -// hashMap.put("sim", "122223333444"); 322 + hashMap.put("sim","13800009998");
  323 +// hashMap.put("sim", "123456789011");
320 } 324 }
321 -//  
322 return hashMap; 325 return hashMap;
323 } 326 }
324 327
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/service/impl/Jt1078OfServiceImpl.java
@@ -32,8 +32,8 @@ public class Jt1078OfServiceImpl implements Jt1078OfService { @@ -32,8 +32,8 @@ public class Jt1078OfServiceImpl implements Jt1078OfService {
32 @Override 32 @Override
33 public List<CarTreeData> getCarTreeData() { 33 public List<CarTreeData> getCarTreeData() {
34 try { 34 try {
35 - String lineJson = tohuaConfigBean.requestLine(httpClientUtil, String.valueOf(100));  
36 - String carJson = tohuaConfigBean.requestCars(httpClientUtil, String.valueOf(100)); 35 +// String lineJson = tohuaConfigBean.requestLine(httpClientUtil, String.valueOf(100));
  36 +// String carJson = tohuaConfigBean.requestCars(httpClientUtil, String.valueOf(100));
37 } catch (Exception e) { 37 } catch (Exception e) {
38 throw new RuntimeException(e); 38 throw new RuntimeException(e);
39 } 39 }
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
@@ -71,7 +71,6 @@ public class StreamProxyController { @@ -71,7 +71,6 @@ public class StreamProxyController {
71 @RequestParam(required = false)Integer count, 71 @RequestParam(required = false)Integer count,
72 @RequestParam(required = false)String query, 72 @RequestParam(required = false)String query,
73 @RequestParam(required = false)Boolean online ){ 73 @RequestParam(required = false)Boolean online ){
74 -  
75 return streamProxyService.getAll(page, count); 74 return streamProxyService.getAll(page, count);
76 } 75 }
77 76
src/main/java/com/genersoft/iot/vmp/vmanager/util/FTPUtils.java deleted 100644 → 0
1 -package com.genersoft.iot.vmp.vmanager.util;  
2 -  
3 -import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.FtpConfigBean;  
4 -import lombok.extern.log4j.Log4j2;  
5 -import org.apache.commons.net.ftp.FTPClient;  
6 -import org.apache.commons.net.ftp.FTPReply;  
7 -import org.springframework.stereotype.Component;  
8 -  
9 -import javax.annotation.Resource;  
10 -import java.io.IOException;  
11 -  
12 -/**  
13 - * FTP工具类  
14 - *  
15 - * @Author WangXin  
16 - * @Data 2025/2/11  
17 - * @Version 1.0.0  
18 - */  
19 -@Log4j2  
20 -@Component  
21 -public class FTPUtils {  
22 -  
23 - @Resource  
24 - private FtpConfigBean ftpConfigBean;  
25 -  
26 - private FTPClient connectFtpServer() {  
27 - FTPClient ftpClient = new FTPClient();  
28 - ftpClient.setConnectTimeout(1000 * 60);  
29 - ftpClient.setControlEncoding("utf-8");  
30 - ftpClient.enterLocalPassiveMode();  
31 -  
32 - int retryTimes = ftpConfigBean.getRetryTimes(); // 假设getRetryTimes方法返回int类型的重试次数,-1表示无限重试  
33 - boolean isConnected = false;  
34 - int attempts = 0;  
35 -  
36 - while (!isConnected && (retryTimes == -1 || attempts < retryTimes)) {  
37 - try {  
38 - int replyCode;  
39 - ftpClient.connect(ftpConfigBean.getHost());  
40 - ftpClient.login(ftpConfigBean.getUsername(), ftpConfigBean.getPassword());  
41 - replyCode = ftpClient.getReplyCode();  
42 -  
43 - if (!FTPReply.isPositiveCompletion(replyCode)) {  
44 - log.info("连接FTP服务器 {} 失败", ftpConfigBean.getHost());  
45 - ftpClient.disconnect();  
46 - attempts++;  
47 - if (retryTimes != -1) {  
48 - log.info("第 {} 次尝试连接失败, 将重新连接", attempts);  
49 - }  
50 - continue; // 连接不成功,继续循环  
51 - }  
52 - isConnected = true;  
53 - log.info("replyCode:{}", replyCode);  
54 - } catch (IOException e) {  
55 - log.error("连接失败: {}", e.toString());  
56 - attempts++;  
57 - if (retryTimes != -1) {  
58 - log.info("第 {} 次尝试连接失败, 错误信息: {}", attempts, e.getMessage());  
59 - }  
60 - try {  
61 - // 等待一段时间再重试  
62 - Thread.sleep(ftpConfigBean.getRetryWaitTimes());  
63 - } catch (InterruptedException ie) {  
64 - Thread.currentThread().interrupt();  
65 - }  
66 - }  
67 - }  
68 - if (!isConnected) {  
69 - log.error("无法连接到FTP服务器,已达到最大重试次数");  
70 - return null;  
71 - }  
72 - return ftpClient;  
73 - }  
74 -}  
src/main/java/com/genersoft/iot/vmp/vmanager/util/FtpUtils.java 0 → 100644
  1 +package com.genersoft.iot.vmp.vmanager.util;
  2 +
  3 +import cn.hutool.extra.ftp.FtpException;
  4 +import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.FtpConfigBean;
  5 +import lombok.RequiredArgsConstructor;
  6 +import lombok.extern.log4j.Log4j2;
  7 +import org.apache.commons.lang3.StringUtils;
  8 +import org.apache.commons.net.ftp.FTPClient;
  9 +import org.apache.commons.net.ftp.FTPFile;
  10 +import org.apache.commons.net.ftp.FTPReply;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import java.io.IOException;
  14 +import java.io.InputStream;
  15 +import java.net.SocketException;
  16 +import java.util.LinkedList;
  17 +import java.util.List;
  18 +
  19 +/**
  20 + * FTP服务工具类
  21 + */
  22 +@Log4j2
  23 +@Component
  24 +@RequiredArgsConstructor
  25 +public class FtpUtils {
  26 +
  27 + private final FtpConfigBean ftpConfigBean;
  28 +
  29 + /**
  30 + * 获取 FTPClient对象
  31 + * @return FTPClient对象
  32 + */
  33 + private FTPClient getFTPClient() {
  34 + /**
  35 + * 创建 FTPClient对象(对于连接ftp服务器,以及上传和上传都必须要用到一个对象)
  36 + */
  37 + try {
  38 + FTPClient ftpClient = new FTPClient();
  39 + /**
  40 + * 连接 FTP服务
  41 + */
  42 + // 设置编码
  43 + ftpClient.setControlEncoding("UTF-8");
  44 + // 设置连接超时时间(单位:毫秒)
  45 + ftpClient.setConnectTimeout(10 * 1000);
  46 + // 连接
  47 + ftpClient.connect(ftpConfigBean.getHost(), ftpConfigBean.getPort());
  48 + // 登录
  49 + ftpClient.login(ftpConfigBean.getUsername(), ftpConfigBean.getPassword());
  50 + /**
  51 + * ftpClient.getReplyCode():接受状态码(如果成功,返回230,如果失败返回503)
  52 + * FTPReply.isPositiveCompletion():如果连接成功返回true,否则返回false
  53 + */
  54 + if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
  55 + log.error("未连接到FTP服务,用户名或密码错误");
  56 + // 连接失败,断开连接
  57 + ftpClient.disconnect();
  58 + return null;
  59 + } else {
  60 + log.info("连接到FTP服务成功");
  61 + // 设置二进制方式传输文件
  62 + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
  63 + // 设置被动工作模式,文件传输端口设置,否则文件上传不成功,也不报错
  64 + ftpClient.enterLocalPassiveMode();
  65 + }
  66 + return ftpClient;
  67 + } catch (SocketException e) {
  68 + log.error("FTP的IP地址错误,请正确配置。");
  69 + throw new FtpException("FTP的IP地址错误,请正确配置。");
  70 + } catch (IOException e) {
  71 + log.error("FTP的端口错误,请正确配置。");
  72 + throw new FtpException("FTP的端口错误,请正确配置。");
  73 + } catch (Exception e) {
  74 + log.error("获取ftp客户端异常");
  75 + throw new FtpException("获取ftp客户端异常");
  76 + }
  77 + }
  78 +
  79 + /**
  80 + * 断开 FTPClient对象
  81 + */
  82 + private void closeConnect(FTPClient ftpClient) {
  83 + try {
  84 + if (ftpClient != null && ftpClient.isConnected()) {
  85 + ftpClient.logout();
  86 + // 断开ftp的连接
  87 + ftpClient.disconnect();
  88 + log.info("关闭ftp客户端成功");
  89 + }
  90 + } catch (Exception e) {
  91 + log.error("关闭ftp客户端异常");
  92 + throw new FtpException("关闭ftp客户端异常");
  93 + }
  94 + }
  95 +
  96 + /**
  97 + * 创建文件夹
  98 + * @param ftpBasePath FTP用户上传的根目录
  99 + * @param dirPath 需要创建的文件夹,多层使用/隔开
  100 + * @return
  101 + */
  102 + public boolean createDirectory(String ftpBasePath, String dirPath) {
  103 + FTPClient ftpClient = getFTPClient();
  104 + try {
  105 + /**
  106 + * 切换到ftp的服务器路径。
  107 + * FTP服务为FTP虚拟用户默认了根目录,所以我们可以切换也可以不切换,结果是一样的,都会到用户的根目录下。推荐显示指定。
  108 + * FTP服务会判断文件夹已存在,不会创建,不存在,则会创建。
  109 + */
  110 + ftpClient.changeWorkingDirectory(ftpBasePath);
  111 + if (StringUtils.isBlank(dirPath)) {
  112 + return false;
  113 + }
  114 +
  115 + String[] dirPathArr = dirPath.split("/");
  116 + for (String dir : dirPathArr) {
  117 + if (StringUtils.isNotBlank(dir)) {
  118 + ftpClient.makeDirectory(dir);
  119 + // 切换到ftp的创建目录
  120 + ftpClient.changeWorkingDirectory(dir);
  121 + }
  122 + }
  123 + return true;
  124 + } catch (IOException e) {
  125 + log.error("创建文件夹异常");
  126 + throw new FtpException("创建文件夹异常");
  127 + } finally {
  128 + closeConnect(ftpClient);
  129 + }
  130 + }
  131 +
  132 + /**
  133 + * 查询指定路径下的所有文件的文件名
  134 + * @param dirPath 查询指定路径
  135 + * @return
  136 + */
  137 + public List<String> listFileName(String dirPath) {
  138 + if (StringUtils.isBlank(dirPath)) {
  139 + return null;
  140 + }
  141 + FTPClient ftpClient = getFTPClient();
  142 +
  143 + // 获得指定目录下所有文件名
  144 + FTPFile[] ftpFiles = null;
  145 + try {
  146 + //ftpClient.enterLocalPassiveMode(); // 列出路径下的所有文件的文件名
  147 + ftpFiles = ftpClient.listFiles(dirPath);
  148 + } catch (IOException e) {
  149 + log.info("获取文件列表失败");
  150 + throw new FtpException("获取文件列表失败");
  151 + } finally {
  152 + closeConnect(ftpClient);
  153 + }
  154 + List<String> fileNameList = new LinkedList<>();
  155 + for (int i = 0; ftpFiles != null && i < ftpFiles.length; i++) {
  156 + FTPFile file = ftpFiles[i];
  157 + if (file.isFile()) {
  158 + fileNameList.add(file.getName());
  159 + }
  160 + }
  161 + return fileNameList;
  162 + }
  163 +
  164 + /**
  165 + * 上传文件到ftp服务
  166 + * @param ftpBasePath FTP用户上传的根目录
  167 + * @param fileDirPath 上传的文件存储目录
  168 + * @param fileName 上传的文件名
  169 + * @param is 上传的文件输入流
  170 + */
  171 + public boolean uploadFileToFtp(String ftpBasePath, String fileDirPath, String fileName, InputStream is) {
  172 + FTPClient ftpClient = getFTPClient();
  173 + boolean result = false;
  174 + try {
  175 + // 创建文件存储目录
  176 + createDirectory(ftpBasePath, fileDirPath);
  177 + // 切换到ftp的文件目录,即文件上传目录
  178 + ftpClient.changeWorkingDirectory(fileDirPath);
  179 + ftpClient.setControlEncoding("UTF-8");
  180 + ftpClient.setBufferSize(1024 * 10);
  181 + // 设置文件类型为二进制方式传输文件
  182 + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
  183 + ftpClient.enterLocalPassiveMode();
  184 + ftpClient.setDefaultTimeout(18000);
  185 + ftpClient.setConnectTimeout(6000);
  186 + ftpClient.setSoTimeout(6000);
  187 + result = ftpClient.storeFile(fileName, is);
  188 + } catch (IOException e) {
  189 + log.error("上传文件到ftp服务失败:{}", e.getMessage());
  190 + throw new FtpException("上传文件到ftp服务失败:{}", e.getMessage());
  191 + } finally {
  192 + closeConnect(ftpClient);
  193 + }
  194 + return result;
  195 + }
  196 +
  197 + /**
  198 + * 从FTP中获取文件的输入流
  199 + * @param ftpFilePath ftp文件路径,根目录开始
  200 + * @return
  201 + */
  202 + public InputStream getInputStreamOfFtpFile(String ftpFilePath) {
  203 + FTPClient ftpClient = getFTPClient();
  204 +
  205 + InputStream is = null;
  206 + try {
  207 + is = ftpClient.retrieveFileStream(ftpFilePath);
  208 + } catch (IOException e) {
  209 + log.error("获取文件输入流异常");
  210 + throw new FtpException("获取文件输入流异常");
  211 + } finally {
  212 + closeConnect(ftpClient);
  213 + }
  214 + return is;
  215 + }
  216 +
  217 + /**
  218 + * 删除ftp文件
  219 + * @param ftpFilePath ftp文件路径,根目录开始
  220 + * @return
  221 + */
  222 + public boolean deleteFtpFile(String ftpFilePath) {
  223 + FTPClient ftpClient = getFTPClient();
  224 + boolean result = false;
  225 + try {
  226 + result = ftpClient.deleteFile(ftpFilePath);
  227 + } catch (IOException e) {
  228 + log.error("删除ftp文件失败:{}", e.getMessage());
  229 + throw new FtpException("删除ftp文件失败:{}", e.getMessage());
  230 + } finally {
  231 + closeConnect(ftpClient);
  232 + }
  233 + return result;
  234 + }
  235 +
  236 +}
  237 +
src/main/resources/application-dev100.yml
@@ -141,7 +141,7 @@ tuohua: @@ -141,7 +141,7 @@ tuohua:
141 historyUdpPort: 9999 141 historyUdpPort: 9999
142 ip : 61.169.120.202 142 ip : 61.169.120.202
143 jt1078: 143 jt1078:
144 - ports: 49101,49200 144 + ports: 49101,49101
145 port: 9100 145 port: 9100
146 httpPort: 3333 146 httpPort: 3333
147 addPortVal: 0 147 addPortVal: 0
@@ -155,7 +155,7 @@ tuohua: @@ -155,7 +155,7 @@ tuohua:
155 stopSendPort: 9102 155 stopSendPort: 9102
156 ws: ws://61.169.120.202:1909/schedule/{stream}.live.flv 156 ws: ws://61.169.120.202:1909/schedule/{stream}.live.flv
157 wss: wss://61.169.120.202:2930/schedule/{stream}.live.flv 157 wss: wss://61.169.120.202:2930/schedule/{stream}.live.flv
158 - downloadFLV: http://118.113.164.50:1909/schedule/{stream}.live.flv 158 + downloadFLV: http://61.169.120.202:1909/schedule/{stream}.live.flv
159 get: 159 get:
160 url: http://192.168.169.100:3333/video/{stream}.flv 160 url: http://192.168.169.100:3333/video/{stream}.flv
161 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey} 161 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey}
@@ -165,9 +165,9 @@ ftp: @@ -165,9 +165,9 @@ ftp:
165 host: 192.168.169.100 165 host: 192.168.169.100
166 httpPath: ftp://192.168.169.100 166 httpPath: ftp://192.168.169.100
167 filePathPrefix: http://192.168.169.100:10021/wvp-local 167 filePathPrefix: http://192.168.169.100:10021/wvp-local
168 - password: ftpadmin 168 + password: ftp@123
169 port: 21 169 port: 21
170 - username: ftp@123 170 + username: ftpadmin
171 retryTimes: 5 171 retryTimes: 5
172 retryWaitTimes: 3000 172 retryWaitTimes: 3000
173 173
src/main/resources/application-local.yml
@@ -152,7 +152,7 @@ tuohua: @@ -152,7 +152,7 @@ tuohua:
152 historyUdpPort: 9999 152 historyUdpPort: 9999
153 ip : 61.169.120.202 153 ip : 61.169.120.202
154 jt1078: 154 jt1078:
155 - ports: 9000,9500 155 + ports: 9000,9000
156 addPortVal: 30000 156 addPortVal: 30000
157 pushURL: http://192.168.169.100:3333/new/server/{pushKey}/{port}/{httpPort} 157 pushURL: http://192.168.169.100:3333/new/server/{pushKey}/{port}/{httpPort}
158 stopPushURL: http://192.168.169.100:3333/stop/channel/{pushKey}/{port}/{httpPort} 158 stopPushURL: http://192.168.169.100:3333/stop/channel/{pushKey}/{port}/{httpPort}
web_src/src/components/HistoricalRecord.vue
@@ -160,13 +160,15 @@ export default { @@ -160,13 +160,15 @@ export default {
160 items[i].channel = channel 160 items[i].channel = channel
161 items[i].name = items[i].startTime + '-' + items[i].endTime; 161 items[i].name = items[i].startTime + '-' + items[i].endTime;
162 } 162 }
163 - this.historyData = items  
164 - console.log(this.historyData) 163 + this.historyData = items;
165 this.loading = false 164 this.loading = false
166 } else if (res && res.data && res.data.data && res.data.data.msg) { 165 } else if (res && res.data && res.data.data && res.data.data.msg) {
167 this.$message.error(res.data.data.msg); 166 this.$message.error(res.data.data.msg);
168 this.loading = false 167 this.loading = false
169 - } else { 168 + } else if (items === undefined) {
  169 + this.historyData = [];
  170 + this.loading = false
  171 + }else {
170 this.loading = false 172 this.loading = false
171 } 173 }
172 }).cache(res => { 174 }).cache(res => {
web_src/src/components/JT1078Components/historical/HistoricalDataTree.vue
@@ -26,7 +26,8 @@ export default { @@ -26,7 +26,8 @@ export default {
26 //计算属性 类似于data概念", 26 //计算属性 类似于data概念",
27 computed: {}, 27 computed: {},
28 //监控data中的数据变化", 28 //监控data中的数据变化",
29 - watch: {}, 29 + watch: {
  30 + },
30 //方法集合", 31 //方法集合",
31 methods: { 32 methods: {
32 //点击事件 33 //点击事件