Browse Source

Merge branch 'develop'

# Conflicts:
#	src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyBizService.java
#	src/main/resources/application.properties
欧阳劲驰 2 months ago
parent
commit
58ed53d426
34 changed files with 1222 additions and 374 deletions
  1. 42 0
      src/main/java/com/shkpr/service/alambizplugin/apiparam/GisSurveyCheckParams.java
  2. 129 96
      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. 82 50
      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. 37 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. 52 23
      src/main/java/com/shkpr/service/alambizplugin/components/checker/OverlapLinesFinder.java
  10. 26 2
      src/main/java/com/shkpr/service/alambizplugin/configuration/WebMvcConfiguration.java
  11. 3 1
      src/main/java/com/shkpr/service/alambizplugin/configuration/WebSecurityConfiguration.java
  12. 2 2
      src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java
  13. 2 2
      src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyCheckStatusEnum.java
  14. 43 0
      src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveySystemCheckResultPath.java
  15. 5 0
      src/main/java/com/shkpr/service/alambizplugin/constants/ResponseCode.java
  16. 36 84
      src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java
  17. 20 2
      src/main/java/com/shkpr/service/alambizplugin/controllerfilter/JWTAuthenticationFilter.java
  18. 2 0
      src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTGisSurveyBizFilter.java
  19. 23 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyJobInfoMapper.java
  20. 23 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyProjectInfoMapper.java
  21. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyJobInfoServiceImpl.java
  22. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyProjectInfoServiceImpl.java
  23. 21 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyJobInfoService.java
  24. 21 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyProjectInfoService.java
  25. 0 40
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckTaskId.java
  26. 1 1
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckElement.java
  27. 66 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckId.java
  28. 36 18
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckResult.java
  29. 31 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResultDetail.java
  30. 34 0
      src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckSubtask.java
  31. 10 12
      src/main/java/com/shkpr/service/alambizplugin/globalmgr/ScheduleTaskMgr.java
  32. 6 2
      src/main/resources/application.properties
  33. 9 0
      src/main/resources/mapper/GisSurveyJobInfoMapper.xml
  34. 9 0
      src/main/resources/mapper/GisSurveyProjectInfoMapper.xml

