|
@@ -1,16 +1,14 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-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.bean.dto.ClientPrintTaskDto;
|
|
|
-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.bean.dto.*;
|
|
|
+import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -35,6 +33,9 @@ public class ClientServiceImpl implements ClientService {
|
|
|
@Autowired
|
|
|
private ExamDetailService examDetailService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExamDetailCourseService examDetailCourseService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private BasicAttachmentService basicAttachmentService;
|
|
|
|
|
@@ -69,6 +70,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
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<>();
|
|
@@ -152,6 +154,153 @@ public class ClientServiceImpl implements ClientService {
|
|
|
return pirntTaskDtoIPage;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getPrintData(Long schoolId, Long examDetailId, String machineCode, Boolean isForceTry, String printUser) {
|
|
|
+ // 1.校验是否打样
|
|
|
+ List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
|
|
|
+ if(isForceTry){
|
|
|
+ for (ExamDetailCourse examDetailCours : examDetailCourses) {
|
|
|
+ QueryWrapper<ClientStatus> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId)
|
|
|
+ .eq(ClientStatus::getCourseCode, examDetailCours.getCourseCode())
|
|
|
+ .eq(ClientStatus::getPaperNumber, examDetailCours.getPaperNumber())
|
|
|
+ .eq(ClientStatus::getMachineCode, machineCode);
|
|
|
+ ClientStatus clientStatuse = clientStatusService.getOne(queryWrapper);
|
|
|
+ if(clientStatuse == null){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该机器没有打样");
|
|
|
+ } else {
|
|
|
+ if (!clientStatuse.getPass()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该机器打样不合格");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> finalMap = new HashMap<>();
|
|
|
+ // 2.取生成的完整的pdf
|
|
|
+ ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
|
+ 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> attachMap = commonService.filePreview(examDetail.getAttachmentId().toString(), false);
|
|
|
+ String totalPathUrl = attachMap.get("pathUrl");
|
|
|
+ if(StringUtils.isNotBlank(totalPathUrl)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场pdf文件丢失");
|
|
|
+ }
|
|
|
+
|
|
|
+ finalMap.put("total", totalPathUrl);
|
|
|
+
|
|
|
+ // 3.取学生试卷、题卡、备用试卷、题卡,印品
|
|
|
+ Map<String, Object> detailMap = new HashMap<>();
|
|
|
+ // 3.1取试卷
|
|
|
+ Map<String, String> map = mapCourseUrl(schoolId, examDetailId);
|
|
|
+ // 3.2取考生
|
|
|
+ List<Map<String, String>> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
|
|
|
+ // 3.3生成试卷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());
|
|
|
+ detailMap.put("paper", paperList);
|
|
|
+ // 3.4生成题卡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);
|
|
|
+ Map<String, String> urlMap = commonService.filePreview(attachmentId, false);
|
|
|
+ printDataDto.setUrl(urlMap.get("pathUrl"));
|
|
|
+ return printDataDto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ detailMap.put("card", cardList);
|
|
|
+
|
|
|
+ //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"));
|
|
|
+ stringMap.put("courseName", m.get("courseName"));
|
|
|
+ stringMap.put("paperNumber", m.get("paperNumber"));
|
|
|
+ stringMap.put("paperType", m.get("paperType"));
|
|
|
+ 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(":");
|
|
|
+ String key = sj.add(keyMap.get("courseCode")).add(keyMap.get("paperNumber")).add(keyMap.get("paperType")).toString();
|
|
|
+ clientPrintBackupDataDto.setUrl(map.get(key));
|
|
|
+ paperBackupList.add(clientPrintBackupDataDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ backupMap.put("paper", paperBackupList);
|
|
|
+
|
|
|
+ // todo 备用题卡
|
|
|
+
|
|
|
+ //3.5
|
|
|
+ String variableContent = examPrintPlan.getVariableContent();
|
|
|
+ String ordinaryContent = examPrintPlan.getOrdinaryContent();
|
|
|
+ List<Map> variableList = JSONObject.parseArray(variableContent, Map.class);
|
|
|
+ List<Map> otherList = new ArrayList<>();
|
|
|
+ for (Map variable : variableList) {
|
|
|
+ Map vMap = new HashMap();
|
|
|
+ vMap.put("type", variable.get("type"));
|
|
|
+ Map<String, String> urlMap = commonService.filePreview(variable.get("attachmentId").toString(), false);
|
|
|
+ vMap.put("htmlUrl", urlMap.get("htmlUrl"));
|
|
|
+ vMap.put("pdfUrl", urlMap.get("pdfUrl"));
|
|
|
+ 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"));
|
|
|
+ Map<String, String> urlMap = commonService.filePreview(ordinary.get("attachmentId").toString(), false);
|
|
|
+ vMap.put("htmlUrl", urlMap.get("htmlUrl"));
|
|
|
+ vMap.put("pdfUrl", urlMap.get("pdfUrl"));
|
|
|
+ otherList.add(vMap);
|
|
|
+ }
|
|
|
+ finalMap.put("other", otherList);
|
|
|
+ return finalMap;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据考场生成试卷map
|
|
|
*
|