Prechádzať zdrojové kódy

系统检查结果改为已文件为主

欧阳劲驰 2 mesiacov pred
rodič
commit
205263ea51
29 zmenil súbory, kde vykonal 1155 pridanie a 345 odobranie
  1. 6 0
      src/main/java/com/shkpr/service/alambizplugin/apiparam/GisSurveyCheckParams.java
  2. 105 65
      src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyBizService.java
  3. 36 0
      src/main/java/com/shkpr/service/alambizplugin/commproperties/GisSurveySystemCheckProperties.java
  4. 259 0
      src/main/java/com/shkpr/service/alambizplugin/components/GisSurveySystemCheckResultManager.java
  5. 63 49
      src/main/java/com/shkpr/service/alambizplugin/components/GisSurveySystemChecker.java
  6. 43 14
      src/main/java/com/shkpr/service/alambizplugin/components/checker/DuplicatePointsFinder.java
  7. 45 8
      src/main/java/com/shkpr/service/alambizplugin/components/checker/IsolatedLinesFinder.java
  8. 45 17
      src/main/java/com/shkpr/service/alambizplugin/components/checker/IsolatedPointsFinder.java
  9. 43 14
      src/main/java/com/shkpr/service/alambizplugin/components/checker/OverlapLinesFinder.java
  10. 2 2
      src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyCheckStatusEnum.java
  11. 30 0
      src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveySystemCheckResultPath.java
  12. 8 8
      src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java
  13. 23 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyJobInfoMapper.java
  14. 23 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyProjectInfoMapper.java
  15. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyJobInfoServiceImpl.java
  16. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyProjectInfoServiceImpl.java
  17. 21 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyJobInfoService.java
  18. 21 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyProjectInfoService.java
  19. 0 113
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckResult.java
  20. 0 40
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckTaskId.java
  21. 1 1
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckElement.java
  22. 66 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckId.java
  23. 148 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResult.java
  24. 31 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResultDetail.java
  25. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckSubtask.java
  26. 10 12
      src/main/java/com/shkpr/service/alambizplugin/globalmgr/ScheduleTaskMgr.java
  27. 6 2
      src/main/resources/application.properties
  28. 9 0
      src/main/resources/mapper/GisSurveyJobInfoMapper.xml
  29. 9 0
      src/main/resources/mapper/GisSurveyProjectInfoMapper.xml

+ 6 - 0
src/main/java/com/shkpr/service/alambizplugin/apiparam/GisSurveyCheckParams.java

@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
 
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
+import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.Objects;
 
