|
@@ -3,7 +3,11 @@ package com.jkcredit.info.query.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.jkcredit.common.model.CommonResponseObject;
|
|
import com.jkcredit.common.model.CommonResponseObject;
|
|
import com.jkcredit.info.query.service.InformationQueryService;
|
|
import com.jkcredit.info.query.service.InformationQueryService;
|
|
|
|
+import com.jkcredit.info.query.util.SSLSocketClient;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
|
+import okhttp3.Request;
|
|
|
|
+import okhttp3.Response;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
|
@@ -16,8 +20,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -55,11 +62,19 @@ public class InfoQueryController {
|
|
urlStringBuffer.append("&gmsfhm=").append(gmsfhm);
|
|
urlStringBuffer.append("&gmsfhm=").append(gmsfhm);
|
|
String imageUrl = urlStringBuffer.toString();
|
|
String imageUrl = urlStringBuffer.toString();
|
|
log.info("getImage.imageUrl:{}", imageUrl);
|
|
log.info("getImage.imageUrl:{}", imageUrl);
|
|
|
|
+
|
|
|
|
+ InputStream imageStream = informationQueryService.getImageStream(imageUrl);
|
|
|
|
+ if (imageStream == null) {
|
|
|
|
+ log.info("imageStream == null");
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
- return ImageIO.read(new URL(imageUrl));
|
|
|
|
|
|
+ return ImageIO.read(imageStream);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("getImage.url:{},Exception:{}", urlStringBuffer.toString(), e);
|
|
log.error("getImage.url:{},Exception:{}", urlStringBuffer.toString(), e);
|
|
}
|
|
}
|
|
|
|
+ log.info("imageStream != null");
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -73,8 +88,13 @@ public class InfoQueryController {
|
|
urlStringBuffer.append("&jgmc=").append(jgmc);
|
|
urlStringBuffer.append("&jgmc=").append(jgmc);
|
|
String imageUrl = urlStringBuffer.toString();
|
|
String imageUrl = urlStringBuffer.toString();
|
|
log.info("getCrjImage.imageUrl:{}", imageUrl);
|
|
log.info("getCrjImage.imageUrl:{}", imageUrl);
|
|
|
|
+
|
|
|
|
+ InputStream imageStream = informationQueryService.getImageStream(imageUrl);
|
|
|
|
+ if (imageStream == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
- return ImageIO.read(new URL(imageUrl));
|
|
|
|
|
|
+ return ImageIO.read(imageStream);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("getImage.url:{},Exception:{}", urlStringBuffer.toString(), e);
|
|
log.error("getImage.url:{},Exception:{}", urlStringBuffer.toString(), e);
|
|
}
|
|
}
|