Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
c847a7c7
Commit
c847a7c7
authored
Oct 29, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
d5d03481
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
ImageCombined.java
...haoban/manage/service/context/combined/ImageCombined.java
+11
-7
QWmediaTest.java
haoban-manage3-service/src/test/java/QWmediaTest.java
+8
-2
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/context/combined/ImageCombined.java
View file @
c847a7c7
...
@@ -15,6 +15,7 @@ import java.awt.image.BufferedImage;
...
@@ -15,6 +15,7 @@ import java.awt.image.BufferedImage;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ArrayBlockingQueue
;
...
@@ -39,7 +40,7 @@ public class ImageCombined {
...
@@ -39,7 +40,7 @@ public class ImageCombined {
40
,
40
,
60L
,
60L
,
TimeUnit
.
SECONDS
,
TimeUnit
.
SECONDS
,
new
ArrayBlockingQueue
<>(
6
0
),
new
ArrayBlockingQueue
<>(
4
0
),
new
ThreadPoolExecutor
.
AbortPolicy
()
new
ThreadPoolExecutor
.
AbortPolicy
()
);
);
...
@@ -107,12 +108,15 @@ public class ImageCombined {
...
@@ -107,12 +108,15 @@ public class ImageCombined {
private
static
BufferedImage
loadImageWithReader
(
String
url
)
{
private
static
BufferedImage
loadImageWithReader
(
String
url
)
{
try
{
try
{
URL
imageUrl
=
new
URL
(
url
);
URL
imageUrl
=
new
URL
(
url
);
ImageInputStream
input
=
ImageIO
.
createImageInputStream
(
imageUrl
.
openStream
());
try
(
InputStream
inputStream
=
imageUrl
.
openStream
();
Iterator
<
ImageReader
>
readers
=
ImageIO
.
getImageReaders
(
input
);
ImageInputStream
imageInputStream
=
ImageIO
.
createImageInputStream
(
inputStream
))
{
if
(
readers
.
hasNext
())
{
ImageReader
reader
=
readers
.
next
();
Iterator
<
ImageReader
>
readers
=
ImageIO
.
getImageReaders
(
imageInputStream
);
reader
.
setInput
(
input
,
true
);
if
(
readers
.
hasNext
())
{
return
reader
.
read
(
0
);
ImageReader
reader
=
readers
.
next
();
reader
.
setInput
(
imageInputStream
,
true
);
return
reader
.
read
(
0
);
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logger
.
error
(
"读取异常: {}"
,
url
,
e
);
logger
.
error
(
"读取异常: {}"
,
url
,
e
);
...
...
haoban-manage3-service/src/test/java/QWmediaTest.java
View file @
c847a7c7
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -78,8 +80,12 @@ public class QWmediaTest {
...
@@ -78,8 +80,12 @@ public class QWmediaTest {
try
{
try
{
semaphore
.
acquire
();
// 获取许可,控制并发请求
semaphore
.
acquire
();
// 获取许可,控制并发请求
jo
.
put
(
"imageUrl"
,
list
.
get
(
requestId
));
jo
.
put
(
"imageUrl"
,
list
.
get
(
requestId
));
String
post
=
HttpUtil
.
post
(
"https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json"
,
jo
.
toJSONString
());
HttpResponse
execute
=
HttpRequest
.
post
(
"https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json"
).
timeout
(
1000000
).
body
(
jo
.
toJSONString
()).
execute
();
System
.
out
.
println
(
post
);
String
body
=
execute
.
body
();
String
headerValue
=
execute
.
header
(
"x-request-id"
);
// String post = HttpUtil.post("https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json", jo.toJSONString());
System
.
out
.
println
(
body
);
System
.
out
.
println
(
headerValue
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"异常: "
+
e
.
getMessage
());
System
.
out
.
println
(
"异常: "
+
e
.
getMessage
());
}
finally
{
}
finally
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment