|
@@ -27,6 +27,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -115,15 +116,13 @@ public class ClientServiceImpl implements ClientService {
|
|
|
// 取试卷
|
|
|
List<Map<String, Object>> examDetailCourses = examDetailCourseService.listByExamDetailId(examDetailId);
|
|
|
Map<String, Map<String, String>> map = mapCourseUrl(examDetailCourses);
|
|
|
- // 取考生
|
|
|
- List<Map> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, ticketNumber, type);
|
|
|
// 生成试卷List
|
|
|
if (printContent.contains("PAPER")) {
|
|
|
- finalMap.put("paper", splicePaperContent(studentList, map));
|
|
|
+ finalMap.put("paper", splicePaperContent(examDetailCourses, map));
|
|
|
}
|
|
|
if (printContent.contains("CARD")) {
|
|
|
// 生成题卡List
|
|
|
- finalMap.put("card", spliceCardContent(studentList));
|
|
|
+ finalMap.put("card", spliceCardContent(examDetailCourses));
|
|
|
}
|
|
|
//
|
|
|
|
|
@@ -188,8 +187,6 @@ public class ClientServiceImpl implements ClientService {
|
|
|
Map<String, Object> backupMap = new HashMap<>();
|
|
|
// 备份数量
|
|
|
int backupCount = examPrintPlan.getBackupCount();
|
|
|
- // 取考生列表
|
|
|
- List<Map> studentList = examDetailService.listStudentByExamDetailId(examDetail.getSchoolId(), examDetailId, null, null);
|
|
|
if (printContent.contains("PAPER")) {
|
|
|
if (examDetail.getAttachmentId() == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("考场pdf文件未生成");
|
|
@@ -209,9 +206,9 @@ public class ClientServiceImpl implements ClientService {
|
|
|
// 取试卷
|
|
|
Map<String, Map<String, String>> map = mapCourseUrl(examDetailCourses);
|
|
|
// 生成试卷List
|
|
|
- detailMap.put("paper", splicePaperContent(studentList, map));
|
|
|
+ detailMap.put("paper", splicePaperContent(examDetailCourses, map));
|
|
|
//试卷
|
|
|
- List<Map<String, String>> keyMaps = studentList.stream().map(m -> {
|
|
|
+ List<Map<String, String>> keyMaps = examDetailCourses.stream().map(m -> {
|
|
|
Map<String, String> stringMap = new HashMap<>();
|
|
|
stringMap.put("courseCode", m.get("courseCode").toString());
|
|
|
stringMap.put("courseName", m.get("courseName").toString());
|
|
@@ -243,7 +240,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
finalMap.put("cardTotal", totalCardPathUrl);
|
|
|
|
|
|
// 生成题卡List
|
|
|
- detailMap.put("card", spliceCardContent(studentList));
|
|
|
+ detailMap.put("card", spliceCardContent(examDetailCourses));
|
|
|
|
|
|
// 备用题卡
|
|
|
List<ClientPrintBackupDataDto> cardBackupList = new ArrayList<>();
|
|
@@ -649,35 +646,73 @@ public class ClientServiceImpl implements ClientService {
|
|
|
/**
|
|
|
* 生成试卷url公共方法
|
|
|
*
|
|
|
- * @param studentList
|
|
|
+ * @param examDetailCourses
|
|
|
* @param map
|
|
|
*/
|
|
|
- private List<ClientPrintDataDto> splicePaperContent(List<Map> studentList, Map<String, Map<String, String>> map) {
|
|
|
- List<ClientPrintDataDto> paperList = studentList.stream().map(m -> {
|
|
|
- ClientPrintDataDto printDataDto = newClientPrintDataDto(m);
|
|
|
- StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
- String key = sj.add(printDataDto.getCourseCode()).add(m.get("paperNumber").toString()).add(printDataDto.getPaperType()).toString();
|
|
|
- printDataDto.setMd5(map.get(key).get("md5"));
|
|
|
- printDataDto.setUrl(map.get(key).get("url"));
|
|
|
- return printDataDto;
|
|
|
+ private List<ClientPrintDataDto> splicePaperContent(List<Map<String, Object>> examDetailCourses, Map<String, Map<String, String>> map) {
|
|
|
+ return examDetailCourses.stream().map(m -> {
|
|
|
+ // 取考生列表
|
|
|
+ List<Map> studentList = examDetailService.listStudentByExamDetailCourseId(Long.valueOf(m.get("schoolId").toString()), Long.valueOf(m.get("examDetailCourseId").toString()), null, null);
|
|
|
+ Integer printCount = Integer.parseInt(m.get("printCount").toString());
|
|
|
+ if (studentList != null && studentList.size() > 0) {
|
|
|
+ for (Map studentMap : studentList) {
|
|
|
+ ClientPrintDataDto printDataDto = newClientPrintDataDto(studentMap);
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
+ String key = sj.add(printDataDto.getCourseCode()).add(studentMap.get("paperNumber").toString()).add(printDataDto.getPaperType()).toString();
|
|
|
+ printDataDto.setMd5(map.get(key).get("md5"));
|
|
|
+ printDataDto.setUrl(map.get(key).get("url"));
|
|
|
+ return printDataDto;
|
|
|
+ }
|
|
|
+ } else if (printCount != null && printCount > 0) {
|
|
|
+ for (int i = 0; i < printCount; i++) {
|
|
|
+ ClientPrintDataDto printDataDto = newClientPrintDataDto(m);
|
|
|
+ StringJoiner sj = new StringJoiner(SystemConstant.DELIMITER);
|
|
|
+ String key = sj.add(printDataDto.getCourseCode()).add(m.get("paperNumber").toString()).add(printDataDto.getPaperType()).toString();
|
|
|
+ printDataDto.setMd5(map.get(key).get("md5"));
|
|
|
+ printDataDto.setUrl(map.get(key).get("url"));
|
|
|
+ return printDataDto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return paperList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成题卡url公共方法
|
|
|
*
|
|
|
- * @param studentList
|
|
|
+ * @param examDetailCourses
|
|
|
*/
|
|
|
- private List<ClientPrintDataDto> spliceCardContent(List<Map> studentList) {
|
|
|
- List<ClientPrintDataDto> cardList = studentList.stream().map(m -> {
|
|
|
- ClientPrintDataDto printDataDto = newClientPrintDataDto(m);
|
|
|
- Map<String, String> urlMap = teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(m.get("attachmentId").toString()), false);
|
|
|
- printDataDto.setMd5(urlMap.get("md5"));
|
|
|
- printDataDto.setUrl(urlMap.get("url"));
|
|
|
- return printDataDto;
|
|
|
+ private List<ClientPrintDataDto> spliceCardContent(List<Map<String, Object>> examDetailCourses) {
|
|
|
+ return examDetailCourses.stream().map(m -> {
|
|
|
+ // 取考生列表
|
|
|
+ List<Map> studentList = examDetailService.listStudentByExamDetailCourseId(Long.valueOf(m.get("schoolId").toString()), Long.valueOf(m.get("examDetailCourseId").toString()), null, null);
|
|
|
+ Integer printCount = Integer.parseInt(m.get("printCount").toString());
|
|
|
+ if (studentList != null && studentList.size() > 0) {
|
|
|
+ for (Map studentMap : studentList) {
|
|
|
+ ClientPrintDataDto printDataDto = newClientPrintDataDto(studentMap);
|
|
|
+ Map<String, String> urlMap = teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(studentMap.get("attachmentId").toString()), false);
|
|
|
+ printDataDto.setMd5(urlMap.get("md5"));
|
|
|
+ printDataDto.setUrl(urlMap.get("url"));
|
|
|
+ return printDataDto;
|
|
|
+ }
|
|
|
+ } else if (printCount > 0) {
|
|
|
+ AtomicInteger atomicInteger = new AtomicInteger(0);
|
|
|
+ List<JSONObject> commonAttachmentIds = JSONObject.parseArray(m.get("commonAttachmentId").toString(), JSONObject.class) ;
|
|
|
+ List<String> paperTypes = Arrays.stream(m.get("paperType").toString().split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < printCount; i++) {
|
|
|
+ int seq = atomicInteger.getAndIncrement();
|
|
|
+ int mod = seq % commonAttachmentIds.size();
|
|
|
+ String tempPaperType = paperTypes.get(mod);
|
|
|
+ JSONObject jsonObject = commonAttachmentIds.stream().filter(j -> tempPaperType.equals(j.getString("name"))).findFirst().get();
|
|
|
+ ClientPrintDataDto printDataDto = newClientPrintDataDto(m);
|
|
|
+ Map<String, String> urlMap = teachcloudCommonService.filePreviewByAttachmentId(Long.valueOf(jsonObject.get("attachmentId").toString()), false);
|
|
|
+ printDataDto.setMd5(urlMap.get("md5"));
|
|
|
+ printDataDto.setUrl(urlMap.get("url"));
|
|
|
+ return printDataDto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return cardList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -689,8 +724,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
ClientPrintDataDto printDataDto = new ClientPrintDataDto();
|
|
|
String courseCode = m.get("courseCode").toString();
|
|
|
String courseName = m.get("courseName").toString();
|
|
|
- String studentName = m.get("studentName").toString();
|
|
|
- String studentCode = m.get("studentCode").toString();
|
|
|
+ String studentName = m.containsKey("studentName") ? m.get("studentName").toString() : "";
|
|
|
+ String studentCode = m.containsKey("studentCode") ? m.get("studentCode").toString() : "";
|
|
|
String paperType = m.get("paperType").toString();
|
|
|
printDataDto.setCourseCode(courseCode);
|
|
|
printDataDto.setCourseName(courseName);
|