Commit e8fc19d8712d59563966809207381fce30ad395a

Authored by liujun001
1 parent b95fe5fb

优化视频

src/main/java/com/genersoft/iot/vmp/conf/StreamProxyTask.java 0 → 100644
  1 +package com.genersoft.iot.vmp.conf;
  2 +
  3 +import com.genersoft.iot.vmp.service.StremProxyService1078;
  4 +import org.apache.commons.collections4.CollectionUtils;
  5 +import org.apache.commons.lang3.StringUtils;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.data.redis.core.RedisTemplate;
  10 +import org.springframework.scheduling.annotation.Scheduled;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +import java.util.Date;
  14 +import java.util.Objects;
  15 +import java.util.Set;
  16 +import java.util.concurrent.TimeUnit;
  17 +
  18 +@Component
  19 +public class StreamProxyTask {
  20 + @Autowired
  21 + private RedisTemplate redisTemplate;
  22 + @Autowired
  23 + private StremProxyService1078 stremProxyService1078;
  24 + private Logger logger = LoggerFactory.getLogger(StreamProxyTask.class);
  25 +
  26 + public static final Long TIME_OUT = 180L;
  27 +
  28 + @Scheduled(cron = "0 15 * * * ? ")
  29 + public void work() {
  30 + Set<String> keys = redisTemplate.keys("tag:history:port:*");
  31 + if (CollectionUtils.isEmpty(keys)) {
  32 + return;
  33 + }
  34 + Long nowDate = new Date().getTime();
  35 + for (String key : keys) {
  36 + String stream = StringUtils.substringAfter(key, "tag:history:port:");
  37 + if (StringUtils.isEmpty(stream)) {
  38 + continue;
  39 + }
  40 +
  41 + Object value = redisTemplate.opsForValue().get("tag:history:httpPort:time:"+stream);
  42 + if(Objects.isNull(value)){
  43 + sendIORequestStop(stream);
  44 + continue;
  45 + }
  46 + try {
  47 + Long val = (Long) value;
  48 + if(val == 0L){
  49 + sendIORequestStop(stream);
  50 + continue;
  51 + }
  52 +
  53 + Long val1 = (nowDate-val)/1000;
  54 + if(val1 > TIME_OUT){
  55 + sendIORequestStop(stream);
  56 + }
  57 +
  58 + }catch (Exception e){
  59 + logger.error("[{}]停流失败",stream,e);
  60 + }
  61 + }
  62 +
  63 + // task execution logic
  64 + }
  65 +
  66 + private void sendIORequestStop(String stream){
  67 + try {
  68 + String sim = StringUtils.substringBeforeLast(stream,"-");
  69 + String channel = StringUtils.substringAfterLast(stream,"-");
  70 + Object port = redisTemplate.opsForValue().get("tag:history:port:" + stream);
  71 + Object portHtt = redisTemplate.opsForValue().get("tag:history:httpPort:" + stream);
  72 + stremProxyService1078.sendIORequestStop(sim,channel,stream, (Integer) port, (Integer) portHtt);
  73 +
  74 + }catch (Exception e){
  75 + logger.error("[{}]停流失败",stream,e);
  76 + }
  77 +
  78 + }
  79 +}
src/main/java/com/genersoft/iot/vmp/service/StremProxyService1078.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service;
  2 +
  3 +import java.util.Map;
  4 +
  5 +public interface StremProxyService1078 {
  6 + Map<String, Object> sendIORequestStop(String sim, String channel, String stream, Integer port, Integer httpPort);
  7 +
  8 + Map<String, Object> sendIORequestStop( String stream);
  9 +}
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -18,10 +18,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; @@ -18,10 +18,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
18 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 18 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
19 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 19 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
20 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; 20 import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
21 -import com.genersoft.iot.vmp.service.IGbStreamService;  
22 -import com.genersoft.iot.vmp.service.IMediaServerService;  
23 -import com.genersoft.iot.vmp.service.IMediaService;  
24 -import com.genersoft.iot.vmp.service.IStreamProxyService; 21 +import com.genersoft.iot.vmp.service.*;
25 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 22 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
26 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 23 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
27 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; 24 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
@@ -32,9 +29,11 @@ import com.genersoft.iot.vmp.utils.DateUtil; @@ -32,9 +29,11 @@ import com.genersoft.iot.vmp.utils.DateUtil;
32 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; 29 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
33 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; 30 import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
34 import com.github.pagehelper.PageInfo; 31 import com.github.pagehelper.PageInfo;
  32 +import org.apache.commons.lang3.StringUtils;
35 import org.slf4j.Logger; 33 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory; 34 import org.slf4j.LoggerFactory;
37 import org.springframework.beans.factory.annotation.Autowired; 35 import org.springframework.beans.factory.annotation.Autowired;
  36 +import org.springframework.data.redis.core.RedisTemplate;
38 import org.springframework.jdbc.datasource.DataSourceTransactionManager; 37 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
39 import org.springframework.scheduling.annotation.Scheduled; 38 import org.springframework.scheduling.annotation.Scheduled;
40 import org.springframework.stereotype.Service; 39 import org.springframework.stereotype.Service;
@@ -43,10 +42,8 @@ import org.springframework.transaction.TransactionStatus; @@ -43,10 +42,8 @@ import org.springframework.transaction.TransactionStatus;
43 import org.springframework.util.CollectionUtils; 42 import org.springframework.util.CollectionUtils;
44 import org.springframework.util.ObjectUtils; 43 import org.springframework.util.ObjectUtils;
45 44
46 -import java.util.HashMap;  
47 -import java.util.List;  
48 -import java.util.Map;  
49 -import java.util.UUID; 45 +import java.util.*;
  46 +import java.util.concurrent.TimeUnit;
50 import java.util.function.Function; 47 import java.util.function.Function;
51 import java.util.stream.Collectors; 48 import java.util.stream.Collectors;
52 49
@@ -106,14 +103,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -106,14 +103,18 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
106 103
107 @Autowired 104 @Autowired
108 TransactionDefinition transactionDefinition; 105 TransactionDefinition transactionDefinition;
  106 + @Autowired
  107 + private StremProxyService1078 stremProxyService1078;
  108 + @Autowired
  109 + private RedisTemplate redisTemplate;
