Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
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
s_guodong
gjjs-bd-common
Commits
be6a49ce
Commit
be6a49ce
authored
Aug 18, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加从根节点获取值
parent
27862d52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
20 deletions
+69
-20
SnapshotServiceImpl.java
...lliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
+69
-20
No files found.
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
View file @
be6a49ce
...
...
@@ -6,6 +6,8 @@ import com.brilliance.mda.runtime.mda.snapshot.bo.unpack.*;
import
com.brilliance.mda.runtime.mda.util.MdaUtils
;
import
com.brilliance.mda.runtime.mda.util.XmlUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
...
...
@@ -21,6 +23,8 @@ import java.util.*;
*/
@Service
public
class
SnapshotServiceImpl
implements
SnapshotService
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
SnapshotServiceImpl
.
class
);
protected
static
final
String
DISPLAY_TEMPLATE_PATH
=
"displayTemplate/"
;
private
static
final
Set
<
String
>
keySet
=
new
HashSet
<>();
...
...
@@ -116,13 +120,19 @@ public class SnapshotServiceImpl implements SnapshotService {
}
for
(
LabelBo
labelBo
:
labelList
)
{
PackLabelBo
data
=
new
PackLabelBo
();
CustomAttributes
customAttributes
=
labelBo
.
getCustomAttributes
();
String
value
=
customAttributes
.
getLabelId
();
PackLabelBo
data
=
new
PackLabelBo
();
// /bctp/LT000070/
String
[]
split
=
value
.
substring
(
1
,
value
.
length
()
-
1
).
split
(
"/"
);
String
i18NString
=
MdaUtils
.
getI18NString
(
split
[
0
],
split
[
1
]);
data
.
setValue
(
i18NString
);
if
(
StringUtils
.
isBlank
(
value
))
{
value
=
customAttributes
.
getFieldUrl
();
keySet
.
add
(
value
);
data
.
setValue
(
"${"
+
value
+
"}"
);
}
else
{
// /bctp/LT000070/
String
[]
split
=
value
.
substring
(
1
,
value
.
length
()
-
1
).
split
(
"/"
);
String
i18NString
=
MdaUtils
.
getI18NString
(
split
[
0
],
split
[
1
]);
data
.
setValue
(
i18NString
);
}
data
.
setStyle
(
labelBo
.
getStyle
());
labelBoList
.
add
(
data
);
}
...
...
@@ -198,26 +208,65 @@ public class SnapshotServiceImpl implements SnapshotService {
@Override
public
Map
<
String
,
Object
>
getValueMap
(
Set
<
String
>
keySet
,
IModule
parent
)
{
Map
<
String
,
Object
>
valueMap
=
new
HashMap
();
IModule
root
=
getRoot
(
parent
);
for
(
String
key
:
keySet
)
{
String
[]
split
=
key
.
split
(
"\\\\"
);
Class
aClass
=
parent
.
getClass
();
Object
value
=
""
;
Object
obj
=
parent
;
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
String
s
=
split
[
i
];
try
{
Method
getMethod
=
aClass
.
getDeclaredMethod
(
"get"
+
s
.
substring
(
0
,
1
).
toUpperCase
()
+
s
.
substring
(
1
));
value
=
getMethod
.
invoke
(
obj
);
aClass
=
value
.
getClass
();
obj
=
value
;
}
catch
(
Exception
e
)
{
}
if
(
key
.
startsWith
(
"\\"
))
{
// 从根节点获取值
getValueFromModule
(
valueMap
,
root
,
key
);
}
else
{
getValueFromModule
(
valueMap
,
parent
,
key
);
}
valueMap
.
put
(
key
,
value
==
null
?
""
:
value
);
}
return
valueMap
;
}
/**
* 获取根节点
*
* @param module
* @return
*/
private
IModule
getRoot
(
IModule
module
)
{
IModule
parent
=
module
.
getParent
();
if
(
parent
==
null
)
{
return
module
;
}
return
getRoot
(
parent
);
}
/**
* 从模型中取值
*
* @param valueMap
* @param parent
* @param key
*/
private
void
getValueFromModule
(
Map
<
String
,
Object
>
valueMap
,
IModule
parent
,
String
key
)
{
String
originKey
=
key
;
if
(
key
.
startsWith
(
"\\"
))
{
key
=
key
.
substring
(
1
);
}
String
[]
split
=
key
.
split
(
"\\\\"
);
Class
aClass
=
parent
.
getClass
();
Object
value
=
""
;
Object
obj
=
parent
;
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
String
s
=
split
[
i
];
try
{
Method
getMethod
=
aClass
.
getDeclaredMethod
(
"get"
+
s
.
substring
(
0
,
1
).
toUpperCase
()
+
s
.
substring
(
1
));
value
=
getMethod
.
invoke
(
obj
);
if
(
value
==
null
)
{
break
;
}
aClass
=
value
.
getClass
();
obj
=
value
;
}
catch
(
Exception
e
)
{
log
.
error
(
"获取模板中的值{}错误:"
,
originKey
,
e
);
}
}
valueMap
.
put
(
originKey
,
value
==
null
?
""
:
value
);
}
}
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