Commit 42c0ddca by ThomasAdv

模型匹配,uniqueFlag对应字段值为空则不匹配模型

1 parent eabb6bd3
...@@ -580,6 +580,7 @@ public class DataReportRabbitMQConsumer { ...@@ -580,6 +580,7 @@ public class DataReportRabbitMQConsumer {
} }
List<ModelFieldMappingDTO> modelFieldMappings = model.getModelFieldMappings(); List<ModelFieldMappingDTO> modelFieldMappings = model.getModelFieldMappings();
if (CollectionUtils.isNotEmpty(modelFieldMappings)) { if (CollectionUtils.isNotEmpty(modelFieldMappings)) {
if(allUniqueFieldNotEmpty(modelFieldMappings, jsonData)){
List<ModelFieldMappingDTO> oneIdFields = modelFieldMappings.stream() List<ModelFieldMappingDTO> oneIdFields = modelFieldMappings.stream()
.filter(modelFieldMapping -> modelFieldMapping.getOneidFlag() != null .filter(modelFieldMapping -> modelFieldMapping.getOneidFlag() != null
&& modelFieldMapping.getOneidFlag()) && modelFieldMapping.getOneidFlag())
...@@ -595,6 +596,10 @@ public class DataReportRabbitMQConsumer { ...@@ -595,6 +596,10 @@ public class DataReportRabbitMQConsumer {
matchModels.add(model); matchModels.add(model);
} }
} }
}else {
log.error("model:{} unique field is empty, not match", model.getModelName());
}
} }
} }
List<String> modelNames = matchModels.stream().map(ModelDTO::getModelName).collect(Collectors.toList()); List<String> modelNames = matchModels.stream().map(ModelDTO::getModelName).collect(Collectors.toList());
...@@ -607,6 +612,28 @@ public class DataReportRabbitMQConsumer { ...@@ -607,6 +612,28 @@ public class DataReportRabbitMQConsumer {
return matchModels; return matchModels;
} }
private boolean allUniqueFieldNotEmpty(List<ModelFieldMappingDTO> modelFieldMappings, JSONObject jsonData) {
if (CollectionUtils.isNotEmpty(modelFieldMappings)) {
return modelFieldMappings.stream().noneMatch(o->{
if (o.getUniqueFlag() != null && o.getUniqueFlag()
&& !OneIdBelongEnum.getOneIdFieldNames().contains(o.getFieldName())) {
Object fieldValue = jsonData.get(o.getFieldName());
if (fieldValue instanceof String) {
if (StringUtils.isBlank((String) fieldValue)) {
log.info("model:{} unique field:{} is empty, not match", o.getModelName(), o.getFieldName());
return true;
}
}else if(fieldValue == null){
log.info("model:{} unique field:{} is null, not match", o.getModelName(), o.getFieldName());
return true;
}
}
return false;
});
}
return true;
}
/** /**
* 匹配模型标识字段 * 匹配模型标识字段
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!