|
@@ -4,9 +4,11 @@ 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.google.gson.JsonObject;
|
|
|
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.contant.SystemConstant;
|
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -75,7 +77,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
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>> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
|
|
|
+ Map<String, String> map = mapCourseUrl(examDetailCourses);
|
|
|
// 取考生
|
|
|
List<Map<String, String>> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, ticketNumber, type);
|
|
|
// 生成试卷List
|
|
@@ -93,7 +96,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
printDataDto.setStudentCode(studentCode);
|
|
|
printDataDto.setPaperType(paperType);
|
|
|
|
|
|
- StringJoiner sj = new StringJoiner(":");
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
String key = sj.add(courseCode).add(paperNumber).add(paperType).toString();
|
|
|
printDataDto.setUrl(map.get(key));
|
|
|
return printDataDto;
|
|
@@ -155,27 +158,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
}
|
|
|
|
|
|
@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("该机器打样不合格");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ public Map<String, Object> getPrintData(Long schoolId, Long examDetailId, String machineCode, String printUser) {
|
|
|
+ List<Map<String, String>> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
|
|
|
Map<String, Object> finalMap = new HashMap<>();
|
|
|
// 2.取生成的完整的pdf
|
|
|
ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
@@ -199,7 +183,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
// 3.取学生试卷、题卡、备用试卷、题卡,印品
|
|
|
Map<String, Object> detailMap = new HashMap<>();
|
|
|
// 3.1取试卷
|
|
|
- Map<String, String> map = mapCourseUrl(schoolId, examDetailId);
|
|
|
+ Map<String, String> map = mapCourseUrl(examDetailCourses);
|
|
|
// 3.2取考生
|
|
|
List<Map<String, String>> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
|
|
|
// 3.3生成试卷List
|
|
@@ -217,7 +201,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
printDataDto.setStudentCode(studentCode);
|
|
|
printDataDto.setPaperType(paperType);
|
|
|
|
|
|
- StringJoiner sj = new StringJoiner(":");
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
String key = sj.add(courseCode).add(paperNumber).add(paperType).toString();
|
|
|
printDataDto.setUrl(map.get(key));
|
|
|
return printDataDto;
|
|
@@ -264,7 +248,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
clientPrintBackupDataDto.setCourseName(keyMap.get("courseName"));
|
|
|
clientPrintBackupDataDto.setPaperNumber(keyMap.get("paperNumber"));
|
|
|
clientPrintBackupDataDto.setPaperType(keyMap.get("paperType"));
|
|
|
- StringJoiner sj = new StringJoiner(":");
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
String key = sj.add(keyMap.get("courseCode")).add(keyMap.get("paperNumber")).add(keyMap.get("paperType")).toString();
|
|
|
clientPrintBackupDataDto.setUrl(map.get(key));
|
|
|
paperBackupList.add(clientPrintBackupDataDto);
|
|
@@ -273,7 +257,24 @@ public class ClientServiceImpl implements ClientService {
|
|
|
|
|
|
backupMap.put("paper", paperBackupList);
|
|
|
|
|
|
- // todo 备用题卡
|
|
|
+ // 备用题卡
|
|
|
+ List<ClientPrintBackupDataDto> cardBackupList = new ArrayList<>();
|
|
|
+ for (Map<String, String> examDetailCours : examDetailCourses) {
|
|
|
+ String attachmentIds = examDetailCours.get("attachmentIds");
|
|
|
+ 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(backupCard.get("courseCode").toString());
|
|
|
+ clientPrintBackupDataDto.setCourseName(backupCard.get("courseName").toString());
|
|
|
+ clientPrintBackupDataDto.setPaperNumber(backupCard.get("paperNumber").toString());
|
|
|
+ clientPrintBackupDataDto.setPaperType(backupCard.get("name").toString());
|
|
|
+ Map<String, String> urlMap = commonService.filePreview(backupCard.get("attachmentId").toString(), false);
|
|
|
+ clientPrintBackupDataDto.setUrl(urlMap.get("pathUrl"));
|
|
|
+ cardBackupList.add(clientPrintBackupDataDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ backupMap.put("card", cardBackupList);
|
|
|
|
|
|
//3.5
|
|
|
String variableContent = examPrintPlan.getVariableContent();
|
|
@@ -281,37 +282,53 @@ public class ClientServiceImpl implements ClientService {
|
|
|
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);
|
|
|
+ int count = Integer.parseInt(variable.get("backupCount").toString());
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ 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);
|
|
|
+ int count = Integer.parseInt(ordinary.get("backupCount").toString());
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getPrintDataBatch(Long schoolId, Long machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate) {
|
|
|
+ Set<Long> orgIds = commonService.listSubOrgIds(null);
|
|
|
+ List<ClientPrintTaskDto> pirntTaskDtoList = examPrintPlanService.listClientPrintTask(schoolId,machineCode, printPlanId, status, courseCode, paperNumber, examPlace, examRoom, examStartTime, examEndTime,isDownload,validate, orgIds);
|
|
|
+ List<Map<String, Object>> finalList = new ArrayList<>();
|
|
|
+ for (ClientPrintTaskDto clientPrintTaskDto : pirntTaskDtoList) {
|
|
|
+ Map<String, Object> map = getPrintData(schoolId, Long.valueOf(clientPrintTaskDto.getExamDetailId()), null, null);
|
|
|
+ finalList.add(map);
|
|
|
+ }
|
|
|
+ return finalList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据考场生成试卷map
|
|
|
*
|
|
|
- * @param schoolId
|
|
|
- * @param examDetailId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, String> mapCourseUrl(Long schoolId, Long examDetailId) {
|
|
|
- List<Map<String, String>> taskDetails = examTaskDetailService.listByExamDetailId(schoolId, examDetailId);
|
|
|
+ public Map<String, String> mapCourseUrl(List<Map<String, String>> mapList) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
- for (Map<String, String> taskDetail : taskDetails) {
|
|
|
+ for (Map<String, String> taskDetail : mapList) {
|
|
|
String courseCode = taskDetail.get("courseCode");
|
|
|
String paperNumber = taskDetail.get("paperNumber");
|
|
|
String paperAttachmentIds = taskDetail.get("paperAttachmentIds");
|
|
@@ -321,7 +338,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
String attachmentId = attaMap.get("attachmentId").toString();
|
|
|
BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
|
|
|
String url = commonService.filePreview(attachment.getPath());
|
|
|
- StringJoiner sj = new StringJoiner(":");
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
String key = sj.add(courseCode).add(paperNumber).add(name).toString();
|
|
|
map.put(key, url);
|
|
|
}
|