From b8a3a680f3e6720a8329bfaae571b09659aace52 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 09 四月 2025 19:47:55 +0800
Subject: [PATCH] 开发推流拉流工具类

---
 ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/RealVideoMsgController.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/RealVideoMsgController.java b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/RealVideoMsgController.java
index 0853c4b..326dcfd 100644
--- a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/RealVideoMsgController.java
+++ b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/RealVideoMsgController.java
@@ -15,7 +15,10 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.time.LocalDateTime;
+import java.time.ZoneOffset;
 
 /**
  * 实时音视频控制器
@@ -48,13 +51,13 @@
 	 */
 	@PostMapping("/startupRealVideo")
 	public R<UPRealvideoMsgStartupAckVo> startupRealVideo(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo) {
-		R realVideo = downRealvideoMsgStartupService.startupRealVideo(inferiorPlatformId, vehicleNo);
+		R<String> realVideo = downRealvideoMsgStartupService.startupRealVideo(inferiorPlatformId, vehicleNo);
 		if (realVideo.getCode() != 200) {
-			return realVideo;
+			return R.fail(realVideo.getMsg());
 		}
 		//发送成功,定时任务获取响应结果
 		int num = 0;
-		LocalDateTime now = LocalDateTime.now();
+		long now = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8));
 		while (true) {
 			UPRealvideoMsgStartupAck realvideoMsgStartupAck = upRealvideoMsgStartupAckDao.findByInferiorPlatformIdAndVehicleNoAndCreateTimeAfter(inferiorPlatformId, vehicleNo, now);
 			if (null == realvideoMsgStartupAck) {
@@ -72,6 +75,13 @@
 					case 0:
 						UPRealvideoMsgStartupAckVo vo = new UPRealvideoMsgStartupAckVo();
 						BeanUtils.copyProperties(realvideoMsgStartupAck, vo);
+						String encode = null;
+						try {
+							encode = URLEncoder.encode(vehicleNo, "UTF-8");
+						} catch (UnsupportedEncodingException e) {
+							throw new RuntimeException(e);
+						}
+						vo.setUrl("http://" + vo.getServerIP() + ":" + vo.getServerPort() + "/" + encode + "." + vo.getVehicleColor() + ".1.0." + realVideo.getData());
 						return R.ok(vo);
 					case 1:
 						return R.fail("失败");
@@ -108,7 +118,7 @@
 		}
 		//发送成功,定时任务获取响应结果
 		int num = 0;
-		LocalDateTime now = LocalDateTime.now();
+		Long now = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8));
 		while (true) {
 			UPRealvideoMsgEndAck upRealvideoMsgEndAck = upRealvideoMsgEndAckDao.findByInferiorPlatformIdAndVehicleNoAndCreateTimeAfter(inferiorPlatformId, vehicleNo, now);
 			if (null == upRealvideoMsgEndAck) {

--
Gitblit v1.7.1