|
@@ -94,7 +94,8 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
}
|
|
|
});
|
|
|
boolean exception = false;
|
|
|
- String timeFormat = "yyyy-MM-dd HH:mm:ss:sss";
|
|
|
+// String timeFormat = "yyyy-MM-dd HH:mm:ss:sss";
|
|
|
+ String timeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
|
//保存数据到数据库
|
|
|
if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
|
log.info("开始导入考生数据");
|
|
@@ -107,9 +108,9 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
List<TEStudent> teStudentList = new ArrayList<>();
|
|
|
List<TBUserRole> tbUserRoleList = new ArrayList<>();
|
|
|
List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
|
|
|
- JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
|
|
+ List txtList = new ArrayList();
|
|
|
TBTaskHistory tbTaskHistory = null;
|
|
|
- jsonObject.put(DateUtil.format(new Date(), timeFormat), "开始准备处理导入的考生数据");
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导入的考生数据");
|
|
|
int y = 0, min = 0;
|
|
|
try {
|
|
|
Gson gson = new Gson();
|
|
@@ -179,11 +180,11 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
tbTaskHistory.setStatus(TaskTypeExecEnum.finish.ordinal());
|
|
|
tbTaskHistory.setSummary("共处理了" + size + "条数据");
|
|
|
tbTaskHistory.setFinishTime(new Date());
|
|
|
- jsonObject.put(DateUtil.format(new Date(), timeFormat), "考生数据处理完毕," + tbTaskHistory.getSummary());
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->考生数据处理完毕," + tbTaskHistory.getSummary());
|
|
|
} else {
|
|
|
tbTaskHistory.setStatus(TaskTypeExecEnum.running.ordinal());
|
|
|
tbTaskHistory.setSummary("正在处理第" + min + "条至" + max + "条数据");
|
|
|
- jsonObject.put(DateUtil.format(new Date(), timeFormat), "考生数据处理中," + tbTaskHistory.getSummary());
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->考生数据处理中," + tbTaskHistory.getSummary());
|
|
|
}
|
|
|
tbTaskHistory.setProgress(progress.doubleValue());
|
|
|
tbTaskHistoryService.updateById(tbTaskHistory);
|
|
@@ -211,7 +212,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
}
|
|
|
});
|
|
|
if (count.get() > 0) {
|
|
|
- jsonObject.put(DateUtil.format(new Date(), timeFormat), "创建了" + count + "条考场数据");
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->创建了" + count + "条考场数据");
|
|
|
}
|
|
|
}
|
|
|
long end = System.currentTimeMillis();
|
|
@@ -220,7 +221,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
e.printStackTrace();
|
|
|
exception = true;
|
|
|
String exceptionStr = "考生数据处理到第" + (min + y + 1) + "条时发生异常:" + e.getMessage();
|
|
|
- jsonObject.put(DateUtil.format(new Date(), timeFormat), exceptionStr);
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->" + exceptionStr);
|
|
|
tbTaskHistory.setSummary(exceptionStr);
|
|
|
tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
if (Objects.nonNull(teStudentList) && teStudentList.size() > 0) {
|
|
@@ -242,8 +243,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
}
|
|
|
} finally {
|
|
|
//这里写入txt文件
|
|
|
- log.info("jsonObject:{}", jsonObject.toJSONString());
|
|
|
- writeImportResultTxt(exception, ossUtil, tbTaskHistoryService, tbTaskHistory, jsonObject, path, type, ossEnv);
|
|
|
+ writeImportResultTxt(exception, ossUtil, tbTaskHistoryService, tbTaskHistory, txtList.toString(), path, type, ossEnv);
|
|
|
}
|
|
|
}
|
|
|
return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
|
|
@@ -287,7 +287,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
* @param ossEnv
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- void writeImportResultTxt(boolean exception, OssUtil ossUtil, TBTaskHistoryService tbTaskHistoryService, TBTaskHistory tbTaskHistory, JSONObject jsonObject, String path, String type, Map<String, Object> ossEnv) throws IOException {
|
|
|
+ void writeImportResultTxt(boolean exception, OssUtil ossUtil, TBTaskHistoryService tbTaskHistoryService, TBTaskHistory tbTaskHistory, String txtStr, String path, String type, Map<String, Object> ossEnv) throws IOException {
|
|
|
FileWriter fileWriter = null;
|
|
|
try {
|
|
|
path = path.substring(0, path.lastIndexOf(File.separator) + 1);
|
|
@@ -296,7 +296,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
file.createNewFile();
|
|
|
}
|
|
|
fileWriter = new FileWriter(file);
|
|
|
- fileWriter.write(jsonObject.toJSONString());
|
|
|
+ fileWriter.write(txtStr);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("path", file.getPath());
|
|
|
json.put("type", type);
|
|
@@ -306,7 +306,7 @@ public class TaskExamStudentTemplete implements TaskImportTemplete {
|
|
|
tbTaskHistory.setResultFilePath(json.toJSONString());
|
|
|
}
|
|
|
if (Objects.equals(type, SystemConstant.OSS)) {
|
|
|
- ossUtil.ossUpload(ossEnv, file.getPath(), jsonObject.toJSONString());
|
|
|
+ ossUtil.ossUpload(ossEnv, file.getPath(), txtStr);
|
|
|
file.delete();
|
|
|
}
|
|
|
tbTaskHistoryService.updateById(tbTaskHistory);
|