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
0e2c90bd
Commit
0e2c90bd
authored
Jan 16, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改标签元数据导入接口
parent
f23569f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
71 deletions
+50
-71
TagFileService.java
...java/com/keymobile/tagmanager/service/TagFileService.java
+50
-71
No files found.
src/main/java/com/keymobile/tagmanager/service/TagFileService.java
View file @
0e2c90bd
...
...
@@ -61,8 +61,8 @@ public class TagFileService {
importLog
.
setCreator
(
userName
);
importLog
.
setDept
(
dept
);
mongoOperations
.
save
(
importLog
);
new
Thread
(
new
TagMetadataImportExecutor
(
userName
,
userId
,
dept
,
idPath
,
dimensionType
,
tagType
,
file
,
importLog
)
).
start
()
;
this
.
TagMetadataImportExecutor
(
userName
,
userId
,
dept
,
idPath
,
dimensionType
,
tagType
,
file
,
importLog
);
return
"ok"
;
}
...
...
@@ -215,78 +215,57 @@ public class TagFileService {
/**
*author:zhangkb time:2020-1-14 desc:标签管理导入
*/
class
TagMetadataImportExecutor
implements
Runnable
{
private
String
dept
;
private
MultipartFile
file
;
private
ImportLog
importLog
;
private
String
userName
;
private
String
userId
;
private
String
idPath
;
private
String
dimensionType
;
private
String
tagType
;
public
TagMetadataImportExecutor
(
String
userName
,
String
userId
,
String
dept
,
String
idPath
,
String
dimensionType
,
String
tagType
,
MultipartFile
file
,
ImportLog
importLog
)
{
this
.
userName
=
userName
;
this
.
userId
=
userId
;
this
.
dept
=
dept
;
this
.
file
=
file
;
this
.
importLog
=
importLog
;
this
.
idPath
=
idPath
;
this
.
dimensionType
=
dimensionType
;
this
.
tagType
=
tagType
;
}
@Override
public
void
run
()
{
try
{
boolean
hasOtherFail
=
false
;
ImportParams
params
=
new
ImportParams
();
params
.
setTitleRows
(
0
);
params
.
setHeadRows
(
1
);
params
.
setNeedVerify
(
true
);
params
.
setVerifyHandler
(
new
TagMetadataVerifyHandler
());
ExcelImportResult
<
TagMetadata
>
excelImportResult
=
ExcelImportUtil
.
importExcelMore
(
file
.
getInputStream
(),
TagMetadata
.
class
,
params
);
List
<
String
>
successIds
=
new
ArrayList
<>();
List
<
TagMetadata
>
tagMetadatas
=
excelImportResult
.
getList
();
for
(
TagMetadata
tagMetadata
:
tagMetadatas
)
{
//判断元数据名称是否在repo存在
String
claz
=
null
;
if
(
"TABLE"
.
equals
(
tagMetadata
.
getMetaModel
().
toUpperCase
()))
{
claz
=
"Catalog,Database,Schema,Table"
;
}
if
(
"HANAVIEW"
.
equals
(
tagMetadata
.
getMetaModel
().
toUpperCase
()))
{
claz
=
"Catalog,Database,Schema,HanaView"
;
}
Map
<
String
,
Object
>
meta
=
repoService
.
getMetaByNamePathAndClass
(
claz
,
tagMetadata
.
getMetaName
());
if
(
meta
.
isEmpty
())
{
importLog
.
appendErrorMsg
(
String
.
format
(
"第%s行, 元数据名为[%s]的元数据不存在"
,
tagMetadata
.
getRowNum
(),
tagMetadata
.
getMetaName
()));
hasOtherFail
=
true
;
}
else
{
successIds
.
add
(
meta
.
get
(
"_id"
).
toString
());
}
public
void
TagMetadataImportExecutor
(
String
userName
,
String
userId
,
String
dept
,
String
idPath
,
String
dimensionType
,
String
tagType
,
MultipartFile
file
,
ImportLog
importLog
){
try
{
boolean
hasOtherFail
=
false
;
ImportParams
params
=
new
ImportParams
();
params
.
setTitleRows
(
0
);
params
.
setHeadRows
(
1
);
params
.
setNeedVerify
(
true
);
params
.
setVerifyHandler
(
new
TagMetadataVerifyHandler
());
ExcelImportResult
<
TagMetadata
>
excelImportResult
=
ExcelImportUtil
.
importExcelMore
(
file
.
getInputStream
(),
TagMetadata
.
class
,
params
);
List
<
String
>
successIds
=
new
ArrayList
<>();
List
<
TagMetadata
>
tagMetadatas
=
excelImportResult
.
getList
();
for
(
TagMetadata
tagMetadata
:
tagMetadatas
)
{
//判断元数据名称是否在repo存在
String
claz
=
null
;
if
(
"TABLE"
.
equals
(
tagMetadata
.
getMetaModel
().
toUpperCase
()))
{
claz
=
"Catalog,Database,Schema,Table"
;
}
if
(!
successIds
.
isEmpty
())
{
//调用repo接口批量打元数据标签
repoService
.
addTag
(
dimensionType
,
idPath
,
successIds
,
tagType
);
if
(
"HANAVIEW"
.
equals
(
tagMetadata
.
getMetaModel
().
toUpperCase
()))
{
claz
=
"Catalog,Database,Schema,HanaView"
;
}
excelImportResult
.
getFailList
().
forEach
(
tag
->
{
importLog
.
appendErrorMsg
(
String
.
format
(
"第%s行, %s"
,
tag
.
getRowNum
()
+
params
.
getTitleRows
()
+
params
.
getReadRows
(),
tag
.
getErrorMsg
()
));
});
importLog
.
setHasFailNum
(!
excelImportResult
.
getFailList
().
isEmpty
()
||
hasOtherFail
);
importLog
.
setTotalNum
(
excelImportResult
.
getList
().
size
()
+
excelImportResult
.
getFailList
().
size
(
));
importLog
.
setSuccessIds
(
successIds
)
;
}
catch
(
Exception
e
)
{
importLog
.
appendErrorMsg
(
e
.
getCause
().
getMessage
());
}
finally
{
importLog
.
setReport
(
importLog
.
generateReport
());
importLog
.
setEndTime
(
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
importLog
.
setHasFinish
(
true
);
mongoOperations
.
save
(
importLog
);
Map
<
String
,
Object
>
meta
=
repoService
.
getMetaByNamePathAndClass
(
claz
,
tagMetadata
.
getMetaName
(
));
if
(
meta
.
isEmpty
())
{
importLog
.
appendErrorMsg
(
String
.
format
(
"第%s行, 元数据名为[%s]的元数据不存在"
,
tagMetadata
.
getRowNum
(),
tagMetadata
.
getMetaName
()
));
hasOtherFail
=
true
;
}
else
{
successIds
.
add
(
meta
.
get
(
"_id"
).
toString
());
}
}
if
(!
successIds
.
isEmpty
())
{
//调用repo接口批量打元数据标签
repoService
.
addTag
(
dimensionType
,
idPath
,
successIds
,
tagType
);
}
excelImportResult
.
getFailList
().
forEach
(
tag
->
{
importLog
.
appendErrorMsg
(
String
.
format
(
"第%s行, %s"
,
tag
.
getRowNum
()
+
params
.
getTitleRows
()
+
params
.
getReadRows
(),
tag
.
getErrorMsg
()));
});
importLog
.
setHasFailNum
(!
excelImportResult
.
getFailList
().
isEmpty
()
||
hasOtherFail
);
importLog
.
setTotalNum
(
excelImportResult
.
getList
().
size
()
+
excelImportResult
.
getFailList
().
size
());
importLog
.
setSuccessIds
(
successIds
);
}
catch
(
Exception
e
)
{
importLog
.
appendErrorMsg
(
e
.
getCause
().
getMessage
());
}
finally
{
importLog
.
setReport
(
importLog
.
generateReport
());
importLog
.
setEndTime
(
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
importLog
.
setHasFinish
(
true
);
mongoOperations
.
save
(
importLog
);
}
}
class
TagMetadataVerifyHandler
implements
IExcelVerifyHandler
<
TagMetadata
>{
...
...
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