|
@@ -559,45 +559,45 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
|
|
|
Gson gson = new Gson();
|
|
|
OpenRecordNeedMarkBean openRecordNeedMarkBean = gson.fromJson(gson.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
|
|
|
List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(tOeExamRecord.getId());
|
|
|
- List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
|
|
|
- List<OpenRecordAnswerBean> finalAnswers = answers;
|
|
|
- answersTemp.forEach(s -> {
|
|
|
- OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
|
|
|
- try {
|
|
|
- openRecordAnswerBean.setAnswer(gson.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
|
|
|
- }.getType()));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("错误答案:{}", s.getAnswer(), e);
|
|
|
- }
|
|
|
- finalAnswers.add(openRecordAnswerBean);
|
|
|
- });
|
|
|
- openRecordNeedMarkBean.setAnswers(answers.stream().filter(answer -> {
|
|
|
- Map<String, Integer> struct = paperStructMap.get(tOeExamRecord.getPaperId());
|
|
|
- if (struct == null) {
|
|
|
- struct = teExamPaperService.getPaperStructCacheBean(tOeExamRecord.getPaperId());
|
|
|
- if (struct != null) {
|
|
|
- paperStructMap.put(tOeExamRecord.getPaperId(), struct);
|
|
|
- } else {
|
|
|
- log.error("找不到对应的试卷结构,paperId=" + tOeExamRecord.getPaperId());
|
|
|
- return false;
|
|
|
+ if (!CollectionUtils.isEmpty(answersTemp)) {
|
|
|
+ List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
|
|
|
+ List<OpenRecordAnswerBean> finalAnswers = answers;
|
|
|
+ answersTemp.forEach(s -> {
|
|
|
+ OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
|
|
|
+ try {
|
|
|
+ openRecordAnswerBean.setAnswer(gson.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
|
|
|
+ }.getType()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("错误答案:{}", s.getAnswer(), e);
|
|
|
+ }
|
|
|
+ finalAnswers.add(openRecordAnswerBean);
|
|
|
+ });
|
|
|
+ openRecordNeedMarkBean.setAnswers(answers.stream().filter(answer -> {
|
|
|
+ Map<String, Integer> struct = paperStructMap.get(tOeExamRecord.getPaperId());
|
|
|
+ if (struct == null) {
|
|
|
+ struct = teExamPaperService.getPaperStructCacheBean(tOeExamRecord.getPaperId());
|
|
|
+ if (struct != null) {
|
|
|
+ paperStructMap.put(tOeExamRecord.getPaperId(), struct);
|
|
|
+ } else {
|
|
|
+ log.error("找不到对应的试卷结构,paperId=" + tOeExamRecord.getPaperId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
+ Integer type = struct.get(RedisKeyHelper
|
|
|
+ .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
|
|
|
+ answer.getSubIndex()));
|
|
|
+ //过滤单选、多选、判断题
|
|
|
+ return type != null && type != 1 && type != 2 && type != 3;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ File fileAnswerJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.ANSWER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
|
|
|
+ if (!fileAnswerJson.exists()) {
|
|
|
+ fileAnswerJson.getParentFile().mkdirs();
|
|
|
+ fileAnswerJson.createNewFile();
|
|
|
}
|
|
|
- Integer type = struct.get(RedisKeyHelper
|
|
|
- .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
|
|
|
- answer.getSubIndex()));
|
|
|
- //过滤单选、多选、判断题
|
|
|
- return type != null && type != 1 && type != 2 && type != 3;
|
|
|
- }).collect(Collectors.toList()));
|
|
|
-
|
|
|
- File fileAnswerJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.ANSWER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
|
|
|
- if (!fileAnswerJson.exists()) {
|
|
|
- fileAnswerJson.getParentFile().mkdirs();
|
|
|
- fileAnswerJson.createNewFile();
|
|
|
+ IOUtils.write(JacksonUtil.parseJson(openRecordNeedMarkBean.getAnswers()).getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(fileAnswerJson));
|
|
|
+ recordJsonList.add(fileAnswerJson);
|
|
|
+ cloudMarkUtil.callFileUploadApi(new FileUploadParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), fileAnswerJson, CloudMarkFileUploadTypeEnum.JSON));
|
|
|
}
|
|
|
- IOUtils.write(JacksonUtil.parseJson(openRecordNeedMarkBean).getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(fileAnswerJson));
|
|
|
- recordJsonList.add(fileAnswerJson);
|
|
|
- cloudMarkUtil.callFileUploadApi(new FileUploadParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), fileAnswerJson, CloudMarkFileUploadTypeEnum.JSON));
|
|
|
-
|
|
|
jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
currentTaskSize++;
|
|
|
tbTaskHistory.setRemark(jsonObject.toJSONString());
|