@@ -44,6 +45,11 @@ public class GisSurveyCheckParams {
     private String operator;
 
     /**
+     * 元素/属性的变化时间
+     */
+    private LocalDateTime refreshTime;
+
+    /**
      * 入参校验
      *
      * @return 校验状态

+ 105 - 65
src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyBizService.java

@@ -3,20 +3,23 @@ package com.shkpr.service.alambizplugin.bizservice;
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
+import com.shkpr.service.alambizplugin.commproperties.GisSurveySystemCheckProperties;
+import com.shkpr.service.alambizplugin.components.GisSurveySystemCheckResultManager;
 import com.shkpr.service.alambizplugin.components.GisSurveySystemChecker;
 import com.shkpr.service.alambizplugin.constants.GisSurveyCheckTypeEnum;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckResult;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckTaskId;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyJobInfoService;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfoService;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckSubtask;
 import org.springframework.stereotype.Component;
 import org.springframework.util.concurrent.ListenableFuture;
 
 import java.time.Duration;
 import java.time.LocalDateTime;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
@@ -32,23 +35,37 @@ public class GisSurveyBizService {
     /**
      * 任务缓存
      */
-    private final static Map<GisSurveyCheckTaskId, ListenableFuture<GisSurveyCheckResult>> FUTURE_CACHE = new ConcurrentHashMap<>();
+    private final static Map<GisSurveySystemCheckId, ListenableFuture<GisSurveySystemCheckResult>> TASK_CACHE = new ConcurrentHashMap<>();
+    /**
+     * 子任务缓存
+     */
+    private final static Map<GisSurveySystemCheckId, GisSurveySystemCheckSubtask> SUBTASK_CACHE = new ConcurrentHashMap<>();
+
     /**
      * 开始时间缓存
      */
-    private final static Map<GisSurveyCheckTaskId, LocalDateTime> TIME_CACHE = new ConcurrentHashMap<>();
+    private final static Map<GisSurveySystemCheckId, LocalDateTime> TIME_CACHE = new ConcurrentHashMap<>();
     /**
      * log
      */
     private final String mStrClassName;
     private final String mBizType;
 
+    private final GisSurveySystemCheckProperties systemCheckProperties;
+    private final GisSurveySystemCheckResultManager systemCheckFileManager;
     private final GisSurveySystemChecker systemChecker;
+    private final GisSurveyProjectInfoService projectInfoService;
+    private final GisSurveyJobInfoService jobInfoService;
 
-    public GisSurveyBizService(GisSurveySystemChecker systemChecker) {
+    public GisSurveyBizService(GisSurveySystemCheckProperties systemCheckProperties, GisSurveySystemCheckResultManager systemCheckFileManager
+            , GisSurveySystemChecker systemChecker, GisSurveyProjectInfoService projectInfoService, GisSurveyJobInfoService jobInfoService) {
         mStrClassName = "GisSurveyBizService";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.systemCheckProperties = systemCheckProperties;
+        this.systemCheckFileManager = systemCheckFileManager;
         this.systemChecker = systemChecker;
+        this.projectInfoService = projectInfoService;
+        this.jobInfoService = jobInfoService;
     }
 
     /**
@@ -57,22 +74,40 @@ public class GisSurveyBizService {
      * @param params 系统检查参数
      * @return 检查状态
      */
-    public GisSurveyCheckResult sysCheckFun(GisSurveyCheckParams params) {
-        //任务标识
-        GisSurveyCheckTaskId taskId = generateTaskId(params);
-        if (taskId == null) return GisSurveyCheckResult.notExists(params);
+    public GisSurveySystemCheckResult sysCheckFun(GisSurveyCheckParams params) {
+        //系统检查id
+        GisSurveySystemCheckId systemCheckId = GisSurveySystemCheckId.generateId(params);
+        if (systemCheckId == null) return GisSurveySystemCheckResult.notExists(params);
         //获取已存在的任务
-        ListenableFuture<GisSurveyCheckResult> previousFuture = FUTURE_CACHE.get(taskId);
+        ListenableFuture<GisSurveySystemCheckResult> previousFuture = TASK_CACHE.get(systemCheckId);
+        //获取已存在的结果
+        GisSurveySystemCheckResult result = systemCheckFileManager.getResult(systemCheckId);
+        //获取元素更新时间
+        LocalDateTime refreshTime = getRefreshTimeDuration(systemCheckId);
+        //回填元素更新时间
+        params.setRefreshTime(refreshTime);
+        //判断结果是否存在
+        if (result != null) {
+            //判断时间间隔,如滞后未到临界,则直接返回结果
+            if (result.getRefreshTime() != null && refreshTime != null) {
+                //结果滞后数据库的时间
+                Duration lags = Duration.between(result.getRefreshTime(), refreshTime);
+                //规定滞后时间大于真实滞后时间,直接返回结果
+                if (systemCheckProperties.getResultLagDuration().compareTo(lags) >= 0) {
+                    return result;
+                }
+            }
+        }
+        //系统检查子任务
+        GisSurveySystemCheckSubtask checkSubtask = SUBTASK_CACHE.get(systemCheckId);
         //进行中判断(未完成且未清除)
         if (previousFuture != null && !previousFuture.isDone() && !previousFuture.isCancelled())
-            return GisSurveyCheckResult.inProgress(params, TIME_CACHE.get(taskId));
-        //已结束判断,删除缓存
-        if (previousFuture != null && (previousFuture.isDone() || previousFuture.isCancelled()))
-            FUTURE_CACHE.remove(taskId);
+            return GisSurveySystemCheckResult.inProgress(params, checkSubtask, TIME_CACHE.get(systemCheckId));
         //启动检查任务
-        startTask(taskId, params);
+        startTask(systemCheckId, params);
         //返回进行中
-        return GisSurveyCheckResult.inProgress(params, LocalDateTime.now());
+        return GisSurveySystemCheckResult.inProgress(params, checkSubtask, LocalDateTime.now());
+
     }
 
     /**
@@ -81,19 +116,19 @@ public class GisSurveyBizService {
      * @param params 系统检查参数
      * @return 检查结果(可能进行中)
      */
-    public GisSurveyCheckResult getResult(GisSurveyCheckParams params) {
+    public GisSurveySystemCheckResult getResult(GisSurveyCheckParams params) {
         //任务标识
-        GisSurveyCheckTaskId taskId = generateTaskId(params);
-        if (taskId == null) return GisSurveyCheckResult.notExists(params);
+        GisSurveySystemCheckId systemCheckId = GisSurveySystemCheckId.generateId(params);
+        if (systemCheckId == null) return GisSurveySystemCheckResult.notExists(params);
         //获取任务
-        ListenableFuture<GisSurveyCheckResult> checkFuture = FUTURE_CACHE.get(taskId);
-        if (checkFuture == null) return GisSurveyCheckResult.notExists(params);
+        ListenableFuture<GisSurveySystemCheckResult> checkFuture = TASK_CACHE.get(systemCheckId);
+        if (checkFuture == null) return GisSurveySystemCheckResult.notExists(params);
         //已结束,则直接返回失败(如完成cancelled为false,切无法clear)
-        if (checkFuture.isCancelled()) return GisSurveyCheckResult.fail(params);
+        if (checkFuture.isCancelled()) return GisSurveySystemCheckResult.fail(params);
         //完成判断,如完成直接返回结果
         if (checkFuture.isDone()) {
             try {
-                return FUTURE_CACHE.get(taskId).get();
+                return TASK_CACHE.get(systemCheckId).get();
             } catch (ExecutionException | InterruptedException e) {
                 //打印报错信息(不太可能走到这里)
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
@@ -103,11 +138,11 @@ public class GisSurveyBizService {
                                 , e.getMessage()
                         )
                 );
-                return GisSurveyCheckResult.fail(params);
+                return GisSurveySystemCheckResult.fail(params);
             }
         }
         //返回进行中
-        return GisSurveyCheckResult.inProgress(params, TIME_CACHE.get(taskId));
+        return GisSurveySystemCheckResult.inProgress(params, SUBTASK_CACHE.get(systemCheckId), TIME_CACHE.get(systemCheckId));
     }
 
     /**
@@ -116,30 +151,30 @@ public class GisSurveyBizService {
      * @param params 系统检查参数
      * @return 检查结果(可能进行中)
      */
-    public GisSurveyCheckResult delResult(GisSurveyCheckParams params) {
+    public GisSurveySystemCheckResult delResult(GisSurveyCheckParams params) {
         //任务标识
-        GisSurveyCheckTaskId taskId = generateTaskId(params);
-        if (taskId == null) return GisSurveyCheckResult.fail(params);
+        GisSurveySystemCheckId taskId = GisSurveySystemCheckId.generateId(params);
+        if (taskId == null) return GisSurveySystemCheckResult.fail(params);
         //如无缓存,则直接返回不存在
-        if (!FUTURE_CACHE.containsKey(taskId)) return GisSurveyCheckResult.notExists(params);
+        if (!TASK_CACHE.containsKey(taskId)) return GisSurveySystemCheckResult.notExists(params);
         //关闭检查任务
-        return stopTask(taskId) ? GisSurveyCheckResult.success(params) : GisSurveyCheckResult.fail(params);
+        return stopTask(taskId) ? GisSurveySystemCheckResult.success(params) : GisSurveySystemCheckResult.fail(params);
     }
 
     /**
      * 过期任务
      * <p>用于检查和使任务过期</p>
      */
-    public void expireResult(long ttl) {
+    public void expireResult(Duration ttl) {
         //获取超时的id
-        List<GisSurveyCheckTaskId> taskIds = TIME_CACHE.entrySet().stream()
-                .filter(entry -> Duration.between(entry.getValue(), LocalDateTime.now()).toMillis() > ttl)
+        List<GisSurveySystemCheckId> taskIds = TIME_CACHE.entrySet().stream()
+                .filter(entry -> Duration.between(entry.getValue(), LocalDateTime.now()).compareTo(ttl) > 0)
                 .map(Map.Entry::getKey)
                 .collect(Collectors.toList());
         //停止超时的任务并删除任务缓存
-        for (GisSurveyCheckTaskId taskId : taskIds) {
+        for (GisSurveySystemCheckId taskId : taskIds) {
             //如任务不存在,则删除时间缓存
-            if (!FUTURE_CACHE.containsKey(taskId)) TIME_CACHE.remove(taskId);
+            if (!TASK_CACHE.containsKey(taskId)) TIME_CACHE.remove(taskId);
             //停用缓存
             if (stopTask(taskId)) TIME_CACHE.remove(taskId);
             else {
@@ -156,41 +191,46 @@ public class GisSurveyBizService {
     }
 
     /**
-     * 生成任务标识
+     * 获取更新时间
      *
-     * @param params 系统检查参数
-     * @return 任务标识
+     * @param systemCheckId 系统检查id
+     * @return 元素更新时间
      */
-    private GisSurveyCheckTaskId generateTaskId(GisSurveyCheckParams params) {
-        //获取枚举
-        GisSurveyCheckTypeEnum checkTypeEnum = Arrays.stream(GisSurveyCheckTypeEnum.values())
-                .filter(enumeration -> Objects.equals(params.getCheckType(), enumeration.getCode()))
-                .findFirst().orElse(null);
-        if (checkTypeEnum == null) return null;
-        //项目维度
-        if (checkTypeEnum.equals(GisSurveyCheckTypeEnum.PROJECT)) {
-            return new GisSurveyCheckTaskId(GisSurveyCheckTypeEnum.PROJECT.getCode(), params.getProjId());
-        }
-        //任务维度
-        else if (checkTypeEnum.equals(GisSurveyCheckTypeEnum.JOB)) {
-            return new GisSurveyCheckTaskId(GisSurveyCheckTypeEnum.PROJECT.getCode(), params.getJobId());
-        }
-        return null;
+    public LocalDateTime getRefreshTimeDuration(GisSurveySystemCheckId systemCheckId) {
+        //默认为当前时间
+        LocalDateTime refreshTime = LocalDateTime.now();
+        //根据检查维度获取数据库里的更新时间
+        if (systemCheckId.getCheckType() == GisSurveyCheckTypeEnum.PROJECT)
+            refreshTime = projectInfoService.findRefreshTimeByUid(systemCheckId.getCode());
+        if (systemCheckId.getCheckType() == GisSurveyCheckTypeEnum.JOB)
+            refreshTime = jobInfoService.findRefreshTimeByUid(systemCheckId.getCode());
+        return refreshTime;
     }
 
     /**
      * 启动任务
      *
-     * @param taskId 任务id
-     * @param params 检查参数
+     * @param systemCheckId 系统检查id
+     * @param params        检查参数
      */
-    private void startTask(GisSurveyCheckTaskId taskId, GisSurveyCheckParams params) {
+    private void startTask(GisSurveySystemCheckId systemCheckId, GisSurveyCheckParams params) {
+        //获取已存在的任务
+        ListenableFuture<GisSurveySystemCheckResult> previousFuture = TASK_CACHE.get(systemCheckId);
+        //已结束判断,删除缓存
+        if (previousFuture != null && (previousFuture.isDone() || previousFuture.isCancelled())) {
+            TASK_CACHE.remove(systemCheckId);
+            SUBTASK_CACHE.remove(systemCheckId);
+            TIME_CACHE.remove(systemCheckId);
+        }
         //异步执行系统检查任务
-        ListenableFuture<GisSurveyCheckResult> checkFuture = systemChecker.systemCheckTask(params);
+        ListenableFuture<GisSurveySystemCheckResult> checkFuture = systemChecker.systemCheckTask(params,
+                //缓存子任务句柄
+                subtask -> SUBTASK_CACHE.put(systemCheckId, subtask)
+        );
         //缓存任务句柄
-        FUTURE_CACHE.put(taskId, checkFuture);
+        TASK_CACHE.put(systemCheckId, checkFuture);
         //缓存时间
-        TIME_CACHE.put(taskId, LocalDateTime.now());
+        TIME_CACHE.put(systemCheckId, LocalDateTime.now());
     }
 
     /**
@@ -199,11 +239,11 @@ public class GisSurveyBizService {
      * @param taskId 任务id
      * @return 关闭状态
      */
-    private Boolean stopTask(GisSurveyCheckTaskId taskId) {
-        ListenableFuture<GisSurveyCheckResult> future = FUTURE_CACHE.get(taskId);
+    private Boolean stopTask(GisSurveySystemCheckId taskId) {
+        ListenableFuture<GisSurveySystemCheckResult> future = TASK_CACHE.get(taskId);
         //完成判断,完成删除缓存
         if (future.isCancelled() || future.isDone()) {
-            FUTURE_CACHE.remove(taskId);
+            TASK_CACHE.remove(taskId);
             TIME_CACHE.remove(taskId);
             return true;
         }
@@ -211,7 +251,7 @@ public class GisSurveyBizService {
         boolean cancel = future.cancel(true);
         //清除成功,删除缓存
         if (cancel) {
-            FUTURE_CACHE.remove(taskId);
+            TASK_CACHE.remove(taskId);
             TIME_CACHE.remove(taskId);
             return true;
         }

+ 36 - 0
src/main/java/com/shkpr/service/alambizplugin/commproperties/GisSurveySystemCheckProperties.java

@@ -0,0 +1,36 @@
+package com.shkpr.service.alambizplugin.commproperties;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.time.Duration;
+
+/**
+ * 系统检查配置
+ *
+ * @author 欧阳劲驰
+ * @since 0.0.1
+ */
+@Getter
+@Setter
+@ConfigurationProperties(prefix = "system-check")
+public class GisSurveySystemCheckProperties {
+    /**
+     * 系统检查任务超时时间
+     */
+    private Duration ttl;
+    /**
+     * 超时检查间隔(毫秒)
+     */
+    private Long ttlCheckInterval;
+    /**
+     * 资源路径
+     */
+    private String resourcePath;
+    /**
+     * 结果滞后时间
+     */
+    private Duration resultLagDuration;
+
+}

+ 259 - 0
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveySystemCheckResultManager.java

@@ -0,0 +1,259 @@
+package com.shkpr.service.alambizplugin.components;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.commproperties.GisSurveySystemCheckProperties;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
+import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
+import org.apache.commons.io.FileUtils;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 系统检查结果管理
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Component
+public class GisSurveySystemCheckResultManager {
+    /**
+     * 临时文件夹缓存
+     */
+    private final static Map<GisSurveySystemCheckId, Path> TEMP_DIR_CACHE = new ConcurrentHashMap<>();
+
+    private final static Integer BUFFER_SIZE = 4 * 1024;
+    /**
+     * log
+     */
+    private final String mStrClassName;
+    private final String mBizType;
+    private final GisSurveySystemCheckProperties systemCheckProperties;
+    private final ObjectMapper objectMapper;
+
+    public GisSurveySystemCheckResultManager(GisSurveySystemCheckProperties systemCheckProperties, ObjectMapper objectMapper) {
+        mStrClassName = "GisSurveySystemCheckResultManager";
+        mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.systemCheckProperties = systemCheckProperties;
+        this.objectMapper = objectMapper;
+    }
+
+    /**
+     * 获取结果
+     *
+     * @param systemCheckId 系统检查id
+     * @return 检查结果
+     */
+    public GisSurveySystemCheckResult getResult(GisSurveySystemCheckId systemCheckId) {
+        //创建文件输入流
+        File file = Paths.get(getResultDirPath(systemCheckId).toString(), GisSurveySystemCheckResultPath.RESULT).toFile();
+        if (!file.exists()) return null;
+        try (FileInputStream fileInputStream = new FileInputStream(file)) {
+            //获取文件通道
+            FileChannel channel = fileInputStream.getChannel();
+            //创建缓冲区
+            ByteBuffer byteBuffer = ByteBuffer.allocate((int) file.length());
+            //读取通道
+            int read = channel.read(byteBuffer);
+            //输入读取信息
+            if (read > 0) return objectMapper.readValue(byteBuffer.array(), GisSurveySystemCheckResult.class);
+        } catch (IOException e) {
+            //打印报错信息
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format(
+                            "监测到io异常 系统检查id:%s msg:%s"
+                            , systemCheckId
+                            , e.getMessage()
+                    )
+            );
+            return null;
+        }
+        return null;
+    }
+
+    /**
+     * 创建临时文件夹
+     *
+     * @param systemCheckId 系统id
+     */
+    public Boolean createTempDirectory(GisSurveySystemCheckId systemCheckId) {
+        try {
+            //创建临时文件夹,并缓存路径
+            Path tempDirectory = Files.createTempDirectory(Paths.get(systemCheckProperties.getResourcePath()),
+                    systemCheckId.getCheckType().getFlag() + "-" + systemCheckId.getCode() + "-");
+            TEMP_DIR_CACHE.put(systemCheckId, tempDirectory);
+            return tempDirectory.toFile().exists();
+        } catch (IOException e) {
+            //打印报错信息
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format(
+                            "监测到io异常 系统检查id:%s msg:%s"
+                            , systemCheckId
+                            , e.getMessage()
+                    )
+            );
+            return false;
+        }
+    }
+
+    /**
+     * 删除临时文件夹
+     *
+     * @param systemCheckId 系统检查id
+     */
+    public void deleteTempDirectory(GisSurveySystemCheckId systemCheckId) {
+        if (TEMP_DIR_CACHE.containsKey(systemCheckId)) {
+            //删除缓存,并删除文件夹
+            Path remove = TEMP_DIR_CACHE.remove(systemCheckId);
+            try {
+                FileUtils.deleteDirectory(remove.toFile());
+            } catch (IOException e) {
+                //打印报错信息
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                        , String.format(
+                                "监测到io异常 系统检查id:%s msg:%s"
+                                , systemCheckId
+                                , e.getMessage()
+                        )
+                );
+            }
+        }
+    }
+
+    /**
+     * 写入结果文件
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param path          文件名路径
+     */
+    public void writeResult(Object data, GisSurveySystemCheckId systemCheckId, String path) {//打印报错信息
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "开始执行写入孤立点文件,系统id:%s,文件名:%s========>"
+                        , systemCheckId
+                        , path
+                )
+        );
+        long begin = System.currentTimeMillis();
+
+        //写入文件
+        File file = Paths.get(TEMP_DIR_CACHE.get(systemCheckId).toString(), path).toFile();
+        try {
+            //序列化数据
+            final byte[] bytes = objectMapper.writeValueAsBytes(data);
+            //写入文件
+            int total = writeFile(bytes, file);
+            if (total > 0) {
+                long end = System.currentTimeMillis();
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "结束执行写入孤立点文件,系统id:%s,文件名:%s,用时(毫秒):%d"
+                                , systemCheckId
+                                , path
+                                , (end - begin)
+                        )
+                );
+            }
+        } catch (IOException e) {
+            //打印报错信息
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format(
+                            "监测到io异常 系统检查id:%s msg:%s"
+                            , systemCheckId
+                            , e.getMessage()
+                    )
+            );
+        }
+    }
+
+    /**
+     * 替换结果
+     *
+     * @param systemCheckId 系统检查id
+     * @return 替换状态
+     */
+    public boolean replaceResult(GisSurveySystemCheckId systemCheckId) {
+        //临时文件路径
+        Path path = TEMP_DIR_CACHE.get(systemCheckId);
+        try {
+            //替换结果目录
+            FileUtils.copyDirectory(path.toFile(), getResultDirPath(systemCheckId).toFile());
+            //删除临时文件
+            deleteTempDirectory(systemCheckId);
+
+            return true;
+        } catch (IOException e) {
+            //打印报错信息
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format(
+                            "监测到io异常 系统检查id:%s msg:%s"
+                            , systemCheckId
+                            , e.getMessage()
+                    )
+            );
+        }
+        return false;
+    }
+
+    /**
+     * 获取结果文件夹路径
+     *
+     * @param systemCheckId 系统检查id
+     * @return 结果文件夹路径
+     */
+    private Path getResultDirPath(GisSurveySystemCheckId systemCheckId) {
+        return Paths.get(systemCheckProperties.getResourcePath(), systemCheckId.getCheckType().getFlag() +
+                "-" + systemCheckId.getCode());
+    }
+
+    /**
+     * 写文件
+     *
+     * @param data 数据
+     * @param file 文件
+     * @return 写入数量
+     * @throws IOException io异常
+     */
+    private int writeFile(final byte[] data, final File file) throws IOException {
+        //创建文件输出流(此处会创建文件)
+        try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
+            //获取文件通道
+            FileChannel channel = fileOutputStream.getChannel();
+            //创建缓冲区
+            ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE);
+            //偏移量
+            int offset = 0;
+            //写入总数
+            int total = 0;
+            while (offset < data.length) {
+                //分片大小
+                int chunkSize = Math.min(BUFFER_SIZE, data.length - offset);
+                //重置缓冲区,存入缓冲区,翻转
+                byteBuffer.clear();
+                byteBuffer.put(data, offset, chunkSize);
+                byteBuffer.flip();
+                //写入当前块
+                total += channel.write(byteBuffer);
+                offset += chunkSize;
+            }
+            //强制写入
+            channel.force(true);
+            return total;
+        }
+    }
+}

+ 63 - 49
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveySystemChecker.java

@@ -9,13 +9,16 @@ import com.shkpr.service.alambizplugin.components.checker.IsolatedPointsFinder;
 import com.shkpr.service.alambizplugin.components.checker.OverlapLinesFinder;
 import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
 import com.shkpr.service.alambizplugin.constants.GisSurveyCheckTypeEnum;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.TypeDefineService;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckElement;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckResult;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckSubtask;
 import com.shkpr.service.alambizplugin.dto.TypeDefine;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
@@ -25,8 +28,8 @@ import org.springframework.util.concurrent.ListenableFuture;
 import java.time.Duration;
 import java.time.LocalDateTime;
 import java.util.List;
-import java.util.Objects;
 import java.util.concurrent.ExecutionException;
+import java.util.function.Consumer;
 
 /**
  * 系统检查执行器
@@ -42,6 +45,7 @@ public class GisSurveySystemChecker {
     private final String mStrClassName;
     private final String mBizType;
 
+    private final GisSurveySystemCheckResultManager systemCheckResultManager;
     private final GisSurveyLayerApplyService gisSurveyLayerApplyService;
     private final TypeDefineService typeDefineService;
     private final IsolatedPointsFinder isolatedPointsFinder;
@@ -49,9 +53,10 @@ public class GisSurveySystemChecker {
     private final DuplicatePointsFinder duplicatePointsFinder;
     private final OverlapLinesFinder overlapLinesFinder;
 
-    public GisSurveySystemChecker(GisSurveyLayerApplyService gisSurveyLayerApplyService, TypeDefineService typeDefineService, IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder, DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder) {
+    public GisSurveySystemChecker(GisSurveySystemCheckResultManager systemCheckResultManager, GisSurveyLayerApplyService gisSurveyLayerApplyService, TypeDefineService typeDefineService, IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder, DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder) {
         mStrClassName = "GisSurveySystemChecker";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.systemCheckResultManager = systemCheckResultManager;
         this.gisSurveyLayerApplyService = gisSurveyLayerApplyService;
         this.typeDefineService = typeDefineService;
         this.isolatedPointsFinder = isolatedPointsFinder;
@@ -67,23 +72,23 @@ public class GisSurveySystemChecker {
      * @return 系统检查返回
      */
     @Async
-    public ListenableFuture<GisSurveyCheckResult> systemCheckTask(GisSurveyCheckParams params) {
-        //项目id
-        String projId = params.getProjId();
-        //任务id
-        String jobId = params.getJobId();
-        //检查类型
-        Integer checkType = params.getCheckType();
+    public ListenableFuture<GisSurveySystemCheckResult> systemCheckTask(GisSurveyCheckParams params, Consumer<GisSurveySystemCheckSubtask> onStartSubtask) {
+        //系统检查id
+        GisSurveySystemCheckId systemCheckId = GisSurveySystemCheckId.generateId(params);
+        if (systemCheckId == null) return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
+        //创建临时文件夹
+        if (!systemCheckResultManager.createTempDirectory(systemCheckId))
+            return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
         //构建返回
-        GisSurveyCheckResult result = GisSurveyCheckResult.fail(params);
+        GisSurveySystemCheckResult result = GisSurveySystemCheckResult.fail(params);
         //孤立点任务
-        ListenableFuture<List<GisSurveyCheckElement>> isolatedPointsFuture = null;
+        ListenableFuture<GisSurveySystemCheckResultDetail> isolatedPointsFuture = null;
         //孤立线任务
-        ListenableFuture<List<List<GisSurveyCheckElement>>> IsolatedLinesFuture = null;
+        ListenableFuture<GisSurveySystemCheckResultDetail> isolatedLinesFuture = null;
         //重复点任务
-        ListenableFuture<List<List<GisSurveyCheckElement>>> duplicatePointsFuture = null;
+        ListenableFuture<GisSurveySystemCheckResultDetail> duplicatePointsFuture = null;
         //重叠线任务
-        ListenableFuture<List<List<GisSurveyCheckElement>>> overlapLinesFuture = null;
+        ListenableFuture<GisSurveySystemCheckResultDetail> overlapLinesFuture = null;
         //点集合
         List<GisSurveyLayerApplyPoint> points = null;
         //线集合
@@ -91,75 +96,85 @@ public class GisSurveySystemChecker {
         try {
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
                     , String.format(
-                            "开始执行系统检查;检查类型 检查类型:%s 项目ID:%s 任务ID:%s"
-                            , checkType
-                            , projId
-                            , jobId
+                            "开始执行系统检查;检查类型 检查类型:%s code:%s"
+                            , systemCheckId.getCheckType().getFlag()
+                            , systemCheckId.getCode()
                     )
             );
 
             //根据项目查询点线信息
-            if (Objects.equals(checkType, GisSurveyCheckTypeEnum.PROJECT.getCode())) {
-                points = gisSurveyLayerApplyService.findAddPointByProjId(projId);
-                lines = gisSurveyLayerApplyService.findAddLineByProjId(projId);
+            if (GisSurveyCheckTypeEnum.PROJECT == systemCheckId.getCheckType()) {
+                points = gisSurveyLayerApplyService.findAddPointByProjId(systemCheckId.getCode());
+                lines = gisSurveyLayerApplyService.findAddLineByProjId(systemCheckId.getCode());
             }
             //根据任务查询点线信息
-            else if (Objects.equals(checkType, GisSurveyCheckTypeEnum.JOB.getCode())) {
-                points = gisSurveyLayerApplyService.findAddPointByJobId(jobId);
-                lines = gisSurveyLayerApplyService.findAddLineByJobId(jobId);
+            else if (GisSurveyCheckTypeEnum.JOB == systemCheckId.getCheckType()) {
+                points = gisSurveyLayerApplyService.findAddPointByJobId(systemCheckId.getCode());
+                lines = gisSurveyLayerApplyService.findAddLineByJobId(systemCheckId.getCode());
             }
             //查询经纬度类型定义
             List<TypeDefine> typeDefines = typeDefineService.findLatLng();
 
             //孤立点检查
             if (points != null && lines != null) {
-                isolatedPointsFuture = isolatedPointsFinder.findIsolatedPoints(points, lines);
+                isolatedPointsFuture = isolatedPointsFinder.findIsolatedPoints(points, lines, systemCheckId);
             }
             //重复点检查
             if (points != null) {
-                duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines);
+                duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, systemCheckId);
             }
             //孤立线和重叠线检查
             if (lines != null) {
-                IsolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines);
-                overlapLinesFuture = overlapLinesFinder.findDuplicateLines(lines);
+                isolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines, systemCheckId);
+                overlapLinesFuture = overlapLinesFinder.findDuplicateLines(lines, systemCheckId);
             }
 
+            //返回子任务
+            onStartSubtask.accept(
+                    new GisSurveySystemCheckSubtask(isolatedPointsFuture, isolatedLinesFuture, duplicatePointsFuture, overlapLinesFuture)
+            );
+
             //等待结果,并存入返回,优先监听点相关(执行速度快且只需要点集合,优先释放点集合内存)
             if (isolatedPointsFuture != null) {
                 //监听孤立点
-                final List<GisSurveyCheckElement> isolatedPoints = isolatedPointsFuture.get();
-                result.setIsolatedPoints(isolatedPoints);
+                final GisSurveySystemCheckResultDetail isolatedPointsResult = isolatedPointsFuture.get();
+                result.setIsolatedPointsResult(isolatedPointsResult);
                 //释放点缓存(孤立点和重复点都完成时,后续不需要点数据,释放缓存节省内存)
                 if (duplicatePointsFuture != null && duplicatePointsFuture.isDone()) points.clear();
             }
             if (duplicatePointsFuture != null) {
                 //监听重复点
-                final List<List<GisSurveyCheckElement>> duplicatePointCodes = duplicatePointsFuture.get();
-                result.setDuplicatePoints(duplicatePointCodes);
+                final GisSurveySystemCheckResultDetail duplicatePointsResult = duplicatePointsFuture.get();
+                result.setDuplicatePointsResult(duplicatePointsResult);
                 //释放点缓存(孤立点和重复点都完成时,后续不需要点数据,释放缓存节省内存)
                 if (isolatedPointsFuture != null && isolatedPointsFuture.isDone()) points.clear();
             }
-            if (IsolatedLinesFuture != null) {
+            if (isolatedLinesFuture != null) {
                 //监听重复线
-                final List<List<GisSurveyCheckElement>> isolatedLines = IsolatedLinesFuture.get();
-                result.setIsolatedLines(isolatedLines);
+                final GisSurveySystemCheckResultDetail isolatedLinesResult = isolatedLinesFuture.get();
+                result.setIsolatedLinesResult(isolatedLinesResult);
             }
             if (overlapLinesFuture != null) {
                 //监听重叠线
-                final List<List<GisSurveyCheckElement>> overlapLines = overlapLinesFuture.get();
-                result.setOverlapLines(overlapLines);
+                final GisSurveySystemCheckResultDetail overlapLinesResult = overlapLinesFuture.get();
+                result.setOverlapLinesResult(overlapLinesResult);
             }
 
             //完成检查
-            result.setCompleteTime(LocalDateTime.now());
             result.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
+            result.setCompleteTime(LocalDateTime.now());
+
+            //写入结果
+            systemCheckResultManager.writeResult(result, systemCheckId, GisSurveySystemCheckResultPath.RESULT);
+            //替换结果
+            if (!systemCheckResultManager.replaceResult(systemCheckId))
+                return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
+
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
                     , String.format(
-                            "结束执行系统检查;检查类型: %d,项目ID:%s, 任务ID:,%s,用时(毫秒):%d",
-                            checkType,
-                            projId,
-                            jobId,
+                            "结束执行系统检查;检查类型: %s, code:%s , 用时(毫秒):%d",
+                            systemCheckId.getCheckType().getFlag(),
+                            systemCheckId.getCode(),
                             Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis()
                     )
             );
@@ -167,15 +182,14 @@ public class GisSurveySystemChecker {
         } catch (InterruptedException | ExecutionException e) {
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
                     , String.format(
-                            "监测到中断或执行异常,开始清除子任务 检查类型:%d,项目ID:%s, 任务ID:,%s,",
-                            checkType,
-                            projId,
-                            jobId
+                            "监测到中断或执行异常,开始清除子任务 检查类型:%s, code:%s",
+                            systemCheckId.getCheckType().getFlag(),
+                            systemCheckId.getCode()
                     )
             );
             //清除子任务
             if (isolatedPointsFuture != null) isolatedPointsFuture.cancel(true);
-            if (IsolatedLinesFuture != null) IsolatedLinesFuture.cancel(true);
+            if (isolatedLinesFuture != null) isolatedLinesFuture.cancel(true);
             if (duplicatePointsFuture != null) duplicatePointsFuture.cancel(true);
             if (overlapLinesFuture != null) overlapLinesFuture.cancel(true);
             //失败信息

+ 43 - 14
src/main/java/com/shkpr/service/alambizplugin/components/checker/DuplicatePointsFinder.java

@@ -3,9 +3,13 @@ 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.components.GisSurveySystemCheckResultManager;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import com.shkpr.service.alambizplugin.dto.TypeDefine;
 import org.apache.commons.lang3.StringUtils;
 import org.locationtech.jts.geom.Coordinate;
@@ -42,10 +46,12 @@ public class DuplicatePointsFinder {
      */
     private final String mStrClassName;
     private final String mBizType;
+    private final GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager;
 
-    public DuplicatePointsFinder() {
+    public DuplicatePointsFinder(GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager) {
         mStrClassName = "DuplicatePointsFinder";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.gisSurveySystemCheckResultManager = gisSurveySystemCheckResultManager;
     }
 
     /**
@@ -57,7 +63,8 @@ public class DuplicatePointsFinder {
      * @return 重复点
      */
     @Async
-    public ListenableFuture<List<List<GisSurveyCheckElement>>> findDuplicatePoints(List<GisSurveyLayerApplyPoint> points, List<TypeDefine> typeDefines) throws InterruptedException {
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findDuplicatePoints(List<GisSurveyLayerApplyPoint> points
+            , List<TypeDefine> typeDefines, GisSurveySystemCheckId systemCheckId) throws InterruptedException {
         //经纬度精度
         int lonScale = getScale(typeDefines, LNG_KEY);
         int latScale = getScale(typeDefines, LAT_KEY);
@@ -77,25 +84,18 @@ public class DuplicatePointsFinder {
                 }, Collectors.toList()));
         //响应中断
         if (Thread.interrupted()) throw new InterruptedException();
-        //并行流处理
-        List<List<GisSurveyCheckElement>> collect = keyToPoints.values().parallelStream()
+        //并行流寻找重复点
+        List<List<GisSurveySystemCheckElement>> groupElements = keyToPoints.values().parallelStream()
                 //过滤组内大于1
                 .filter(group -> group.size() > 1)
                 //转为返回元素
                 .map(group -> group.stream()
-                        .map(point-> BeanUtil.copy(point, GisSurveyCheckElement.class))
+                        .map(point -> BeanUtil.copy(point, GisSurveySystemCheckElement.class))
                         .collect(Collectors.toList())
                 )
                 .collect(Collectors.toList());
 
-        long end = System.currentTimeMillis();
-        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
-                , String.format(
-                        "结束执行寻找重复点,用时(毫秒):%d"
-                        , (end - begin)
-                )
-        );
-        return new AsyncResult<>(collect);
+        return new AsyncResult<>(createResult(groupElements, systemCheckId, begin));
     }
 
     /**
@@ -124,4 +124,33 @@ public class DuplicatePointsFinder {
         }
         return DEFAULT_SCALE;
     }
+
+    /**
+     * 创建结果
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param begin         开始时间
+     * @return 结果
+     */
+    private GisSurveySystemCheckResultDetail createResult(List<List<GisSurveySystemCheckElement>> data
+            , GisSurveySystemCheckId systemCheckId, long begin) {
+        //数据大小
+        final int size = data.size();
+        //写入路径
+        String path = GisSurveySystemCheckResultPath.DUPLICATE_POINTS;
+        //写入文件
+        gisSurveySystemCheckResultManager.writeResult(data, systemCheckId, path);
+
+        long end = System.currentTimeMillis();
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "结束执行寻找重复点,用时(毫秒):%d"
+                        , (end - begin)
+                )
+        );
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true, path, size);
+    }
 }

