|
@@ -78,9 +78,9 @@ public class ClientServiceImpl implements ClientService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean updatePrintProgress(Long examDetailId, String machineCode, Integer printProgress) {
|
|
|
+ public Boolean updatePrintProgress(Long examDetailId, String machineCode, Integer printProgress, Boolean isPrint) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
- return examDetailService.updatePrintProgress(schoolId, examDetailId, machineCode, printProgress);
|
|
|
+ return examDetailService.updatePrintProgress(schoolId, examDetailId, machineCode, printProgress, isPrint);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -157,94 +157,100 @@ public class ClientServiceImpl implements ClientService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("打印员不能为空");
|
|
|
}
|
|
|
if (isPrint && StringUtils.isNotBlank(examDetail.getPrintUser()) && !examDetail.getPrintUser().equals(printUser)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该任务已被[" + printUser + "]占用");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该任务已被[" + examDetail.getPrintUser() + "]占用");
|
|
|
}
|
|
|
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
List<Map<String, Object>> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
|
|
|
Map<String, Object> finalMap = new HashMap<>();
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
|
|
|
// 2.取生成的完整的pdf
|
|
|
- if (examDetail.getAttachmentId() == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考场pdf未生成");
|
|
|
- }
|
|
|
-
|
|
|
- BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
|
|
|
- if (attachment == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考场pdf文件记录异常");
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> totalPathUrl = commonService.filePreviewByAttachmentId(examDetail.getAttachmentId(), false);
|
|
|
- if (StringUtils.isBlank(totalPathUrl.get("url"))) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
|
|
|
- }
|
|
|
-
|
|
|
- finalMap.put("total", totalPathUrl);
|
|
|
+ String printContent = examPrintPlan.getPrintContent();
|
|
|
+ // 是否包含试卷、题卡
|
|
|
+ if(StringUtils.isNotBlank(printContent)) {
|
|
|
+ // 试卷、题卡map
|
|
|
+ Map<String, Object> detailMap = new HashMap<>();
|
|
|
+ // 备用试卷、备用题卡map
|
|
|
+ Map<String, Object> backupMap = new HashMap<>();
|
|
|
+ // 备份数量
|
|
|
+ int backupCount = examPrintPlan.getBackupCount().intValue();
|
|
|
+ // 取考生列表
|
|
|
+ List<Map> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
|
|
|
+ if(printContent.contains("PAPER")){
|
|
|
+ if (examDetail.getAttachmentId() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场pdf未生成");
|
|
|
+ }
|
|
|
|
|
|
- // 3.取学生试卷、题卡、备用试卷、题卡,印品
|
|
|
- Map<String, Object> detailMap = new HashMap<>();
|
|
|
- // 3.1取试卷
|
|
|
- Map<String, Map<String, String>> map = mapCourseUrl(examDetailCourses);
|
|
|
- // 3.2取考生
|
|
|
- List<Map> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
|
|
|
- // 3.3生成试卷List
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
|
|
|
+ if (attachment == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场pdf文件记录异常");
|
|
|
+ }
|
|
|
|
|
|
- detailMap.put("paper", splicePaperContent(studentList, map));
|
|
|
- // 3.4生成题卡List
|
|
|
+ Map<String, String> totalPathUrl = commonService.filePreviewByAttachmentId(examDetail.getAttachmentId(), false);
|
|
|
+ if (StringUtils.isBlank(totalPathUrl.get("url"))) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
|
|
|
+ }
|
|
|
|
|
|
- detailMap.put("card", spliceCardContent(studentList));
|
|
|
+ finalMap.put("total", totalPathUrl);
|
|
|
+ // 取试卷
|
|
|
+ Map<String, Map<String, String>> map = mapCourseUrl(examDetailCourses);
|
|
|
+ // 生成试卷List
|
|
|
+ detailMap.put("paper", splicePaperContent(studentList, map));
|
|
|
+ //试卷
|
|
|
+ List<Map<String, String>> keyMaps = studentList.stream().map(m -> {
|
|
|
+ Map<String, String> stringMap = new HashMap<>();
|
|
|
+ stringMap.put("courseCode", m.get("courseCode").toString());
|
|
|
+ stringMap.put("courseName", m.get("courseName").toString());
|
|
|
+ stringMap.put("paperNumber", m.get("paperNumber").toString());
|
|
|
+ stringMap.put("paperType", m.get("paperType").toString());
|
|
|
+ return stringMap;
|
|
|
+ }).distinct().collect(Collectors.toList());
|
|
|
+ List<ClientPrintBackupDataDto> paperBackupList = new ArrayList<>();
|
|
|
+ for (Map<String, String> keyMap : keyMaps) {
|
|
|
+ for (int i = 0; i < backupCount; i++) {
|
|
|
+ ClientPrintBackupDataDto clientPrintBackupDataDto = new ClientPrintBackupDataDto();
|
|
|
+ clientPrintBackupDataDto.setCourseCode(keyMap.get("courseCode"));
|
|
|
+ clientPrintBackupDataDto.setCourseName(keyMap.get("courseName"));
|
|
|
+ clientPrintBackupDataDto.setPaperNumber(keyMap.get("paperNumber"));
|
|
|
+ clientPrintBackupDataDto.setPaperType(keyMap.get("paperType"));
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
+ String key = sj.add(keyMap.get("courseCode")).add(keyMap.get("paperNumber")).add(keyMap.get("paperType")).toString();
|
|
|
+ clientPrintBackupDataDto.setMd5(map.get(key).get("md5"));
|
|
|
+ clientPrintBackupDataDto.setUrl(map.get(key).get("url"));
|
|
|
+ paperBackupList.add(clientPrintBackupDataDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ backupMap.put("paper", paperBackupList);
|
|
|
|
|
|
- //3.4备用试卷、题卡
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
|
|
|
- Map<String, Object> backupMap = new HashMap<>();
|
|
|
- int backupCount = examPrintPlan.getBackupCount().intValue();
|
|
|
- //试卷
|
|
|
- List<Map<String, String>> keyMaps = studentList.stream().map(m -> {
|
|
|
- Map<String, String> stringMap = new HashMap<>();
|
|
|
- stringMap.put("courseCode", m.get("courseCode").toString());
|
|
|
- stringMap.put("courseName", m.get("courseName").toString());
|
|
|
- stringMap.put("paperNumber", m.get("paperNumber").toString());
|
|
|
- stringMap.put("paperType", m.get("paperType").toString());
|
|
|
- return stringMap;
|
|
|
- }).distinct().collect(Collectors.toList());
|
|
|
- List<ClientPrintBackupDataDto> paperBackupList = new ArrayList<>();
|
|
|
- for (Map<String, String> keyMap : keyMaps) {
|
|
|
- for (int i = 0; i < backupCount; i++) {
|
|
|
- ClientPrintBackupDataDto clientPrintBackupDataDto = new ClientPrintBackupDataDto();
|
|
|
- clientPrintBackupDataDto.setCourseCode(keyMap.get("courseCode"));
|
|
|
- clientPrintBackupDataDto.setCourseName(keyMap.get("courseName"));
|
|
|
- clientPrintBackupDataDto.setPaperNumber(keyMap.get("paperNumber"));
|
|
|
- clientPrintBackupDataDto.setPaperType(keyMap.get("paperType"));
|
|
|
- StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
- String key = sj.add(keyMap.get("courseCode")).add(keyMap.get("paperNumber")).add(keyMap.get("paperType")).toString();
|
|
|
- clientPrintBackupDataDto.setMd5(map.get(key).get("md5"));
|
|
|
- clientPrintBackupDataDto.setUrl(map.get(key).get("url"));
|
|
|
- paperBackupList.add(clientPrintBackupDataDto);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- backupMap.put("paper", paperBackupList);
|
|
|
-
|
|
|
- // 备用题卡
|
|
|
- List<ClientPrintBackupDataDto> cardBackupList = new ArrayList<>();
|
|
|
- for (Map<String, Object> examDetailCours : examDetailCourses) {
|
|
|
- String attachmentIds = examDetailCours.get("attachmentIds").toString();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
|
|
|
- List<Map> backupCards = JSONObject.parseArray(JSONObject.toJSONString(jsonObject.get("card")), Map.class);
|
|
|
- for (Map backupCard : backupCards) {
|
|
|
- ClientPrintBackupDataDto clientPrintBackupDataDto = new ClientPrintBackupDataDto();
|
|
|
- clientPrintBackupDataDto.setCourseCode(examDetailCours.get("courseCode").toString());
|
|
|
- clientPrintBackupDataDto.setCourseName(examDetailCours.get("courseName").toString());
|
|
|
- clientPrintBackupDataDto.setPaperNumber(examDetailCours.get("paperNumber").toString());
|
|
|
- clientPrintBackupDataDto.setPaperType(backupCard.get("name").toString());
|
|
|
- Map<String, String> urlMap = commonService.filePreviewByAttachmentId(Long.valueOf(backupCard.get("attachmentId").toString()), false);
|
|
|
- clientPrintBackupDataDto.setMd5(urlMap.get("md5"));
|
|
|
- clientPrintBackupDataDto.setUrl(urlMap.get("url"));
|
|
|
- cardBackupList.add(clientPrintBackupDataDto);
|
|
|
+ if(printContent.contains("CARD")){
|
|
|
+ // 生成题卡List
|
|
|
+ detailMap.put("card", spliceCardContent(studentList));
|
|
|
+
|
|
|
+ // 备用题卡
|
|
|
+ List<ClientPrintBackupDataDto> cardBackupList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> examDetailCours : examDetailCourses) {
|
|
|
+ String attachmentIds = examDetailCours.get("cardAttachmentIds").toString();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
|
|
|
+ List<Map> backupCards = JSONObject.parseArray(JSONObject.toJSONString(jsonObject.get("card")), Map.class);
|
|
|
+ for (Map backupCard : backupCards) {
|
|
|
+ ClientPrintBackupDataDto clientPrintBackupDataDto = new ClientPrintBackupDataDto();
|
|
|
+ clientPrintBackupDataDto.setCourseCode(examDetailCours.get("courseCode").toString());
|
|
|
+ clientPrintBackupDataDto.setCourseName(examDetailCours.get("courseName").toString());
|
|
|
+ clientPrintBackupDataDto.setPaperNumber(examDetailCours.get("paperNumber").toString());
|
|
|
+ clientPrintBackupDataDto.setPaperType(backupCard.get("name").toString());
|
|
|
+ Map<String, String> urlMap = commonService.filePreviewByAttachmentId(Long.valueOf(backupCard.get("attachmentId").toString()), false);
|
|
|
+ clientPrintBackupDataDto.setMd5(urlMap.get("md5"));
|
|
|
+ clientPrintBackupDataDto.setUrl(urlMap.get("url"));
|
|
|
+ cardBackupList.add(clientPrintBackupDataDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ backupMap.put("card", cardBackupList);
|
|
|
}
|
|
|
+ detailMap.put("backup", backupMap);
|
|
|
+ finalMap.put("detail", detailMap);
|
|
|
}
|
|
|
- backupMap.put("card", cardBackupList);
|
|
|
- detailMap.put("backup", backupMap);
|
|
|
- finalMap.put("detail", detailMap);
|
|
|
|
|
|
//3.5
|
|
|
String variableContent = examPrintPlan.getVariableContent();
|