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
0f5ed36a
Commit
0f5ed36a
authored
Oct 28, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合成图片并生成mediaId
parent
5446b449
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
ImageCombined.java
...haoban/manage/service/context/combined/ImageCombined.java
+4
-1
MaterialServiceImpl.java
...oban/manage/service/service/impl/MaterialServiceImpl.java
+1
-0
QWmediaTest.java
haoban-manage3-service/src/test/java/QWmediaTest.java
+8
-11
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/context/combined/ImageCombined.java
View file @
0f5ed36a
...
...
@@ -72,7 +72,7 @@ public class ImageCombined {
}
BufferedImage
combinedImage
=
generateImage
(
largeImage
,
qrCodeImage
,
showStyle
,
lineOne
,
lineTwo
);
ImageIO
.
write
(
combinedImage
,
"jpg"
,
new
File
(
OUTPUT_PATH
));
//
ImageIO.write(combinedImage, "jpg", new File(OUTPUT_PATH));
try
(
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
())
{
ImageIO
.
write
(
combinedImage
,
"jpg"
,
baos
);
// 返回字节数组
...
...
@@ -96,6 +96,8 @@ public class ImageCombined {
}
private
static
BufferedImage
generateImage
(
BufferedImage
image
,
BufferedImage
qrCode
,
int
showStyle
,
String
lineOne
,
String
lineTwo
)
throws
Exception
{
logger
.
info
(
"合成图片开始"
);
int
width
=
image
.
getWidth
();
int
height
=
image
.
getHeight
();
...
...
@@ -134,6 +136,7 @@ public class ImageCombined {
}
g
.
dispose
();
logger
.
info
(
"合成图片结束"
);
return
combinedImage
;
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/MaterialServiceImpl.java
View file @
0f5ed36a
...
...
@@ -359,6 +359,7 @@ public class MaterialServiceImpl implements MaterialService {
//合成图片
byte
[]
combinedImageData
=
ImageCombined
.
getCombinedImage
(
combinedQDTO
);
if
(
combinedImageData
==
null
)
{
logger
.
info
(
"合成图片的数据为空"
);
return
jsonResponse
;
}
if
(
imageUrl
.
contains
(
"?"
))
{
...
...
haoban-manage3-service/src/test/java/QWmediaTest.java
View file @
0f5ed36a
import
com.alibaba.fastjson.JSON
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO
;
import
com.gic.haoban.manage.api.qdto.combined.CombinedQDTO
;
import
com.gic.haoban.manage.service.context.combined.ImageCombined
;
import
com.gic.haoban.manage.service.service.MaterialService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.wechat.api.enums.QywxMediaTypeEnum
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -20,6 +24,8 @@ public class QWmediaTest {
private
QywxSuiteApiService
qywxSuiteApiService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
@Autowired
private
MaterialService
materialService
;
private
static
final
String
LARGE_IMAGE_URL
=
"https://jhdm-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4582434f589b494aa4f27df6e3aa3770.png?imageView2/2/w/1080/h/10800/format/jpg"
;
private
static
final
String
QR_CODE_URL
=
"https://gicinner-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4ffc77073ca1476fb264bf1be9f11383.png"
;
...
...
@@ -28,23 +34,14 @@ public class QWmediaTest {
@Test
public
void
test
()
throws
Exception
{
WxEnterpriseQwDTO
qwDTO
=
this
.
wxEnterpriseService
.
getQwInfo
(
"b18ffdc9d0644912865a248859914d80"
)
;
CombinedQDTO
combinedQDTO
=
new
CombinedQDTO
();
combinedQDTO
.
setImageUrl
(
LARGE_IMAGE_URL
);
combinedQDTO
.
setQrCodeUrl
(
QR_CODE_URL
);
combinedQDTO
.
setShowStyle
(
1
);
combinedQDTO
.
setLineOne
(
STORE_NAME
);
combinedQDTO
.
setLineTwo
(
GUIDE_NAME
);
String
[]
arr
=
null
;
byte
[]
combinedImageData
=
ImageCombined
.
getCombinedImage
(
combinedQDTO
);
// 将 BufferedImage 写入 ByteArrayOutputStream
if
(
LARGE_IMAGE_URL
.
contains
(
"?"
))
{
arr
=
LARGE_IMAGE_URL
.
split
(
"\\?"
)[
0
].
split
(
"/"
)
;
}
else
{
arr
=
LARGE_IMAGE_URL
.
split
(
"/"
);
}
// JSONResponse test = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), combinedImageData, arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(), qwDTO.isSelf(), qwDTO.getUrlHost());
// System.out.println(JSON.toJSONString(test));
JSONResponse
json
=
materialService
.
getMaterialIdByCombined
(
"b18ffdc9d0644912865a248859914d80"
,
combinedQDTO
);
System
.
out
.
println
(
JSON
.
toJSONString
(
json
));
}
...
...
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