|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -7,6 +8,8 @@ import com.qmth.distributed.print.business.bean.dto.CardCustDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.ExamCardParams;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
+import com.qmth.distributed.print.business.enums.CardStatusEnum;
|
|
|
+import com.qmth.distributed.print.business.enums.CardTypeEnum;
|
|
|
import com.qmth.distributed.print.business.enums.MakeMethodEnum;
|
|
|
import com.qmth.distributed.print.business.mapper.ExamCardMapper;
|
|
|
import com.qmth.distributed.print.business.service.BasicExamRuleService;
|
|
@@ -21,8 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -50,11 +56,11 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
SysUser user = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
|
|
- validateCardData(examCardParams, schoolId);
|
|
|
+ validateCardData(examCardParams);
|
|
|
|
|
|
// 新增
|
|
|
- ExamCard examCard = null;
|
|
|
- ExamCardDetail examCardDetail = null;
|
|
|
+ ExamCard examCard;
|
|
|
+ ExamCardDetail examCardDetail;
|
|
|
if (examCardParams.getId() == null) {
|
|
|
examCard = new ExamCard();
|
|
|
examCard.setId(SystemConstant.getDbUuid());
|
|
@@ -64,6 +70,8 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
examCard.setTitle(examCardParams.getTitle());
|
|
|
examCard.setMakeMethod(examCardParams.getMakeMethod());
|
|
|
examCard.setStatus(examCardParams.getStatus());
|
|
|
+ examCard.setType(examCardParams.getType());
|
|
|
+ examCard.setTemplateId(examCardParams.getTemplateId());
|
|
|
examCard.setCreateId(user.getId());
|
|
|
examCard.setCreateTime(System.currentTimeMillis());
|
|
|
this.save(examCard);
|
|
@@ -88,6 +96,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
if (!examCardParams.getMakeMethod().name().equals(examCard.getMakeMethod().name())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡制作方式不能更改");
|
|
|
}
|
|
|
+ examCard.setStatus(examCardParams.getStatus());
|
|
|
examCard.setUpdateId(user.getId());
|
|
|
examCard.setUpdateTime(System.currentTimeMillis());
|
|
|
this.updateById(examCard);
|
|
@@ -123,7 +132,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
SysUser user = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
|
|
- if(!MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())){
|
|
|
+ if (!MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡制作类型错误");
|
|
|
}
|
|
|
if (StringUtils.isBlank(examCardParams.getAttachmentId())) {
|
|
@@ -138,6 +147,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
examCard.setMakeMethod(examCardParams.getMakeMethod());
|
|
|
examCard.setTitle(examCardParams.getTitle());
|
|
|
examCard.setStatus(examCardParams.getStatus());
|
|
|
+ examCard.setType(CardTypeEnum.CUSTOM);
|
|
|
examCard.setCreateId(user.getId());
|
|
|
examCard.setCreateTime(System.currentTimeMillis());
|
|
|
this.save(examCard);
|
|
@@ -161,13 +171,48 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
return this.baseMapper.getCardDetail(cardId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ExamCard getOneByTemplateId(Long templateId) {
|
|
|
+ QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ExamCard::getTemplateId, templateId);
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean usedCardByTemplateId(Long templateId) {
|
|
|
+ List<ExamTaskDetail> list = examTaskDetailService.listByTemplateId(templateId);
|
|
|
+ return !list.isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamCard> listSelectCard(String courseCode, Long cardRuleId, String paperType) {
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+
|
|
|
+ // 通用题卡
|
|
|
+ List<ExamCard> list = new ArrayList<>();
|
|
|
+ List<ExamCard> genericCards = this.baseMapper.listGenericCard(schoolId, sysUser.getOrgId(), CardTypeEnum.GENERIC.name());
|
|
|
+ if (!genericCards.isEmpty()) {
|
|
|
+ list.addAll(genericCards);
|
|
|
+ }
|
|
|
+ // 专卡
|
|
|
+ if (SystemConstant.ALL_CARD != cardRuleId) {
|
|
|
+ List<ExamCard> customCards = this.baseMapper.listCustom(schoolId, sysUser.getOrgId(), courseCode, CardTypeEnum.CUSTOM.name());
|
|
|
+ if(!customCards.isEmpty()){
|
|
|
+ list.addAll(customCards);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Collections.sort(list, Comparator.comparing(ExamCard::getType));
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 数据验证
|
|
|
*
|
|
|
* @param examCardParams
|
|
|
*/
|
|
|
- private void validateCardData(ExamCardParams examCardParams, Long schoolId) {
|
|
|
+ private void validateCardData(ExamCardParams examCardParams) {
|
|
|
BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
|
|
|
if (basicExamRule == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
|
|
@@ -179,48 +224,49 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
if (!basicExamRule.getCustomCard() && MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("未启用客服制卡,不能选择该方式制作题卡");
|
|
|
}
|
|
|
- if (Objects.isNull(examCardParams.getStatus())) {
|
|
|
+ if (examCardParams.getStatus() == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("提交方式不能为空");
|
|
|
}
|
|
|
- if (examCardParams.getExamTaskId() == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务ID不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(examCardParams.getCourseCode())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程代码不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(examCardParams.getCourseName())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程名称不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- if (MakeMethodEnum.SELECT.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
- if (examCardParams.getId() == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("选择已有题卡时,题卡ID不能为空");
|
|
|
+ if (CardTypeEnum.CUSTOM.name().equals(examCardParams.getType())) {
|
|
|
+ if (examCardParams.getExamTaskId() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务ID不能为空");
|
|
|
}
|
|
|
- // 当前选择题卡是否已绑定
|
|
|
- List<ExamTaskDetail> list = examTaskDetailService.listByCardId(examCardParams.getId());
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("选择的题卡已被其它命题任务绑定");
|
|
|
+ if (StringUtils.isBlank(examCardParams.getCourseCode())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程代码不能为空");
|
|
|
}
|
|
|
-
|
|
|
- } else if (MakeMethodEnum.SELF.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
- if (StringUtils.isBlank(examCardParams.getTitle())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡标题不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(examCardParams.getContent())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡内容不能为空");
|
|
|
+ if (StringUtils.isBlank(examCardParams.getCourseName())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程名称不能为空");
|
|
|
}
|
|
|
- if ("SUBMIT".equals(examCardParams.getStatus())) {
|
|
|
- if (StringUtils.isBlank(examCardParams.getHtmlContent())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("提交题卡时,html内容不能为空");
|
|
|
+ if (MakeMethodEnum.SELECT.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
+ if (examCardParams.getId() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("选择已有题卡时,题卡ID不能为空");
|
|
|
}
|
|
|
- }
|
|
|
- } else if (MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
- if (StringUtils.isBlank(examCardParams.getContent())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡内容不能为空");
|
|
|
- }
|
|
|
- if ("SUBMIT".equals(examCardParams.getStatus())) {
|
|
|
- if (StringUtils.isBlank(examCardParams.getHtmlContent())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("提交题卡时,html内容不能为空");
|
|
|
+ // 当前选择题卡是否已绑定
|
|
|
+ List<ExamTaskDetail> list = examTaskDetailService.listByCardId(examCardParams.getId());
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("选择的题卡已被其它命题任务绑定");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (MakeMethodEnum.SELF.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
+ if (StringUtils.isBlank(examCardParams.getTitle())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡标题不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(examCardParams.getContent())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡内容不能为空");
|
|
|
+ }
|
|
|
+ if (CardStatusEnum.SUBMIT.name().equals(examCardParams.getStatus().name())) {
|
|
|
+ if (StringUtils.isBlank(examCardParams.getHtmlContent())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("提交题卡时,html内容不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
+ if (StringUtils.isBlank(examCardParams.getContent())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡内容不能为空");
|
|
|
+ }
|
|
|
+ if (CardStatusEnum.SUBMIT.name().equals(examCardParams.getStatus().name())) {
|
|
|
+ if (StringUtils.isBlank(examCardParams.getHtmlContent())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("提交题卡时,html内容不能为空");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|