Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f942a2f2
authored
Dec 28, 2021
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
工单相关-下载工单图片
1 parent
607ce2c9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
src/main/java/cn/com/glsx/admin/modules/controller/WorkOrderController.java
src/main/java/cn/com/glsx/admin/modules/service/WorkOrderService.java
src/main/java/cn/com/glsx/admin/modules/controller/WorkOrderController.java
View file @
f942a2f
...
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -57,6 +58,14 @@ public class WorkOrderController {
...
@@ -57,6 +58,14 @@ public class WorkOrderController {
@ApiOperation
(
value
=
"工单照片导出"
)
@ApiOperation
(
value
=
"工单照片导出"
)
@GetMapping
(
value
=
"/batchExportPics"
)
@GetMapping
(
value
=
"/batchExportPics"
)
public
void
batchExportPics
(
HttpServletResponse
response
,
WorkOrderSearch
search
)
throws
IOException
{
public
void
batchExportPics
(
HttpServletResponse
response
,
WorkOrderSearch
search
)
throws
IOException
{
String
filename
=
new
String
(
DateUtils
.
formatSerial
(
new
Date
()).
getBytes
(
StandardCharsets
.
UTF_8
),
StandardCharsets
.
ISO_8859_1
)
+
".zip"
;
response
.
reset
();
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
filename
);
response
.
setContentType
(
"application/octet-stream; charset=utf-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
if
(
CollectionUtils
.
isEmpty
(
search
.
getOrderIds
()))
{
if
(
CollectionUtils
.
isEmpty
(
search
.
getOrderIds
()))
{
throw
new
AdminException
(
"参数为空"
);
throw
new
AdminException
(
"参数为空"
);
}
}
...
...
src/main/java/cn/com/glsx/admin/modules/service/WorkOrderService.java
View file @
f942a2f
...
@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
...
@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -106,11 +107,18 @@ public class WorkOrderService {
...
@@ -106,11 +107,18 @@ public class WorkOrderService {
List
<
WorkOrderDocs
>
woDocs
=
docsMap
.
get
(
wv
.
getWorkOrderId
());
List
<
WorkOrderDocs
>
woDocs
=
docsMap
.
get
(
wv
.
getWorkOrderId
());
String
vinPath
=
wv
.
getVin
()
+
File
.
separator
;
ZipEntry
vinDir
=
new
ZipEntry
(
vinPath
);
if
(
CollectionUtils
.
isNotEmpty
(
woDocs
))
{
if
(
CollectionUtils
.
isNotEmpty
(
woDocs
))
{
zos
.
putNextEntry
(
vinDir
);
for
(
WorkOrderDocs
doc
:
woDocs
)
{
for
(
WorkOrderDocs
doc
:
woDocs
)
{
byte
[]
bytes
=
HttpUtils
.
downloadBytes
(
doc
.
getPath
());
byte
[]
bytes
=
HttpUtils
.
downloadBytes
(
doc
.
getPath
());
zos
.
putNextEntry
(
new
ZipEntry
(
doc
.
getName
()));
zos
.
putNextEntry
(
new
ZipEntry
(
vinPath
+
doc
.
getName
()));
zos
.
write
(
bytes
,
0
,
bytes
.
length
);
zos
.
write
(
bytes
,
0
,
bytes
.
length
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment