Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
huaxin-rq
Project
Project
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
耿迪迪
huaxin-rq
Commits
9c68523f
Commit
9c68523f
authored
Jul 04, 2026
by
耿迪迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
安检单导出问题修改
parent
e22b53ae
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
17 deletions
+42
-17
business_new.docx
...-admin/src/main/resources/excelTemplate/business_new.docx
+0
-0
quarter_new.docx
...n-admin/src/main/resources/excelTemplate/quarter_new.docx
+0
-0
resident_new.xlsx
...-admin/src/main/resources/excelTemplate/resident_new.xlsx
+0
-0
InspectExportUtil.java
...n/java/com/zehong/common/utils/poi/InspectExportUtil.java
+36
-12
TTaskInspectExportServiceImpl.java
...ng/system/service/impl/TTaskInspectExportServiceImpl.java
+5
-5
TTaskInspectExportMapper.xml
...main/resources/mapper/system/TTaskInspectExportMapper.xml
+1
-0
No files found.
huaxin-admin/src/main/resources/excelTemplate/business_new.docx
View file @
9c68523f
No preview for this file type
huaxin-admin/src/main/resources/excelTemplate/quarter_new.docx
View file @
9c68523f
No preview for this file type
huaxin-admin/src/main/resources/excelTemplate/resident_new.xlsx
View file @
9c68523f
No preview for this file type
huaxin-common/src/main/java/com/zehong/common/utils/poi/InspectExportUtil.java
View file @
9c68523f
...
@@ -5,11 +5,13 @@ import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
...
@@ -5,11 +5,13 @@ import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
import
cn.hutool.core.img.ImgUtil
;
import
cn.hutool.core.img.ImgUtil
;
import
com.zehong.common.config.ProjectNameConfig
;
import
com.zehong.common.config.ProjectNameConfig
;
import
com.zehong.common.exception.CustomException
;
import
com.zehong.common.exception.CustomException
;
import
com.zehong.common.utils.StringUtils
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.AffineTransformOp
;
import
java.awt.image.AffineTransformOp
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
...
@@ -81,7 +83,8 @@ public class InspectExportUtil {
...
@@ -81,7 +83,8 @@ public class InspectExportUtil {
InputStream
source
=
this
.
getClass
().
getResourceAsStream
(
"/excelTemplate/"
+
template
);
InputStream
source
=
this
.
getClass
().
getResourceAsStream
(
"/excelTemplate/"
+
template
);
MyXWPFDocument
doc
=
new
MyXWPFDocument
(
source
);
MyXWPFDocument
doc
=
new
MyXWPFDocument
(
source
);
WordExportUtil
.
exportWord07
(
doc
,
map
);
WordExportUtil
.
exportWord07
(
doc
,
map
);
String
filename
=
(
String
)
map
.
get
(
"company"
)
+
map
.
get
(
"createTime"
)
+
"安检单.docx"
;
String
company
=
(
String
)
map
.
get
(
"company"
);
String
filename
=
(
StringUtils
.
isNotEmpty
(
company
)
?
company
:
(
String
)
map
.
get
(
"username"
))
+
map
.
get
(
"createTime"
)
+
"安检单.docx"
;
FileOutputStream
out
=
new
FileOutputStream
(
getExportAbsoluteFile
(
filename
));
FileOutputStream
out
=
new
FileOutputStream
(
getExportAbsoluteFile
(
filename
));
doc
.
write
(
out
);
doc
.
write
(
out
);
out
.
flush
();
out
.
flush
();
...
@@ -182,26 +185,47 @@ public class InspectExportUtil {
...
@@ -182,26 +185,47 @@ public class InspectExportUtil {
// 得到图片的中心点
// 得到图片的中心点
int
width
=
image
.
getWidth
();
int
width
=
image
.
getWidth
();
int
height
=
image
.
getHeight
();
int
height
=
image
.
getHeight
();
double
sin
=
Math
.
abs
(
Math
.
sin
(
Math
.
toRadians
(
angle
))),
double
rads
=
Math
.
toRadians
(
angle
);
cos
=
Math
.
abs
(
Math
.
cos
(
Math
.
toRadians
(
angle
)));
double
sin
=
Math
.
abs
(
Math
.
sin
(
rads
));
double
cos
=
Math
.
abs
(
Math
.
cos
(
rads
));
int
newWidth
=
(
int
)
Math
.
floor
(
width
*
cos
+
height
*
sin
),
int
newWidth
=
(
int
)
Math
.
floor
(
width
*
cos
+
height
*
sin
),
newHeight
=
(
int
)
Math
.
floor
(
height
*
cos
+
width
*
sin
);
newHeight
=
(
int
)
Math
.
floor
(
height
*
cos
+
width
*
sin
);
int
imageType
=
image
.
getType
();
int
imageType
=
image
.
getType
();
if
(
0
==
imageType
){
if
(
0
==
imageType
){
imageType
=
BufferedImage
.
TYPE_INT_ARGB
;
imageType
=
BufferedImage
.
TYPE_INT_ARGB
;
}
}
// 创建一个新的图片用于保存旋转后的图片
if
(
width
<=
0
||
height
<=
0
)
{
BufferedImage
rotatedImage
=
new
BufferedImage
(
newWidth
,
newHeight
,
imageType
);
throw
new
IOException
(
"图片尺寸异常: "
+
width
+
"x"
+
height
);
}
if
(
newWidth
<
1
)
newWidth
=
1
;
if
(
newHeight
<
1
)
newHeight
=
1
;
// ==========================================
// 使用 Graphics2D 旋转(100% 稳定,不依赖浮点数精度)
// ==========================================
BufferedImage
rotated
=
new
BufferedImage
(
newWidth
,
newHeight
,
imageType
);
Graphics2D
g
=
rotated
.
createGraphics
();
// 设置旋转的中心点
// 高质量渲染
g
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g
.
setRenderingHint
(
RenderingHints
.
KEY_INTERPOLATION
,
RenderingHints
.
VALUE_INTERPOLATION_BICUBIC
);
g
.
setRenderingHint
(
RenderingHints
.
KEY_RENDERING
,
RenderingHints
.
VALUE_RENDER_QUALITY
);
// 设置变换
AffineTransform
at
=
new
AffineTransform
();
AffineTransform
at
=
new
AffineTransform
();
at
.
translate
((
newWidth
-
width
)
/
2
,
(
newHeight
-
height
)
/
2
);
at
.
translate
((
newWidth
-
width
)
/
2.0
,
(
newHeight
-
height
)
/
2.0
);
at
.
rotate
(
Math
.
toRadians
(
angle
),
width
/
2
,
height
/
2
);
at
.
rotate
(
rads
,
width
/
2.0
,
height
/
2.0
);
g
.
drawImage
(
image
,
at
,
null
);
g
.
dispose
();
// 转标准 RGB(避免后续 POI 插入 Excel 时出问题)
BufferedImage
standard
=
new
BufferedImage
(
newWidth
,
newHeight
,
imageType
);
Graphics2D
g2
=
standard
.
createGraphics
();
g2
.
drawImage
(
rotated
,
0
,
0
,
null
);
g2
.
dispose
();
// 执行旋转
return
standard
;
AffineTransformOp
op
=
new
AffineTransformOp
(
at
,
AffineTransformOp
.
TYPE_BICUBIC
);
rotatedImage
=
op
.
filter
(
image
,
rotatedImage
);
return
rotatedImage
;
}
}
/**
/**
...
...
huaxin-system/src/main/java/com/zehong/system/service/impl/TTaskInspectExportServiceImpl.java
View file @
9c68523f
...
@@ -194,7 +194,9 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
...
@@ -194,7 +194,9 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
String
dangerNumber
=
contentJson
.
getString
(
"dangerNumber"
);
String
dangerNumber
=
contentJson
.
getString
(
"dangerNumber"
);
map
.
put
(
"dangerNumber"
,
"0"
.
equals
(
dangerNumber
)
?
true
:
false
);
map
.
put
(
"dangerNumber"
,
"0"
.
equals
(
dangerNumber
)
?
true
:
false
);
//map.put("zgDay",contentJson.getString("zgDay"));
//map.put("zgDay",contentJson.getString("zgDay"));
map
.
put
(
"qmUrl"
,
contentJson
.
getString
(
"qmUrl"
));
if
(
StringUtils
.
isNotEmpty
(
contentJson
.
getString
(
"qmUrl"
))){
map
.
put
(
"qmUrl"
,
contentJson
.
getString
(
"qmUrl"
));
}
JSONObject
userInfo
=
contentJson
.
getJSONObject
(
"userInfo"
);
JSONObject
userInfo
=
contentJson
.
getJSONObject
(
"userInfo"
);
if
(
null
!=
userInfo
){
if
(
null
!=
userInfo
){
for
(
String
userKey
:
userInfo
.
keySet
()){
for
(
String
userKey
:
userInfo
.
keySet
()){
...
@@ -281,14 +283,13 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
...
@@ -281,14 +283,13 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
//user中获取
//user中获取
TBusiness
businessInfo
=
tBusinessMapper
.
selectTBusinessById
(
businessInspectList
.
get
(
finalIndex
).
getReceiveId
());
TBusiness
businessInfo
=
tBusinessMapper
.
selectTBusinessById
(
businessInspectList
.
get
(
finalIndex
).
getReceiveId
());
if
(
null
!=
businessInfo
){
if
(
null
!=
businessInfo
){
map
.
put
(
"
company"
,
businessInfo
.
getCompany
());
map
.
put
(
"
username"
,
businessInfo
.
getUsername
());
map
.
put
(
"address"
,
businessInfo
.
getAddress
());
map
.
put
(
"address"
,
businessInfo
.
getAddress
());
map
.
put
(
"usernum"
,
businessInfo
.
getUsernum
());
map
.
put
(
"usernum"
,
businessInfo
.
getUsernum
());
map
.
put
(
"phone"
,
businessInfo
.
getPhone
());
map
.
put
(
"phone"
,
businessInfo
.
getPhone
());
}
}
//安检单中取
//安检单中取
map
.
put
(
"qitawentiText"
,
obj
.
getJSONObject
(
"qitawenti"
).
getString
(
"textarea"
));
map
.
put
(
"yijian"
,
contentJson
.
getString
(
"yijian"
));
map
.
put
(
"yijian"
,
contentJson
.
getString
(
"yijian"
));
map
.
put
(
"inspector"
,
businessInspectList
.
get
(
finalIndex
).
getMemberName
());
map
.
put
(
"inspector"
,
businessInspectList
.
get
(
finalIndex
).
getMemberName
());
map
.
put
(
"currentDate"
,
new
SimpleDateFormat
(
"yyyy年MM月dd日"
).
format
(
businessInspectList
.
get
(
finalIndex
).
getCreateTime
()));
map
.
put
(
"currentDate"
,
new
SimpleDateFormat
(
"yyyy年MM月dd日"
).
format
(
businessInspectList
.
get
(
finalIndex
).
getCreateTime
()));
...
@@ -302,7 +303,7 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
...
@@ -302,7 +303,7 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
exportLog
.
setMemberId
(
businessInspectList
.
get
(
finalIndex
).
getMemberId
());
exportLog
.
setMemberId
(
businessInspectList
.
get
(
finalIndex
).
getMemberId
());
exportLog
.
setType
(
businessInspectList
.
get
(
finalIndex
).
getType
());
exportLog
.
setType
(
businessInspectList
.
get
(
finalIndex
).
getType
());
exportLog
.
setCreateTime
(
new
Date
());
exportLog
.
setCreateTime
(
new
Date
());
exportLog
.
setFileName
((
String
)
map
.
get
(
"
company
"
)
+
map
.
get
(
"createTime"
)
+
"安检单.docx"
);
exportLog
.
setFileName
((
String
)
map
.
get
(
"
username
"
)
+
map
.
get
(
"createTime"
)
+
"安检单.docx"
);
map
.
put
(
"exportLog"
,
exportLog
);
map
.
put
(
"exportLog"
,
exportLog
);
mapList
.
add
(
map
);
mapList
.
add
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -382,7 +383,6 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
...
@@ -382,7 +383,6 @@ public class TTaskInspectExportServiceImpl implements ITTaskInspectExportService
}
}
//安检单中取
//安检单中取
map
.
put
(
"qitawentiText"
,
obj
.
getJSONObject
(
"qitawenti"
).
getString
(
"textarea"
));
map
.
put
(
"yijian"
,
contentJson
.
getString
(
"yijian"
));
map
.
put
(
"yijian"
,
contentJson
.
getString
(
"yijian"
));
map
.
put
(
"inspector"
,
industryQuarterInspectList
.
get
(
finalIndex
).
getMemberName
());
map
.
put
(
"inspector"
,
industryQuarterInspectList
.
get
(
finalIndex
).
getMemberName
());
map
.
put
(
"currentDate"
,
new
SimpleDateFormat
(
"yyyy年MM月dd日"
).
format
(
industryQuarterInspectList
.
get
(
finalIndex
).
getCreateTime
()));
map
.
put
(
"currentDate"
,
new
SimpleDateFormat
(
"yyyy年MM月dd日"
).
format
(
industryQuarterInspectList
.
get
(
finalIndex
).
getCreateTime
()));
...
...
huaxin-system/src/main/resources/mapper/system/TTaskInspectExportMapper.xml
View file @
9c68523f
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
</if>
</if>
LEFT JOIN sys_user su ON su.user_id = ex.member_id
LEFT JOIN sys_user su ON su.user_id = ex.member_id
<where>
<where>
ex.file_name NOT LIKE 'null%';
<if
test=
"taskId != null "
>
and ex.task_id = #{taskId}
</if>
<if
test=
"taskId != null "
>
and ex.task_id = #{taskId}
</if>
<if
test=
"inspectId != null "
>
and ex.inspect_id = #{inspectId}
</if>
<if
test=
"inspectId != null "
>
and ex.inspect_id = #{inspectId}
</if>
<if
test=
"memberId != null "
>
and ex.member_id = #{memberId}
</if>
<if
test=
"memberId != null "
>
and ex.member_id = #{memberId}
</if>
...
...
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