Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Z
zlmy-cloud
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
zlmy
zlmy-cloud
Commits
c95f6655
Commit
c95f6655
authored
Aug 05, 2025
by
鲁鸿波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐患台账导出报错解决
parent
3bf4d356
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
4 deletions
+80
-4
TSafeHazardExportVO.java
.../com/testor/module/safe/model/vo/TSafeHazardExportVO.java
+2
-1
TSafeHazardOrgServiceImpl.java
...r/module/safe/service/impl/TSafeHazardOrgServiceImpl.java
+78
-3
No files found.
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/safe/model/vo/TSafeHazardExportVO.java
View file @
c95f6655
...
@@ -71,7 +71,8 @@ public class TSafeHazardExportVO {
...
@@ -71,7 +71,8 @@ public class TSafeHazardExportVO {
@ExcelProperty
(
value
=
"检查日期"
,
index
=
14
,
converter
=
LocalDateTimeConverter
.
class
)
@ExcelProperty
(
value
=
"检查日期"
,
index
=
14
,
converter
=
LocalDateTimeConverter
.
class
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createDate
;
//private Date createDate;
private
LocalDateTime
createDate
;
@ExcelProperty
(
value
=
"整改措施"
,
index
=
15
)
@ExcelProperty
(
value
=
"整改措施"
,
index
=
15
)
private
String
rectificationReform
;
private
String
rectificationReform
;
...
...
zlmy-modules/zlmy-boot/src/main/java/com/testor/module/safe/service/impl/TSafeHazardOrgServiceImpl.java
View file @
c95f6655
...
@@ -3,7 +3,13 @@ package com.testor.module.safe.service.impl;
...
@@ -3,7 +3,13 @@ package com.testor.module.safe.service.impl;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.converters.Converter
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.GlobalConfiguration
;
import
com.alibaba.excel.metadata.property.ExcelContentProperty
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.excel.write.metadata.fill.FillConfig
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
@@ -93,7 +99,9 @@ import java.net.HttpURLConnection;
...
@@ -93,7 +99,9 @@ import java.net.HttpURLConnection;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.time.format.DateTimeParseException
;
import
java.util.*
;
import
java.util.*
;
...
@@ -729,7 +737,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
...
@@ -729,7 +737,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
@Autowired
@Autowired
private
ProcessInstanceController
processInstanceController
;
private
ProcessInstanceController
processInstanceController
;
@SneakyThrows
/*
@SneakyThrows
@Override
@Override
public Boolean exportEntity(TSafeHazardOrgParam param, HttpServletResponse response) {
public Boolean exportEntity(TSafeHazardOrgParam param, HttpServletResponse response) {
try {
try {
...
@@ -769,6 +777,72 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
...
@@ -769,6 +777,72 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
WriteSheet dealerSheet = EasyExcel.writerSheet(0, "隐患台账")
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).head(TSafeHazardExportVO.class).build();
ExcelWriter build = EasyExcelFactory.write(response.getOutputStream()).build();
build.write(tSafeHazardExportVOS,dealerSheet);
build.finish();
*//*InputStream templatePathName = this.getClass().getClassLoader().getResourceAsStream("excel/tzdc.xlsx");
ByteArrayOutputStream out = new ByteArrayOutputStream();
ExcelWriter excelWriter = EasyExcel.write(out).withTemplate(templatePathName).registerConverter(new LocalDateTimeConverter()).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
excelWriter.fill(tSafeHazardExportVOS, fillConfig, writeSheet);
excelWriter.finish();
byte[] bytes = out.toByteArray();
out.flush();
out.close();
OutputStream outputStream = response.getOutputStream();
outputStream.write(bytes);
outputStream.flush();
outputStream.close();*//*
} catch (Exception e) {
e.printStackTrace();
}
return true;
}*/
@SneakyThrows
@Override
public
Boolean
exportEntity
(
TSafeHazardOrgParam
param
,
HttpServletResponse
response
)
{
try
{
String
orgId
=
param
.
getOrgId
();
if
(
StringUtils
.
isBlank
(
orgId
))
{
orgId
=
ContextUtils
.
getLoginUser
().
getOrgId
();
}
List
<
String
>
orgIds
=
new
ArrayList
<>();
String
finalOrgId
=
orgId
;
if
(
param
.
getCondOrgIdList
()
!=
null
&&
param
.
getCondOrgIdList
().
size
()
>
0
)
{
orgIds
=
param
.
getCondOrgIdList
();
}
else
{
if
(
param
.
isThisOrg
())
{
orgIds
.
add
(
orgId
);
}
else
{
orgIds
=
sysOrgService
.
list
(
new
QueryWrapper
<
SysOrg
>().
like
(
SysOrg
.
PARENT_IDS
,
finalOrgId
).
ne
(
SysOrg
.
STATUS
,
BizConstants
.
STATUS_DELETE
).
eq
(
SysOrg
.
IS_DEPT
,
0
).
orderByAsc
(
"tree_sort"
))
.
stream
().
map
(
SysOrg:
:
getOrgId
).
collect
(
Collectors
.
toList
());
if
(
orgIds
==
null
||
orgIds
.
size
()
==
0
)
{
//存入当前机构
orgIds
.
add
(
finalOrgId
);
}
}
}
param
.
setCondOrgIdList
(
orgIds
);
List
<
TSafeHazardExportVO
>
tSafeHazardExportVOS
=
exportBuild
(
param
);
logger
.
info
(
"**************************************写入模板*****************************"
);
// response.setContentType("application/vnd.ms-excel");
// response.setCharacterEncoding("utf-8");
// String fileName = URLEncoder.encode("隐患台账", "utf-8");
// response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
// response.addHeader("Pargam", "no-cache");
// response.addHeader("Cache-Control", "no-cache");
String
fileName
=
"隐患台账"
;
response
.
setContentType
(
"application/vnd.ms-excel;charset=utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
)
+
".xlsx"
);
WriteSheet
dealerSheet
=
EasyExcel
.
writerSheet
(
0
,
"隐患台账"
)
WriteSheet
dealerSheet
=
EasyExcel
.
writerSheet
(
0
,
"隐患台账"
)
.
registerWriteHandler
(
new
LongestMatchColumnWidthStyleStrategy
()).
head
(
TSafeHazardExportVO
.
class
).
build
();
.
registerWriteHandler
(
new
LongestMatchColumnWidthStyleStrategy
()).
head
(
TSafeHazardExportVO
.
class
).
build
();
...
@@ -776,7 +850,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
...
@@ -776,7 +850,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
build
.
write
(
tSafeHazardExportVOS
,
dealerSheet
);
build
.
write
(
tSafeHazardExportVOS
,
dealerSheet
);
build
.
finish
();
build
.
finish
();
/*
InputStream templatePathName = this.getClass().getClassLoader().getResourceAsStream("excel/tzdc.xlsx");
InputStream
templatePathName
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"excel/tzdc.xlsx"
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
).
withTemplate
(
templatePathName
).
registerConverter
(
new
LocalDateTimeConverter
()).
build
();
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
).
withTemplate
(
templatePathName
).
registerConverter
(
new
LocalDateTimeConverter
()).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
().
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
().
build
();
...
@@ -789,7 +863,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
...
@@ -789,7 +863,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
OutputStream
outputStream
=
response
.
getOutputStream
();
OutputStream
outputStream
=
response
.
getOutputStream
();
outputStream
.
write
(
bytes
);
outputStream
.
write
(
bytes
);
outputStream
.
flush
();
outputStream
.
flush
();
outputStream.close();
*/
outputStream
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -815,6 +889,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
...
@@ -815,6 +889,7 @@ public class TSafeHazardOrgServiceImpl extends SuperServiceImpl<TSafeHazardOrgDa
if
(
StringUtils
.
isBlank
(
nature
)){
if
(
StringUtils
.
isBlank
(
nature
)){
nature
=
String
.
valueOf
(
byId
.
getTreeLevel
());
nature
=
String
.
valueOf
(
byId
.
getTreeLevel
());
}
}
/*if ( byId.getTreeLevel().toString().equals("2")){
/*if ( byId.getTreeLevel().toString().equals("2")){
tSafeHazardExportVO.setRegionalUnits(byId.getOrgName());
tSafeHazardExportVO.setRegionalUnits(byId.getOrgName());
}else if (byId.getTreeLevel().toString().equals("3")){
}else if (byId.getTreeLevel().toString().equals("3")){
...
...
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