Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
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-store
Commits
db5498ea
Commit
db5498ea
authored
Mar 11, 2020
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改导购导入
parent
007ffcf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
20 deletions
+29
-20
ClerkImportController.java
...a/com/gic/store/web/controller/ClerkImportController.java
+29
-20
clerk_batch_import.xlsx
...tore-web/src/main/resources/excel/clerk_batch_import.xlsx
+0
-0
No files found.
gic-store-web/src/main/java/com/gic/store/web/controller/ClerkImportController.java
View file @
db5498ea
...
...
@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -56,28 +57,36 @@ public class ClerkImportController {
*/
@RequestMapping
(
"/clerk-import-template-download"
)
public
Object
download
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
List
<
List
<
String
>>
list
=
new
ArrayList
<>()
;
String
fileName
=
" 导购资料导入模板.xlsx"
;
List
<
String
>
list1
=
new
ArrayList
<>();
Collections
.
addAll
(
list1
,
"序号"
,
"导购名"
,
"导购关联主键"
,
"门店名"
,
"门店关联主键"
,
"职位"
,
"性别"
,
"区号"
,
"手机号"
);
List
<
String
>
list2
=
new
ArrayList
<>();
Collections
.
addAll
(
list2
,
""
,
"必填,不能超过20个字"
,
"必填,不能超过20个字,为导购的唯一识别码"
,
"必填,不能超过20个字"
,
"必填,不能超过20个字"
,
"非必填,不能超过30个字"
,
"\"男\"或\"女\""
,
"区号,如不填默认为 086"
,
"必填,不能超过20个字"
);
// 模拟数据
List
<
String
>
list3
=
new
ArrayList
<>();
Collections
.
addAll
(
list3
,
"1"
,
"张三"
,
"A011"
,
"测试门店"
,
"A001"
,
"店长"
,
"女"
,
"086"
,
"12345678912"
);
Collections
.
addAll
(
list
,
list3
);
Workbook
workbook
=
ExcelUtils
.
getWorkbook
(
"导购资料导入模板"
,
list1
,
list2
,
list
,
null
);
String
fileName
=
"导购资料导入模板.xlsx"
;
byte
[]
bytesName
=
fileName
.
getBytes
(
"UTF-8"
);
fileName
=
new
String
(
bytesName
,
"ISO-8859-1"
);
response
.
setHeader
(
"content-disposition"
,
"attachment;fileName="
+
fileName
);
OutputStream
out
=
response
.
getOutputStream
();
workbook
.
write
(
out
);
out
.
close
();
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"
));
fo
=
response
.
getOutputStream
();
// String rootPath = request.getSession().getServletContext().getRealPath("/");
// String filePath = "excel/store_tag_batch_import.xlsx";
// in = new FileInputStream(new File(rootPath + filePath));
in
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"excel/clerk_batch_import.xlsx"
);
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
();
}
}
return
RestResponse
.
success
();
}
...
...
gic-store-web/src/main/resources/excel/clerk_batch_import.xlsx
0 → 100644
View file @
db5498ea
File added
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