|
@@ -3,8 +3,11 @@ package com.shkpr.service.alambizplugin.components;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
+import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdExportParams;
|
|
|
+import com.shkpr.service.alambizplugin.commtools.CRSUtil;
|
|
|
import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
|
|
|
import com.shkpr.service.alambizplugin.constants.CommAsyncStatusEnum;
|
|
|
+import com.shkpr.service.alambizplugin.constants.CommCRSDefine;
|
|
|
import com.shkpr.service.alambizplugin.constants.FileTypeEnum;
|
|
|
import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
|
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyExcelDefine;
|
|
@@ -21,6 +24,8 @@ import org.apache.commons.compress.archivers.ArchiveException;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.geotools.data.DataUtilities;
|
|
|
import org.geotools.feature.SchemaException;
|
|
|
+import org.locationtech.jts.geom.Coordinate;
|
|
|
+import org.locationtech.jts.geom.Geometry;
|
|
|
import org.opengis.feature.simple.SimpleFeatureType;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.scheduling.annotation.AsyncResult;
|
|
@@ -28,6 +33,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.concurrent.ListenableFuture;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.time.Duration;
|
|
@@ -78,15 +84,18 @@ public class GisSurveyThirdExporter {
|
|
|
/**
|
|
|
* 第三方导出任务
|
|
|
*
|
|
|
- * @param jobId 任务id
|
|
|
- * @param fileType 导出文件类型
|
|
|
- * @param operator 操作人
|
|
|
+ * @param params 导出参数
|
|
|
* @return 导出结果
|
|
|
*/
|
|
|
@Async
|
|
|
- public ListenableFuture<CommAsyncResult<Map<String, String>>> thirdExportTask(String jobId, FileTypeEnum fileType, String operator) {
|
|
|
+ public ListenableFuture<CommAsyncResult<Map<String, String>>> thirdExportTask(GisSurveyThirdExportParams params) {
|
|
|
+ //参数
|
|
|
+ String jobId = params.getJobId();
|
|
|
+ FileTypeEnum fileType = params.getFileTypeEnum();
|
|
|
+ String targetCRSCode = params.getTargetCRSCode();
|
|
|
+ String operator = params.getOperator();
|
|
|
//构建返回
|
|
|
- CommAsyncResult<Map<String, String>> result = CommAsyncResult.fail(jobId);
|
|
|
+ CommAsyncResult<Map<String, String>> result = CommAsyncResult.fail(params.getJobId());
|
|
|
result.setOperator(operator);
|
|
|
try {
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
@@ -102,6 +111,9 @@ public class GisSurveyThirdExporter {
|
|
|
List<GisSurveyLayerApply> points = gisSurveyLayerApplyService.findAllByJobIdAndKind(jobId, GisMetadataDefine.TYPE_KINE.POINT);
|
|
|
List<GisSurveyLayerApply> lines = gisSurveyLayerApplyService.findAllByJobIdAndKind(jobId, GisMetadataDefine.TYPE_KINE.LINE);
|
|
|
|
|
|
+ //处理坐标系
|
|
|
+ if (!Objects.equals(targetCRSCode, CommCRSDefine.CGCS2000)) transformGeom(targetCRSCode, points, lines);
|
|
|
+
|
|
|
//获取图层key
|
|
|
List<String> pointLayer = getLayerKeys(points);
|
|
|
List<String> lineLayer = getLayerKeys(lines);
|
|
@@ -184,6 +196,50 @@ public class GisSurveyThirdExporter {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 转换geom
|
|
|
+ *
|
|
|
+ * @param targetCRSCode 目标坐标系
|
|
|
+ * @param points 点集合
|
|
|
+ * @param lines 线结合
|
|
|
+ */
|
|
|
+ private void transformGeom(String targetCRSCode, List<GisSurveyLayerApply> points, List<GisSurveyLayerApply> lines) {
|
|
|
+ //处理点
|
|
|
+ points.parallelStream().forEach(point -> {
|
|
|
+ //获取geom
|
|
|
+ Geometry geometry = point.getGis();
|
|
|
+ if (geometry == null) return;
|
|
|
+ //转换geom
|
|
|
+ Geometry transform = CRSUtil.transform(geometry, CommCRSDefine.CGCS2000, targetCRSCode);
|
|
|
+ if (transform == null) return;
|
|
|
+ //回填元素
|
|
|
+ point.setGis(transform);
|
|
|
+ //获取解析后的经纬度
|
|
|
+ Coordinate coordinate = transform.getCoordinate();
|
|
|
+ String lngStr = BigDecimal.valueOf(coordinate.getX()).toPlainString();
|
|
|
+ String latStr = BigDecimal.valueOf(coordinate.getY()).toPlainString();
|
|
|
+ //回填经纬度属性
|
|
|
+ List<GisSurveyPropertyValue> propertyValues = point.getPropertyValues();
|
|
|
+ propertyValues.stream()
|
|
|
+ .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.LAT))
|
|
|
+ .forEach(it -> it.setValue(latStr));
|
|
|
+ propertyValues.stream()
|
|
|
+ .filter(it -> Objects.equals(it.getProperty(), GisSurveyExcelDefine.TEMPLATE.LNG))
|
|
|
+ .forEach(it -> it.setValue(lngStr));
|
|
|
+ });
|
|
|
+ //处理线
|
|
|
+ lines.parallelStream().forEach(line -> {
|
|
|
+ //获取geom
|
|
|
+ Geometry geometry = line.getGis();
|
|
|
+ if (geometry == null) return;
|
|
|
+ //转换geom
|
|
|
+ Geometry transform = CRSUtil.transform(geometry, CommCRSDefine.CGCS2000, targetCRSCode);
|
|
|
+ if (transform == null) return;
|
|
|
+ //回填元素
|
|
|
+ line.setGis(transform);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 导出excel
|
|
|
*
|
|
|
* @param points 点
|