|
@@ -4,21 +4,24 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.qmth.distributed.print.business.bean.dto.BasicPrintConfigDto;
|
|
|
|
import com.qmth.distributed.print.business.bean.dto.CardCustDto;
|
|
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.dto.CardDetailDto;
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamCardDto;
|
|
import com.qmth.distributed.print.business.bean.dto.SyncExamCardDto;
|
|
import com.qmth.distributed.print.business.bean.params.ExamCardParams;
|
|
import com.qmth.distributed.print.business.bean.params.ExamCardParams;
|
|
|
|
+import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.enums.CardStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.CardStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.CardTypeEnum;
|
|
import com.qmth.distributed.print.business.enums.CardTypeEnum;
|
|
import com.qmth.distributed.print.business.enums.MakeMethodEnum;
|
|
import com.qmth.distributed.print.business.enums.MakeMethodEnum;
|
|
|
|
+import com.qmth.distributed.print.business.enums.TemplateTypeEnum;
|
|
import com.qmth.distributed.print.business.mapper.ExamCardMapper;
|
|
import com.qmth.distributed.print.business.mapper.ExamCardMapper;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.bean.params.ArraysParams;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
import com.qmth.teachcloud.common.entity.BasicAttachment;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
|
+import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
import com.qmth.teachcloud.common.service.BasicAttachmentService;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
@@ -28,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -66,6 +70,9 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
@Autowired
|
|
@Autowired
|
|
BasicCourseService basicCourseService;
|
|
BasicCourseService basicCourseService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ BasicTemplateOrgService basicTemplateOrgService;
|
|
|
|
+
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public String saveExamCard(ExamCardParams examCardParams) {
|
|
public String saveExamCard(ExamCardParams examCardParams) {
|
|
@@ -83,7 +90,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
if (examCardParams.getId() == null) {
|
|
if (examCardParams.getId() == null) {
|
|
examCard = new ExamCard();
|
|
examCard = new ExamCard();
|
|
examCard.setSchoolId(schoolId);
|
|
examCard.setSchoolId(schoolId);
|
|
- if(Objects.isNull(examCardParams.getTemplateId())) {
|
|
|
|
|
|
+ if (Objects.isNull(examCardParams.getTemplateId())) {
|
|
examCard.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examCardParams.getCourseCode()));
|
|
examCard.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examCardParams.getCourseCode()));
|
|
} else {
|
|
} else {
|
|
examCard.setOrgId(user.getOrgId());
|
|
examCard.setOrgId(user.getOrgId());
|
|
@@ -94,7 +101,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
examCard.setMakeMethod(examCardParams.getMakeMethod());
|
|
examCard.setMakeMethod(examCardParams.getMakeMethod());
|
|
examCard.setStatus(examCardParams.getStatus());
|
|
examCard.setStatus(examCardParams.getStatus());
|
|
examCard.setType(examCardParams.getType());
|
|
examCard.setType(examCardParams.getType());
|
|
- examCard.setTemplateId(examCardParams.getTemplateId());
|
|
|
|
|
|
+ examCard.setAttachmentId(Long.valueOf(examCardParams.getAttachmentId()));
|
|
examCard.insertInfo(user.getId());
|
|
examCard.insertInfo(user.getId());
|
|
this.save(examCard);
|
|
this.save(examCard);
|
|
|
|
|
|
@@ -199,7 +206,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
@Override
|
|
@Override
|
|
public ExamCard getOneByTemplateId(Long templateId) {
|
|
public ExamCard getOneByTemplateId(Long templateId) {
|
|
QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
|
|
- queryWrapper.lambda().eq(ExamCard::getTemplateId, templateId);
|
|
|
|
|
|
+ queryWrapper.lambda().eq(ExamCard::getAttachmentId, templateId);
|
|
return this.getOne(queryWrapper);
|
|
return this.getOne(queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -263,12 +270,154 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
return this.baseMapper.listSyncCardByCourseCodeAndPaperNumber(schoolId, courseCode, paperNumber);
|
|
return this.baseMapper.listSyncCardByCourseCodeAndPaperNumber(schoolId, courseCode, paperNumber);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public IPage<ExamCard> listPage(Boolean enable, Long createStartTime, Long createEndTime, String courseCode, String type, Integer pageNumber, Integer pageSize) {
|
|
|
|
|
|
+ public IPage<ExamCard> listPage(String type, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Page<ExamCard> page = new Page<>(pageNumber, pageSize);
|
|
Page<ExamCard> page = new Page<>(pageNumber, pageSize);
|
|
- IPage<ExamCard> examCardIPage = this.baseMapper.listPage(page, schoolId, enable, createStartTime, createEndTime, courseCode, type);
|
|
|
|
- return null;
|
|
|
|
|
|
+ IPage<ExamCard> iPage = this.baseMapper.listPage(page, schoolId, type, title, createMethod, enable, createStartTime, createEndTime);
|
|
|
|
+
|
|
|
|
+ if (iPage.getRecords().size() > 0) {
|
|
|
|
+ iPage.getRecords().forEach(m -> {
|
|
|
|
+ //查询适用学院
|
|
|
|
+ List<SysOrg> sysOrgs = basicTemplateOrgService.listByTypeAndTemplateId(type, Long.valueOf(m.getId()));
|
|
|
|
+ m.setOrgs(sysOrgs);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return iPage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public Long saveGeneric(GenericExamCardParams params) {
|
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+
|
|
|
|
+ QueryWrapper<ExamCard> checkTitleQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ checkTitleQueryWrapper.lambda().eq(ExamCard::getSchoolId, schoolId).eq(ExamCard::getType, CardTypeEnum.GENERIC).eq(ExamCard::getTitle, params.getTitle().trim());
|
|
|
|
+ ExamCard checkTitleExamCardList = this.getOne(checkTitleQueryWrapper);
|
|
|
|
+
|
|
|
|
+ ExamCard examCard = new ExamCard();
|
|
|
|
+ ExamCardDetail examCardDetail = new ExamCardDetail();
|
|
|
|
+ // 新增
|
|
|
|
+ if (Objects.isNull(params.getId())) {
|
|
|
|
+ // 保存题卡
|
|
|
|
+ examCard.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examCard.setSchoolId(schoolId);
|
|
|
|
+ examCard.setOrgId(sysUser.getOrgId());
|
|
|
|
+
|
|
|
|
+ if (checkTitleExamCardList != null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡名称重复");
|
|
|
|
+ }
|
|
|
|
+ examCard.setTitle(params.getTitle());
|
|
|
|
+ examCard.setMakeMethod(MakeMethodEnum.SELECT); // 默认值
|
|
|
|
+// examCard.setStatus(CardStatusEnum.SUBMIT); // 默认值
|
|
|
|
+ examCard.setStatus(CardStatusEnum.valueOf(params.getStatus()));
|
|
|
|
+ examCard.setType(CardTypeEnum.GENERIC); // 默认值
|
|
|
|
+ examCard.setCreateMethod(params.getCreateMethod());
|
|
|
|
+ examCard.setAttachmentId(params.getAttachmentId());
|
|
|
|
+ examCard.setEnable(true); // 默认值
|
|
|
|
+ examCard.setCardRuleId(params.getCardRuleId());
|
|
|
|
+ examCard.setRemark(params.getRemark());
|
|
|
|
+ examCard.setCreateId(sysUser.getId());
|
|
|
|
+ examCard.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ this.save(examCard);
|
|
|
|
+
|
|
|
|
+ // 保存题卡内容
|
|
|
|
+ examCardDetail.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examCardDetail.setCardId(examCard.getId());
|
|
|
|
+ examCardDetail.setCreateId(sysUser.getId());
|
|
|
|
+ examCardDetail.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ // 方式为上传
|
|
|
|
+ if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
|
|
|
|
+ if (params.getAttachmentId() == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请上传模板文件");
|
|
|
|
+ }
|
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(params.getAttachmentId());
|
|
|
|
+ if (attachment == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("无模板文件记录");
|
|
|
|
+ }
|
|
|
|
+ if (!".html".equalsIgnoreCase(attachment.getType())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
|
|
|
|
+ }
|
|
|
|
+ examCardDetail.setHtmlContent(teachcloudCommonService.readFileContent(attachment.getPath()));
|
|
|
|
+ }
|
|
|
|
+ // 方式为自定义
|
|
|
|
+ else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod()) || CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
|
|
|
|
+ examCardDetail.setContent(params.getContent());
|
|
|
|
+ examCardDetail.setHtmlContent(params.getHtmlContent());
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡创建方式异常");
|
|
|
|
+ }
|
|
|
|
+ examCardDetailService.save(examCardDetail);
|
|
|
|
+ }
|
|
|
|
+ // 修改
|
|
|
|
+ else {
|
|
|
|
+ examCard = this.getById(params.getId());
|
|
|
|
+ if (checkTitleExamCardList != null && !Objects.equals(params.getId(), examCard.getId())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡名称重复");
|
|
|
|
+ }
|
|
|
|
+ examCard.setTitle(params.getTitle());
|
|
|
|
+ examCard.setAttachmentId(params.getAttachmentId());
|
|
|
|
+ examCard.setCardRuleId(params.getCardRuleId());
|
|
|
|
+ examCard.setStatus(CardStatusEnum.valueOf(params.getStatus()));
|
|
|
|
+ examCard.setRemark(params.getRemark());
|
|
|
|
+ examCard.setUpdateId(sysUser.getId());
|
|
|
|
+ examCard.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ this.updateById(examCard);
|
|
|
|
+
|
|
|
|
+ examCardDetail = examCardDetailService.getByCardId(params.getId());
|
|
|
|
+ examCardDetail.setUpdateId(sysUser.getId());
|
|
|
|
+ examCardDetail.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ // 方式为上传
|
|
|
|
+ if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
|
|
|
|
+ if (params.getAttachmentId() == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请上传模板文件");
|
|
|
|
+ }
|
|
|
|
+ BasicAttachment attachment = basicAttachmentService.getById(params.getAttachmentId());
|
|
|
|
+ if (attachment == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("无模板文件记录");
|
|
|
|
+ }
|
|
|
|
+ if (!".html".equalsIgnoreCase(attachment.getType())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
|
|
|
|
+ }
|
|
|
|
+ examCardDetail.setHtmlContent(teachcloudCommonService.readFileContent(attachment.getPath()));
|
|
|
|
+ }
|
|
|
|
+ // 方式为自定义
|
|
|
|
+ else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod()) || CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
|
|
|
|
+ examCardDetail.setContent(params.getContent());
|
|
|
|
+ examCardDetail.setHtmlContent(params.getHtmlContent());
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡创建方式异常");
|
|
|
|
+ }
|
|
|
|
+ examCardDetailService.updateById(examCardDetail);
|
|
|
|
+
|
|
|
|
+ //删除权限
|
|
|
|
+ basicTemplateOrgService.removeByRuleId(examCard.getId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保存适用范围
|
|
|
|
+ if (params.getOrgIds() == null || params.getOrgIds().length == 0) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择适用范围");
|
|
|
|
+ }
|
|
|
|
+ basicTemplateOrgService.saveBatch(schoolId, TemplateTypeEnum.GENERIC, examCard.getId(), params.getOrgIds(), examCard.getCreateId());
|
|
|
|
+ return examCard.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean deleteGeneric(Long id) {
|
|
|
|
+ // 校验题卡是否被绑定
|
|
|
|
+ QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.lambda().eq(ExamTaskDetail::getCardId, id);
|
|
|
|
+ ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(queryWrapper);
|
|
|
|
+ if(examTaskDetail != null){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡已绑定命题任务,不能删除");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ examCardDetailService.removeByCardId(id);
|
|
|
|
+ return this.removeById(id);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|