Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
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
base_platform_enterprise
gic-platform-enterprise
Commits
47b22720
Commit
47b22720
authored
May 09, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微盟批量导入同步门店模板
parent
8fdef92b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
28 deletions
+24
-28
WmStoreSyncController.java
...c/enterprise/web/controller/wm/WmStoreSyncController.java
+24
-28
No files found.
gic-platform-enterprise-web/src/main/java/com/gic/enterprise/web/controller/wm/WmStoreSyncController.java
View file @
47b22720
package
com
.
gic
.
enterprise
.
web
.
controller
.
wm
;
import
java.io.*
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -32,34 +36,26 @@ public class WmStoreSyncController {
@RequestMapping
(
"wm-store-import-template"
)
public
void
wmStoreImportTemplate
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
String
fileName
=
" 门店同步模板.xls"
;
OutputStream
fo
=
null
;
InputStream
in
=
null
;
try
{
response
.
setContentType
(
"text/html;charset=gbk"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
new
String
(
fileName
.
getBytes
(
"gbk"
),
"ISO-8859-1"
));
ClassPathResource
res
=
new
ClassPathResource
(
"exceltemplate/wm_store_import_template.xls"
);
String
userAgent
=
request
.
getHeader
(
"User-Agent"
).
toLowerCase
();
String
fileName
=
"门店同步模板.xls"
;
if
(
userAgent
.
contains
(
"firefox"
))
{
byte
[]
bytesName
=
fileName
.
getBytes
(
"UTF-8"
);
fileName
=
new
String
(
bytesName
,
"ISO-8859-1"
);
response
.
setHeader
(
"content-disposition"
,
"attachment;fileName="
+
fileName
);
}
else
{
response
.
setHeader
(
"content-disposition"
,
"attachment;fileName="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
}
fo
=
response
.
getOutputStream
();
String
filePath
=
ClassLoader
.
getSystemResource
(
"exceltemplate/wm_store_import_template.xls"
).
getPath
();
LOGGER
.
info
(
"门店同步模板路径:{}"
,
filePath
);
in
=
new
FileInputStream
(
new
File
(
filePath
));
byte
[]
b
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
in
.
read
(
b
))
!=
-
1
)
{
fo
.
write
(
b
,
0
,
len
);
}
fo
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
fo
!=
null
)
{
fo
.
close
();
}
if
(
in
!=
null
)
{
in
.
close
();
}
InputStream
is
=
res
.
getInputStream
();
OutputStream
out
=
response
.
getOutputStream
();
int
bytes
=
0
;
byte
[]
bufferOut
=
new
byte
[
1024
];
while
((
bytes
=
is
.
read
(
bufferOut
))
!=
-
1
)
{
out
.
write
(
bufferOut
,
0
,
bytes
);
}
out
.
close
();
is
.
close
();
}
}
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