|
@@ -2,6 +2,7 @@ package com.shkpr.service.alambizplugin.components.checker;
|
|
|
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
+import com.shkpr.service.alambizplugin.commtools.BeanUtil;
|
|
|
import com.shkpr.service.alambizplugin.commtools.GeomUtil;
|
|
|
import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
|
|
|
import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
|
|
@@ -9,8 +10,10 @@ import com.shkpr.service.alambizplugin.constants.GisSurveyExcelDefine;
|
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -23,6 +26,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 无效属性查找器
|
|
@@ -57,12 +61,14 @@ public class InvalidPropertiesFinder {
|
|
|
* @param lines 线集合
|
|
|
* @param pointLayerTemplates 点图层模版集合
|
|
|
* @param lineLayerTemplates 线图层模版集合
|
|
|
+ * @param checkConstraint 检查约束
|
|
|
+ * @param projectConstraints 项目约束条件
|
|
|
* @return 重复点
|
|
|
*/
|
|
|
@Async
|
|
|
public ListenableFuture<GisSurveyThirdImportResultDetail<Map<String, List<GisSurveyThirdImportElement>>>> findInvalidProperties(
|
|
|
List<Map<String, String>> points, List<Map<String, String>> lines, List<GisMetadataLayerTemplate> pointLayerTemplates
|
|
|
- , List<GisMetadataLayerTemplate> lineLayerTemplates) throws InterruptedException {
|
|
|
+ , List<GisMetadataLayerTemplate> lineLayerTemplates, Boolean checkConstraint, List<GisSurveyCondition> projectConstraints) throws InterruptedException {
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找无效属性 ======>");
|
|
|
long begin = System.currentTimeMillis();
|
|
|
|
|
@@ -74,6 +80,8 @@ public class InvalidPropertiesFinder {
|
|
|
List<GisSurveyThirdImportElement> invalidTypesResult = new ArrayList<>();
|
|
|
//超出范围结果
|
|
|
List<GisSurveyThirdImportElement> outRangesResult = new ArrayList<>();
|
|
|
+ //超出约束结果
|
|
|
+ List<GisSurveyThirdImportElement> outConstraintResult = new ArrayList<>();
|
|
|
//检查点属性
|
|
|
for (Map<String, String> point : points) {
|
|
|
//响应中断
|
|
@@ -91,7 +99,7 @@ public class InvalidPropertiesFinder {
|
|
|
));
|
|
|
else
|
|
|
//图层存在则检查图层
|
|
|
- checkLayer(point, layerTemplate, missingRequirementsResult, invalidTypesResult);
|
|
|
+ checkLayer(point, layerTemplate, checkConstraint, projectConstraints, missingRequirementsResult, invalidTypesResult, outConstraintResult);
|
|
|
//检查坐标超出范围
|
|
|
if (checkOutRanges(point, layerTemplate))
|
|
|
outRangesResult.add(
|
|
@@ -121,7 +129,7 @@ public class InvalidPropertiesFinder {
|
|
|
));
|
|
|
else
|
|
|
//图层存在则检查图层
|
|
|
- checkLayer(line, layerTemplate, missingRequirementsResult, invalidTypesResult);
|
|
|
+ checkLayer(line, layerTemplate, checkConstraint, projectConstraints, missingRequirementsResult, invalidTypesResult, outConstraintResult);
|
|
|
}
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
@@ -138,6 +146,7 @@ public class InvalidPropertiesFinder {
|
|
|
result.put(GisSurveyExcelDefine.RESULT.MISSING_REQUIREMENTS, missingRequirementsResult);
|
|
|
result.put(GisSurveyExcelDefine.RESULT.INVALID_TYPES, invalidTypesResult);
|
|
|
result.put(GisSurveyExcelDefine.RESULT.OUT_RANGES, outRangesResult);
|
|
|
+ result.put(GisSurveyExcelDefine.RESULT.OUT_CONSTRAINT, outConstraintResult);
|
|
|
return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(true, result));
|
|
|
}
|
|
|
|
|
@@ -167,39 +176,123 @@ public class InvalidPropertiesFinder {
|
|
|
*
|
|
|
* @param data 数据
|
|
|
* @param layerTemplate 图层模版
|
|
|
+ * @param checkConstraint 检查超出约束
|
|
|
+ * @param projectConstraints 项目约束
|
|
|
* @param missingRequirementsResult 缺少必填结果
|
|
|
* @param invalidTypesResult 无效类型结果
|
|
|
+ * @param outConstraintResult 超出约束结果
|
|
|
*/
|
|
|
public void checkLayer(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
|
|
|
- , List<GisSurveyThirdImportElement> missingRequirementsResult
|
|
|
- , List<GisSurveyThirdImportElement> invalidTypesResult) {
|
|
|
+ , Boolean checkConstraint, List<GisSurveyCondition> projectConstraints, List<GisSurveyThirdImportElement> missingRequirementsResult
|
|
|
+ , List<GisSurveyThirdImportElement> invalidTypesResult, List<GisSurveyThirdImportElement> outConstraintResult) {
|
|
|
+ //项目约束映射
|
|
|
+ Map<String, GisSurveyCondition> projectConstraintsMapping = projectConstraints.stream()
|
|
|
+ .collect(Collectors.toMap(GisSurveyCondition::getProperty, it -> it));
|
|
|
//遍历图层属性模版
|
|
|
for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
|
|
|
- //排除非必填
|
|
|
- if (propertyTemplate.getRequired() != 1 || propertyTemplate.getStatus() != 1)
|
|
|
- continue;
|
|
|
//排除编码
|
|
|
if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.CODE, propertyTemplate.getKey())
|
|
|
|| Objects.equals(GisSurveyExcelDefine.TEMPLATE.UP_NODE, propertyTemplate.getKey())
|
|
|
|| Objects.equals(GisSurveyExcelDefine.TEMPLATE.DOWN_NODE, propertyTemplate.getKey()))
|
|
|
continue;
|
|
|
- //模版名称
|
|
|
- String templateName = propertyTemplate.getName();
|
|
|
- //必填不存在则存入缺少必填
|
|
|
- if (data.get(templateName) == null || StringUtils.isBlank(data.get(templateName))) {
|
|
|
- GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
|
|
|
- layerTemplate,
|
|
|
- propertyTemplate.getName()
|
|
|
+ //当前属性值
|
|
|
+ String value = data.get(propertyTemplate.getName());
|
|
|
+ //必填
|
|
|
+ if (propertyTemplate.getRequired() == 1 && propertyTemplate.getStatus() == 1) {
|
|
|
+ //值不存在则存入缺少必填
|
|
|
+ if (StringUtils.isBlank(value)) {
|
|
|
+ GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
|
|
|
+ layerTemplate,
|
|
|
+ propertyTemplate.getName()
|
|
|
+ );
|
|
|
+ missingRequirementsResult.add(gisSurveyThirdImportElement);
|
|
|
+ //值存在
|
|
|
+ } else {
|
|
|
+ //判断超出约束
|
|
|
+ checkOutConstraint(
|
|
|
+ projectConstraintsMapping.get(propertyTemplate.getKey()),
|
|
|
+ data, layerTemplate, propertyTemplate, value, outConstraintResult
|
|
|
+ );
|
|
|
+ //判断数字类型
|
|
|
+ if ((GisSurveyExcelDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
|
|
|
+ GisSurveyExcelDefine.DATA_TYPE.DOUBLE.equals(propertyTemplate.getType()))
|
|
|
+ && !NumberUtils.isParsable(value)) {
|
|
|
+ invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
|
|
|
+ layerTemplate,
|
|
|
+ propertyTemplate.getName()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //非必填
|
|
|
+ else {
|
|
|
+ //判断超出约束
|
|
|
+ if (checkConstraint && StringUtils.isNotBlank(value)) checkOutConstraint(
|
|
|
+ projectConstraintsMapping.get(propertyTemplate.getKey()),
|
|
|
+ data, layerTemplate, propertyTemplate, value, outConstraintResult
|
|
|
);
|
|
|
- missingRequirementsResult.add(gisSurveyThirdImportElement);
|
|
|
- } else if ((GisSurveyExcelDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
|
|
|
- GisSurveyExcelDefine.DATA_TYPE.DOUBLE.equals(propertyTemplate.getType()))
|
|
|
- && !NumberUtils.isParsable(data.get(templateName)))
|
|
|
- //存在且类型为数字,则判断数字类型
|
|
|
- invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
|
|
|
- layerTemplate,
|
|
|
- propertyTemplate.getName()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查超出约束
|
|
|
+ *
|
|
|
+ * @param projectConstraint 项目约束
|
|
|
+ * @param data 数据
|
|
|
+ * @param layerTemplate 图层模版
|
|
|
+ * @param propertyTemplate 属性模版
|
|
|
+ * @param value 值
|
|
|
+ * @param outConstraintResult 超出约束结果
|
|
|
+ */
|
|
|
+ public void checkOutConstraint(GisSurveyCondition projectConstraint, Map<String, String> data
|
|
|
+ , GisMetadataLayerTemplate layerTemplate, GisMetadataPropertyTemplate propertyTemplate
|
|
|
+ , String value, List<GisSurveyThirdImportElement> outConstraintResult) {
|
|
|
+ GisSurveyCondition constraint = null;
|
|
|
+ //模版约束
|
|
|
+ if (StringUtils.isNotBlank(propertyTemplate.getMode()) && CollectionUtils.isNotEmpty(propertyTemplate.getRanges())) {
|
|
|
+ constraint = BeanUtil.copy(propertyTemplate, GisSurveyCondition.class);
|
|
|
+ }
|
|
|
+ //项目约束
|
|
|
+ if (projectConstraint != null) {
|
|
|
+ constraint = projectConstraint;
|
|
|
+ }
|
|
|
+ if (constraint == null || StringUtils.isBlank(value)) return;
|
|
|
+ //约束模式
|
|
|
+ String mode = constraint.getMode();
|
|
|
+ //约束范围
|
|
|
+ List<String> ranges = constraint.getRanges();
|
|
|
+ if (StringUtils.isBlank(mode) || CollectionUtils.isEmpty(ranges)) return;
|
|
|
+ //列表约束
|
|
|
+ if (Objects.equals("list", constraint.getMode())) {
|
|
|
+ //如列表不包含值,则超出约束
|
|
|
+ if (!ranges.contains(value)) {
|
|
|
+ outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
|
|
|
+ propertyTemplate.getName(), value, constraint
|
|
|
));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //极值约束
|
|
|
+ else if (Objects.equals("extremum", constraint.getMode())) {
|
|
|
+ if (ranges.size() != 2) return;
|
|
|
+ //最小值判断
|
|
|
+ String minStr = ranges.get(0);
|
|
|
+ if (StringUtils.isNotBlank(minStr) && NumberUtils.isParsable(minStr)) {
|
|
|
+ double min = Double.parseDouble(minStr);
|
|
|
+ if (!NumberUtils.isParsable(value) || Double.parseDouble(value) < min) {
|
|
|
+ outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
|
|
|
+ propertyTemplate.getName(), value, constraint));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //最大值判断
|
|
|
+ String maxStr = ranges.get(1);
|
|
|
+ if (StringUtils.isNotBlank(maxStr) && NumberUtils.isParsable(maxStr)) {
|
|
|
+ double max = Double.parseDouble(maxStr);
|
|
|
+ if (!NumberUtils.isParsable(value) || Double.parseDouble(value) > max) {
|
|
|
+ outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
|
|
|
+ propertyTemplate.getName(), value, constraint));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|