|
@@ -1,6 +1,7 @@
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -975,39 +976,47 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
}
|
|
}
|
|
|
|
|
|
// 题卡
|
|
// 题卡
|
|
- Long cardId = examTaskDetail.getCardId();
|
|
|
|
- if (cardId != null) {
|
|
|
|
- ExamCard examCard = examCardService.getById(cardId);
|
|
|
|
-
|
|
|
|
- String cardPath = rootPath + File.separator + examTask.getPaperNumber();
|
|
|
|
- String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
|
|
|
|
- String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
|
|
|
|
-
|
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
|
|
|
|
- String htmlContent;
|
|
|
|
- // 通用模板
|
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
|
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
|
- } else {
|
|
|
|
- BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
|
- }
|
|
|
|
|
|
+// Long cardId = examTaskDetail.getCardId();
|
|
|
|
+ if (Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
|
+ JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
|
|
|
|
+ String cardId = null;
|
|
|
|
+ for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
+ JSONObject object = jsonArrayPaper.getJSONObject(i);
|
|
|
|
+ cardId = (String) object.get("cardId");
|
|
|
|
+ }
|
|
|
|
+ if (cardId != null) {
|
|
|
|
+ ExamCard examCard = examCardService.getById(cardId);
|
|
|
|
+
|
|
|
|
+ String cardPath = rootPath + File.separator + examTask.getPaperNumber();
|
|
|
|
+ String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
|
|
|
|
+ String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
|
|
|
|
+
|
|
|
|
+ ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
|
|
|
|
+ String htmlContent;
|
|
|
|
+ // 通用模板
|
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
|
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
|
+ } else {
|
|
|
|
+ BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
|
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
|
+ }
|
|
|
|
|
|
- // html
|
|
|
|
- File htmlFile = new File(cardHtmlPath);
|
|
|
|
- if (!htmlFile.getParentFile().exists()) {
|
|
|
|
- htmlFile.getParentFile().mkdirs();
|
|
|
|
- }
|
|
|
|
- // 生成html文件
|
|
|
|
- FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
|
|
|
|
- fileList.add(htmlFile);
|
|
|
|
- // 转pdf文件
|
|
|
|
- File pdfFile = new File(cardPdfPath);
|
|
|
|
- if (!pdfFile.exists()) {
|
|
|
|
- pdfFile.createNewFile();
|
|
|
|
|
|
+ // html
|
|
|
|
+ File htmlFile = new File(cardHtmlPath);
|
|
|
|
+ if (!htmlFile.getParentFile().exists()) {
|
|
|
|
+ htmlFile.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ // 生成html文件
|
|
|
|
+ FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
|
|
|
|
+ fileList.add(htmlFile);
|
|
|
|
+ // 转pdf文件
|
|
|
|
+ File pdfFile = new File(cardPdfPath);
|
|
|
|
+ if (!pdfFile.exists()) {
|
|
|
|
+ pdfFile.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
|
|
+ fileList.add(pdfFile);
|
|
}
|
|
}
|
|
- HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
|
|
- fileList.add(pdfFile);
|
|
|
|
}
|
|
}
|
|
if (fileList.size() == 0) {
|
|
if (fileList.size() == 0) {
|
|
throw ExceptionResultEnum.ERROR.exception("没有可导出文件");
|
|
throw ExceptionResultEnum.ERROR.exception("没有可导出文件");
|
|
@@ -1255,29 +1264,41 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
if (StringUtils.isNotBlank(examTaskDetail.getExposedPaperType())) {
|
|
if (StringUtils.isNotBlank(examTaskDetail.getExposedPaperType())) {
|
|
throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能切换题卡");
|
|
throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能切换题卡");
|
|
}
|
|
}
|
|
- if (Objects.nonNull(examTaskDetail.getCardId())) {
|
|
|
|
- ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
|
|
|
|
- if (examCard == null) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡不存在");
|
|
|
|
- }
|
|
|
|
- if (MakeMethodEnum.CUST.equals(examCard.getMakeMethod())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("客服制卡方式,不能切换");
|
|
|
|
- }
|
|
|
|
|
|
+ QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
|
|
|
|
+ List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
|
|
|
|
+ if (!CollectionUtils.isEmpty(examTaskDetailList)) {
|
|
|
|
+ for (ExamTaskDetail e : examTaskDetailList) {
|
|
|
|
+ if (Objects.nonNull(e.getPaperAttachmentIds())) {
|
|
|
|
+ JSONArray jsonArrayPaper = JSONArray.parseArray(e.getPaperAttachmentIds());
|
|
|
|
+ for (int i = 0; i < jsonArrayPaper.size(); i++) {
|
|
|
|
+ JSONObject object = jsonArrayPaper.getJSONObject(i);
|
|
|
|
+ ExamCard examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
|
|
|
|
+ if (examCard == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡不存在");
|
|
|
|
+ }
|
|
|
|
+ if (MakeMethodEnum.CUST.equals(examCard.getMakeMethod())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("客服制卡方式,不能切换");
|
|
|
|
+ }
|
|
|
|
|
|
- // 删除自建题卡
|
|
|
|
- if (!MakeMethodEnum.SELECT.name().equals(examTaskDetail.getMakeMethod())) {
|
|
|
|
- UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
|
- updateWrapper.lambda().eq(ExamCardDetail::getCardId, examTaskDetail.getCardId());
|
|
|
|
- examCardDetailService.remove(updateWrapper);
|
|
|
|
|
|
+ // 删除自建题卡
|
|
|
|
+ if (!MakeMethodEnum.SELECT.name().equals(examTaskDetail.getMakeMethod())) {
|
|
|
|
+ UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
|
|
|
|
+ examCardDetailService.remove(updateWrapper);
|
|
|
|
+ examCardService.removeById(examCard.getId());
|
|
|
|
+ }
|
|
|
|
|
|
- examCardService.removeById(examTaskDetail.getCardId());
|
|
|
|
|
|
+// UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+// examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getCardId, null)
|
|
|
|
+// .set(ExamTaskDetail::getMakeMethod, null)
|
|
|
|
+// .eq(ExamTaskDetail::getId, examTaskDetail.getId());
|
|
|
|
+ object.put("cardId", null);
|
|
|
|
+ e.setMakeMethod(null);
|
|
|
|
+ examTaskDetailService.updateById(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
- examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getCardId, null)
|
|
|
|
- .set(ExamTaskDetail::getMakeMethod, null)
|
|
|
|
- .eq(ExamTaskDetail::getId, examTaskDetail.getId());
|
|
|
|
- examTaskDetailService.update(examTaskDetailUpdateWrapper);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1606,7 +1627,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
|
|
|
// 更新实际考生数量
|
|
// 更新实际考生数量
|
|
List<ExamTaskStudentObjectParam> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamList();
|
|
List<ExamTaskStudentObjectParam> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamList();
|
|
- List<ExamStudent> examStudents = printCommonService.createBatchStudentByStudentList(schoolId,examDetailList.getExtendFields(),examTaskStudentObjectParamList,examDetailCourse.getId(),sysUser);
|
|
|
|
|
|
+ List<ExamStudent> examStudents = printCommonService.createBatchStudentByStudentList(schoolId, examDetailList.getExtendFields(), examTaskStudentObjectParamList, examDetailCourse.getId(), sysUser);
|
|
if (!CollectionUtils.isEmpty(examStudents)) {
|
|
if (!CollectionUtils.isEmpty(examStudents)) {
|
|
examStudentService.insertBatch(examStudents);
|
|
examStudentService.insertBatch(examStudents);
|
|
}
|
|
}
|
|
@@ -1706,12 +1727,12 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
// 查询教研室所在学院
|
|
// 查询教研室所在学院
|
|
List<SysOrg> orgList = sysOrgService.findParentsByOrgId(teachingRoom.getId());
|
|
List<SysOrg> orgList = sysOrgService.findParentsByOrgId(teachingRoom.getId());
|
|
List<SysOrg> schoolOrgList = orgList.stream().filter(e -> OrgTypeEnum.SCHOOL.equals(e.getType())).collect(Collectors.toList());
|
|
List<SysOrg> schoolOrgList = orgList.stream().filter(e -> OrgTypeEnum.SCHOOL.equals(e.getType())).collect(Collectors.toList());
|
|
- if (schoolOrgList.size() != 1){
|
|
|
|
|
|
+ if (schoolOrgList.size() != 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("学校级机构信息异常");
|
|
throw ExceptionResultEnum.ERROR.exception("学校级机构信息异常");
|
|
}
|
|
}
|
|
SysOrg schoolOrg = schoolOrgList.get(0);
|
|
SysOrg schoolOrg = schoolOrgList.get(0);
|
|
List<SysOrg> collegeList = orgList.stream().filter(e -> Objects.equals(schoolOrg.getId(), e.getParentId())).collect(Collectors.toList());
|
|
List<SysOrg> collegeList = orgList.stream().filter(e -> Objects.equals(schoolOrg.getId(), e.getParentId())).collect(Collectors.toList());
|
|
- if (collegeList.size() != 1){
|
|
|
|
|
|
+ if (collegeList.size() != 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("学院级机构信息异常");
|
|
throw ExceptionResultEnum.ERROR.exception("学院级机构信息异常");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1846,13 +1867,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
List<ExamTaskStudentObjectResult> result = new ArrayList<>();
|
|
List<ExamTaskStudentObjectResult> result = new ArrayList<>();
|
|
switch (examObjectType) {
|
|
switch (examObjectType) {
|
|
case TEACH_CLAZZ_STUDENT:
|
|
case TEACH_CLAZZ_STUDENT:
|
|
- TeachCourse teachCourse = teachCourseService.getOne(new QueryWrapper<TeachCourse>().lambda().eq(TeachCourse::getSchoolId,schoolId).eq(TeachCourse::getBasicCourseId,basicCourseId));
|
|
|
|
- if (Objects.isNull(teachCourse)){
|
|
|
|
|
|
+ TeachCourse teachCourse = teachCourseService.getOne(new QueryWrapper<TeachCourse>().lambda().eq(TeachCourse::getSchoolId, schoolId).eq(TeachCourse::getBasicCourseId, basicCourseId));
|
|
|
|
+ if (Objects.isNull(teachCourse)) {
|
|
throw ExceptionResultEnum.ERROR.exception("未找到教学课程");
|
|
throw ExceptionResultEnum.ERROR.exception("未找到教学课程");
|
|
}
|
|
}
|
|
|
|
|
|
// 教学班对象
|
|
// 教学班对象
|
|
- List<TeachStudent> teachStudentDatasource = teachStudentService.list(new QueryWrapper<TeachStudent>().lambda().eq(TeachStudent::getSchoolId, schoolId).eq(TeachStudent::getUserId, userId).eq(TeachStudent::getTeachCourseId,teachCourse.getId()));
|
|
|
|
|
|
+ List<TeachStudent> teachStudentDatasource = teachStudentService.list(new QueryWrapper<TeachStudent>().lambda().eq(TeachStudent::getSchoolId, schoolId).eq(TeachStudent::getUserId, userId).eq(TeachStudent::getTeachCourseId, teachCourse.getId()));
|
|
|
|
|
|
// 教学班id集合
|
|
// 教学班id集合
|
|
List<Long> teachClazzIdList = teachStudentDatasource.stream().map(TeachStudent::getTeachClazzId).distinct().collect(Collectors.toList());
|
|
List<Long> teachClazzIdList = teachStudentDatasource.stream().map(TeachStudent::getTeachClazzId).distinct().collect(Collectors.toList());
|
|
@@ -1933,7 +1954,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
studentImportMap.put("inputStream", file.getInputStream());
|
|
studentImportMap.put("inputStream", file.getInputStream());
|
|
studentImportMap.put(SystemConstant.SYS_USER, requestUser);
|
|
studentImportMap.put(SystemConstant.SYS_USER, requestUser);
|
|
taskLogicService.executeImportBasicStudentLogic(studentImportMap);
|
|
taskLogicService.executeImportBasicStudentLogic(studentImportMap);
|
|
- List<String> studentCodeList = JSONObject.parseArray(JSON.toJSONString(studentImportMap.get("studentCodeList")),String.class);
|
|
|
|
|
|
+ List<String> studentCodeList = JSONObject.parseArray(JSON.toJSONString(studentImportMap.get("studentCodeList")), String.class);
|
|
|
|
|
|
// 导入的学生信息查询
|
|
// 导入的学生信息查询
|
|
List<BasicStudentResult> basicStudentResultDatasource = basicStudentService.basicStudentList(schoolId, null, null, null, studentCodeList);
|
|
List<BasicStudentResult> basicStudentResultDatasource = basicStudentService.basicStudentList(schoolId, null, null, null, studentCodeList);
|