|
@@ -7,6 +7,8 @@ import com.dahuatech.icc.oauth.http.IccTokenResponse;
|
|
import com.dahuatech.icc.oauth.profile.IccProfile;
|
|
import com.dahuatech.icc.oauth.profile.IccProfile;
|
|
import com.huimv.common.utils.StringUtilsWork;
|
|
import com.huimv.common.utils.StringUtilsWork;
|
|
import com.huimv.video.dhicc.icc.CommonConstant;
|
|
import com.huimv.video.dhicc.icc.CommonConstant;
|
|
|
|
+import com.huimv.video.dhicc.test.manager.IOauthIntegrationManager;
|
|
|
|
+import com.huimv.video.dhicc.test.response.GetTokenResponse;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.client.methods.HttpGet;
|
|
import org.apache.http.client.methods.HttpGet;
|
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
@@ -14,6 +16,7 @@ import org.apache.http.conn.ssl.SSLContextBuilder;
|
|
import org.apache.http.conn.ssl.TrustStrategy;
|
|
import org.apache.http.conn.ssl.TrustStrategy;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -28,30 +31,63 @@ import java.security.cert.CertificateException;
|
|
import java.security.cert.X509Certificate;
|
|
import java.security.cert.X509Certificate;
|
|
|
|
|
|
import static com.huimv.video.dhicc.icc.CommonConstant.IPAndPort;
|
|
import static com.huimv.video.dhicc.icc.CommonConstant.IPAndPort;
|
|
|
|
+import static com.huimv.video.dhicc.icc.CommonConstant.Sg_IPAndPort;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/picture")
|
|
@RequestMapping("/picture")
|
|
public class GetPicture {
|
|
public class GetPicture {
|
|
|
|
+ @Autowired
|
|
|
|
+ private IOauthIntegrationManager oauthIntegrationManager;
|
|
@RequestMapping("/get")
|
|
@RequestMapping("/get")
|
|
public void getCarRecord(HttpServletRequest request, HttpServletResponse response,
|
|
public void getCarRecord(HttpServletRequest request, HttpServletResponse response,
|
|
@RequestParam(name = "fileUrl", required = false) String fileUrl,
|
|
@RequestParam(name = "fileUrl", required = false) String fileUrl,
|
|
@RequestParam(name = "alarmPicture", required = false) String alarmPicture,
|
|
@RequestParam(name = "alarmPicture", required = false) String alarmPicture,
|
|
- @RequestParam(name = "path", required = false) String path
|
|
|
|
|
|
+ @RequestParam(name = "path", required = false) String path,
|
|
|
|
+ @RequestParam(name = "farmId") Integer farmId
|
|
) throws IOException, ClientException {
|
|
) throws IOException, ClientException {
|
|
- String url;
|
|
|
|
- IClient iClient = new DefaultClient();
|
|
|
|
- //如果 fileURL不为空 就认为是拿摄像头抓拍图片
|
|
|
|
- if (StringUtilsWork.isNotEmpty(fileUrl)) {
|
|
|
|
- url = IPAndPort + "/evo-apigw/" + fileUrl;
|
|
|
|
- } else if (StringUtilsWork.isNotEmpty(path)) {
|
|
|
|
- //档案的图片
|
|
|
|
- IccTokenResponse.IccToken token = iClient.getAccessToken(IccProfile.grantType);
|
|
|
|
- url = IPAndPort + "/evo-pic/" + path + "?token=" + token.getAccess_token() + "&oss_addr=" + CommonConstant.Document_oss_addr;
|
|
|
|
- } else {
|
|
|
|
- //事件的图片
|
|
|
|
- IccTokenResponse.IccToken token = iClient.getAccessToken(IccProfile.grantType);
|
|
|
|
- url = IPAndPort + "/evo-pic/" + alarmPicture + "?token=" + token.getAccess_token() + "&oss_addr=" + CommonConstant.shijian_oss_addr;
|
|
|
|
|
|
+ String url = "";
|
|
|
|
+ if (farmId == 1){
|
|
|
|
+ GetTokenResponse tokenTest01 = oauthIntegrationManager.getTokenTest01();
|
|
|
|
+ String access_token = tokenTest01.getData().getAccess_token();
|
|
|
|
+ //如果 fileURL不为空 就认为是拿摄像头抓拍图片
|
|
|
|
+ if (StringUtilsWork.isNotEmpty(fileUrl)) {
|
|
|
|
+ url = Sg_IPAndPort + "/evo-apigw/" + fileUrl;
|
|
|
|
+ } else if (StringUtilsWork.isNotEmpty(path)) {
|
|
|
|
+ //档案的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + path + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Document_Oss_Addr;
|
|
|
|
+ } else {
|
|
|
|
+ //事件的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + alarmPicture + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Shijian_Oss_Addr;
|
|
|
|
+ }
|
|
|
|
+ }else if (farmId == 22){
|
|
|
|
+ GetTokenResponse tokenTest02 = oauthIntegrationManager.getTokenTest02();
|
|
|
|
+ String access_token = tokenTest02.getData().getAccess_token();
|
|
|
|
+ //如果 fileURL不为空 就认为是拿摄像头抓拍图片
|
|
|
|
+ //目前只有曙光照片
|
|
|
|
+ if (StringUtilsWork.isNotEmpty(fileUrl)) {
|
|
|
|
+ url = Sg_IPAndPort + "/evo-apigw/" + fileUrl;
|
|
|
|
+ } else if (StringUtilsWork.isNotEmpty(path)) {
|
|
|
|
+ //档案的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + path + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Document_Oss_Addr;
|
|
|
|
+ } else {
|
|
|
|
+ //事件的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + alarmPicture + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Shijian_Oss_Addr;
|
|
|
|
+ }
|
|
|
|
+ }else if (farmId == 21){
|
|
|
|
+ GetTokenResponse tokenTest03 = oauthIntegrationManager.getTokenTest03();
|
|
|
|
+ String access_token = tokenTest03.getData().getAccess_token();
|
|
|
|
+ //如果 fileURL不为空 就认为是拿摄像头抓拍图片
|
|
|
|
+ //目前只有曙光照片
|
|
|
|
+ if (StringUtilsWork.isNotEmpty(fileUrl)) {
|
|
|
|
+ url = Sg_IPAndPort + "/evo-apigw/" + fileUrl;
|
|
|
|
+ } else if (StringUtilsWork.isNotEmpty(path)) {
|
|
|
|
+ //档案的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + path + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Document_Oss_Addr;
|
|
|
|
+ } else {
|
|
|
|
+ //事件的图片
|
|
|
|
+ url = Sg_IPAndPort + "/evo-pic/" + alarmPicture + "?token=" + access_token + "&oss_addr=" + CommonConstant.Sg_Shijian_Oss_Addr;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
HttpResponse httpResponse = null;
|
|
HttpResponse httpResponse = null;
|
|
try {
|
|
try {
|