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
aa204af7
Commit
aa204af7
authored
Aug 21, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理日期格式
parent
639dcc16
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
23 deletions
+60
-23
Test.java
gjjs-bd-business/src/test/java/com/brilliance/test/Test.java
+12
-2
SnapshotServiceImpl.java
...lliance/mda/runtime/mda/snapshot/SnapshotServiceImpl.java
+14
-2
DateUtil.java
...in/java/com/brilliance/mda/runtime/mda/util/DateUtil.java
+18
-0
XmlUtil.java
...ain/java/com/brilliance/mda/runtime/mda/util/XmlUtil.java
+16
-19
No files found.
gjjs-bd-business/src/test/java/com/brilliance/test/Test.java
View file @
aa204af7
package
com
.
brilliance
.
test
;
import
com.brilliance.mda.runtime.mda.snapshot.SnapshotServiceImpl
;
import
java.util.HashSet
;
public
class
Test
{
@org
.
junit
.
jupiter
.
api
.
Test
public
void
test
(){
HashSet
set
=
new
HashSet
();
public
void
test
()
{
HashSet
set
=
new
HashSet
();
set
.
add
(
"com"
);
set
.
add
(
"com1"
);
set
.
add
(
"com"
);
System
.
out
.
println
(
set
.
size
());
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/snapshot/SnapshotServiceImpl.java
View file @
aa204af7
...
...
@@ -3,6 +3,7 @@ package com.brilliance.mda.runtime.mda.snapshot;
import
com.brilliance.mda.runtime.mda.IModule
;
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.MdaUtils
;
import
com.brilliance.mda.runtime.mda.util.XmlUtil
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -54,6 +55,7 @@ public class SnapshotServiceImpl implements SnapshotService {
DocumentBo
documentBo
=
XmlUtil
.
unmarshToObjBinding
(
DocumentBo
.
class
,
file
);
return
documentBo
;
}
catch
(
Exception
e
)
{
log
.
error
(
"模板{}解析失败"
,
panelPath
,
e
);
}
return
null
;
}
...
...
@@ -159,7 +161,7 @@ public class SnapshotServiceImpl implements SnapshotService {
for
(
CustomAttributes
customAttribute
:
customAttributes
)
{
text
=
customAttribute
.
getFieldUrl
();
if
(
StringUtils
.
isNotBlank
(
text
))
{
keySet
.
add
(
text
);
keySet
.
add
(
text
+
":"
+
textboxBo
.
getFormat
()
);
break
;
}
}
...
...
@@ -244,12 +246,18 @@ public class SnapshotServiceImpl implements SnapshotService {
*/
private
void
getValueFromModule
(
Map
<
String
,
Object
>
valueMap
,
IModule
parent
,
String
key
)
{
String
originKey
=
key
;
String
format
=
""
;
if
(
key
.
contains
(
":"
))
{
String
[]
split
=
key
.
split
(
":"
);
originKey
=
split
[
0
];
format
=
split
[
1
];
}
if
(
key
.
startsWith
(
"\\"
))
{
key
=
key
.
substring
(
1
);
}
String
[]
split
=
key
.
split
(
"\\\\"
);
Class
aClass
=
parent
.
getClass
();
Object
value
=
""
;
Object
value
=
null
;
Object
obj
=
parent
;
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
String
s
=
split
[
i
];
...
...
@@ -265,6 +273,10 @@ public class SnapshotServiceImpl implements SnapshotService {
log
.
error
(
"获取模板中的值{}错误:"
,
originKey
,
e
);
}
}
if
(
value
!=
null
&&
StringUtils
.
isNotBlank
(
format
))
{
value
=
DateUtil
.
format
((
Date
)
value
,
format
.
replaceAll
(
"/"
,
"-"
));
}
valueMap
.
put
(
originKey
,
value
==
null
?
""
:
value
);
}
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/DateUtil.java
0 → 100644
View file @
aa204af7
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
util
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/21
*/
public
class
DateUtil
{
public
static
String
format
(
Date
date
,
String
pattern
)
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
pattern
);
return
date
!=
null
?
dateFormat
.
format
(
date
)
:
null
;
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/XmlUtil.java
View file @
aa204af7
...
...
@@ -19,26 +19,22 @@ public class XmlUtil {
/**
* 将XML格式的文件转换成JAXB实现对象
*/
public
static
<
T
>
T
unmarshToObjBinding
(
Class
<
T
>
tclz
,
File
file
)
{
try
{
JAXBContext
jc
=
jaxbContextMap
.
get
(
tclz
);
if
(
jc
==
null
)
{
jc
=
JAXBContext
.
newInstance
(
tclz
);
jaxbContextMap
.
put
(
tclz
,
jc
);
}
Unmarshaller
un
=
jc
.
createUnmarshaller
();
sax
.
setNamespaceAware
(
false
);
XMLReader
xmlReader
=
sax
.
newSAXParser
().
getXMLReader
();
Source
source
=
new
SAXSource
(
xmlReader
,
new
InputSource
(
new
FileInputStream
(
file
)));
Object
obj
=
un
.
unmarshal
(
source
);
if
(
JAXBElement
.
class
.
isAssignableFrom
(
obj
.
getClass
()))
{
obj
=
(
T
)
JAXBIntrospector
.
getValue
(
obj
);
}
return
(
T
)
obj
;
}
catch
(
Exception
e
)
{
public
static
<
T
>
T
unmarshToObjBinding
(
Class
<
T
>
tclz
,
File
file
)
throws
Exception
{
JAXBContext
jc
=
jaxbContextMap
.
get
(
tclz
);
if
(
jc
==
null
)
{
jc
=
JAXBContext
.
newInstance
(
tclz
);
jaxbContextMap
.
put
(
tclz
,
jc
);
}
return
null
;
Unmarshaller
un
=
jc
.
createUnmarshaller
();
sax
.
setNamespaceAware
(
false
);
XMLReader
xmlReader
=
sax
.
newSAXParser
().
getXMLReader
();
Source
source
=
new
SAXSource
(
xmlReader
,
new
InputSource
(
new
FileInputStream
(
file
)));
Object
obj
=
un
.
unmarshal
(
source
);
if
(
JAXBElement
.
class
.
isAssignableFrom
(
obj
.
getClass
()))
{
obj
=
(
T
)
JAXBIntrospector
.
getValue
(
obj
);
}
return
(
T
)
obj
;
}
...
...
@@ -60,6 +56,7 @@ public class XmlUtil {
u
.
marshal
(
t
,
sw
);
xmlstr
=
sw
.
toString
();
}
catch
(
Exception
e
)
{
}
return
xmlstr
;
}
...
...
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