|
@@ -0,0 +1,168 @@
|
|
|
+package com.qmth.distributed.print.business.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ClientExamStudentDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ClientExamTaskDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ClientPrintDataDto;
|
|
|
+import com.qmth.distributed.print.business.entity.BasicAttachment;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamDetail;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
|
+import com.qmth.distributed.print.business.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Date: 2021/4/20.
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ClientServiceImpl implements ClientService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamTaskService examTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamTaskDetailService examTaskDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClientStatusService clientStatusService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamDetailService examDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BasicAttachmentService basicAttachmentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamPrintPlanService examPrintPlanService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<ClientExamTaskDto> listTryTask(Long schoolId, String machineCode, Long orgId, Long printPlanId, String courseCode, String paperNumber, Boolean isTry, Boolean isPass, Integer pageNumber, Integer pageSize) {
|
|
|
+ return examTaskService.listTryTask(schoolId, machineCode, orgId, printPlanId, courseCode, paperNumber, isTry, isPass, pageNumber, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getUrl(Long schoolId, Long examTaskId) {
|
|
|
+ return examTaskDetailService.getUrl(schoolId, examTaskId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean tagPass(Long schoolId, Long examTaskId, String machineCode, Boolean isPass, Long userId) {
|
|
|
+ return clientStatusService.tagPass(schoolId, examTaskId, machineCode, isPass, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updatePrintProgress(Long schoolId, Long examDetailId, Integer printProgress) {
|
|
|
+ return examDetailService.updatePrintProgress(schoolId, examDetailId, printProgress);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<ClientExamStudentDto> listStudent(Long schoolId, Long examDetailId, String ticketNumber, String studentName, String courseCode, Integer pageNumber, Integer pageSize) {
|
|
|
+ return examDetailService.listStudent(schoolId, examDetailId, ticketNumber, studentName, courseCode, pageNumber, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getReprintData(Long schoolId, Long examDetailId, String ticketNumber, String type) {
|
|
|
+ Map<String, Object> finalMap = new HashMap<>();
|
|
|
+ // 取试卷
|
|
|
+ Map<String, String> map = mapCourseUrl(schoolId, examDetailId);
|
|
|
+ // 取考生
|
|
|
+ List<Map<String, String>> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, ticketNumber, type);
|
|
|
+ // 生成试卷List
|
|
|
+ List<ClientPrintDataDto> paperList = studentList.stream().map(m -> {
|
|
|
+ ClientPrintDataDto printDataDto = new ClientPrintDataDto();
|
|
|
+ String courseCode = m.get("courseCode");
|
|
|
+ String courseName = m.get("courseName");
|
|
|
+ String paperNumber = m.get("paperNumber");
|
|
|
+ String studentName = m.get("studentName");
|
|
|
+ String studentCode = m.get("studentCode");
|
|
|
+ String paperType = m.get("paperType");
|
|
|
+ printDataDto.setCourseCode(courseCode);
|
|
|
+ printDataDto.setCourseName(courseName);
|
|
|
+ printDataDto.setStudentName(studentName);
|
|
|
+ printDataDto.setStudentCode(studentCode);
|
|
|
+ printDataDto.setPaperType(paperType);
|
|
|
+
|
|
|
+ StringJoiner sj = new StringJoiner(":");
|
|
|
+ String key = sj.add(courseCode).add(paperNumber).add(paperType).toString();
|
|
|
+ printDataDto.setUrl(map.get(key));
|
|
|
+ return printDataDto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ finalMap.put("paper", paperList);
|
|
|
+ // 生成题卡List
|
|
|
+ List<ClientPrintDataDto> cardList = studentList.stream().map(m -> {
|
|
|
+ ClientPrintDataDto printDataDto = new ClientPrintDataDto();
|
|
|
+ String courseCode = m.get("courseCode");
|
|
|
+ String courseName = m.get("courseName");
|
|
|
+ String studentName = m.get("studentName");
|
|
|
+ String studentCode = m.get("studentCode");
|
|
|
+ String paperType = m.get("paperType");
|
|
|
+ String attachmentId = m.get("attachmentId");
|
|
|
+ printDataDto.setCourseCode(courseCode);
|
|
|
+ printDataDto.setCourseName(courseName);
|
|
|
+ printDataDto.setStudentName(studentName);
|
|
|
+ printDataDto.setStudentCode(studentCode);
|
|
|
+ printDataDto.setPaperType(paperType);
|
|
|
+ printDataDto.setUrl(commonService.filePreview(attachmentId, false));
|
|
|
+ return printDataDto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ finalMap.put("card", cardList);
|
|
|
+ //
|
|
|
+ ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
|
|
|
+ String variableContent = examPrintPlan.getVariableContent();
|
|
|
+ String ordinaryContent = examPrintPlan.getOrdinaryContent();
|
|
|
+ List<Map> variableList = JSONObject.parseArray(variableContent, Map.class);
|
|
|
+ List<Map> otherList = new ArrayList<>();
|
|
|
+ // todo 签到表、卷袋贴生成html路径
|
|
|
+ for (Map variable : variableList) {
|
|
|
+ Map vMap = new HashMap();
|
|
|
+ vMap.put("type", variable.get("type"));
|
|
|
+ vMap.put("url", commonService.filePreview(variable.get("attachmentId").toString()));
|
|
|
+ otherList.add(vMap);
|
|
|
+ }
|
|
|
+ List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
|
|
|
+ for (Map ordinary : ordinaryList) {
|
|
|
+ Map vMap = new HashMap();
|
|
|
+ vMap.put("type", ordinary.get("type"));
|
|
|
+ vMap.put("url", commonService.filePreview(ordinary.get("attachmentId").toString()));
|
|
|
+ otherList.add(vMap);
|
|
|
+ }
|
|
|
+ finalMap.put("other", otherList);
|
|
|
+ return finalMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据考场生成试卷map
|
|
|
+ *
|
|
|
+ * @param schoolId
|
|
|
+ * @param examDetailId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, String> mapCourseUrl(Long schoolId, Long examDetailId) {
|
|
|
+ List<Map<String, String>> taskDetails = examTaskDetailService.listByExamDetailId(schoolId, examDetailId);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ for (Map<String, String> taskDetail : taskDetails) {
|
|
|
+ String courseCode = taskDetail.get("courseCode");
|
|
|
+ String paperNumber = taskDetail.get("paperNumber");
|
|
|
+ String paperAttachmentIds = taskDetail.get("paperAttachmentIds");
|
|
|
+ List<Map> attachementIds = JSONObject.parseArray(paperAttachmentIds, Map.class);
|
|
|
+ for (Map attaMap : attachementIds) {
|
|
|
+ String name = attaMap.get("name").toString();
|
|
|
+ String attachmentId = attaMap.get("attachmentId").toString();
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
|
+ String url = commonService.filePreview(attachment.getPath());
|
|
|
+ StringJoiner sj = new StringJoiner(":");
|
|
|
+ String key = sj.add(courseCode).add(paperNumber).add(name).toString();
|
|
|
+ map.put(key, url);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|