|
@@ -80,6 +80,7 @@ import cn.com.qmth.scancentral.entity.StudentEntity;
|
|
|
import cn.com.qmth.scancentral.entity.StudentPaperEntity;
|
|
|
import cn.com.qmth.scancentral.entity.SubjectEntity;
|
|
|
import cn.com.qmth.scancentral.entity.UserEntity;
|
|
|
+import cn.com.qmth.scancentral.enums.AsyncTaskStatus;
|
|
|
import cn.com.qmth.scancentral.enums.ExamMode;
|
|
|
import cn.com.qmth.scancentral.enums.ExamStatus;
|
|
|
import cn.com.qmth.scancentral.enums.ExamStatusCheckMode;
|
|
@@ -2240,10 +2241,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
BreachAndStatusImportTaskVo vo = new BreachAndStatusImportTaskVo();
|
|
|
vo.setTaskId(taskId);
|
|
|
- vo.setTotalCount(list.size());
|
|
|
+ vo.setTotalCount(list.size() - 1);
|
|
|
vo.setExamId(examId);
|
|
|
vo.setSubjectCode(subjectCode);
|
|
|
- vo.setSuccess(true);
|
|
|
+ vo.setStatus(AsyncTaskStatus.RUNNING);
|
|
|
vo.setProgress(0.0);
|
|
|
vo.setTempDir(temDir);
|
|
|
vo.setFile(txt);
|
|
@@ -2268,11 +2269,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
breachImportCheck(vo, in);
|
|
|
} catch (ParameterException e) {
|
|
|
vo.setErrMsg(e.getMessage());
|
|
|
- vo.setSuccess(false);
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
throw e;
|
|
|
} catch (Exception e) {
|
|
|
vo.setErrMsg("系统错误");
|
|
|
- vo.setSuccess(false);
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
throw new ParameterException("系统错误", e);
|
|
|
} finally {
|
|
|
if (in != null) {
|
|
@@ -2283,41 +2284,44 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
}
|
|
|
// 根据校验结果上传文件
|
|
|
- if (vo.getSuccess()) {
|
|
|
- InputStream excelIn = null;
|
|
|
- try {
|
|
|
- String md5 = MD5Util.md5Hex(vo.getFile());
|
|
|
- excelIn = new FileInputStream(vo.getFile());
|
|
|
- fileService.uploadBreach(excelIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
- } catch (IOException e) {
|
|
|
- throw new ParameterException("系统错误", e);
|
|
|
- } finally {
|
|
|
- if (excelIn != null) {
|
|
|
- try {
|
|
|
- excelIn.close();
|
|
|
- } catch (IOException e) {
|
|
|
- }
|
|
|
+ InputStream excelIn = null;
|
|
|
+ try {
|
|
|
+ String md5 = MD5Util.md5Hex(vo.getFile());
|
|
|
+ excelIn = new FileInputStream(vo.getFile());
|
|
|
+ fileService.uploadBreach(excelIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
+ } catch (IOException e) {
|
|
|
+ vo.setErrMsg("系统错误");
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
+ throw new ParameterException("系统错误", e);
|
|
|
+ } finally {
|
|
|
+ if (excelIn != null) {
|
|
|
+ try {
|
|
|
+ excelIn.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
}
|
|
|
- File info = new File(vo.getTempDir().getAbsolutePath() + "/breach-info.txt");
|
|
|
- InputStream infoIn = null;
|
|
|
- try {
|
|
|
- FileUtils.write(info, vo.getProgressCount() + "", "utf-8");
|
|
|
- String md5 = MD5Util.md5Hex(info);
|
|
|
- infoIn = new FileInputStream(info);
|
|
|
- fileService.uploadBreachInfo(infoIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
- } catch (IOException e) {
|
|
|
- throw new ParameterException("系统错误", e);
|
|
|
- } finally {
|
|
|
- if (infoIn != null) {
|
|
|
- try {
|
|
|
- infoIn.close();
|
|
|
- } catch (IOException e) {
|
|
|
- }
|
|
|
+ }
|
|
|
+ File info = new File(vo.getTempDir().getAbsolutePath() + "/breach-info.txt");
|
|
|
+ InputStream infoIn = null;
|
|
|
+ try {
|
|
|
+ FileUtils.write(info, vo.getProgressCount() + "", "utf-8");
|
|
|
+ String md5 = MD5Util.md5Hex(info);
|
|
|
+ infoIn = new FileInputStream(info);
|
|
|
+ fileService.uploadBreachInfo(infoIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
+ } catch (IOException e) {
|
|
|
+ vo.setErrMsg("系统错误");
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
+ throw new ParameterException("系统错误", e);
|
|
|
+ } finally {
|
|
|
+ if (infoIn != null) {
|
|
|
+ try {
|
|
|
+ infoIn.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
}
|
|
|
- vo.setTotalCount(vo.getProgressCount());
|
|
|
}
|
|
|
+ vo.setTotalCount(vo.getProgressCount());
|
|
|
+ vo.setStatus(AsyncTaskStatus.SUCCESS);
|
|
|
}
|
|
|
|
|
|
private void breachImportCheck(BreachAndStatusImportTaskVo vo, InputStream in) {
|
|
@@ -2395,10 +2399,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
BreachAndStatusImportTaskVo vo = new BreachAndStatusImportTaskVo();
|
|
|
vo.setTaskId(taskId);
|
|
|
- vo.setTotalCount(list.size());
|
|
|
+ vo.setTotalCount(list.size() - 1);
|
|
|
vo.setExamId(examId);
|
|
|
vo.setSubjectCode(subjectCode);
|
|
|
- vo.setSuccess(true);
|
|
|
+ vo.setStatus(AsyncTaskStatus.RUNNING);
|
|
|
vo.setProgress(0.0);
|
|
|
vo.setTempDir(temDir);
|
|
|
vo.setFile(txt);
|
|
@@ -2422,11 +2426,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
custStatusImportCheck(vo, in);
|
|
|
} catch (ParameterException e) {
|
|
|
vo.setErrMsg(e.getMessage());
|
|
|
- vo.setSuccess(false);
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
throw e;
|
|
|
} catch (Exception e) {
|
|
|
vo.setErrMsg("系统错误");
|
|
|
- vo.setSuccess(false);
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
throw new ParameterException("系统错误", e);
|
|
|
} finally {
|
|
|
if (in != null) {
|
|
@@ -2437,41 +2441,44 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> i
|
|
|
}
|
|
|
}
|
|
|
// 根据校验结果上传文件
|
|
|
- if (vo.getSuccess()) {
|
|
|
- InputStream excelIn = null;
|
|
|
- try {
|
|
|
- String md5 = MD5Util.md5Hex(vo.getFile());
|
|
|
- excelIn = new FileInputStream(vo.getFile());
|
|
|
- fileService.uploadCustStatus(excelIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
- } catch (IOException e) {
|
|
|
- throw new ParameterException("系统错误", e);
|
|
|
- } finally {
|
|
|
- if (excelIn != null) {
|
|
|
- try {
|
|
|
- excelIn.close();
|
|
|
- } catch (IOException e) {
|
|
|
- }
|
|
|
+ InputStream excelIn = null;
|
|
|
+ try {
|
|
|
+ String md5 = MD5Util.md5Hex(vo.getFile());
|
|
|
+ excelIn = new FileInputStream(vo.getFile());
|
|
|
+ fileService.uploadCustStatus(excelIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
+ } catch (IOException e) {
|
|
|
+ vo.setErrMsg("系统错误");
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
+ throw new ParameterException("系统错误", e);
|
|
|
+ } finally {
|
|
|
+ if (excelIn != null) {
|
|
|
+ try {
|
|
|
+ excelIn.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
}
|
|
|
- File info = new File(vo.getTempDir().getAbsolutePath() + "/cust-status-info.txt");
|
|
|
- InputStream infoIn = null;
|
|
|
- try {
|
|
|
- FileUtils.write(info, vo.getProgressCount() + "", "utf-8");
|
|
|
- String md5 = MD5Util.md5Hex(info);
|
|
|
- infoIn = new FileInputStream(info);
|
|
|
- fileService.uploadCustStatusInfo(infoIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
- } catch (IOException e) {
|
|
|
- throw new ParameterException("系统错误", e);
|
|
|
- } finally {
|
|
|
- if (infoIn != null) {
|
|
|
- try {
|
|
|
- infoIn.close();
|
|
|
- } catch (IOException e) {
|
|
|
- }
|
|
|
+ }
|
|
|
+ File info = new File(vo.getTempDir().getAbsolutePath() + "/cust-status-info.txt");
|
|
|
+ InputStream infoIn = null;
|
|
|
+ try {
|
|
|
+ FileUtils.write(info, vo.getProgressCount() + "", "utf-8");
|
|
|
+ String md5 = MD5Util.md5Hex(info);
|
|
|
+ infoIn = new FileInputStream(info);
|
|
|
+ fileService.uploadCustStatusInfo(infoIn, md5, vo.getExamId(), vo.getSubjectCode());
|
|
|
+ } catch (IOException e) {
|
|
|
+ vo.setErrMsg("系统错误");
|
|
|
+ vo.setStatus(AsyncTaskStatus.FAILED);
|
|
|
+ throw new ParameterException("系统错误", e);
|
|
|
+ } finally {
|
|
|
+ if (infoIn != null) {
|
|
|
+ try {
|
|
|
+ infoIn.close();
|
|
|
+ } catch (IOException e) {
|
|
|
}
|
|
|
}
|
|
|
- vo.setTotalCount(vo.getProgressCount());
|
|
|
}
|
|
|
+ vo.setTotalCount(vo.getProgressCount());
|
|
|
+ vo.setStatus(AsyncTaskStatus.SUCCESS);
|
|
|
}
|
|
|
|
|
|
private void custStatusImportCheck(BreachAndStatusImportTaskVo vo, InputStream in) {
|