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
b4221c36
Commit
b4221c36
authored
Aug 22, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快照中列表的渲染
parent
6887dadd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
58 deletions
+139
-58
Test.java
gjjs-bd-business/src/test/java/com/brilliance/test/Test.java
+0
-8
MdaContext.java
...ava/com/brilliance/mda/runtime/mda/driver/MdaContext.java
+1
-1
SnapshotService.java
.../brilliance/mda/runtime/mda/snapshot/SnapshotService.java
+4
-2
SnapshotServiceImpl.java
...lliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
+131
-45
PackListboxBo.java
...iance/mda/runtime/mda/snapshot/bo/pack/PackListboxBo.java
+2
-1
DateUtils.java
...n/java/com/brilliance/mda/runtime/mda/util/DateUtils.java
+1
-1
No files found.
gjjs-bd-business/src/test/java/com/brilliance/test/Test.java
View file @
b4221c36
package
com
.
brilliance
.
test
;
import
com.brilliance.mda.runtime.mda.snapshot.SnapshotServiceImpl
;
import
java.util.HashSet
;
public
class
Test
{
...
...
@@ -16,11 +14,5 @@ public class Test {
System
.
out
.
println
(
set
);
}
@org
.
junit
.
jupiter
.
api
.
Test
public
void
getTemplateContent
()
{
SnapshotServiceImpl
snapshotServiceImpl
=
new
SnapshotServiceImpl
();
String
templateContent
=
snapshotServiceImpl
.
getTemplateContent
(
"litp.nlitp"
);
System
.
out
.
println
(
templateContent
);
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/MdaContext.java
View file @
b4221c36
...
...
@@ -259,7 +259,7 @@ public class MdaContext implements IContext {
IModule
parent
=
panel
.
getParent
();
String
panelPath
=
panel
.
getPath
();
// 获取模板内容
String
templateContent
=
snapshotService
.
getTemplateContent
(
panelPath
);
String
templateContent
=
snapshotService
.
getTemplateContent
(
panelPath
,
parent
);
// 获取填充值的key
Set
<
ValueVo
>
keySet
=
snapshotService
.
getKeySet
();
// 获取填充的值
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/snapshot/SnapshotService.java
View file @
b4221c36
...
...
@@ -18,9 +18,10 @@ public interface SnapshotService {
* 获取模板内容
*
* @param panelPath
* @param parent
* @return
*/
String
getTemplateContent
(
String
panelPath
);
String
getTemplateContent
(
String
panelPath
,
IModule
parent
);
/**
* 获取快照模板中所需的值
...
...
@@ -43,9 +44,10 @@ public interface SnapshotService {
* 组装成xml需要的实体
*
* @param documentBo
* @param parent
* @return
*/
PackDocumentBo
packTemplate
(
DocumentBo
documentBo
);
PackDocumentBo
packTemplate
(
DocumentBo
documentBo
,
IModule
parent
);
/**
* 获取需要填充值的实体
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
View file @
b4221c36
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
snapshot
;
import
com.brilliance.mda.runtime.mda.IModule
;
import
com.brilliance.mda.runtime.mda.impl.ModuleList
;
import
com.brilliance.mda.runtime.mda.snapshot.bo.ValueVo
;
import
com.brilliance.mda.runtime.mda.snapshot.bo.pack.*
;
import
com.brilliance.mda.runtime.mda.snapshot.bo.unpack.*
;
import
com.brilliance.mda.runtime.mda.util.DateUtil
;
import
com.brilliance.mda.runtime.mda.util.DateUtil
s
;
import
com.brilliance.mda.runtime.mda.util.MdaUtils
;
import
com.brilliance.mda.runtime.mda.util.XmlUtil
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -32,11 +33,11 @@ public class SnapshotServiceImpl implements SnapshotService {
private
static
final
Set
<
ValueVo
>
keySet
=
new
HashSet
<>();
@Override
public
String
getTemplateContent
(
String
panelPath
)
{
public
String
getTemplateContent
(
String
panelPath
,
IModule
parent
)
{
// 解析标准模板
DocumentBo
documentBo
=
this
.
unpackTemplate
(
panelPath
);
// 获取组装xml的实体
PackDocumentBo
packDocumentBo
=
this
.
packTemplate
(
documentBo
);
PackDocumentBo
packDocumentBo
=
this
.
packTemplate
(
documentBo
,
parent
);
String
s
=
XmlUtil
.
marshToXmlBinding
(
PackDocumentBo
.
class
,
packDocumentBo
);
String
replace
=
s
.
replace
(
"<window>"
,
"<window xmlns=\"http://www.zkoss.org/2005/zul\" xmlns:w=\"http://www.zkoss.org/2005/zk/client\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" height=\"100%\" width=\"100%\" xsi:schemaLocation=\"http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd\">"
);
return
replace
;
...
...
@@ -63,7 +64,7 @@ public class SnapshotServiceImpl implements SnapshotService {
@Override
public
PackDocumentBo
packTemplate
(
DocumentBo
documentBo
)
{
public
PackDocumentBo
packTemplate
(
DocumentBo
documentBo
,
IModule
parent
)
{
keySet
.
clear
();
List
<
TextboxBo
>
textboxList
;
...
...
@@ -114,7 +115,7 @@ public class SnapshotServiceImpl implements SnapshotService {
packDivBo
.
setCheckboxBoList
(
handleCheckboxList
(
checkboxList
));
// listboxList
packDivBo
.
setListboxBoList
(
handleListboxList
(
listboxList
));
packDivBo
.
setListboxBoList
(
handleListboxList
(
listboxList
,
parent
));
// 组成xml需要的实体
PackBorderlayoutBo
packBorderlayoutBo
=
new
PackBorderlayoutBo
();
...
...
@@ -193,26 +194,11 @@ public class SnapshotServiceImpl implements SnapshotService {
aClass
=
value
.
getClass
();
obj
=
value
;
}
catch
(
Exception
e
)
{
log
.
error
(
"获取模板中的值{}错误:"
,
originKey
,
e
);
}
}
if
(
value
!=
null
)
{
String
format
=
valueVo
.
getFormat
();
String
codeTable
=
valueVo
.
getCodeTable
();
// 从码表中转换
if
(
StringUtils
.
isNotBlank
(
codeTable
))
{
value
=
MdaUtils
.
getCodetableLabel
(
codeTable
,
(
String
)
value
);
}
// 时间格式化
if
(
StringUtils
.
isNotBlank
(
format
)
&&
value
instanceof
Date
)
{
value
=
DateUtil
.
format
((
Date
)
value
,
format
.
replaceAll
(
"/"
,
"-"
));
}
// boolean 类型转换为String
if
(
value
instanceof
Boolean
)
{
value
=
String
.
valueOf
(
value
);
log
.
warn
(
"获取模板中的值{}为空"
,
originKey
);
}
}
// 格式转换
value
=
formatValue
(
value
,
valueVo
);
valueMap
.
put
(
originKey
,
value
==
null
?
""
:
value
);
}
...
...
@@ -260,11 +246,13 @@ public class SnapshotServiceImpl implements SnapshotService {
for
(
TextboxBo
textboxBo
:
textboxList
)
{
List
<
CustomAttributes
>
customAttributes
=
textboxBo
.
getCustomAttributes
();
String
text
=
getAttributeValue
(
customAttributes
).
getFieldUrl
();
PackTextboxBo
data
=
new
PackTextboxBo
();
if
(
StringUtils
.
isNotBlank
(
text
))
{
keySet
.
add
(
new
ValueVo
(
text
));
data
.
setText
(
"${"
+
text
+
"}"
);
}
else
{
data
.
setText
(
""
);
}
PackTextboxBo
data
=
new
PackTextboxBo
();
data
.
setText
(
"${"
+
text
+
"}"
);
data
.
setStyle
(
textboxBo
.
getStyle
());
data
.
setCols
(
textboxBo
.
getCols
());
data
.
setRows
(
textboxBo
.
getRows
()
==
null
?
"1"
:
textboxBo
.
getRows
());
...
...
@@ -323,12 +311,13 @@ public class SnapshotServiceImpl implements SnapshotService {
CustomAttributes
attributeValue
=
getAttributeValue
(
customAttributes
);
String
text
=
attributeValue
.
getFieldUrl
();
PackComboboxBo
data
=
new
PackComboboxBo
();
if
(
StringUtils
.
isNotBlank
(
text
))
{
keySet
.
add
(
new
ValueVo
(
text
,
null
,
attributeValue
.
getCodeTable
()));
data
.
setText
(
"${"
+
text
+
"}"
);
}
else
{
data
.
setText
(
""
);
}
PackComboboxBo
data
=
new
PackComboboxBo
();
data
.
setText
(
"${"
+
text
+
"}"
);
data
.
setStyle
(
textboxBo
.
getStyle
());
comboboxBoList
.
add
(
data
);
}
...
...
@@ -350,11 +339,13 @@ public class SnapshotServiceImpl implements SnapshotService {
for
(
TextboxBo
textboxBo
:
xdateboxList
)
{
List
<
CustomAttributes
>
customAttributes
=
textboxBo
.
getCustomAttributes
();
String
text
=
getAttributeValue
(
customAttributes
).
getFieldUrl
();
PackDateboxBo
data
=
new
PackDateboxBo
();
if
(
StringUtils
.
isNotBlank
(
text
))
{
keySet
.
add
(
new
ValueVo
(
text
,
textboxBo
.
getFormat
(),
null
));
data
.
setText
(
"${"
+
text
+
"}"
);
}
else
{
data
.
setText
(
""
);
}
PackDateboxBo
data
=
new
PackDateboxBo
();
data
.
setText
(
"${"
+
text
+
"}"
);
data
.
setStyle
(
textboxBo
.
getStyle
());
data
.
setFormat
(
textboxBo
.
getFormat
());
dateboxBoList
.
add
(
data
);
...
...
@@ -377,11 +368,13 @@ public class SnapshotServiceImpl implements SnapshotService {
for
(
TextboxBo
textboxBo
:
xdecimalboxList
)
{
List
<
CustomAttributes
>
customAttributes
=
textboxBo
.
getCustomAttributes
();
String
text
=
getAttributeValue
(
customAttributes
).
getFieldUrl
();
PackDecimalboxBo
data
=
new
PackDecimalboxBo
();
if
(
StringUtils
.
isNotBlank
(
text
))
{
keySet
.
add
(
new
ValueVo
(
text
));
data
.
setText
(
"${"
+
text
+
"}"
);
}
else
{
data
.
setText
(
""
);
}
PackDecimalboxBo
data
=
new
PackDecimalboxBo
();
data
.
setText
(
"${"
+
text
+
"}"
);
data
.
setStyle
(
textboxBo
.
getStyle
());
data
.
setFormat
(
textboxBo
.
getFormat
());
decimalboxBoList
.
add
(
data
);
...
...
@@ -408,16 +401,22 @@ public class SnapshotServiceImpl implements SnapshotService {
String
labelId
=
attributeValue
.
getLabelId
();
if
(
StringUtils
.
isBlank
(
labelId
))
{
labelId
=
attributeValue
.
getFieldUrl
();
keySet
.
add
(
new
ValueVo
(
labelId
)
);
data
.
setLabel
(
"${"
+
labelId
+
"}"
);
//
labelId = attributeValue.getFieldUrl();
data
.
setLabel
(
"${"
+
fieldUrl
+
"}"
);
keySet
.
add
(
new
ValueVo
(
fieldUrl
)
);
}
else
{
// /bctp/LT000070/
String
[]
split
=
labelId
.
substring
(
1
,
labelId
.
length
()
-
1
).
split
(
"/"
);
String
i18NString
=
MdaUtils
.
getI18NString
(
split
[
0
],
split
[
1
]);
data
.
setLabel
(
i18NString
);
}
data
.
setChecked
(
"${"
+
fieldUrl
+
"}"
);
if
(
StringUtils
.
isNotBlank
(
fieldUrl
))
{
data
.
setChecked
(
"${"
+
fieldUrl
+
"}"
);
keySet
.
add
(
new
ValueVo
(
fieldUrl
));
}
else
{
data
.
setChecked
(
""
);
}
data
.
setStyle
(
checkboxBo
.
getStyle
());
checkboxBoList
.
add
(
data
);
}
...
...
@@ -429,9 +428,10 @@ public class SnapshotServiceImpl implements SnapshotService {
* 处理listboxList
*
* @param listboxList
* @param parent
* @return
*/
private
List
<
PackListboxBo
>
handleListboxList
(
List
<
ListboxBo
>
listboxList
)
{
private
List
<
PackListboxBo
>
handleListboxList
(
List
<
ListboxBo
>
listboxList
,
IModule
parent
)
{
List
<
PackListboxBo
>
listboxBoList
=
new
ArrayList
<>();
if
(
listboxList
==
null
)
{
return
listboxBoList
;
...
...
@@ -441,16 +441,12 @@ public class SnapshotServiceImpl implements SnapshotService {
// 表头
PackListheadBo
packListhead
=
new
PackListheadBo
();
List
<
PackListheaderBo
>
listheader
=
new
ArrayList
<>();
// 表数据
PackListitemBo
packListiteam
=
new
PackListitemBo
();
List
<
PackListcellBo
>
listcell
=
new
ArrayList
<>();
ListheadBo
listhead
=
listbox
.
getListhead
();
CustomAttributes
attributeValue
=
getAttributeValue
(
listbox
.
getCustomAttributes
());
String
fieldUrl
=
attributeValue
.
getFieldUrl
();
String
rowHeight
=
attributeValue
.
getRowHeight
();
Set
<
String
>
columnNameSet
=
new
HashSet
<>();
List
<
CustomAttributes
>
customAttributesList
=
new
ArrayList
<>();
List
<
ListheaderBo
>
listheaderList
=
listhead
.
getListheaderList
();
for
(
ListheaderBo
listheaderBo
:
listheaderList
)
{
List
<
CustomAttributes
>
customAttributes
=
listheaderBo
.
getCustomAttributes
();
...
...
@@ -465,10 +461,35 @@ public class SnapshotServiceImpl implements SnapshotService {
listheaderData
.
setLabel
(
i18NString
);
listheaderData
.
setStyle
(
listheaderBo
.
getStyle
());
listheader
.
add
(
listheaderData
);
// 表格字段名
columnNameSet
.
add
(
attributeValue1
.
getColumnName
());
// 表格字段属性
customAttributesList
.
add
(
attributeValue1
);
}
// 表数据
List
<
PackListitemBo
>
packListiteam
=
new
ArrayList
<>();
String
fieldUrl
=
attributeValue
.
getFieldUrl
();
String
rowHeight
=
attributeValue
.
getRowHeight
();
List
<
Map
<
String
,
Object
>>
value4List
=
getValue4List
(
fieldUrl
,
parent
,
columnNameSet
);
for
(
Map
<
String
,
Object
>
map
:
value4List
)
{
List
<
PackListcellBo
>
listcell
=
new
ArrayList
<>();
for
(
CustomAttributes
customAttributes
:
customAttributesList
)
{
Object
value
=
map
.
get
(
customAttributes
.
getColumnName
());
// 格式转换
value
=
formatValue
(
value
,
new
ValueVo
(
null
,
customAttributes
.
getFormatter
(),
customAttributes
.
getCodeTable
()));
PackListcellBo
listCellData
=
new
PackListcellBo
();
listCellData
.
setLabel
(
value
==
null
?
""
:
String
.
valueOf
(
value
));
listCellData
.
setStyle
(
customAttributes
.
getColumnStyle
());
listcell
.
add
(
listCellData
);
}
PackListitemBo
packListitemBo
=
new
PackListitemBo
();
packListitemBo
.
setListcell
(
listcell
);
packListitemBo
.
setHeight
(
rowHeight
);
packListiteam
.
add
(
packListitemBo
);
}
packListiteam
.
setListcell
(
listcell
);
packListiteam
.
setHeight
(
rowHeight
);
packListhead
.
setListheader
(
listheader
);
data
.
setPackListheadBo
(
packListhead
);
data
.
setPackListitemBo
(
packListiteam
);
...
...
@@ -479,4 +500,69 @@ public class SnapshotServiceImpl implements SnapshotService {
}
/**
* 获取列表中的值
*
* @param fieldUrl
* @param parent
* @param columnNameSet
* @return
*/
private
List
<
Map
<
String
,
Object
>>
getValue4List
(
String
fieldUrl
,
IModule
parent
,
Set
<
String
>
columnNameSet
)
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
valueMap
=
new
HashMap
();
IModule
root
=
getRoot
(
parent
);
if
(
fieldUrl
.
startsWith
(
"\\"
))
{
// 从根节点获取值
getValueFromModule
(
valueMap
,
root
,
new
ValueVo
(
fieldUrl
));
}
else
{
getValueFromModule
(
valueMap
,
parent
,
new
ValueVo
(
fieldUrl
));
}
ModuleList
moduleList
=
(
ModuleList
)
valueMap
.
get
(
fieldUrl
);
for
(
int
i
=
0
;
i
<
moduleList
.
fullSize
();
i
++)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
IModule
module
=
moduleList
.
getElement
(
i
);
Class
<?
extends
IModule
>
aClass
=
module
.
getClass
();
for
(
String
columnName
:
columnNameSet
)
{
try
{
Method
getMethod
=
aClass
.
getDeclaredMethod
(
"get"
+
columnName
.
substring
(
0
,
1
).
toUpperCase
()
+
columnName
.
substring
(
1
));
Object
value
=
getMethod
.
invoke
(
module
);
data
.
put
(
columnName
,
value
);
}
catch
(
Exception
e
)
{
}
}
list
.
add
(
data
);
}
return
list
;
}
/**
* 格式转换
*
* @param value
* @param valueVo
* @return
*/
private
Object
formatValue
(
Object
value
,
ValueVo
valueVo
)
{
if
(
value
!=
null
)
{
String
format
=
valueVo
.
getFormat
();
String
codeTable
=
valueVo
.
getCodeTable
();
// 从码表中转换
if
(
StringUtils
.
isNotBlank
(
codeTable
))
{
value
=
MdaUtils
.
getCodetableLabel
(
codeTable
,
(
String
)
value
);
}
// 时间格式化
if
(
StringUtils
.
isNotBlank
(
format
)
&&
value
instanceof
Date
)
{
value
=
DateUtils
.
format
((
Date
)
value
,
format
.
replaceAll
(
"/"
,
"-"
));
}
// boolean 类型转换为String
if
(
value
instanceof
Boolean
)
{
value
=
String
.
valueOf
(
value
);
}
}
return
value
;
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/snapshot/bo/pack/PackListboxBo.java
View file @
b4221c36
...
...
@@ -3,6 +3,7 @@ package com.brilliance.mda.runtime.mda.snapshot.bo.pack;
import
lombok.Data
;
import
javax.xml.bind.annotation.*
;
import
java.util.List
;
/**
* @Description
...
...
@@ -23,5 +24,5 @@ public class PackListboxBo {
private
PackListheadBo
packListheadBo
;
@XmlElement
(
name
=
"listitem"
)
private
PackListitemBo
packListitemBo
;
private
List
<
PackListitemBo
>
packListitemBo
;
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/DateUtil.java
→
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/DateUtil
s
.java
View file @
b4221c36
...
...
@@ -9,7 +9,7 @@ import java.util.Date;
* @Author s_guodong
* @Date 2023/8/21
*/
public
class
DateUtil
{
public
class
DateUtil
s
{
public
static
String
format
(
Date
date
,
String
pattern
)
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
pattern
);
...
...
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