|
@@ -8,6 +8,7 @@ import java.util.Set;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
+import cn.com.qmth.scancentral.enums.AsyncTaskStatus;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -49,7 +50,7 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
@Override
|
|
|
public boolean existRunningStudentImportTask() {
|
|
|
for (ImportTaskVo task : IMPORT_TASKS.values()) {
|
|
|
- if (task.getRunning()) {
|
|
|
+ if (AsyncTaskStatus.RUNNING == task.getStatus()) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -63,7 +64,7 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
ImportTaskVo task = new ImportTaskVo();
|
|
|
task.setTaskId(taskId);
|
|
|
task.setProgress(0d);
|
|
|
- task.setRunning(true);
|
|
|
+ task.setStatus(AsyncTaskStatus.RUNNING);
|
|
|
IMPORT_TASKS.put(taskId, task);
|
|
|
|
|
|
List<StudentImportInfo> list = new ArrayList<>();
|
|
@@ -72,7 +73,7 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
log.warn("【考生导入】解析考生数据,有效共{}条! taskId:{}", list.size(), taskId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("【考生导入】解析考生数据错误! taskId:{} {}", taskId, e.getMessage());
|
|
|
- task.setRunning(false);
|
|
|
+ task.setStatus(AsyncTaskStatus.FAILED);
|
|
|
task.setErrMsg(e.getMessage());
|
|
|
return;
|
|
|
}
|
|
@@ -105,15 +106,15 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
finishCount = finishCount + batchList.size();
|
|
|
}
|
|
|
|
|
|
+ task.setStatus(AsyncTaskStatus.SUCCESS);
|
|
|
task.setProgress(100d);
|
|
|
long cost = (System.currentTimeMillis() - startTime) / 1000L;
|
|
|
log.info("【考生导入】共{}条 已导入:{}条 已耗时:{}秒 进度:100% taskId:{}", total, finishCount, cost, taskId);
|
|
|
} catch (Exception e) {
|
|
|
+ task.setStatus(AsyncTaskStatus.FAILED);
|
|
|
task.setErrMsg(String.format("导入异常终止,已导入%s条,未导入%s条!", finishCount, total - finishCount));
|
|
|
log.error("【考生导入】导入异常终止,已导入{}条,未导入{}条!taskId:{} err:{}", finishCount, total - finishCount, taskId,
|
|
|
e.getMessage(), e);
|
|
|
- } finally {
|
|
|
- task.setRunning(false);
|
|
|
}
|
|
|
}
|
|
|
|