+ 42 - 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,47 @@ public class GisSurveyCheckParams {
     private String operator;
 
     /**
+     * 忽略失败
+     */
+    private Boolean ignoreFail = false;
+
+    /**
+     * 返回上次结果
+     */
+    private Boolean returnLastResult = false;
+
+    /**
+     * 是否启动检查(满足检查条件的情况下)
+     */
+    private Boolean checkStart = true;
+
+    /**
+     * 孤立点启动
+     */
+    private Boolean isolatedPointsStart = true;
+
+    /**
+     * 孤立线启动
+     */
+    private Boolean isolatedLinesStart = true;
+
+    /**
+     * 重复点启动
+     */
+    private Boolean duplicatePointsStart = true;
+
+    /**
+     * 重叠线启动
+     */
+    private Boolean overlapLinesStart = true;
+
+    /**
+     * 元素/属性的变化时间
+     * <p>系统内部用</p>
+     */
+    private LocalDateTime refreshTime;
+
+    /**
      * 入参校验
      *
      * @return 校验状态

+ 129 - 96
src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyBizService.java

@@ -3,17 +3,22 @@ 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.GisSurveyCheckStatusEnum;
 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;
@@ -32,23 +37,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,100 +76,107 @@ 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);
-        //进行中判断(未完成且未清除)
-        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);
-        //启动检查任务
-        startTask(taskId, params);
-        //返回进行中
-        return GisSurveyCheckResult.inProgress(params, LocalDateTime.now());
-    }
-
-    /**
-     * 获取结果
-     *
-     * @param params 系统检查参数
-     * @return 检查结果(可能进行中)
-     */
-    public GisSurveyCheckResult getResult(GisSurveyCheckParams params) {
-        //任务标识
-        GisSurveyCheckTaskId taskId = generateTaskId(params);
-        if (taskId == null) return GisSurveyCheckResult.notExists(params);
-        //获取任务
-        ListenableFuture<GisSurveyCheckResult> checkFuture = FUTURE_CACHE.get(taskId);
-        if (checkFuture == null) return GisSurveyCheckResult.notExists(params);
-        //已结束,则直接返回失败(如完成cancelled为false,切无法clear)
-        if (checkFuture.isCancelled()) return GisSurveyCheckResult.fail(params);
-        //完成判断,如完成直接返回结果
-        if (checkFuture.isDone()) {
+        ListenableFuture<GisSurveySystemCheckResult> previousFuture = TASK_CACHE.get(systemCheckId);
+        //如任务已完成,则检查历史失败
+        if (!params.getIgnoreFail() && previousFuture != null && previousFuture.isDone()) {
             try {
-                return FUTURE_CACHE.get(taskId).get();
-            } catch (ExecutionException | InterruptedException e) {
-                //打印报错信息(不太可能走到这里)
+                //获取结果,并检查失败
+                GisSurveySystemCheckResult gisSurveySystemCheckResult = previousFuture.get();
+                if (Objects.equals(gisSurveySystemCheckResult.getCheckStatus(), GisSurveyCheckStatusEnum.FAIL.getCode()))
+                    return gisSurveySystemCheckResult;
+            } catch (InterruptedException | ExecutionException e) {
+                //打印报错信息(不太可能走到这)
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
-                        , String.format(
-                                "监测到中断或执行异常 param:%s msg:%s"
-                                , params
-                                , e.getMessage()
-                        )
+                        , String.format("检查历史失败异常 系统检查id:%s msg:%s", systemCheckId, e.getMessage())
                 );
-                return GisSurveyCheckResult.fail(params);
             }
+
+        }
+
+        //获取已存在的结果
+        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 GisSurveySystemCheckResult.inProgress(params, checkSubtask, TIME_CACHE.get(systemCheckId));
+        //启动检查任务
+        if (Boolean.TRUE.equals(params.getCheckStart())) {
+            startTask(systemCheckId, params);
+            //如需要返回上次结果,则直接返回结果
+            if (Boolean.TRUE.equals(params.getReturnLastResult())) {
+                return result;
+            }
+            //返回进行中
+            return GisSurveySystemCheckResult.inProgress(params, checkSubtask, LocalDateTime.now());
         }
-        //返回进行中
-        return GisSurveyCheckResult.inProgress(params, TIME_CACHE.get(taskId));
+        //未启动返回结果
+        return result;
     }
 
     /**
-     * 删除结果
+     * 取消检查
      *
      * @param params 系统检查参数
      * @return 检查结果(可能进行中)
      */
-    public GisSurveyCheckResult delResult(GisSurveyCheckParams params) {
+    public GisSurveySystemCheckResult cancelCheck(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>
-     *
-     * @param ttl 超时时间(分钟)
      */
-    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()).toMinutes() > ttl)
+        List<GisSurveySystemCheckId> systemCheckIds = 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 systemCheckId : systemCheckIds) {
             //如任务不存在,则删除时间缓存
-            if (!FUTURE_CACHE.containsKey(taskId)) TIME_CACHE.remove(taskId);
+            if (!TASK_CACHE.containsKey(systemCheckId)) TIME_CACHE.remove(systemCheckId);
             //停用缓存
-            if (stopTask(taskId)) TIME_CACHE.remove(taskId);
+            if (stopTask(systemCheckId)) TIME_CACHE.remove(systemCheckId);
             else {
                 //打印报错信息
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
                         , String.format(
-                                "过期任务停止失败 ttl:%s taskId:%s"
+                                "过期任务停止失败 ttl:%s 系统检查id:%s"
                                 , ttl
-                                , taskId
+                                , systemCheckId
                         )
                 );
             }
@@ -158,54 +184,61 @@ 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;
+    private 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),
+                //删除子任务句柄
+                subtaskSystemCheckId -> SUBTASK_CACHE.remove(systemCheckId)
+        );
         //缓存任务句柄
-        FUTURE_CACHE.put(taskId, checkFuture);
+        TASK_CACHE.put(systemCheckId, checkFuture);
         //缓存时间
