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
20cce451
Commit
20cce451
authored
Sep 04, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态码表
parent
010bb492
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
18 deletions
+66
-18
SnapshotServiceImpl.java
...lliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
+16
-5
MdaUtils.java
...in/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
+26
-10
Systems.java
...ain/java/com/brilliance/mda/runtime/mda/util/Systems.java
+24
-3
No files found.
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
View file @
20cce451
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
snapshot
;
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
snapshot
;
import
com.brilliance.mda.runtime.mda.CodetableItem
;
import
com.brilliance.mda.runtime.mda.Constants
;
import
com.brilliance.mda.runtime.mda.Constants
;
import
com.brilliance.mda.runtime.mda.IModule
;
import
com.brilliance.mda.runtime.mda.IModule
;
import
com.brilliance.mda.runtime.mda.IPanel
;
import
com.brilliance.mda.runtime.mda.IPanel
;
...
@@ -197,7 +198,7 @@ public class SnapshotServiceImpl implements SnapshotService {
...
@@ -197,7 +198,7 @@ public class SnapshotServiceImpl implements SnapshotService {
}
}
}
}
// 格式转换
// 格式转换
value
=
formatValue
(
value
,
valueVo
);
value
=
formatValue
(
value
,
valueVo
,
parent
);
valueMap
.
put
(
originKey
,
value
==
null
?
""
:
value
);
valueMap
.
put
(
originKey
,
value
==
null
?
""
:
value
);
}
}
...
@@ -477,7 +478,7 @@ public class SnapshotServiceImpl implements SnapshotService {
...
@@ -477,7 +478,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for
(
CustomAttributes
customAttributes
:
customAttributesList
)
{
for
(
CustomAttributes
customAttributes
:
customAttributesList
)
{
Object
value
=
map
.
get
(
customAttributes
.
getColumnName
());
Object
value
=
map
.
get
(
customAttributes
.
getColumnName
());
// 格式转换
// 格式转换
value
=
formatValue
(
value
,
new
ValueVo
(
null
,
customAttributes
.
getFormatter
(),
customAttributes
.
getCodeTable
(),
customAttributes
.
getFormatter
()));
value
=
formatValue
(
value
,
new
ValueVo
(
null
,
customAttributes
.
getFormatter
(),
customAttributes
.
getCodeTable
(),
customAttributes
.
getFormatter
())
,
parent
);
PackListcellBo
listCellData
=
new
PackListcellBo
();
PackListcellBo
listCellData
=
new
PackListcellBo
();
listCellData
.
setLabel
(
value
==
null
?
""
:
String
.
valueOf
(
value
));
listCellData
.
setLabel
(
value
==
null
?
""
:
String
.
valueOf
(
value
));
listCellData
.
setStyle
(
customAttributes
.
getColumnStyle
());
listCellData
.
setStyle
(
customAttributes
.
getColumnStyle
());
...
@@ -654,16 +655,26 @@ public class SnapshotServiceImpl implements SnapshotService {
...
@@ -654,16 +655,26 @@ public class SnapshotServiceImpl implements SnapshotService {
*
*
* @param value
* @param value
* @param valueVo
* @param valueVo
* @param parent
* @return
* @return
*/
*/
private
Object
formatValue
(
Object
value
,
ValueVo
valueVo
)
{
private
Object
formatValue
(
Object
value
,
ValueVo
valueVo
,
IModule
parent
)
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
String
format
=
valueVo
.
getFormat
();
String
format
=
valueVo
.
getFormat
();
String
codeTable
=
valueVo
.
getCodeTable
();
String
codeTable
=
valueVo
.
getCodeTable
();
String
formatter
=
valueVo
.
getFormatter
();
String
formatter
=
valueVo
.
getFormatter
();
// 从码表中转换
// 从码表中转换
if
(
StringUtils
.
isNotBlank
(
codeTable
)
&&
"{0}"
.
equals
(
formatter
))
{
if
(
"{0}"
.
equals
(
formatter
))
{
value
=
MdaUtils
.
getCodetableLabel
(
codeTable
,
(
String
)
value
);
if
(
StringUtils
.
isNotBlank
(
codeTable
))
{
// 静态码表
value
=
MdaUtils
.
getCodetableLabel
(
codeTable
,
(
String
)
value
);
}
else
{
// 动态码表
Set
<
ValueVo
>
valueVos
=
new
HashSet
<>();
valueVos
.
add
(
new
ValueVo
(
valueVo
.
getKey
()
+
"CodeTable"
));
Map
<
String
,
Object
>
map
=
getValueMap
(
valueVos
,
parent
);
value
=
MdaUtils
.
getCodetableLabel
((
List
<
CodetableItem
>)
map
.
get
(
valueVo
.
getKey
()
+
"CodeTable"
),
(
String
)
value
);
}
}
}
if
(
StringUtils
.
isNotBlank
(
format
))
{
if
(
StringUtils
.
isNotBlank
(
format
))
{
if
(
value
instanceof
Date
)
{
if
(
value
instanceof
Date
)
{
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
View file @
20cce451
...
@@ -23,6 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...
@@ -23,6 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.io.*
;
import
java.io.*
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -961,6 +962,19 @@ public class MdaUtils {
...
@@ -961,6 +962,19 @@ public class MdaUtils {
return
Codetables
.
getCodetableLabel
(
key
,
codetable
,
locale
.
getLanguage
());
return
Codetables
.
getCodetableLabel
(
key
,
codetable
,
locale
.
getLanguage
());
}
}
public
static
String
getCodetableLabel
(
List
<
CodetableItem
>
codeTable
,
String
key
)
{
String
label
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
codeTable
))
{
for
(
CodetableItem
codetableItem
:
codeTable
)
{
if
(
key
.
equalsIgnoreCase
(
codetableItem
.
getValue
()))
{
label
=
codetableItem
.
getLabel
();
break
;
}
}
}
return
label
;
}
public
static
String
getCodetableLabel
(
Locale
locale
,
String
codetable
,
String
key
)
{
public
static
String
getCodetableLabel
(
Locale
locale
,
String
codetable
,
String
key
)
{
return
Codetables
.
getCodetableLabel
(
key
,
codetable
,
locale
.
getLanguage
());
return
Codetables
.
getCodetableLabel
(
key
,
codetable
,
locale
.
getLanguage
());
}
}
...
@@ -1355,19 +1369,21 @@ public class MdaUtils {
...
@@ -1355,19 +1369,21 @@ public class MdaUtils {
}
}
/**
/**
* todo
*
* @param o
* @param o
*/
*/
public
static
void
setValues
(
Object
...
o
)
{
public
static
void
setValues
(
Object
...
o
)
{
// if (o.length == 3) {
if
(
o
.
length
==
3
)
{
// Object o1 = o[0];
Object
o1
=
o
[
0
];
// Object o2 = o[1];
Object
o2
=
o
[
1
];
// Object o3 = o[2];
Object
o3
=
o
[
2
];
// if (o1 instanceof IModule && o2 instanceof String) {
if
(
o1
instanceof
IModule
&&
o2
instanceof
String
&&
o3
instanceof
List
)
{
// Datas.setFieldValue((IModule) o1, (String) o2, o3);
String
fieldName
=
(
String
)
o2
;
// }
try
{
// }
Datas
.
setFieldValue
((
IModule
)
o1
,
fieldName
+
"CodeTable"
,
o3
);
}
catch
(
Exception
e
)
{
}
}
}
}
}
/**
/**
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/Systems.java
View file @
20cce451
...
@@ -37,7 +37,7 @@ public class Systems {
...
@@ -37,7 +37,7 @@ public class Systems {
private
static
final
List
<
Resource
>
resources
=
new
ArrayList
<>();
private
static
final
List
<
Resource
>
resources
=
new
ArrayList
<>();
private
static
final
Map
<
String
,
In
putStream
>
FILE_MAP
=
new
HashMap
<>();
private
static
final
Map
<
String
,
ByteArrayOut
putStream
>
FILE_MAP
=
new
HashMap
<>();
public
static
void
setAttribute
(
IDatafield
field
,
String
ATTR
,
Object
val
)
{
public
static
void
setAttribute
(
IDatafield
field
,
String
ATTR
,
Object
val
)
{
setAttribute
(
field
.
getParent
(),
field
.
getName
(),
ATTR
,
val
);
setAttribute
(
field
.
getParent
(),
field
.
getName
(),
ATTR
,
val
);
...
@@ -1038,12 +1038,33 @@ public class Systems {
...
@@ -1038,12 +1038,33 @@ public class Systems {
if
(
FILE_MAP
.
size
()
==
0
)
{
if
(
FILE_MAP
.
size
()
==
0
)
{
for
(
Resource
resource
:
resources
)
{
for
(
Resource
resource
:
resources
)
{
try
{
try
{
FILE_MAP
.
put
(
resource
.
getFilename
(),
resource
.
getInputStream
(
));
FILE_MAP
.
put
(
resource
.
getFilename
(),
cloneInputStream
(
resource
.
getInputStream
()
));
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
}
}
}
}
}
}
return
FILE_MAP
.
get
(
fileName
);
ByteArrayOutputStream
byteArrayOutputStream
=
FILE_MAP
.
get
(
fileName
);
if
(
byteArrayOutputStream
==
null
)
{
log
.
error
(
"获取快照文件{}失败"
,
fileName
);
return
null
;
}
return
new
ByteArrayInputStream
(
byteArrayOutputStream
.
toByteArray
());
}
private
static
ByteArrayOutputStream
cloneInputStream
(
InputStream
input
)
{
try
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
1024
];
int
len
;
while
((
len
=
input
.
read
(
buffer
))
>
-
1
)
{
baos
.
write
(
buffer
,
0
,
len
);
}
baos
.
flush
();
return
baos
;
}
catch
(
IOException
e
)
{
log
.
error
(
"获取快照文件失败"
,
e
);
return
null
;
}
}
}
}
}
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