+ 45 - 8
src/main/java/com/shkpr/service/alambizplugin/components/checker/IsolatedLinesFinder.java

@@ -4,9 +4,13 @@ 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.components.GisSurveySystemCheckResultManager;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Component;
@@ -30,10 +34,12 @@ public class IsolatedLinesFinder {
      */
     private final String mStrClassName;
     private final String mBizType;
+    private final GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager;
 
-    public IsolatedLinesFinder() {
+    public IsolatedLinesFinder(GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager) {
         mStrClassName = "IsolatedLinesFinder";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.gisSurveySystemCheckResultManager = gisSurveySystemCheckResultManager;
     }
 
     /**
@@ -43,14 +49,15 @@ public class IsolatedLinesFinder {
      * @return 线分组
      */
     @Async
-    public ListenableFuture<List<List<GisSurveyCheckElement>>> findIsolatedLines(List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findIsolatedLines(List<GisSurveyLayerApplyLine> lines
+            , GisSurveySystemCheckId systemCheckId) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找孤立线========>");
         long begin = System.currentTimeMillis();
 
         //创建并查集
         UnionFind unionFind = new UnionFind();
         //分组线
-        List<List<GisSurveyCheckElement>> groupLines = unionFind.groupLines(lines);
+        List<List<GisSurveySystemCheckElement>> groupElements = unionFind.groupLines(lines);
 
         long end = System.currentTimeMillis();
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -59,7 +66,37 @@ public class IsolatedLinesFinder {
                         , (end - begin)
                 )
         );
-        return new AsyncResult<>(groupLines);
+        return new AsyncResult<>(createResult(groupElements, systemCheckId, begin));
+
+    }
+
+    /**
+     * 创建结果
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param begin         开始时间
+     * @return 结果
+     */
+    private GisSurveySystemCheckResultDetail createResult(List<List<GisSurveySystemCheckElement>> data
+            , GisSurveySystemCheckId systemCheckId, long begin) {
+        //数据大小
+        final int size = data.size();
+        //写入路径
+        String path = GisSurveySystemCheckResultPath.ISOLATED_LINES;
+        //写入文件
+        gisSurveySystemCheckResultManager.writeResult(data, systemCheckId, path);
+
+        long end = System.currentTimeMillis();
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "结束执行寻找孤立线,用时(毫秒):%d"
+                        , (end - begin)
+                )
+        );
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true, path, size);
     }
 
     /**
@@ -79,7 +116,7 @@ public class IsolatedLinesFinder {
          * @param lines 线集合
          * @return 分组集合
          */
