|
|
@@ -7,6 +7,7 @@ import com.zhiqiyun.open.core.video.VideoDockingService;
|
|
|
import com.zhiqiyun.open.exception.ServiceException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.http.HttpHost;
|
|
|
import org.apache.http.client.config.CookieSpecs;
|
|
|
import org.apache.http.client.config.RequestConfig;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
@@ -16,6 +17,7 @@ import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.BoundValueOperations;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
@@ -38,9 +40,11 @@ import static com.zhiqiyun.open.camera.config.CameraConfig.*;
|
|
|
@Service
|
|
|
public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
|
|
|
- //public final static String URI = "https://222.84.250.39:9800";
|
|
|
-// public final static String URI = "https://172.169.12.21:18531";
|
|
|
- public final static String URI = "https://10.37.113.208:18531";
|
|
|
+ // public final static String URI = "https://172.169.12.21:18531";
|
|
|
+// public final static String URI = "https://10.37.113.208:18531";
|
|
|
+// public final static String URI = "http://59.211.51.102:18531";
|
|
|
+// public final static String URI = "http://10.35.5.111:18531";
|
|
|
+ public final static String URI = "https://10.35.5.111:8090/ly";
|
|
|
|
|
|
public final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN:%s";
|
|
|
|
|
|
@@ -50,14 +54,20 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
@Resource
|
|
|
private ThreadPoolTaskExecutor taskExecutor;
|
|
|
|
|
|
+ @Value("${proxy.host}")
|
|
|
+ private String proxyHost;
|
|
|
+
|
|
|
+ @Value("${proxy.port}")
|
|
|
+ private int proxyPort;
|
|
|
+
|
|
|
@Override
|
|
|
public String getValidToken() throws Exception {
|
|
|
- String name = SecureUtil.md5(URI + "_" + USER_NAME_Urban);
|
|
|
+ String name = SecureUtil.md5(URI + "_" + USER_NAME_URBAN);
|
|
|
BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(String.format(VIDEO_JSESSIONID_TOKEN, name));
|
|
|
String token = boundValueOperations.get();
|
|
|
if (StringUtils.isBlank(token) || !token.contains("JSESSIONID")) {
|
|
|
Map<String, Object> paramValues = new HashMap<>(2);
|
|
|
- paramValues.put("userName", USER_NAME_Urban);
|
|
|
+ paramValues.put("userName", USER_NAME_URBAN);
|
|
|
paramValues.put("password", PASSWORD);
|
|
|
|
|
|
CloseableHttpResponse response = httpPost("/loginInfo/login/v1.0", paramValues, null);
|
|
|
@@ -79,7 +89,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
|
|
|
@Override
|
|
|
public void refreshValidToken() throws Exception {
|
|
|
- BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(String.format(VIDEO_JSESSIONID_TOKEN, USER_NAME_Urban));
|
|
|
+ BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(String.format(VIDEO_JSESSIONID_TOKEN, USER_NAME_URBAN));
|
|
|
String cookie = boundValueOperations.get();
|
|
|
if (StringUtils.isBlank(cookie)) {
|
|
|
return;
|
|
|
@@ -197,7 +207,8 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
* @param paramValues paramValues
|
|
|
* @return String
|
|
|
*/
|
|
|
- private static CloseableHttpResponse httpPost(String uri, Map<String, Object> paramValues, String cookie) throws IOException {
|
|
|
+ private CloseableHttpResponse httpPost(String uri, Map<String, Object> paramValues, String cookie) throws IOException {
|
|
|
+
|
|
|
// 1. 创建HttpClient
|
|
|
CloseableHttpClient httpClient = createSSLClientDefault();
|
|
|
String url = String.format("%s" + uri, URI);
|
|
|
@@ -207,6 +218,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
.setConnectTimeout(10000)
|
|
|
//数据读取超时时间5秒
|
|
|
.setSocketTimeout(5000)
|
|
|
+// .setProxy(new HttpHost(proxyHost, proxyPort))
|
|
|
.setCookieSpec(CookieSpecs.STANDARD).build();
|
|
|
|
|
|
// 2. 创建POST请求
|
|
|
@@ -237,7 +249,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
* @param paramValues paramValues
|
|
|
* @return String
|
|
|
*/
|
|
|
- private static CloseableHttpResponse httpGet(String uri, Map<String, String> paramValues, String cookie) throws IOException {
|
|
|
+ private CloseableHttpResponse httpGet(String uri, Map<String, String> paramValues, String cookie) throws IOException {
|
|
|
// 1. 创建HttpClient
|
|
|
CloseableHttpClient httpClient = createSSLClientDefault();
|
|
|
String url = String.format("%s" + uri, URI);
|
|
|
@@ -249,6 +261,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
.setConnectTimeout(10000)
|
|
|
//数据读取超时时间5秒
|
|
|
.setSocketTimeout(5000)
|
|
|
+ .setProxy(new HttpHost(proxyHost, proxyPort))
|
|
|
.setCookieSpec(CookieSpecs.STANDARD).build();
|
|
|
HttpGet httpGet = new HttpGet(url);
|
|
|
httpGet.setHeader("Content-Type", "application/json;charset=UTF-8");
|
|
|
@@ -279,7 +292,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
* @param paramValues paramValues
|
|
|
* @return String
|
|
|
*/
|
|
|
- public static CloseableHttpResponse httpDelete(String uri, Map<String, String> paramValues, String cookie) throws IOException {
|
|
|
+ public CloseableHttpResponse httpDelete(String uri, Map<String, String> paramValues, String cookie) throws IOException {
|
|
|
// 1. 创建HttpClient
|
|
|
CloseableHttpClient httpClient = createSSLClientDefault();
|
|
|
String url = String.format("%s" + uri, URI);
|
|
|
@@ -290,6 +303,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
.setConnectTimeout(10000)
|
|
|
//数据读取超时时间5秒
|
|
|
.setSocketTimeout(5000)
|
|
|
+ .setProxy(new HttpHost(proxyHost, proxyPort))
|
|
|
.setCookieSpec(CookieSpecs.STANDARD).build();
|
|
|
|
|
|
// 2. 创建POST请求
|