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
94e18a23
Commit
94e18a23
authored
Aug 28, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
从容器中获取ObjectMapper
parent
00cce7ce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
23 deletions
+36
-23
JsonConfig.java
...ess/src/main/java/com/ceb/gjjs/mda/config/JsonConfig.java
+2
-0
MdaUtils.java
...in/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
+32
-14
Modules.java
...ain/java/com/brilliance/mda/runtime/mda/util/Modules.java
+2
-9
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/JsonConfig.java
View file @
94e18a23
...
...
@@ -2,6 +2,7 @@ package com.ceb.gjjs.mda.config;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
;
...
...
@@ -30,6 +31,7 @@ public class JsonConfig {
// 反序列化的时候如果多了其他属性,不抛出异常
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
objectMapper
.
disable
(
SerializationFeature
.
FAIL_ON_EMPTY_BEANS
);
// 日期格式处理
// objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
View file @
94e18a23
...
...
@@ -7,7 +7,6 @@ import com.brilliance.mda.runtime.mda.driver.MdaEnv;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.runtime.mda.impl.AttributeValue
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
oracle.sql.TIMESTAMP
;
import
org.apache.commons.beanutils.MethodUtils
;
import
org.apache.commons.beanutils.PropertyUtils
;
...
...
@@ -23,6 +22,8 @@ import org.apache.poi.ss.usermodel.*;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
import
java.io.*
;
import
java.math.BigDecimal
;
...
...
@@ -58,12 +59,26 @@ public class MdaUtils {
pMap
.
clear
();
}
private
static
synchronized
Properties
getProperties
(
String
name
)
throws
FileNotFoundException
,
IOException
{
Properties
properties
=
(
Properties
)
pMap
.
get
(
name
);
private
static
synchronized
Properties
getProperties
(
String
name
)
throws
IOException
{
Properties
properties
=
pMap
.
get
(
name
);
if
(
properties
==
null
)
{
properties
=
new
Properties
();
properties
.
load
(
new
FileInputStream
(
new
File
(
name
)));
//路径问题: 不存在就去类路径下找
File
propfile
=
new
File
(
name
);
if
(!
propfile
.
exists
())
{
String
pathToUse
=
StringUtils
.
cleanPath
(
name
);
IContext
ctx
=
MdaEnv
.
getContext
();
String
rootpath
=
ctx
.
getEnvConfig
().
getRootPath
();
pathToUse
=
pathToUse
.
substring
(
rootpath
.
length
());
if
(
pathToUse
.
startsWith
(
"/"
))
{
pathToUse
=
pathToUse
.
substring
(
1
);
}
ClassLoader
classLoader
=
ClassUtils
.
getDefaultClassLoader
();
InputStream
in
=
classLoader
.
getResourceAsStream
(
pathToUse
);
properties
.
load
(
in
);
}
else
{
properties
.
load
(
new
FileInputStream
(
propfile
));
}
pMap
.
put
(
name
,
properties
);
}
return
properties
;
...
...
@@ -589,7 +604,8 @@ public class MdaUtils {
return
Collections
.
EMPTY_LIST
;
}
public
static
final
void
saveLines
(
List
<
String
>
lines
,
String
lineEnding
,
String
fileName
,
String
encoding
)
{
public
static
final
void
saveLines
(
List
<
String
>
lines
,
String
lineEnding
,
String
fileName
,
String
encoding
)
{
try
{
IOUtils
.
writeLines
(
lines
,
""
,
new
FileOutputStream
(
fileName
),
encoding
);
}
catch
(
Exception
e
)
{
...
...
@@ -654,7 +670,8 @@ public class MdaUtils {
return
sheetNames
;
}
public
static
final
int
loadExcel
(
List
<
String
[]>
list
,
IStream
s
,
int
sheetIndex
,
int
rowOffset
,
int
rowMax
,
int
columnOffset
,
int
columnCount
)
{
public
static
final
int
loadExcel
(
List
<
String
[]>
list
,
IStream
s
,
int
sheetIndex
,
int
rowOffset
,
int
rowMax
,
int
columnOffset
,
int
columnCount
)
{
Workbook
wb
=
getWorkbook
(
s
);
if
(
wb
==
null
)
return
-
1
;
...
...
@@ -765,7 +782,8 @@ public class MdaUtils {
unloadExcel
(
new
List
[]{
list
},
new
String
[
1
],
s
,
flag
);
}
public
static
final
void
generate
(
String
templateFileName
,
String
fileName
,
String
exportType
,
Map
params
,
Object
data
)
{
public
static
final
void
generate
(
String
templateFileName
,
String
fileName
,
String
exportType
,
Map
params
,
Object
data
)
{
// FileOutputStream fos = null;
// try {
// fos = new FileOutputStream(fileName);
...
...
@@ -777,7 +795,8 @@ public class MdaUtils {
// }
}
public
static
final
void
generate
(
String
templateFileName
,
IStream
is
,
String
exportType
,
Map
params
,
Object
data
)
{
public
static
final
void
generate
(
String
templateFileName
,
IStream
is
,
String
exportType
,
Map
params
,
Object
data
)
{
// try {
// ReportUtils.generate(templateFileName, is.getOutputStream(), exportType, params, data);
// } catch (Exception e) {
...
...
@@ -928,9 +947,8 @@ public class MdaUtils {
}
public
static
void
saveData
(
IModule
module
,
IStream
os
)
{
ObjectMapper
mapper
=
new
ObjectMapper
(
);
ObjectMapper
mapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
try
{
mapper
.
disable
(
SerializationFeature
.
FAIL_ON_EMPTY_BEANS
);
mapper
.
writeValue
(
os
.
getOutputStream
(),
module
);
}
catch
(
Exception
e
)
{
log
.
error
(
"模型序列化异常"
,
e
);
...
...
@@ -952,7 +970,7 @@ public class MdaUtils {
}
public
static
void
loadData
(
IModule
module
,
IStream
stream
)
{
ObjectMapper
mapper
=
new
ObjectMapper
(
);
ObjectMapper
mapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
try
{
module
.
copyValues
(
mapper
.
readValue
(
stream
.
getInputStream
(),
module
.
getClass
()));
}
catch
(
Exception
e
)
{
...
...
@@ -961,7 +979,7 @@ public class MdaUtils {
}
public
static
String
toJson
(
Object
dataMap
)
{
ObjectMapper
mapper
=
new
ObjectMapper
(
);
ObjectMapper
mapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
try
{
return
mapper
.
writeValueAsString
(
dataMap
);
}
catch
(
Exception
e
)
{
...
...
@@ -971,7 +989,7 @@ public class MdaUtils {
}
public
static
<
T
>
T
fromJson
(
String
json
,
Class
<
T
>
clazz
)
{
ObjectMapper
mapper
=
new
ObjectMapper
(
);
ObjectMapper
mapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
return
mapper
.
convertValue
(
json
,
clazz
);
}
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/Modules.java
View file @
94e18a23
...
...
@@ -10,8 +10,6 @@ import com.brilliance.mda.runtime.mda.impl.ModuleList;
import
com.brilliance.mda.support.td.ModuleInfoManager
;
import
com.brilliance.mda.support.td.TDFieldInfo
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
;
import
org.apache.commons.beanutils.MethodUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -60,12 +58,7 @@ public class Modules {
}
public
static
ObjectMapper
getObjectMapper
()
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
SimpleFilterProvider
filterProvider
=
new
SimpleFilterProvider
();
// 在存盘的时候,不需要过滤字段,故 serializeAllExcept 不传参数
SimpleBeanPropertyFilter
fieldFilter
=
SimpleBeanPropertyFilter
.
serializeAllExcept
();
filterProvider
.
addFilter
(
"fieldFilter"
,
fieldFilter
);
objectMapper
.
setFilterProvider
(
filterProvider
);
ObjectMapper
objectMapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
return
objectMapper
;
}
...
...
@@ -81,7 +74,7 @@ public class Modules {
}
public
static
Object
data2Module
(
Class
clazz
,
String
dataString
)
{
ObjectMapper
mapper
=
new
ObjectMapper
(
);
ObjectMapper
mapper
=
MdaEnv
.
getBean
(
ObjectMapper
.
class
);
try
{
boolean
isEnableNotify
=
DCR
.
isEnable
();
if
(
isEnableNotify
)
...
...
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