-        TIME_CACHE.put(taskId, LocalDateTime.now());
+        TIME_CACHE.put(systemCheckId, LocalDateTime.now());
     }
 
     /**
-     * 关闭检查任务
+     * 停止任务
      *
      * @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;
         }
@@ -213,7 +246,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 fileName      文件名
+     */
+    public void writeResult(Object data, GisSurveySystemCheckId systemCheckId, String fileName) {
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "开始执行写入结果文件,系统id:%s,文件名:%s========>"
+                        , systemCheckId
+                        , fileName
+                )
+        );
+        long begin = System.currentTimeMillis();
+
+        //写入文件
+        File file = Paths.get(TEMP_DIR_CACHE.get(systemCheckId).toString(), fileName).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
+                                , fileName
+                                , (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;
+        }
+    }
+}

+ 82 - 50
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;
@@ -63,27 +68,30 @@ public class GisSurveySystemChecker {
     /**
      * 系统检查任务
      *
-     * @param params 系统检查参数
+     * @param params              系统检查参数
+     * @param onStartSubtask      启动子任务
+     * @param onDeprecatedSubtask 弃用子任务(完成数据收集/取消)
      * @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, Consumer<GisSurveySystemCheckId> onDeprecatedSubtask) {
+        //系统检查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,96 +99,120 @@ 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);
+                if (params.getIsolatedPointsStart())
+                    isolatedPointsFuture = isolatedPointsFinder.findIsolatedPoints(points, lines, systemCheckId);
             }
             //重复点检查
             if (points != null) {
-                duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines);
+                if (params.getDuplicatePointsStart())
+                    duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, systemCheckId);
             }
             //孤立线和重叠线检查
             if (lines != null) {
-                IsolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines);
-                overlapLinesFuture = overlapLinesFinder.findDuplicateLines(lines);
+                if (params.getIsolatedLinesStart())
+                    isolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines, systemCheckId);
+                if (params.getOverlapLinesStart())
+                    overlapLinesFuture = overlapLinesFinder.findOverlapLines(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)) {
+                //弃用子任务
+                onDeprecatedSubtask.accept(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()
                     )
             );
+
+            //弃用子任务
+            onDeprecatedSubtask.accept(systemCheckId);
             return new AsyncResult<>(result);
         } 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);
+
             //失败信息
             result.setCheckStatus(GisSurveyCheckStatusEnum.FAIL.getCode());
             result.setCompleteTime(LocalDateTime.now());
+
+            //弃用子任务
+            onDeprecatedSubtask.accept(systemCheckId);
             return new AsyncResult<>(result);
         }
     }

+ 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, GisSurveySystemCheckResultPath.relativePath(systemCheckId, path), size);
+    }
 }

+ 37 - 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,35 @@ 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);
+
+        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
@@ -59,7 +86,9 @@ public class IsolatedLinesFinder {
                         , (end - begin)
                 )
         );
-        return new AsyncResult<>(groupLines);
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true, GisSurveySystemCheckResultPath.relativePath(systemCheckId, path), size);
     }
 
     /**
@@ -79,7 +108,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 +134,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 +145,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, GisSurveySystemCheckResultPath.relativePath(systemCheckId, path), size);
     }
 
 }

+ 52 - 23
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;
@@ -19,7 +23,7 @@ import java.util.Arrays;
 import java.util.List;
 
 /**
- * 寻找重线
+ * 寻找重线
  *
  * @author 欧阳劲驰
  * @since 0.0.1
@@ -33,27 +37,30 @@ 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;
     }
 
     /**
-     * 寻找重线
-     * <p>返回的为重复线组,未重复的线不会出现在返回结果</p>
+     * 寻找重线
+     * <p>返回的为重叠线组,未重叠的线不会出现在返回结果</p>
      * <p>一组线,仅为两条重叠的线,长度固定为2</p>
      *
      * @param lines 线集合
-     * @return 重线分组
+     * @return 重线分组
      */
     @Async
-    public ListenableFuture<List<List<GisSurveyCheckElement>>> findDuplicateLines(List<GisSurveyLayerApplyLine> lines) throws InterruptedException {
-        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找重复线========>");
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findOverlapLines(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);
@@ -63,23 +70,16 @@ public class OverlapLinesFinder {
                 GisSurveyLayerApplyLine line2 = lines.get(j);
                 //响应中断
                 if (Thread.interrupted()) throw new InterruptedException();
-                // 判断是否重
-                if (calcDuplicateLines(line1, line2)) {
-                    // 创建两两一组的重线对
-                    result.add(Arrays.asList(BeanUtil.copy(line1, GisSurveyCheckElement.class),
-                            BeanUtil.copy(line2, GisSurveyCheckElement.class)));
+                // 判断是否重
+                if (calcOverlapLines(line1, line2)) {
+                    // 创建两两一组的重线对
+                    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));
     }
 
     /**
@@ -89,7 +89,7 @@ public class OverlapLinesFinder {
      * @param line2 线段2
      * @return 重叠状态
      */
-    public boolean calcDuplicateLines(GisSurveyLayerApplyLine line1, GisSurveyLayerApplyLine line2) {
+    public boolean calcOverlapLines(GisSurveyLayerApplyLine line1, GisSurveyLayerApplyLine line2) {
         //取出四个点
         Coordinate a = line2.getGis().getCoordinateN(0);
         Coordinate b = line1.getGis().getCoordinateN(1);
@@ -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, GisSurveySystemCheckResultPath.relativePath(systemCheckId, path), size);
+    }
 }

+ 26 - 2
src/main/java/com/shkpr/service/alambizplugin/configuration/WebMvcConfiguration.java

@@ -1,5 +1,8 @@
 package com.shkpr.service.alambizplugin.configuration;
+
 import com.shkpr.service.alambizplugin.SpringContextUtil;
+import com.shkpr.service.alambizplugin.commproperties.GisSurveySystemCheckProperties;
+import com.shkpr.service.alambizplugin.constants.ApiURI;
 import com.shkpr.service.alambizplugin.interfaces.URIInterceptorIntef;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -9,7 +12,12 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 import org.springframework.web.filter.CorsFilter;
-import org.springframework.web.servlet.config.annotation.*;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
 import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
@@ -21,7 +29,23 @@ import java.util.TreeMap;
  */
 @Configuration
 @EnableWebMvc
-public class WebMvcConfiguration implements WebMvcConfigurer{
+public class WebMvcConfiguration implements WebMvcConfigurer {
+    final
+    GisSurveySystemCheckProperties systemCheckProperties;
+
+    public WebMvcConfiguration(GisSurveySystemCheckProperties systemCheckProperties) {
+        this.systemCheckProperties = systemCheckProperties;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        //系统检查结果映射
+        registry.addResourceHandler(ApiURI.URI_GIS_SURVEY_H + "/" + ApiURI.URI_XXX_SYS_CHECK_RESULTS + "/**")
+                .addResourceLocations("file:" + systemCheckProperties.getResourcePath() + "/");
+    }
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {

+ 3 - 1
src/main/java/com/shkpr/service/alambizplugin/configuration/WebSecurityConfiguration.java

@@ -50,7 +50,9 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
                 .antMatchers(ApiURI.URI_ACCESS_TOKEN_CHECK).permitAll()
                 .antMatchers(ApiURI.URI_FILE_BUSI_XXX).permitAll()
                 .antMatchers("/").permitAll()
-                .anyRequest().authenticated()                                                                                          //所有其他请求需要身份认证
+                //系统检查结果放行
+                .antMatchers(ApiURI.URI_GIS_SURVEY_H + "/" + ApiURI.URI_XXX_SYS_CHECK_RESULTS+"/**").permitAll()
+                .anyRequest().permitAll()                                                                                          //所有其他请求需要身份认证
                 .and()
                 .addFilterBefore(new ApiJWTBizFilterMgr(ApiURI.URI_ALL_BUSI_XXX, authenticationManager()),
                         UsernamePasswordAuthenticationFilter.class);

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

@@ -25,8 +25,8 @@ public class ApiURI {
     public static final String URI_XXX_CHG_PWD = "pwd-chg";
     public static final String URI_XXX_IMAGES = "images";
     public static final String URI_XXX_SYS_CHECK = "sys-check";
-    public static final String URI_XXX_SYS_CHECK_GET = "sys-check-get";
-    public static final String URI_XXX_SYS_CHECK_DEL = "sys-check-del";
+    public static final String URI_XXX_SYS_CHECK_CANCEL = "sys-check-cancel";
+    public static final String URI_XXX_SYS_CHECK_RESULTS = "sys-check-results";
 
     public static final String URI_ACCESS_TOKEN_CHECK = "/kpr-plugin/apply/access-token-check";
     public static final String URI_FILE_BUSI_XXX = "/files/**";

+ 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),
     /**

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

@@ -0,0 +1,43 @@
+package com.shkpr.service.alambizplugin.constants;
+
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
+
+/**
+ * 系统检查结果路径
+ *
+ * @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";
+
+    /**
+     * 获取相对路径
+     *
+     * @param systemCheckId 系统检查id
+     * @param fileName      文件名
+     * @return 相对路径
+     */
+    public static String relativePath(GisSurveySystemCheckId systemCheckId, String fileName) {
+        return systemCheckId.getCheckType().getFlag() + "-" + systemCheckId.getCode() + "/" + fileName;
+    }
+}

+ 5 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/ResponseCode.java

@@ -95,6 +95,11 @@ public enum ResponseCode {
 
     RESULT_FAST_DFS_UPLOAD_FAILED(30000, "Upload File To FastDfs Failed."),
 
+    RESULT_SYSTEM_CHECK_FAILED(40000, "System check failed."),
+    RESULT_SYSTEM_CHECK_NOT_FOUND(40001, "System check not found."),
+    RESULT_SYSTEM_CHECK_CANCEL_FAILED(40002, "System check cancel failed."),
+    RESULT_SYSTEM_CHECK_RESULT_NOT_FOUND(40003, "System check result not found."),
+
     BUSINESS_SYNC_FUN_FAILED(65529,"The Synch operation failed."),
     BUSINESS_DB_REQ_FAILED(65530,"The DB operation failed."),
     BUSINESS_API_ABOLISH(65531,"The Api has been abolished."),

+ 36 - 84
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;
@@ -29,16 +29,11 @@ import java.util.concurrent.atomic.AtomicInteger;
 @RequestMapping(ApiURI.URI_GIS_SURVEY_H)
 @RestController
 public class ApiGisSurveyController {
-    //message
-    final String MSG_SUCCESS = "success.";
-    final String MSG_FAILED = "failed.";
-    final String MSG_NOT_EXISTS = "notExists.";
     //log
     private final String mStrClassName;
     private final String mBizType;
     //计数器
     private final AtomicInteger mSeqSysCheckReq;
-    private final AtomicInteger mSeqSysCheckGetReq;
     private final AtomicInteger mSeqSysCheckDelReq;
 
     private final GisSurveyBizService gisSurveyBizService;
@@ -47,7 +42,6 @@ public class ApiGisSurveyController {
         mStrClassName = "ApiGisSurveyController";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         mSeqSysCheckReq = new AtomicInteger(0);
-        mSeqSysCheckGetReq = new AtomicInteger(0);
         mSeqSysCheckDelReq = new AtomicInteger(0);
         this.gisSurveyBizService = gisSurveyBizService;
     }
@@ -64,7 +58,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,72 +84,29 @@ public class ApiGisSurveyController {
                         , strRunSeq
                         , oJsonParam));
         //构建result
-        ResponseRes<GisSurveyCheckResult> resResult = new ResponseRes<>();
-        resResult.setResmsg(MSG_FAILED);
-        resResult.setResdata(null);
+        ResponseRes<GisSurveySystemCheckResult> resResult = new ResponseRes<>();
+        resResult.setRescode(ResponseCode.RESULT_SYSTEM_CHECK_FAILED.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_SYSTEM_CHECK_FAILED.toStrMsg());
+
         //执行系统检查
-        GisSurveyCheckResult result = gisSurveyBizService.sysCheckFun(oJsonParam);
-        resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
-        resResult.setResdata(result);
-        resResult.setResmsg(MSG_SUCCESS);
-        //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;
-    }
+        GisSurveySystemCheckResult result = gisSurveyBizService.sysCheckFun(oJsonParam);
 
-    /**
-     * 获取系统检查
-     *
-     * @param request       request
-     * @param strClientType 客户端类型
-     * @param strUserAgent  用户信息
-     * @param oJsonParam    参数
-     * @param bindRes       bindingResult
-     * @return 系统检查回执
-     * @throws SelfException selfException
-     */
-    @PostMapping(value = ApiURI.URI_XXX_SYS_CHECK_GET)
-    public ResponseRes<GisSurveyCheckResult> 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
-            , BindingResult bindRes) 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 (oJsonParam == null || bindRes.hasErrors() || !oJsonParam.checkValid()) {
-            throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrCode()
-                    , String.format(ApiURI.EXCEPTION_FORMAT
-                    , strPlatform
-                    , URI_PATH
-                    , ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrMsg()));
+        //执行成功
+        if (result != null && !Objects.equals(result.getCheckStatus(), GisSurveyCheckStatusEnum.FAIL.getCode())) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+            resResult.setResdata(result);
         }
-        //begin
-        long llReqBefore = System.currentTimeMillis();
-        String strRunSeq = String.format("%d-%d", llReqBefore, mSeqSysCheckGetReq.incrementAndGet());
-        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
-                , String.format("%s:%s seq:{%s} param:%s begin====>"
-                        , strPlatform
-                        , URI_PATH
-                        , strRunSeq
-                        , oJsonParam));
-        //构建result
-        ResponseRes<GisSurveyCheckResult> resResult = new ResponseRes<>();
-        resResult.setResmsg(MSG_FAILED);
-        //尝试获取系统检查result
-        GisSurveyCheckResult result = gisSurveyBizService.getResult(oJsonParam);
-        resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
-        resResult.setResdata(result);
-        resResult.setResmsg(MSG_SUCCESS);
+        //执行失败
+        if (result != null && Objects.equals(result.getCheckStatus(), GisSurveyCheckStatusEnum.FAIL.getCode())) {
+            resResult.setResdata(result);
+        }
+        //结果为空
+        if (result == null) {
+            resResult.setRescode(ResponseCode.RESULT_SYSTEM_CHECK_RESULT_NOT_FOUND.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_SYSTEM_CHECK_RESULT_NOT_FOUND.toStrMsg());
+        }
+
         //end
         resResult.setTimestamp(System.currentTimeMillis());
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
@@ -170,18 +121,18 @@ public class ApiGisSurveyController {
     }
 
     /**
-     * 除系统检查
+     * 除系统检查
      *
      * @param request       request
      * @param strClientType 客户端类型
      * @param strUserAgent  用户信息
      * @param oJsonParam    参数
      * @param bindRes       bindingResult
-     * @return 除状态
+     * @return 除状态
      * @throws SelfException selfException
      */
