|
@@ -508,7 +508,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
Set<Long> orgIds = commonService.listSubOrgIds(null);
|
|
|
Page<ExamTaskDto> page = new Page<>(pageNumber, pageSize);
|
|
|
- String[] strings = new String[]{ExamStatusEnum.NEW.name()};
|
|
|
+ String[] strings = new String[]{ExamStatusEnum.NEW.name(), ExamStatusEnum.FINISH.name()};
|
|
|
IPage<ExamTaskDto> examTaskDtoIPage = this.baseMapper.listTaskApply(page, schoolId, auditStatus, reviewStatus, cardRuleId, courseCode, paperNumber, startTime, endTime, strings, sysUser.getId(), orgIds);
|
|
|
return examTaskDtoIPage;
|
|
|
}
|
|
@@ -667,19 +667,34 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
if (!ExamCardStatusEnum.SUBMIT.name().equals(examCard.getStatus().name())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("请先提交题卡");
|
|
|
}
|
|
|
+
|
|
|
+ // 是否强制包含试卷
|
|
|
+ BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
|
|
|
+ if (basicExamRule.getIncludePaper()) {
|
|
|
+ if (StringUtils.isBlank(examTaskDetail.getPaperAttachmentIds())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("试卷文件未上传");
|
|
|
+ }
|
|
|
+ List<Map> paperAttachmentIds = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
|
|
|
+ long count = paperAttachmentIds.stream().filter(m -> StringUtils.isBlank(m.get("attachmentId").toString())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所有类型的试卷文件必须全部上传");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 更新examTask状态status
|
|
|
ExamTask examTask = this.getById(examTaskDetail.getExamTaskId());
|
|
|
- if (examTask.getStatus().name().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
|
|
|
+ if (examTaskDetail.getOperateType().equals(ExamStatusEnum.SUBMIT.name()) && !examTask.getReview()) {
|
|
|
examTask.setStatus(ExamStatusEnum.FINISH);
|
|
|
// 校验是否可以提交打印状态
|
|
|
commonService.checkData(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber(), (SysUser) ServletUtil.getRequestUser());
|
|
|
+ } else {
|
|
|
+ examTask.setStatus(ExamStatusEnum.valueOf(examTaskDetail.getOperateType()));
|
|
|
}
|
|
|
|
|
|
UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda()
|
|
|
- .set(ExamTask::getStatus, ExamStatusEnum.valueOf(examTaskDetail.getOperateType()))
|
|
|
+ .set(ExamTask::getStatus, examTask.getStatus())
|
|
|
.set(ExamTask::getUpdateId, sysUser.getId())
|
|
|
.set(ExamTask::getUpdateTime, System.currentTimeMillis())
|
|
|
.set(ExamTask::getReviewStatus, null)
|
|
@@ -778,17 +793,21 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
|
|
|
List<JSONObject> jsonObjectList = JSONObject.parseArray(paperAttachmentIds, JSONObject.class);
|
|
|
// 本地保存目录
|
|
|
- String rootPath = SystemConstant.DOWNLOAD_TEMP + File.separator + schoolId + File.separator + examTaskDetail.getId();
|
|
|
+ String rootPath = SystemConstant.TEMP_FILES_DIR + File.separator + schoolId + File.separator + examTaskDetail.getId();
|
|
|
List<File> fileList = new ArrayList<>();
|
|
|
// 试卷
|
|
|
for (JSONObject jsonObject : jsonObjectList) {
|
|
|
- Long id = jsonObject.getLongValue("attachmentId");
|
|
|
- BasicAttachment attachment = basicAttachmentService.getById(id);
|
|
|
- if (attachment == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("附件数据异常");
|
|
|
+ String id = jsonObject.get("attachmentId").toString();
|
|
|
+ String name = jsonObject.get("name").toString();
|
|
|
+ if (StringUtils.isNotBlank(id)) {
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(id);
|
|
|
+ if (attachment == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("附件数据异常");
|
|
|
+ }
|
|
|
+ String fileName = attachment.getName() + "-" + name + attachment.getType();
|
|
|
+ File file = commonService.copyFile(rootPath, fileName, attachment);
|
|
|
+ fileList.add(file);
|
|
|
}
|
|
|
- File file = commonService.copyFile(rootPath, attachment);
|
|
|
- fileList.add(file);
|
|
|
}
|
|
|
|
|
|
// 题卡
|
|
@@ -796,24 +815,25 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
if (cardId != null) {
|
|
|
ExamCard examCard = examCardService.getById(cardId);
|
|
|
// 通用模板
|
|
|
- if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())){
|
|
|
- if(examCard.getTemplateId() != null){
|
|
|
+ if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
|
|
|
+ if (examCard.getTemplateId() != null) {
|
|
|
BasicTemplate basicTemplate = basicTemplateService.getById(examCard.getTemplateId());
|
|
|
- if(basicTemplate == null){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡文件异常");
|
|
|
+ if (basicTemplate == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡文件异常");
|
|
|
}
|
|
|
BasicAttachment attachment = basicAttachmentService.getById(basicTemplate.getAttachmentId());
|
|
|
- File file = commonService.copyFile(rootPath, attachment);
|
|
|
+ String fileName = attachment.getName() + attachment.getType();
|
|
|
+ File file = commonService.copyFile(rootPath, fileName, attachment);
|
|
|
fileList.add(file);
|
|
|
}
|
|
|
}
|
|
|
// 自制题卡或者客服制卡
|
|
|
else {
|
|
|
ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
|
|
|
- if(StringUtils.isBlank(examCardDetail.getHtmlContent())){
|
|
|
+ if (StringUtils.isBlank(examCardDetail.getHtmlContent())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡内容有误");
|
|
|
}
|
|
|
- File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle()+".html", examCardDetail.getHtmlContent());
|
|
|
+ File file = basicAttachmentService.saveAttachmentHtml(rootPath, examCard.getTitle() + ".html", examCardDetail.getHtmlContent());
|
|
|
fileList.add(file);
|
|
|
}
|
|
|
}
|