فهرست منبع

增加合并副表接口

欧阳劲驰 2 ماه پیش
والد
کامیت
4b4aba6190
20فایلهای تغییر یافته به همراه386 افزوده شده و 38 حذف شده
  1. 2 2
      src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyThirdImportBizService.java
  2. 7 3
      src/main/java/com/shkpr/service/alambizplugin/commtools/ExcelUtils.java
  3. 30 3
      src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java
  4. 27 9
      src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidLinesFinder.java
  5. 1 0
      src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java
  6. 68 3
      src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java
  7. 1 0
      src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTGisSurveyBizFilter.java
  8. 9 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyJobInfoMapper.java
  9. 8 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyLayerApplyMapper.java
  10. 9 1
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyLayerApplyThirdCopyMapper.java
  11. 9 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyProjectInfoMapper.java
  12. 19 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyPropertyValueMapper.java
  13. 88 8
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyLayerApplyServiceImpl.java
  14. 12 4
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyLayerApplyService.java
  15. 51 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyPropertyValue.java
  16. 6 0
      src/main/resources/mapper/GisSurveyJobInfoMapper.xml
  17. 10 0
      src/main/resources/mapper/GisSurveyLayerApplyMapper.xml
  18. 6 0
      src/main/resources/mapper/GisSurveyLayerApplyThirdCopyMapper.xml
  19. 12 5
      src/main/resources/mapper/GisSurveyProjectInfoMapper.xml
  20. 11 0
      src/main/resources/mapper/GisSurveyPropertyValueMapper.xml

+ 2 - 2
src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyThirdImportBizService.java

@@ -114,12 +114,12 @@ public class GisSurveyThirdImportBizService {
     }
 
     /**
-     * 取消检查
+     * 取消导入
      *
      * @param jobId 任务id
      * @return 取消结果
      */