-    @PostMapping(value = ApiURI.URI_XXX_SYS_CHECK_DEL)
-    public ResponseRes<?> delCheck(HttpServletRequest request
+    @PostMapping(value = ApiURI.URI_XXX_SYS_CHECK_CANCEL)
+    public ResponseRes<?> cancelCheck(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
@@ -208,18 +159,19 @@ public class ApiGisSurveyController {
                         , oJsonParam));
         //构建result
         ResponseRes<Boolean> resResult = new ResponseRes<>();
-        resResult.setResmsg(MSG_FAILED);
-        //执行删除返回
-        GisSurveyCheckResult delResult = gisSurveyBizService.delResult(oJsonParam);
+        resResult.setRescode(ResponseCode.RESULT_SYSTEM_CHECK_CANCEL_FAILED.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_SYSTEM_CHECK_CANCEL_FAILED.toStrMsg());
+        //清除检查
+        GisSurveySystemCheckResult cancelCheck = gisSurveyBizService.cancelCheck(oJsonParam);
         //成功
-        if (Objects.equals(delResult.getCheckStatus(), GisSurveyCheckStatusEnum.SUCCESS.getCode())) {
-            resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
-            resResult.setResmsg(MSG_SUCCESS);
+        if (Objects.equals(cancelCheck.getCheckStatus(), GisSurveyCheckStatusEnum.SUCCESS.getCode())) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
         }
         //不存在
-        else if (Objects.equals(delResult.getCheckStatus(), GisSurveyCheckStatusEnum.NOT_EXISTS.getCode())) {
-            resResult.setRescode(ResponseCode.STATUS_SUCCESS.toStrCode());
-            resResult.setResmsg(MSG_NOT_EXISTS);
+        else if (Objects.equals(cancelCheck.getCheckStatus(), GisSurveyCheckStatusEnum.NOT_EXISTS.getCode())) {
+            resResult.setRescode(ResponseCode.RESULT_SYSTEM_CHECK_NOT_FOUND.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_SYSTEM_CHECK_NOT_FOUND.toStrMsg());
         }
         //end
         resResult.setTimestamp(System.currentTimeMillis());

+ 20 - 2
src/main/java/com/shkpr/service/alambizplugin/controllerfilter/JWTAuthenticationFilter.java

@@ -1,12 +1,14 @@
 package com.shkpr.service.alambizplugin.controllerfilter;
+
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.commtools.HttpTool;
+import com.shkpr.service.alambizplugin.constants.ApiURI;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.constants.ResponseCode;
 import com.shkpr.service.alambizplugin.controllercheck.JWTControllerCheck;
 import com.shkpr.service.alambizplugin.exception.SelfAuthFilterException;
 import com.shkpr.service.alambizplugin.globalcache.GlobalData;
-import com.shkpr.service.alambizplugin.constants.ResponseCode;
 import org.springframework.security.authentication.AccountExpiredException;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -16,6 +18,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
 import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 import org.springframework.security.web.util.matcher.RequestMatcher;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.util.PathMatcher;
 
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
@@ -29,13 +33,15 @@ import java.io.IOException;
  * 如果校验通过,就认为这是一个取得授权的合法请求
  */
 public class JWTAuthenticationFilter extends BasicAuthenticationFilter {
-    private RequestMatcher mRequestMatcher = null;
     protected String mStrThisSampleName = null;
     protected JWTControllerCheck mControllerCheck = null;
+    private RequestMatcher mRequestMatcher = null;
+    private PathMatcher mPathMatcher = null;
 
     public JWTAuthenticationFilter(AuthenticationManager authenticationManager){
         super(authenticationManager);
         this.mStrThisSampleName = this.getClass().getSimpleName();
+        mPathMatcher = new AntPathMatcher();
     }
 
     public JWTAuthenticationFilter(String url, AuthenticationManager authenticationManager){
@@ -43,6 +49,7 @@ public class JWTAuthenticationFilter extends BasicAuthenticationFilter {
         this.mStrThisSampleName = this.getClass().getSimpleName();
         if (url != null && !url.isEmpty())
             this.mRequestMatcher = new AntPathRequestMatcher(url);
+        mPathMatcher = new AntPathMatcher();
     }
 
     public void setControllerCheck(JWTControllerCheck mControllerCheck) {
@@ -56,6 +63,17 @@ public class JWTAuthenticationFilter extends BasicAuthenticationFilter {
             return;
         }
 
+        //系统检查结果放行
+        if (this.mPathMatcher != null &&
+                this.mPathMatcher.match(
+                        String.format("%s%s", request.getContextPath(), ApiURI.URI_GIS_SURVEY_H + "/" + ApiURI.URI_XXX_SYS_CHECK_RESULTS + "/**"),
+                        request.getRequestURI()
+                )
+        ) {
+            chain.doFilter(request, response);
+            return;
+        }
+
         if (mControllerCheck != null && !mControllerCheck.checkRequest(request, response))  //当前URI已匹配成功,但Request请求格式不对,不再向后传递
             return;
 

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

@@ -20,6 +20,8 @@ public class ApiJWTGisSurveyBizFilter extends JWTAuthenticationFilter {
     static {
         msMapURI2Method = new HashMap<String, String>();
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_SYS_CHECK), "POST");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_SYS_CHECK_CANCEL), "POST");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_SYS_CHECK_RESULTS), "GET");
     }
 
     public ApiJWTGisSurveyBizFilter(String url, AuthenticationManager authenticationManager){

+ 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.GisSurveyJobInfoMapper;
+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
+    GisSurveyJobInfoMapper jobInfoMapper;
+
+    public GisSurveyJobInfoServiceImpl(GisSurveyJobInfoMapper jobInfoMapper) {
+        this.jobInfoMapper = jobInfoMapper;
+    }
+
+    /**
+     * 根据uid查询刷新时间
+     *
+     * @param uid uid
+     * @return 刷新时间
+     */
+    @Override
+    public LocalDateTime findRefreshTimeByUid(String uid) {
+        return jobInfoMapper.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 - 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.JOB, 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);
+    }
+}

