|
@@ -87,63 +87,8 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
@Resource
|
|
@Resource
|
|
ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
|
|
ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
|
|
@Resource
|
|
@Resource
|
|
- private PrintCommonService printCommonService;
|
|
|
|
- @Resource
|
|
|
|
private FileUploadService fileUploadService;
|
|
private FileUploadService fileUploadService;
|
|
|
|
|
|
- /**
|
|
|
|
- * 创建A4文件
|
|
|
|
- *
|
|
|
|
- * @param tbTaskPdf
|
|
|
|
- * @param examDetailCourseList
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- @Transactional
|
|
|
|
- public void createA4File(TBTaskPdf tbTaskPdf, List<ExamDetailCourse> examDetailCourseList) throws Exception {
|
|
|
|
- CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
|
|
|
|
- ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
|
|
|
|
- ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
|
|
|
|
- BasicSchool basicSchool = commonCacheService.schoolCache(tbTaskPdf.getSchoolId());
|
|
|
|
- // 印品
|
|
|
|
- String ordinaryContent = examPrintPlan.getOrdinaryContent();
|
|
|
|
- if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
|
|
|
|
- //获取普通印品
|
|
|
|
- JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
|
|
|
|
- for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
- JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
- if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
|
- Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
- BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
- createPdfNewUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
|
|
|
|
- if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
|
|
|
|
- String variableContent = examPrintPlan.getVariableContent();
|
|
|
|
- if (StringUtils.isNotBlank(variableContent)) {
|
|
|
|
- List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
|
- List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
|
|
|
|
- //获取变量印品
|
|
|
|
- JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
|
|
|
|
- for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
|
- JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
|
- String type = (String) jsonObjectVariable.get("type");
|
|
|
|
- if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
|
|
|
|
- Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
|
|
|
|
- if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
|
- createPdfNewUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
|
|
|
|
- } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
- Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
- createPdfNewUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- examDetailService.updateById(examDetail);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void executeCreatePdfLogic(TBTaskPdf tbTaskPdf) {
|
|
public void executeCreatePdfLogic(TBTaskPdf tbTaskPdf) {
|
|
CreatePdfDto createPdfDto = new CreatePdfDto();
|
|
CreatePdfDto createPdfDto = new CreatePdfDto();
|
|
@@ -174,7 +119,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
} finally {
|
|
} finally {
|
|
- if(CollectionUtils.isNotEmpty(createPdfDto.getFileTempList())){
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(createPdfDto.getFileTempList())) {
|
|
for (File file : createPdfDto.getFileTempList()) {
|
|
for (File file : createPdfDto.getFileTempList()) {
|
|
FileUtil.deleteFile(file);
|
|
FileUtil.deleteFile(file);
|
|
}
|
|
}
|
|
@@ -253,13 +198,8 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
|
|
for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
|
|
String[] paperTypes = examDetailCourse.getPaperType().split(",");
|
|
String[] paperTypes = examDetailCourse.getPaperType().split(",");
|
|
|
|
|
|
- List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
|
|
|
|
- List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
|
|
|
|
- List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
|
|
|
|
- List<PdfDto> backupCardPdfList = new ArrayList<>();//备份题卡
|
|
|
|
-
|
|
|
|
//查询命题任务绑定的试卷和题卡
|
|
//查询命题任务绑定的试卷和题卡
|
|
- ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(tbTaskPdf.getSchoolId(), tbTaskPdf.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
|
|
|
|
|
|
+ ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(tbTaskPdf.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
|
|
if (examTask == null) {
|
|
if (examTask == null) {
|
|
throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
|
|
throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
|
|
} else if (examTask.getReview()) {
|
|
} else if (examTask.getReview()) {
|
|
@@ -273,8 +213,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
}
|
|
}
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
|
|
|
|
|
|
- List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
|
|
-
|
|
|
|
CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
|
|
CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
|
|
String printContent = examPrintPlan.getPrintContent();
|
|
String printContent = examPrintPlan.getPrintContent();
|
|
if (StringUtils.isBlank(printContent)) {
|
|
if (StringUtils.isBlank(printContent)) {
|
|
@@ -283,10 +221,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
// 计算备份数量,默认最小为1份。
|
|
// 计算备份数量,默认最小为1份。
|
|
int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
|
|
|
|
+ List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
|
|
// 试卷数据组装
|
|
// 试卷数据组装
|
|
if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
|
|
if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
|
|
List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
|
|
List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
|
|
-
|
|
|
|
// 生成考生试卷
|
|
// 生成考生试卷
|
|
if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
if (CollectionUtils.isNotEmpty(examStudentList)) {
|
|
for (ExamStudent t : examStudentList) {
|
|
for (ExamStudent t : examStudentList) {
|
|
@@ -333,7 +271,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
if (examStudentList != null && examStudentList.size() > 0) {
|
|
if (examStudentList != null && examStudentList.size() > 0) {
|
|
for (ExamStudent t : examStudentList) {
|
|
for (ExamStudent t : examStudentList) {
|
|
// 用带条码的模板
|
|
// 用带条码的模板
|
|
- createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
|
|
|
+ createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), basicCardRule);
|
|
}
|
|
}
|
|
examStudentService.updateBatchById(examStudentList);
|
|
examStudentService.updateBatchById(examStudentList);
|
|
} else if (examDetailCourse.getTotalSubjects() != null) {
|
|
} else if (examDetailCourse.getTotalSubjects() != null) {
|
|
@@ -344,7 +282,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
int seq = atomicInteger.getAndIncrement();
|
|
int seq = atomicInteger.getAndIncrement();
|
|
int mod = seq % examTaskDetail.getDrawCount();
|
|
int mod = seq % examTaskDetail.getDrawCount();
|
|
String tempPaperType = paperTypes[mod];
|
|
String tempPaperType = paperTypes[mod];
|
|
- BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
|
|
|
|
|
|
+ BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), basicCardRule);
|
|
|
|
|
|
if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
|
|
stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
|
|
@@ -352,9 +290,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
object.put("name", tempPaperType);
|
|
object.put("name", tempPaperType);
|
|
object.put("attachmentId", basicAttachment.getId());
|
|
object.put("attachmentId", basicAttachment.getId());
|
|
stuJsonArray.add(object);
|
|
stuJsonArray.add(object);
|
|
-
|
|
|
|
- // 用不带条码的模板
|
|
|
|
-// basicAttachmentList.add(basicAttachment);
|
|
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
@@ -362,8 +297,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
} else {
|
|
} else {
|
|
throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
|
|
}
|
|
}
|
|
- // 题卡
|
|
|
|
- createPdfDto.getCardPdfList().addAll(studentCardPdfList);
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONArray jsonArray = new JSONArray();
|
|
JSONArray jsonArray = new JSONArray();
|
|
@@ -396,4 +329,57 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 创建A4文件
|
|
|
|
+ *
|
|
|
|
+ * @param tbTaskPdf
|
|
|
|
+ * @param examDetailCourseList
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Transactional
|
|
|
|
+ public void createA4File(TBTaskPdf tbTaskPdf, List<ExamDetailCourse> examDetailCourseList) throws Exception {
|
|
|
|
+ CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
|
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
|
|
|
|
+ ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
|
|
|
|
+ BasicSchool basicSchool = commonCacheService.schoolCache(tbTaskPdf.getSchoolId());
|
|
|
|
+ // 印品
|
|
|
|
+ String ordinaryContent = examPrintPlan.getOrdinaryContent();
|
|
|
|
+ if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
|
|
|
|
+ //获取普通印品
|
|
|
|
+ JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
|
|
|
|
+ for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
|
|
|
|
+ JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
|
|
|
|
+ if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
|
|
|
|
+ Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
|
|
|
|
+ BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
|
|
|
|
+ createPdfNewUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
|
|
|
|
+ if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
|
|
|
|
+ String variableContent = examPrintPlan.getVariableContent();
|
|
|
|
+ if (StringUtils.isNotBlank(variableContent)) {
|
|
|
|
+ List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
|
+ List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
|
|
|
|
+ //获取变量印品
|
|
|
|
+ JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
|
|
|
|
+ for (int i = 0; i < jsonArrayVariable.size(); i++) {
|
|
|
|
+ JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
|
|
|
|
+ String type = (String) jsonObjectVariable.get("type");
|
|
|
|
+ if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
|
|
|
|
+ Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
|
|
|
|
+ if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
|
|
|
|
+ createPdfNewUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
|
|
|
|
+ } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
|
|
|
|
+ Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
|
|
|
|
+ createPdfNewUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ examDetailService.updateById(examDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|