| 
					
				 | 
			
			
				@@ -1,6 +1,8 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.lutao.cloud.oil.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.http.HttpUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.json.JSONUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.lutao.cloud.common.core.util.MessageInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.lutao.cloud.common.core.util.StringUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,6 +32,13 @@ public class VideoEquipmentInfoServiceImpl extends ServiceImpl<VideoEquipmentInf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private RestTemplate restTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String TOKEN_URL = "http://dgs-servicebusgate2.zww.yjcloud.cn/oauth/token"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String previewURLs = "http://dgs-servicebusgate2.zww.yjcloud.cn/service/api/artemis/api/video/v1/cameras/previewURLs"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String CLIENT_ID = "8a7b785f08d04d439b71bc2b415cb685"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String CLIENT_SECRET = "OA!Bq_P!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final String CONTENT_TYPE = "application/json"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public MessageInfo<List<VideoEquipmentInfoTreeVO>> queryVideoEquipmentInfoTree() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -142,55 +151,63 @@ public class VideoEquipmentInfoServiceImpl extends ServiceImpl<VideoEquipmentInf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public MessageInfo getVideoUrl(String videoCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 获取token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("获取视频地址"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String url = "http://dgs-servicebusgate2.zww.yjcloud.cn/oauth/token?client_id=8a7b785f08d04d439b71bc2b415cb685&client_secret=OA!Bq_P!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("url:" + url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> map = restTemplate.getForObject(url, Map.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("map:" + map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String token = map.get("access_token"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 请求数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String url2 = "http://dgs-servicebusgate2.zww.yjcloud.cn/service/api/artemis/api/video/v1/cameras/previewURLs?client_id=8a7b785f08d04d439b71bc2b415cb685&access_token=" + token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> parameters = new LinkedHashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        parameters.put("cameraIndexCode", videoCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        parameters.put("protocol", "wss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("url:" + url2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        MessageInfo result = restTemplate.postForObject(url2, JSONObject.toJSONString(parameters), MessageInfo.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // ws地址转化,从10段到59段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String token = getAccessToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cn.hutool.json.JSONObject newRequestBody = JSONUtil.createObj(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        newRequestBody.set("cameraIndexCode", videoCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        newRequestBody.set("protocol", "wss"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String rootBody = HttpUtil.createPost(previewURLs) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .header("client_id", CLIENT_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .header("access_token", token) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .body(newRequestBody.toString()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .execute().body(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * 	"code": "0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * 	"msg": "success", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 	"msg": "SUCCESS", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * 	"data": { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * 		"url": "wss://10.18.18.53:6014/proxy/10.18.18.53:559/openUrl/uQhfGdq" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * 	    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         * 		"url": "wss://10.210.114.45:6014/proxy/10.210.114.45:559/openUrl/r8jroqY" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         *        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        Map<String, String> data11 = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        data11.put("url", "wss://10.18.18.53:6014/proxy/10.18.18.53:559/openUrl/uQhfGdq"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //wss://10.18.18.53:6014/proxy/10.18.18.53:559/openUrl/yrtJ9EA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //data11.put("url", "ws://10.18.18.53:559/openUrl/gC42FPi"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //  wss://10.18.18.53:6014/proxy/10.18.18.53:559/openUrl/uQhfGdq 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //  => wss:/splw2.mem.cegn.cn:6014/proxy/splw2.mem.cegn.cn:559/openurl/xlgbLPy 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, String> data = (Map<String, String>) result.getData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String url = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cn.hutool.json.JSONObject data = JSONUtil.parseObj(rootBody).getJSONObject("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (data != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String wsUrl = data.get("url"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String replace; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String wsUrl = data.getStr("url"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String replace = wsUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 解决院网不能播放视频问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //replace = wsUrl.replace("10.18.18.53", "splw2.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            replace = wsUrl.replace("10.210.114.45", "splw1.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            replace = wsUrl.replace("10.210.114.46", "splw2.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            replace = wsUrl.replace("10.210.114.47", "splw3.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            replace = replace.replace("10.210.114.45", "splw1.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            replace = replace.replace("10.210.114.46", "splw2.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            replace = replace.replace("10.210.114.47", "splw3.mem.cegn.cn"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 地址转换 10.18.18.53 -> 59.255.61.78 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				              //replace = wsUrl.replace("10.18.18.53:6014", "splw2.mem.cegn.cn:6014"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            data.put("url", replace); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            result.setData(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            url = replace; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return MessageInfo.ok(new JSONObject().set("url", url)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String getAccessToken() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String body = HttpUtil.createGet(TOKEN_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .header("client_id", CLIENT_ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .header("client_secret", CLIENT_SECRET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .header("Content-Type", CONTENT_TYPE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .execute().body(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cn.hutool.json.JSONObject tokenBody = JSONUtil.parseObj(body); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return tokenBody.getStr("access_token"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |