Parcourir la source

实现第三方导入数据存入副表

欧阳劲驰 il y a 2 mois
Parent
commit
8361ec55f5

+ 5 - 5
sql.properties

@@ -1,4 +1,4 @@
-spring.datasource.data.jdbc-url=jdbc:postgresql://140.246.183.164:5432/water_smart_develop_branch?useSSL=false&useAffectedRows=false&allowMultiQueries=true
+spring.datasource.data.jdbc-url=jdbc:postgresql://140.246.183.164:5432/water_smart_develop_branch?useSSL=false&useAffectedRows=false&allowMultiQueries=true&rewriteBatchedStatements=true
 spring.datasource.data.username=postgres
 spring.datasource.data.password=kpr.23417.postgres
 
@@ -15,9 +15,9 @@ spring.datasource.data.test-while-idle=true
 spring.datasource.data.max-lifetime=120000
 spring.datasource.data.idle-timeout=30000
 spring.datasource.data.connection-timeout=30000
-# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+# 锟斤拷锟矫硷拷锟斤拷锟矫才斤拷锟斤拷一锟轿硷拷猓�拷锟斤拷锟斤拷要锟截闭的匡拷锟斤拷锟斤拷锟接o拷锟斤拷位锟角猴拷锟斤拷
 spring.datasource.data.time-between-eviction-runs-millis=60000
-# 配置一个连接在池中最小生存的时间,单位是毫秒
+# ����һ�������ڳ�����С�����ʱ�䣬��λ�Ǻ���
 spring.datasource.data.minEvictableIdleTimeMillis=300000
 
 
@@ -37,7 +37,7 @@ spring.datasource.data2.test-while-idle=true
 spring.datasource.data2.max-lifetime=120000
 spring.datasource.data2.idle-timeout=30000
 spring.datasource.data2.connection-timeout=30000
-# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+# 锟斤拷锟矫硷拷锟斤拷锟矫才斤拷锟斤拷一锟轿硷拷猓�拷锟斤拷锟斤拷要锟截闭的匡拷锟斤拷锟斤拷锟接o拷锟斤拷位锟角猴拷锟斤拷
 spring.datasource.data2.time-between-eviction-runs-millis=60000
-# 配置一个连接在池中最小生存的时间,单位是毫秒
+# ����һ�������ڳ�����С�����ʱ�䣬��λ�Ǻ���
 spring.datasource.data2.minEvictableIdleTimeMillis=300000

+ 45 - 0
src/main/java/com/shkpr/service/alambizplugin/commtools/PointCodeUtil.java

@@ -0,0 +1,45 @@
+package com.shkpr.service.alambizplugin.commtools;
+
+import org.apache.commons.codec.digest.DigestUtils;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+
+/**
+ * 点code工具
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public class PointCodeUtil {
+    /**
+     * 时间格式化规则
+     */
+    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");
+    /**
+     * 前缀
+     */
+    private static final String PREFIX = "GSM";
+    /**
+     * 截取范围
+     */
+    private static final int[] RANGE = {9, 21};
+
+    /**
+     * 生成code
+     *
+     * @return code
+     */
+    public static String generateCode() {
+        //生成时间字符串
+        String timeStr = LocalDateTime.now().format(FORMATTER);
+        //生成UUID
+        String uuid = UUID.randomUUID().toString();
+        //转为md5,并截取10-21,并转大写
+        String md5Hash = DigestUtils.md5Hex(uuid);
+        String md5Str = md5Hash.substring(RANGE[0], RANGE[1]).toUpperCase();
+        // 拼接结果
+        return PREFIX + timeStr + md5Str;
+    }
+}

+ 200 - 5
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java

@@ -4,6 +4,7 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
 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.InvalidLinesFinder;
 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.LogFlagBusiType;
 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.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.GisSurveyThirdImportResult;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportSubtask;
 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.AsyncResult;
 import org.springframework.stereotype.Component;
@@ -30,8 +37,11 @@ import java.io.InputStream;
 import java.time.Duration;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
@@ -50,16 +60,18 @@ public class GisSurveyThirdImporter {
      */
     private final String mStrClassName;
     private final String mBizType;
-
     private final GisMetadataLayerTemplateService layerTemplateService;
+    private final GisSurveyLayerApplyThirdCopyService gisSurveyLayerApplyThirdCopyService;
     private final DuplicatePointsFinder duplicatePointsFinder;
     private final InvalidLinesFinder invalidLinesFinder;
     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";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         this.layerTemplateService = layerTemplateService;
+        this.gisSurveyLayerApplyThirdCopyService = gisSurveyLayerApplyThirdCopyService;
         this.duplicatePointsFinder = duplicatePointsFinder;
         this.invalidLinesFinder = invalidLinesFinder;
         this.invalidPropertiesFinder = invalidPropertiesFinder;
@@ -102,10 +114,10 @@ public class GisSurveyThirdImporter {
 
             //提取图层名
             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> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), listLayerNames);
+            List<GisMetadataLayerTemplate> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), lineLayerNames);
 
             //无效属性检查
             invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines, pointLayerTemplates, lineLayerTemplates);
@@ -140,11 +152,20 @@ public class GisSurveyThirdImporter {
                 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.setCompleteTime(LocalDateTime.now());
+            result.setPreviewData(layerApplyList);
 
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
                     , String.format(
@@ -266,4 +287,178 @@ public class GisSurveyThirdImporter {
                 CollectionUtils.isEmpty(invalidTypesResult) && CollectionUtils.isEmpty(outRanges) &&
                 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;
+    }
 }

+ 15 - 5
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyImportDefine.java

@@ -16,17 +16,19 @@ public interface GisSurveyImportDefine {
     }
 
     /**
-     * 点
+     * 点文件映射
      */
     interface POINT {
         String NO = "点号";
         String LAYER = "点类型";
         String LNG = "X坐标/经度";
         String LAT = "Y坐标/纬度";
+        String ELEVATION = "地面高程";
+        String DEPTH = "埋深";
     }
 
     /**
-     * 线
+     * 线文件映射
      */
     interface LINE {
         String UP_NO = "起点号";
@@ -35,7 +37,7 @@ public interface GisSurveyImportDefine {
     }
 
     /**
-     * 模版
+     * 数据库模版映射
      */
     interface TEMPLATE {
         String CODE = "code";
@@ -46,9 +48,17 @@ public interface GisSurveyImportDefine {
     }
 
     /**
-     * 结果
+     * 入库默认值
      */
-    interface RESULT{
+    interface DEFAULT_VALUE {
+        String APPLY = "add";
+        Short SOURCE = (short) (0xff);
+    }
+
+    /**
+     * 结果key
+     */
+    interface RESULT {
         String INVALID_LAYERS = "invalidLayersResult";
         String MISSING_REQUIREMENTS = "missingRequirementsResult";
         String INVALID_TYPES = "invalidTypesResult";

+ 30 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyLayerApplyThirdCopyMapper.java

@@ -0,0 +1,30 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 采集元素第三方导入副本mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface GisSurveyLayerApplyThirdCopyMapper {
+    /**
+     * 保存
+     *
+     * @param record 对象
+     * @return 保存数量
+     */
+    int save(GisSurveyLayerApplyThirdCopy record);
+
+    /**
+     * 根据jobId删除
+     *
+     * @param jobId jobId
+     * @return 删除数量
+     */
+    int deleteByJobId(@Param("jobId") String jobId);
+}

+ 30 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyPropertyValueThirdCopyMapper.java

@@ -0,0 +1,30 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 采集元素属性第三方导入副本表
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface GisSurveyPropertyValueThirdCopyMapper {
+    /**
+     * 保存
+     *
+     * @param record 对象
+     * @return 保存数量
+     */
+    int save(GisSurveyPropertyValueThirdCopy record);
+
+    /**
+     * 根据jobId删除
+     *
+     * @param jobId jobId
+     * @return 删除数量
+     */
+    int deleteByJobId(@Param("jobId") String jobId);
+}

+ 107 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyLayerApplyThirdCopyServiceImpl.java

@@ -0,0 +1,107 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper;
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueThirdCopyMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyThirdCopyService;
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
+import com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 采集元素第三方导入副本Service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Service
+public class GisSurveyLayerApplyThirdCopyServiceImpl implements GisSurveyLayerApplyThirdCopyService {
+    /**
+     * log
+     */
+    private final String mStrClassName;
+    private final String mBizType;
+    private final SqlSessionFactory mainSqlSessionFactory;
+
+    public GisSurveyLayerApplyThirdCopyServiceImpl(@Qualifier("mainSqlSessionFactory") SqlSessionFactory mainSqlSessionFactory) {
+        this.mainSqlSessionFactory = mainSqlSessionFactory;
+        mStrClassName = "GisSurveyThirdImporter";
+        mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+    }
+
+    /**
+     * 批量保存
+     *
+     * @param jobId          任务id
+     * @param layerApplyList 数据集合
+     * @return 保存状态
+     */
+    @Override
+    public Boolean saveAll(String jobId, List<GisSurveyLayerApplyThirdCopy> layerApplyList) throws InterruptedException {
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "开始批量写入元素和图形,开启批处理 任务ID:%s"
+                        , jobId
+                )
+        );
+        long begin = System.currentTimeMillis();
+        //开启批处理
+        try (SqlSession sqlSession = mainSqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
+            try {
+                //从session获取mapper
+                GisSurveyLayerApplyThirdCopyMapper layerApplyThirdCopyMapper = sqlSession.getMapper(GisSurveyLayerApplyThirdCopyMapper.class);
+                GisSurveyPropertyValueThirdCopyMapper propertyValueThirdCopyMapper = sqlSession.getMapper(GisSurveyPropertyValueThirdCopyMapper.class);
+                //删除原本job
+                layerApplyThirdCopyMapper.deleteByJobId(jobId);
+                propertyValueThirdCopyMapper.deleteByJobId(jobId);
+                //批量插入
+                for (GisSurveyLayerApplyThirdCopy layerApply : layerApplyList) {
+                    //检查线程中断,并响应
+                    if (Thread.interrupted()) throw new InterruptedException();
+                    //插入元素
+                    layerApplyThirdCopyMapper.save(layerApply);
+                    for (GisSurveyPropertyValueThirdCopy propertyValue : layerApply.getPropertyValueList()) {
+                        //插入属性
+                        propertyValueThirdCopyMapper.save(propertyValue);
+                    }
+                }
+                //提交(此处会发送sql至数据库)
+                sqlSession.commit();
+
+                long end = System.currentTimeMillis();
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "结束批量写入元素和图形,提交并关闭批处理 任务ID:%s 用时(毫秒):%d"
+                                , jobId
+                                , (end - begin)
+                        )
+                );
+                return true;
+            } catch (Exception e) {
+                //回滚
+                sqlSession.rollback();
+
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                        , String.format(
+                                "批量写入元素和图形失败,回滚操作 任务ID:%s error:%s"
+                                , jobId
+                                , e
+                        )
+                );
+
+                //传递中断异常
+                if (e instanceof InterruptedException) throw new InterruptedException();
+
+                return false;
+            }
+        }
+    }
+}

+ 22 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyLayerApplyThirdCopyService.java

@@ -0,0 +1,22 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
+
+import java.util.List;
+
+/**
+ * 采集元素第三方导入副本Service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface GisSurveyLayerApplyThirdCopyService {
+    /**
+     * 批量保存
+     *
+     * @param jobId          任务id
+     * @param layerApplyList 数据集合
+     * @return 保存状态
+     */
+    Boolean saveAll(String jobId, List<GisSurveyLayerApplyThirdCopy> layerApplyList) throws InterruptedException;
+}

+ 76 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyLayerApplyThirdCopy.java

@@ -0,0 +1,76 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 采集元素第三方导入副本表
+ */
+@Data
+public class GisSurveyLayerApplyThirdCopy {
+    /**
+     * 所属任务的唯一ID
+     */
+    private String jobId;
+
+    /**
+     * 元素唯一编码
+     */
+    private String code;
+
+    /**
+     * 元素类型标识符
+     */
+    private String layer;
+
+    /**
+     * 元素分类:point--点;line--线;face--面
+     */
+    private String kind;
+
+    /**
+     * 坐标值
+     */
+    private String gis;
+
+    /**
+     * 固定操作标记为:add
+     */
+    private String apply;
+
+    /**
+     * 固定数据来源为:255
+     */
+    private Short source;
+
+    /**
+     * 线的起点唯一编码
+     */
+    private String upNode;
+
+    /**
+     * 线的终点唯一编码
+     */
+    private String downNode;
+
+    /**
+     * 点的高程
+     */
+    private Double elevation;
+
+    /**
+     * 点的埋深
+     */
+    private Double depth;
+
+    /**
+     * 点的序号
+     */
+    private String no;
+
+    /**
+     * 属性值
+     */
+    private List<GisSurveyPropertyValueThirdCopy> propertyValueList;
+}

+ 37 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyPropertyValueThirdCopy.java

@@ -0,0 +1,37 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * 采集元素属性第三方导入副本表
+ */
+@Getter
+@Setter
+@ToString
+@AllArgsConstructor
+@NoArgsConstructor
+public class GisSurveyPropertyValueThirdCopy {
+    /**
+     * 所属任务的唯一ID
+     */
+    private String jobId;
+
+    /**
+     * 所属元素的唯一编码
+     */
+    private String code;
+
+    /**
+     * 属性唯一标识符
+     */
+    private String property;
+
+    /**
+     * 取值
+     */
+    private String value;
+}

+ 5 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyThirdImportResult.java

@@ -75,6 +75,11 @@ public class GisSurveyThirdImportResult {
     private GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>> invalidLinesResult = new GisSurveyThirdImportResultDetail<>();
 
     /**
+     * 预览数据
+     */
+    private List<GisSurveyLayerApplyThirdCopy> previewData;
+
+    /**
      * 进行中
      */
     public static GisSurveyThirdImportResult inProgress(GisSurveyThirdImportParams params, GisSurveyThirdImportSubtask subtask, LocalDateTime requestTime) {

+ 105 - 0
src/main/resources/mapper/GisSurveyLayerApplyThirdCopyMapper.xml

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper">
+    <resultMap id="BaseResultMap" type="com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy">
+        <!--@Table k3_gis_survey_layer_apply_third_copy-->
+        <id column="job_id" jdbcType="VARCHAR" property="jobId"/>
+        <id column="code" jdbcType="VARCHAR" property="code"/>
+        <result column="layer" jdbcType="VARCHAR" property="layer"/>
+        <result column="kind" jdbcType="VARCHAR" property="kind"/>
+        <result column="gis" jdbcType="VARCHAR" property="gis"/>
+        <result column="apply" jdbcType="VARCHAR" property="apply"/>
+        <result column="source" jdbcType="SMALLINT" property="source"/>
+        <result column="up_node" jdbcType="VARCHAR" property="upNode"/>
+        <result column="down_node" jdbcType="VARCHAR" property="downNode"/>
+        <result column="elevation" jdbcType="DOUBLE" property="elevation"/>
+        <result column="depth" jdbcType="DOUBLE" property="depth"/>
+        <result column="no" jdbcType="VARCHAR" property="no"/>
+    </resultMap>
+
+    <insert id="save">
+        INSERT INTO k3_gis_survey_layer_apply_third_copy
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="jobId != null">
+                job_id,
+            </if>
+            <if test="code != null">
+                code,
+            </if>
+            <if test="layer != null">
+                layer,
+            </if>
+            <if test="kind != null">
+                kind,
+            </if>
+            <if test="gis != null">
+                gis,
+            </if>
+            <if test="apply != null">
+                apply,
+            </if>
+            <if test="source != null">
+                "source",
+            </if>
+            <if test="upNode != null">
+                up_node,
+            </if>
+            <if test="downNode != null">
+                down_node,
+            </if>
+            <if test="elevation != null">
+                elevation,
+            </if>
+            <if test="depth != null">
+                "depth",
+            </if>
+            <if test="no != null">
+                "no"
+            </if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="jobId != null">
+                #{jobId,jdbcType=VARCHAR},
+            </if>
+            <if test="code != null">
+                #{code,jdbcType=VARCHAR},
+            </if>
+            <if test="layer != null">
+                #{layer,jdbcType=VARCHAR},
+            </if>
+            <if test="kind != null">
+                #{kind,jdbcType=VARCHAR},
+            </if>
+            <if test="gis != null">
+                #{gis,jdbcType=VARCHAR},
+            </if>
+            <if test="apply != null">
+                #{apply,jdbcType=VARCHAR},
+            </if>
+            <if test="source != null">
+                #{source,jdbcType=SMALLINT},
+            </if>
+            <if test="upNode != null">
+                #{upNode,jdbcType=VARCHAR},
+            </if>
+            <if test="downNode != null">
+                #{downNode,jdbcType=VARCHAR},
+            </if>
+            <if test="elevation != null">
+                #{elevation,jdbcType=DOUBLE},
+            </if>
+            <if test="depth != null">
+                #{depth,jdbcType=DOUBLE},
+            </if>
+            <if test="no != null">
+                #{no,jdbcType=VARCHAR}
+            </if>
+        </trim>
+    </insert>
+
+    <delete id="deleteByJobId">
+        delete from k3_gis_survey_layer_apply_third_copy
+        where job_id=#{jobId,jdbcType=VARCHAR}
+    </delete>
+</mapper>

+ 49 - 0
src/main/resources/mapper/GisSurveyPropertyValueThirdCopyMapper.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueThirdCopyMapper">
+    <resultMap id="BaseResultMap" type="com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy">
+        <!--@Table k3_gis_survey_property_value_third_copy-->
+        <id column="job_id" jdbcType="VARCHAR" property="jobId"/>
+        <id column="code" jdbcType="VARCHAR" property="code"/>
+        <id column="property" jdbcType="VARCHAR" property="property"/>
+        <result column="value" jdbcType="VARCHAR" property="value"/>
+    </resultMap>
+
+    <insert id="save">
+        INSERT INTO k3_gis_survey_property_value_third_copy
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="jobId != null">
+                job_id,
+            </if>
+            <if test="code != null">
+                code,
+            </if>
+            <if test="property != null">
+                property,
+            </if>
+            <if test="value != null">
+                "value"
+            </if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="jobId != null">
+                #{jobId,jdbcType=VARCHAR},
+            </if>
+            <if test="code != null">
+                #{code,jdbcType=VARCHAR},
+            </if>
+            <if test="property != null">
+                #{property,jdbcType=VARCHAR},
+            </if>
+            <if test="value != null">
+                #{value,jdbcType=VARCHAR}
+            </if>
+        </trim>
+    </insert>
+
+    <delete id="deleteByJobId">
+        delete from k3_gis_survey_property_value_third_copy
+        where job_id=#{jobId,jdbcType=VARCHAR}
+    </delete>
+</mapper>