109 110
110 111
111 @Override 112 @Override
112 public void save(StreamProxyItem param, GeneralCallback<StreamInfo> callback) { 113 public void save(StreamProxyItem param, GeneralCallback<StreamInfo> callback) {
113 MediaServerItem mediaInfo; 114 MediaServerItem mediaInfo;
114 - if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){ 115 + if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())) {
115 mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null); 116 mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null);
116 - }else { 117 + } else {
117 mediaInfo = mediaServerService.getOne(param.getMediaServerId()); 118 mediaInfo = mediaServerService.getOne(param.getMediaServerId());
118 } 119 }
119 if (mediaInfo == null) { 120 if (mediaInfo == null) {
@@ -144,17 +145,17 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -144,17 +145,17 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
144 if (schema.equalsIgnoreCase("rtsp")) { 145 if (schema.equalsIgnoreCase("rtsp")) {
145 port = mediaInfo.getRtspPort(); 146 port = mediaInfo.getRtspPort();
146 schemaForUri = schema; 147 schemaForUri = schema;
147 - }else if (schema.equalsIgnoreCase("flv")) { 148 + } else if (schema.equalsIgnoreCase("flv")) {
148 port = mediaInfo.getRtmpPort(); 149 port = mediaInfo.getRtmpPort();
149 schemaForUri = schema; 150 schemaForUri = schema;
150 - }else { 151 + } else {
151 port = mediaInfo.getRtmpPort(); 152 port = mediaInfo.getRtmpPort();
152 schemaForUri = schema; 153 schemaForUri = schema;
153 } 154 }
154 155
155 dstUrl = String.format("%s://%s:%s/%s/%s", schemaForUri, "127.0.0.1", port, param.getApp(), 156 dstUrl = String.format("%s://%s:%s/%s/%s", schemaForUri, "127.0.0.1", port, param.getApp(),
156 param.getStream()); 157 param.getStream());
157 - }else { 158 + } else {
158 dstUrl = String.format("rtsp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtspPort(), param.getApp(), 159 dstUrl = String.format("rtsp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtspPort(), param.getApp(),
159 param.getStream()); 160 param.getStream());
160 } 161 }
@@ -165,7 +166,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -165,7 +166,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
165 // 更新 166 // 更新
166 if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) { 167 if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) {
167 saveResult = updateStreamProxy(param); 168 saveResult = updateStreamProxy(param);
168 - }else { // 新增 169 + } else { // 新增
169 saveResult = addStreamProxy(param); 170 saveResult = addStreamProxy(param);
170 } 171 }
171 if (!saveResult) { 172 if (!saveResult) {
@@ -181,11 +182,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -181,11 +182,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
181 if (param.isEnable()) { 182 if (param.isEnable()) {
182 String talkKey = UUID.randomUUID().toString(); 183 String talkKey = UUID.randomUUID().toString();
183 String delayTalkKey = UUID.randomUUID().toString(); 184 String delayTalkKey = UUID.randomUUID().toString();
184 - dynamicTask.startDelay(delayTalkKey, ()->{ 185 + dynamicTask.startDelay(delayTalkKey, () -> {
185 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false); 186 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);
186 if (streamInfo != null) { 187 if (streamInfo != null) {
187 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); 188 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
188 - }else { 189 + } else {
189 dynamicTask.stop(talkKey); 190 dynamicTask.stop(talkKey);
190 callback.run(ErrorCode.ERROR100.getCode(), "超时", null); 191 callback.run(ErrorCode.ERROR100.getCode(), "超时", null);
191 } 192 }
@@ -197,22 +198,21 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -197,22 +198,21 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
197 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( 198 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
198 mediaInfo, param.getApp(), param.getStream(), null, null); 199 mediaInfo, param.getApp(), param.getStream(), null, null);
199 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); 200 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
200 - }else { 201 + } else {
201 param.setEnable(false); 202 param.setEnable(false);
202 // 直接移除 203 // 直接移除
203 if (param.isEnableRemoveNoneReader()) { 204 if (param.isEnableRemoveNoneReader()) {
204 del(param.getApp(), param.getStream()); 205 del(param.getApp(), param.getStream());
205 - }else { 206 + } else {
206 updateStreamProxy(param); 207 updateStreamProxy(param);
207 } 208 }
208 - if (jsonObject == null){ 209 + if (jsonObject == null) {
209 callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null); 210 callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null);
210 - }else { 211 + } else {
211 callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null); 212 callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null);
212 } 213 }
213 } 214 }
214 - }  
215 - else{ 215 + } else {
216 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( 216 StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
217 mediaInfo, param.getApp(), param.getStream(), null, null); 217 mediaInfo, param.getApp(), param.getStream(), null, null);
218 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); 218 callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
@@ -228,8 +228,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -228,8 +228,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
228 for (int i = 0; i < paramArray.length; i++) { 228 for (int i = 0; i < paramArray.length; i++) {
229 if (paramArray[i].equalsIgnoreCase("-f")) { 229 if (paramArray[i].equalsIgnoreCase("-f")) {
230 if (i + 1 < paramArray.length - 1) { 230 if (i + 1 < paramArray.length - 1) {
231 - return paramArray[i+1];  
232 - }else { 231 + return paramArray[i + 1];
  232 + } else {
233 return null; 233 return null;
234 } 234 }
235 235
@@ -240,6 +240,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -240,6 +240,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
240 240
241 /** 241 /**
242 * 新增代理流 242 * 新增代理流
  243 + *
243 * @param streamProxyItem 244 * @param streamProxyItem
244 * @return 245 * @return
245 */ 246 */
@@ -259,14 +260,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -259,14 +260,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
259 return false; 260 return false;
260 } 261 }
261 } 262 }
262 - }else { 263 + } else {
263 //事务回滚 264 //事务回滚
264 dataSourceTransactionManager.rollback(transactionStatus); 265 dataSourceTransactionManager.rollback(transactionStatus);
265 return false; 266 return false;
266 } 267 }
267 result = true; 268 result = true;
268 dataSourceTransactionManager.commit(transactionStatus); //手动提交 269 dataSourceTransactionManager.commit(transactionStatus); //手动提交
269 - }catch (Exception e) { 270 + } catch (Exception e) {
270 logger.error("向数据库添加流代理失败:", e); 271 logger.error("向数据库添加流代理失败:", e);
271 dataSourceTransactionManager.rollback(transactionStatus); 272 dataSourceTransactionManager.rollback(transactionStatus);
272 } 273 }
@@ -277,6 +278,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -277,6 +278,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
277 278
278 /** 279 /**
279 * 更新代理流 280 * 更新代理流
  281 + *
280 * @param streamProxyItem 282 * @param streamProxyItem
281 * @return 283 * @return
282 */ 284 */
@@ -302,7 +304,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -302,7 +304,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
302 304
303 dataSourceTransactionManager.commit(transactionStatus); //手动提交 305 dataSourceTransactionManager.commit(transactionStatus); //手动提交
304 result = true; 306 result = true;
305 - }catch (Exception e) { 307 + } catch (Exception e) {
306 logger.error("未处理的异常 ", e); 308 logger.error("未处理的异常 ", e);
307 dataSourceTransactionManager.rollback(transactionStatus); 309 dataSourceTransactionManager.rollback(transactionStatus);
308 } 310 }
@@ -316,7 +318,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -316,7 +318,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
316 if (param.getMediaServerId() == null) { 318 if (param.getMediaServerId() == null) {
317 logger.warn("添加代理时MediaServerId 为null"); 319 logger.warn("添加代理时MediaServerId 为null");
318 return null; 320 return null;
319 - }else { 321 + } else {
320 mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); 322 mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
321 } 323 }
322 if (mediaServerItem == null) { 324 if (mediaServerItem == null) {
@@ -325,11 +327,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -325,11 +327,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
325 if (zlmServerFactory.isStreamReady(mediaServerItem, param.getApp(), param.getStream())) { 327 if (zlmServerFactory.isStreamReady(mediaServerItem, param.getApp(), param.getStream())) {
326 zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream()); 328 zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream());
327 } 329 }
328 - if ("ffmpeg".equalsIgnoreCase(param.getType())){ 330 + if ("ffmpeg".equalsIgnoreCase(param.getType())) {
329 result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrcUrl().trim(), param.getDstUrl(), 331 result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrcUrl().trim(), param.getDstUrl(),
330 param.getTimeoutMs() + "", param.isEnableAudio(), param.isEnableMp4(), 332 param.getTimeoutMs() + "", param.isEnableAudio(), param.isEnableMp4(),
331 param.getFfmpegCmdKey()); 333 param.getFfmpegCmdKey());
332 - }else { 334 + } else {
333 result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl().trim(), 335 result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl().trim(),
334 param.isEnableAudio(), param.isEnableMp4(), param.getRtpType()); 336 param.isEnableAudio(), param.isEnableMp4(), param.getRtpType());
335 } 337 }
@@ -338,12 +340,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -338,12 +340,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
338 if (result != null && result.getInteger("code") == 0) { 340 if (result != null && result.getInteger("code") == 0) {
339 JSONObject data = result.getJSONObject("data"); 341 JSONObject data = result.getJSONObject("data");
340 if (data == null) { 342 if (data == null) {
341 - logger.warn("[获取拉流代理的结果数据Data] 失败: {}", result ); 343 + logger.warn("[获取拉流代理的结果数据Data] 失败: {}", result);
342 return result; 344 return result;
343 } 345 }
344 String key = data.getString("key"); 346 String key = data.getString("key");
345 if (key == null) { 347 if (key == null) {
346 - logger.warn("[获取拉流代理的结果数据Data中的KEY] 失败: {}", result ); 348 + logger.warn("[获取拉流代理的结果数据Data中的KEY] 失败: {}", result);
347 return result; 349 return result;
348 } 350 }
349 param.setStreamKey(key); 351 param.setStreamKey(key);
@@ -354,14 +356,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -354,14 +356,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
354 356
355 @Override 357 @Override
356 public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) { 358 public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) {
357 - if (param ==null) { 359 + if (param == null) {
358 return null; 360 return null;
359 } 361 }
360 MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); 362 MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
361 JSONObject result = null; 363 JSONObject result = null;
362 - if ("ffmpeg".equalsIgnoreCase(param.getType())){ 364 + if ("ffmpeg".equalsIgnoreCase(param.getType())) {
363 result = zlmresTfulUtils.delFFmpegSource(mediaServerItem, param.getStreamKey()); 365 result = zlmresTfulUtils.delFFmpegSource(mediaServerItem, param.getStreamKey());
364 - }else { 366 + } else {
365 result = zlmresTfulUtils.delStreamProxy(mediaServerItem, param.getStreamKey()); 367 result = zlmresTfulUtils.delStreamProxy(mediaServerItem, param.getStreamKey());
366 } 368 }
367 return result; 369 return result;
@@ -374,6 +376,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -374,6 +376,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
374 376
375 @Override 377 @Override
376 public void del(String app, String stream) { 378 public void del(String app, String stream) {
  379 + Object object = redisTemplate.opsForValue().get("tag:history:httpPort:time:" + stream);
  380 + if (Objects.nonNull(object)) {
  381 +
  382 + return;
  383 + }
  384 + stremProxyService1078.sendIORequestStop(stream);
377 StreamProxyItem streamProxyItem = videoManagerStorager.queryStreamProxy(app, stream); 385 StreamProxyItem streamProxyItem = videoManagerStorager.queryStreamProxy(app, stream);
378 if (streamProxyItem != null) { 386 if (streamProxyItem != null) {
379 gbStreamService.sendCatalogMsg(streamProxyItem, CatalogEvent.DEL); 387 gbStreamService.sendCatalogMsg(streamProxyItem, CatalogEvent.DEL);
@@ -386,7 +394,13 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -386,7 +394,13 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
386 JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyItem); 394 JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyItem);
387 if (jsonObject != null && jsonObject.getInteger("code") == 0) { 395 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
388 logger.info("[移除代理]: 代理: {}/{}, 从zlm移除成功", app, stream); 396 logger.info("[移除代理]: 代理: {}/{}, 从zlm移除成功", app, stream);
389 - }else { 397 + String sim = StringUtils.substringBeforeLast(stream, "-");
  398 + String channel = StringUtils.substringAfterLast(stream, "-");
  399 + Object port = redisTemplate.opsForValue().get("tag:history:port:" + stream);
  400 + Object httpPort = redisTemplate.opsForValue().get("tag:history:httpPort:" + stream);
  401 +
  402 + stremProxyService1078.sendIORequestStop(sim, channel, stream, (Integer) port, (Integer) httpPort);
  403 + } else {
390 logger.info("[移除代理]: 代理: {}/{}, 从zlm移除失败", app, stream); 404 logger.info("[移除代理]: 代理: {}/{}, 从zlm移除失败", app, stream);
391 } 405 }
392 } 406 }
@@ -396,7 +410,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -396,7 +410,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
396 public boolean start(String app, String stream) { 410 public boolean start(String app, String stream) {
397 boolean result = false; 411 boolean result = false;
398 StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); 412 StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream);
399 - if (streamProxy != null && !streamProxy.isEnable() ) { 413 + if (streamProxy != null && !streamProxy.isEnable()) {
400 JSONObject jsonObject = addStreamProxyToZlm(streamProxy); 414 JSONObject jsonObject = addStreamProxyToZlm(streamProxy);
401 if (jsonObject == null) { 415 if (jsonObject == null) {
402 return false; 416 return false;
@@ -405,12 +419,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -405,12 +419,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
405 result = true; 419 result = true;
406 streamProxy.setEnable(true); 420 streamProxy.setEnable(true);
407 updateStreamProxy(streamProxy); 421 updateStreamProxy(streamProxy);
408 - }else { 422 + }else if(jsonObject.getInteger("code") == -1){
  423 + redisTemplate.opsForValue().set("stream:status:"+stream,"1",30, TimeUnit.SECONDS);
  424 + } else {
409 logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), 425 logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"),
410 - streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl()); 426 + streamProxy.getSrcUrl() == null ? streamProxy.getUrl() : streamProxy.getSrcUrl());
411 } 427 }
412 } else if (streamProxy != null && streamProxy.isEnable()) { 428 } else if (streamProxy != null && streamProxy.isEnable()) {
413 - return true ; 429 + return true;
414 } 430 }
415 return result; 431 return result;
416 } 432 }
@@ -434,11 +450,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -434,11 +450,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
434 JSONObject result = new JSONObject(); 450 JSONObject result = new JSONObject();
435 JSONObject mediaServerConfigResuly = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); 451 JSONObject mediaServerConfigResuly = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
436 if (mediaServerConfigResuly != null && mediaServerConfigResuly.getInteger("code") == 0 452 if (mediaServerConfigResuly != null && mediaServerConfigResuly.getInteger("code") == 0
437 - && mediaServerConfigResuly.getJSONArray("data").size() > 0){ 453 + && mediaServerConfigResuly.getJSONArray("data").size() > 0) {
438 JSONObject mediaServerConfig = mediaServerConfigResuly.getJSONArray("data").getJSONObject(0); 454 JSONObject mediaServerConfig = mediaServerConfigResuly.getJSONArray("data").getJSONObject(0);
439 455
440 for (String key : mediaServerConfig.keySet()) { 456 for (String key : mediaServerConfig.keySet()) {
441 - if (key.startsWith("ffmpeg.cmd")){ 457 + if (key.startsWith("ffmpeg.cmd")) {
442 result.put(key, mediaServerConfig.getString(key)); 458 result.put(key, mediaServerConfig.getString(key));
443 } 459 }
444 } 460 }
@@ -474,7 +490,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -474,7 +490,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
474 // 设置为离线 490 // 设置为离线
475 logger.info("恢复流代理失败" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); 491 logger.info("恢复流代理失败" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream());
476 updateStatus(false, streamProxyDto.getApp(), streamProxyDto.getStream()); 492 updateStatus(false, streamProxyDto.getApp(), streamProxyDto.getStream());
477 - }else { 493 + } else {
478 updateStatus(true, streamProxyDto.getApp(), streamProxyDto.getStream()); 494 updateStatus(true, streamProxyDto.getApp(), streamProxyDto.getStream());
479 } 495 }
480 } 496 }
@@ -519,16 +535,16 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -519,16 +535,16 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
519 return streamProxyMapper.updateStatus(app, stream, status); 535 return streamProxyMapper.updateStatus(app, stream, status);
520 } 536 }
521 537
522 - private void syncPullStream(String mediaServerId){ 538 + private void syncPullStream(String mediaServerId) {
523 MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); 539 MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId);
524 if (mediaServer != null) { 540 if (mediaServer != null) {
525 List<OnStreamChangedHookParam> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); 541 List<OnStreamChangedHookParam> allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL");
526 if (allPullStream.size() > 0) { 542 if (allPullStream.size() > 0) {
527 - zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ 543 + zlmresTfulUtils.getMediaList(mediaServer, jsonObject -> {
528 Map<String, StreamInfo> stringStreamInfoMap = new HashMap<>(); 544 Map<String, StreamInfo> stringStreamInfoMap = new HashMap<>();
529 if (jsonObject.getInteger("code") == 0) { 545 if (jsonObject.getInteger("code") == 0) {
530 JSONArray data = jsonObject.getJSONArray("data"); 546 JSONArray data = jsonObject.getJSONArray("data");
531 - if(data != null && data.size() > 0) { 547 + if (data != null && data.size() > 0) {
532 for (int i = 0; i < data.size(); i++) { 548 for (int i = 0; i < data.size(); i++) {
533 JSONObject streamJSONObj = data.getJSONObject(i); 549 JSONObject streamJSONObj = data.getJSONObject(i);
534 if ("rtsp".equals(streamJSONObj.getString("schema"))) { 550 if ("rtsp".equals(streamJSONObj.getString("schema"))) {
@@ -537,14 +553,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -537,14 +553,14 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
537 String stream = streamJSONObj.getString("stream"); 553 String stream = streamJSONObj.getString("stream");
538 streamInfo.setApp(app); 554 streamInfo.setApp(app);
539 streamInfo.setStream(stream); 555 streamInfo.setStream(stream);
540 - stringStreamInfoMap.put(app+stream, streamInfo); 556 + stringStreamInfoMap.put(app + stream, streamInfo);
541 } 557 }
542 } 558 }
543 } 559 }
544 } 560 }
545 if (stringStreamInfoMap.size() == 0) { 561 if (stringStreamInfoMap.size() == 0) {
546 redisCatchStorage.removeStream(mediaServerId, "PULL"); 562 redisCatchStorage.removeStream(mediaServerId, "PULL");
547 - }else { 563 + } else {
548 for (String key : stringStreamInfoMap.keySet()) { 564 for (String key : stringStreamInfoMap.keySet()) {
549 StreamInfo streamInfo = stringStreamInfoMap.get(key); 565 StreamInfo streamInfo = stringStreamInfoMap.get(key);
550 if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) { 566 if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) {
@@ -575,7 +591,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -575,7 +591,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
575 591
576 List<MediaServerItem> all = mediaServerService.getAllOnline(); 592 List<MediaServerItem> all = mediaServerService.getAllOnline();
577 593
578 - if (CollectionUtils.isEmpty(all)){ 594 + if (CollectionUtils.isEmpty(all)) {
579 return; 595 return;
580 } 596 }
581 597
@@ -583,7 +599,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -583,7 +599,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
583 599
584 List<StreamProxyItem> list = videoManagerStorager.getStreamProxyListForEnable(true); 600 List<StreamProxyItem> list = videoManagerStorager.getStreamProxyListForEnable(true);
585 601
586 - if (CollectionUtils.isEmpty(list)){ 602 + if (CollectionUtils.isEmpty(list)) {
587 return; 603 return;
588 } 604 }
589 605
@@ -594,7 +610,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -594,7 +610,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
594 // TODO 支持其他 schema 610 // TODO 支持其他 schema
595 JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), streamProxyItem.getStream(), "rtsp"); 611 JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), streamProxyItem.getStream(), "rtsp");
596 612
597 - if (mediaInfo == null){ 613 + if (mediaInfo == null) {
598 streamProxyItem.setStatus(false); 614 streamProxyItem.setStatus(false);
599 } else { 615 } else {
600 if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { 616 if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) {
src/main/java/com/genersoft/iot/vmp/service/impl/StremProxyService1078Impl.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.impl;
  2 +
  3 +import com.genersoft.iot.vmp.service.StremProxyService1078;
  4 +import com.genersoft.iot.vmp.vmanager.jt1078.platform.ben.HttpClientPostEntity;
  5 +import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.Jt1078ConfigBean;
  6 +import com.genersoft.iot.vmp.vmanager.jt1078.platform.handler.HttpClientUtil;
  7 +import org.apache.commons.collections4.CollectionUtils;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.data.redis.core.RedisTemplate;
  13 +import org.springframework.stereotype.Service;
  14 +import org.springframework.web.bind.annotation.PathVariable;
  15 +
  16 +import java.io.IOException;
  17 +import java.net.URISyntaxException;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +import java.util.Map;
  21 +import java.util.Objects;
  22 +import java.util.concurrent.TimeUnit;
  23 +
  24 +@Service
  25 +public class StremProxyService1078Impl implements StremProxyService1078 {
  26 +
  27 + @Autowired
  28 + private Jt1078ConfigBean jt1078ConfigBean;
  29 +
  30 + @Autowired
  31 + private HttpClientUtil httpClientUtil;
  32 + @Autowired
  33 + private RedisTemplate<Object, Object> redisTemplate;
  34 +
  35 + private static final Logger log = LoggerFactory.getLogger(StremProxyService1078Impl.class);
  36 +
  37 +
  38 + @Override
  39 + public Map<String, Object> sendIORequestStop(String sim, String channel, String stream, Integer port, Integer httpPort) {
  40 + Map<String, Object> resultMap = new HashMap<>();
  41 + if (StringUtils.isBlank(sim)) {
  42 + resultMap.put("code", "-100");
  43 + resultMap.put("message", "sim 不能为空");
  44 +
  45 + return resultMap;
  46 + }
  47 +
  48 + if (StringUtils.isBlank(channel)) {
  49 + resultMap.put("code", "-100");
  50 + resultMap.put("message", "channel 不能为空");
  51 +
  52 + return resultMap;
  53 + }
  54 +
  55 + String msg = jt1078ConfigBean.formatMessageStop(sim, channel);
  56 +
  57 +
  58 + String url = null;
  59 + try {
  60 + url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getJt1078SendPort());
  61 + HttpClientPostEntity entity = httpClientUtil.doPost(url, msg, null);
  62 +
  63 + url = jt1078ConfigBean.formatStopPushURL(stream, port, httpPort);
  64 + httpClientUtil.doGet(url, null);
  65 +
  66 +
  67 +
  68 + if (Objects.isNull(entity)) {
  69 + log.info("HttpClientPostEntity is null");
  70 + } else {
  71 + log.info(entity.getResultStr());
  72 + }
  73 +
  74 +
  75 + resultMap.put("code", "1");
  76 + resultMap.put("message", "OK");
  77 +
  78 + return resultMap;
  79 + } catch (URISyntaxException | IOException e) {
  80 + log.error("发送停止推流指令异常;[{}],[{}]", url, msg, e);
  81 +
  82 + resultMap.put("code", "-20");
  83 + resultMap.put("message", "发送停止推流指令异常");
  84 + return resultMap;
  85 + }
  86 + }
  87 +
  88 + @Override
  89 + public Map<String, Object> sendIORequestStop(String stream) {
  90 + String sim = StringUtils.substringBefore(stream, "-");
  91 + String channel = StringUtils.substringAfterLast(stream, "-");
  92 +
  93 + Object port = this.redisTemplate.opsForValue().get("tag:history:port:" + stream);
  94 + Object httpPort = this.redisTemplate.opsForValue().get("tag:history:httpPort:" + stream);
  95 +
  96 + return sendIORequestStop(sim, channel, stream, (Integer) port, (Integer) httpPort);
  97 + }
  98 +}
src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamContent.java
@@ -99,6 +99,9 @@ public class StreamContent { @@ -99,6 +99,9 @@ public class StreamContent {
99 99
100 private double progress; 100 private double progress;
101 101
  102 + public StreamContent(){
  103 +
  104 + }
102 public StreamContent(StreamInfo streamInfo) { 105 public StreamContent(StreamInfo streamInfo) {
103 if (streamInfo == null) { 106 if (streamInfo == null) {
104 return; 107 return;
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/Jt1078OfCarController.java
  1 +//
  2 +// Source code recreated from a .class file by IntelliJ IDEA
  3 +// (powered by FernFlower decompiler)
  4 +//
  5 +
1 package com.genersoft.iot.vmp.vmanager.jt1078.platform; 6 package com.genersoft.iot.vmp.vmanager.jt1078.platform;
2 7
3 import com.alibaba.fastjson2.JSON; 8 import com.alibaba.fastjson2.JSON;
  9 +import com.alibaba.fastjson2.JSONArray;
4 import com.alibaba.fastjson2.JSONException; 10 import com.alibaba.fastjson2.JSONException;
  11 +import com.alibaba.fastjson2.JSONObject;
5 import com.genersoft.iot.vmp.conf.MediaConfig; 12 import com.genersoft.iot.vmp.conf.MediaConfig;
6 -import com.genersoft.iot.vmp.conf.UserSetting;  
7 -import com.genersoft.iot.vmp.conf.security.SecurityUtils; 13 +import com.genersoft.iot.vmp.conf.StreamProxyTask;
  14 +import com.genersoft.iot.vmp.conf.exception.ControllerException;
8 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; 15 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
9 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; 16 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
10 import com.genersoft.iot.vmp.service.IStreamPushService; 17 import com.genersoft.iot.vmp.service.IStreamPushService;
  18 +import com.genersoft.iot.vmp.service.StremProxyService1078;
11 import com.genersoft.iot.vmp.vmanager.bean.StreamContent; 19 import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
12 import com.genersoft.iot.vmp.vmanager.jt1078.platform.ben.HttpClientPostEntity; 20 import com.genersoft.iot.vmp.vmanager.jt1078.platform.ben.HttpClientPostEntity;
13 import com.genersoft.iot.vmp.vmanager.jt1078.platform.ben.TestEntity; 21 import com.genersoft.iot.vmp.vmanager.jt1078.platform.ben.TestEntity;
@@ -15,52 +23,51 @@ import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.Jt1078ConfigBean; @@ -15,52 +23,51 @@ import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.Jt1078ConfigBean;
15 import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.RtspConfigBean; 23 import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.RtspConfigBean;
16 import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.TuohuaConfigBean; 24 import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.TuohuaConfigBean;
17 import com.genersoft.iot.vmp.vmanager.jt1078.platform.handler.HttpClientUtil; 25 import com.genersoft.iot.vmp.vmanager.jt1078.platform.handler.HttpClientUtil;
18 -  
19 import com.genersoft.iot.vmp.vmanager.streamProxy.StreamProxyController; 26 import com.genersoft.iot.vmp.vmanager.streamProxy.StreamProxyController;
20 import com.genersoft.iot.vmp.vmanager.streamPush.StreamPushController; 27 import com.genersoft.iot.vmp.vmanager.streamPush.StreamPushController;
21 -import com.sun.jna.platform.win32.Rasapi32Util;  
22 -import com.xiaoleilu.hutool.crypto.SecureUtil;  
23 -import com.xiaoleilu.hutool.crypto.asymmetric.KeyType;  
24 -import com.xiaoleilu.hutool.crypto.asymmetric.RSA; 28 +
  29 +import java.io.ByteArrayOutputStream;
  30 +import java.io.IOException;
  31 +import java.net.URISyntaxException;
  32 +import java.security.Key;
  33 +import java.security.KeyFactory;
  34 +import java.security.spec.X509EncodedKeySpec;
  35 +import java.text.MessageFormat;
  36 +import java.util.ArrayList;
  37 +import java.util.Date;
  38 +import java.util.HashMap;
  39 +import java.util.Iterator;
  40 +import java.util.List;
  41 +import java.util.Map;
  42 +import java.util.Objects;
  43 +import java.util.concurrent.TimeUnit;
  44 +import javax.crypto.Cipher;
  45 +import javax.servlet.http.HttpServletRequest;
  46 +
25 import org.apache.commons.collections4.CollectionUtils; 47 import org.apache.commons.collections4.CollectionUtils;
  48 +import org.apache.commons.collections4.MapUtils;
26 import org.apache.commons.lang3.RandomUtils; 49 import org.apache.commons.lang3.RandomUtils;
27 import org.apache.commons.lang3.StringUtils; 50 import org.apache.commons.lang3.StringUtils;
28 -  
29 import org.apache.http.client.CookieStore; 51 import org.apache.http.client.CookieStore;
30 -  
31 import org.apache.http.cookie.Cookie; 52 import org.apache.http.cookie.Cookie;
32 -import org.apache.logging.log4j.util.Base64Util;  
33 import org.jetbrains.annotations.Nullable; 53 import org.jetbrains.annotations.Nullable;
34 import org.slf4j.Logger; 54 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory; 55 import org.slf4j.LoggerFactory;
36 import org.springframework.beans.factory.annotation.Autowired; 56 import org.springframework.beans.factory.annotation.Autowired;
  57 +import org.springframework.beans.factory.annotation.Value;
37 import org.springframework.data.redis.core.RedisTemplate; 58 import org.springframework.data.redis.core.RedisTemplate;
38 import org.springframework.util.Base64Utils; 59 import org.springframework.util.Base64Utils;
39 -import org.springframework.web.bind.annotation.*; 60 +import org.springframework.web.bind.annotation.GetMapping;
  61 +import org.springframework.web.bind.annotation.PathVariable;
  62 +import org.springframework.web.bind.annotation.PostMapping;
  63 +import org.springframework.web.bind.annotation.RequestBody;
  64 +import org.springframework.web.bind.annotation.RequestMapping;
  65 +import org.springframework.web.bind.annotation.RestController;
40 66
41 -import javax.crypto.Cipher;  
42 -import javax.servlet.http.HttpServletRequest;  
43 -import javax.xml.bind.DatatypeConverter;  
44 -import java.io.ByteArrayOutputStream;  
45 -import java.io.IOException;  
46 -import java.net.URISyntaxException;  
47 -import java.security.*;  
48 -import java.security.spec.InvalidKeySpecException;  
49 -import java.security.spec.X509EncodedKeySpec;  
50 -import java.text.MessageFormat;  
51 -import java.util.*;  
52 -import java.util.concurrent.TimeUnit;  
53 -  
54 -/**  
55 - * @author liujun  
56 - * @date 2024年10月21日 14:12  
57 - */  
58 @RestController 67 @RestController
59 -@RequestMapping("/api/jt1078/query") 68 +@RequestMapping({"/api/jt1078/query"})
60 public class Jt1078OfCarController { 69 public class Jt1078OfCarController {
61 private static final Logger log = LoggerFactory.getLogger(Jt1078OfCarController.class); 70 private static final Logger log = LoggerFactory.getLogger(Jt1078OfCarController.class);
62 -  
63 -  
64 @Autowired 71 @Autowired
65 private HttpClientUtil httpClientUtil; 72 private HttpClientUtil httpClientUtil;
66 @Autowired 73 @Autowired
@@ -75,478 +82,500 @@ public class Jt1078OfCarController { @@ -75,478 +82,500 @@ public class Jt1078OfCarController {
75 private StreamPushController streamPushController; 82 private StreamPushController streamPushController;
76 @Autowired 83 @Autowired
77 private StreamProxyController streamProxyController; 84 private StreamProxyController streamProxyController;
78 -  
79 @Autowired 85 @Autowired
80 private IStreamPushService streamPushService; 86 private IStreamPushService streamPushService;
81 -  
82 private String jsessionid = null; 87 private String jsessionid = null;
83 -  
84 @Autowired 88 @Autowired
85 private RedisTemplate<Object, Object> redisTemplate; 89 private RedisTemplate<Object, Object> redisTemplate;
86 -  
87 - 90 + @Autowired
  91 + private StremProxyService1078 stremProxyService1078;
88 private static final long TIME_COUNT = 300000L; 92 private static final long TIME_COUNT = 300000L;
  93 + private Date tokenDate;
89 94
  95 + @Value("${spring.profiles.active}")
  96 + private String profilesActive;
90 97
91 - private Date tokenDate;  
92 98
  99 + public Jt1078OfCarController() {
  100 + }
93 101
94 - @GetMapping("/company/tree") 102 + @GetMapping({"/company/tree"})
95 public Map<String, Object> requestTreeOfCompany() { 103 public Map<String, Object> requestTreeOfCompany() {
96 - Map<String, Object> resultMap = new HashMap<>(); 104 + Map<String, Object> resultMap = new HashMap();
  105 +
97 try { 106 try {
98 resultMap.put("code", "1"); 107 resultMap.put("code", "1");
99 -  
100 - List<HashMap<String, Object>> compList = new ArrayList<>();  
101 - compList.add(tuohuaConfigBean.combationTree("100", "company1", "100", false, "新城市公交", "100", false, "span><img src='/metronic_v4.5.4/layui/icon/company1.png' class ='imageIcon' /></span><span>新城市公交</span>",  
102 - "<span><img src='/metronic_v4.5.4/layui/icon/company1.png' class ='imageIcon' /></span><span>浦东公交</span>", 2));  
103 - 108 + List<HashMap<String, Object>> compList = new ArrayList();
  109 + compList.add(this.tuohuaConfigBean.combationTree("100", "company1", "100", false, "新城市公交", "100", false, "span><img src='/metronic_v4.5.4/layui/icon/company1.png' class ='imageIcon' /></span><span>新城市公交</span>", "<span><img src='/metronic_v4.5.4/layui/icon/company1.png' class ='imageIcon' /></span><span>浦东公交</span>", 2));
104 resultMap.put("code", "1"); 110 resultMap.put("code", "1");
105 resultMap.put("result", compList); 111 resultMap.put("result", compList);
106 - } catch (JSONException e) { 112 + } catch (JSONException var3) {
107 resultMap.put("code", "-100"); 113 resultMap.put("code", "-100");
108 - resultMap.put("message", "请求错误,请联系管理员");  
109 - 114 + resultMap.put("msg", "请求错误,请联系管理员");
110 } 115 }
111 116
112 return resultMap; 117 return resultMap;
113 } 118 }
114 119
115 - @GetMapping("/car/tree/{companyId}") 120 + @GetMapping({"/car/tree/{companyId}"})
116 public Map<String, Object> requestTreeOfCarByCompanyId(@PathVariable String companyId) { 121 public Map<String, Object> requestTreeOfCarByCompanyId(@PathVariable String companyId) {
117 - Map<String, Object> resultMap = new HashMap<>(); 122 + Map<String, Object> resultMap = new HashMap();
  123 +
118 try { 124 try {
119 - List<HashMap<String, Object>> linesCars = tuohuaConfigBean.requestOfLineAndCarAndCombationTree(httpClientUtil, companyId); 125 + List<HashMap<String, Object>> linesCars = this.tuohuaConfigBean.requestOfLineAndCarAndCombationTree(this.httpClientUtil, companyId);
120 resultMap.put("result", linesCars); 126 resultMap.put("result", linesCars);
121 resultMap.put("code", "1"); 127 resultMap.put("code", "1");
122 - } catch (Exception e) { 128 + } catch (Exception var4) {
123 resultMap.put("code", "-100"); 129 resultMap.put("code", "-100");
124 - resultMap.put("message", "请求错误,请联系管理员"); 130 + resultMap.put("msg", "请求错误,请联系管理员");
125 } 131 }
126 132
127 return resultMap; 133 return resultMap;
128 } 134 }
129 135
130 - @GetMapping("/car/sim/{zbh}") 136 + @GetMapping({"/car/sim/{zbh}"})
131 public Map<String, Object> requestSimple(@PathVariable String zbh) { 137 public Map<String, Object> requestSimple(@PathVariable String zbh) {
132 - Map<String, Object> resultMap = new HashMap<>(); 138 + Map<String, Object> resultMap = new HashMap();
  139 +
133 try { 140 try {
134 - if (cookieTimeOut()) {  
135 - requestToken(); 141 + if (this.cookieTimeOut()) {
  142 + this.requestToken();
136 } 143 }
137 - String url = MessageFormat.format(tuohuaConfigBean.getSimURL(), zbh);  
138 - HttpClientPostEntity clientPostEntity = httpClientUtil.doGet(url, jsessionid); 144 +
  145 + String url = MessageFormat.format(this.tuohuaConfigBean.getSimURL(), zbh);
  146 + HttpClientPostEntity clientPostEntity = this.httpClientUtil.doGet(url, this.jsessionid);
139 if (Objects.isNull(clientPostEntity)) { 147 if (Objects.isNull(clientPostEntity)) {
140 resultMap.put("code", "-1"); 148 resultMap.put("code", "-1");
141 - resultMap.put("message", "请求错误,请联系管理员"); 149 + resultMap.put("msg", "请求错误,请联系管理员");
  150 + return resultMap;
  151 + } else {
  152 + HashMap<String, Object> hashMap = (HashMap) JSON.parseObject(clientPostEntity.getResultStr(), HashMap.class);
  153 + resultMap.put("code", "1");
  154 + resultMap.put("result", hashMap.get("sim"));
142 return resultMap; 155 return resultMap;
143 } 156 }
144 -  
145 - HashMap<String, Object> hashMap = JSON.parseObject(clientPostEntity.getResultStr(), HashMap.class);  
146 - resultMap.put("code", "1");  
147 - resultMap.put("result", hashMap.get("sim"));  
148 -// resultMap.put("result", JSON.parseArray(clientPostEntity.getResultStr(),HashMap.class));  
149 - return resultMap;  
150 - } catch (URISyntaxException | IOException | JSONException e) { 157 + } catch (IOException | JSONException | URISyntaxException var6) {
  158 + Exception e = var6;
151 log.error("请求token异常", e); 159 log.error("请求token异常", e);
152 resultMap.put("code", "-100"); 160 resultMap.put("code", "-100");
153 - resultMap.put("message", "请求错误,请联系管理员");  
154 - jsessionid = null; 161 + resultMap.put("msg", "请求错误,请联系管理员");
  162 + this.jsessionid = null;
  163 + return resultMap;
155 } 164 }
156 - return resultMap;  
157 } 165 }
158 166
159 - @GetMapping("/send/request/io/{sim}/{channel}") 167 + @GetMapping({"/send/request/io/{sim}/{channel}"})
160 public Map<String, Object> sendIORequest(@PathVariable String sim, @PathVariable String channel) { 168 public Map<String, Object> sendIORequest(@PathVariable String sim, @PathVariable String channel) {
161 - Map<String, Object> resultMap = new HashMap<>(); 169 + Map<String, Object> resultMap = new HashMap();
162 if (StringUtils.isBlank(sim)) { 170 if (StringUtils.isBlank(sim)) {
163 resultMap.put("code", "-100"); 171 resultMap.put("code", "-100");
164 - resultMap.put("message", "sim 不能为空");  
165 - 172 + resultMap.put("msg", "sim 不能为空");
166 return resultMap; 173 return resultMap;
167 - }  
168 -  
169 - if (StringUtils.isBlank(channel)) { 174 + } else if (StringUtils.isBlank(channel)) {
170 resultMap.put("code", "-100"); 175 resultMap.put("code", "-100");
171 - resultMap.put("message", "channel 不能为空");  
172 - 176 + resultMap.put("msg", "channel 不能为空");
173 return resultMap; 177 return resultMap;
174 - }  
175 - String msg = null;  
176 -  
177 - String stream = StringUtils.join(sim, "-", channel);  
178 - String url = StringUtils.replace(jt1078ConfigBean.getJt1078Url(), "{0}", jt1078ConfigBean.getJt1078SendPort());  
179 - try {  
180 - StreamContent streamContent = getStreamContentPlayURL(StringUtils.join(stream));  
181 - if (Objects.isNull(streamContent) || StringUtils.isBlank(streamContent.getWs_flv())) {  
182 - //List<StreamPushItem> streamPushItems = streamPushService.getPushList(StringUtils.join(sim, "-", channel));  
183 - // int count = CollectionUtils.size(streamPushItems);  
184 - // if (count == 0) {  
185 - HttpClientPostEntity entity = createServerLister(stream);  
186 - if (Objects.isNull(entity)) {  
187 - resultMap.put("code", "-20");  
188 - resultMap.put("message", "新建链接错误,请稍后再试");  
189 - return resultMap;  
190 - }  
191 -  
192 - resultMap.put("port", entity.getPort());  
193 - resultMap.put("httpPort", entity.getHttpPort());  
194 - resultMap.put("stream", stream); 178 + } else {
  179 + String msg = null;
  180 + String stream = StringUtils.join(new String[]{sim, "-", channel});
  181 + String url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getJt1078SendPort());
  182 +
  183 + try {
  184 + StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{stream}));
  185 + if (Objects.isNull(streamContent) || StringUtils.isBlank(streamContent.getWs_flv())) {
  186 + HttpClientPostEntity entity = this.createServerLister(stream);
  187 + if (Objects.isNull(entity)) {
  188 + resultMap.put("code", "-20");
  189 + resultMap.put("msg", "新建链接错误,请稍后再试");
  190 +
  191 + return resultMap;
  192 + }
195 193
196 - redisTemplate.opsForValue().set("tag:history:port:" + stream, entity.getPort(), 2, TimeUnit.DAYS);  
197 - redisTemplate.opsForValue().set("tag:history:httpPort:" + stream, entity.getHttpPort(), 2, TimeUnit.DAYS);  
198 - redisTemplate.opsForValue().set("tag:history:httpPort:time:" + stream, new Date().getTime(), 1800, TimeUnit.SECONDS); 194 + resultMap.put("port", entity.getPort());
  195 + resultMap.put("httpPort", entity.getHttpPort());
  196 + resultMap.put("stream", stream);
  197 + this.redisTemplate.opsForValue().set("tag:history:port:" + stream, entity.getPort(), 2L, TimeUnit.DAYS);
  198 + this.redisTemplate.opsForValue().set("tag:history:httpPort:" + stream, entity.getHttpPort(), 2L, TimeUnit.DAYS);
  199 + this.redisTemplate.opsForValue().set("tag:history:httpPort:time:" + stream, (new Date()).getTime(), StreamProxyTask.TIME_OUT, TimeUnit.SECONDS);
  200 + msg = this.jt1078ConfigBean.formatMessageId(sim, channel, this.rtspConfigBean, entity.getPort());
  201 + entity = this.httpClientUtil.doPost(url, msg, (String) null);
  202 + Map<String, Object> resultMap1 = this.chooseEntity(entity, url, false);
  203 + if (Objects.nonNull(resultMap1)) {
  204 + return resultMap1;
  205 + }
199 206
200 - msg = jt1078ConfigBean.formatMessageId(sim, channel, rtspConfigBean, entity.getPort()); 207 + log.info(entity.getResultStr());
  208 + Thread.sleep(2000L);
  209 + this.createStreamProxy(sim + "-" + channel);
  210 + Map<String, Object> resultMap2 = this.getStreamContent(stream);
  211 + if (Objects.nonNull(resultMap2) && Objects.nonNull(resultMap2.get("code")) && !StringUtils.equals(resultMap2.get("code").toString(), "1")) {
  212 + return resultMap2;
  213 + }
201 214
202 - entity = httpClientUtil.doPost(url, msg, null);  
203 -// Map<String, Object> resultMap1 = chooseEntity(entity);  
204 -// if (Objects.nonNull(resultMap1)) {  
205 -// return resultMap1;  
206 -// }  
207 - log.info(entity.getResultStr());  
208 - createStreamProxy(sim + "-" + channel); 215 + streamContent = (StreamContent) resultMap2.get("streamContent");
  216 + }else{
  217 + resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:"+stream));
  218 + resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:"+stream));
  219 + resultMap.put("stream", stream);
  220 + }
209 221
210 - streamContent = getStreamContent(stream);  
211 - }  
212 - resultMap.put("code", "1");  
213 - resultMap.put("message", "OK");  
214 - resultMap.put("data", streamContent);  
215 222
216 - return resultMap;  
217 - } catch (URISyntaxException | IOException | InterruptedException e) {  
218 - log.error("发送推流指令异常;[{}],[{}]", url, msg, e);  
219 223
220 - resultMap.put("code", "-20");  
221 - resultMap.put("message", "发送推流指令异常");  
222 224
223 - return resultMap; 225 + resultMap.put("code", "1");
  226 + resultMap.put("message", "OK");
  227 + resultMap.put("data", streamContent);
  228 + return resultMap;
  229 + } catch (IOException | InterruptedException | URISyntaxException var11) {
  230 + Exception e = var11;
  231 + log.error("发送推流指令异常;[{}],[{}]", new Object[]{url, msg, e});
  232 + resultMap.put("code", "-20");
  233 + resultMap.put("msg", "发送推流指令异常");
  234 + return resultMap;
  235 + }
224 } 236 }
225 } 237 }
226 238
227 -  
228 - @GetMapping("/send/stop/io/{sim}/{channel}/{stream}/{port}/{httpPort}") 239 + @GetMapping({"/send/stop/io/{sim}/{channel}/{stream}/{port}/{httpPort}"})
229 public Map<String, Object> sendIORequestStop(@PathVariable String sim, @PathVariable String channel, @PathVariable String stream, @PathVariable Integer port, @PathVariable Integer httpPort) { 240 public Map<String, Object> sendIORequestStop(@PathVariable String sim, @PathVariable String channel, @PathVariable String stream, @PathVariable Integer port, @PathVariable Integer httpPort) {
230 - Map<String, Object> resultMap = new HashMap<>(); 241 + Map<String, Object> resultMap = new HashMap();
231 if (StringUtils.isBlank(sim)) { 242 if (StringUtils.isBlank(sim)) {
232 resultMap.put("code", "-100"); 243 resultMap.put("code", "-100");
233 - resultMap.put("message", "sim 不能为空");  
234 - 244 + resultMap.put("msg", "sim 不能为空");
235 return resultMap; 245 return resultMap;
236 - }  
237 -  
238 - if (StringUtils.isBlank(channel)) { 246 + } else if (StringUtils.isBlank(channel)) {
239 resultMap.put("code", "-100"); 247 resultMap.put("code", "-100");
240 - resultMap.put("message", "channel 不能为空");  
241 - 248 + resultMap.put("msg", "channel 不能为空");
242 return resultMap; 249 return resultMap;
243 - }  
244 -  
245 - String msg = jt1078ConfigBean.formatMessageStop(sim, channel);  
246 -  
247 -  
248 - String url = jt1078ConfigBean.formatStopPushURL(stream, port, httpPort);  
249 - try {  
250 - streamProxyController.del(stream,stream);  
251 -  
252 - httpClientUtil.doGet(url, null);  
253 -  
254 - url = StringUtils.replace(jt1078ConfigBean.getJt1078Url(), "{0}", jt1078ConfigBean.getStopSendPort());  
255 - List<StreamPushItem> streamPushItems = streamPushService.getPushList(stream);  
256 - int count = CollectionUtils.size(streamPushItems);  
257 - for (int i = 0; i < count; i++) {  
258 - StreamPushItem item = streamPushItems.get(i); 250 + } else {
  251 + Map<String, Object> resultMap1 = this.stremProxyService1078.sendIORequestStop(sim, channel, stream, port, httpPort);
  252 + if (Objects.nonNull(resultMap1) && Objects.nonNull(resultMap1.get("code")) && !StringUtils.equals(resultMap1.get("code").toString(), "1")) {
  253 + return resultMap1;
  254 + } else {
259 try { 255 try {
260 - streamPushService.stop(item.getApp(), item.getStream());  
261 - } catch (Exception e) {  
262 - log.error("推流停止失败,[{}]", item, e);  
263 - }  
264 -  
265 - } 256 + this.streamProxyController.del(stream, stream);
  257 + List<StreamPushItem> streamPushItems = this.streamPushService.getPushList(stream);
  258 + int count = CollectionUtils.size(streamPushItems);
  259 +
  260 + for (int i = 0; i < count; ++i) {
  261 + StreamPushItem item = streamPushItems.get(i);
  262 +
  263 + try {
  264 + this.streamPushService.stop(item.getApp(), item.getStream());
  265 + } catch (Exception var13) {
  266 + Exception e = var13;
  267 + log.error("推流停止失败,[{}]", item, e);
  268 + }
  269 + }
266 270
267 - HttpClientPostEntity entity = httpClientUtil.doPost(url, msg, null);  
268 - if (Objects.isNull(entity)) {  
269 - log.info("HttpClientPostEntity is null");  
270 - } else {  
271 - log.info(entity.getResultStr()); 271 + resultMap.put("code", "1");
  272 + resultMap.put("message", "OK");
  273 + return resultMap;
  274 + } catch (Exception var14) {
  275 + resultMap.put("code", "-20");
  276 + resultMap.put("msg", "发送停止推流指令异常");
  277 + return resultMap;
  278 + }
272 } 279 }
273 -  
274 -  
275 - resultMap.put("code", "1");  
276 - resultMap.put("message", "OK");  
277 -  
278 - return resultMap;  
279 - } catch (URISyntaxException | IOException e) {  
280 - log.error("发送停止推流指令异常;[{}],[{}]", url, msg, e);  
281 -  
282 - resultMap.put("code", "-20");  
283 - resultMap.put("message", "发送停止推流指令异常");  
284 - return resultMap;  
285 } 280 }
286 } 281 }
287 282
288 - @GetMapping("/history/list/{sim}/{channel}/{startTime}/{endTime}") 283 + @GetMapping({"/history/list/{sim}/{channel}/{startTime}/{endTime}"})
289 public Map<String, Object> historyListOfSim(@PathVariable String sim, @PathVariable String channel, @PathVariable String startTime, @PathVariable String endTime) { 284 public Map<String, Object> historyListOfSim(@PathVariable String sim, @PathVariable String channel, @PathVariable String startTime, @PathVariable String endTime) {
290 - Map<String, Object> resultMap = new HashMap<>(); 285 + Map<String, Object> resultMap = new HashMap();
291 if (StringUtils.isBlank(sim)) { 286 if (StringUtils.isBlank(sim)) {
292 resultMap.put("code", "-100"); 287 resultMap.put("code", "-100");
293 - resultMap.put("message", "sim 不能为空");  
294 - 288 + resultMap.put("msg", "sim 不能为空");
295 return resultMap; 289 return resultMap;
296 - }  
297 -  
298 - if (StringUtils.isBlank(channel)) { 290 + } else if (StringUtils.isBlank(channel)) {
299 resultMap.put("code", "-100"); 291 resultMap.put("code", "-100");
300 - resultMap.put("message", "channel 不能为空");  
301 - 292 + resultMap.put("msg", "channel 不能为空");
302 return resultMap; 293 return resultMap;
303 - }  
304 -  
305 - if (StringUtils.isBlank(startTime)) { 294 + } else if (StringUtils.isBlank(startTime)) {
306 resultMap.put("code", "-100"); 295 resultMap.put("code", "-100");
307 - resultMap.put("message", "开始时间不能为空");  
308 - 296 + resultMap.put("msg", "开始时间不能为空");
309 return resultMap; 297 return resultMap;
310 - }  
311 -  
312 - if (StringUtils.isBlank(endTime)) { 298 + } else if (StringUtils.isBlank(endTime)) {
313 resultMap.put("code", "-100"); 299 resultMap.put("code", "-100");
314 - resultMap.put("message", "结束时间不能为空");  
315 - 300 + resultMap.put("msg", "结束时间不能为空");
316 return resultMap; 301 return resultMap;
317 - }  
318 -  
319 - String url = StringUtils.replace(jt1078ConfigBean.getJt1078Url(), "{0}", jt1078ConfigBean.getHistoryListPort());  
320 - startTime = formatTime(startTime);  
321 - endTime = formatTime(endTime);  
322 -  
323 - String msg = jt1078ConfigBean.formatMessageHistoryListRTSP(sim, channel, startTime, endTime);  
324 -  
325 - try { 302 + } else {
  303 + String url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getHistoryListPort());
  304 + startTime = this.formatTime(startTime);
  305 + endTime = this.formatTime(endTime);
  306 + String msg = this.jt1078ConfigBean.formatMessageHistoryListRTSP(sim, channel, startTime, endTime);
326 307
327 - HttpClientPostEntity entity = httpClientUtil.doPost(url, msg, null); 308 + try {
  309 + HttpClientPostEntity entity = this.httpClientUtil.doPost(url, msg, (String) null);
  310 + if (Objects.isNull(entity)) {
  311 + resultMap.put("code", "-1");
  312 + resultMap.put("msg", "请求历史视频列表错误,请联系管理员");
  313 + return resultMap;
  314 + } else {
  315 + Map<String, Object> resultMap1 = this.chooseEntity(entity, url, true);
  316 + if (Objects.nonNull(resultMap1)) {
  317 + return resultMap1;
  318 + } else {
  319 + HashMap<String, Object> hashMap = (HashMap) JSON.parseObject(entity.getResultStr(), HashMap.class);
  320 + if (MapUtils.isNotEmpty(hashMap) && Objects.nonNull(hashMap.get("data"))) {
  321 + JSONObject dataJO = (JSONObject) hashMap.get("data");
  322 + if (Objects.nonNull(dataJO.get("items"))) {
  323 + JSONArray jsonArray = (JSONArray) dataJO.get("items");
  324 + for (Object o : jsonArray) {
  325 + JSONObject jo = (JSONObject) o;
  326 + String startTimeStr = jo.getString("startTime");
  327 + if(StringUtils.isEmpty(startTimeStr)){
  328 + startTimeStr = StringUtils.join(String.valueOf(System.currentTimeMillis()), "-", String.valueOf(RandomUtils.nextInt(1, 1000)));
  329 + }else{
  330 + startTimeStr = StringUtils.replace(startTimeStr,"-","");
  331 + startTimeStr = StringUtils.replace(startTimeStr,":","");
  332 + startTimeStr = StringUtils.replace(startTimeStr," ","");
  333 + }
  334 + String channelMapping = StringUtils.join(new String[]{sim, "-", startTimeStr, "-", channel});
  335 + jo.put("channelMapping", channelMapping);
  336 + }
  337 + }
  338 + }
  339 + resultMap.put("code", "1");
328 340
329 - if (Objects.isNull(entity)) {  
330 - resultMap.put("code", "-1");  
331 - resultMap.put("message", "请求历史视频列表错误,请联系管理员"); 341 + resultMap.put("obj", hashMap);
  342 + return resultMap;
  343 + }
  344 + }
  345 + } catch (URISyntaxException var11) {
  346 + URISyntaxException e = var11;
  347 + log.error("发送获取历史视频指令异常;[{}],[{}]", new Object[]{url, msg, e});
  348 + resultMap.put("code", "-20");
  349 + resultMap.put("msg", "发送获取历史视频指令异常");
  350 + return resultMap;
  351 + } catch (IOException var12) {
  352 + IOException e = var12;
  353 + log.error("发送获取历史视频指令异常;[{}],[{}]", new Object[]{url, msg, e});
  354 + resultMap.put("code", "-20");
  355 + resultMap.put("msg", "发送获取历史视频指令异常");
332 return resultMap; 356 return resultMap;
333 } 357 }
334 -  
335 - Map<String, Object> resultMap1 = chooseEntity(entity,url);  
336 - if (Objects.nonNull(resultMap1)) {  
337 - return resultMap1;  
338 - }  
339 -  
340 - HashMap<String, Object> hashMap = JSON.parseObject(entity.getResultStr(), HashMap.class);  
341 - resultMap.put("code", "1");  
342 - resultMap.put("obj", hashMap);  
343 -  
344 - return resultMap;  
345 - } catch (URISyntaxException e) {  
346 - log.error("发送获取历史视频指令异常;[{}],[{}]", url, msg, e);  
347 -  
348 - resultMap.put("code", "-20");  
349 - resultMap.put("message", "发送获取历史视频指令异常");  
350 - return resultMap;  
351 - } catch (IOException e) {  
352 - log.error("发送获取历史视频指令异常;[{}],[{}]", url, msg, e);  
353 -  
354 - resultMap.put("code", "-20");  
355 - resultMap.put("message", "发送获取历史视频指令异常");  
356 -  
357 - return resultMap;  
358 } 358 }
359 } 359 }
360 360
361 -  
362 - @GetMapping("/send/request/io/history/{sim}/{channel}/{startTime}/{endTime}")  
363 - public Map<String, Object> sendIORequestOfHistory(@PathVariable String sim, @PathVariable String channel, @PathVariable String startTime, @PathVariable String endTime) {  
364 - Map<String, Object> resultMap = new HashMap<>(); 361 + @GetMapping({"/send/request/io/history/{sim}/{channel}/{startTime}/{endTime}/{channelMapping}"})
  362 + public Map<String, Object> sendIORequestOfHistory(@PathVariable String sim, @PathVariable String channel, @PathVariable String startTime, @PathVariable String endTime, @PathVariable String channelMapping) {
  363 + Map<String, Object> resultMap = new HashMap();
365 if (StringUtils.isBlank(sim)) { 364 if (StringUtils.isBlank(sim)) {
366 resultMap.put("code", "-100"); 365 resultMap.put("code", "-100");
367 - resultMap.put("message", "sim 不能为空");  
368 - 366 + resultMap.put("msg", "sim 不能为空");
369 return resultMap; 367 return resultMap;
370 - }  
371 -  
372 - if (StringUtils.isBlank(channel)) { 368 + } else if (StringUtils.isBlank(channel)) {
373 resultMap.put("code", "-100"); 369 resultMap.put("code", "-100");
374 - resultMap.put("message", "channel 不能为空");  
375 - 370 + resultMap.put("msg", "channel 不能为空");
376 return resultMap; 371 return resultMap;
377 - }  
378 -  
379 - if (StringUtils.isBlank(startTime)) { 372 + } else if (StringUtils.isBlank(startTime)) {
380 resultMap.put("code", "-100"); 373 resultMap.put("code", "-100");
381 - resultMap.put("message", "开始时间不能为空");  
382 - 374 + resultMap.put("msg", "开始时间不能为空");
383 return resultMap; 375 return resultMap;
384 - }  
385 -  
386 - if (StringUtils.isBlank(endTime)) { 376 + } else if (StringUtils.isBlank(endTime)) {
387 resultMap.put("code", "-100"); 377 resultMap.put("code", "-100");
388 - resultMap.put("message", "结束时间不能为空");  
389 - 378 + resultMap.put("msg", "结束时间不能为空");
390 return resultMap; 379 return resultMap;
391 - }  
392 - startTime = formatTime(startTime);  
393 - endTime = formatTime(endTime);  
394 -  
395 - String channelMapping = StringUtils.join(sim, "-", String.valueOf(System.currentTimeMillis()), "-", String.valueOf(RandomUtils.nextInt(1, 1000)));  
396 - String key = StringUtils.join(sim, "-", channel);  
397 - redisTemplate.opsForValue().set(key, channelMapping, 1, TimeUnit.HOURS);  
398 -  
399 - String msg = null;  
400 -  
401 - log.info("msg:{}", msg);  
402 - String url = StringUtils.replace(jt1078ConfigBean.getJt1078Url(), "{0}", jt1078ConfigBean.getPlayHistoryPort());  
403 -  
404 - try {  
405 - HttpClientPostEntity entity = createServerLister(channelMapping);  
406 - if (Objects.isNull(entity)) {  
407 - resultMap.put("code", "-20");  
408 - resultMap.put("message", "新建链接错误,请稍后再试"); 380 + } else {
  381 + StreamContent streamContent = this.getStreamContentPlayURL(StringUtils.join(new String[]{channelMapping}));
  382 + if(Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())){
  383 + resultMap.put("code", "1");
  384 + log.info("StreamContent:[{}]", streamContent);
  385 + resultMap.put("data", streamContent);
  386 +
  387 + resultMap.put("port", redisTemplate.opsForValue().get("tag:history:port:"+channelMapping));
  388 + resultMap.put("httpPort", redisTemplate.opsForValue().get("tag:history:httpPort:"+channelMapping));
  389 + resultMap.put("stream", channelMapping);
409 return resultMap; 390 return resultMap;
410 } 391 }
  392 + startTime = this.formatTime(startTime);
  393 + endTime = this.formatTime(endTime);
411 394
412 - Map<String, Object> resultMap1 = chooseEntity(entity,url);  
413 - if (Objects.nonNull(resultMap1)) {  
414 - return resultMap1;  
415 - }  
416 -  
417 - resultMap.put("stream", channelMapping);  
418 - resultMap.put("port", entity.getPort());  
419 - resultMap.put("httpPort", entity.getHttpPort());  
420 -  
421 - redisTemplate.opsForValue().set("tag:history:port:" + channelMapping, entity.getPort(), 2, TimeUnit.DAYS);  
422 - redisTemplate.opsForValue().set("tag:history:httpPort:" + channelMapping, entity.getHttpPort(), 2, TimeUnit.DAYS);  
423 - redisTemplate.opsForValue().set("tag:history:httpPort:time:" + channelMapping, new Date().getTime(), 1800, TimeUnit.SECONDS);  
424 -  
425 - msg = jt1078ConfigBean.formatMessageHistoryPlayRTSP(sim, channel, startTime, endTime, rtspConfigBean, entity.getPort());  
426 - boolean flag = false; 395 + String key = StringUtils.join(new String[]{sim, "-", channel});
  396 + this.redisTemplate.opsForValue().set(key, channelMapping, 1L, TimeUnit.HOURS);
  397 + String msg = null;
  398 + log.info("msg:{}", msg);
  399 + String url = StringUtils.replace(this.jt1078ConfigBean.getJt1078Url(), "{0}", this.jt1078ConfigBean.getPlayHistoryPort());
427 400
428 - key = key + "-lock";  
429 - int index = 0;  
430 - do {  
431 - index++; 401 + try {
  402 + HttpClientPostEntity entity = this.createServerLister(channelMapping);
  403 + if (Objects.isNull(entity)) {
  404 + resultMap.put("code", "-20");
  405 + resultMap.put("msg", "新建链接错误,请稍后再试");
  406 + return resultMap;
  407 + } else {
  408 + this.chooseEntity(entity, url, false);
  409 + resultMap.put("stream", channelMapping);
  410 + resultMap.put("port", entity.getPort());
  411 + resultMap.put("httpPort", entity.getHttpPort());
  412 + this.redisTemplate.opsForValue().set("tag:history:port:" + channelMapping, entity.getPort(), 2L, TimeUnit.DAYS);
  413 + this.redisTemplate.opsForValue().set("tag:history:httpPort:" + channelMapping, entity.getHttpPort(), 2L, TimeUnit.DAYS);
  414 + this.redisTemplate.opsForValue().set("tag:history:httpPort:time:" + channelMapping, (new Date()).getTime(), StreamProxyTask.TIME_OUT, TimeUnit.SECONDS);
  415 + msg = this.jt1078ConfigBean.formatMessageHistoryPlayRTSP(sim, channel, startTime, endTime, this.rtspConfigBean, entity.getPort());
432 416
433 - flag = redisTemplate.opsForValue().setIfAbsent(key, key, 100, TimeUnit.SECONDS);  
434 - if (flag) {  
435 log.info("获取推流"); 417 log.info("获取推流");
436 - entity = httpClientUtil.doPost(url, msg, null);  
437 - }  
438 - Thread.sleep(1000);  
439 - if (index > 100) {  
440 - break; 418 + this.createStreamProxy(sim + "-" + channel);
  419 + entity = this.httpClientUtil.doPost(url, msg, (String) null);
  420 + Map<String, Object> resultMap2 = this.chooseEntity(entity, url, true);
  421 + if (Objects.nonNull(resultMap2)) {
  422 + return resultMap2;
  423 + } else {
  424 + log.info(entity.getResultStr());
  425 + this.createStreamProxy(channelMapping);
  426 + resultMap.put("code", "1");
  427 + Thread.sleep(2000L);
  428 + Map<String, Object> resultMap3 = this.getStreamContent(channelMapping);
  429 + if (Objects.nonNull(resultMap3) && Objects.nonNull(resultMap3.get("code")) && !StringUtils.equals(resultMap3.get("code").toString(), "1")) {
  430 + return resultMap3;
  431 + } else {
  432 + streamContent = (StreamContent) resultMap3.get("streamContent");
  433 + if (Objects.isNull(streamContent)) {
  434 + resultMap.put("code", "-20");
  435 + resultMap.put("msg", "新建链接错误,请稍后再试");
  436 + return resultMap;
  437 + } else {
  438 + log.info("StreamContent:[{}]", streamContent);
  439 + resultMap.put("data", streamContent);
  440 + return resultMap;
  441 + }
  442 + }
  443 + }
441 } 444 }
442 - } while (!flag);  
443 -  
444 - if (!flag) { 445 + } catch (IOException | URISyntaxException var16) {
  446 + Exception e = var16;
  447 + log.error("发送推流指令异常;[{}],[{}]", new Object[]{url, msg, e});
445 resultMap.put("code", "-20"); 448 resultMap.put("code", "-20");
446 - resultMap.put("message", "发送推流指令错误,请稍后再试"); 449 + resultMap.put("msg", "发送推流指令异常");
447 return resultMap; 450 return resultMap;
  451 + } catch (InterruptedException var17) {
  452 + InterruptedException e = var17;
  453 + throw new RuntimeException(e);
448 } 454 }
449 - log.info(entity.getResultStr());  
450 - createStreamProxy(channelMapping);  
451 -  
452 - resultMap.put("code", "1");  
453 - resultMap.put("message", "OK");  
454 -  
455 - Thread.sleep(10000);  
456 -  
457 - StreamContent streamContent = getStreamContent(channelMapping);  
458 -  
459 - log.info("StreamContent:[{}]", streamContent);  
460 - resultMap.put("data", streamContent);  
461 -  
462 -  
463 - return resultMap;  
464 - } catch (URISyntaxException | IOException e) {  
465 - log.error("发送推流指令异常;[{}],[{}]", url, msg, e);  
466 -  
467 - resultMap.put("code", "-20");  
468 - resultMap.put("message", "发送推流指令异常");  
469 -  
470 - return resultMap;  
471 - } catch (InterruptedException e) {  
472 - throw new RuntimeException(e);  
473 } 455 }
474 } 456 }
475 457
  458 + public Map<>
476 459
477 - @PostMapping("/test") 460 + @PostMapping({"/test"})
478 public String test(@RequestBody TestEntity test) { 461 public String test(@RequestBody TestEntity test) {
479 -  
480 return "OK"; 462 return "OK";
481 } 463 }
482 464
483 - @GetMapping("/test1") 465 + @GetMapping({"/test1"})
484 public String test1(HttpServletRequest request) throws URISyntaxException, IOException { 466 public String test1(HttpServletRequest request) throws URISyntaxException, IOException {
485 - jsessionid = StringUtils.join("JSESSIONID=", request.getParameter("jsessionid")); 467 + this.jsessionid = StringUtils.join(new String[]{"JSESSIONID=", request.getParameter("jsessionid")});
486 return "OK"; 468 return "OK";
487 } 469 }
488 470
489 @Nullable 471 @Nullable
490 - private StreamContent getStreamContent(String stream) throws InterruptedException { 472 + private Map<String, Object> getStreamContent(String stream) throws InterruptedException {
491 StreamContent streamContent = null; 473 StreamContent streamContent = null;
  474 + Map<String, Object> datas = new HashMap();
492 int index = 0; 475 int index = 0;
493 - do {  
494 - index++;  
495 - streamContent = getStreamContentPlayURL(stream);  
496 476
  477 + Integer countTimeOut = 0;
  478 +
  479 + do {
  480 + ++index;
  481 + streamContent = this.getStreamContentPlayURL(stream);
497 if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) { 482 if (Objects.nonNull(streamContent) && StringUtils.isNotEmpty(streamContent.getWs_flv())) {
498 break; 483 break;
499 } 484 }
500 - Thread.sleep(100);  
501 - } while (index < 600); 485 +
  486 + Object valObj = redisTemplate.opsForValue().get("stream:status:" + stream);
  487 + if (Objects.nonNull(valObj) && StringUtils.equals(valObj.toString(), "1")) {
  488 + StreamProxyItem streamProxyItem = streamProxyController.one("schedule",stream);
  489 + if(Objects.nonNull(streamProxyItem) && StringUtils.isNotEmpty(streamProxyItem.getApp())){
  490 + try {
  491 + streamProxyController.start("schedule", stream);
  492 + } catch (Exception e) {
  493 + log.error(e.getMessage());
  494 + }
  495 + }else{
  496 + createStreamProxy(stream);
  497 + }
  498 +
  499 +
  500 + }else{
  501 + Object val = this.redisTemplate.opsForValue().get("timeout:" + stream);
  502 + if (Objects.nonNull(val) && StringUtils.equals(val.toString(), "1")) {
  503 +
  504 + countTimeOut++;
  505 + try {
  506 + streamProxyController.start("schedule", stream);
  507 + } catch (Exception e) {
  508 + log.error(e.getMessage());
  509 + }
  510 + }
  511 + }
  512 +
  513 +
  514 +
  515 + Thread.sleep(1000L);
  516 + log.info("===============>" + index);
  517 + } while (index < 20);
  518 +
  519 + if (countTimeOut > 0) {
  520 + datas.put("code", "301");
  521 + datas.put("msg", "获取摄像头视频数据失败,请稍后再试");
  522 + return datas;
  523 + }
  524 +
  525 + log.info("===============>" + index);
  526 + if (Objects.isNull(streamContent)) {
  527 + streamContent = new StreamContent();
  528 + streamContent.setWs_flv(StringUtils.replace(this.jt1078ConfigBean.getWs(), "{stream}", stream));
  529 + streamContent.setWss_flv(StringUtils.replace(this.jt1078ConfigBean.getWss(), "{stream}", stream));
  530 + }
502 531
503 log.info("StreamContent:[{}]", streamContent); 532 log.info("StreamContent:[{}]", streamContent);
504 - return streamContent; 533 + datas.put("code", "1");
  534 + datas.put("streamContent", streamContent);
  535 + return datas;
505 } 536 }
506 537
507 private StreamContent getStreamContentPlayURL(String stream) { 538 private StreamContent getStreamContentPlayURL(String stream) {
508 try { 539 try {
509 - return streamPushController.getPlayUrl("schedule", stream, mediaConfig.getId());  
510 - } catch (com.genersoft.iot.vmp.conf.exception.ControllerException e) {  
511 - log.debug("获取播放地址失败:[{}],[{}]", stream, mediaConfig.getId()); 540 + return this.streamPushController.getPlayUrl("schedule", stream, this.mediaConfig.getId());
  541 + } catch (ControllerException var3) {
  542 + log.debug("获取播放地址失败:[{}],[{}]", stream, this.mediaConfig.getId());
  543 + return null;
512 } 544 }
513 - return null;  
514 } 545 }
515 546
516 private void requestToken() throws URISyntaxException, IOException { 547 private void requestToken() throws URISyntaxException, IOException {
517 HttpClientPostEntity entity = this.httpClientUtil.doGet(this.tuohuaConfigBean.getPageURL(), (String) null); 548 HttpClientPostEntity entity = this.httpClientUtil.doGet(this.tuohuaConfigBean.getPageURL(), (String) null);
518 - if (!Objects.isNull(entity)) {  
519 - if (!Objects.isNull(entity) && !Objects.isNull(entity.getResultStr())) {  
520 - HashMap<String, String> resultMap = (HashMap) JSON.parseObject(entity.getResultStr(), HashMap.class);  
521 - log.info("获取key:[{}]", resultMap.get("publickey"));  
522 - Map<String, String> params = new HashMap();  
523 - params.put("userName", encryptByPublicKey(this.tuohuaConfigBean.getUserName(), resultMap.get("publickey")));  
524 - params.put("password", encryptByPublicKey(this.tuohuaConfigBean.getPassword(), resultMap.get("publickey")));  
525 - HttpClientPostEntity postEntity = this.httpClientUtil.doPost(this.tuohuaConfigBean.getLoginURL(), params, (String) null);  
526 - if (Objects.nonNull(postEntity)) {  
527 - CookieStore tokenCookieStore = null;  
528 - tokenCookieStore = postEntity.getCookieStore();  
529 - if (Objects.nonNull(tokenCookieStore)) {  
530 - List<Cookie> cookies = tokenCookieStore.getCookies();  
531 - if (CollectionUtils.isNotEmpty(cookies)) {  
532 - Iterator var7 = cookies.iterator();  
533 -  
534 - while (var7.hasNext()) {  
535 - Cookie cookie = (Cookie) var7.next();  
536 - if (StringUtils.equalsIgnoreCase("jsessionid", cookie.getName()) && StringUtils.isNotBlank(cookie.getValue())) {  
537 - this.jsessionid = StringUtils.join(new String[]{"JSESSIONID=", cookie.getValue()});  
538 - break;  
539 - } 549 + if (!Objects.isNull(entity) && !Objects.isNull(entity) && !Objects.isNull(entity.getResultStr())) {
  550 + HashMap<String, String> resultMap = (HashMap) JSON.parseObject(entity.getResultStr(), HashMap.class);
  551 + log.info("获取key:[{}]", resultMap.get("publickey"));
  552 + Map<String, String> params = new HashMap();
  553 + params.put("userName", encryptByPublicKey(this.tuohuaConfigBean.getUserName(), (String) resultMap.get("publickey")));
  554 + params.put("password", encryptByPublicKey(this.tuohuaConfigBean.getPassword(), (String) resultMap.get("publickey")));
  555 + HttpClientPostEntity postEntity = this.httpClientUtil.doPost(this.tuohuaConfigBean.getLoginURL(), params, (String) null);
  556 + if (Objects.nonNull(postEntity)) {
  557 + CookieStore tokenCookieStore = null;
  558 + tokenCookieStore = postEntity.getCookieStore();
  559 + if (Objects.nonNull(tokenCookieStore)) {
  560 + List<Cookie> cookies = tokenCookieStore.getCookies();
  561 + if (CollectionUtils.isNotEmpty(cookies)) {
  562 + Iterator var7 = cookies.iterator();
  563 +
  564 + while (var7.hasNext()) {
  565 + Cookie cookie = (Cookie) var7.next();
  566 + if (StringUtils.equalsIgnoreCase("jsessionid", cookie.getName()) && StringUtils.isNotBlank(cookie.getValue())) {
  567 + this.jsessionid = StringUtils.join(new String[]{"JSESSIONID=", cookie.getValue()});
  568 + break;
540 } 569 }
541 } 570 }
542 } 571 }
543 -  
544 - this.tokenDate = new Date();  
545 - log.info("获取token:[{}]", this.jsessionid);  
546 } 572 }
547 573
  574 + this.tokenDate = new Date();
  575 + log.info("获取token:[{}]", this.jsessionid);
548 } 576 }
549 } 577 }
  578 +
550 } 579 }
551 580
552 public static String encryptByPublicKey(String data, String publicKey) { 581 public static String encryptByPublicKey(String data, String publicKey) {
@@ -579,12 +608,13 @@ public class Jt1078OfCarController { @@ -579,12 +608,13 @@ public class Jt1078OfCarController {
579 out.close(); 608 out.close();
580 String var15 = new String(Base64Utils.encode(encryptedData)); 609 String var15 = new String(Base64Utils.encode(encryptedData));
581 return var15; 610 return var15;
582 - } catch (Exception var19) { 611 + } catch (Exception var18) {
  612 + Exception var19 = var18;
583 log.error("RSA 异常", var19); 613 log.error("RSA 异常", var19);
  614 + return null;
584 } finally { 615 } finally {
585 - 616 + ;
586 } 617 }
587 - return null;  
588 } 618 }
589 619
590 private boolean cookieTimeOut() { 620 private boolean cookieTimeOut() {
@@ -603,85 +633,93 @@ public class Jt1078OfCarController { @@ -603,85 +633,93 @@ public class Jt1078OfCarController {
603 } 633 }
604 634
605 private HttpClientPostEntity createServerLister(String channelMapping) throws URISyntaxException, IOException { 635 private HttpClientPostEntity createServerLister(String channelMapping) throws URISyntaxException, IOException {
606 - Integer port = RandomUtils.nextInt(jt1078ConfigBean.getStart1078Port(), jt1078ConfigBean.getEnd1078Port());  
607 - Integer httPort = RandomUtils.nextInt(jt1078ConfigBean.getStart1078Port(), jt1078ConfigBean.getEnd1078Port()); 636 + Integer port = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
  637 + Integer httPort = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
  638 + String url;
608 if (!Objects.equals(port, httPort) && Objects.nonNull(port)) { 639 if (!Objects.equals(port, httPort) && Objects.nonNull(port)) {
609 -// Integer port = 1078;  
610 -// Integer httPort = 3333;  
611 -  
612 - String key = "jt1078:server:port:" + port; 640 + url = "jt1078:server:port:" + port;
613 String httpKey = "jt1078:server:httpport:" + httPort; 641 String httpKey = "jt1078:server:httpport:" + httPort;
614 int index = 0; 642 int index = 0;
615 - while (redisTemplate.hasKey(key) || redisTemplate.hasKey(httpKey)) {  
616 - port = RandomUtils.nextInt(jt1078ConfigBean.getStart1078Port(), jt1078ConfigBean.getEnd1078Port());  
617 - httPort = RandomUtils.nextInt(jt1078ConfigBean.getStart1078Port(), jt1078ConfigBean.getEnd1078Port());  
618 - key = "jt1078:server:port:" + port;  
619 - httpKey = "jt1078:server:httpport:" + httPort;  
620 643
  644 + while (this.redisTemplate.hasKey(url) || this.redisTemplate.hasKey(httpKey)) {
  645 + port = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
  646 + httPort = RandomUtils.nextInt(this.jt1078ConfigBean.getStart1078Port(), this.jt1078ConfigBean.getEnd1078Port());
  647 + url = "jt1078:server:port:" + port;
  648 + httpKey = "jt1078:server:httpport:" + httPort;
621 if (index > 1000) { 649 if (index > 1000) {
622 break; 650 break;
623 } 651 }
624 } 652 }
625 653
626 - redisTemplate.opsForValue().set(key, 1, 2, TimeUnit.DAYS);  
627 - redisTemplate.opsForValue().set(httpKey, 1, 2, TimeUnit.DAYS); 654 + this.redisTemplate.opsForValue().set(url, 1, 2L, TimeUnit.DAYS);
  655 + this.redisTemplate.opsForValue().set(httpKey, 1, 2L, TimeUnit.DAYS);
628 } else { 656 } else {
629 port = 1078; 657 port = 1078;
630 httPort = 3333; 658 httPort = 3333;
631 } 659 }
632 660
633 - String url = jt1078ConfigBean.formatPushURL(channelMapping, port, httPort); 661 + url = this.jt1078ConfigBean.formatPushURL(channelMapping, port, httPort);
634 662
635 - HttpClientPostEntity httpClientPostEntity = httpClientUtil.doGet(url, null);  
636 - if (Objects.isNull(httpClientPostEntity)) { 663 + try {
  664 + HttpClientPostEntity httpClientPostEntity = this.httpClientUtil.doGet(url, (String) null);
  665 + if (Objects.isNull(httpClientPostEntity)) {
  666 + return null;
  667 + } else {
  668 + httpClientPostEntity.setHttpPort(httPort);
  669 + httpClientPostEntity.setPort(port);
  670 + return httpClientPostEntity;
  671 + }
  672 + } catch (Exception var7) {
  673 + Exception e = var7;
  674 + log.error("url:[{}]", url, e);
637 return null; 675 return null;
638 } 676 }
639 -// HttpClientPostEntity httpClientPostEntity = new HttpClientPostEntity();  
640 - httpClientPostEntity.setHttpPort(httPort);  
641 - httpClientPostEntity.setPort(port);  
642 -  
643 - return httpClientPostEntity;  
644 } 677 }
645 678
646 - private Map<String, Object> chooseEntity(HttpClientPostEntity entity,String url) {  
647 - Map<String, Object> result = new HashMap<>(); 679 + private Map<String, Object> chooseEntity(HttpClientPostEntity entity, String url, boolean flag) {
  680 + Map<String, Object> result = new HashMap();
648 if (Objects.isNull(entity)) { 681 if (Objects.isNull(entity)) {
649 result.put("code", "301"); 682 result.put("code", "301");
650 result.put("msg", "下发指令异常"); 683 result.put("msg", "下发指令异常");
651 return result; 684 return result;
652 - }  
653 - try {  
654 - Map<String, Object> rsultMap = JSON.parseObject(entity.getResultStr(), HashMap.class);  
655 - if (Objects.equals(rsultMap.get("code"), "4000") || Objects.equals(rsultMap.get("code"), 4000)) {  
656 - result.put("code", "304");  
657 - result.put("msg", "离线的客户端(请检查设备是否注册或者鉴权");  
658 - return result;  
659 - } 685 + } else {
  686 + try {
  687 + Map<String, Object> rsultMap = (Map) JSON.parseObject(entity.getResultStr(), HashMap.class);
  688 + if (Objects.equals(rsultMap.get("code"), "4000") || Objects.equals(rsultMap.get("code"), 4000)) {
  689 + result.put("code", "304");
  690 + result.put("msg", "离线的客户端(请检查设备是否注册或者鉴权");
  691 + return result;
  692 + }
660 693
661 - if (Objects.nonNull(rsultMap.get("success")) && StringUtils.equalsAnyIgnoreCase(String.valueOf(rsultMap.get("success")), "true")) {  
662 - return null;  
663 - } else if (StringUtils.isNoneBlank(rsultMap.get("msg") + "")) {  
664 - result.put("code", "304");  
665 - result.put("msg", rsultMap.get("msg"));  
666 - return result;  
667 - }  
668 - }catch (Exception e){  
669 - log.error("entity.getResultStr():{{}}",entity.getResultStr(),e);  
670 - } 694 + if (flag) {
  695 + if (Objects.nonNull(rsultMap.get("success")) && StringUtils.equalsAnyIgnoreCase(String.valueOf(rsultMap.get("success")), new CharSequence[]{"true"})) {
  696 + return null;
  697 + }
671 698
672 - return null; 699 + if (StringUtils.isNoneBlank(new CharSequence[]{rsultMap.get("msg") + ""})) {
  700 + result.put("code", "304");
  701 + result.put("msg", rsultMap.get("msg"));
  702 + return result;
  703 + }
  704 + }
  705 + } catch (Exception var6) {
  706 + Exception e = var6;
  707 + log.error("entity.getResultStr():{{}}", entity.getResultStr(), e.getMessage());
  708 + }
673 709
  710 + return null;
  711 + }
674 } 712 }
675 713
676 private void createStreamProxy(String stream) { 714 private void createStreamProxy(String stream) {
677 - String url = StringUtils.replace(jt1078ConfigBean.getGetURL(), "{stream}", stream); 715 + String url = StringUtils.replace(this.jt1078ConfigBean.getGetURL(), "{stream}", stream);
678 StreamProxyItem item = new StreamProxyItem(); 716 StreamProxyItem item = new StreamProxyItem();
679 item.setApp("schedule"); 717 item.setApp("schedule");
680 item.setEnable(true); 718 item.setEnable(true);
681 item.setEnableAudio(true); 719 item.setEnableAudio(true);
682 item.setRtpType("default"); 720 item.setRtpType("default");
683 item.setStream(stream); 721 item.setStream(stream);
684 - item.setMediaServerId(mediaConfig.getId()); 722 + item.setMediaServerId(this.mediaConfig.getId());
685 item.setUrl(url); 723 item.setUrl(url);
686 item.setFfmpegCmdKey("ffmpeg.cmd"); 724 item.setFfmpegCmdKey("ffmpeg.cmd");
687 item.setEnable(true); 725 item.setEnable(true);
@@ -689,10 +727,7 @@ public class Jt1078OfCarController { @@ -689,10 +727,7 @@ public class Jt1078OfCarController {
689 item.setEnableMp4(false); 727 item.setEnableMp4(false);
690 item.setEnableRemoveNoneReader(false); 728 item.setEnableRemoveNoneReader(false);
691 item.setEnableDisableNoneReader(false); 729 item.setEnableDisableNoneReader(false);
692 -  
693 - streamProxyController.save(item);  
694 - 730 + item.setName(stream);
  731 + this.streamProxyController.save(item);
695 } 732 }
696 -  
697 -  
698 } 733 }
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/Jt1078ConfigBean.java
1 -package com.genersoft.iot.vmp.vmanager.jt1078.platform.config;  
2 -  
3 -import org.apache.commons.lang3.StringUtils;  
4 -import org.springframework.beans.factory.annotation.Value;  
5 -import org.springframework.stereotype.Component;  
6 -  
7 -import java.util.Objects;  
8 -  
9 -/**  
10 - * @author liujun  
11 - * @date 2024年10月23日 13:38  
12 - */  
13 -@Component  
14 -public class Jt1078ConfigBean {  
15 - @Value("${tuohua.bsth.jt1078.url}")  
16 - private String jt1078Url;  
17 - @Value("${tuohua.bsth.jt1078.sendPort}")  
18 - private String jt1078SendPort;  
19 - @Value("${tuohua.bsth.jt1078.stopSendPort}")  
20 - private String stopSendPort;  
21 - @Value("${tuohua.bsth.jt1078.historyListPort}")  
22 - private String historyListPort;  
23 - @Value("${tuohua.bsth.jt1078.playHistoryPort}")  
24 - private String playHistoryPort;  
25 -  
26 - @Value("${tuohua.bsth.jt1078.ports}")  
27 - private String portsOf1078;  
28 -  
29 - @Value("${tuohua.bsth.jt1078.pushURL}")  
30 - private String pushURL;  
31 - @Value("${tuohua.bsth.jt1078.stopPushURL}")  
32 - private String stopPUshURL;  
33 -  
34 - private Integer start1078Port;  
35 - private Integer end1078Port;  
36 - @Value("${tuohua.bsth.jt1078.get.url}")  
37 - private String getURL;  
38 -  
39 -  
40 - 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\"}";  
41 - 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\"}";  
42 - private static final String SEND_IO_HISTORY_RTSP = "{\"msgid\":37381,\"clientId\":\"{clientId}\",\"startTime\":\"{startTime}\",\"endTime\":\"{endTime}\",\"mediaType\":0,\"streamType\":0,\"storageType\":0,\"channelId\":{channelNo}}";  
43 - 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}";  
44 -  
45 - public String formatMessageId(String sim, String channel, RtspConfigBean configBean,Integer port) {  
46 - String msg = StringUtils.replace(SEND_IO_MESSAGE_RTSP, "{clientId}", sim);  
47 - msg = StringUtils.replace(msg, "{tcpPort}", port+"");  
48 - msg = StringUtils.replace(msg, "{udpPort}", port+"");  
49 - msg = StringUtils.replace(msg, "{channelNo}", channel);  
50 - return StringUtils.replace(msg, "{ip}", configBean.getRtspIp());  
51 - }  
52 -  
53 - public String formatMessageStop(String sim, String channel) {  
54 - String msg = StringUtils.replace(SEND_IO_MESSAGE_RTSP_STOP, "{clientId}", sim);  
55 - return StringUtils.replace(msg, "{channelNo}", channel);  
56 - }  
57 -  
58 - public String formatMessageHistoryListRTSP(String sim, String channel, String startTime, String endTime) {  
59 - String msg = StringUtils.replace(SEND_IO_HISTORY_RTSP, "{clientId}", sim);  
60 - msg = StringUtils.replace(msg, "{startTime}", startTime);  
61 - msg = StringUtils.replace(msg, "{endTime}", endTime);  
62 - return StringUtils.replace(msg, "{channelNo}", channel);  
63 - }  
64 -  
65 - public String formatMessageHistoryPlayRTSP(String sim, String channel, String startTime, String endTime, RtspConfigBean configBean,Integer port) {  
66 - String msg = StringUtils.replace(SEND_IO_PLAY_RTSP, "{clientId}", sim);  
67 - msg = StringUtils.replace(msg, "{startTime}", startTime);  
68 - msg = StringUtils.replace(msg, "{endTime}", endTime);  
69 - msg = StringUtils.replace(msg, "{channelNo}", channel);  
70 - msg = StringUtils.replace(msg, "{tcpPort}", port+"");  
71 - msg = StringUtils.replace(msg, "{udpPort}", port+"");  
72 - msg = StringUtils.replace(msg, "{sim}", sim);  
73 - return StringUtils.replace(msg, "{ip}", configBean.getRtspIp());  
74 - }  
75 -  
76 - public String formatPushURL(String pushKey, int port, int httpPort) {  
77 - String msg = StringUtils.replace(pushURL, "{pushKey}", pushKey);  
78 - msg = StringUtils.replace(msg, "{port}", String.valueOf(port));  
79 - return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort));  
80 - }  
81 -  
82 - public String formatStopPushURL(String pushKey, int port, int httpPort) {  
83 - String msg = StringUtils.replace(stopPUshURL, "{pushKey}", pushKey);  
84 - msg = StringUtils.replace(msg, "{port}", String.valueOf(port));  
85 - return StringUtils.replace(msg, "{httpPort}", String.valueOf(httpPort));  
86 - }  
87 -  
88 - public String getJt1078Url() {  
89 - return jt1078Url;  
90 - }  
91 -  
92 - public String getJt1078SendPort() {  
93 - return jt1078SendPort;  
94 - }  
95 -  
96 - public String getStopSendPort() {  
97 - return stopSendPort;  
98 - }  
99 -  
100 - public String getHistoryListPort() {  
101 - return historyListPort;  
102 - }  
103 -  
104 - public String getPlayHistoryPort() {  
105 - return playHistoryPort;  
106 - }  
107 -  
108 - public String getPushURL() {  
109 - return pushURL;  
110 - }  
111 -  
112 - public Integer getStart1078Port() {  
113 - if (Objects.isNull(start1078Port)) {  
114 - start1078Port = Integer.parseInt(StringUtils.substringBefore(portsOf1078, ","));  
115 - }  
116 - return start1078Port;  
117 - }  
118 -  
119 - public Integer getEnd1078Port() {  
120 - if (Objects.isNull(end1078Port)) {  
121 - end1078Port = Integer.parseInt(StringUtils.substringAfter(portsOf1078, ","));  
122 - }  
123 - return end1078Port;  
124 - }  
125 -  
126 - public String getStopPUshURL() {  
127 - return stopPUshURL;  
128 - }  
129 -  
130 - public String getGetURL() {  
131 - return getURL;  
132 - }  
133 -} 1 +package com.genersoft.iot.vmp.vmanager.jt1078.platform.config; import com.genersoft.iot.vmp.vmanager.jt1078.platform.config.RtspConfigBean; import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @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; 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() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getAddPort().intValue()) + ""); 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\":0,\"storageType\":0,\"channelId\":{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() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{udpPort}", (port.intValue() + getAddPort().intValue()) + ""); msg = StringUtils.replace(msg, "{sim}", sim); return StringUtils.replace(msg, "{ip}", configBean.getRtspIp()); } 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 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 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; } }
134 \ No newline at end of file 2 \ No newline at end of file
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/config/TuohuaConfigBean.java
@@ -6,7 +6,9 @@ import com.genersoft.iot.vmp.vmanager.jt1078.platform.handler.HttpClientUtil; @@ -6,7 +6,9 @@ import com.genersoft.iot.vmp.vmanager.jt1078.platform.handler.HttpClientUtil;
6 import org.apache.commons.collections4.CollectionUtils; 6 import org.apache.commons.collections4.CollectionUtils;
7 import org.apache.commons.lang3.RandomUtils; 7 import org.apache.commons.lang3.RandomUtils;
8 import org.apache.commons.lang3.StringUtils; 8 import org.apache.commons.lang3.StringUtils;
  9 +import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.beans.factory.annotation.Value; 10 import org.springframework.beans.factory.annotation.Value;
  11 +import org.springframework.data.redis.core.RedisTemplate;
10 import org.springframework.stereotype.Component; 12 import org.springframework.stereotype.Component;
11 13
12 import java.security.MessageDigest; 14 import java.security.MessageDigest;
@@ -44,6 +46,12 @@ public class TuohuaConfigBean { @@ -44,6 +46,12 @@ public class TuohuaConfigBean {
44 @Value("${tuohua.bsth.login.rest.password}") 46 @Value("${tuohua.bsth.login.rest.password}")
45 private String restPassword; 47 private String restPassword;
46 48
  49 + @Value("${spring.profiles.active}")
  50 + private String profileActive;
  51 +
  52 + @Autowired
  53 + private RedisTemplate redisTemplate;
  54 +
47 55
48 public String getBaseURL() { 56 public String getBaseURL() {
49 return baseURL; 57 return baseURL;
@@ -86,6 +94,7 @@ public class TuohuaConfigBean { @@ -86,6 +94,7 @@ public class TuohuaConfigBean {
86 private final String LINE_URL = "/line/company/{companyId}?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}"; 94 private final String LINE_URL = "/line/company/{companyId}?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}";
87 //private final String LINE_URL = "/line/all?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}"; 95 //private final String LINE_URL = "/line/all?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}";
88 private final String CAR_URL = "/car/company/{companyId}?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}"; 96 private final String CAR_URL = "/car/company/{companyId}?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}";
  97 + private final String GPS_URL = "//gps/all?timestamp={timestamp}&nonce={nonce}&password={password}&sign={sign}";
89 98
90 public String requestLine(HttpClientUtil httpClientUtil, String companyId) throws Exception { 99 public String requestLine(HttpClientUtil httpClientUtil, String companyId) throws Exception {
91 String nonce = random(5); 100 String nonce = random(5);
@@ -114,9 +123,27 @@ public class TuohuaConfigBean { @@ -114,9 +123,27 @@ public class TuohuaConfigBean {
114 return Objects.isNull(postEntity) ? null : postEntity.getResultStr(); 123 return Objects.isNull(postEntity) ? null : postEntity.getResultStr();
115 } 124 }
116 125
  126 + public List<HashMap> requestGPS(HttpClientUtil httpClientUtil) throws Exception {
  127 + String nonce = random(6);
  128 + String timestamp = String.valueOf(new Date().getTime());
  129 + Map<String, String> map = new HashMap<>();
  130 + map.put("timestamp", timestamp);
  131 + map.put("nonce", nonce);
  132 + map.put("password", getRestPassword());
  133 + String sign = getSHA1(map);
  134 + String url = StringUtils.join(getBaseURL(), formatURL(GPS_URL, map, sign));
  135 + HttpClientPostEntity postEntity = httpClientUtil.doGet(url, null);
  136 + if (Objects.isNull(postEntity) || StringUtils.isEmpty(postEntity.getResultStr())) {
  137 + return null;
  138 + }
  139 + return (List<HashMap>) JSON.parseArray(postEntity.getResultStr(), HashMap.class);
  140 +
  141 + }
  142 +
117 public List<HashMap<String, Object>> requestOfLineAndCarAndCombationTree(HttpClientUtil httpClientUtil, String companyId) throws Exception { 143 public List<HashMap<String, Object>> requestOfLineAndCarAndCombationTree(HttpClientUtil httpClientUtil, String companyId) throws Exception {
118 String lineJson = requestLine(httpClientUtil, companyId); 144 String lineJson = requestLine(httpClientUtil, companyId);
119 String carJson = requestCars(httpClientUtil, companyId); 145 String carJson = requestCars(httpClientUtil, companyId);
  146 +// String carJson = redisTemplate.opsForValue().get("test:car").toString();
120 147
121 148
122 List<HashMap> linesJsonList = null; 149 List<HashMap> linesJsonList = null;
@@ -126,6 +153,7 @@ public class TuohuaConfigBean { @@ -126,6 +153,7 @@ public class TuohuaConfigBean {
126 linesSize = CollectionUtils.size(linesJsonList); 153 linesSize = CollectionUtils.size(linesJsonList);
127 } 154 }
128 155
  156 + List<HashMap> gpsList = requestGPS(httpClientUtil);
129 List<HashMap> carJsonList = null; 157 List<HashMap> carJsonList = null;
130 int carsJsonSize = 0; 158 int carsJsonSize = 0;
131 if (StringUtils.isNoneBlank(carJson)) { 159 if (StringUtils.isNoneBlank(carJson)) {
@@ -140,13 +168,15 @@ public class TuohuaConfigBean { @@ -140,13 +168,15 @@ public class TuohuaConfigBean {
140 if (linesSize > 0) { 168 if (linesSize > 0) {
141 List<HashMap<String, Object>> lines = linesJsonList.stream().map(hashMap -> { 169 List<HashMap<String, Object>> lines = linesJsonList.stream().map(hashMap -> {
142 String code = convertStr(hashMap.get("lineCode")); 170 String code = convertStr(hashMap.get("lineCode"));
143 - HashMap<String, Object> map = combationTree(code, convertStr(hashMap.get("line")), code, false, convertStr(hashMap.get("name")), code, false, 171 + String name = convertStr(hashMap.get("name"));
  172 +
  173 + HashMap<String, Object> map = combationTree(code, convertStr(hashMap.get("line")), code, false, name, code, false,
144 "<span><img src='/metronic_v4.5.4/layui/icon/line.png' class ='imageIcon' /></span><span>" + convertStr(hashMap.get("name")) + "</span>", 174 "<span><img src='/metronic_v4.5.4/layui/icon/line.png' class ='imageIcon' /></span><span>" + convertStr(hashMap.get("name")) + "</span>",
145 "<span><img src='/metronic_v4.5.4/layui/icon/line.png' class ='imageIcon' /></span><span>" + convertStr(hashMap.get("name")) + "</span>", 201); 175 "<span><img src='/metronic_v4.5.4/layui/icon/line.png' class ='imageIcon' /></span><span>" + convertStr(hashMap.get("name")) + "</span>", 201);
146 if (carsSize > 0) { 176 if (carsSize > 0) {
147 List<HashMap> carList = carJsonListFinal.stream().filter(c -> Objects.nonNull(c.get("lineCode")) && StringUtils.equals(convertStr(c.get("lineCode")), code)).map(ch -> { 177 List<HashMap> carList = carJsonListFinal.stream().filter(c -> Objects.nonNull(c.get("lineCode")) && StringUtils.equals(convertStr(c.get("lineCode")), code)).map(ch -> {
148 ch.put("used", "1"); 178 ch.put("used", "1");
149 - return combatioinCarTree(ch); 179 + return combatioinCarTree(ch,gpsList);
150 }).collect(Collectors.toList()); 180 }).collect(Collectors.toList());
151 181
152 map.put("children", carList); 182 map.put("children", carList);
@@ -158,7 +188,7 @@ public class TuohuaConfigBean { @@ -158,7 +188,7 @@ public class TuohuaConfigBean {
158 } 188 }
159 189
160 if (carsSize > 0) { 190 if (carsSize > 0) {
161 - List<HashMap<String, Object>> cars = carJsonList.stream().filter(c -> !Objects.equals(convertStr(c.get("used")), "1")).map(c -> combatioinCarTree(c)).collect(Collectors.toList()); 191 + List<HashMap<String, Object>> cars = carJsonList.stream().filter(c -> !Objects.equals(convertStr(c.get("used")), "1")).map(c -> combatioinCarTree(c,gpsList)).collect(Collectors.toList());
162 returnData.addAll(cars); 192 returnData.addAll(cars);
163 } 193 }
164 return returnData; 194 return returnData;
@@ -211,15 +241,31 @@ public class TuohuaConfigBean { @@ -211,15 +241,31 @@ public class TuohuaConfigBean {
211 return result; 241 return result;
212 } 242 }
213 243
214 - private HashMap<String, Object> combatioinCarTree(HashMap ch) { 244 +
  245 + private HashMap<String, Object> combatioinCarTree(HashMap ch, List<HashMap> gpsList) {
215 String code = convertStr(ch.get("nbbm")); 246 String code = convertStr(ch.get("nbbm"));
216 - HashMap<String, Object> hashMap = combationTree(code, "bus1", code, false, code, code, false, "<span><img src='/metronic_v4.5.4/layui/icon/bus1.png' class ='imageIcon' /></span><span>" + code + "</span>", 247 + String sim = convertStr(ch.get("sim"));
  248 + String name = code;
  249 +
  250 + Optional<HashMap> optional = gpsList.stream().filter(g -> Objects.nonNull(g) && Objects.nonNull(g.get("deviceId")) &&
  251 + Objects.nonNull(ch.get("equipmentCode")) && Objects.equals(g.get("deviceId").toString(), ch.get("equipmentCode").toString())).findFirst();
  252 + if (StringUtils.isEmpty(sim) || !optional.isPresent() || Objects.isNull(optional.get().get("abnormalStatus")) || StringUtils.equalsIgnoreCase("offline", optional.get().get("abnormalStatus").toString())) {
  253 + name = "<del>" + name + "</del>";
  254 + }
  255 +
  256 + HashMap<String, Object> hashMap = combationTree(code, "bus1", code, false, name, code, false, "<span><img src='/metronic_v4.5.4/layui/icon/bus1.png' class ='imageIcon' /></span><span>" + code + "</span>",
217 "<span><img src='/metronic_v4.5.4/layui/icon/bus1.png' class ='imageIcon' /></span><span>" + code + "</span>", 301); 257 "<span><img src='/metronic_v4.5.4/layui/icon/bus1.png' class ='imageIcon' /></span><span>" + code + "</span>", 301);
218 hashMap.put("sim", formatSim(convertStr(ch.get("sim")))); 258 hashMap.put("sim", formatSim(convertStr(ch.get("sim"))));
219 -// hashMap.put("sim","013800138999"); 259 +
  260 + if (StringUtils.equals(profileActive, "local")) {
  261 +// hashMap.put("sim","123456789011");
  262 + hashMap.put("sim", "122223333444");
  263 + }
  264 +//
220 return hashMap; 265 return hashMap;
221 } 266 }
222 267
  268 +
223 private String random(Integer count) { 269 private String random(Integer count) {
224 StringBuilder builder = new StringBuilder(); 270 StringBuilder builder = new StringBuilder();
225 for (int i = 0; i < count; i++) { 271 for (int i = 0; i < count; i++) {
@@ -253,7 +299,7 @@ public class TuohuaConfigBean { @@ -253,7 +299,7 @@ public class TuohuaConfigBean {
253 StringBuilder builder = new StringBuilder(); 299 StringBuilder builder = new StringBuilder();
254 boolean flag = true; 300 boolean flag = true;
255 for (int i = 0; i < length; i++) { 301 for (int i = 0; i < length; i++) {
256 - char val = chars[i]; 302 + char val = chars[i];
257 if (flag && val == '0') { 303 if (flag && val == '0') {
258 continue; 304 continue;
259 } 305 }
src/main/java/com/genersoft/iot/vmp/vmanager/jt1078/platform/handler/HttpClientUtil.java
@@ -16,6 +16,8 @@ import org.apache.http.impl.client.BasicCookieStore; @@ -16,6 +16,8 @@ import org.apache.http.impl.client.BasicCookieStore;
16 import org.apache.http.impl.client.DefaultHttpClient; 16 import org.apache.http.impl.client.DefaultHttpClient;
17 import org.apache.http.impl.cookie.BasicClientCookie; 17 import org.apache.http.impl.cookie.BasicClientCookie;
18 import org.apache.http.message.BasicNameValuePair; 18 import org.apache.http.message.BasicNameValuePair;
  19 +import org.apache.http.params.BasicHttpParams;
  20 +import org.apache.http.params.HttpConnectionParams;
19 import org.apache.http.util.EntityUtils; 21 import org.apache.http.util.EntityUtils;
20 import org.jetbrains.annotations.NotNull; 22 import org.jetbrains.annotations.NotNull;
21 import org.slf4j.Logger; 23 import org.slf4j.Logger;
@@ -37,7 +39,7 @@ public class HttpClientUtil { @@ -37,7 +39,7 @@ public class HttpClientUtil {
37 39
38 public HttpClientPostEntity doPost(String url, Map<String, String> params, String jsessionid) throws URISyntaxException, IOException { 40 public HttpClientPostEntity doPost(String url, Map<String, String> params, String jsessionid) throws URISyntaxException, IOException {
39 // 创建Httpclient对象 41 // 创建Httpclient对象
40 - DefaultHttpClient httpclient = new DefaultHttpClient(); 42 + DefaultHttpClient httpclient = getHttpClient();
41 // 定义请求的参数 43 // 定义请求的参数
42 CookieStore cookieStore1 = combationCookie(jsessionid); 44 CookieStore cookieStore1 = combationCookie(jsessionid);
43 httpclient.setCookieStore(cookieStore1); 45 httpclient.setCookieStore(cookieStore1);
@@ -75,7 +77,7 @@ public class HttpClientUtil { @@ -75,7 +77,7 @@ public class HttpClientUtil {
75 77
76 public HttpClientPostEntity doPost(String url, String requestBody, String jsessionid) throws URISyntaxException, IOException { 78 public HttpClientPostEntity doPost(String url, String requestBody, String jsessionid) throws URISyntaxException, IOException {
77 // 创建Httpclient对象 79 // 创建Httpclient对象
78 - DefaultHttpClient httpclient = new DefaultHttpClient(); 80 + DefaultHttpClient httpclient = getHttpClient();
79 // 定义请求的参数 81 // 定义请求的参数
80 CookieStore cookieStore1 = combationCookie( jsessionid); 82 CookieStore cookieStore1 = combationCookie( jsessionid);
81 83
@@ -129,7 +131,7 @@ public class HttpClientUtil { @@ -129,7 +131,7 @@ public class HttpClientUtil {
129 131
130 public HttpClientPostEntity doGet(String url, String jsessionid) throws URISyntaxException, IOException { 132 public HttpClientPostEntity doGet(String url, String jsessionid) throws URISyntaxException, IOException {
131 // 创建Httpclient对象 133 // 创建Httpclient对象
132 - DefaultHttpClient httpclient = new DefaultHttpClient(); 134 + DefaultHttpClient httpclient = getHttpClient();
133 // 定义请求的参数 135 // 定义请求的参数
134 CookieStore cookieStore1 = combationCookie(jsessionid); 136 CookieStore cookieStore1 = combationCookie(jsessionid);
135 // 137 //
@@ -174,4 +176,17 @@ public class HttpClientUtil { @@ -174,4 +176,17 @@ public class HttpClientUtil {
174 log.info("url:{};requestBody:{};response data:{}",url,requestBody,result); 176 log.info("url:{};requestBody:{};response data:{}",url,requestBody,result);
175 return postEntity; 177 return postEntity;
176 } 178 }
  179 +
  180 +
  181 + /**
  182 + * 获取 HttpClient,主要是封装了超时设置
  183 + * @return
  184 + */
  185 + public DefaultHttpClient getHttpClient(){
  186 + BasicHttpParams httpParams = new BasicHttpParams();
  187 + HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
  188 + HttpConnectionParams.setSoTimeout(httpParams, 15000);
  189 + DefaultHttpClient client = new DefaultHttpClient(httpParams);
  190 + return client;
  191 + }
177 } 192 }
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
@@ -22,12 +22,14 @@ import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,12 +22,14 @@ import io.swagger.v3.oas.annotations.tags.Tag;
22 import org.slf4j.Logger; 22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory; 23 import org.slf4j.LoggerFactory;
24 import org.springframework.beans.factory.annotation.Autowired; 24 import org.springframework.beans.factory.annotation.Autowired;
  25 +import org.springframework.data.redis.core.RedisTemplate;
25 import org.springframework.stereotype.Controller; 26 import org.springframework.stereotype.Controller;
26 import org.springframework.util.ObjectUtils; 27 import org.springframework.util.ObjectUtils;
27 import org.springframework.web.bind.annotation.*; 28 import org.springframework.web.bind.annotation.*;
28 import org.springframework.web.context.request.async.DeferredResult; 29 import org.springframework.web.context.request.async.DeferredResult;
29 30
30 import java.util.UUID; 31 import java.util.UUID;
  32 +import java.util.concurrent.TimeUnit;
31 33
32 @SuppressWarnings("rawtypes") 34 @SuppressWarnings("rawtypes")
33 /** 35 /**
@@ -52,6 +54,8 @@ public class StreamProxyController { @@ -52,6 +54,8 @@ public class StreamProxyController {
52 54
53 @Autowired 55 @Autowired
54 private UserSetting userSetting; 56 private UserSetting userSetting;
  57 + @Autowired
  58 + private RedisTemplate redisTemplate;
55 59
56 60
57 @Operation(summary = "分页查询流代理", security = @SecurityRequirement(name = JwtUtils.HEADER)) 61 @Operation(summary = "分页查询流代理", security = @SecurityRequirement(name = JwtUtils.HEADER))
@@ -127,6 +131,7 @@ public class StreamProxyController { @@ -127,6 +131,7 @@ public class StreamProxyController {
127 requestMessage.setData(WVPResult.fail(code, msg)); 131 requestMessage.setData(WVPResult.fail(code, msg));
128 } 132 }
129 resultHolder.invokeAllResult(requestMessage); 133 resultHolder.invokeAllResult(requestMessage);
  134 + redisTemplate.opsForValue().set("timeout:"+param.getStream(),"1",30, TimeUnit.SECONDS);
130 }); 135 });
131 return result; 136 return result;
132 } 137 }
src/main/resources/application-local.yml
@@ -13,11 +13,11 @@ spring: @@ -13,11 +13,11 @@ spring:
13 # REDIS数据库配置 13 # REDIS数据库配置
14 redis: 14 redis:
15 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 15 # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
16 - host: 192.168.169.100 16 + host: 192.168.168.124
17 # [必须修改] 端口号 17 # [必须修改] 端口号
18 port: 6379 18 port: 6379
19 # [可选] 数据库 DB 19 # [可选] 数据库 DB
20 - database: 8 20 + database: 10
21 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 21 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
22 # password: guzijian 22 # password: guzijian
23 # [可选] 超时时间 23 # [可选] 超时时间
@@ -42,7 +42,7 @@ spring: @@ -42,7 +42,7 @@ spring:
42 max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位) 42 max-lifetime: 1200000 # 是池中连接关闭后的最长生命周期(以毫秒为单位)
43 #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 43 #[可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
44 server: 44 server:
45 - port: 18080 45 + port: 28080
46 # [可选] HTTPS配置, 默认不开启 46 # [可选] HTTPS配置, 默认不开启
47 ssl: 47 ssl:
48 # [可选] 是否开启HTTPS访问 48 # [可选] 是否开启HTTPS访问
@@ -133,6 +133,7 @@ tuohua: @@ -133,6 +133,7 @@ tuohua:
133 login: 133 login:
134 pageURL: http://192.169.1.92:9088/user/login/jCryptionKey 134 pageURL: http://192.169.1.92:9088/user/login/jCryptionKey
135 url: http://192.169.1.92:9088/user/login 135 url: http://192.169.1.92:9088/user/login
  136 +
136 userName: yuanxiaohu 137 userName: yuanxiaohu
137 password: Yxiaohu1.0 138 password: Yxiaohu1.0
138 rest: 139 rest:
@@ -142,16 +143,17 @@ tuohua: @@ -142,16 +143,17 @@ tuohua:
142 url: 143 url:
143 company: http://192.169.1.92:9088/video/tree 144 company: http://192.169.1.92:9088/video/tree
144 car: http://192.169.1.92:9088/video/tree/carNo/{0} 145 car: http://192.169.1.92:9088/video/tree/carNo/{0}
145 - sim: http://192.169.1.92:9088/video//tree/caNO/sim/{0} 146 + sim: http://192.169.1.92:9088/video/tree/caNO/sim/{0}
146 wvp28181: 147 wvp28181:
147 rtsp: 148 rtsp:
148 - tcpPort: 1078  
149 - udpPort: 1078 149 + tcpPort: 11078
  150 + udpPort: 11078
150 historyTcpPort: 9999 151 historyTcpPort: 9999
151 historyUdpPort: 9999 152 historyUdpPort: 9999
152 ip : 61.169.120.202 153 ip : 61.169.120.202
153 jt1078: 154 jt1078:
154 ports: 9100,9600 155 ports: 9100,9600
  156 + addPortVal: 30000
155 pushURL: http://192.169.1.92:3333/new/server/{pushKey}/{port}/{httpPort} 157 pushURL: http://192.169.1.92:3333/new/server/{pushKey}/{port}/{httpPort}
156 stopPushURL: http://192.169.1.92:3333/stop/channel/{pushKey}/{port}/{httpPort} 158 stopPushURL: http://192.169.1.92:3333/stop/channel/{pushKey}/{port}/{httpPort}
157 url: http://192.168.168.241:8100/device/{0} 159 url: http://192.168.168.241:8100/device/{0}
@@ -159,6 +161,8 @@ tuohua: @@ -159,6 +161,8 @@ tuohua:
159 playHistoryPort: 9201 161 playHistoryPort: 9201
160 sendPort: 9101 162 sendPort: 9101
161 stopSendPort: 9102 163 stopSendPort: 9102
  164 + ws: ws://192.168.169.100:1091/schedule/{stream}.live.flv
  165 + wss: wss://192.168.169.100:443/schedule/{stream}.live.flv
162 get: 166 get:
163 url: http://192.169.1.92:3333/video/{stream}.flv 167 url: http://192.169.1.92:3333/video/{stream}.flv
164 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey} 168 playURL: /play/wasm/ws%3A%2F%2F{ip}%3A{port}%2Fschedule%2F{sim}-{channel}.live.flv%3FcallId%{publickey}
src/main/resources/application-localDev.yml
No preview for this file type
web_src/config/index.js
@@ -11,7 +11,7 @@ module.exports = { @@ -11,7 +11,7 @@ module.exports = {
11 assetsPublicPath: "/", 11 assetsPublicPath: "/",
12 proxyTable: { 12 proxyTable: {
13 "/debug": { 13 "/debug": {
14 - target: "http://10.10.2.22:18089", 14 + target: "http://127.0.0.1:28080",
15 changeOrigin: true, 15 changeOrigin: true,
16 pathRewrite: { 16 pathRewrite: {
17 "^/debug": "/", 17 "^/debug": "/",
web_src/package.json
@@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
9 "start": "npm run dev", 9 "start": "npm run dev",
10 "build": "node build/build.js" 10 "build": "node build/build.js"
11 }, 11 },
  12 + "resolutions": {
  13 + "lodash": "4.17.21"
  14 + },
12 "dependencies": { 15 "dependencies": {
13 "@liveqing/liveplayer": "^2.7.10", 16 "@liveqing/liveplayer": "^2.7.10",
14 "axios": "^0.24.0", 17 "axios": "^0.24.0",
@@ -28,12 +31,13 @@ @@ -28,12 +31,13 @@
28 "vue-contextmenujs": "^1.3.13", 31 "vue-contextmenujs": "^1.3.13",
29 "vue-cookies": "^1.8.3", 32 "vue-cookies": "^1.8.3",
30 "vue-giant-tree": "^0.1.5", 33 "vue-giant-tree": "^0.1.5",
  34 + "vue-hot-reload-api": "^2.3.4",
31 "vue-router": "^3.1.6", 35 "vue-router": "^3.1.6",
32 "vue-ztree-2.0": "^1.0.4" 36 "vue-ztree-2.0": "^1.0.4"
33 }, 37 },
34 "devDependencies": { 38 "devDependencies": {
35 "autoprefixer": "^7.1.2", 39 "autoprefixer": "^7.1.2",
36 - "babel-core": "^6.22.1", 40 + "babel-core": "^6.26.3",
37 "babel-helper-vue-jsx-merge-props": "^2.0.3", 41 "babel-helper-vue-jsx-merge-props": "^2.0.3",
38 "babel-loader": "^7.1.1", 42 "babel-loader": "^7.1.1",
39 "babel-plugin-syntax-jsx": "^6.18.0", 43 "babel-plugin-syntax-jsx": "^6.18.0",
@@ -48,6 +52,7 @@ @@ -48,6 +52,7 @@
48 "file-loader": "^1.1.4", 52 "file-loader": "^1.1.4",
49 "friendly-errors-webpack-plugin": "^1.6.1", 53 "friendly-errors-webpack-plugin": "^1.6.1",
50 "html-webpack-plugin": "^2.30.1", 54 "html-webpack-plugin": "^2.30.1",
  55 + "i": "^0.3.7",
51 "node-notifier": "^5.1.2", 56 "node-notifier": "^5.1.2",
52 "optimize-css-assets-webpack-plugin": "^3.2.0", 57 "optimize-css-assets-webpack-plugin": "^3.2.0",
53 "ora": "^1.2.0", 58 "ora": "^1.2.0",
web_src/src/components/DeviceList1078.vue 0 → 100644
  1 +<template>
  2 + <div id="devicePosition" style="width:100vw; height: 91vh">
  3 +
  4 + <el-container v-loading="loading" style="height: 91vh;" element-loading-text="拼命加载中">
  5 + <el-aside width="300px" style="background-color: #ffffff">
  6 + <div class="device-tree-main-box">
  7 + <div id="DeviceTree" style="width: 100%;height: 100%; background-color: #FFFFFF; overflow: auto">
  8 + <el-container>
  9 + <el-header>设备列表</el-header>
  10 + <el-main style="background-color: #ffffff;">
  11 + <tree :nodes="nodes" @onClick="onClick" @onCheck="onCheck" @onExpand="onExpand" @onCreated="handleCreated" :props="defaultProps"/>
  12 + </el-main>
  13 + </el-container>
  14 + </div>
  15 + </div>
  16 + </el-aside>
  17 + <el-container>
  18 +
  19 + <el-header height="5vh" style="text-align: left;font-size: 17px;line-height:5vh;width:90%">
  20 + 分屏:
  21 + <i class="el-icon-full-screen btn" :class="{active:spilt==1}" @click="spiltClickFun(1)"/>
  22 + <i class="el-icon-menu btn" :class="{active:spilt==4}" @click="spiltClickFun(4)"/>
  23 + <i class="el-icon-s-grid btn" :class="{active:spilt==9}" @click="spiltClickFun(9)"/>
  24 +
  25 + <button style="margin-left: 15px;" @click="openViewDIalog()">历史数据</button>
  26 + <button style="margin-left: 15px;" @click="OneClickPlayback()">一键播放车辆视频</button>
  27 + </el-header>
  28 +
  29 +
  30 + <el-main style="padding: 0;">
  31 + <div style="width: 99%;height: 85vh;display: flex;flex-wrap: wrap;background-color: #000;">
  32 + <div v-for="i in spilt" :key="i" class="play-box"
  33 + :style="liveStyle" :class="{redborder:playerIdx == (i-1)}"
  34 + @click="playerIdx = (i-1)">
  35 + <div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{ i }}</div>
  36 + <player ref="player" v-else :videoUrl="videoUrl[i-1]" fluent autoplay @screenshot="shot"
  37 + @destroy="destroy"/>
  38 + </div>
  39 + </div>
  40 + </el-main>
  41 + </el-container>
  42 + </el-container>
  43 +
  44 +
  45 + <el-dialog title="历史视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog"
  46 + v-if="showVideoDialog" width="800px" :close-delay="5000" :fullscreen="true" :show-close="false">
  47 + <el-container v-loading="loading" style="height: 88vh;" element-loading-text="拼命加载中">
  48 +
  49 + <div style="width:100%;display: flex;flex-direction: column;justify-content: space-between;">
  50 + <div style="width: 90%;text-align:left;margin-bottom:5px;margin-left: 25px;">
  51 + <el-date-picker size="smaill" v-model="startTime" type="datetime" style="width:220px" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间" />
  52 + <el-date-picker size="smaill" v-model="endTime" type="datetime" style="width:220px" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间" />
  53 +
  54 + <button @click="searchHitoryList()">搜索</button>
  55 + <button @click="download()">下载播放视频</button>
  56 + <button @click="close()">关闭窗口</button>
  57 + </div>
  58 +
  59 + <div style="width: 100%;display:flex;flex-direction:row; justify-content:space-between;">
  60 + <div style="width:20%" v-html="historyPlayListHtml" @click="playHistoryItem">
  61 +
  62 + </div>
  63 + <div style="width: 78%;">
  64 + <div style="width: 95%;height: 80vh;display: flex;flex-wrap: wrap;background-color: #000;">
  65 + <div v-if="!videoUrl[0]" style="color: #ffffff;font-size: 30px;font-weight: bold;"></div>
  66 + <player ref="player" v-else :videoUrl="videoUrl[0]" fluent autoplay @screenshot="shot"
  67 + @destroy="destroy"/>
  68 + </div>
  69 + </div>
  70 + </div>
  71 + </div>
  72 + </el-container>
  73 + </el-dialog>
  74 +
  75 + </div>
  76 +</template>
  77 +
  78 +<script>
  79 +import tree from "vue-giant-tree";
  80 +import uiHeader from "../layout/UiHeader.vue";
  81 +import player from './common/jessibuca.vue'
  82 +import DeviceTree from './common/DeviceTree.vue'
  83 +import { isEmpty } from "ol/extent";
  84 +
  85 +
  86 +export default {
  87 + name: "live",
  88 + components: {
  89 + uiHeader, player, DeviceTree,tree
  90 + },
  91 + data() {
  92 + return {
  93 + videoUrl: [''],
  94 + videoUrlHistory: "",
  95 + spilt: 1,//分屏
  96 + playerIdx: 0,//激活播放器
  97 +
  98 + updateLooper: 0, //数据刷新轮训标志
  99 + count: 15,
  100 + historyLoadingFlag:true,
  101 + total: 0,
  102 + startTime:'',
  103 + endTime:'',
  104 + //channel
  105 + loading: false,
  106 + device: null,
  107 + nodes:[],
  108 + carPlayTimer:null,
  109 + ztreeObj:null,
  110 + ztreeNode:null,
  111 + fullscreenLoading:true,
  112 + fullscreenLoadingStyle:'',
  113 + showVideoDialog:false,
  114 + historyPlayListHtml:'',
  115 + hisotoryPlayFlag:false,
  116 + downloadURL:null,
  117 + port:-1,
  118 + httpPort:-1,
  119 + stream:"",
  120 + sim:"",
  121 + channel:"",
  122 + setting: {
  123 + callback: {
  124 + beforeExpand: this.beforeExpand
  125 + },
  126 + check: {
  127 + enable: false,
  128 + },
  129 + edit: {
  130 + enable: false,
  131 + }
  132 + },
  133 + defaultProps: {
  134 + children: 'children',
  135 + label: 'title',
  136 + name: 'title',
  137 + isLeaf: 'spread',
  138 + nameIsHTML: true,
  139 + view: {
  140 + nameIsHTML: true
  141 + }
  142 + }
  143 + };
  144 + },
  145 +
  146 + mounted() {
  147 + let that = this;
  148 + that.initTreeData();
  149 + },
  150 + created() {
  151 + this.checkPlayByParam()
  152 + },
  153 +
  154 + computed: {
  155 + liveStyle() {
  156 + let style = {width: '100%', height: '100%'}
  157 + switch (this.spilt) {
  158 + case 4:
  159 + style = {width: '49%', height: '49%'}
  160 + break
  161 + case 9:
  162 + style = {width: '32%', height: '32%'}
  163 + break
  164 + }
  165 + this.$nextTick(() => {
  166 + for (let i = 0; i < this.spilt; i++) {
  167 + const player = this.$refs.player
  168 + player && player[i] && player[i].updatePlayerDomSize()
  169 + }
  170 + })
  171 + return style
  172 + }
  173 + },
  174 + watch: {
  175 + spilt(newValue) {
  176 + console.log("切换画幅;" + newValue)
  177 + let that = this
  178 + for (let i = 1; i <= newValue; i++) {
  179 + if (!that.$refs['player' + i]) {
  180 + continue
  181 + }
  182 + this.$nextTick(() => {
  183 + if (that.$refs['player' + i] instanceof Array) {
  184 + that.$refs['player' + i][0].resize()
  185 + } else {
  186 + that.$refs['player' + i].resize()
  187 + }
  188 + })
  189 +
  190 + }
  191 + window.localStorage.setItem('split', newValue)
  192 + },
  193 + '$route.fullPath': 'checkPlayByParam'
  194 + },
  195 + destroyed() {
  196 + this.sendIORequestStop(this.sim,this.channel);
  197 + clearTimeout(this.updateLooper);
  198 + if(!this.isEmpty(this.carPlayTimer)){
  199 + console.log("bbbbbbbbbbbbbbb");
  200 +
  201 + clearTimeout(this.carPlayTimer);
  202 + }
  203 + },
  204 + methods: {
  205 + destroy(idx) {
  206 + console.log(idx);
  207 + this.clear(idx.substring(idx.length - 1))
  208 + },
  209 + treeChannelClick(device, data, isCatalog) {
  210 + if (data.channelId && !isCatalog) {
  211 + if (device.online === 0) {
  212 + this.$message.error('设备离线!不允许点播');
  213 + this.closeLoading();
  214 + return false;
  215 + }else {
  216 + let pageObj = this;
  217 +
  218 + pageObj.sendDevicePush(data);
  219 +
  220 + }
  221 + }
  222 + },
  223 + contextMenuEvent: function (device, event, data, isCatalog) {
  224 +
  225 + },
  226 + //通知设备上传媒体流
  227 + sendDevicePush: function (itemData,fun) {
  228 + // if (itemData.status === 0) {
  229 + // this.$message.error('设备离线!');
  230 + // return
  231 + // }
  232 + this.save(itemData)
  233 + let deviceId = itemData.deviceId;
  234 + // this.isLoging = true;
  235 + let channelId = itemData.channelId;
  236 +
  237 + if(this.isEmpty(deviceId)){
  238 + this.$message.error("没有获取到sim卡,请检查设备是否接入");
  239 + this.closeLoading();
  240 + if(fun){
  241 + fun();
  242 + }
  243 + return;
  244 + }
  245 +
  246 +
  247 + console.log("通知设备推流1:" + deviceId + " : " + channelId);
  248 + let idxTmp = this.playerIdx
  249 + let that = this;
  250 + this.loading = true
  251 +
  252 + this.$axios({
  253 + method: 'get',
  254 + url: '/api/jt1078/query/send/request/io/' + deviceId + '/' + channelId
  255 + }).then(function (res) {
  256 +
  257 + if (res.data.code === 0 && res.data.data && (res.data.data.code ==="1" || res.data.data.code==1) ) {
  258 + let videoUrl;
  259 + that.port=res.data.data.port;
  260 + that.httpPort = res.data.data.httpPort;
  261 + that.stream = res.data.data.stream;
  262 + console.log(that.httpPort);
  263 + console.log(that.port);
  264 + console.log(res.data);
  265 +
  266 + console.log("===========================>");
  267 +
  268 +
  269 + if(res.data.data.data){
  270 + this.downloadURL.value = res.data.data.data.flv;
  271 + if (location.protocol === "https:") {
  272 + videoUrl = res.data.data.data.wss_flv;
  273 + } else {
  274 + videoUrl = res.data.data.data.ws_flv;
  275 + }
  276 + console.log(videoUrl);
  277 +
  278 + itemData.playUrl = videoUrl;
  279 + that.setPlayUrl(videoUrl, idxTmp);
  280 + }
  281 +
  282 + }else {
  283 + if(!that.isEmpty(res.data.data) && !that.isEmpty( res.data.data.msg)){
  284 + that.$message.error(res.data.data.msg);
  285 + }else{
  286 +
  287 + that.$message.error(res.data.msg);
  288 + }
  289 +
  290 + }
  291 +
  292 + if(fun){
  293 +
  294 + fun();
  295 + }
  296 + }).catch(function (e) {
  297 + if(fun){
  298 + console.log("fun-------------------->2");
  299 + fun();
  300 + }
  301 + }).finally(() => {
  302 + this.closeLoading();
  303 + });
  304 +
  305 +
  306 + },
  307 + setPlayUrl(url, idx) {
  308 +
  309 + this.$set(this.videoUrl, idx, url)
  310 + let _this = this
  311 + setTimeout(() => {
  312 + window.localStorage.setItem('videoUrl', JSON.stringify(_this.videoUrl))
  313 + }, 100)
  314 +
  315 + },
  316 + checkPlayByParam() {
  317 + let {deviceId, channelId} = this.$route.query
  318 + if (deviceId && channelId) {
  319 + this.sendDevicePush({deviceId, channelId})
  320 + }
  321 + },
  322 + shot(e) {
  323 + // console.log(e)
  324 + // send({code:'image',data:e})
  325 + var base64ToBlob = function (code) {
  326 + let parts = code.split(';base64,');
  327 + let contentType = parts[0].split(':')[1];
  328 + let raw = window.atob(parts[1]);
  329 + let rawLength = raw.length;
  330 + let uInt8Array = new Uint8Array(rawLength);
  331 + for (let i = 0; i < rawLength; ++i) {
  332 + uInt8Array[i] = raw.charCodeAt(i);
  333 + }
  334 + return new Blob([uInt8Array], {
  335 + type: contentType
  336 + });
  337 + };
  338 + let aLink = document.createElement('a');
  339 + let blob = base64ToBlob(e); //new Blob([content]);
  340 + let evt = document.createEvent("HTMLEvents");
  341 + evt.initEvent("click", true, true); //initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
  342 + aLink.download = '截图';
  343 + aLink.href = URL.createObjectURL(blob);
  344 + aLink.click();
  345 + },
  346 + save(item) {
  347 + let dataStr = window.localStorage.getItem('playData') || '[]'
  348 + let data = JSON.parse(dataStr);
  349 + data[this.playerIdx] = item
  350 + window.localStorage.setItem('playData', JSON.stringify(data))
  351 + },
  352 + clear(idx) {
  353 + let dataStr = window.localStorage.getItem('playData') || '[]'
  354 + let data = JSON.parse(dataStr);
  355 + data[idx - 1] = null;
  356 + console.log(data);
  357 + window.localStorage.setItem('playData', JSON.stringify(data))
  358 + },
  359 + initTreeData(){
  360 + this.showLoading();
  361 + this.$axios({
  362 + method: 'get',
  363 + url:`/api/jt1078/query/company/tree`,
  364 + }).then((res) => {
  365 + if(res && res.data && res.data.data){
  366 + if(res.data.data.code == 1){
  367 + let data = res.data.data.result;
  368 + this.initDate(this.nodes,data);
  369 + }else if(res.data.data.message){
  370 + this.$message.error(res.data.data.message);
  371 + }
  372 + }else{
  373 + this.$message.error("请求错误,请刷新再试");
  374 + }
  375 +
  376 + this.closeLoading();
  377 +
  378 +
  379 + });
  380 + },
  381 +
  382 + initDate(nodes,datas){
  383 + if(nodes && datas){
  384 + let len = datas.length;
  385 + for (let i = 0; i < len; i++) {
  386 + if(null == datas[i].id || undefined == datas[i].id || "" == datas[i].id){
  387 + continue;
  388 + }
  389 + let node = this.combationNodeValue(datas[i].name,datas[i].id,datas[i].type,true,datas[i].sim)
  390 +
  391 + nodes.push(node);
  392 + if(datas[i].children){
  393 + node.children = [];
  394 + this.initDate(node.children,datas[i].children);
  395 + }
  396 + }
  397 + }
  398 + },
  399 + combationNodeValue(name,id,type,isParent,sim){
  400 + if(this.isEmpty(sim)){
  401 + sim = "";
  402 + }
  403 +
  404 + return {
  405 + name: name,
  406 + id: id,
  407 + sim:sim,
  408 + type: type,
  409 + isParent: isParent,
  410 +
  411 + }
  412 + },
  413 + onClick(evt, treeId, treeNode) {
  414 + this.combationChildNode(treeNode);
  415 + },
  416 + onCheck(evt, treeId, treeNode) {
  417 +
  418 + },
  419 + beforeExpand(treeId, treeNode) {
  420 +
  421 + return true;
  422 + },
  423 + onExpand(evt, treeId, treeNode) {
  424 + this.combationChildNode(treeNode);
  425 + },
  426 + handleCreated(ztreeObj) {
  427 + this.ztreeObj = ztreeObj;
  428 + this.ztreeObj.setting.view.nameIsHTML=true;
  429 +
  430 + },
  431 +
  432 + combationChildNode(treeNo){
  433 + this.ztreeNode = treeNo;
  434 + if(treeNo.seachChild && (treeNo.seachChild == 'true')){
  435 + return;
  436 + }
  437 + console.log(treeNo.type);
  438 +
  439 + this.showLoading();
  440 + if(treeNo.type == 401 || treeNo.type == '401'){
  441 + let device = new Object();
  442 + if(this.isEmpty(treeNo.online)){
  443 + treeNo.online = 1;
  444 + }
  445 + device.online = treeNo.online;
  446 +
  447 + if(this.spilt == 1){
  448 + this.videoUrl=[]
  449 + }
  450 +
  451 + let pageObj = this;
  452 +
  453 + if(!this.isEmpty(this.sim) && !this.channel && this.sim != treeNo.sim && this.channel != treeNo.id){
  454 + let data = new Object();
  455 + data.channelId =treeNo.id;
  456 + data.sim = treeNo.sim;
  457 + data.deviceId = treeNo.sim;
  458 + this.sim = treeNo.sim;
  459 + this.channel = treeNo.id;
  460 + console.log("stop");
  461 +
  462 + this.sendIORequestStop(data.sim,data.channelId,function(){
  463 +
  464 + let flag = pageObj.treeChannelClick(device,data,false);
  465 + if(false == flag){
  466 + treeNo.online = 0;
  467 + }
  468 + });
  469 + }else{
  470 + let data = new Object();
  471 + data.channelId =treeNo.id;
  472 + data.sim = treeNo.sim;
  473 + data.deviceId = treeNo.sim;
  474 + this.sim = treeNo.sim;
  475 + this.channel = treeNo.id;
  476 +
  477 + let flag = pageObj.treeChannelClick(device,data,false);
  478 + if(false == flag){
  479 + treeNo.online = 0;
  480 + }
  481 + }
  482 + }else if(treeNo.type ==301 || treeNo.type=='301'){
  483 + this.addChannel(treeNo);
  484 + this.channel = null;
  485 + }else if(treeNo.type==2|| treeNo.type=='2') {
  486 + this.requestChildNode(treeNo);
  487 + this.sim = null;
  488 + this.channel = null;
  489 + }else{
  490 + this.closeLoading();
  491 + }
  492 +
  493 + },
  494 + addChannel(treeNo){
  495 + let labels=['ADAS','DSM','路况','司机','整车前','中门','倒车','前门客流','后面客流'];
  496 + let children=[];
  497 + let len = labels.length;
  498 + let i = 0;
  499 +
  500 + let pageObj = this;
  501 + for(;i<len;i++){
  502 + let node = this.combationNodeValue(labels[i],i+1,401,false);
  503 + node.sim = treeNo.sim;
  504 + node.zbh = treeNo.name;
  505 + node.id=i+1;
  506 + children.push(node);
  507 + }
  508 + this.ztreeObj.addNodes(treeNo,0,children,true);
  509 + treeNo.seachChild='true';
  510 +
  511 + pageObj.sim = treeNo.sim;
  512 +
  513 + this.closeLoading();
  514 +
  515 + },
  516 + requestChildNode(treeNo){
  517 +
  518 + if(treeNo.spread==='false' || !treeNo.spread){
  519 + let id = treeNo.id;
  520 + let that = this;
  521 + this.$axios({
  522 + method: 'get',
  523 + url:`/api/jt1078/query/car/tree/`+id,
  524 + }).then((res) => {
  525 +
  526 + if(res && res.data && res.data.data){
  527 + if(res.data.data.code == 1){
  528 + let children =[];
  529 + this.initDate(children,res.data.data.result);
  530 +
  531 + this.ztreeObj.addNodes(treeNo,-1,children,true);
  532 + treeNo.seachChild='true';
  533 +
  534 + this.carPlayTimer = setTimeout(function(){
  535 + that.requestChildNode1();
  536 + },15000);
  537 +
  538 + }else if(res.data.data.message){
  539 + this.$message.error(res.data.data.message);
  540 + }
  541 + }else{
  542 + this.$message.error("请求错误,请刷新再试");
  543 + }
  544 +
  545 + this.closeLoading();
  546 + })
  547 + }
  548 + },
  549 + requestChildNode1(treeNo){
  550 + let that = this;
  551 + this.$axios({
  552 + method: 'get',
  553 + url:`/api/jt1078/query/car/tree/`+100,
  554 + }).then((res) => {
  555 +
  556 + if(res && res.data && res.data.data){
  557 + if(res.data.data.code == 1){
  558 + this.refreshRequestRefresh(res.data.data.result);
  559 +
  560 + }else if(res.data.data.message){
  561 + this.$message.error(res.data.data.message);
  562 + }
  563 + }else{
  564 + this.$message.error("请求错误,请刷新再试");
  565 + }
  566 + })
  567 + },
  568 +
  569 + refreshRequestRefresh(nodes){
  570 + if(nodes){
  571 + let length = nodes.length;
  572 + for(let i=0;i<length;i++){
  573 + let findNode = this.ztreeObj.getNodeByParam("id",nodes[i].id+"",null);
  574 + if(findNode){
  575 + findNode.name = nodes[i].name;
  576 + if(findNode.type==301 || findNode.type=='301'){
  577 + findNode.name = nodes[i].name;
  578 + }else{
  579 + findNode.name = nodes[i].name;
  580 + }
  581 + this.ztreeObj.updateNode(findNode);
  582 +
  583 + if(nodes[i].children){
  584 + this.refreshRequestRefresh(nodes[i].children);
  585 + }
  586 + }
  587 +
  588 +
  589 + }
  590 + }
  591 + },
  592 + showLoading(){
  593 +
  594 +
  595 + this.loading = true;
  596 + this.fullscreenLoading = true;
  597 + // this.fullscreenLoadingStyle ='display:block';
  598 + },
  599 + closeLoading(){
  600 + this.loading = false;
  601 + //this.fullscreenLoadingStyle ='display:none';
  602 + this.fullscreenLoading = false;
  603 + console.log("已经关闭");
  604 +
  605 +
  606 + },
  607 + sendIORequestStop(sim,channel,fun){
  608 + if(this.isEmpty(sim) || this.isEmpty(channel)){
  609 + console.log("sim:"+sim+";channel:"+channel);
  610 + if(fun){
  611 + fun();
  612 + }
  613 + return;
  614 + }
  615 +
  616 +
  617 +
  618 + this.videoUrl=[''];
  619 + this.$axios({
  620 + method: 'get',
  621 + url:`/api/jt1078/query/send/stop/io/`+sim+"/"+channel+"/"+this.stream+"/"+this.port+"/"+this.httpPort+"/",
  622 + }).then((res) => {
  623 + console.log(res);
  624 + if(fun){
  625 + fun();
  626 + }
  627 + });
  628 + },
  629 + isEmpty(val){
  630 + return null == val || undefined == val || "" == val;
  631 + },
  632 + openViewDIalog(){
  633 +
  634 + if(this.isEmpty(this.sim)){
  635 + this.$message.error('请选择车辆');
  636 + return;
  637 + }
  638 +
  639 + if(this.isEmpty(this.channel)){
  640 +
  641 + this.$message.error('请选择通道');
  642 + return;
  643 + }
  644 + this.showLoading();
  645 + let pageObj =this;
  646 + this.videoUrl=[''];
  647 +
  648 +
  649 + pageObj.showVideoDialog = true;
  650 + pageObj.closeLoading();
  651 +
  652 +
  653 + },
  654 + close() {
  655 + let pageObj = this;
  656 + this.showLoading();
  657 + if(this.hisotoryPlayFlag){
  658 + this.sendIORequestStop(this.sim,this.channel,function(){
  659 + pageObj.showVideoDialog = false;
  660 + pageObj.videoUrl=[''];
  661 + pageObj.closeLoading();
  662 + console.log("关闭弹窗");
  663 + });
  664 + }else{
  665 + pageObj.showVideoDialog = false;
  666 + pageObj.closeLoading();
  667 + }
  668 + },
  669 + searchHitoryList(){
  670 + if(this.isEmpty(this.sim)){
  671 + this.$message.error('请选择车辆');
  672 + return;
  673 + }
  674 +
  675 + if(this.isEmpty(this.channel)){
  676 + this.$message.error('请选择通道');
  677 + return;
  678 + }
  679 +
  680 + if(this.isEmpty(this.startTime)){
  681 + this.$message.error('请选择开始时间');
  682 + return;
  683 + }
  684 +
  685 + if(this.isEmpty(this.endTime)){
  686 + this.$message.error('请选择结束时间');
  687 + return;
  688 + }
  689 +
  690 + this.showLoading();
  691 +
  692 + let pageObj = this;
  693 + this.$axios({
  694 + method: 'get',
  695 + url: '/api/jt1078/query/history/list/' + this.sim + '/' + this.channel+"/"+this.startTime+"/"+this.endTime
  696 + }).then(function (res) {
  697 +
  698 +
  699 + if(res &&res.data && res.data.data && res.data.data.obj && res.data.data.code==1 && res.data.data.obj.data && res.data.data.obj.data.items){
  700 + let length = res.data.data.obj.data.items.length;
  701 + let html = "<div class='historyListDiv'><ul>";
  702 + for (let i = 0; i < length; i++) {
  703 + let item = res.data.data.obj.data.items[i];
  704 + if(item.channelNo === pageObj.channel){
  705 + let title = item.startTime+"——"+item.endTime;
  706 + html+="<li class='historyListLi' click='playHistoryItem()' startTime = '"+item.startTime+"' endTime='"+item.endTime+"' streamType='"+item.streamType+"' title='"+title+"' channelMapping='"+item.channelMapping+"'>"+title+"</li>";
  707 + }
  708 + }
  709 + pageObj.historyPlayListHtml = html+"</ul></div>";
  710 + pageObj.closeLoading();
  711 + }else if(res && res.data && res.data.data && res.data.data.msg){
  712 + pageObj.$message.error(res.data.data.msg);
  713 + pageObj.closeLoading();
  714 + }else{
  715 + pageObj.closeLoading();
  716 + }
  717 + });
  718 + },
  719 + playHistoryItem(e){
  720 + if(this.isEmpty(this.sim)){
  721 + this.$message.error('请选择车辆');
  722 + return;
  723 + }
  724 +
  725 + if(this.isEmpty(this.channel)){
  726 + this.$message.error('请选择通道');
  727 + return;
  728 + }
  729 +
  730 + if(this.isEmpty(this.startTime)){
  731 + this.$message.error('请选择开始时间');
  732 + return;
  733 + }
  734 +
  735 + if(this.isEmpty(this.endTime)){
  736 + this.$message.error('请选择结束时间');
  737 + return;
  738 + }
  739 +
  740 + let pageObj = this;
  741 + this.showLoading();
  742 +
  743 + this.videoUrl =[];
  744 +
  745 +
  746 + pageObj.$axios({
  747 + method: 'get',
  748 + url: '/api/jt1078/query/send/request/io/history/' + pageObj.sim + '/' + pageObj.channel+"/"+e.target.getAttribute('startTime')+"/"+e.target.getAttribute('endTime')+"/"+e.target.getAttribute('channelMapping')
  749 + }).then(function (res) {
  750 + console.log(res);
  751 +
  752 + if (res.data && res.data.data && res.data.data.data) {
  753 + let videoUrl1;
  754 + if (location.protocol === "https:") {
  755 + videoUrl1 = res.data.data.data.wss_flv;
  756 + } else {
  757 + videoUrl1 = res.data.data.data.ws_flv;
  758 + }
  759 + pageObj.port=res.data.data.port;
  760 + pageObj.httpPort = res.data.data.httpPort;
  761 + pageObj.stream = res.data.data.stream;
  762 + pageObj.videoUrlHistory = videoUrl1;
  763 +
  764 + let itemData = new Object();
  765 + itemData.deviceId = pageObj.sim;
  766 + // this.isLoging = true;
  767 + itemData.channelId= pageObj.channel;
  768 + itemData.playUrl = videoUrl1;
  769 + console.log(pageObj.playerIdx);
  770 +
  771 + pageObj.setPlayUrl(videoUrl1, 0);
  772 + pageObj.hisotoryPlayFlag = true;
  773 + // pageObj.$nextTick(() => {
  774 + // pageObj.createdPlay();
  775 + // pageObj.closeLoading();
  776 + // })
  777 + } else if(res.data.data && res.data.data.msg){
  778 + pageObj.$message.error(res.data.data.msg);
  779 + } else if(res.data.msg){
  780 + pageObj.$message.error(res.data.msg);
  781 + }else if(res.msg){
  782 + pageObj.$message.error(res.msg);
  783 + }
  784 + pageObj.closeLoading();
  785 + });
  786 +
  787 + },
  788 + createdPlay() {
  789 + if (flvjs.isSupported()) {
  790 + // var videoDom = document.getElementById('myVideo')
  791 + console.log(this.videoUrlHistory);
  792 + let videoDom = this.$refs.myVideo
  793 + // 创建一个播放器实例
  794 + var player = flvjs.createPlayer({
  795 + type: 'flv', // 媒体类型,默认是 flv,
  796 + isLive: false, // 是否是直播流
  797 + url: this.videoUrlHistory // 流地址
  798 + }, {
  799 + // 其他的配置项可以根据项目实际情况参考 api 去配置
  800 + autoCleanupMinBackwardDuration: true, // 清除缓存 对 SourceBuffer 进行自动清理
  801 + })
  802 + player.attachMediaElement(videoDom)
  803 + player.load()
  804 + player.play()
  805 + this.player = player
  806 + }
  807 + },
  808 + OneClickPlayback(){
  809 + if(this.isEmpty(this.sim)){
  810 + this.$message.error('请选择车辆');
  811 + return;
  812 + }
  813 + this.spilt = 9;
  814 +
  815 + for(let i=0;i<9;i++){
  816 + let item = new Object();
  817 + item.deviceId = this.sim;
  818 + item.channelId = 1+i;
  819 + this.playerIdx=i;
  820 + this.sendDevicePush(item);
  821 + }
  822 +
  823 +
  824 + },
  825 + spiltClickFun(val){
  826 + this.spilt = val;
  827 + if(val-1 < this.playerIdx){
  828 + this.playerIdx = val-1;
  829 + }
  830 + },
  831 + download(){
  832 + if(this.isEmpty(this.downloadURL) || this.isEmpty(this.downloadURL.value)){
  833 + return;
  834 + }
  835 + window.open(this.downloadURL.value,"_download");
  836 + }
  837 + }
  838 +};
  839 +
  840 +
  841 +</script>
  842 +
  843 +<style>
  844 +.device-tree-main-box{
  845 + text-align: left;
  846 +}
  847 +.btn {
  848 + margin: 0 10px;
  849 +
  850 +}
  851 +
  852 +.btn:hover {
  853 + color: #409EFF;
  854 +}
  855 +
  856 +.btn.active {
  857 + color: #409EFF;
  858 +
  859 +}
  860 +
  861 +.redborder {
  862 + border: 2px solid red !important;
  863 +}
  864 +
  865 +.play-box {
  866 + background-color: #000000;
  867 + border: 2px solid #505050;
  868 + display: flex;
  869 + align-items: center;
  870 + justify-content: center;
  871 +}
  872 +.historyListLi{
  873 + width: 97%;
  874 + white-space: nowrap;
  875 + text-overflow: ellipsis;
  876 + cursor: pointer;
  877 + padding: 3px;
  878 + margin-bottom: 6px;
  879 + border: 1px solid #000000;
  880 +}
  881 +.historyListDiv{
  882 + height:80vh;
  883 + width:100%;
  884 + overflow-y:auto;
  885 + overflow-x:hidden;
  886 +}
  887 +</style>
  888 +<style>
  889 +.videoList {
  890 + display: flex;
  891 + flex-wrap: wrap;
  892 + align-content: flex-start;
  893 +}
  894 +
  895 +.video-item {
  896 + position: relative;
  897 + width: 15rem;
  898 + height: 10rem;
  899 + margin-right: 1rem;
  900 + background-color: #000000;
  901 +}
  902 +
  903 +.video-item-img {
  904 + position: absolute;
  905 + top: 0;
  906 + bottom: 0;
  907 + left: 0;
  908 + right: 0;
  909 + margin: auto;
  910 + width: 100%;
  911 + height: 100%;
  912 +}
  913 +
  914 +.video-item-img:after {
  915 + content: "";
  916 + display: inline-block;
  917 + position: absolute;
  918 + z-index: 2;
  919 + top: 0;
  920 + bottom: 0;
  921 + left: 0;
  922 + right: 0;
  923 + margin: auto;
  924 + width: 3rem;
  925 + height: 3rem;
  926 + background-image: url("../assets/loading.png");
  927 + background-size: cover;
  928 + background-color: #000000;
  929 +}
  930 +
  931 +.video-item-title {
  932 + position: absolute;
  933 + bottom: 0;
  934 + color: #000000;
  935 + background-color: #ffffff;
  936 + line-height: 1.5rem;
  937 + padding: 0.3rem;
  938 + width: 14.4rem;
  939 +}
  940 +
  941 +.baidumap {
  942 + width: 100%;
  943 + height: 100%;
  944 + border: none;
  945 + position: absolute;
  946 + left: 0;
  947 + top: 0;
  948 + right: 0;
  949 + bottom: 0;
  950 + margin: auto;
  951 +}
  952 +
  953 +/* 去除百度地图版权那行字 和 百度logo */
  954 +.baidumap > .BMap_cpyCtrl {
  955 + display: none !important;
  956 +}
  957 +
  958 +.baidumap > .anchorBL {
  959 + display: none !important;
  960 +}
  961 +</style>
0 \ No newline at end of file 962 \ No newline at end of file
web_src/src/components/common/DeviceTree1078.vue 0 → 100644
  1 +<template>
  2 + <div id="DeviceTree" style="width: 100%;height: 100%; background-color: #FFFFFF; overflow: auto">
  3 + <el-container>
  4 + <el-header>设备列表</el-header>
  5 + <el-main style="background-color: #ffffff;">
  6 + <div class="device-tree-main-box">
  7 + <el-tree ref="gdTree" :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" node-key="id" style="min-width: 100%; display:inline-block !important;">
  8 + <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%">
  9 + <span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span>
  10 + <span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span>
  11 + <span v-if="node.data.type === 2 && node.data.online" title="目录" class="device-online iconfont icon-jiedianleilianjipingtai"></span>
  12 + <span v-if="node.data.type === 2 && !node.data.online" title="目录" class="device-offline iconfont icon-jiedianleilianjipingtai"></span>
  13 + <span v-if="node.data.type === 3 && node.data.online " title="在线通道" class="device-online iconfont icon-shebeileijiankongdian"></span>
  14 + <span v-if="node.data.type === 3 && !node.data.online" title="在线通道" class="device-offline iconfont icon-shebeileijiankongdian"></span>
  15 + <span v-if="node.data.type === 4 && node.data.online " title="在线通道-球机" class="device-online iconfont icon-shebeileiqiuji"></span>
  16 + <span v-if="node.data.type === 4 && !node.data.online" title="在线通道-球机" class="device-offline iconfont icon-shebeileiqiuji"></span>
  17 + <span v-if="node.data.type === 5 && node.data.online " title="在线通道-半球" class="device-online iconfont icon-shebeileibanqiu"></span>
  18 + <span v-if="node.data.type === 5 && !node.data.online" title="在线通道-半球" class="device-offline iconfont icon-shebeileibanqiu"></span>
  19 + <span v-if="node.data.type === 6 && node.data.online " title="在线通道-枪机" class="device-online iconfont icon-shebeileiqiangjitongdao"></span>
  20 + <span v-if="node.data.type === 6 && !node.data.online" title="在线通道-枪机" class="device-offline iconfont icon-shebeileiqiangjitongdao"></span>
  21 + <span v-if="node.data.online" style="padding-left: 1px" class="device-online">{{ node.label }}</span>
  22 + <span v-if="!node.data.online" style="padding-left: 1px" class="device-offline">{{ node.label }}</span>
  23 + <span>
  24 + <i v-if="node.data.hasGPS && node.data.online" style="color: #9d9d9d" class="device-online iconfont icon-dizhi"></i>
  25 + <i v-if="node.data.hasGPS && !node.data.online" style="color: #9d9d9d" class="device-offline iconfont icon-dizhi"></i>
  26 + </span>
  27 + </span>
  28 + </el-tree>
  29 + </div>
  30 + </el-main>
  31 + </el-container>
  32 + </div>
  33 +</template>
  34 +
  35 +<script>
  36 +import DeviceService from "../service/DeviceService1078.js";
  37 +
  38 +export default {
  39 + name: 'DeviceTree',
  40 + data() {
  41 + return {
  42 + deviceService: new DeviceService(),
  43 + defaultProps: {
  44 + children: 'children',
  45 + label: 'name',
  46 + isLeaf: 'isLeaf'
  47 + }
  48 + };
  49 + },
  50 + props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'],
  51 + methods: {
  52 + handleNodeClick(data,node,element) {
  53 + let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
  54 + if(typeof (this.clickEvent) == "function") {
  55 + this.clickEvent(deviceNode.data.userData, data.userData, data.type === 2)
  56 + }
  57 + },
  58 + handleContextMenu(event,data,node,element) {
  59 + console.log("右键点击事件")
  60 + let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
  61 + if(typeof (this.contextMenuEvent) == "function") {
  62 + this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
  63 + }
  64 + },
  65 + loadNode: function(node, resolve){
  66 + console.log(this.device)
  67 + if (node.level === 0) {
  68 + if (this.device) {
  69 + let node = {
  70 + name: this.device.name || this.device.deviceId,
  71 + isLeaf: false,
  72 + id: this.device.deviceId,
  73 + type: this.device.online,
  74 + online: this.device.online === 1,
  75 + userData: this.device
  76 + }
  77 + resolve([node])
  78 + }else {
  79 + this.deviceService.getAllDeviceList((data)=>{
  80 + console.log(data)
  81 + if (data.length > 0) {
  82 + let nodeList = []
  83 + for (let i = 0; i < data.length; i++) {
  84 + console.log(data[i].name)
  85 + let node = {
  86 + name: data[i].name || data[i].deviceId,
  87 + isLeaf: false,
  88 + id: data[i].deviceId,
  89 + type: data[i].online,
  90 + online: data[i].online === 1,
  91 + userData: data[i]
  92 + }
  93 + nodeList.push(node);
  94 + }
  95 + resolve(nodeList)
  96 + }else {
  97 + resolve([])
  98 + }
  99 + }, (list)=>{
  100 + console.log("设备加载完成")
  101 + }, (error)=>{
  102 +
  103 + })
  104 + }
  105 + }else {
  106 + let channelArray = []
  107 +
  108 + this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{
  109 + console.log(catalogData)
  110 + channelArray = channelArray.concat(catalogData)
  111 + this.channelDataHandler(channelArray, resolve)
  112 + },(endCatalogData) => {
  113 +
  114 + })
  115 + }
  116 +
  117 + },
  118 + channelDataHandler: function (data, resolve) {
  119 + if (data.length > 0) {
  120 + let nodeList = []
  121 + for (let i = 0; i <data.length; i++) {
  122 + let item = data[i];
  123 + let type = 3;
  124 + if (item.id.length <= 10) {
  125 + type = 2;
  126 + }else {
  127 + if (item.id.length > 14) {
  128 + let channelType = item.id.substring(10, 13)
  129 + console.log("channelType: " + channelType)
  130 + if (channelType === '215' || channelType === '216') {
  131 + type = 2;
  132 + }
  133 + console.log(type)
  134 + if (item.basicData.ptzType === 1 ) { // 1-球机;2-半球;3-固定枪机;4-遥控枪机
  135 + type = 4;
  136 + }else if (item.basicData.ptzType === 2) {
  137 + type = 5;
  138 + }else if (item.basicData.ptzType === 3 || item.basicData.ptzType === 4) {
  139 + type = 6;
  140 + }
  141 + }else {
  142 + if (item.basicData.subCount > 0 || item.basicData.parental === 1) {
  143 + type = 2;
  144 + }
  145 + }
  146 + }
  147 + let node = {
  148 + name: item.name || item.basicData.channelId,
  149 + isLeaf: type !== 2,
  150 + id: item.id,
  151 + deviceId: item.deviceId,
  152 + type: type,
  153 + online: item.basicData.status === 1,
  154 + hasGPS: item.basicData.longitude*item.basicData.latitude !== 0,
  155 + userData: item.basicData
  156 + }
  157 + nodeList.push(node);
  158 + }
  159 + resolve(nodeList)
  160 + }else {
  161 + resolve([])
  162 + }
  163 + },
  164 + reset: function (){
  165 + this.$forceUpdate();
  166 + }
  167 + },
  168 + destroyed() {
  169 + // if (this.jessibuca) {
  170 + // this.jessibuca.destroy();
  171 + // }
  172 + // this.playing = false;
  173 + // this.loaded = false;
  174 + // this.performance = "";
  175 + },
  176 +}
  177 +</script>
  178 +
  179 +<style>
  180 +.device-tree-main-box{
  181 + text-align: left;
  182 +}
  183 +.device-online{
  184 + color: #252525;
  185 +}
  186 +.device-offline{
  187 + color: #727272;
  188 +}
  189 +</style>
web_src/src/components/common/h265web.vue 0 → 100644
  1 +<template>
  2 + <div ref="container" @dblclick="fullscreenSwich" style="width:100%;height:100%;background-color: #000000;margin:0 auto;">
  3 + <div class="buttons-box" id="buttonsBox">
  4 + <div class="buttons-box-left">
  5 + <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
  6 + <i v-if="playing" class="iconfont icon-pause jessibuca-btn" @click="pause"></i>
  7 + <i class="iconfont icon-stop jessibuca-btn" @click="destroy"></i>
  8 + <i v-if="isNotMute" class="iconfont icon-audio-high jessibuca-btn" @click="mute()"></i>
  9 + <i v-if="!isNotMute" class="iconfont icon-audio-mute jessibuca-btn" @click="cancelMute()"></i>
  10 + </div>
  11 + <div class="buttons-box-right">
  12 + <span class="jessibuca-btn">{{ kBps }} kb/s</span>
  13 + <!-- <i class="iconfont icon-file-record1 jessibuca-btn"></i>-->
  14 + <!-- <i class="iconfont icon-xiangqing2 jessibuca-btn" ></i>-->
  15 + <i class="iconfont icon-camera1196054easyiconnet jessibuca-btn" @click="jessibuca.screenshot('截图','png',0.5)"
  16 + style="font-size: 1rem !important"></i>
  17 + <i class="iconfont icon-shuaxin11 jessibuca-btn" @click="playBtnClick"></i>
  18 + <i v-if="!fullscreen" class="iconfont icon-weibiaoti10 jessibuca-btn" @click="fullscreenSwich"></i>
  19 + <i v-if="fullscreen" class="iconfont icon-weibiaoti11 jessibuca-btn" @click="fullscreenSwich"></i>
  20 + </div>
  21 + </div>
  22 + </div>
  23 +</template>
  24 +
  25 +<script>
  26 +let jessibucaPlayer = {};
  27 +export default {
  28 + name: 'jessibuca',
  29 + data() {
  30 + return {
  31 + playing: false,
  32 + isNotMute: false,
  33 + quieting: false,
  34 + fullscreen: false,
  35 + loaded: false, // mute
  36 + speed: 0,
  37 + performance: "", // 工作情况
  38 + kBps: 0,
  39 + btnDom: null,
  40 + videoInfo: null,
  41 + volume: 1,
  42 + rotate: 0,
  43 + vod: true, // 点播
  44 + forceNoOffscreen: false,
  45 + };
  46 + },
  47 + props: ['videoUrl', 'error', 'hasAudio', 'height'],
  48 + mounted() {
  49 + window.onerror = (msg) => {
  50 + // console.error(msg)
  51 + };
  52 + console.log(this._uid)
  53 + let paramUrl = decodeURIComponent(this.$route.params.url)
  54 + this.$nextTick(() => {
  55 + this.updatePlayerDomSize()
  56 + window.onresize = () => {
  57 + this.updatePlayerDomSize()
  58 + }
  59 + if (typeof (this.videoUrl) == "undefined") {
  60 + this.videoUrl = paramUrl;
  61 + }
  62 + this.btnDom = document.getElementById("buttonsBox");
  63 + console.log("初始化时的地址为: " + this.videoUrl)
  64 + this.play(this.videoUrl)
  65 + })
  66 + },
  67 + watch: {
  68 + videoUrl(newData, oldData) {
  69 + this.play(newData)
  70 + },
  71 + immediate: true
  72 + },
  73 + methods: {
  74 + updatePlayerDomSize() {
  75 + let dom = this.$refs.container;
  76 + let width = dom.parentNode.clientWidth
  77 + let height = (9 / 16) * width
  78 +
  79 + const clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight)
  80 + if (height > clientHeight) {
  81 + height = clientHeight
  82 + width = (16 / 9) * height
  83 + }
  84 +
  85 + dom.style.width = width + 'px';
  86 + dom.style.height = height + "px";
  87 + },
  88 + create() {
  89 + let options = {};
  90 + console.log("hasAudio " + this.hasAudio)
  91 +
  92 + jessibucaPlayer[this._uid] = new window.Jessibuca(Object.assign(
  93 + {
  94 + container: this.$refs.container,
  95 + videoBuffer: 0.2, // 最大缓冲时长,单位秒
  96 + isResize: true,
  97 + decoder: "static/js/jessibuca/decoder.js",
  98 + useMSE: false,
  99 + showBandwidth: false,
  100 + isFlv: true,
  101 + // text: "WVP-PRO",
  102 + // background: "static/images/zlm-logo.png",
  103 + loadingText: "加载中",
  104 + hasAudio: typeof (this.hasAudio) == "undefined" ? true : this.hasAudio,
  105 + debug: false,
  106 + supportDblclickFullscreen: false, // 是否支持屏幕的双击事件,触发全屏,取消全屏事件。
  107 + operateBtns: {
  108 + fullscreen: false,
  109 + screenshot: false,
  110 + play: false,
  111 + audio: false,
  112 + recorder: false,
  113 + },
  114 + record: "record",
  115 + vod: this.vod,
  116 + forceNoOffscreen: this.forceNoOffscreen,
  117 + isNotMute: this.isNotMute,
  118 + },
  119 + options
  120 + ));
  121 + let jessibuca = jessibucaPlayer[this._uid];
  122 + let _this = this;
  123 + jessibuca.on("load", function () {
  124 + console.log("on load init");
  125 + });
  126 +
  127 + jessibuca.on("log", function (msg) {
  128 + console.log("on log", msg);
  129 + });
  130 + jessibuca.on("record", function (msg) {
  131 + console.log("on record:", msg);
  132 + });
  133 + jessibuca.on("pause", function () {
  134 + _this.playing = false;
  135 + });
  136 + jessibuca.on("play", function () {
  137 + _this.playing = true;
  138 + });
  139 + jessibuca.on("fullscreen", function (msg) {
  140 + console.log("on fullscreen", msg);
  141 + _this.fullscreen = msg
  142 + });
  143 +
  144 + jessibuca.on("mute", function (msg) {
  145 + console.log("on mute", msg);
  146 + _this.isNotMute = !msg;
  147 + });
  148 + jessibuca.on("audioInfo", function (msg) {
  149 + // console.log("audioInfo", msg);
  150 + });
  151 +
  152 + jessibuca.on("videoInfo", function (msg) {
  153 + // this.videoInfo = msg;
  154 + console.log("videoInfo", msg);
  155 +
  156 + });
  157 +
  158 + jessibuca.on("bps", function (bps) {
  159 + // console.log('bps', bps);
  160 +
  161 + });
  162 + let _ts = 0;
  163 + jessibuca.on("timeUpdate", function (ts) {
  164 + // console.log('timeUpdate,old,new,timestamp', _ts, ts, ts - _ts);
  165 + _ts = ts;
  166 + });
  167 +
  168 + jessibuca.on("videoInfo", function (info) {
  169 + console.log("videoInfo", info);
  170 + });
  171 +
  172 + jessibuca.on("error", function (error) {
  173 + console.log("error", error);
  174 + });
  175 +
  176 + jessibuca.on("timeout", function () {
  177 + console.log("timeout");
  178 + });
  179 +
  180 + jessibuca.on('start', function () {
  181 + console.log('start');
  182 + })
  183 +
  184 + jessibuca.on("performance", function (performance) {
  185 + let show = "卡顿";
  186 + if (performance === 2) {
  187 + show = "非常流畅";
  188 + } else if (performance === 1) {
  189 + show = "流畅";
  190 + }
  191 + _this.performance = show;
  192 + });
  193 + jessibuca.on('buffer', function (buffer) {
  194 + // console.log('buffer', buffer);
  195 + })
  196 +
  197 + jessibuca.on('stats', function (stats) {
  198 + // console.log('stats', stats);
  199 + })
  200 +
  201 + jessibuca.on('kBps', function (kBps) {
  202 + _this.kBps = Math.round(kBps);
  203 + });
  204 +
  205 + // 显示时间戳 PTS
  206 + jessibuca.on('videoFrame', function () {
  207 +
  208 + })
  209 +
  210 + //
  211 + jessibuca.on('metadata', function () {
  212 +
  213 + });
  214 + },
  215 + playBtnClick: function (event) {
  216 + this.play(this.videoUrl)
  217 + },
  218 + play: function (url) {
  219 + console.log(url)
  220 + if (jessibucaPlayer[this._uid]) {
  221 + this.destroy();
  222 + }
  223 + this.create();
  224 + jessibucaPlayer[this._uid].on("play", () => {
  225 + this.playing = true;
  226 + this.loaded = true;
  227 + this.quieting = jessibuca.quieting;
  228 + });
  229 + if (jessibucaPlayer[this._uid].hasLoaded()) {
  230 + jessibucaPlayer[this._uid].play(url);
  231 + } else {
  232 + jessibucaPlayer[this._uid].on("load", () => {
  233 + console.log("load 播放")
  234 + jessibucaPlayer[this._uid].play(url);
  235 + });
  236 + }
  237 + },
  238 + pause: function () {
  239 + if (jessibucaPlayer[this._uid]) {
  240 + jessibucaPlayer[this._uid].pause();
  241 + }
  242 + this.playing = false;
  243 + this.err = "";
  244 + this.performance = "";
  245 + },
  246 + mute: function () {
  247 + if (jessibucaPlayer[this._uid]) {
  248 + jessibucaPlayer[this._uid].mute();
  249 + }
  250 + },
  251 + cancelMute: function () {
  252 + if (jessibucaPlayer[this._uid]) {
  253 + jessibucaPlayer[this._uid].cancelMute();
  254 + }
  255 + },
  256 + destroy: function () {
  257 + if (jessibucaPlayer[this._uid]) {
  258 + jessibucaPlayer[this._uid].destroy();
  259 + }
  260 + if (document.getElementById("buttonsBox") == null) {
  261 + this.$refs.container.appendChild(this.btnDom)
  262 + }
  263 + jessibucaPlayer[this._uid] = null;
  264 + this.playing = false;
  265 + this.err = "";
  266 + this.performance = "";
  267 +
  268 + },
  269 + eventcallbacK: function (type, message) {
  270 + // console.log("player 事件回调")
  271 + // console.log(type)
  272 + // console.log(message)
  273 + },
  274 + fullscreenSwich: function () {
  275 + let isFull = this.isFullscreen()
  276 + jessibucaPlayer[this._uid].setFullscreen(!isFull)
  277 + this.fullscreen = !isFull;
  278 + },
  279 + isFullscreen: function () {
  280 + return document.fullscreenElement ||
  281 + document.msFullscreenElement ||
  282 + document.mozFullScreenElement ||
  283 + document.webkitFullscreenElement || false;
  284 + }
  285 + },
  286 + destroyed() {
  287 + if (jessibucaPlayer[this._uid]) {
  288 + jessibucaPlayer[this._uid].destroy();
  289 + }
  290 + this.playing = false;
  291 + this.loaded = false;
  292 + this.performance = "";
  293 + },
  294 +}
  295 +</script>
  296 +
  297 +<style>
  298 +.buttons-box {
  299 + width: 100%;
  300 + height: 28px;
  301 + background-color: rgba(43, 51, 63, 0.7);
  302 + position: absolute;
  303 + display: -webkit-box;
  304 + display: -ms-flexbox;
  305 + display: flex;
  306 + left: 0;
  307 + bottom: 0;
  308 + user-select: none;
  309 + z-index: 10;
  310 +}
  311 +
  312 +.jessibuca-btn {
  313 + width: 20px;
  314 + color: rgb(255, 255, 255);
  315 + line-height: 27px;
  316 + margin: 0px 10px;
  317 + padding: 0px 2px;
  318 + cursor: pointer;
  319 + text-align: center;
  320 + font-size: 0.8rem !important;
  321 +}
  322 +
  323 +.buttons-box-right {
  324 + position: absolute;
  325 + right: 0;
  326 +}
  327 +</style>
web_src/src/components/service/DeviceService1078.js 0 → 100644
  1 +import axios from 'axios';
  2 +
  3 +class DeviceService{
  4 +
  5 + constructor() {
  6 + this.$axios = axios;
  7 + }
  8 +
  9 + getDeviceList(currentPage, count, callback, errorCallback){
  10 + this.$axios({
  11 + method: 'get',
  12 + url:`/api/jt1078/query/company/tree`,
  13 + params: {
  14 + page: currentPage,
  15 + count: count
  16 + }
  17 + }).then((res) => {
  18 + if (typeof (callback) == "function") callback(res.data)
  19 + }).catch((error) => {
  20 + console.log(error);
  21 + if (typeof (errorCallback) == "function") errorCallback(error)
  22 + });
  23 + }
  24 +
  25 + getDevice(deviceId, callback, errorCallback){
  26 + this.$axios({
  27 + method: 'get',
  28 + url:`/api/device/query/devices/${deviceId}`,
  29 + }).then((res) => {
  30 + if (typeof (callback) == "function") callback(res.data)
  31 + }).catch((error) => {
  32 + console.log(error);
  33 + if (typeof (errorCallback) == "function") errorCallback(error)
  34 + });
  35 + }
  36 +
  37 + getAllDeviceList(callback,endCallback, errorCallback) {
  38 + let currentPage = 1;
  39 + let count = 100;
  40 + let deviceList = []
  41 + this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
  42 + }
  43 +
  44 + getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback) {
  45 + this.getDeviceList(currentPage, count, (data) => {
  46 + if (data.code === 0 && data.data.list) {
  47 + if (typeof (callback) == "function") callback(data.data.list)
  48 + deviceList = deviceList.concat(data.data.list);
  49 + if (deviceList.length < data.data.total) {
  50 + currentPage ++
  51 + this.getAllDeviceListIteration(deviceList, currentPage, count, callback, endCallback, errorCallback)
  52 + }else {
  53 + if (typeof (endCallback) == "function") endCallback(deviceList)
  54 + }
  55 + }
  56 + }, errorCallback)
  57 + }
  58 +
  59 +
  60 + getAllChannel(isCatalog, catalogUnderDevice, deviceId, callback, endCallback, errorCallback) {
  61 + let currentPage = 1;
  62 + let count = 100;
  63 + let catalogList = []
  64 + this.getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback)
  65 + }
  66 +
  67 + getAllChannelIteration(isCatalog, catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
  68 + this.getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, (data) => {
  69 + if (data.list) {
  70 + if (typeof (callback) == "function") callback(data.list)
  71 + catalogList = catalogList.concat(data.list);
  72 + if (catalogList.length < data.total) {
  73 + currentPage ++
  74 + this.getAllChannelIteration(isCatalog,catalogUnderDevice, deviceId, catalogList, currentPage, count, callback, errorCallback)
  75 + }else {
  76 + console.log(1)
  77 + if (typeof (endCallback) == "function") endCallback(catalogList)
  78 + }
  79 + }
  80 + }, errorCallback)
  81 + }
  82 + getChanel(isCatalog, catalogUnderDevice, deviceId, currentPage, count, callback, errorCallback) {
  83 + this.$axios({
  84 + method: 'get',
  85 + url: `/api/device/query/devices/${deviceId}/channels`,
  86 + params:{
  87 + page: currentPage,
  88 + count: count,
  89 + query: "",
  90 + online: "",
  91 + channelType: isCatalog,
  92 + catalogUnderDevice: catalogUnderDevice
  93 + }
  94 + }).then((res) =>{
  95 + if (typeof (callback) == "function") callback(res.data)
  96 + }).catch(errorCallback);
  97 + }
  98 +
  99 +
  100 + getAllSubChannel(isCatalog, deviceId, channelId, callback, endCallback, errorCallback) {
  101 + let currentPage = 1;
  102 + let count = 100;
  103 + let catalogList = []
  104 + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
  105 + }
  106 +
  107 + getAllSubChannelIteration(isCatalog, deviceId,channelId, catalogList, currentPage, count, callback, endCallback, errorCallback) {
  108 + this.getSubChannel(isCatalog, deviceId, channelId, currentPage, count, (data) => {
  109 + if (data.list) {
  110 + if (typeof (callback) == "function") callback(data.list)
  111 + catalogList = catalogList.concat(data.list);
  112 + if (catalogList.length < data.total) {
  113 + currentPage ++
  114 + this.getAllSubChannelIteration(isCatalog, deviceId, channelId, catalogList, currentPage, count, callback, endCallback, errorCallback)
  115 + }else {
  116 + if (typeof (endCallback) == "function") endCallback(catalogList)
  117 + }
  118 + }
  119 + }, errorCallback)
  120 + }
  121 + getSubChannel(isCatalog, deviceId, channelId, currentPage, count, callback, errorCallback) {
  122 + this.$axios({
  123 + method: 'get',
  124 + url: `/api/device/query/sub_channels/${deviceId}/${channelId}/channels`,
  125 + params:{
  126 + page: currentPage,
  127 + count: count,
  128 + query: "",
  129 + online: "",
  130 + channelType: isCatalog
  131 + }
  132 + }).then((res) =>{
  133 + if (typeof (callback) == "function") callback(res.data)
  134 + }).catch(errorCallback);
  135 + }
  136 +
  137 + getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) {
  138 + let currentPage = 1;
  139 + let count = 100;
  140 + let catalogList = []
  141 + this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback)
  142 + }
  143 +
  144 + getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) {
  145 + this.getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, (data) => {
  146 + if (data.code === 0 && data.data.list) {
  147 + if (typeof (callback) == "function") callback(data.data.list)
  148 + catalogList = catalogList.concat(data.data.list);
  149 + if (catalogList.length < data.data.total) {
  150 + currentPage ++
  151 + this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback)
  152 + }else {
  153 + if (typeof (endCallback) == "function") endCallback(catalogList)
  154 + }
  155 + }
  156 + }, errorCallback)
  157 + }
  158 + getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, callback, errorCallback) {
  159 + if (onlyCatalog == null || typeof onlyCatalog === "undefined") {
  160 + onlyCatalog = false;
  161 + }
  162 + this.$axios({
  163 + method: 'get',
  164 + url: `/api/device/query/tree/${deviceId}`,
  165 + params:{
  166 + page: currentPage,
  167 + count: count,
  168 + parentId: parentId,
  169 + onlyCatalog: onlyCatalog
  170 + }
  171 + }).then((res) =>{
  172 + if (typeof (callback) == "function") callback(res.data)
  173 + }).catch(errorCallback);
  174 + }
  175 +}
  176 +
  177 +export default DeviceService;
web_src/src/layout/UiHeader.vue
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 <el-menu-item index="/console">控制台</el-menu-item> 7 <el-menu-item index="/console">控制台</el-menu-item>
8 8
9 - <el-menu-item index="/deviceList1078">1078设备</el-menu-item> 9 + <el-menu-item index="/deviceList1078">设备列表</el-menu-item>
10 10
11 <el-menu-item v-if="editUser" index="/userManager">用户管理</el-menu-item> 11 <el-menu-item v-if="editUser" index="/userManager">用户管理</el-menu-item>
12 12
web_src/static/js/config.js
1 -window.baseUrl = "http://118.113.164.50:18989"; 1 +window.baseUrl = "http://127.0.0.1:28080";
2 2
3 // map组件全局参数, 注释此内容可以关闭地图功能 3 // map组件全局参数, 注释此内容可以关闭地图功能
4 window.mapParam = { 4 window.mapParam = {
web_src/utils/waterMark.js
@@ -27,8 +27,8 @@ export default function watermark(element, config) { @@ -27,8 +27,8 @@ export default function watermark(element, config) {
27 start_y: 0, // y轴起始位置 27 start_y: 0, // y轴起始位置
28 space_x: 100, // x轴间距 28 space_x: 100, // x轴间距
29 space_y: 50, // y轴间距 29 space_y: 50, // y轴间距
30 - width: 210, // 宽度  
31 - height: 80, // 长度 30 + width: 610, // 宽度
  31 + height: 380, // 长度
32 fontSize: 20, // 字体 32 fontSize: 20, // 字体
33 color: '#aaa', // 字色 33 color: '#aaa', // 字色
34 alpha: 0.4, // 透明度 34 alpha: 0.4, // 透明度