|
@@ -2,14 +2,26 @@ package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.distributed.print.business.bean.params.ExamCardParams;
|
|
import com.qmth.distributed.print.business.bean.result.WorkResult;
|
|
import com.qmth.distributed.print.business.bean.result.WorkResult;
|
|
-import com.qmth.distributed.print.business.entity.ExamCard;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
|
+import com.qmth.distributed.print.business.enums.MakeMethodEnum;
|
|
import com.qmth.distributed.print.business.mapper.ExamCardMapper;
|
|
import com.qmth.distributed.print.business.mapper.ExamCardMapper;
|
|
|
|
+import com.qmth.distributed.print.business.service.BasicExamRuleService;
|
|
|
|
+import com.qmth.distributed.print.business.service.ExamCardDetailService;
|
|
import com.qmth.distributed.print.business.service.ExamCardService;
|
|
import com.qmth.distributed.print.business.service.ExamCardService;
|
|
|
|
+import com.qmth.distributed.print.business.service.ExamTaskDetailService;
|
|
|
|
+import com.qmth.distributed.print.business.util.ServletUtil;
|
|
|
|
+import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -27,6 +39,15 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
@Resource
|
|
@Resource
|
|
ExamCardMapper examCardMapper;
|
|
ExamCardMapper examCardMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private BasicExamRuleService basicExamRuleService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamCardDetailService examCardDetailService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamTaskDetailService examTaskDetailService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询我的工作台
|
|
* 查询我的工作台
|
|
*
|
|
*
|
|
@@ -54,4 +75,129 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
public IPage<WorkResult> queryByMyWorkSubmit(IPage<Map> iPage, Long userId, Long schoolId, ExamStatusEnum status) {
|
|
public IPage<WorkResult> queryByMyWorkSubmit(IPage<Map> iPage, Long userId, Long schoolId, ExamStatusEnum status) {
|
|
return examCardMapper.queryByMyWorkSubmit(iPage, userId, schoolId, Objects.nonNull(status) ? status.name() : null);
|
|
return examCardMapper.queryByMyWorkSubmit(iPage, userId, schoolId, Objects.nonNull(status) ? status.name() : null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public String saveExamCard(ExamCardParams examCardParams) {
|
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
+ SysUser user = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+
|
|
|
|
+ validateCardData(examCardParams, schoolId);
|
|
|
|
+
|
|
|
|
+ // 新增
|
|
|
|
+ ExamCard examCard = null;
|
|
|
|
+ ExamCardDetail examCardDetail = null;
|
|
|
|
+ if (examCardParams.getId() == null) {
|
|
|
|
+ examCard = new ExamCard();
|
|
|
|
+ examCard.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examCard.setSchoolId(schoolId);
|
|
|
|
+ examCard.setCourseCode(examCardParams.getCourseCode());
|
|
|
|
+ examCard.setCourseName(examCardParams.getCourseName());
|
|
|
|
+ examCard.setTitle(examCardParams.getTitle());
|
|
|
|
+ examCard.setMakeMethod(examCardParams.getMakeMethod());
|
|
|
|
+ examCard.setStatus(examCardParams.getStatus());
|
|
|
|
+ examCard.setCreateId(user.getId());
|
|
|
|
+ examCard.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ this.save(examCard);
|
|
|
|
+
|
|
|
|
+ examCardDetail = new ExamCardDetail();
|
|
|
|
+ examCardDetail.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examCardDetail.setCardId(examCard.getId());
|
|
|
|
+ examCardDetail.setContent(examCardParams.getContent());
|
|
|
|
+ examCardDetail.setHtmlContent(examCardParams.getHtmlContent());
|
|
|
|
+ examCardDetail.setAttachmentId(examCardParams.getAttachmentId());
|
|
|
|
+ examCardDetail.setCreateId(user.getId());
|
|
|
|
+ examCardDetail.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ examCardDetailService.save(examCardDetail);
|
|
|
|
+ }
|
|
|
|
+ // 修改
|
|
|
|
+ else {
|
|
|
|
+ examCard = this.getById(examCardParams.getId());
|
|
|
|
+ examCard.setTitle(examCardParams.getTitle());
|
|
|
|
+ if (!examCardParams.getCourseCode().equals(examCard.getCourseCode())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程不能更改");
|
|
|
|
+ }
|
|
|
|
+ if (!examCardParams.getMakeMethod().name().equals(examCard.getMakeMethod().name())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡制作方式不能更改");
|
|
|
|
+ }
|
|
|
|
+ examCard.setUpdateId(user.getId());
|
|
|
|
+ examCard.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ this.updateById(examCard);
|
|
|
|
+
|
|
|
|
+ examCardDetail = examCardDetailService.getByCardId(examCardParams.getId());
|
|
|
|
+ if (examCardDetail == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡数据有误");
|
|
|
|
+ }
|
|
|
|
+ examCardDetail.setContent(examCardParams.getContent());
|
|
|
|
+ examCardDetail.setHtmlContent(examCardParams.getHtmlContent());
|
|
|
|
+ examCardDetail.setAttachmentId(examCardParams.getAttachmentId());
|
|
|
|
+ examCardDetail.setUpdateId(user.getId());
|
|
|
|
+ examCardDetail.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ examCardDetailService.updateById(examCardDetail);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 绑定命题任务
|
|
|
|
+ examTaskDetailService.bindCardId(examCardParams.getExamTaskId(), examCard.getId());
|
|
|
|
+ return String.valueOf(examCard.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 数据验证
|
|
|
|
+ *
|
|
|
|
+ * @param examCardParams
|
|
|
|
+ */
|
|
|
|
+ private void validateCardData(ExamCardParams examCardParams, Long schoolId) {
|
|
|
|
+ BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId(schoolId);
|
|
|
|
+ if (basicExamRule == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(examCardParams.getMakeMethod().name())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡制作方式不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (!basicExamRule.getCustomCard() && MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未启用客服制卡,不能选择该方式制作题卡");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(examCardParams.getStatus())) {
|
|
|
|
+ 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不能为空");
|
|
|
|
+ }
|
|
|
|
+ // 当前选择题卡是否已绑定
|
|
|
|
+ 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 ("SUBMIT".equals(examCardParams.getStatus())) {
|
|
|
|
+ if (StringUtils.isBlank(examCardParams.getHtmlContent())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("提交题卡时,html内容不能为空");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (MakeMethodEnum.CUST.name().equals(examCardParams.getMakeMethod().name())) {
|
|
|
|
+ if (StringUtils.isBlank(examCardParams.getAttachmentId())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("客户制卡时,附件未上传");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|