|
@@ -36,7 +36,7 @@ public class GisSurveyThirdExportBizService {
|
|
|
/**
|
|
|
* 任务缓存
|
|
|
*/
|
|
|
- private final static Map<String, ListenableFuture<CommAsyncResult<String>>> TASK_CACHE = new ConcurrentHashMap<>();
|
|
|
+ private final static Map<String, ListenableFuture<CommAsyncResult<Map<String, String>>>> TASK_CACHE = new ConcurrentHashMap<>();
|
|
|
/**
|
|
|
* 开始时间缓存
|
|
|
*/
|
|
@@ -73,23 +73,24 @@ public class GisSurveyThirdExportBizService {
|
|
|
* @param fileType 导出文件类型
|
|
|
* @return 转换结果
|
|
|
*/
|
|
|
- public CommAsyncResult<String> thirdExport(String jobId, FileTypeEnum fileType) {
|
|
|
+ public CommAsyncResult<Map<String, String>> thirdExport(String jobId, FileTypeEnum fileType) {
|
|
|
//获取上次结果
|
|
|
- CommAsyncResult<String> lastResult = getResult(jobId);
|
|
|
+ CommAsyncResult<Map<String, String>> lastResult = getResult(jobId);
|
|
|
|
|
|
//失败/进行中处理
|
|
|
if (lastResult != null && !Objects.equals(CommAsyncStatusEnum.SUCCESS.getCode(), lastResult.getStatus()))
|
|
|
return lastResult;
|
|
|
|
|
|
//文件结果flag
|
|
|
- final String FLAG = GisSurveyThirdExporter.RESULT_PREFIX + fileType.getName() + "-" + jobId;
|
|
|
+ final String FLAG = GisSurveyThirdExporter.RESULT_PREFIX + jobId;
|
|
|
//获取文件结果
|
|
|
- CommAsyncResult<String> fileResult = asyncResultManager.getResult(FLAG, new TypeReference<CommAsyncResult<String>>() {
|
|
|
+ CommAsyncResult<Map<String, String>> fileResult = asyncResultManager.getResult(FLAG, new TypeReference<CommAsyncResult<Map<String, String>>>() {
|
|
|
});
|
|
|
//获取数据更新时间
|
|
|
LocalDateTime refreshTime = jobInfoService.findRefreshTimeByUid(jobId);
|
|
|
- //判断文件结果落后时间
|
|
|
- if (fileResult != null && fileResult.getRefreshTime() != null && refreshTime != null) {
|
|
|
+ //直接返回文件结果判断:结果\刷新时间\数据不为空,结果数据包含当前项,文件结果落后数据库
|
|
|
+ if (fileResult != null && fileResult.getRefreshTime() != null && refreshTime != null
|
|
|
+ && fileResult.getData() != null && fileResult.getData().containsKey(fileType.getName())) {
|
|
|
//文件结果落后数据间隔
|
|
|
Duration lags = Duration.between(fileResult.getRefreshTime(), refreshTime);
|
|
|
//超出间隔,直接返回
|
|
@@ -111,15 +112,15 @@ public class GisSurveyThirdExportBizService {
|
|
|
* @param jobId 任务id
|
|
|
* @return 结果
|
|
|
*/
|
|
|
- public CommAsyncResult<String> getResult(String jobId) {
|
|
|
+ public CommAsyncResult<Map<String, String>> getResult(String jobId) {
|
|
|
//获取已存在的任务
|
|
|
- ListenableFuture<CommAsyncResult<String>> previousFuture = TASK_CACHE.get(jobId);
|
|
|
+ ListenableFuture<CommAsyncResult<Map<String, String>>> previousFuture = TASK_CACHE.get(jobId);
|
|
|
|
|
|
//判断完成
|
|
|
if (previousFuture != null && previousFuture.isDone()) {
|
|
|
try {
|
|
|
//获取结果
|
|
|
- CommAsyncResult<String> result = previousFuture.get();
|
|
|
+ CommAsyncResult<Map<String, String>> result = previousFuture.get();
|
|
|
//如成功/失败,则直接返回
|
|
|
if (Objects.equals(result.getStatus(), CommAsyncStatusEnum.FAIL.getCode()) ||
|
|
|
Objects.equals(result.getStatus(), GisSurveConvertStatusEnum.SUCCESS.getCode()))
|
|
@@ -149,11 +150,11 @@ public class GisSurveyThirdExportBizService {
|
|
|
*/
|
|
|
private void startTask(String jobId, FileTypeEnum fileType) {
|
|
|
//获取已存在的任务
|
|
|
- ListenableFuture<CommAsyncResult<String>> previousFuture = TASK_CACHE.get(jobId);
|
|
|
+ ListenableFuture<CommAsyncResult<Map<String, String>>> previousFuture = TASK_CACHE.get(jobId);
|
|
|
//已结束判断,删除缓存
|
|
|
if (previousFuture != null && (previousFuture.isDone() || previousFuture.isCancelled())) removeCache(jobId);
|
|
|
//执行异步任务
|
|
|
- ListenableFuture<CommAsyncResult<String>> future = thirdExporter.thirdExportTask(jobId, fileType);
|
|
|
+ ListenableFuture<CommAsyncResult<Map<String, String>>> future = thirdExporter.thirdExportTask(jobId, fileType);
|
|
|
//任务超时
|
|
|
taskScheduler.schedule(() -> {
|
|
|
if (!future.isCancelled() && !future.isDone() && stopTask(future)) {
|