Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-cdp-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e3f6f9b6
authored
Sep 21, 2023
by
ThomasAdv
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
更新模型数据处理
1 parent
c84a0173
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
6 deletions
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/entity/ModelFieldMapping.java
platform-cdp/pom.xml
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/ModelFieldConstants.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/enums/ModelFieldUnionRuleEnum.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/model/ModelFieldMappingDTO.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
platform-cdp-api/src/main/java/cn/com/glsx/cdp/modules/entity/ModelFieldMapping.java
View file @
e3f6f9b
...
@@ -39,7 +39,7 @@ public class ModelFieldMapping implements Serializable {
...
@@ -39,7 +39,7 @@ public class ModelFieldMapping implements Serializable {
* 合并规则 (1-非空优先2-最后一次入库优先3-第一次入库优先4-时间最小5-时间最大)
* 合并规则 (1-非空优先2-最后一次入库优先3-第一次入库优先4-时间最小5-时间最大)
*/
*/
@Column
(
name
=
"union_rule"
)
@Column
(
name
=
"union_rule"
)
private
Integer
unionRule
;
private
Byte
unionRule
;
/**
/**
* 模型识别标识:1
* 模型识别标识:1
...
...
platform-cdp/pom.xml
View file @
e3f6f9b
...
@@ -63,7 +63,6 @@
...
@@ -63,7 +63,6 @@
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
<version>
1.16.14
</version>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/ModelFieldConstants.java
View file @
e3f6f9b
package
cn
.
com
.
glsx
.
cdp
.
common
.
constant
;
package
cn
.
com
.
glsx
.
cdp
.
common
.
constant
;
public
class
ModelFieldConstants
{
public
class
ModelFieldConstants
{
public
final
static
String
ORGID
=
"orgId"
;
public
final
static
String
ORGID
=
"org_id"
;
public
final
static
String
ADD_WAY
=
"addWay"
;
public
final
static
String
ADD_WAY
=
"add_way"
;
public
final
static
String
EX_JSON
=
"ex_json"
;
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/enums/ModelFieldUnionRuleEnum.java
0 → 100644
View file @
e3f6f9b
package
cn
.
com
.
glsx
.
cdp
.
modules
.
enums
;
public
enum
ModelFieldUnionRuleEnum
{
LAST_PRO
((
byte
)
1
,
"最后一次入库优先"
),
FIRST_PRO
((
byte
)
2
,
"第一次入库优先"
),
MIN_TIME_PRO
((
byte
)
3
,
"时间最小优先"
),
MAX_TIME_PRO
((
byte
)
4
,
"时间最大优先"
);
private
final
Byte
value
;
private
final
String
displayText
;
ModelFieldUnionRuleEnum
(
Byte
value
,
String
displayText
){
this
.
value
=
value
;
this
.
displayText
=
displayText
;
}
public
Byte
getValue
()
{
return
value
;
}
public
String
getDisplayText
()
{
return
displayText
;
}
public
static
ModelFieldUnionRuleEnum
getByValue
(
Byte
value
){
if
(
value
!=
null
)
{
for
(
ModelFieldUnionRuleEnum
modelFieldUnionRuleEnum
:
ModelFieldUnionRuleEnum
.
values
())
{
if
(
modelFieldUnionRuleEnum
.
getValue
().
equals
(
value
))
{
return
modelFieldUnionRuleEnum
;
}
}
}
return
null
;
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/model/ModelFieldMappingDTO.java
View file @
e3f6f9b
...
@@ -8,6 +8,7 @@ import lombok.ToString;
...
@@ -8,6 +8,7 @@ import lombok.ToString;
import
lombok.experimental.SuperBuilder
;
import
lombok.experimental.SuperBuilder
;
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@SuperBuilder
@SuperBuilder
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
View file @
e3f6f9b
...
@@ -2,6 +2,7 @@ package cn.com.glsx.cdp.modules.queue;
...
@@ -2,6 +2,7 @@ package cn.com.glsx.cdp.modules.queue;
import
cn.com.glsx.cdp.common.constant.ModelFieldConstants
;
import
cn.com.glsx.cdp.common.constant.ModelFieldConstants
;
import
cn.com.glsx.cdp.config.RabbitMQConfig
;
import
cn.com.glsx.cdp.config.RabbitMQConfig
;
import
cn.com.glsx.cdp.modules.enums.ModelFieldUnionRuleEnum
;
import
cn.com.glsx.cdp.modules.enums.OneIdBelongEnum
;
import
cn.com.glsx.cdp.modules.enums.OneIdBelongEnum
;
import
cn.com.glsx.cdp.modules.model.ModelDTO
;
import
cn.com.glsx.cdp.modules.model.ModelDTO
;
import
cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO
;
import
cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO
;
...
@@ -128,8 +129,103 @@ public class DataReportRabbitMQConsumer {
...
@@ -128,8 +129,103 @@ public class DataReportRabbitMQConsumer {
* @date 2023年09月15日 17:24:15
* @date 2023年09月15日 17:24:15
*/
*/
private
Map
<
String
,
Object
>
mergeModelData
(
ModelDTO
modelDTO
,
Map
<
String
,
Object
>
existModelData
)
{
private
Map
<
String
,
Object
>
mergeModelData
(
ModelDTO
modelDTO
,
Map
<
String
,
Object
>
existModelData
)
{
//TODO 合并模型数据
Map
<
String
,
ModelFieldMappingDTO
>
newDataMap
=
getNewDataMap
(
modelDTO
);
return
null
;
Map
<
String
,
Object
>
mergeResultMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
String
,
ModelFieldMappingDTO
>
newDataMapEntry
:
newDataMap
.
entrySet
())
{
String
fieldName
=
newDataMapEntry
.
getKey
();
mergeResultMap
.
put
(
fieldName
,
mergeField
(
newDataMapEntry
.
getValue
(),
existModelData
.
get
(
fieldName
)));
}
return
mergeResultMap
;
}
/**
* 合并字段
*
* @param newDataModelFieldMapping
* @param oldValue
* @return java.lang.Object
* @author caiym
* @date 2023年09月19日 19:57:08
*/
private
Object
mergeField
(
ModelFieldMappingDTO
newDataModelFieldMapping
,
Object
oldValue
)
{
if
(
newDataModelFieldMapping
==
null
)
{
return
oldValue
;
}
ModelFieldUnionRuleEnum
modelFieldUnionRuleEnum
=
ModelFieldUnionRuleEnum
.
getByValue
(
newDataModelFieldMapping
.
getUnionRule
());
return
mergeField
(
modelFieldUnionRuleEnum
,
oldValue
,
newDataModelFieldMapping
.
getFieldValue
());
}
/**
* 合并字段
*
* @param unionRuleEnum
* @param oldValue
* @param newValue
* @return java.lang.Object
* @author caiym
* @date 2023年09月19日 19:57:19
*/
private
Object
mergeField
(
ModelFieldUnionRuleEnum
unionRuleEnum
,
Object
oldValue
,
Object
newValue
)
{
if
(
unionRuleEnum
!=
null
)
{
switch
(
unionRuleEnum
)
{
case
FIRST_PRO:
return
oldValue
;
case
LAST_PRO:
return
newValue
==
null
?
oldValue:
newValue
;
case
MAX_TIME_PRO:
if
(
oldValue
instanceof
Date
&&
newValue
instanceof
Date
)
{
if
(((
Date
)
oldValue
).
after
((
Date
)
newValue
))
{
return
oldValue
;
}
else
{
return
newValue
;
}
}
case
MIN_TIME_PRO:
if
(
oldValue
instanceof
Date
&&
newValue
instanceof
Date
)
{
if
(((
Date
)
oldValue
).
after
((
Date
)
newValue
))
{
return
newValue
;
}
else
{
return
oldValue
;
}
}
default
:
}
}
if
(
newValue
instanceof
String
)
{
return
((
String
)
newValue
).
isEmpty
()
?
oldValue
:
newValue
;
}
else
{
return
newValue
==
null
?
oldValue
:
newValue
;
}
}
/**
* 获取新数据map
*
* @param modelDTO
* @return java.util.Map<java.lang.String,cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO>
* @author caiym
* @date 2023年09月19日 19:57:43
*/
private
static
Map
<
String
,
ModelFieldMappingDTO
>
getNewDataMap
(
ModelDTO
modelDTO
)
{
Map
<
String
,
ModelFieldMappingDTO
>
newDataMap
=
new
HashMap
<>();
JSONObject
exJson
=
new
JSONObject
();
for
(
ModelFieldMappingDTO
modelFieldMapping
:
modelDTO
.
getModelFieldMappings
())
{
if
(
modelFieldMapping
.
getExpandFlag
()
!=
null
&&
modelFieldMapping
.
getExpandFlag
())
{
exJson
.
put
(
modelFieldMapping
.
getFieldName
(),
modelFieldMapping
.
getFieldValue
());
}
else
{
newDataMap
.
put
(
modelFieldMapping
.
getFieldName
(),
modelFieldMapping
);
}
}
if
(
exJson
.
size
()
>
0
)
{
ModelFieldMappingDTO
modelFieldMapping
=
ModelFieldMappingDTO
.
builder
().
unionRule
(
ModelFieldUnionRuleEnum
.
LAST_PRO
.
getValue
()).
fieldName
(
ModelFieldConstants
.
EX_JSON
).
fieldValue
(
exJson
.
toJSONString
()).
build
();
newDataMap
.
put
(
ModelFieldConstants
.
EX_JSON
,
modelFieldMapping
);
}
return
newDataMap
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment