Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
1b5b099a
Commit
1b5b099a
authored
Jul 21, 2023
by
lisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改批量导出监管码
parent
8dbc7363
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
EquipmentCategoryController.java
...odule/tzs/biz/controller/EquipmentCategoryController.java
+30
-8
ImageUtils.java
...om/yeejoin/amos/boot/module/tzs/biz/utils/ImageUtils.java
+3
-3
No files found.
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/EquipmentCategoryController.java
View file @
1b5b099a
...
@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
...
@@ -20,6 +20,7 @@ import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import
com.yeejoin.amos.boot.module.tzs.api.vo.EquipExportVo
;
import
com.yeejoin.amos.boot.module.tzs.api.vo.EquipExportVo
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.EquipmentCategoryServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.ImageUtils
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.ImageUtils
;
import
com.yeejoin.amos.component.robot.BadRequest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -311,6 +312,11 @@ public class EquipmentCategoryController extends BaseController {
...
@@ -311,6 +312,11 @@ public class EquipmentCategoryController extends BaseController {
@GetMapping
(
value
=
"/exportData"
)
@GetMapping
(
value
=
"/exportData"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"设备信息导出"
,
notes
=
"设备信息导出"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"设备信息导出"
,
notes
=
"设备信息导出"
)
public
void
exportData
(
HttpServletResponse
response
,
EquipExportDto
dto
)
{
public
void
exportData
(
HttpServletResponse
response
,
EquipExportDto
dto
)
{
if
(!
ObjectUtils
.
isEmpty
(
dto
.
getUSE_PLACE
()))
{
String
address
=
dto
.
getUSE_PLACE
().
substring
(
1
,
dto
.
getUSE_PLACE
().
length
()
-
1
);
address
=
address
.
replace
(
", "
,
"/"
);
dto
.
setUSE_PLACE
(
address
);
}
List
<
EquipExportVo
>
equipExportData
=
equipmentCategoryServiceImpl
.
getEquipExportData
(
dto
);
List
<
EquipExportVo
>
equipExportData
=
equipmentCategoryServiceImpl
.
getEquipExportData
(
dto
);
ExcelUtil
.
createTemplate
(
response
,
"设备信息"
,
"设备信息"
,
equipExportData
,
EquipExportVo
.
class
,
null
,
false
);
ExcelUtil
.
createTemplate
(
response
,
"设备信息"
,
"设备信息"
,
equipExportData
,
EquipExportVo
.
class
,
null
,
false
);
}
}
...
@@ -401,16 +407,32 @@ public class EquipmentCategoryController extends BaseController {
...
@@ -401,16 +407,32 @@ public class EquipmentCategoryController extends BaseController {
ImageSizeEnums
imageSizeEnums
=
ImageSizeEnums
.
getEnumByCode
(
type
);
ImageSizeEnums
imageSizeEnums
=
ImageSizeEnums
.
getEnumByCode
(
type
);
//创建list 存放图片
//创建list 存放图片
List
<
File
>
fileList
=
new
ArrayList
<>();
List
<
File
>
fileList
=
new
ArrayList
<>();
if
(!
ObjectUtils
.
isEmpty
(
dto
.
getUSE_PLACE
()))
{
String
address
=
dto
.
getUSE_PLACE
().
substring
(
1
,
dto
.
getUSE_PLACE
().
length
()
-
1
);
address
=
address
.
replace
(
", "
,
"/"
);
dto
.
setUSE_PLACE
(
address
);
}
List
<
EquipExportVo
>
equipExportData
=
equipmentCategoryServiceImpl
.
exportImageZip
(
dto
,
pageNum
,
size
);
List
<
EquipExportVo
>
equipExportData
=
equipmentCategoryServiceImpl
.
exportImageZip
(
dto
,
pageNum
,
size
);
List
<
EquipExportVo
>
unique
=
equipExportData
.
stream
().
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getSupervisoryCode
())).
collect
(
List
<
EquipExportVo
>
unique
=
equipExportData
.
stream
().
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getSupervisoryCode
())).
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
collectingAndThen
(
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
EquipExportVo:
:
getSupervisoryCode
))),
ArrayList:
:
new
)
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
EquipExportVo:
:
getSupervisoryCode
))),
ArrayList:
:
new
)
);
);
List
<
EquipExportVo
>
collect
=
unique
.
stream
().
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getCode96333
())).
collect
(
if
(
ImageSizeEnums
.
DT
.
getCode
().
equals
(
type
)){
Collectors
.
collectingAndThen
(
unique
=
unique
.
stream
().
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getCode96333
())).
collect
(
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
EquipExportVo:
:
getCode96333
))),
ArrayList:
:
new
)
Collectors
.
collectingAndThen
(
);
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
EquipExportVo:
:
getCode96333
))),
ArrayList:
:
new
)
for
(
EquipExportVo
equipExportDatum
:
collect
)
{
);
}
if
(
ObjectUtils
.
isEmpty
(
unique
)){
File
zipFile
=
File
.
createTempFile
(
"设备码信息"
,
".zip"
);
File
nullFile
=
File
.
createTempFile
(
"当前导出数据为空+"
,
".txt"
);
fileList
.
add
(
nullFile
);
// 调用压缩方法
ImageUtils
.
zipFiles
(
fileList
,
zipFile
,
".txt"
);
ImageUtils
.
downloadResourceZip
(
"设备码信息.zip"
,
zipFile
.
getAbsolutePath
(),
response
);
zipFile
.
delete
();
}
for
(
EquipExportVo
equipExportDatum
:
unique
)
{
InputStream
bgImgFile
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"temp/"
+
imageSizeEnums
.
getBgPath
());
InputStream
bgImgFile
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"temp/"
+
imageSizeEnums
.
getBgPath
());
if
(
"DT"
.
equals
(
type
)
&&
!
ObjectUtils
.
isEmpty
(
equipExportDatum
.
getCode96333
()))
{
if
(
"DT"
.
equals
(
type
)
&&
!
ObjectUtils
.
isEmpty
(
equipExportDatum
.
getCode96333
()))
{
File
QrCodeFile
=
File
.
createTempFile
(
equipExportDatum
.
getCode96333
()
+
"+"
,
".png"
);
File
QrCodeFile
=
File
.
createTempFile
(
equipExportDatum
.
getCode96333
()
+
"+"
,
".png"
);
...
@@ -423,10 +445,10 @@ public class EquipmentCategoryController extends BaseController {
...
@@ -423,10 +445,10 @@ public class EquipmentCategoryController extends BaseController {
}
}
bgImgFile
.
close
();
bgImgFile
.
close
();
}
}
File
zipFile
=
File
.
createTempFile
(
"
imageZip
"
,
".zip"
);
File
zipFile
=
File
.
createTempFile
(
"
设备码信息
"
,
".zip"
);
// 调用压缩方法
// 调用压缩方法
ImageUtils
.
zipFiles
(
fileList
,
zipFile
);
ImageUtils
.
zipFiles
(
fileList
,
zipFile
,
".png"
);
ImageUtils
.
downloadResourceZip
(
"
imageZip
.zip"
,
zipFile
.
getAbsolutePath
(),
response
);
ImageUtils
.
downloadResourceZip
(
"
设备码信息
.zip"
,
zipFile
.
getAbsolutePath
(),
response
);
zipFile
.
delete
();
zipFile
.
delete
();
}
}
...
...
amos-boot-system-tzs/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/utils/ImageUtils.java
View file @
1b5b099a
...
@@ -169,7 +169,7 @@ public class ImageUtils {
...
@@ -169,7 +169,7 @@ public class ImageUtils {
OutputStream
out
=
null
;
OutputStream
out
=
null
;
InputStream
fileInputStream
=
null
;
InputStream
fileInputStream
=
null
;
try
{
try
{
response
.
reset
();
//
response.reset();
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setHeader
(
"content-Type"
,
"application/zip"
);
response
.
setHeader
(
"content-Type"
,
"application/zip"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
...
@@ -218,7 +218,7 @@ public class ImageUtils {
...
@@ -218,7 +218,7 @@ public class ImageUtils {
* @param srcFiles
* @param srcFiles
* @param zipFile
* @param zipFile
*/
*/
public
static
void
zipFiles
(
List
<
File
>
srcFiles
,
File
zipFile
)
{
public
static
void
zipFiles
(
List
<
File
>
srcFiles
,
File
zipFile
,
String
fileType
)
{
try
{
try
{
if
(
srcFiles
.
size
()
!=
0
)
{
if
(
srcFiles
.
size
()
!=
0
)
{
// 判断压缩后的文件存在不,不存在则创建
// 判断压缩后的文件存在不,不存在则创建
...
@@ -255,7 +255,7 @@ public class ImageUtils {
...
@@ -255,7 +255,7 @@ public class ImageUtils {
for
(
File
srcFile
:
srcFiles
)
{
for
(
File
srcFile
:
srcFiles
)
{
fileInputStream
=
new
FileInputStream
(
srcFile
);
fileInputStream
=
new
FileInputStream
(
srcFile
);
// 实例化 ZipEntry 对象,源文件数组中的当前文件
// 实例化 ZipEntry 对象,源文件数组中的当前文件
zipEntry
=
new
ZipEntry
(
StringUtils
.
substringBefore
(
srcFile
.
getName
(),
"+"
)
+
".png"
);
zipEntry
=
new
ZipEntry
(
StringUtils
.
substringBefore
(
srcFile
.
getName
(),
"+"
)
+
fileType
);
zipOutputStream
.
putNextEntry
(
zipEntry
);
zipOutputStream
.
putNextEntry
(
zipEntry
);
// 该变量记录每次真正读的字节个数
// 该变量记录每次真正读的字节个数
int
len
;
int
len
;
...
...
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