-    public int cancelCheck(String jobId) {
+    public int cancelImport(String jobId) {
         //如无缓存,则直接返回不存在
         if (!TASK_CACHE.containsKey(jobId)) return GisSurveyImportStatusEnum.NOT_EXISTS.getCode();
         //关闭检查任务

+ 7 - 3
src/main/java/com/shkpr/service/alambizplugin/commtools/ExcelUtils.java

@@ -60,7 +60,7 @@ public class ExcelUtils {
      * @param dataRowNum   数据行
      * @return 数据(key : 页名, v : 数据)
      */
-    public static Map<String, List<Map<String, String>>> parseExcelFile(String path, Integer headerRowNum, Integer dataRowNum) {
+    public static Map<String, List<Map<String, String>>> parseExcelFile(String path, Integer headerRowNum, Integer dataRowNum) throws InterruptedException {
         //excel枚举
         ExcelEnum excelEnum = null;
         //文件后缀
@@ -90,7 +90,7 @@ public class ExcelUtils {
      * @return 数据(key : 页名, v : 数据)
      */
     public static Map<String, List<Map<String, String>>> parseExcelFile(InputStream inputStream, ExcelEnum excelEnum
-            , Integer headerRowNum, Integer dataRowNum) {
+            , Integer headerRowNum, Integer dataRowNum) throws InterruptedException {
         if (inputStream == null || excelEnum == null || excelEnum == ExcelEnum.CSV) return null;
         //读取输入流
         try (Workbook workbook = excelEnum == ExcelEnum.XLSX ? new XSSFWorkbook(inputStream) : new HSSFWorkbook(inputStream)) {
@@ -116,7 +116,7 @@ public class ExcelUtils {
      * @param dataRowNum   数据行
      * @return 数据
      */
-    private static List<Map<String, String>> parseSheet(Sheet sheet, Integer headerRowNum, Integer dataRowNum) {
+    private static List<Map<String, String>> parseSheet(Sheet sheet, Integer headerRowNum, Integer dataRowNum) throws InterruptedException {
         //数据集合
         List<Map<String, String>> dataList = new ArrayList<>();
         if (sheet == null) return dataList;
@@ -128,6 +128,8 @@ public class ExcelUtils {
         //字段映射
         Map<Integer, String> fieldMap = new HashMap<>();
         for (Cell cell : rowHead) {
+            //检查线程中断,并响应
+            if (Thread.interrupted()) throw new InterruptedException();
             //获取值,如不为空,则存入索引关系
             String cellValue = getCellValue(cell);
             if (!StringUtils.isEmpty(cellValue)) {
@@ -136,6 +138,8 @@ public class ExcelUtils {
         }
         //遍历行
         for (Row row : sheet) {
+            //检查线程中断,并响应
+            if (Thread.interrupted()) throw new InterruptedException();
             //跳过非数据行
             if (row == null || row.getRowNum() < dataRowNum) continue;
             //跳过空行

+ 30 - 3
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java

@@ -147,6 +147,13 @@ public class GisSurveyThirdImporter {
             if (!checkResult(result)) {
                 result.setImportStatus(GisSurveyImportStatusEnum.DATA_ERROR.getCode());
                 result.setCompleteTime(LocalDateTime.now());
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "第三方导入结果未通过;任务id: %s, 用时(毫秒):%d",
+                                params.getJobId(),
+                                Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis()
+                        )
+                );
                 //弃用子任务
                 onDeprecatedSubtask.accept(params.getJobId());
                 return new AsyncResult<>(result);
@@ -157,6 +164,14 @@ public class GisSurveyThirdImporter {
             //批量写入
             Boolean saved = gisSurveyLayerApplyThirdCopyService.saveAll(params.getJobId(), layerApplyList);
             if (!saved) {
+                result.setCompleteTime(LocalDateTime.now());
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "第三方导入入库失败;任务id: %s, 用时(毫秒):%d",
+                                params.getJobId(),
+                                Duration.between(result.getRequestTime(), LocalDateTime.now()).toMillis()
+                        )
+                );
                 //弃用子任务
                 onDeprecatedSubtask.accept(params.getJobId());
                 return new AsyncResult<>(result);
@@ -174,7 +189,6 @@ public class GisSurveyThirdImporter {
                             Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis()
                     )
             );
-
             //弃用子任务
             onDeprecatedSubtask.accept(params.getJobId());
             return new AsyncResult<>(result);
@@ -210,15 +224,17 @@ public class GisSurveyThirdImporter {
      * @param lines        线集合
      * @throws IOException io异常
      */
-    private void parseExcel(List<InputStream> inputStreams, List<Map<String, String>> points, List<Map<String, String>> lines) throws IOException {
+    private void parseExcel(List<InputStream> inputStreams, List<Map<String, String>> points, List<Map<String, String>> lines) throws IOException, InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行解析excel   ======>");
         long begin = System.currentTimeMillis();
 
         //解析文件
         for (InputStream inputStream : inputStreams) {
+            //检查线程中断,并响应
+            if (Thread.interrupted()) throw new InterruptedException();
             //解析excel
             Map<String, List<Map<String, String>>> excelData = ExcelUtils.parseExcelFile(inputStream,
-                    ExcelEnum.XLSX, 0, 3);
+                    ExcelEnum.XLSX, 0, 2);
             //填入集合
             if (excelData != null && excelData.containsKey(GisMetadataDefine.TYPE_KINE.POINT))
                 points.addAll(excelData.get(GisMetadataDefine.TYPE_KINE.POINT));
@@ -301,6 +317,9 @@ public class GisSurveyThirdImporter {
      */
     private List<GisSurveyLayerApplyThirdCopy> decodeDataToLayerApply(List<Map<String, String>> points, List<Map<String, String>> lines
             , List<GisMetadataLayerTemplate> pointLayerTemplates, List<GisMetadataLayerTemplate> lineLayerTemplates, GisSurveyThirdImportParams params) {
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "导入结果通过,开始解码点线数据   ======>");
+        long begin = System.currentTimeMillis();
+
         //按模版名分组,便于快速找到模版
         Map<String, GisMetadataLayerTemplate> poineTemplateMap = pointLayerTemplates.stream()
                 .collect(Collectors.toMap(
@@ -337,6 +356,14 @@ public class GisSurveyThirdImporter {
 
             result.add(layerApply);
         }
+
+        long end = System.currentTimeMillis();
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "结束执行解码点线数据,用时(毫秒):%d"
+                        , (end - begin)
+                )
+        );
         return result;
     }
 

+ 27 - 9
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidLinesFinder.java

@@ -55,16 +55,34 @@ public class InvalidLinesFinder {
         long begin = System.currentTimeMillis();
 
         //如点为空,则全是无效线
-        if (points.isEmpty()) return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(true,
-                lines.stream()
-                        //转code字符串
-                        .map(line -> GisSurveyThirdImportElement.create(line, GisSurveyImportDefine.LayerType.LINE))
-                        .collect(Collectors.toList())
-        ));
+        if (points.isEmpty()) {
+            long end = System.currentTimeMillis();
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                    , String.format(
+                            "结束执行寻找无效线,用时(毫秒):%d"
+                            , (end - begin)
+                    )
+            );
+            return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(true,
+                    lines.stream()
+                            //转code字符串
+                            .map(line -> GisSurveyThirdImportElement.create(line, GisSurveyImportDefine.LayerType.LINE))
+                            .collect(Collectors.toList())
+            ));
+        }
         //如线为空,则无无效线
-        if (lines.isEmpty()) return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(
-                true, Lists.newArrayList()
-        ));
+        if (lines.isEmpty()) {
+            long end = System.currentTimeMillis();
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                    , String.format(
+                            "结束执行寻找无效线,用时(毫秒):%d"
+                            , (end - begin)
+                    )
+            );
+            return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(
+                    true, Lists.newArrayList()
+            ));
+        }
 
         //点号集合
         Set<String> nos = points.parallelStream()

+ 1 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java

@@ -29,6 +29,7 @@ public class ApiURI {
     public static final String URI_XXX_SYS_CHECK_RESULTS = "sys-check-results";
     public static final String URI_XXX_THIRD_IMPORT= "third-import";
     public static final String URI_XXX_THIRD_IMPORT_CANCEL= "third-import-cancel";
+    public static final String URI_XXX_THIRD_IMPORT_COMMIT= "third-import-commit";
 
     public static final String URI_ACCESS_TOKEN_CHECK = "/kpr-plugin/apply/access-token-check";
     public static final String URI_FILE_BUSI_XXX = "/files/**";

+ 68 - 3
src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java

@@ -14,6 +14,7 @@ import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.constants.ResponseCode;
 import com.shkpr.service.alambizplugin.controllerfilter.TokenAuthenticationService;
 import com.shkpr.service.alambizplugin.controllervalid.CommonParamValidSK;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
 import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResult;
 import com.shkpr.service.alambizplugin.dto.ResponseRes;
@@ -50,8 +51,10 @@ public class ApiGisSurveyController {
 
     private final GisSurveySystemCheckBizService systemCheckBizService;
     private final GisSurveyThirdImportBizService thirdImportBizService;
+    private final GisSurveyLayerApplyService layerApplyService;
 
-    public ApiGisSurveyController(GisSurveySystemCheckBizService systemCheckBizService, GisSurveyThirdImportBizService thirdImportBizService) {
+    public ApiGisSurveyController(GisSurveySystemCheckBizService systemCheckBizService
+            , GisSurveyThirdImportBizService thirdImportBizService, GisSurveyLayerApplyService layerApplyService) {
         mStrClassName = "ApiGisSurveyController";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         mSeqSysCheckReq = new AtomicInteger(0);
@@ -60,6 +63,7 @@ public class ApiGisSurveyController {
         mSeqThirdImportCancelReq = new AtomicInteger(0);
         this.systemCheckBizService = systemCheckBizService;
         this.thirdImportBizService = thirdImportBizService;
+        this.layerApplyService = layerApplyService;
     }
 
     /**
@@ -325,8 +329,8 @@ public class ApiGisSurveyController {
         ResponseRes<Boolean> resResult = new ResponseRes<>();
         resResult.setRescode(ResponseCode.RESULT_THIRD_IMPORT_CANCEL_FAILED.toStrCode());
         resResult.setResmsg(ResponseCode.RESULT_THIRD_IMPORT_CANCEL_FAILED.toStrMsg());
-        //清除检查
-        Integer cancelCheck = thirdImportBizService.cancelCheck(jobId);
+        //清除导入
+        Integer cancelCheck = thirdImportBizService.cancelImport(jobId);
         //成功
         if (Objects.equals(cancelCheck, GisSurveyCheckStatusEnum.SUCCESS.getCode())) {
             resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
@@ -349,4 +353,65 @@ public class ApiGisSurveyController {
                         , resResult.getTimestamp() - llReqBefore));
         return resResult;
     }
+
+    /**
+     * 提交第三方导入
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param jobId         任务id
+     * @return 清除状态
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_THIRD_IMPORT_COMMIT)
+    public ResponseRes<?> commitImport(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam("jobId") String jobId) throws Exception {
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(jobId)) {
+            throw new SelfException(ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrCode()
+                    , String.format(ApiURI.EXCEPTION_FORMAT
+                    , strPlatform
+                    , URI_PATH
+                    , ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrMsg()));
+        }
+        //begin
+        long llReqBefore = System.currentTimeMillis();
+        String strRunSeq = String.format("%d-%d", llReqBefore, mSeqThirdImportCancelReq.incrementAndGet());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} param:%s begin====>"
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , jobId));
+        //构建result
+        ResponseRes<Boolean> resResult = new ResponseRes<>();
+        resResult.setRescode(ResponseCode.RESULT_THIRD_IMPORT_FAILED.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_THIRD_IMPORT_FAILED.toStrMsg());
+
+        //提交导入
+        Boolean commitStatus = layerApplyService.mergeCopy(jobId);
+        //成功
+        if (Objects.equals(commitStatus, Boolean.TRUE)) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        }
+
+        //end
+        resResult.setTimestamp(System.currentTimeMillis());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , resResult.getRescode()
+                        , resResult.getResmsg()
+                        , resResult.getTimestamp() - llReqBefore));
+        return resResult;
+    }
 }

+ 1 - 0
src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTGisSurveyBizFilter.java

@@ -24,6 +24,7 @@ public class ApiJWTGisSurveyBizFilter extends JWTAuthenticationFilter {
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_SYS_CHECK_RESULTS), "GET");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT), "POST");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_CANCEL), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_COMMIT), "GET");
     }
 
     public ApiJWTGisSurveyBizFilter(String url, AuthenticationManager authenticationManager){

+ 9 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyJobInfoMapper.java

@@ -20,4 +20,13 @@ public interface GisSurveyJobInfoMapper {
      * @return 刷新时间
      */
     LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+
+    /**
+     * 根据uid更新刷新时间
+     *
+     * @param uid       uid
+     * @param timestamp 时间戳
+     * @return 刷新时间
+     */
+    int updateRefreshTimeByUid(@Param("uid") String uid, @Param("timestamp") Long timestamp);
 }

+ 8 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyLayerApplyMapper.java

@@ -45,4 +45,12 @@ public interface GisSurveyLayerApplyMapper {
      * @return 线集合
      */
     Cursor<GisSurveyLayerApplyLine> findAddLineByJobId(@Param("jobId") String jobId);
+
+    /**
+     * 根据任务id合并副表
+     *
+     * @param jobId 任务id
+     * @return 合并数量
+     */
+    int mergeCopyByJobId(@Param("jobId") String jobId);
 }

+ 9 - 1
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyLayerApplyThirdCopyMapper.java

@@ -21,10 +21,18 @@ public interface GisSurveyLayerApplyThirdCopyMapper {
     int save(GisSurveyLayerApplyThirdCopy record);
 
     /**
-     * 根据jobId删除
+     * 根据任务Id删除
      *
      * @param jobId jobId
      * @return 删除数量
      */
     int deleteByJobId(@Param("jobId") String jobId);
+
+    /**
+     * 根据任务Id获取总数
+     *
+     * @param jobId 任务id
+     * @return 总数
+     */
+    int countByJobId(@Param("jobId") String jobId);
 }

+ 9 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyProjectInfoMapper.java

@@ -20,4 +20,13 @@ public interface GisSurveyProjectInfoMapper {
      * @return 刷新时间
      */
     LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+
+    /**
+     * 根据任务id更新刷新时间
+     *
+     * @param jobId     任务id
+     * @param timestamp 时间戳
+     * @return 刷新时间
+     */
+    int updateRefreshTimeByUid(@Param("jobId") String jobId, @Param("timestamp") Long timestamp);
 }

+ 19 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyPropertyValueMapper.java

@@ -0,0 +1,19 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 采集元素属性取值mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface GisSurveyPropertyValueMapper {
+    /**
+     * 根据任务id合并副表
+     *
+     * @param jobId 任务id
+     * @return 合并数量
+     */
+    int mergeCopyByJobId(@Param("jobId") String jobId);
+}

+ 88 - 8
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyLayerApplyServiceImpl.java

@@ -3,11 +3,18 @@ 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.GisSurveyJobInfoMapper;
 import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyMapper;
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyLayerApplyThirdCopyMapper;
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyPropertyValueMapper;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
 import org.apache.ibatis.cursor.Cursor;
+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 org.springframework.transaction.annotation.Transactional;
 
@@ -23,18 +30,21 @@ import java.util.List;
  */
 @Service
 public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyService {
-    final
-    GisSurveyLayerApplyMapper gisSurveyLayerApplyMapper;
     /**
      * log
      */
     private final String mStrClassName;
     private final String mBizType;
 
-    public GisSurveyLayerApplyServiceImpl(GisSurveyLayerApplyMapper gisSurveyLayerApplyMapper) {
+    private final SqlSessionFactory sqlSessionFactory;
+    private final GisSurveyLayerApplyMapper layerApplyMapper;
+
+    public GisSurveyLayerApplyServiceImpl(@Qualifier("mainSqlSessionFactory") SqlSessionFactory sqlSessionFactory
+            , GisSurveyLayerApplyMapper layerApplyMapper) {
         mStrClassName = "GisSurveyLayerApplyServiceImpl";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
-        this.gisSurveyLayerApplyMapper = gisSurveyLayerApplyMapper;
+        this.sqlSessionFactory = sqlSessionFactory;
+        this.layerApplyMapper = layerApplyMapper;
     }
 
 
@@ -56,7 +66,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
         );
         long begin = System.currentTimeMillis();
         //获取游标
-        try (Cursor<GisSurveyLayerApplyPoint> cursor = gisSurveyLayerApplyMapper.findAddPointByProjId(projId)) {
+        try (Cursor<GisSurveyLayerApplyPoint> cursor = layerApplyMapper.findAddPointByProjId(projId)) {
             //迭代游标
             for (GisSurveyLayerApplyPoint point : cursor) {
                 //检查线程中断,并响应
@@ -103,7 +113,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
         );
         long begin = System.currentTimeMillis();
         //获取游标
-        try (Cursor<GisSurveyLayerApplyLine> cursor = gisSurveyLayerApplyMapper.findAddLineByProjId(projId)) {
+        try (Cursor<GisSurveyLayerApplyLine> cursor = layerApplyMapper.findAddLineByProjId(projId)) {
             //迭代游标
             for (GisSurveyLayerApplyLine point : cursor) {
                 //检查线程中断,并响应
@@ -150,7 +160,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
         );
         long begin = System.currentTimeMillis();
         //获取游标
-        try (Cursor<GisSurveyLayerApplyPoint> cursor = gisSurveyLayerApplyMapper.findAddPointByJobId(jobId)) {
+        try (Cursor<GisSurveyLayerApplyPoint> cursor = layerApplyMapper.findAddPointByJobId(jobId)) {
             //迭代游标
             for (GisSurveyLayerApplyPoint gisSurveyLayerApplyPoint : cursor) {
                 //检查线程中断,并响应
@@ -197,7 +207,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
         );
         long begin = System.currentTimeMillis();
         //获取游标
-        try (Cursor<GisSurveyLayerApplyLine> cursor = gisSurveyLayerApplyMapper.findAddLineByJobId(jobId)) {
+        try (Cursor<GisSurveyLayerApplyLine> cursor = layerApplyMapper.findAddLineByJobId(jobId)) {
             //迭代游标
             for (GisSurveyLayerApplyLine line : cursor) {
                 //检查线程中断,并响应
@@ -225,4 +235,74 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
         }
         return lines;
     }
+
+    /**
+     * 合并副表
+     *
+     * @param jobId 任务id
+     * @return 合并结果
+     */
+    public Boolean mergeCopy(String jobId) {
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "开始合并副表,开启session和事务 任务ID:%s"
+                        , jobId
+                )
+        );
+        long begin = System.currentTimeMillis();
+        //开启session
+        try (SqlSession session = sqlSessionFactory.openSession(false)) {
+            try {
+                //获取需要的mapper
+                GisSurveyLayerApplyMapper layerApplyMapper = session.getMapper(GisSurveyLayerApplyMapper.class);
+                GisSurveyLayerApplyThirdCopyMapper layerApplyThirdCopyMapper = session.getMapper(GisSurveyLayerApplyThirdCopyMapper.class);
+                GisSurveyPropertyValueMapper propertyValueMapper = session.getMapper(GisSurveyPropertyValueMapper.class);
+                GisSurveyProjectInfoMapper projectInfoMapper = session.getMapper(GisSurveyProjectInfoMapper.class);
+                GisSurveyJobInfoMapper jobInfoMapper = session.getMapper(GisSurveyJobInfoMapper.class);
+
+                //需要合并的数量
+                int mergeCount = layerApplyThirdCopyMapper.countByJobId(jobId);
+
+                //合并属性
+                propertyValueMapper.mergeCopyByJobId(jobId);
+                //合并元素
+                int layerApply = layerApplyMapper.mergeCopyByJobId(jobId);
+
+                //检查合并数量
+                if (mergeCount != layerApply) {
+                    session.rollback();
+                    return false;
+                }
+
+                //更新刷新时间
+                long timestamp = System.currentTimeMillis();
+                System.out.println(timestamp);
+                projectInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
+                jobInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
+
+                long end = System.currentTimeMillis();
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "合并副表成功,提交事务 任务ID:%s 用时(毫秒):%d"
+                                , jobId
+                                , (end - begin)
+                        )
+                );
+                //提交
+                session.commit();
+                return true;
+            } catch (Exception e) {
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                        , String.format(
+                                "合并副表失败 开始回滚操作 任务id:%s error:%s"
+                                , jobId
+                                , e
+                        )
+                );
+
+                session.rollback();
+                return false;
+            }
+        }
+    }
 }

+ 12 - 4
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyLayerApplyService.java

@@ -18,7 +18,7 @@ public interface GisSurveyLayerApplyService {
      * @param projId 项目id
      * @return 点集合
      */
-    List<GisSurveyLayerApplyPoint> findAddPointByProjId(String projId)throws InterruptedException;
+    List<GisSurveyLayerApplyPoint> findAddPointByProjId(String projId) throws InterruptedException;
 
     /**
      * 根据项目id查询新增线
@@ -26,7 +26,7 @@ public interface GisSurveyLayerApplyService {
      * @param projId 项目id
      * @return 线集合
      */
-    List<GisSurveyLayerApplyLine> findAddLineByProjId(String projId)throws InterruptedException;
+    List<GisSurveyLayerApplyLine> findAddLineByProjId(String projId) throws InterruptedException;
 
     /**
      * 根据任务id查询新增点
@@ -34,7 +34,7 @@ public interface GisSurveyLayerApplyService {
      * @param jobId 任务id
      * @return 点集合
      */
-    List<GisSurveyLayerApplyPoint> findAddPointByJobId(String jobId)throws InterruptedException;
+    List<GisSurveyLayerApplyPoint> findAddPointByJobId(String jobId) throws InterruptedException;
 
     /**
      * 根据任务id查询新增线
@@ -42,5 +42,13 @@ public interface GisSurveyLayerApplyService {
      * @param jobId 任务id
      * @return 线集合
      */
-    List<GisSurveyLayerApplyLine> findAddLineByJobId(String jobId)throws InterruptedException;
+    List<GisSurveyLayerApplyLine> findAddLineByJobId(String jobId) throws InterruptedException;
+
+    /**
+     * 合并副表
+     *
+     * @param jobId 任务id
+     * @return 合并结果
+     */
+    Boolean mergeCopy(String jobId);
 }

+ 51 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyPropertyValue.java

@@ -0,0 +1,51 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.Data;
+
+/**
+ * 采集元素属性取值表
+ */
+@Data
+public class GisSurveyPropertyValue {
+    /**
+    * 所属任务的唯一ID
+    */
+    private String jobId;
+
+    /**
+    * 所属元素的唯一编码
+    */
+    private String code;
+
+    /**
+    * 属性唯一标识符
+    */
+    private String property;
+
+    private Long id;
+
+    /**
+    * 取值
+    */
+    private String value;
+
+    /**
+    * 审核结果:-1--待审核;0--未通过;1--已通过
+    */
+    private Short pass;
+
+    /**
+    * 最近审核备注说明
+    */
+    private String checkNote;
+
+    /**
+    * 最近审核修改数据:{"before":"xxx","after":"yyy"}
+    */
+    private String checkData;
+
+    /**
+    * 最近审核修改标记:0--未修改;1--已修改
+    */
+    private Short checkEdit;
+}

+ 6 - 0
src/main/resources/mapper/GisSurveyJobInfoMapper.xml

@@ -6,4 +6,10 @@
         from k3_gis_survey_job_info
         where uid = #{uid,jdbcType=VARCHAR};
     </select>
+
+    <update id="updateRefreshTimeByUid">
+        update k3_gis_survey_job_info
+        set refresh_time = #{timestamp,jdbcType=BIGINT}
+        where uid = #{uid,jdbcType=VARCHAR};
+    </update>
 </mapper>

+ 10 - 0
src/main/resources/mapper/GisSurveyLayerApplyMapper.xml

@@ -75,4 +75,14 @@
         where jo.uid = #{jobId,jdbcType=VARCHAR}
         and la.kind = 'line';
     </select>
+
+    <insert id="mergeCopyByJobId">
+        insert into k3_gis_survey_layer_apply(code, job_id, layer, kind, gis, apply, source, up_node,
+        down_node,elevation,depth,no)
+        select code, job_id, layer, kind, gis, apply, source, up_node,
+        down_node,elevation,depth,no
+        from k3_gis_survey_layer_apply_third_copy
+        where job_id = #{jobId,jdbcType=VARCHAR}
+        order by job_id, code
+    </insert>
 </mapper>

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

@@ -102,4 +102,10 @@
         delete from k3_gis_survey_layer_apply_third_copy
         where job_id=#{jobId,jdbcType=VARCHAR}
     </delete>
+
+    <select id="countByJobId" resultType="java.lang.Integer">
+        select count(1)
+        from k3_gis_survey_layer_apply_third_copy
+        where job_id=#{jobId,jdbcType=VARCHAR}
+    </select>
 </mapper>

+ 12 - 5
src/main/resources/mapper/GisSurveyProjectInfoMapper.xml

@@ -1,9 +1,16 @@
 <?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.GisSurveyProjectInfoMapper">
-  <select id="findRefreshTimeByUid" resultType="java.time.LocalDateTime">
-    select to_timestamp(refresh_time / 1000.0) AT TIME ZONE 'PRC'
-    from k3_gis_survey_project_info
-    where uid = #{uid,jdbcType=VARCHAR};
-  </select>
+    <select id="findRefreshTimeByUid" resultType="java.time.LocalDateTime">
+        select to_timestamp(refresh_time / 1000.0) AT TIME ZONE 'PRC'
+        from k3_gis_survey_project_info
+        where uid = #{uid,jdbcType=VARCHAR};
+    </select>
+
+    <update id="updateRefreshTimeByUid">
+        update k3_gis_survey_project_info pi
+        set refresh_time =#{timestamp,jdbcType=BIGINT}
+        where exists (select 1 from k3_gis_survey_job_info ji where ji.uid=#{jobId,jdbcType=VARCHAR} )
+        and pi.uid = (select proj_id from k3_gis_survey_job_info ji where ji.uid=#{jobId,jdbcType=VARCHAR} limit 1)
+    </update>
 </mapper>

+ 11 - 0
src/main/resources/mapper/GisSurveyPropertyValueMapper.xml

@@ -0,0 +1,11 @@
+<?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.GisSurveyPropertyValueMapper">
+    <insert id="mergeCopyByJobId">
+        insert into k3_gis_survey_property_value (property, code, job_id, value)
+        select property, code, job_id, value
+        from k3_gis_survey_property_value_third_copy
+        where job_id = #{jobId,jdbcType=VARCHAR}
+        order by job_id, code, property;
+    </insert>
+</mapper>