-        public List<List<GisSurveyCheckElement>> groupLines(List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
+        public List<List<GisSurveySystemCheckElement>> groupLines(List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
             //处理所有线
             for (GisSurveyLayerApplyLine line : lines) {
                 //响应中断
@@ -105,7 +142,7 @@ public class IsolatedLinesFinder {
             //清理关系表
             pointRoot.clear();
             //构建分组结果
-            Map<String, List<GisSurveyCheckElement>> groups = new HashMap<>();
+            Map<String, List<GisSurveySystemCheckElement>> groups = new HashMap<>();
             for (GisSurveyLayerApplyLine line : lines) {
                 //响应中断
                 if (Thread.interrupted()) throw new InterruptedException();
@@ -116,7 +153,7 @@ public class IsolatedLinesFinder {
                 //当前线存入根线组
                 groups.computeIfAbsent(rootCode, k -> new ArrayList<>())
                         //转为返回元素
-                        .add(BeanUtil.copy(line, GisSurveyCheckElement.class));
+                        .add(BeanUtil.copy(line, GisSurveySystemCheckElement.class));
             }
             return new ArrayList<>(groups.values());
         }

+ 45 - 17
src/main/java/com/shkpr/service/alambizplugin/components/checker/IsolatedPointsFinder.java

@@ -4,10 +4,14 @@ 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.components.GisSurveySystemCheckResultManager;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
@@ -31,37 +35,41 @@ public class IsolatedPointsFinder {
      */
     private final String mStrClassName;
     private final String mBizType;
+    private final GisSurveySystemCheckResultManager systemCheckResultManager;
 
-    public IsolatedPointsFinder() {
+    public IsolatedPointsFinder(GisSurveySystemCheckResultManager systemCheckResultManager) {
         mStrClassName = "IsolatedPointsFinder";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.systemCheckResultManager = systemCheckResultManager;
     }
 
     /**
      * 寻找孤立点
      * <p>根据 {@code code} 上下游匹配,不涉及拓扑点</p><p>标识: {@code code} 唯一</p>
      *
-     * @param points 点集合
-     * @param lines  线集合
+     * @param points        点集合
+     * @param lines         线集合
+     * @param systemCheckId 系统检查id
      * @return 孤立点集合
      */
     @Async
-    public ListenableFuture<List<GisSurveyCheckElement>> findIsolatedPoints(List<GisSurveyLayerApplyPoint> points, List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findIsolatedPoints(List<GisSurveyLayerApplyPoint> points
+            , List<GisSurveyLayerApplyLine> lines, GisSurveySystemCheckId systemCheckId) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找孤立点========>");
         long begin = System.currentTimeMillis();
 
         //线为空,点不为空,则全孤立点
-        if (lines.isEmpty() && !points.isEmpty())
-            return new AsyncResult<>(
-                    points.parallelStream()
-                            //转为返回元素
-                            .map(point -> BeanUtil.copy(point, GisSurveyCheckElement.class))
-                            .collect(Collectors.toList())
-            );
+        if (lines.isEmpty() && !points.isEmpty()) {
+            List<GisSurveySystemCheckElement> elements = points.parallelStream()
+                    //转为返回元素
+                    .map(point -> BeanUtil.copy(point, GisSurveySystemCheckElement.class))
+                    .collect(Collectors.toList());
+            return new AsyncResult<>(createResult(elements, systemCheckId, begin));
+        }
         //线为空,点也为空,则无孤立点
-        if (lines.isEmpty()) return new AsyncResult<>(Collections.emptyList());
+        if (lines.isEmpty()) return new AsyncResult<>(createResult(Collections.emptyList(), systemCheckId, begin));
         //点为空,则无孤立点
-        if (points.isEmpty()) return new AsyncResult<>(Collections.emptyList());
+        if (points.isEmpty()) return new AsyncResult<>(createResult(Collections.emptyList(), systemCheckId, begin));
         //计算预期最大容量,避免频繁扩容
         int expectedMaxSize = (int) (((long) lines.size() << 1) / .75f + 1);
         //联通点code
@@ -76,13 +84,31 @@ public class IsolatedPointsFinder {
             connectedPoints.add(line.getDownNode());
         }
         //使用并行流找出孤立点
-        List<GisSurveyCheckElement> collect = points.parallelStream()
+        List<GisSurveySystemCheckElement> elements = points.parallelStream()
                 //转为返回元素
-                .map(point -> BeanUtil.copy(point, GisSurveyCheckElement.class))
+                .map(point -> BeanUtil.copy(point, GisSurveySystemCheckElement.class))
                 //过滤连通点
                 .filter(element -> Objects.nonNull(element) && !connectedPoints.contains(element.getCode()))
                 .collect(Collectors.toList());
+        return new AsyncResult<>(createResult(elements, systemCheckId, begin));
+    }
 
+    /**
+     * 创建结果
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param begin         开始时间
+     * @return 结果
+     */
+    private GisSurveySystemCheckResultDetail createResult(List<GisSurveySystemCheckElement> data
+            , GisSurveySystemCheckId systemCheckId, long begin) {
+        //数据大小
+        final int size = data.size();
+        //写入路径
+        String path = GisSurveySystemCheckResultPath.ISOLATED_POINTS;
+        //写入文件
+        systemCheckResultManager.writeResult(data, systemCheckId, path);
 
         long end = System.currentTimeMillis();
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -91,7 +117,9 @@ public class IsolatedPointsFinder {
                         , (end - begin)
                 )
         );
-        return new AsyncResult<>(collect);
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true, path, size);
     }
 
 }

+ 43 - 14
src/main/java/com/shkpr/service/alambizplugin/components/checker/OverlapLinesFinder.java

@@ -3,9 +3,13 @@ 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.components.GisSurveySystemCheckResultManager;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisSurveyCheckElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import org.locationtech.jts.algorithm.Orientation;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.LineSegment;
@@ -33,10 +37,12 @@ public class OverlapLinesFinder {
      */
     private final String mStrClassName;
     private final String mBizType;
+    private final GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager;
 
-    public OverlapLinesFinder() {
+    public OverlapLinesFinder(GisSurveySystemCheckResultManager gisSurveySystemCheckResultManager) {
         mStrClassName = "OverlapLinesFinder";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.gisSurveySystemCheckResultManager = gisSurveySystemCheckResultManager;
     }
 
     /**
@@ -48,12 +54,13 @@ public class OverlapLinesFinder {
      * @return 重复线分组
      */
     @Async
-    public ListenableFuture<List<List<GisSurveyCheckElement>>> findDuplicateLines(List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findDuplicateLines(List<GisSurveyLayerApplyLine> lines
+            , GisSurveySystemCheckId systemCheckId) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找重复线========>");
         long begin = System.currentTimeMillis();
 
         //结果
-        List<List<GisSurveyCheckElement>> result = new ArrayList<>();
+        List<List<GisSurveySystemCheckElement>> groupElements = new ArrayList<>();
         //双层循环遍历所有线
         for (int i = 0; i < lines.size(); i++) {
             GisSurveyLayerApplyLine line1 = lines.get(i);
@@ -66,20 +73,13 @@ public class OverlapLinesFinder {
                 // 判断是否重复
                 if (calcDuplicateLines(line1, line2)) {
                     // 创建两两一组的重复线对
-                    result.add(Arrays.asList(BeanUtil.copy(line1, GisSurveyCheckElement.class),
-                            BeanUtil.copy(line2, GisSurveyCheckElement.class)));
+                    groupElements.add(Arrays.asList(BeanUtil.copy(line1, GisSurveySystemCheckElement.class),
+                            BeanUtil.copy(line2, GisSurveySystemCheckElement.class)));
                 }
             }
         }
 
-        long end = System.currentTimeMillis();
-        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
-                , String.format(
-                        "结束执行寻找重复线,用时(毫秒):%d"
-                        , (end - begin)
-                )
-        );
-        return new AsyncResult<>(result);
+        return new AsyncResult<>(createResult(groupElements, systemCheckId, begin));
     }
 
     /**
@@ -115,4 +115,33 @@ public class OverlapLinesFinder {
         //判断最大因子是否向前延伸或处于线段内,并且最小因子是否向后延伸或处于线段内
         return (cdMax + EPSILON >= 0) && (cdMin - EPSILON <= 1);
     }
+
+    /**
+     * 创建结果
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param begin         开始时间
+     * @return 结果
+     */
+    private GisSurveySystemCheckResultDetail createResult(List<List<GisSurveySystemCheckElement>> data
+            , GisSurveySystemCheckId systemCheckId, long begin) {
+        //数据大小
+        final int size = data.size();
+        //写入路径
+        String path = GisSurveySystemCheckResultPath.OVERLAP_LINES;
+        //写入文件
+        gisSurveySystemCheckResultManager.writeResult(data, systemCheckId, path);
+
+        long end = System.currentTimeMillis();
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "结束执行寻找重复线,用时(毫秒):%d"
+                        , (end - begin)
+                )
+        );
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true, path, size);
+    }
 }

