|
@@ -6,16 +6,14 @@ import com.aliyun.oss.common.utils.BinaryUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
|
|
import com.qmth.distributed.print.business.bean.dto.excel.UserImportDto;
|
|
import com.qmth.distributed.print.business.bean.dto.excel.UserImportDto;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.DrawRuleEnum;
|
|
import com.qmth.distributed.print.business.enums.DrawRuleEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
import com.qmth.distributed.print.business.templete.service.TaskLogicService;
|
|
-import com.qmth.distributed.print.business.util.GoogleBarCodeUtil;
|
|
|
|
-import com.qmth.distributed.print.business.util.OssUtil;
|
|
|
|
-import com.qmth.distributed.print.business.util.PdfUtil;
|
|
|
|
-import com.qmth.distributed.print.business.util.ServletUtil;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.util.*;
|
|
import com.qmth.distributed.print.business.util.excel.ExcelError;
|
|
import com.qmth.distributed.print.business.util.excel.ExcelError;
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
@@ -33,6 +31,7 @@ import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -86,6 +85,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
@Resource
|
|
@Resource
|
|
OssUtil ossUtil;
|
|
OssUtil ossUtil;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CacheService cacheService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ FreemarkerUtil freemarkerUtil;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 执行导入用户逻辑
|
|
* 执行导入用户逻辑
|
|
*
|
|
*
|
|
@@ -160,123 +165,129 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
throw ExceptionResultEnum.ERROR.exception("印刷计划为空");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ BasicSchool basicSchool = cacheService.schoolCache(examPrintPlan.getSchoolId());
|
|
|
|
+
|
|
//查询examDetail
|
|
//查询examDetail
|
|
QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamDetail> examDetailQueryWrapper = new QueryWrapper<>();
|
|
examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
examDetailQueryWrapper.lambda().eq(ExamDetail::getSchoolId, sysUser.getSchoolId())
|
|
.eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId());
|
|
.eq(ExamDetail::getPrintPlanId, tbTask.getPrintPlanId());
|
|
- ExamDetail examDetail = detailService.getOne(examDetailQueryWrapper);
|
|
|
|
- if (Objects.isNull(examDetail)) {
|
|
|
|
|
|
+ List<ExamDetail> examDetailList = detailService.list(examDetailQueryWrapper);
|
|
|
|
+ if (Objects.isNull(examDetailList) || examDetailList.size() == 0) {
|
|
throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
throw ExceptionResultEnum.ERROR.exception("考务计划为空");
|
|
}
|
|
}
|
|
attachmentIds = Objects.isNull(attachmentIds) ? attachmentIds = new HashSet<>() : attachmentIds;
|
|
attachmentIds = Objects.isNull(attachmentIds) ? attachmentIds = new HashSet<>() : attachmentIds;
|
|
- if (Objects.nonNull(examDetail.getAttachmentId())) {
|
|
|
|
- attachmentIds.add(examDetail.getAttachmentId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //查询examDetailCourse
|
|
|
|
- QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
|
- List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
|
-
|
|
|
|
- List<String> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
|
- List<String> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
|
- List<String> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
- List<String> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<String> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<String> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
-
|
|
|
|
- if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
- //获取普通印品
|
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
|
|
- }
|
|
|
|
|
|
+ for (ExamDetail examDetail : examDetailList) {
|
|
|
|
+ if (Objects.nonNull(examDetail.getAttachmentId())) {
|
|
|
|
+ attachmentIds.add(examDetail.getAttachmentId());
|
|
|
|
+ }
|
|
|
|
|
|
- for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
- //查询试卷
|
|
|
|
- QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode())
|
|
|
|
- .eq(ExamTask::getCourseName, examDetailCourse.getCourseName())
|
|
|
|
- .eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber())
|
|
|
|
- .eq(ExamTask::getEnable, true)
|
|
|
|
- .eq(ExamTask::getStatus, ExamStatusEnum.FINISH);
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.list(examTaskQueryWrapper);
|
|
|
|
- if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务为空");
|
|
|
|
|
|
+ //查询examDetailCourse
|
|
|
|
+ QueryWrapper<ExamDetailCourse> examDetailCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examDetailCourseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetail.getId());
|
|
|
|
+ List<ExamDetailCourse> examDetailCourseList = detailCourseService.list(examDetailCourseQueryWrapper);
|
|
|
|
+
|
|
|
|
+ List<String> variablePdfList = new ArrayList<>();//变量印品(签到表、卷袋贴)
|
|
|
|
+ List<String> ordinaryPdfList = new ArrayList<>();//普通印品(登记表)
|
|
|
|
+ List<String> paperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
+ List<String> examStudentPdfList = new ArrayList<>();//所有题卡
|
|
|
|
+ List<String> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
+ List<String> cardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
+
|
|
|
|
+ if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
|
|
|
|
+ //获取普通印品
|
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
|
|
}
|
|
}
|
|
- Set<Long> examTaskIds = examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
|
|
|
|
- .eq(ExamTaskDetail::getEnable, true);
|
|
|
|
- List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
|
- for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
- //查询题卡
|
|
|
|
- ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
- if (Objects.isNull(examCard)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡为空");
|
|
|
|
|
|
+
|
|
|
|
+ for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
|
|
|
|
+ //查询试卷
|
|
|
|
+ QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode())
|
|
|
|
+ .eq(ExamTask::getCourseName, examDetailCourse.getCourseName())
|
|
|
|
+ .eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber())
|
|
|
|
+ .eq(ExamTask::getEnable, true)
|
|
|
|
+ .eq(ExamTask::getStatus, ExamStatusEnum.FINISH);
|
|
|
|
+ List<ExamTask> examTaskList = examTaskService.list(examTaskQueryWrapper);
|
|
|
|
+ if (Objects.isNull(examTaskList) || examTaskList.size() == 0) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务为空");
|
|
}
|
|
}
|
|
- QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
- List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
+ Set<Long> examTaskIds = examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
|
|
|
|
+ .eq(ExamTaskDetail::getEnable, true);
|
|
|
|
+ List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
+ for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
|
|
|
|
+ //查询题卡
|
|
|
|
+ ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
+ if (Objects.isNull(examCard)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡为空");
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
+ List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
|
|
|
|
|
|
- //抽取卷型
|
|
|
|
- String paperType = getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
|
|
+ //抽取卷型
|
|
|
|
+ String paperType = getPaperType(examPrintPlan, examTaskDetail);
|
|
|
|
|
|
- //获取试卷pdf
|
|
|
|
- getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfList, backupPaperPdfList);
|
|
|
|
|
|
+ //获取试卷pdf
|
|
|
|
+ getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfList, backupPaperPdfList);
|
|
|
|
|
|
- basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
- for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
- getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
+ basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
|
|
|
|
+ for (ExamCardDetail examCardDetail : examCardDetailList) {
|
|
|
|
+ getCardAttachmentId(examCardDetail, attachmentIds);
|
|
|
|
|
|
- //把模板页面上的 ${} 替换成实际内容
|
|
|
|
- String cardContent = replaceHtmlTemplete(examCardDetail);
|
|
|
|
- String studentContent = cardContent;
|
|
|
|
|
|
+ //把模板页面上的 ${} 替换成实际内容
|
|
|
|
+ String cardContent = replaceHtmlTemplete(examCardDetail);
|
|
|
|
+ String studentContent = cardContent;
|
|
|
|
|
|
- for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
- basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, examTaskDetail, jsonArray, sysUser.getId(), cardPdfList));
|
|
|
|
- }
|
|
|
|
|
|
+ for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
|
|
|
|
+ basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfList));
|
|
|
|
+ }
|
|
|
|
|
|
- //查询考生
|
|
|
|
- QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
- .eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
|
- List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
|
|
+ //查询考生
|
|
|
|
+ QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examStudentQueryWrapper.lambda().eq(ExamStudent::getSchoolId, sysUser.getSchoolId())
|
|
|
|
+ .eq(ExamStudent::getExamDetailCourseId, examTaskDetail.getId());
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.list(examStudentQueryWrapper);
|
|
|
|
|
|
- Integer signVariableBackupCount = null, packagVariableBackupCount = null;
|
|
|
|
- for (ExamStudent t : examStudentList) {
|
|
|
|
|
|
+ Integer signVariableBackupCount = null, packagVariableBackupCount = null;
|
|
if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
if (Objects.nonNull(examPrintPlan.getVariableContent())) {
|
|
//获取变量印品
|
|
//获取变量印品
|
|
JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
|
|
for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
String type = (String) jsonObjectVariable.get("type");
|
|
String type = (String) jsonObjectVariable.get("type");
|
|
- Long templeteId = (Long) jsonObjectVariable.get("templeteId");
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(templeteId);
|
|
|
|
|
|
+ Long attachmentId = (Long) jsonObjectVariable.get("attachmentId");
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ String htmlContent = new String(commonService.getFileByte(basicAttachment.getPath(), false), StandardCharsets.UTF_8);
|
|
|
|
+ log.info("htmlContent:{}", htmlContent);
|
|
if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
signVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
signVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
-// String filePath = basicAttachment.getPath();
|
|
|
|
-// ossUtil.ossDownload();
|
|
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAG")) {//卷袋贴
|
|
} else if (Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAG")) {//卷袋贴
|
|
packagVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
packagVariableBackupCount = (Integer) jsonObjectVariable.get("backupCount");
|
|
}
|
|
}
|
|
|
|
+// createSignBook(basicAttachment, htmlContent, examDetailCourse, basicSchool.getName(), examStudentList, variablePdfList);
|
|
|
|
+ createSignBook(basicAttachment, examDetailCourse, basicSchool.getName(), examStudentList, variablePdfList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
|
|
|
|
+
|
|
|
|
+ for (ExamStudent t : examStudentList) {
|
|
|
|
+ basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
|
|
|
|
+ }
|
|
|
|
+ examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
+ jsonObject.put("card", jsonArray);
|
|
|
|
+ examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
}
|
|
}
|
|
- examStudentService.saveOrUpdateBatch(examStudentList);
|
|
|
|
- jsonObject.put("card", jsonArray);
|
|
|
|
- examCardDetail.setAttachmentId(jsonObject.toJSONString());
|
|
|
|
|
|
+ examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
}
|
|
}
|
|
- examCardDetailService.saveOrUpdateBatch(examCardDetailList);
|
|
|
|
|
|
+ examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
}
|
|
}
|
|
- examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
|
|
|
|
|
|
+ //合并pdf
|
|
|
|
+ basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
}
|
|
}
|
|
- //合并pdf
|
|
|
|
- basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
|
|
|
|
-
|
|
|
|
//最后一步删除附件
|
|
//最后一步删除附件
|
|
deleteAttachment(attachmentIds);
|
|
deleteAttachment(attachmentIds);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -291,6 +302,220 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建签到表
|
|
|
|
+ *
|
|
|
|
+ * @param basicAttachment
|
|
|
|
+ * @param examDetailCourse
|
|
|
|
+ * @param schoolName
|
|
|
|
+ * @param examStudentList
|
|
|
|
+ * @param variablePdfList
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ private void createSignBook(BasicAttachment basicAttachment,
|
|
|
|
+// String htmlContent,
|
|
|
|
+ ExamDetailCourse examDetailCourse, String schoolName, List<ExamStudent> examStudentList, List<String> variablePdfList) throws IOException {
|
|
|
|
+ /**html
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{examDetailCourseId\\}", examDetailCourse.getId() + "");
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{schoolName\\}", schoolName);
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{courseName\\}", examDetailCourse.getCourseName());
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{courseCode\\}", examDetailCourse.getCourseCode());
|
|
|
|
+
|
|
|
|
+ // htmlMap.put("examName", exam.getExamName());
|
|
|
|
+ // htmlMap.put("examRoom", examDetailMap.get("examRoom"));
|
|
|
|
+ // htmlMap.put("examRoomId", examDetailMap.get("examRoomId"));
|
|
|
|
+ // htmlMap.put("startTime", examDetailMap.get("startTime"));
|
|
|
|
+ // htmlMap.put("endTime", examDetailMap.get("endTime"));
|
|
|
|
+ // htmlMap.put("sceneNumberId", examDetailMap.get("sceneNumberId"));
|
|
|
|
+
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{paperCode\\}", examDetailCourse.getPaperNumber());
|
|
|
|
+ htmlContent = htmlContent.replaceAll("\\$\\{paperCodeImg\\}", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
|
+
|
|
|
|
+ // List<Map> students = tcPExamStudentService.clientStudentByDetailId(examDetailId);
|
|
|
|
+
|
|
|
|
+ // List<String> extendColumnList = students.stream().map(m -> m.get("extendColumn").toString()).distinct().collect(Collectors.toList());
|
|
|
|
+ // Set<String> classTeacher = new HashSet();
|
|
|
|
+ // if (extendColumnList != null && extendColumnList.size() > 0) {
|
|
|
|
+ // for (String s : extendColumnList) {
|
|
|
|
+ // List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
|
+ // for (Map map : mapList) {
|
|
|
|
+ // if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
|
+ // classTeacher.add(map.get("value").toString());
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
|
+
|
|
|
|
+ int totalCount = examStudentList.size();
|
|
|
|
+ if (totalCount > 0) {
|
|
|
|
+ // List<Map> subList = new ArrayList<>();
|
|
|
|
+ int pageCount = totalCount % 80 == 0 ? totalCount / 80 : totalCount / 80 + 1;
|
|
|
|
+ for (int i = 0; i < pageCount; i++) {
|
|
|
|
+ Map subMap = new HashMap();
|
|
|
|
+ subMap.put("index", i + 1);
|
|
|
|
+ int studentCount;
|
|
|
|
+ List<ExamStudent> subStudents;
|
|
|
|
+ if (pageCount == 1) {
|
|
|
|
+ studentCount = totalCount;
|
|
|
|
+ subStudents = examStudentList;
|
|
|
|
+ } else if (pageCount > 1 && i == pageCount - 1) {
|
|
|
|
+ studentCount = totalCount - (pageCount - 1) * 80;
|
|
|
|
+ subStudents = examStudentList.subList(80 * i, examStudentList.size());
|
|
|
|
+ } else {
|
|
|
|
+ studentCount = 80;
|
|
|
|
+ subStudents = examStudentList.subList(80 * i, 80 * (i + 1));
|
|
|
|
+ }
|
|
|
|
+ subMap.put("studentCount", studentCount);
|
|
|
|
+ List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
|
+ List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ int mod = subStudents.size() % 2;
|
|
|
|
+ int htmlTableCount = mod == 0 ? subStudents.size() / 2 : subStudents.size() / 2 + 1;
|
|
|
|
+ for (int j = 0; j < htmlTableCount; j++) {
|
|
|
|
+ ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
|
+ examStudentDto.setIndex(j + 1);
|
|
|
|
+ examStudentList1.add(examStudentDto);
|
|
|
|
+ // Map map = subStudents.get(j);
|
|
|
|
+ // TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
|
+ // tcPExamStudent.setIndex(j + 1);
|
|
|
|
+ // tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
|
+ // tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
|
+ // tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
|
+ // tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
|
+ // tcPExamStudentList1.add(tcPExamStudent);
|
|
|
|
+ }
|
|
|
|
+ for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
|
+ ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
|
+ examStudentDto.setIndex(j + 1);
|
|
|
|
+ examStudentList2.add(examStudentDto);
|
|
|
|
+ // Map map = students.get(j);
|
|
|
|
+ // TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
|
+ // tcPExamStudent.setIndex(j + 1);
|
|
|
|
+ // tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
|
+ // tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
|
+ // tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
|
+ // tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
|
+ // tcPExamStudentList2.add(tcPExamStudent);
|
|
|
|
+ }
|
|
|
|
+ if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
|
+ for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
|
+ examStudentList2.add(new ExamStudentDto());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // subMap.put("studentList1", examStudentList1);
|
|
|
|
+ // subMap.put("studentList2", examStudentList2);
|
|
|
|
+
|
|
|
|
+ // htmlContent = htmlContent.replaceAll("\\$\\{studentList1\\}", examStudentList1);
|
|
|
|
+ // htmlContent = htmlContent.replaceAll("\\$\\{studentList2\\}", examStudentList2);
|
|
|
|
+
|
|
|
|
+ // subList.add(subMap);
|
|
|
|
+ }
|
|
|
|
+ // htmlMap.put("subList", subList);
|
|
|
|
+ }
|
|
|
|
+ basicAttachmentService.saveAttachmentPdf(basicAttachment, variablePdfList);
|
|
|
|
+ **/
|
|
|
|
+
|
|
|
|
+ Map<String, Object> htmlMap = new HashMap<>();
|
|
|
|
+ htmlMap.put("examDetailCourseId", examDetailCourse.getId());
|
|
|
|
+ htmlMap.put("schoolName", schoolName);
|
|
|
|
+
|
|
|
|
+ htmlMap.put("courseName", examDetailCourse.getCourseName());
|
|
|
|
+ htmlMap.put("courseCode", examDetailCourse.getCourseCode());
|
|
|
|
+// htmlMap.put("examName", exam.getExamName());
|
|
|
|
+// htmlMap.put("examRoom", examDetailMap.get("examRoom"));
|
|
|
|
+// htmlMap.put("examRoomId", examDetailMap.get("examRoomId"));
|
|
|
|
+// htmlMap.put("startTime", examDetailMap.get("startTime"));
|
|
|
|
+// htmlMap.put("endTime", examDetailMap.get("endTime"));
|
|
|
|
+// htmlMap.put("sceneNumberId", examDetailMap.get("sceneNumberId"));
|
|
|
|
+ htmlMap.put("paperCode", examDetailCourse.getPaperNumber());
|
|
|
|
+ htmlMap.put("paperCodeImg", GoogleBarCodeUtil.createBarCode(examDetailCourse.getPaperNumber(), false));
|
|
|
|
+
|
|
|
|
+// List<String> extendColumnList = students.stream().map(m -> m.get("extendColumn").toString()).distinct().collect(Collectors.toList());
|
|
|
|
+// Set<String> classTeacher = new HashSet();
|
|
|
|
+// if (extendColumnList != null && extendColumnList.size() > 0) {
|
|
|
|
+// for (String s : extendColumnList) {
|
|
|
|
+// List<Map> mapList = JSONObject.parseArray(s, Map.class);
|
|
|
|
+// for (Map map : mapList) {
|
|
|
|
+// if (Objects.equals("classTeacher", map.get("code").toString())) {
|
|
|
|
+// classTeacher.add(map.get("value").toString());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// htmlMap.put("classTeacher", String.join(",", classTeacher));
|
|
|
|
+
|
|
|
|
+ int totalCount = examStudentList.size();
|
|
|
|
+ if (totalCount > 0) {
|
|
|
|
+ List<Map> subList = new ArrayList<>();
|
|
|
|
+ int pageCount = totalCount % 80 == 0 ? totalCount / 80 : totalCount / 80 + 1;
|
|
|
|
+ for (int i = 0; i < pageCount; i++) {
|
|
|
|
+ Map subMap = new HashMap();
|
|
|
|
+ subMap.put("index", i + 1);
|
|
|
|
+ int studentCount;
|
|
|
|
+ List<ExamStudent> subStudents;
|
|
|
|
+ if (pageCount == 1) {
|
|
|
|
+ studentCount = totalCount;
|
|
|
|
+ subStudents = examStudentList;
|
|
|
|
+ } else if (pageCount > 1 && i == pageCount - 1) {
|
|
|
|
+ studentCount = totalCount - (pageCount - 1) * 80;
|
|
|
|
+ subStudents = examStudentList.subList(80 * i, examStudentList.size());
|
|
|
|
+ } else {
|
|
|
|
+ studentCount = 80;
|
|
|
|
+ subStudents = examStudentList.subList(80 * i, 80 * (i + 1));
|
|
|
|
+ }
|
|
|
|
+ subMap.put("studentCount", studentCount);
|
|
|
|
+ List<ExamStudentDto> examStudentList1 = new ArrayList<>();
|
|
|
|
+ List<ExamStudentDto> examStudentList2 = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ int mod = subStudents.size() % 2;
|
|
|
|
+ int htmlTableCount = mod == 0 ? subStudents.size() / 2 : subStudents.size() / 2 + 1;
|
|
|
|
+ for (int j = 0; j < htmlTableCount; j++) {
|
|
|
|
+ ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
|
+ examStudentDto.setIndex(j + 1);
|
|
|
|
+ examStudentList1.add(examStudentDto);
|
|
|
|
+// Map map = subStudents.get(j);
|
|
|
|
+// TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
|
+// tcPExamStudent.setIndex(j + 1);
|
|
|
|
+// tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
|
+// tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
|
+// tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
|
+// tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
|
+// tcPExamStudentList1.add(tcPExamStudent);
|
|
|
|
+ }
|
|
|
|
+ for (int j = htmlTableCount; j < subStudents.size(); j++) {
|
|
|
|
+ ExamStudentDto examStudentDto = gson.fromJson(gson.toJson(subStudents.get(j)), ExamStudentDto.class);
|
|
|
|
+ examStudentDto.setIndex(j + 1);
|
|
|
|
+ examStudentList2.add(examStudentDto);
|
|
|
|
+// Map map = students.get(j);
|
|
|
|
+// TcPExamStudent tcPExamStudent = new TcPExamStudent();
|
|
|
|
+// tcPExamStudent.setIndex(j + 1);
|
|
|
|
+// tcPExamStudent.setSiteNumber(String.valueOf(map.get("siteNumber")));
|
|
|
|
+// tcPExamStudent.setStudentCode(String.valueOf(map.get("studentCode")));
|
|
|
|
+// tcPExamStudent.setName(String.valueOf(map.get("name")));
|
|
|
|
+// tcPExamStudent.setExtendColumn(getClassName(map.get("extendColumn").toString()));
|
|
|
|
+// tcPExamStudentList2.add(tcPExamStudent);
|
|
|
|
+ }
|
|
|
|
+ if (examStudentList1.size() > examStudentList2.size()) {
|
|
|
|
+ for (int j = subStudents.size() - htmlTableCount; j < examStudentList1.size(); j++) {
|
|
|
|
+ examStudentList2.add(new ExamStudentDto());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ subMap.put("studentList1", examStudentList1);
|
|
|
|
+ subMap.put("studentList2", examStudentList2);
|
|
|
|
+ subList.add(subMap);
|
|
|
|
+ }
|
|
|
|
+ htmlMap.put("subList", subList);
|
|
|
|
+ }
|
|
|
|
+ freemarkerUtil.createSignBook(htmlMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 替换html通用模版
|
|
* 替换html通用模版
|
|
*
|
|
*
|
|
@@ -372,7 +597,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
paperTypes = unexposedPaperType.split("/");
|
|
paperTypes = unexposedPaperType.split("/");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (Objects.isNull(exposedPaperType) || Objects.isNull(unexposedPaperType)) {
|
|
|
|
|
|
+ if (Objects.isNull(exposedPaperType) && Objects.isNull(unexposedPaperType)) {
|
|
throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
|
|
throw ExceptionResultEnum.ERROR.exception("当前没有未曝光的卷型");
|
|
}
|
|
}
|
|
if (Objects.nonNull(unexposedPaperType)) {
|
|
if (Objects.nonNull(unexposedPaperType)) {
|
|
@@ -482,14 +707,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
* @param paperType
|
|
* @param paperType
|
|
* @param examDetailCourse
|
|
* @param examDetailCourse
|
|
* @param examCard
|
|
* @param examCard
|
|
- * @param examTaskDetail
|
|
|
|
* @param jsonArray
|
|
* @param jsonArray
|
|
* @param userId
|
|
* @param userId
|
|
* @param cardPdfList
|
|
* @param cardPdfList
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public BasicAttachment cardHtml(String cardContent, String paperType, ExamDetailCourse examDetailCourse, ExamCard examCard, ExamTaskDetail examTaskDetail, JSONArray jsonArray, Long userId, List<String> cardPdfList) throws IOException {
|
|
|
|
|
|
+ public BasicAttachment cardHtml(String cardContent, String paperType, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<String> cardPdfList) throws IOException {
|
|
//通用题卡
|
|
//通用题卡
|
|
String cardTemp = cardContent;
|
|
String cardTemp = cardContent;
|
|
cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
|
|
cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
|
|
@@ -503,7 +727,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
BasicAttachment cardAttachment = basicAttachmentService.saveAttachmentHtml(examCard.getSchoolId() + "|" + examCard.getCourseCode(), cardTemp, userId, cardPdfList);
|
|
BasicAttachment cardAttachment = basicAttachmentService.saveAttachmentHtml(examCard.getSchoolId() + "|" + examCard.getCourseCode(), cardTemp, userId, cardPdfList);
|
|
JSONObject object = new JSONObject();
|
|
JSONObject object = new JSONObject();
|
|
object.put("name", paperType);
|
|
object.put("name", paperType);
|
|
- object.put("examTaskDetailId", examTaskDetail.getId());
|
|
|
|
|
|
+ object.put("examDetailCourseId", examDetailCourse.getId());
|
|
object.put("attachmentId", cardAttachment.getId());
|
|
object.put("attachmentId", cardAttachment.getId());
|
|
jsonArray.add(object);
|
|
jsonArray.add(object);
|
|
return cardAttachment;
|
|
return cardAttachment;
|