|
|
@ -1,29 +1,17 @@ |
|
|
|
package com.yxt.supervise.monitor.biz.scheduled; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.supervise.monitor.biz.callpolice.YCallPoliceService; |
|
|
|
import com.yxt.supervise.monitor.biz.messageInfo.YMessageInfoService; |
|
|
|
import com.yxt.supervise.monitor.biz.task.YTaskService; |
|
|
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
|
|
|
import org.apache.http.ssl.SSLContextBuilder; |
|
|
|
import org.apache.http.ssl.TrustStrategy; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.security.KeyManagementException; |
|
|
|
import java.security.KeyStoreException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.security.cert.CertificateException; |
|
|
|
import java.security.cert.X509Certificate; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
@ -38,9 +26,13 @@ public class SyncService { |
|
|
|
@Autowired |
|
|
|
YTaskService yTaskService; |
|
|
|
|
|
|
|
@Value("${haiKangConsumer.clientId}") |
|
|
|
private String clientId; |
|
|
|
|
|
|
|
@Value("${haiKangConsumer.clientSecret}") |
|
|
|
private String clientSecret; |
|
|
|
|
|
|
|
public static String haiKangToken = ""; |
|
|
|
// public static final String imagePath = "/root/supervise/images/";
|
|
|
|
// public static final String imagePath = "D:\\resources\\download\\";
|
|
|
|
public static String haiKangMessageConsumer = ""; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
@ -48,8 +40,8 @@ public class SyncService { |
|
|
|
// 先登录
|
|
|
|
String loginUrl = "https://api2.hik-cloud.com/oauth/token"; |
|
|
|
Map<String, Object> tokenParam = new HashMap<>(); |
|
|
|
tokenParam.put("client_id", "e8e655dfcb154be6962f270fe375edc1"); // 客户端ID String
|
|
|
|
tokenParam.put("client_secret", "3ca20239398c4b86b27c6a080d8345e1"); //访问密钥 String
|
|
|
|
tokenParam.put("client_id", clientId); // 客户端ID String
|
|
|
|
tokenParam.put("client_secret", clientSecret); //访问密钥 String
|
|
|
|
tokenParam.put("grant_type", "client_credentials"); //认证模式 String 目前仅支持client_credentials
|
|
|
|
String tokenResult = HttpUtils.sendPostMap(loginUrl, tokenParam, ""); |
|
|
|
JSONObject tokenObject = JSONObject.parseObject(tokenResult); |
|
|
@ -67,10 +59,10 @@ public class SyncService { |
|
|
|
System.out.println("Get MessageConsumer Success"); |
|
|
|
log.info("Get MessageConsumer Success"); |
|
|
|
} else { |
|
|
|
System.out.println("Get MessageConsumer Error"); |
|
|
|
log.error("Get MessageConsumer Error"); |
|
|
|
String message = consumerObject.get("message").toString(); |
|
|
|
System.out.println(message); |
|
|
|
log.error(message); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,6 +85,4 @@ public class SyncService { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|