+ 2 - 2
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyCheckStatusEnum.java

@@ -13,11 +13,11 @@ import lombok.Getter;
 @Getter
 public enum GisSurveyCheckStatusEnum {
     /**
-     * 项目
+     * 进行中
      */
     IN_PROGRESS(0),
     /**
-     * 任务
+     * 成功
      */
     SUCCESS(1),
     /**

+ 30 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveySystemCheckResultPath.java

@@ -0,0 +1,30 @@
+package com.shkpr.service.alambizplugin.constants;
+
+/**
+ * 系统检查结果路径
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public class GisSurveySystemCheckResultPath {
+    /**
+     * 结果
+     */
+    public final static String RESULT = "result.json";
+    /**
+     * 孤立点
+     */
+    public final static String ISOLATED_POINTS = "isolatedPoints.json";
+    /**
+     * 孤立线
+     */
+    public final static String ISOLATED_LINES = "IsolatedLines.json";
+    /**
+     * 重复点
+     */
+    public final static String DUPLICATE_POINTS = "duplicatePoints.json";
+    /**
+     * 重叠线
+     */
+    public final static String OVERLAP_LINES = "OverlapLines.json";
+}

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

@@ -11,7 +11,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.dto.GisSurveyCheckResult;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
 import com.shkpr.service.alambizplugin.dto.ResponseRes;
 import com.shkpr.service.alambizplugin.exception.SelfException;
 import org.springframework.validation.BindingResult;
