Commit a9264a8bc04335d5d49a39841b039ba5a64d7717

Authored by 648540858
1 parent d68aebd4

修复assist使用https时无法请求的bug

src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
@@ -78,11 +78,11 @@ public class AssistRESTfulUtils { @@ -78,11 +78,11 @@ public class AssistRESTfulUtils {
78 logger.warn("未启用Assist服务"); 78 logger.warn("未启用Assist服务");
79 return null; 79 return null;
80 } 80 }
81 - StringBuffer stringBuffer = new StringBuffer();  
82 - stringBuffer.append(String.format("http://%s:%s/%s", mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api)); 81 + StringBuilder stringBuffer = new StringBuilder();
  82 + stringBuffer.append(api);
83 JSONObject responseJSON = null; 83 JSONObject responseJSON = null;
84 84
85 - if (param != null && param.keySet().size() > 0) { 85 + if (param != null && !param.keySet().isEmpty()) {
86 stringBuffer.append("?"); 86 stringBuffer.append("?");
87 int index = 1; 87 int index = 1;
88 for (String key : param.keySet()){ 88 for (String key : param.keySet()){
@@ -97,6 +97,7 @@ public class AssistRESTfulUtils { @@ -97,6 +97,7 @@ public class AssistRESTfulUtils {
97 } 97 }
98 98
99 String url = stringBuffer.toString(); 99 String url = stringBuffer.toString();
  100 + logger.info("[访问assist]: {}", url);
100 Request request = new Request.Builder() 101 Request request = new Request.Builder()
101 .get() 102 .get()
102 .url(url) 103 .url(url)
@@ -262,7 +263,8 @@ public class AssistRESTfulUtils { @@ -262,7 +263,8 @@ public class AssistRESTfulUtils {
262 return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30); 263 return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30);
263 } 264 }
264 265
265 - public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId, String taskId, Boolean isEnd) { 266 + public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId,
  267 + String taskId, Boolean isEnd, String scheme) {
266 Map<String, Object> param = new HashMap<>(); 268 Map<String, Object> param = new HashMap<>();
267 if (!ObjectUtils.isEmpty(app)) { 269 if (!ObjectUtils.isEmpty(app)) {
268 param.put("app", app); 270 param.put("app", app);
@@ -279,7 +281,8 @@ public class AssistRESTfulUtils { @@ -279,7 +281,8 @@ public class AssistRESTfulUtils {
279 if (!ObjectUtils.isEmpty(isEnd)) { 281 if (!ObjectUtils.isEmpty(isEnd)) {
280 param.put("isEnd", isEnd); 282 param.put("isEnd", isEnd);
281 } 283 }
282 -  
283 - return sendGet(mediaServerItem, "api/record/file/download/task/list", param, null); 284 + String urlStr = String.format("%s://%s:%s/api/record/file/download/task/list",
  285 + scheme, mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort());;
  286 + return sendGet(mediaServerItem, urlStr, param, null);
284 } 287 }
285 } 288 }
src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java
@@ -39,7 +39,7 @@ public interface ICloudRecordService { @@ -39,7 +39,7 @@ public interface ICloudRecordService {
39 /** 39 /**
40 * 查询合并任务列表 40 * 查询合并任务列表
41 */ 41 */
42 - JSONArray queryTask(String app, String stream, String callId, String taskId, String mediaServerId, Boolean isEnd); 42 + JSONArray queryTask(String app, String stream, String callId, String taskId, String mediaServerId, Boolean isEnd, String scheme);
43 43
44 /** 44 /**
45 * 收藏视频,收藏的视频过期不会删除 45 * 收藏视频,收藏的视频过期不会删除
src/main/java/com/genersoft/iot/vmp/service/impl/CloudRecordServiceImpl.java
@@ -142,7 +142,8 @@ public class CloudRecordServiceImpl implements ICloudRecordService { @@ -142,7 +142,8 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
142 } 142 }
143 143
144 @Override 144 @Override
145 - public JSONArray queryTask(String app, String stream, String callId, String taskId, String mediaServerId, Boolean isEnd) { 145 + public JSONArray queryTask(String app, String stream, String callId, String taskId, String mediaServerId,
  146 + Boolean isEnd, String scheme) {
146 MediaServerItem mediaServerItem = null; 147 MediaServerItem mediaServerItem = null;
147 if (mediaServerId == null) { 148 if (mediaServerId == null) {
148 mediaServerItem = mediaServerService.getDefaultMediaServer(); 149 mediaServerItem = mediaServerService.getDefaultMediaServer();
@@ -152,7 +153,8 @@ public class CloudRecordServiceImpl implements ICloudRecordService { @@ -152,7 +153,8 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
152 if (mediaServerItem == null) { 153 if (mediaServerItem == null) {
153 throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体"); 154 throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体");
154 } 155 }
155 - JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd); 156 +
  157 + JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd, scheme);
156 if (result == null || result.getInteger("code") != 0) { 158 if (result == null || result.getInteger("code") != 0) {
157 throw new ControllerException(ErrorCode.ERROR100.getCode(), result == null ? "查询任务列表失败" : result.getString("msg")); 159 throw new ControllerException(ErrorCode.ERROR100.getCode(), result == null ? "查询任务列表失败" : result.getString("msg"));
158 } 160 }
src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java
@@ -174,7 +174,7 @@ public class CloudRecordController { @@ -174,7 +174,7 @@ public class CloudRecordController {
174 throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体"); 174 throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体");
175 }else { 175 }else {
176 if (remoteHost == null) { 176 if (remoteHost == null) {
177 - remoteHost = request.getScheme() + "://" + request.getLocalAddr() + ":" + mediaServerItem.getRecordAssistPort(); 177 + remoteHost = request.getScheme() + "://" + mediaServerItem.getIp() + ":" + mediaServerItem.getRecordAssistPort();
178 } 178 }
179 } 179 }
180 return cloudRecordService.addTask(app, stream, mediaServerItem, startTime, endTime, callId, remoteHost, mediaServerId != null); 180 return cloudRecordService.addTask(app, stream, mediaServerItem, startTime, endTime, callId, remoteHost, mediaServerId != null);
@@ -187,6 +187,7 @@ public class CloudRecordController { @@ -187,6 +187,7 @@ public class CloudRecordController {
187 @Parameter(name = "mediaServerId", description = "流媒体ID", required = false) 187 @Parameter(name = "mediaServerId", description = "流媒体ID", required = false)
188 @Parameter(name = "isEnd", description = "是否结束", required = false) 188 @Parameter(name = "isEnd", description = "是否结束", required = false)
189 public JSONArray queryTaskList( 189 public JSONArray queryTaskList(
  190 + HttpServletRequest request,
190 @RequestParam(required = false) String app, 191 @RequestParam(required = false) String app,
191 @RequestParam(required = false) String stream, 192 @RequestParam(required = false) String stream,
192 @RequestParam(required = false) String callId, 193 @RequestParam(required = false) String callId,
@@ -197,7 +198,8 @@ public class CloudRecordController { @@ -197,7 +198,8 @@ public class CloudRecordController {
197 if (ObjectUtils.isEmpty(mediaServerId)) { 198 if (ObjectUtils.isEmpty(mediaServerId)) {
198 mediaServerId = null; 199 mediaServerId = null;
199 } 200 }
200 - return cloudRecordService.queryTask(app, stream, callId, taskId, mediaServerId, isEnd); 201 +
  202 + return cloudRecordService.queryTask(app, stream, callId, taskId, mediaServerId, isEnd, request.getScheme());
201 } 203 }
202 204
203 @ResponseBody 205 @ResponseBody