Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tagManager
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
lanmw
tagManager
Commits
ecee4836
Commit
ecee4836
authored
Dec 13, 2019
by
lanmw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fileImport and fileExport use dept to filter
parent
dc3f9bf6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
TagFileCtrl.java
src/main/java/com/keymobile/tagmanager/api/TagFileCtrl.java
+4
-2
TagFileService.java
...java/com/keymobile/tagmanager/service/TagFileService.java
+10
-8
No files found.
src/main/java/com/keymobile/tagmanager/api/TagFileCtrl.java
View file @
ecee4836
...
...
@@ -27,13 +27,15 @@ public class TagFileCtrl {
@GetMapping
(
"/exportTag"
)
public
int
export
(
HttpServletResponse
response
)
{
String
userName
=
UserInfoUtils
.
getUserName
();
return
tagExportService
.
exportExcel
(
userName
,
response
);
String
dept
=
userName
;
return
tagExportService
.
exportExcel
(
dept
,
response
);
}
@PostMapping
(
"/importTag"
)
public
String
importExcel
(
MultipartFile
file
,
HttpServletResponse
response
)
throws
Exception
{
String
userName
=
UserInfoUtils
.
getUserName
();
return
tagExportService
.
importExcel
(
userName
,
file
);
String
dept
=
userName
;
return
tagExportService
.
importExcel
(
userName
,
dept
,
file
);
}
...
...
src/main/java/com/keymobile/tagmanager/service/TagFileService.java
View file @
ecee4836
...
...
@@ -43,19 +43,18 @@ public class TagFileService {
@Autowired
private
TagRepository
tagRepository
;
public
int
exportExcel
(
String
userName
,
HttpServletResponse
response
)
{
List
<
Tag
>
toExportTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"creator"
).
is
(
userName
)
.
and
(
"dimensionType"
).
is
(
Constants
.
TAG_DIMENSION_TRUE
)),
Tag
.
class
);
public
int
exportExcel
(
String
dept
,
HttpServletResponse
response
)
{
List
<
Tag
>
toExportTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"dept"
).
is
(
dept
)),
Tag
.
class
);
// 导出操作
ExcelUtils
.
exportExcel
(
toExportTags
,
null
,
"sheet1"
,
Tag
.
class
,
"标签.xlsx"
,
response
);
return
toExportTags
.
size
();
}
public
String
importExcel
(
String
userName
,
MultipartFile
file
)
throws
Exception
{
public
String
importExcel
(
String
userName
,
String
dept
,
MultipartFile
file
)
throws
Exception
{
ImportLog
importLog
=
new
ImportLog
(
UUID
.
randomUUID
().
toString
());
importLog
.
setCreator
(
userName
);
mongoOperations
.
save
(
importLog
);
new
Thread
(
new
ExcelImportExecutor
(
userName
,
file
,
importLog
)).
start
();
new
Thread
(
new
ExcelImportExecutor
(
userName
,
dept
,
file
,
importLog
)).
start
();
return
"ok"
;
}
...
...
@@ -140,18 +139,20 @@ public class TagFileService {
}
class
ExcelImportExecutor
implements
Runnable
{
private
String
userName
;
private
String
dept
;
private
MultipartFile
file
;
private
ImportLog
importLog
;
public
ExcelImportExecutor
(
String
userName
,
MultipartFile
file
,
ImportLog
importLog
)
{
private
String
userName
;
public
ExcelImportExecutor
(
String
userName
,
String
dept
,
MultipartFile
file
,
ImportLog
importLog
)
{
this
.
userName
=
userName
;
this
.
dept
=
dept
;
this
.
file
=
file
;
this
.
importLog
=
importLog
;
}
@Override
public
void
run
()
{
List
<
Tag
>
dimensionTags
=
mongoOperations
.
find
(
Query
.
query
(
Criteria
.
where
(
"d
imensionType"
).
is
(
Constants
.
TAG_DIMENSION_TRUE
)),
Criteria
.
where
(
"d
ept"
).
is
(
dept
)),
Tag
.
class
);
Map
<
String
,
Tag
>
pathTags
=
dimensionTags
.
stream
().
collect
(
Collectors
.
toMap
(
Tag:
:
getPath
,
tag
->
tag
));
try
{
...
...
@@ -192,6 +193,7 @@ public class TagFileService {
t
.
setIdPath
(
parentIdPath
+
Constants
.
TAG_PATH_SEPARATOR
+
t
.
getId
());
t
.
setLevel
(
t
.
getPath
().
split
(
","
).
length
);
t
.
setCreator
(
userName
);
t
.
setDept
(
dept
);
t
.
setDimensionType
(
Constants
.
TAG_DIMENSION_TRUE
);
t
.
setCreateDate
(
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd"
));
t
.
setImportId
(
importLog
.
getId
());
...
...
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