@@ -64,7 +64,7 @@ public class ApiGisSurveyController {
      * @throws SelfException selfException
      */
     @PostMapping(value = ApiURI.URI_XXX_SYS_CHECK)
-    public ResponseRes<GisSurveyCheckResult> sysCheck(HttpServletRequest request
+    public ResponseRes<GisSurveySystemCheckResult> sysCheck(HttpServletRequest request
             , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
             , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
             , @RequestBody(required = false) @Validated(value = {CommonParamValidSK.class}) GisSurveyCheckParams oJsonParam
@@ -90,11 +90,11 @@ public class ApiGisSurveyController {
                         , strRunSeq
                         , oJsonParam));
         //构建result
-        ResponseRes<GisSurveyCheckResult> resResult = new ResponseRes<>();
+        ResponseRes<GisSurveySystemCheckResult> resResult = new ResponseRes<>();
         resResult.setResmsg(MSG_FAILED);
         resResult.setResdata(null);
         //执行系统检查
-        GisSurveyCheckResult result = gisSurveyBizService.sysCheckFun(oJsonParam);
+        GisSurveySystemCheckResult result = gisSurveyBizService.sysCheckFun(oJsonParam);
         resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
         resResult.setResdata(result);
         resResult.setResmsg(MSG_SUCCESS);
@@ -123,7 +123,7 @@ public class ApiGisSurveyController {
      * @throws SelfException selfException
      */
     @PostMapping(value = ApiURI.URI_XXX_SYS_CHECK_GET)
-    public ResponseRes<GisSurveyCheckResult> getCheck(HttpServletRequest request
+    public ResponseRes<GisSurveySystemCheckResult> getCheck(HttpServletRequest request
             , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
             , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
             , @RequestBody(required = false) @Validated(value = {CommonParamValidSK.class}) GisSurveyCheckParams oJsonParam
@@ -149,10 +149,10 @@ public class ApiGisSurveyController {
                         , strRunSeq
                         , oJsonParam));
         //构建result
-        ResponseRes<GisSurveyCheckResult> resResult = new ResponseRes<>();
+        ResponseRes<GisSurveySystemCheckResult> resResult = new ResponseRes<>();
         resResult.setResmsg(MSG_FAILED);
         //尝试获取系统检查result
-        GisSurveyCheckResult result = gisSurveyBizService.getResult(oJsonParam);
+        GisSurveySystemCheckResult result = gisSurveyBizService.getResult(oJsonParam);
         resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
         resResult.setResdata(result);
         resResult.setResmsg(MSG_SUCCESS);
@@ -210,7 +210,7 @@ public class ApiGisSurveyController {
         ResponseRes<Boolean> resResult = new ResponseRes<>();
         resResult.setResmsg(MSG_FAILED);
         //执行删除返回
-        GisSurveyCheckResult delResult = gisSurveyBizService.delResult(oJsonParam);
+        GisSurveySystemCheckResult delResult = gisSurveyBizService.delResult(oJsonParam);
         //成功
         if (Objects.equals(delResult.getCheckStatus(), GisSurveyCheckStatusEnum.SUCCESS.getCode())) {
             resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());

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

@@ -0,0 +1,23 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集任务基本信息mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface GisSurveyJobInfoMapper {
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+}

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

@@ -0,0 +1,23 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集项目基本信息mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface GisSurveyProjectInfoMapper {
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+}

+ 34 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyJobInfoServiceImpl.java

@@ -0,0 +1,34 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyJobInfoService;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集任务基本信息service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Service
+public class GisSurveyJobInfoServiceImpl implements GisSurveyJobInfoService {
+    final
+    GisSurveyProjectInfoMapper ProjectInfoMapper;
+
+    public GisSurveyJobInfoServiceImpl(GisSurveyProjectInfoMapper ProjectInfoMapper) {
+        this.ProjectInfoMapper = ProjectInfoMapper;
+    }
+
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    @Override
+    public LocalDateTime findRefreshTimeByUid(String uid) {
+        return ProjectInfoMapper.findRefreshTimeByUid(uid);
+    }
+}

+ 34 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyProjectInfoServiceImpl.java

@@ -0,0 +1,34 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfoService;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集项目基本信息service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Service
+public class GisSurveyProjectInfoServiceImpl implements GisSurveyProjectInfoService {
+    final
+    GisSurveyProjectInfoMapper projectInfoMapper;
+
+    public GisSurveyProjectInfoServiceImpl(GisSurveyProjectInfoMapper projectInfoMapper) {
+        this.projectInfoMapper = projectInfoMapper;
+    }
+
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    @Override
+    public LocalDateTime findRefreshTimeByUid(String uid) {
+        return projectInfoMapper.findRefreshTimeByUid(uid);
+    }
+}

+ 21 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyJobInfoService.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集任务基本信息service
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface GisSurveyJobInfoService {
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+}

+ 21 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyProjectInfoService.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+
+/**
+ * 采集项目基本信息service
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface GisSurveyProjectInfoService {
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+}

+ 0 - 113
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckResult.java

@@ -1,113 +0,0 @@
-package com.shkpr.service.alambizplugin.dto;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
-import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
-import lombok.Data;
-import org.springframework.beans.BeanUtils;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import java.time.LocalDateTime;
-import java.util.List;
-
-/**
- * 系统检查返回dto
- *
- * @author 欧阳劲驰
- * @since 1.0.0
- */
-@Data
-public class GisSurveyCheckResult {
-    /**
-     * 检查状态:0:进行中,1:成功,2:失败,3:不存在,4:中断
-     */
-    private Integer checkStatus;
-    /**
-     * 检查类型:0:项目,1:任务
-     */
-    private Integer checkType;
-    /**
-     * 项目id
-     */
-    private String projId;
-    /**
-     * 任务id
-     */
-    private String jobId;
-    /**
-     * 当前操作人id
-     */
-    private String operator;
-    /**
-     * 请求检查时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime requestTime;
-    /**
-     * 完成检查时间
-     */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private LocalDateTime completeTime;
-    /**
-     * 孤立点code
-     */
-    private List<GisSurveyCheckElement> isolatedPoints;
-    /**
-     * 孤立线code
-     */
-    private List<List<GisSurveyCheckElement>> isolatedLines;
-    /**
-     * 重复点code集合
-     */
-    private List<List<GisSurveyCheckElement>> duplicatePoints;
-    /**
-     * 重叠线code集合
-     */
-    private List<List<GisSurveyCheckElement>> overlapLines;
-
-    /**
-     * 进行中
-     */
-    public static GisSurveyCheckResult inProgress(GisSurveyCheckParams params, LocalDateTime requestTime) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
-        BeanUtils.copyProperties(params, result);
-        result.setCheckStatus(GisSurveyCheckStatusEnum.IN_PROGRESS.getCode());
-        result.setRequestTime(requestTime);
-        return result;
-    }
-
-    /**
-     * 成功
-     */
-    public static GisSurveyCheckResult success(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
-        BeanUtils.copyProperties(params, result);
-        result.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
-        result.setRequestTime(LocalDateTime.now());
-        return result;
-    }
-
-    /**
-     * 失败
-     */
-    public static GisSurveyCheckResult fail(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
-        BeanUtils.copyProperties(params, result);
-        result.setCheckStatus(GisSurveyCheckStatusEnum.FAIL.getCode());
-        result.setRequestTime(LocalDateTime.now());
-        return result;
-    }
-
-    /**
-     * 不存在
-     */
-    public static GisSurveyCheckResult notExists(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
-        BeanUtils.copyProperties(params, result);
-        result.setCheckStatus(GisSurveyCheckStatusEnum.NOT_EXISTS.getCode());
-        return result;
-    }
-
-}

+ 0 - 40
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckTaskId.java

@@ -1,40 +0,0 @@
-package com.shkpr.service.alambizplugin.dto;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.ToString;
-
-import java.util.Objects;
-
-/**
- * 系统任务id
- *
- * @author 欧阳劲驰
- * @since 1.0.0
- */
-@Getter
-@AllArgsConstructor
-@ToString
-public class GisSurveyCheckTaskId {
-    /**
-     * 任务类型:0:项目,1:任务
-     */
-    private final Integer checkType;
-    /**
-     * 标识(项目code/任务code)
-     */
-    private final String code;
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        GisSurveyCheckTaskId that = (GisSurveyCheckTaskId) o;
-        return Objects.equals(checkType, that.checkType) && Objects.equals(code, that.code);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(checkType, code);
-    }
-}

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckElement.java

@@ -14,7 +14,7 @@ import org.locationtech.jts.geom.Geometry;
  * @since 1.0.0
  */
 @Data
-public class GisSurveyCheckElement {
+public class GisSurveySystemCheckElement {
     /**
      * 元素唯一编码
      */

+ 66 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckId.java

@@ -0,0 +1,66 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
+import com.shkpr.service.alambizplugin.constants.GisSurveyCheckTypeEnum;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * 系统检查id
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Getter
+@AllArgsConstructor
+@ToString
+public class GisSurveySystemCheckId {
+    /**
+     * 检查类型:0:项目,1:任务
+     */
+    private final GisSurveyCheckTypeEnum checkType;
+    /**
+     * 标识(项目code/任务code)
+     */
+    private final String code;
+
+    /**
+     * 生成任务id
+     *
+     * @param params 系统检查参数
+     * @return 系统检查id
+     */
+    public static GisSurveySystemCheckId generateId(GisSurveyCheckParams params) {
+        //获取枚举
+        GisSurveyCheckTypeEnum checkTypeEnum = Arrays.stream(GisSurveyCheckTypeEnum.values())
+                .filter(enumeration -> Objects.equals(params.getCheckType(), enumeration.getCode()))
+                .findFirst().orElse(null);
+        if (checkTypeEnum == null) return null;
+        //项目维度
+        if (checkTypeEnum.equals(GisSurveyCheckTypeEnum.PROJECT)) {
+            return new GisSurveySystemCheckId(GisSurveyCheckTypeEnum.PROJECT, params.getProjId());
+        }
+        //任务维度
+        else if (checkTypeEnum.equals(GisSurveyCheckTypeEnum.JOB)) {
+            return new GisSurveySystemCheckId(GisSurveyCheckTypeEnum.PROJECT, params.getJobId());
+        }
+        return null;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        GisSurveySystemCheckId that = (GisSurveySystemCheckId) o;
+        return Objects.equals(checkType, that.checkType) && Objects.equals(code, that.code);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(checkType, code);
+    }
+}

+ 148 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResult.java

@@ -0,0 +1,148 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
+import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
+import lombok.Data;
+import org.springframework.beans.BeanUtils;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * 系统检查返回dto
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Data
+public class GisSurveySystemCheckResult {
+    /**
+     * 检查状态:0:进行中,1:成功,2:失败,3:不存在,4:中断
+     */
+    private Integer checkStatus;
+    /**
+     * 检查类型:0:项目,1:任务
+     */
+    private Integer checkType;
+    /**
+     * 项目id
+     */
+    private String projId;
+    /**
+     * 任务id
+     */
+    private String jobId;
+    /**
+     * 当前操作人id
+     */
+    private String operator;
+    /**
+     * 请求检查时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime requestTime;
+    /**
+     * 完成检查时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime completeTime;
+    /**
+     * 元素/属性的变化时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime refreshTime;
+    /**
+     * 孤立点结果
+     */
+    private GisSurveySystemCheckResultDetail isolatedPointsResult = new GisSurveySystemCheckResultDetail();
+    /**
+     * 孤立线结果
+     */
+    private GisSurveySystemCheckResultDetail isolatedLinesResult = new GisSurveySystemCheckResultDetail();
+    /**
+     * 重复点结果
+     */
+    private GisSurveySystemCheckResultDetail duplicatePointsResult = new GisSurveySystemCheckResultDetail();
+    /**
+     * 重叠线结果
+     */
+    private GisSurveySystemCheckResultDetail overlapLinesResult = new GisSurveySystemCheckResultDetail();
+    /**
+     * 孤立点集合
+     */
+    private List<GisSurveySystemCheckElement> isolatedPoints;
+    /**
+     * 孤立线code
+     */
+    private List<List<GisSurveySystemCheckElement>> isolatedLines;
+    /**
+     * 重复点code集合
+     */
+    private List<List<GisSurveySystemCheckElement>> duplicatePoints;
+    /**
+     * 重叠线code集合
+     */
+    private List<List<GisSurveySystemCheckElement>> overlapLines;
+
+    /**
+     * 进行中
+     */
+    public static GisSurveySystemCheckResult inProgress(GisSurveyCheckParams params, GisSurveySystemCheckSubtask subtask, LocalDateTime requestTime) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
+        BeanUtils.copyProperties(params, result);
+
+        //设置子任务状态
+        if (subtask != null) {
+            if (subtask.getIsolatedPointsFuture() != null)
+                result.getIsolatedPointsResult().setDone(subtask.getIsolatedPointsFuture().isDone());
+            if (subtask.getIsolatedLinesFuture() != null)
+                result.getIsolatedLinesResult().setDone(subtask.getIsolatedLinesFuture().isDone());
+            if (subtask.getDuplicatePointsFuture() != null)
+                result.getDuplicatePointsResult().setDone(subtask.getDuplicatePointsFuture().isDone());
+            if (subtask.getOverlapLinesFuture() != null)
+                result.getOverlapLinesResult().setDone(subtask.getOverlapLinesFuture().isDone());
+        }
+
+        result.setCheckStatus(GisSurveyCheckStatusEnum.IN_PROGRESS.getCode());
+        result.setRequestTime(requestTime);
+        return result;
+    }
+
+    /**
+     * 成功
+     */
+    public static GisSurveySystemCheckResult success(GisSurveyCheckParams params) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
+        BeanUtils.copyProperties(params, result);
+        result.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
+        result.setRequestTime(LocalDateTime.now());
+        return result;
+    }
+
+    /**
+     * 失败
+     */
+    public static GisSurveySystemCheckResult fail(GisSurveyCheckParams params) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
+        BeanUtils.copyProperties(params, result);
+        result.setCheckStatus(GisSurveyCheckStatusEnum.FAIL.getCode());
+        result.setRequestTime(LocalDateTime.now());
+        return result;
+    }
+
+    /**
+     * 不存在
+     */
+    public static GisSurveySystemCheckResult notExists(GisSurveyCheckParams params) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
+        BeanUtils.copyProperties(params, result);
+        result.setCheckStatus(GisSurveyCheckStatusEnum.NOT_EXISTS.getCode());
+        return result;
+    }
+
+}

+ 31 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResultDetail.java

@@ -0,0 +1,31 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * 系统检查结果详情
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+public class GisSurveySystemCheckResultDetail {
+    /**
+     * 完成状态
+     */
+    private boolean done = false;
+    /**
+     * 结果地址
+     */
+    private String path;
+    /**
+     * 结果大小
+     */
+    private Integer size;
+}

+ 34 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckSubtask.java

@@ -0,0 +1,34 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.util.concurrent.ListenableFuture;
+
+/**
+ * 系统检查子任务
+ *
+ * @author 欧阳劲驰
+ * @since 0.0.1
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+public class GisSurveySystemCheckSubtask {
+    /**
+     * 孤立点任务
+     */
+    private ListenableFuture<GisSurveySystemCheckResultDetail> isolatedPointsFuture;
+    /**
+     * 孤立线任务
+     */
+    private ListenableFuture<GisSurveySystemCheckResultDetail> IsolatedLinesFuture;
+    /**
+     * 重复点任务
+     */
+    private ListenableFuture<GisSurveySystemCheckResultDetail> duplicatePointsFuture;
+    /**
+     * 重叠线任务
+     */
+    private ListenableFuture<GisSurveySystemCheckResultDetail> overlapLinesFuture;
+}

