|
@@ -4,6 +4,7 @@ import com.global.base.log.LogLevelFlag;
|
|
import com.global.base.log.LogPrintMgr;
|
|
import com.global.base.log.LogPrintMgr;
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
|
|
import com.shkpr.service.alambizplugin.commtools.ExcelUtils;
|
|
import com.shkpr.service.alambizplugin.commtools.ExcelUtils;
|
|
|
|
+import com.shkpr.service.alambizplugin.commtools.PointCodeUtil;
|
|
import com.shkpr.service.alambizplugin.components.checker.DuplicatePointsFinder;
|
|
import com.shkpr.service.alambizplugin.components.checker.DuplicatePointsFinder;
|
|
import com.shkpr.service.alambizplugin.components.checker.InvalidLinesFinder;
|
|
import com.shkpr.service.alambizplugin.components.checker.InvalidLinesFinder;
|
|
import com.shkpr.service.alambizplugin.components.checker.InvalidPropertiesFinder;
|
|
import com.shkpr.service.alambizplugin.components.checker.InvalidPropertiesFinder;
|
|
@@ -14,12 +15,18 @@ import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyImportStatusEnum;
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyImportStatusEnum;
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisMetadataLayerTemplateService;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisMetadataLayerTemplateService;
|
|
|
|
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyThirdCopyService;
|
|
import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
|
|
import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
|
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
|
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
|
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResult;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResult;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportSubtask;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportSubtask;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
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;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.AsyncResult;
|
|
import org.springframework.scheduling.annotation.AsyncResult;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -30,8 +37,11 @@ import java.io.InputStream;
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.function.Consumer;
|
|
import java.util.function.Consumer;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -50,16 +60,18 @@ public class GisSurveyThirdImporter {
|
|
*/
|
|
*/
|
|
private final String mStrClassName;
|
|
private final String mStrClassName;
|
|
private final String mBizType;
|
|
private final String mBizType;
|
|
-
|
|
|
|
private final GisMetadataLayerTemplateService layerTemplateService;
|
|
private final GisMetadataLayerTemplateService layerTemplateService;
|
|
|
|
+ private final GisSurveyLayerApplyThirdCopyService gisSurveyLayerApplyThirdCopyService;
|
|
private final DuplicatePointsFinder duplicatePointsFinder;
|
|
private final DuplicatePointsFinder duplicatePointsFinder;
|
|
private final InvalidLinesFinder invalidLinesFinder;
|
|
private final InvalidLinesFinder invalidLinesFinder;
|
|
private final InvalidPropertiesFinder invalidPropertiesFinder;
|
|
private final InvalidPropertiesFinder invalidPropertiesFinder;
|
|
|
|
|
|
- public GisSurveyThirdImporter(GisMetadataLayerTemplateService layerTemplateService, DuplicatePointsFinder duplicatePointsFinder, InvalidLinesFinder invalidLinesFinder, InvalidPropertiesFinder invalidPropertiesFinder) {
|
|
|
|
|
|
+ public GisSurveyThirdImporter(GisMetadataLayerTemplateService layerTemplateService, GisSurveyLayerApplyThirdCopyService gisSurveyLayerApplyThirdCopyService
|
|
|
|
+ , DuplicatePointsFinder duplicatePointsFinder, InvalidLinesFinder invalidLinesFinder, InvalidPropertiesFinder invalidPropertiesFinder) {
|
|
mStrClassName = "GisSurveyThirdImporter";
|
|
mStrClassName = "GisSurveyThirdImporter";
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
this.layerTemplateService = layerTemplateService;
|
|
this.layerTemplateService = layerTemplateService;
|
|
|
|
+ this.gisSurveyLayerApplyThirdCopyService = gisSurveyLayerApplyThirdCopyService;
|
|
this.duplicatePointsFinder = duplicatePointsFinder;
|
|
this.duplicatePointsFinder = duplicatePointsFinder;
|
|
this.invalidLinesFinder = invalidLinesFinder;
|
|
this.invalidLinesFinder = invalidLinesFinder;
|
|
this.invalidPropertiesFinder = invalidPropertiesFinder;
|
|
this.invalidPropertiesFinder = invalidPropertiesFinder;
|
|
@@ -102,10 +114,10 @@ public class GisSurveyThirdImporter {
|
|
|
|
|
|
//提取图层名
|
|
//提取图层名
|
|
List<String> pointLayerNames = getLayerNames(points, GisSurveyImportDefine.POINT.LAYER);
|
|
List<String> pointLayerNames = getLayerNames(points, GisSurveyImportDefine.POINT.LAYER);
|
|
- List<String> listLayerNames = getLayerNames(lines, GisSurveyImportDefine.LINE.LAYER);
|
|
|
|
|
|
+ List<String> lineLayerNames = getLayerNames(lines, GisSurveyImportDefine.LINE.LAYER);
|
|
//图层模版
|
|
//图层模版
|
|
List<GisMetadataLayerTemplate> pointLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), pointLayerNames);
|
|
List<GisMetadataLayerTemplate> pointLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), pointLayerNames);
|
|
- List<GisMetadataLayerTemplate> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), listLayerNames);
|
|
|
|
|
|
+ List<GisMetadataLayerTemplate> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), lineLayerNames);
|
|
|
|
|
|
//无效属性检查
|
|
//无效属性检查
|
|
invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines, pointLayerTemplates, lineLayerTemplates);
|
|
invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines, pointLayerTemplates, lineLayerTemplates);
|
|
@@ -140,11 +152,20 @@ public class GisSurveyThirdImporter {
|
|
return new AsyncResult<>(result);
|
|
return new AsyncResult<>(result);
|
|
}
|
|
}
|
|
|
|
|
|
- //格式化数据,并入库
|
|
|
|
|
|
+ //解码点线数据
|
|
|
|
+ List<GisSurveyLayerApplyThirdCopy> layerApplyList = decodeDataToLayerApply(points, lines, pointLayerTemplates, lineLayerTemplates, params);
|
|
|
|
+ //批量写入
|
|
|
|
+ Boolean saved = gisSurveyLayerApplyThirdCopyService.saveAll(params.getJobId(), layerApplyList);
|
|
|
|
+ if (!saved) {
|
|
|
|
+ //弃用子任务
|
|
|
|
+ onDeprecatedSubtask.accept(params.getJobId());
|
|
|
|
+ return new AsyncResult<>(result);
|
|
|
|
+ }
|
|
|
|
|
|
//完成任务
|
|
//完成任务
|
|
result.setImportStatus(GisSurveyImportStatusEnum.SUCCESS.getCode());
|
|
result.setImportStatus(GisSurveyImportStatusEnum.SUCCESS.getCode());
|
|
result.setCompleteTime(LocalDateTime.now());
|
|
result.setCompleteTime(LocalDateTime.now());
|
|
|
|
+ result.setPreviewData(layerApplyList);
|
|
|
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
, String.format(
|
|
, String.format(
|
|
@@ -266,4 +287,178 @@ public class GisSurveyThirdImporter {
|
|
CollectionUtils.isEmpty(invalidTypesResult) && CollectionUtils.isEmpty(outRanges) &&
|
|
CollectionUtils.isEmpty(invalidTypesResult) && CollectionUtils.isEmpty(outRanges) &&
|
|
CollectionUtils.isEmpty(duplicatePoints) && CollectionUtils.isEmpty(invalidLines);
|
|
CollectionUtils.isEmpty(duplicatePoints) && CollectionUtils.isEmpty(invalidLines);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解码数据到采集元素对象
|
|
|
|
+ * <p>从Map转为 {@code GisSurveyLayerApplyThirdCopy}</p>
|
|
|
|
+ *
|
|
|
|
+ * @param points 点数据
|
|
|
|
+ * @param lines 线数据
|
|
|
|
+ * @param pointLayerTemplates 点图层模版
|
|
|
|
+ * @param lineLayerTemplates 线图层模版
|
|
|
|
+ * @param params 导入参数
|
|
|
|
+ * @return 格式化后数据
|
|
|
|
+ */
|
|
|
|
+ private List<GisSurveyLayerApplyThirdCopy> decodeDataToLayerApply(List<Map<String, String>> points, List<Map<String, String>> lines
|
|
|
|
+ , List<GisMetadataLayerTemplate> pointLayerTemplates, List<GisMetadataLayerTemplate> lineLayerTemplates, GisSurveyThirdImportParams params) {
|
|
|
|
+ //按模版名分组,便于快速找到模版
|
|
|
|
+ Map<String, GisMetadataLayerTemplate> poineTemplateMap = pointLayerTemplates.stream()
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
+ GisMetadataLayerTemplate::getName, it -> it,
|
|
|
|
+ (it1, it2) -> it1
|
|
|
|
+ ));
|
|
|
|
+ Map<String, GisMetadataLayerTemplate> lineTemplateMap = lineLayerTemplates.stream()
|
|
|
|
+ .collect(Collectors.toMap(
|
|
|
|
+ GisMetadataLayerTemplate::getName, it -> it,
|
|
|
|
+ (it1, it2) -> it1
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ //采集元素象集合
|
|
|
|
+ List<GisSurveyLayerApplyThirdCopy> result = new ArrayList<>();
|
|
|
|
+ //点号映射,用于线写入上下游节点
|
|
|
|
+ Map<String, String> pointNoMapping = new HashMap<>();
|
|
|
|
+ //格式化点
|
|
|
|
+ for (Map<String, String> point : points) {
|
|
|
|
+ //获取模版
|
|
|
|
+ GisMetadataLayerTemplate layerTemplate = poineTemplateMap.get(point.get(GisSurveyImportDefine.POINT.LAYER));
|
|
|
|
+ //解码点对象
|
|
|
|
+ GisSurveyLayerApplyThirdCopy layerApply = decodePointToLayerApply(point, layerTemplate, params);
|
|
|
|
+ //存入点号
|
|
|
|
+ pointNoMapping.put(layerApply.getNo(), layerApply.getCode());
|
|
|
|
+
|
|
|
|
+ result.add(layerApply);
|
|
|
|
+ }
|
|
|
|
+ //格式化线
|
|
|
|
+ for (Map<String, String> line : lines) {
|
|
|
|
+ //获取模版
|
|
|
|
+ GisMetadataLayerTemplate layerTemplate = lineTemplateMap.get(line.get(GisSurveyImportDefine.LINE.LAYER));
|
|
|
|
+ //解码对象
|
|
|
|
+ GisSurveyLayerApplyThirdCopy layerApply = decodeLineToLayerApply(line, layerTemplate, params, pointNoMapping);
|
|
|
|
+
|
|
|
|
+ result.add(layerApply);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解码点数据到采集元素对象
|
|
|
|
+ *
|
|
|
|
+ * @param point 点数据
|
|
|
|
+ * @param layerTemplate 图层模版
|
|
|
|
+ * @param params 导入参数
|
|
|
|
+ * @return 采集元素拷贝对象
|
|
|
|
+ */
|
|
|
|
+ private GisSurveyLayerApplyThirdCopy decodePointToLayerApply(Map<String, String> point, GisMetadataLayerTemplate layerTemplate, GisSurveyThirdImportParams params) {
|
|
|
|
+ GisSurveyLayerApplyThirdCopy layerApply = new GisSurveyLayerApplyThirdCopy();
|
|
|
|
+ //必填项
|
|
|
|
+ layerApply.setJobId(params.getJobId());
|
|
|
|
+ layerApply.setCode(PointCodeUtil.generateCode());
|
|
|
|
+ layerApply.setLayer(layerTemplate.getKey());
|
|
|
|
+ layerApply.setKind(GisMetadataDefine.TYPE_KINE.POINT);
|
|
|
|
+ //解析坐标
|
|
|
|
+ double[] coordinate = {Double.parseDouble(point.get(GisSurveyImportDefine.POINT.LNG)),
|
|
|
|
+ Double.parseDouble(point.get(GisSurveyImportDefine.POINT.LAT))};
|
|
|
|
+ layerApply.setGis(Arrays.toString(coordinate));
|
|
|
|
+ //默认值
|
|
|
|
+ layerApply.setApply(GisSurveyImportDefine.DEFAULT_VALUE.APPLY);
|
|
|
|
+ layerApply.setSource(GisSurveyImportDefine.DEFAULT_VALUE.SOURCE);
|
|
|
|
+ //高程和埋深
|
|
|
|
+ String elevationStr = point.get(GisSurveyImportDefine.POINT.ELEVATION);
|
|
|
|
+ if (NumberUtils.isParsable(elevationStr))
|
|
|
|
+ layerApply.setElevation(Double.parseDouble(elevationStr));
|
|
|
|
+ String depthStr = point.get(GisSurveyImportDefine.POINT.DEPTH);
|
|
|
|
+ if (NumberUtils.isParsable(depthStr))
|
|
|
|
+ layerApply.setDepth(Double.parseDouble(depthStr));
|
|
|
|
+ //点号
|
|
|
|
+ layerApply.setNo(point.get(GisSurveyImportDefine.POINT.NO));
|
|
|
|
+ //遍历属性模版
|
|
|
|
+ List<GisSurveyPropertyValueThirdCopy> propertyValueList = new ArrayList<>();
|
|
|
|
+ for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
|
|
|
|
+ //解析属性
|
|
|
|
+ GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(point, layerApply
|
|
|
|
+ , propertyTemplate, params, GisSurveyImportDefine.LayerType.POINT);
|
|
|
|
+ if (propertyValue != null) propertyValueList.add(propertyValue);
|
|
|
|
+ }
|
|
|
|
+ layerApply.setPropertyValueList(propertyValueList);
|
|
|
|
+
|
|
|
|
+ return layerApply;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解码线数据到采集元素对象
|
|
|
|
+ *
|
|
|
|
+ * @param line 线数据
|
|
|
|
+ * @param layerTemplate 图层模版
|
|
|
|
+ * @param params 导入参数
|
|
|
|
+ * @param pointNoMapping 点号映射
|
|
|
|
+ * @return 采集元素拷贝对象
|
|
|
|
+ */
|
|
|
|
+ private GisSurveyLayerApplyThirdCopy decodeLineToLayerApply(Map<String, String> line, GisMetadataLayerTemplate layerTemplate, GisSurveyThirdImportParams params, Map<String, String> pointNoMapping) {
|
|
|
|
+ GisSurveyLayerApplyThirdCopy layerApply = new GisSurveyLayerApplyThirdCopy();
|
|
|
|
+ //必填项
|
|
|
|
+ layerApply.setJobId(params.getJobId());
|
|
|
|
+ layerApply.setCode(PointCodeUtil.generateCode());
|
|
|
|
+ layerApply.setLayer(layerTemplate.getKey());
|
|
|
|
+ layerApply.setKind(GisMetadataDefine.TYPE_KINE.LINE);
|
|
|
|
+ //默认值
|
|
|
|
+ layerApply.setApply(GisSurveyImportDefine.DEFAULT_VALUE.APPLY);
|
|
|
|
+ layerApply.setSource(GisSurveyImportDefine.DEFAULT_VALUE.SOURCE);
|
|
|
|
+ //上下游节点
|
|
|
|
+ layerApply.setUpNode(pointNoMapping.get(line.get(GisSurveyImportDefine.LINE.UP_NO)));
|
|
|
|
+ layerApply.setDownNode(pointNoMapping.get(line.get(GisSurveyImportDefine.LINE.DOWN_NO)));
|
|
|
|
+ //遍历属性模版
|
|
|
|
+ List<GisSurveyPropertyValueThirdCopy> propertyValueList = new ArrayList<>();
|
|
|
|
+ for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
|
|
|
|
+ //解析属性
|
|
|
|
+ GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(line, layerApply, propertyTemplate, params, GisSurveyImportDefine.LayerType.LINE);
|
|
|
|
+ if (propertyValue != null) propertyValueList.add(propertyValue);
|
|
|
|
+ }
|
|
|
|
+ layerApply.setPropertyValueList(propertyValueList);
|
|
|
|
+
|
|
|
|
+ return layerApply;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解码数据到属性值对象
|
|
|
|
+ *
|
|
|
|
+ * @param data 数据
|
|
|
|
+ * @param layerApply 采集元素
|
|
|
|
+ * @param propertyTemplate 属性模版
|
|
|
|
+ * @param params 导出参数
|
|
|
|
+ * @param layerType 图层类型
|
|
|
|
+ * @return 属性值对象
|
|
|
|
+ */
|
|
|
|
+ private GisSurveyPropertyValueThirdCopy decodeDataToPropertyValue(Map<String, String> data, GisSurveyLayerApplyThirdCopy layerApply
|
|
|
|
+ , GisMetadataPropertyTemplate propertyTemplate, GisSurveyThirdImportParams params, GisSurveyImportDefine.LayerType layerType) {
|
|
|
|
+ //点号直接返回点号属性
|
|
|
|
+ if (Objects.equals(GisSurveyImportDefine.TEMPLATE.CODE, propertyTemplate.getKey()))
|
|
|
|
+ return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode()
|
|
|
|
+ , propertyTemplate.getKey(), layerApply.getCode());
|
|
|
|
+ //根据图层类型和模版映射,获取表头
|
|
|
|
+ String templateName = propertyTemplate.getName();
|
|
|
|
+ if (layerType == GisSurveyImportDefine.LayerType.POINT)
|
|
|
|
+ switch (propertyTemplate.getKey()) {
|
|
|
|
+ case GisSurveyImportDefine.TEMPLATE.LNG:
|
|
|
|
+ templateName = GisSurveyImportDefine.POINT.LNG;
|
|
|
|
+ break;
|
|
|
|
+ case GisSurveyImportDefine.TEMPLATE.LAT:
|
|
|
|
+ templateName = GisSurveyImportDefine.POINT.LAT;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (layerType == GisSurveyImportDefine.LayerType.LINE)
|
|
|
|
+ switch (propertyTemplate.getKey()) {
|
|
|
|
+ case GisSurveyImportDefine.TEMPLATE.UP_NODE:
|
|
|
|
+ templateName = GisSurveyImportDefine.LINE.UP_NO;
|
|
|
|
+ break;
|
|
|
|
+ case GisSurveyImportDefine.TEMPLATE.DOWN_NODE:
|
|
|
|
+ templateName = GisSurveyImportDefine.LINE.DOWN_NO;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //获取值
|
|
|
|
+ String value = data.get(templateName);
|
|
|
|
+ if (StringUtils.isNotBlank(value)) return new GisSurveyPropertyValueThirdCopy(params.getJobId()
|
|
|
|
+ , layerApply.getCode(), propertyTemplate.getKey(), value);
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|