|
@@ -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.components.checker.OverlapLinesFinder;
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyCheckTypeEnum;
|
|
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.constants.LogFlagBusiType;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.TypeDefineService;
|
|
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.GisSurveyLayerApplyLine;
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
|
|
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 com.shkpr.service.alambizplugin.dto.TypeDefine;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.AsyncResult;
|
|
import org.springframework.scheduling.annotation.AsyncResult;
|
|
@@ -25,8 +28,8 @@ import org.springframework.util.concurrent.ListenableFuture;
|
|
import java.time.Duration;
|
|
import java.time.Duration;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Objects;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
+import java.util.function.Consumer;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 系统检查执行器
|
|
* 系统检查执行器
|
|
@@ -42,6 +45,7 @@ public class GisSurveySystemChecker {
|
|
private final String mStrClassName;
|
|
private final String mStrClassName;
|
|
private final String mBizType;
|
|
private final String mBizType;
|
|
|
|
|
|
|
|
+ private final GisSurveySystemCheckResultManager systemCheckResultManager;
|
|
private final GisSurveyLayerApplyService gisSurveyLayerApplyService;
|
|
private final GisSurveyLayerApplyService gisSurveyLayerApplyService;
|
|
private final TypeDefineService typeDefineService;
|
|
private final TypeDefineService typeDefineService;
|
|
private final IsolatedPointsFinder isolatedPointsFinder;
|
|
private final IsolatedPointsFinder isolatedPointsFinder;
|
|
@@ -49,9 +53,10 @@ public class GisSurveySystemChecker {
|
|
private final DuplicatePointsFinder duplicatePointsFinder;
|
|
private final DuplicatePointsFinder duplicatePointsFinder;
|
|
private final OverlapLinesFinder overlapLinesFinder;
|
|
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";
|
|
mStrClassName = "GisSurveySystemChecker";
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
|
|
+ this.systemCheckResultManager = systemCheckResultManager;
|
|
this.gisSurveyLayerApplyService = gisSurveyLayerApplyService;
|
|
this.gisSurveyLayerApplyService = gisSurveyLayerApplyService;
|
|
this.typeDefineService = typeDefineService;
|
|
this.typeDefineService = typeDefineService;
|
|
this.isolatedPointsFinder = isolatedPointsFinder;
|
|
this.isolatedPointsFinder = isolatedPointsFinder;
|
|
@@ -67,23 +72,23 @@ public class GisSurveySystemChecker {
|
|
* @return 系统检查返回
|
|
* @return 系统检查返回
|
|
*/
|
|
*/
|
|
@Async
|
|
@Async
|
|
- public ListenableFuture<GisSurveyCheckResult> systemCheckTask(GisSurveyCheckParams params) {
|
|
|
|
- //项目id
|
|
|
|
- String projId = params.getProjId();
|
|
|
|
- //任务id
|
|
|
|
- String jobId = params.getJobId();
|
|
|
|
- //检查类型
|
|
|
|
- Integer checkType = params.getCheckType();
|
|
|
|
|
|
+ public ListenableFuture<GisSurveySystemCheckResult> systemCheckTask(GisSurveyCheckParams params, Consumer<GisSurveySystemCheckSubtask> onStartSubtask) {
|
|
|
|
+ //系统检查id
|
|
|
|
+ GisSurveySystemCheckId systemCheckId = GisSurveySystemCheckId.generateId(params);
|
|
|
|
+ if (systemCheckId == null) return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
|
|
|
|
+ //创建临时文件夹
|
|
|
|
+ if (!systemCheckResultManager.createTempDirectory(systemCheckId))
|
|
|
|
+ return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
|
|
//构建返回
|
|
//构建返回
|
|
- GisSurveyCheckResult result = GisSurveyCheckResult.fail(params);
|
|
|
|
|
|
+ GisSurveySystemCheckResult result = GisSurveySystemCheckResult.fail(params);
|
|
//孤立点任务
|
|
//孤立点任务
|
|
- ListenableFuture<List<GisSurveyCheckElement>> isolatedPointsFuture = null;
|
|
|
|
|
|
+ ListenableFuture<GisSurveySystemCheckResultDetail> isolatedPointsFuture = null;
|
|
//孤立线任务
|
|
//孤立线任务
|
|
- ListenableFuture<List<List<GisSurveyCheckElement>>> IsolatedLinesFuture = null;
|
|
|
|
|
|
+ ListenableFuture<GisSurveySystemCheckResultDetail> isolatedLinesFuture = null;
|
|
//重复点任务
|
|
//重复点任务
|
|
- ListenableFuture<List<List<GisSurveyCheckElement>>> duplicatePointsFuture = null;
|
|
|
|
|
|
+ ListenableFuture<GisSurveySystemCheckResultDetail> duplicatePointsFuture = null;
|
|
//重叠线任务
|
|
//重叠线任务
|
|
- ListenableFuture<List<List<GisSurveyCheckElement>>> overlapLinesFuture = null;
|
|
|
|
|
|
+ ListenableFuture<GisSurveySystemCheckResultDetail> overlapLinesFuture = null;
|
|
//点集合
|
|
//点集合
|
|
List<GisSurveyLayerApplyPoint> points = null;
|
|
List<GisSurveyLayerApplyPoint> points = null;
|
|
//线集合
|
|
//线集合
|
|
@@ -91,75 +96,85 @@ public class GisSurveySystemChecker {
|
|
try {
|
|
try {
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
, String.format(
|
|
, 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();
|
|
List<TypeDefine> typeDefines = typeDefineService.findLatLng();
|
|
|
|
|
|
//孤立点检查
|
|
//孤立点检查
|
|
if (points != null && lines != null) {
|
|
if (points != null && lines != null) {
|
|
- isolatedPointsFuture = isolatedPointsFinder.findIsolatedPoints(points, lines);
|
|
|
|
|
|
+ isolatedPointsFuture = isolatedPointsFinder.findIsolatedPoints(points, lines, systemCheckId);
|
|
}
|
|
}
|
|
//重复点检查
|
|
//重复点检查
|
|
if (points != null) {
|
|
if (points != null) {
|
|
- duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines);
|
|
|
|
|
|
+ duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, systemCheckId);
|
|
}
|
|
}
|
|
//孤立线和重叠线检查
|
|
//孤立线和重叠线检查
|
|
if (lines != null) {
|
|
if (lines != null) {
|
|
- IsolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines);
|
|
|
|
- overlapLinesFuture = overlapLinesFinder.findDuplicateLines(lines);
|
|
|
|
|
|
+ isolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines, systemCheckId);
|
|
|
|
+ overlapLinesFuture = overlapLinesFinder.findDuplicateLines(lines, systemCheckId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //返回子任务
|
|
|
|
+ onStartSubtask.accept(
|
|
|
|
+ new GisSurveySystemCheckSubtask(isolatedPointsFuture, isolatedLinesFuture, duplicatePointsFuture, overlapLinesFuture)
|
|
|
|
+ );
|
|
|
|
+
|
|
//等待结果,并存入返回,优先监听点相关(执行速度快且只需要点集合,优先释放点集合内存)
|
|
//等待结果,并存入返回,优先监听点相关(执行速度快且只需要点集合,优先释放点集合内存)
|
|
if (isolatedPointsFuture != null) {
|
|
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 && duplicatePointsFuture.isDone()) points.clear();
|
|
}
|
|
}
|
|
if (duplicatePointsFuture != null) {
|
|
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 (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) {
|
|
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.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
|
|
|
|
+ result.setCompleteTime(LocalDateTime.now());
|
|
|
|
+
|
|
|
|
+ //写入结果
|
|
|
|
+ systemCheckResultManager.writeResult(result, systemCheckId, GisSurveySystemCheckResultPath.RESULT);
|
|
|
|
+ //替换结果
|
|
|
|
+ if (!systemCheckResultManager.replaceResult(systemCheckId))
|
|
|
|
+ return new AsyncResult<>(GisSurveySystemCheckResult.fail(params));
|
|
|
|
+
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
|
|
, String.format(
|
|
, 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()
|
|
Duration.between(result.getRequestTime(), result.getCompleteTime()).toMillis()
|
|
)
|
|
)
|
|
);
|
|
);
|
|
@@ -167,15 +182,14 @@ public class GisSurveySystemChecker {
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
, String.format(
|
|
, 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 (isolatedPointsFuture != null) isolatedPointsFuture.cancel(true);
|
|
- if (IsolatedLinesFuture != null) IsolatedLinesFuture.cancel(true);
|
|
|
|
|
|
+ if (isolatedLinesFuture != null) isolatedLinesFuture.cancel(true);
|
|
if (duplicatePointsFuture != null) duplicatePointsFuture.cancel(true);
|
|
if (duplicatePointsFuture != null) duplicatePointsFuture.cancel(true);
|
|
if (overlapLinesFuture != null) overlapLinesFuture.cancel(true);
|
|
if (overlapLinesFuture != null) overlapLinesFuture.cancel(true);
|
|
//失败信息
|
|
//失败信息
|