+ 36 - 18
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckResult.java

@@ -8,7 +8,6 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * 系统检查返回dto
@@ -17,7 +16,7 @@ import java.util.List;
  * @since 1.0.0
  */
 @Data
-public class GisSurveyCheckResult {
+public class GisSurveySystemCheckResult {
     /**
      * 检查状态:0:进行中,1:成功,2:失败,3:不存在,4:中断
      */
@@ -51,28 +50,47 @@ public class GisSurveyCheckResult {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime completeTime;
     /**
-     * 孤立点code
+     * 元素/属性的变化时间
      */
-    private List<GisSurveyCheckElement> isolatedPoints;
+    @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();
     /**
-     * 孤立线code
+     * 孤立线结果
      */
-    private List<List<GisSurveyCheckElement>> isolatedLines;
+    private GisSurveySystemCheckResultDetail isolatedLinesResult = new GisSurveySystemCheckResultDetail();
     /**
-     * 重复点code集合
+     * 重复点结果
      */
-    private List<List<GisSurveyCheckElement>> duplicatePoints;
+    private GisSurveySystemCheckResultDetail duplicatePointsResult = new GisSurveySystemCheckResultDetail();
     /**
-     * 重叠线code集合
+     * 重叠线结果
      */
-    private List<List<GisSurveyCheckElement>> overlapLines;
+    private GisSurveySystemCheckResultDetail overlapLinesResult = new GisSurveySystemCheckResultDetail();
 
     /**
      * 进行中
      */
-    public static GisSurveyCheckResult inProgress(GisSurveyCheckParams params, LocalDateTime requestTime) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
+    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;
@@ -81,8 +99,8 @@ public class GisSurveyCheckResult {
     /**
      * 成功
      */
-    public static GisSurveyCheckResult success(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
+    public static GisSurveySystemCheckResult success(GisSurveyCheckParams params) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
         BeanUtils.copyProperties(params, result);
         result.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
         result.setRequestTime(LocalDateTime.now());
@@ -92,8 +110,8 @@ public class GisSurveyCheckResult {
     /**
      * 失败
      */
-    public static GisSurveyCheckResult fail(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
+    public static GisSurveySystemCheckResult fail(GisSurveyCheckParams params) {
+        GisSurveySystemCheckResult result = new GisSurveySystemCheckResult();
         BeanUtils.copyProperties(params, result);
         result.setCheckStatus(GisSurveyCheckStatusEnum.FAIL.getCode());
         result.setRequestTime(LocalDateTime.now());
@@ -103,8 +121,8 @@ public class GisSurveyCheckResult {
     /**
      * 不存在
      */
-    public static GisSurveyCheckResult notExists(GisSurveyCheckParams params) {
-        GisSurveyCheckResult result = new GisSurveyCheckResult();
+    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;
+    /**
+     * 结果地址
+     */
+    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= 1440
+#超时时间
+system-check.ttl= 24h
 #检查周期(毫秒)
 system-check.ttl-check-interval= 60000
+#资源路径
+system-check.resource-path= /home/kprCloud/alam_dma_kpr_plugin/sys-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_job_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>