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