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 8415a916
authored
Sep 27, 2023
by
ThomasAdv
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复oneIdMapping orgId取值为-1问题;数据上报含oneId处理:存在则不更新相关模型,不存在则抛出异常停止处理
1 parent
0add4ae3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/model/OneIdFieldConfigDTO.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdMappingService.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdService.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/model/OneIdFieldConfigDTO.java
View file @
8415a91
...
@@ -17,4 +17,6 @@ public class OneIdFieldConfigDTO extends OneIdFieldConfig {
...
@@ -17,4 +17,6 @@ public class OneIdFieldConfigDTO extends OneIdFieldConfig {
private
static
final
long
serialVersionUID
=
3839452358183537235L
;
private
static
final
long
serialVersionUID
=
3839452358183537235L
;
private
String
fieldValue
;
private
String
fieldValue
;
private
String
oneIdBelongOrgId
;
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
View file @
8415a91
...
@@ -12,6 +12,7 @@ import cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO;
...
@@ -12,6 +12,7 @@ import cn.com.glsx.cdp.modules.model.ModelFieldMappingDTO;
import
cn.com.glsx.cdp.modules.service.ModelService
;
import
cn.com.glsx.cdp.modules.service.ModelService
;
import
cn.com.glsx.cdp.modules.service.OneIdService
;
import
cn.com.glsx.cdp.modules.service.OneIdService
;
import
cn.com.glsx.cdp.modules.util.DateUtil
;
import
cn.com.glsx.cdp.modules.util.DateUtil
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -486,7 +487,7 @@ public class DataReportRabbitMQConsumer {
...
@@ -486,7 +487,7 @@ public class DataReportRabbitMQConsumer {
public
Map
<
OneIdBelongEnum
,
String
>
getOneId
(
List
<
ModelDTO
>
matchModels
,
JSONObject
jsonData
)
{
public
Map
<
OneIdBelongEnum
,
String
>
getOneId
(
List
<
ModelDTO
>
matchModels
,
JSONObject
jsonData
)
{
Map
<
OneIdBelongEnum
,
String
>
oneIdBelongEnumStringMap
=
new
HashMap
<>();
Map
<
OneIdBelongEnum
,
String
>
oneIdBelongEnumStringMap
=
new
HashMap
<>();
List
<
String
>
oneIdModelNames
=
OneIdBelongEnum
.
getModelNames
();
List
<
String
>
oneIdModelNames
=
OneIdBelongEnum
.
getModelNames
();
putOneIdByJSONDataField
(
jsonData
,
oneIdBelongEnumStringMap
,
oneIdModelNames
);
putOneIdByJSONDataField
(
matchModels
,
jsonData
,
oneIdBelongEnumStringMap
,
oneIdModelNames
);
putOneIdByMatchModel
(
matchModels
,
jsonData
,
oneIdModelNames
,
oneIdBelongEnumStringMap
);
putOneIdByMatchModel
(
matchModels
,
jsonData
,
oneIdModelNames
,
oneIdBelongEnumStringMap
);
return
oneIdBelongEnumStringMap
;
return
oneIdBelongEnumStringMap
;
}
}
...
@@ -536,7 +537,7 @@ public class DataReportRabbitMQConsumer {
...
@@ -536,7 +537,7 @@ public class DataReportRabbitMQConsumer {
* @author caiym
* @author caiym
* @date 2023年09月26日 17:01:25
* @date 2023年09月26日 17:01:25
*/
*/
private
void
putOneIdByJSONDataField
(
JSONObject
jsonData
,
Map
<
OneIdBelongEnum
,
String
>
oneIdBelongEnumStringMap
,
List
<
String
>
oneIdModelNames
)
{
private
void
putOneIdByJSONDataField
(
List
<
ModelDTO
>
matchModels
,
JSONObject
jsonData
,
Map
<
OneIdBelongEnum
,
String
>
oneIdBelongEnumStringMap
,
List
<
String
>
oneIdModelNames
)
{
List
<
String
>
oneIdFieldNames
=
OneIdBelongEnum
.
getOneIdFieldNames
();
List
<
String
>
oneIdFieldNames
=
OneIdBelongEnum
.
getOneIdFieldNames
();
for
(
String
oneIdFieldName
:
oneIdFieldNames
)
{
for
(
String
oneIdFieldName
:
oneIdFieldNames
)
{
if
(
jsonData
.
containsKey
(
oneIdFieldName
)
if
(
jsonData
.
containsKey
(
oneIdFieldName
)
...
@@ -548,6 +549,10 @@ public class DataReportRabbitMQConsumer {
...
@@ -548,6 +549,10 @@ public class DataReportRabbitMQConsumer {
log
.
info
(
"get oneId from model:{}, oneIdFieldName:{}, oneId:{}"
,
oneIdBelongEnum
.
getModelName
(),
oneIdFieldName
,
oneId
);
log
.
info
(
"get oneId from model:{}, oneIdFieldName:{}, oneId:{}"
,
oneIdBelongEnum
.
getModelName
(),
oneIdFieldName
,
oneId
);
oneIdBelongEnumStringMap
.
put
(
oneIdBelongEnum
,
oneId
);
oneIdBelongEnumStringMap
.
put
(
oneIdBelongEnum
,
oneId
);
oneIdModelNames
.
remove
(
oneIdBelongEnum
.
getModelName
());
oneIdModelNames
.
remove
(
oneIdBelongEnum
.
getModelName
());
log
.
info
(
"to avoid update by oneId,remove model:{} from matchModels"
,
oneIdBelongEnum
.
getModelName
());
matchModels
.
stream
().
filter
(
o
->
o
.
getModelName
().
equals
(
oneIdBelongEnum
.
getModelName
())).
findFirst
().
ifPresent
(
matchModels:
:
remove
);
}
else
{
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"oneId is not exist, oneIdFieldName:"
+
oneIdFieldName
+
", oneId:"
+
oneId
);
}
}
}
}
}
}
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdMappingService.java
View file @
8415a91
...
@@ -51,12 +51,13 @@ public class OneIdMappingService {
...
@@ -51,12 +51,13 @@ public class OneIdMappingService {
public
void
saveOneIdMapping
(
String
oneId
,
OneIdFieldConfigDTO
oneIdFieldConfigDTO
){
public
void
saveOneIdMapping
(
String
oneId
,
OneIdFieldConfigDTO
oneIdFieldConfigDTO
){
log
.
info
(
"saveOneIdMapping, oneId:{}, oneIdFieldConfigDTO:{}"
,
oneId
,
oneIdFieldConfigDTO
);
log
.
info
(
"saveOneIdMapping, oneId:{}, oneIdFieldConfigDTO:{}"
,
oneId
,
oneIdFieldConfigDTO
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getO
rgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.get
OrgId() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getO
neIdBelongOrgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getOneIdBelong
OrgId() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getBusinessType() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getBusinessType() not be null"
);
RpcAssert
.
assertNotEmpty
(
oneIdFieldConfigDTO
.
getFieldName
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getFieldName() not be empty"
);
RpcAssert
.
assertNotEmpty
(
oneIdFieldConfigDTO
.
getFieldName
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getFieldName() not be empty"
);
RpcAssert
.
assertNotEmpty
(
oneIdFieldConfigDTO
.
getFieldValue
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getFieldValue() not be empty"
);
RpcAssert
.
assertNotEmpty
(
oneIdFieldConfigDTO
.
getFieldValue
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getFieldValue() not be empty"
);
RpcAssert
.
assertNotEmpty
(
oneId
,
DefaultErrorEnum
.
DATA_NULL
,
"oneId not be empty"
);
RpcAssert
.
assertNotEmpty
(
oneId
,
DefaultErrorEnum
.
DATA_NULL
,
"oneId not be empty"
);
OneIdMappingDTO
record
=
OneIdMappingDTOConvert
.
INSTANCE
.
fromOneIdFieldConfig
(
oneId
,
oneIdFieldConfigDTO
,
Constants
.
DEFAULT_UPDATED_BY
);
OneIdMappingDTO
record
=
OneIdMappingDTOConvert
.
INSTANCE
.
fromOneIdFieldConfig
(
oneId
,
oneIdFieldConfigDTO
,
Constants
.
DEFAULT_UPDATED_BY
);
record
.
setOrgId
(
oneIdFieldConfigDTO
.
getOneIdBelongOrgId
());
record
.
setCreatedTime
(
new
Date
());
record
.
setCreatedTime
(
new
Date
());
record
.
setUpdatedTime
(
record
.
getCreatedTime
());
record
.
setUpdatedTime
(
record
.
getCreatedTime
());
try
{
try
{
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdService.java
View file @
8415a91
...
@@ -82,7 +82,7 @@ public class OneIdService {
...
@@ -82,7 +82,7 @@ public class OneIdService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
String
findOrCreateOneId
(
String
finalOneId
,
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
){
public
String
findOrCreateOneId
(
String
finalOneId
,
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
){
log
.
info
(
"findOrCreateOneId,finalOneId:{},fieldName:{}"
,
readyMatchOneIdFieldConfig
.
getFieldName
());
log
.
info
(
"findOrCreateOneId,finalOneId:{},fieldName:{}"
,
readyMatchOneIdFieldConfig
.
getFieldName
());
OneIdMappingDTO
oneIdMapping
=
oneIdMappingService
.
getOneIdMapping
(
readyMatchOneIdFieldConfig
.
getOrgId
(),
OneIdMappingDTO
oneIdMapping
=
oneIdMappingService
.
getOneIdMapping
(
readyMatchOneIdFieldConfig
.
getO
neIdBelongO
rgId
(),
readyMatchOneIdFieldConfig
.
getBusinessType
(),
readyMatchOneIdFieldConfig
.
getFieldName
(),
readyMatchOneIdFieldConfig
.
getBusinessType
(),
readyMatchOneIdFieldConfig
.
getFieldName
(),
readyMatchOneIdFieldConfig
.
getFieldValue
());
readyMatchOneIdFieldConfig
.
getFieldValue
());
if
(
oneIdMapping
==
null
)
{
if
(
oneIdMapping
==
null
)
{
...
@@ -122,6 +122,7 @@ public class OneIdService {
...
@@ -122,6 +122,7 @@ public class OneIdService {
.
filter
(
o
->
oneIdField
.
containsKey
(
o
.
getFieldName
()))
.
filter
(
o
->
oneIdField
.
containsKey
(
o
.
getFieldName
()))
.
map
(
o
->
{
.
map
(
o
->
{
o
.
setFieldValue
(
oneIdField
.
getString
(
o
.
getFieldName
()));
o
.
setFieldValue
(
oneIdField
.
getString
(
o
.
getFieldName
()));
o
.
setOneIdBelongOrgId
(
param
.
getOrgId
());
return
o
;
return
o
;
})
})
.
sorted
(
Comparator
.
comparing
(
OneIdFieldConfigDTO:
:
getPriority
))
.
sorted
(
Comparator
.
comparing
(
OneIdFieldConfigDTO:
:
getPriority
))
...
...
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