+ 10 - 12
src/main/java/com/shkpr/service/alambizplugin/globalmgr/ScheduleTaskMgr.java

@@ -4,13 +4,14 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.global.base.thread.ThreadPoolProxy;
 import com.shkpr.service.alambizplugin.bizservice.GisSurveyBizService;
+import com.shkpr.service.alambizplugin.commproperties.GisSurveySystemCheckProperties;
 import com.shkpr.service.alambizplugin.commtools.TimeTool;
 import com.shkpr.service.alambizplugin.components.GisDynamicDataSource;
 import com.shkpr.service.alambizplugin.components.locks.AlarmOrderLockMgr;
 import com.shkpr.service.alambizplugin.components.locks.SurveyBizLockMgr;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.zaxxer.hikari.HikariDataSource;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -21,19 +22,16 @@ import java.util.Map;
 import java.util.Set;
 
 @Component
+@EnableConfigurationProperties(GisSurveySystemCheckProperties.class)
 public class ScheduleTaskMgr {
-    final
-    GisSurveyBizService gisSurveyBizService;
-
-    /**
-     * 系统检查任务超时时间
-     */
-    @Value("${system-check.ttl}")
-    private Long ttl;
     private final String mStrClassName;
+    private final GisSurveySystemCheckProperties systemCheckProperties;
+    private final GisSurveyBizService gisSurveyBizService;
+
 
-    public ScheduleTaskMgr(GisSurveyBizService gisSurveyBizService) {
+    public ScheduleTaskMgr(GisSurveySystemCheckProperties systemCheckProperties, GisSurveyBizService gisSurveyBizService) {
         mStrClassName = this.getClass().getSimpleName();
+        this.systemCheckProperties = systemCheckProperties;
         this.gisSurveyBizService = gisSurveyBizService;
     }
 
@@ -53,8 +51,8 @@ public class ScheduleTaskMgr {
     @Scheduled(fixedRateString = "${system-check.ttl-check-interval}")
     public void sysCheckTasksTtl() {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue(), mStrClassName
-                , String.format("开始执行系统检查超时任务 ttl(毫秒):%s ======>", ttl));
-        if (ttl != null) gisSurveyBizService.expireResult(ttl);
+                , String.format("开始执行系统检查超时任务 ttl:%s ======>", systemCheckProperties.getTtl()));
+        if (systemCheckProperties.getTtl() != null) gisSurveyBizService.expireResult(systemCheckProperties.getTtl());
     }
 
     @Scheduled(cron = "${cron.refresh.timer.clock}")

+ 6 - 2
src/main/resources/application.properties

@@ -139,10 +139,14 @@ fdfs.pool.max-wait-millis=5000
 des.proxy.fdfs=http://116.63.130.83:9999
 
 #=============系统检查========================
-#超时时间(毫秒)
-system-check.ttl= 1800000
+#超时时间
+system-check.ttl= 24h
 #检查周期(毫秒)
 system-check.ttl-check-interval= 60000
+#资源路径
+system-check.resource-path= /Users/aozzl/IDE/IdeaProjects/KprAlamBizPlugin/system-check-results
+#结果滞后时间
+system-check.result-lag-duration= 30m
 
 
 

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

@@ -0,0 +1,9 @@
+<?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.GisSurveyJobInfoMapper">
+    <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>
+</mapper>

+ 9 - 0
src/main/resources/mapper/GisSurveyProjectInfoMapper.xml

@@ -0,0 +1,9 @@
+<?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>
+</mapper>