|
@@ -6,6 +6,7 @@ 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.dbdao.services.intef.GisSurveyJobInfoService;
|
|
@@ -20,7 +21,9 @@ import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -79,6 +82,22 @@ public class GisSurveyBizService {
|
|
|
if (systemCheckId == null) return GisSurveySystemCheckResult.notExists(params);
|
|
|
//获取已存在的任务
|
|
|
ListenableFuture<GisSurveySystemCheckResult> previousFuture = TASK_CACHE.get(systemCheckId);
|
|
|
+ //如任务已完成,则检查历史失败
|
|
|
+ if (!params.getIgnoreFail() && previousFuture != null && previousFuture.isDone()) {
|
|
|
+ try {
|
|
|
+ //获取结果,并检查失败
|
|
|
+ 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("检查历史失败异常 系统检查id:%s msg:%s", systemCheckId, e.getMessage())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//获取已存在的结果
|
|
|
GisSurveySystemCheckResult result = systemCheckFileManager.getResult(systemCheckId);
|
|
|
//获取元素更新时间
|
|
@@ -97,6 +116,7 @@ public class GisSurveyBizService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//系统检查子任务
|
|
|
GisSurveySystemCheckSubtask checkSubtask = SUBTASK_CACHE.get(systemCheckId);
|
|
|
//进行中判断(未完成且未清除)
|
|
@@ -138,25 +158,25 @@ public class GisSurveyBizService {
|
|
|
*/
|
|
|
public void expireResult(Duration ttl) {
|
|
|
//获取超时的id
|
|
|
- List<GisSurveySystemCheckId> taskIds = TIME_CACHE.entrySet().stream()
|
|
|
+ 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 (GisSurveySystemCheckId taskId : taskIds) {
|
|
|
+ for (GisSurveySystemCheckId systemCheckId : systemCheckIds) {
|
|
|
//如任务不存在,则删除时间缓存
|
|
|
- if (!TASK_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
|
|
|
)
|
|
|
);
|
|
|
}
|