|
@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
|
|
|
-import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
|
|
|
import com.qmth.distributed.print.business.bean.marking.ConvertJpgStorage;
|
|
|
import com.qmth.distributed.print.business.bean.params.ExamCardParams;
|
|
|
import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
|
|
@@ -65,9 +63,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
@Resource
|
|
|
private BasicCardRuleService basicCardRuleService;
|
|
|
|
|
|
- @Resource
|
|
|
- private ExamCardDetailService examCardDetailService;
|
|
|
-
|
|
|
@Resource
|
|
|
private ExamTaskDetailService examTaskDetailService;
|
|
|
|
|
@@ -102,7 +97,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
|
|
|
// 新增
|
|
|
ExamCard examCard;
|
|
|
- ExamCardDetail examCardDetail;
|
|
|
if (examCardParams.getTitle().getBytes().length > 80) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("标题最长只能输入80个字符");
|
|
|
}
|
|
@@ -132,22 +126,15 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
examCard.setAttachmentId(examCardParams.getAttachmentId());
|
|
|
examCard.setCardRuleId(examCardParams.getCardRuleId());
|
|
|
examCard.insertInfo(user.getId());
|
|
|
- this.save(examCard);
|
|
|
|
|
|
- examCardDetail = new ExamCardDetail();
|
|
|
- examCardDetail.setCardId(examCard.getId());
|
|
|
- examCardDetail.setContent(examCardParams.getContent());
|
|
|
+ examCard.setContent(examCardParams.getContent());
|
|
|
String htmlContent = examCardParams.getHtmlContent();
|
|
|
List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), htmlContent, PageSizeEnum.A3);
|
|
|
if (convertJpgStorageList.size() > 0) {
|
|
|
- examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
|
|
|
- }
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
- if (examCardParams.getAttachmentId() != null) {
|
|
|
- examCardDetail.setAttachmentId(String.valueOf(examCardParams.getAttachmentId()));
|
|
|
+ examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
|
|
|
}
|
|
|
- examCardDetail.insertInfo(user.getId());
|
|
|
- examCardDetailService.save(examCardDetail);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
+ this.save(examCard);
|
|
|
}
|
|
|
// 修改
|
|
|
else {
|
|
@@ -166,39 +153,19 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
examCard.setStatus(examCardParams.getStatus());
|
|
|
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());
|
|
|
+ examCard.setContent(examCardParams.getContent());
|
|
|
String htmlContent = examCardParams.getHtmlContent();
|
|
|
List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), htmlContent, PageSizeEnum.A3);
|
|
|
if (convertJpgStorageList.size() > 0) {
|
|
|
- examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
|
|
|
- }
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
- if (examCardParams.getAttachmentId() != null) {
|
|
|
- examCardDetail.setAttachmentId(String.valueOf(examCardParams.getAttachmentId()));
|
|
|
+ examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
|
|
|
}
|
|
|
- examCardDetail.updateInfo(user.getId());
|
|
|
- examCardDetailService.updateById(examCardDetail);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
+ this.updateById(examCard);
|
|
|
}
|
|
|
|
|
|
return String.valueOf(examCard.getId());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public CardDetailDto getCardDetail(Long cardId) {
|
|
|
- ExamCard examCard = this.getById(cardId);
|
|
|
- if (!MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
|
|
|
- return this.baseMapper.getCardDetail(cardId);
|
|
|
- } else {
|
|
|
- return this.baseMapper.getCardDetailBySelect(cardId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public List<ExamCard> listSelectCard(String courseCode, Long cardRuleId, String paperNumber) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
@@ -234,14 +201,14 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<ExamCardPageDto> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
|
|
|
+ public IPage<ExamCard> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
|
|
|
- IPage<ExamCardPageDto> cardPageDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, cardType, title, createMethod, enable, createStartTime, createEndTime, dpr);
|
|
|
- for (ExamCardPageDto record : cardPageDtoIPage.getRecords()) {
|
|
|
- if (StringUtils.isNotBlank(record.getJpgAttachmentInfo())) {
|
|
|
- List<JSONObject> mapList = JSON.parseArray(record.getJpgAttachmentInfo(), JSONObject.class);
|
|
|
+ IPage<ExamCard> cardPageDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, cardType, title, createMethod, enable, createStartTime, createEndTime, dpr);
|
|
|
+ for (ExamCard record : cardPageDtoIPage.getRecords()) {
|
|
|
+ if (StringUtils.isNotBlank(record.getJpgAttachment())) {
|
|
|
+ List<JSONObject> mapList = JSON.parseArray(record.getJpgAttachment(), JSONObject.class);
|
|
|
List<String> imageUrls = new ArrayList<>();
|
|
|
// 组装图片访问url
|
|
|
for (JSONObject object : mapList) {
|
|
@@ -266,7 +233,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
ExamCard checkTitleExamCardList = this.getOne(checkTitleQueryWrapper);
|
|
|
|
|
|
ExamCard examCard = new ExamCard();
|
|
|
- ExamCardDetail examCardDetail = new ExamCardDetail();
|
|
|
// 新增
|
|
|
if (Objects.isNull(params.getId())) {
|
|
|
if (checkTitleExamCardList != null) {
|
|
@@ -291,11 +257,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
examCard.setCreateTime(System.currentTimeMillis());
|
|
|
this.save(examCard);
|
|
|
|
|
|
- // 保存题卡内容
|
|
|
- examCardDetail.setId(SystemConstant.getDbUuid());
|
|
|
- examCardDetail.setCardId(examCard.getId());
|
|
|
- examCardDetail.setCreateId(sysUser.getId());
|
|
|
- examCardDetail.setCreateTime(System.currentTimeMillis());
|
|
|
// 方式为上传
|
|
|
String htmlContent;
|
|
|
if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
|
|
@@ -310,19 +271,17 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
|
|
|
}
|
|
|
htmlContent = teachcloudCommonService.readFileContent(attachment.getPath());
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
}
|
|
|
// 方式为自定义
|
|
|
else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod())
|
|
|
|| CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
|
|
|
- examCardDetail.setContent(params.getContent());
|
|
|
+ examCard.setContent(params.getContent());
|
|
|
htmlContent = params.getHtmlContent();
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
} else {
|
|
|
throw ExceptionResultEnum.ERROR.exception("不存在的题卡创建方式");
|
|
|
}
|
|
|
-
|
|
|
- examCardDetailService.save(examCardDetail);
|
|
|
}
|
|
|
// 修改
|
|
|
else {
|
|
@@ -338,12 +297,8 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
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());
|
|
|
- String htmlContent = "";
|
|
|
+ String htmlContent;
|
|
|
// 方式为上传
|
|
|
if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
|
|
|
if (params.getAttachmentId() == null) {
|
|
@@ -357,29 +312,28 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
|
|
|
}
|
|
|
htmlContent = teachcloudCommonService.readFileContent(attachment.getPath());
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
// 上传题卡,状态为提交
|
|
|
examCard.setStatus(CardStatusEnum.SUBMIT);
|
|
|
}
|
|
|
// 方式为自定义
|
|
|
else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod()) || CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
|
|
|
- examCardDetail.setContent(params.getContent());
|
|
|
+ examCard.setContent(params.getContent());
|
|
|
htmlContent = params.getHtmlContent();
|
|
|
- examCardDetail.setHtmlContent(htmlContent);
|
|
|
+ examCard.setHtmlContent(htmlContent);
|
|
|
} else {
|
|
|
throw ExceptionResultEnum.ERROR.exception("不存在的题卡创建方式");
|
|
|
}
|
|
|
}
|
|
|
// 生成题卡图片
|
|
|
- List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCardDetail.getHtmlContent(), PageSizeEnum.A3);
|
|
|
+ List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCard.getHtmlContent(), PageSizeEnum.A3);
|
|
|
if (convertJpgStorageList.size() > 0) {
|
|
|
- examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
|
|
|
+ examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
|
|
|
}
|
|
|
- examCardDetailService.saveOrUpdate(examCardDetail);
|
|
|
+ this.saveOrUpdate(examCard);
|
|
|
return examCard.getId();
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
@Override
|
|
|
public Boolean deleteGeneric(Long id) {
|
|
|
// 校验题卡是否被绑定
|
|
@@ -387,7 +341,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
if (examTaskDetails != null && examTaskDetails.size() > 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("题卡已绑定命题任务,不能删除");
|
|
|
}
|
|
|
- examCardDetailService.removeByCardId(id);
|
|
|
return this.removeById(id);
|
|
|
}
|
|
|
|
|
@@ -421,45 +374,27 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
}
|
|
|
copyExamCard.setRemark(String.format("来源题卡:%s(%s)", id, examCard.getTitle()));
|
|
|
copyExamCard.setUsed(false);
|
|
|
- this.save(copyExamCard);
|
|
|
- Long copyExamCardId = copyExamCard.getId();
|
|
|
-
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(id);
|
|
|
- if (examCardDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡内容不存在");
|
|
|
- }
|
|
|
- // 复制题卡内容
|
|
|
- ExamCardDetail copyExamCardDetail = new ExamCardDetail();
|
|
|
- BeanUtils.copyProperties(examCardDetail, copyExamCardDetail);
|
|
|
- copyExamCardDetail.setId(SystemConstant.getDbUuid());
|
|
|
- copyExamCardDetail.setCardId(copyExamCardId);
|
|
|
// 生成图片
|
|
|
- List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), copyExamCardDetail.getHtmlContent(), PageSizeEnum.A3);
|
|
|
+ List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), copyExamCard.getHtmlContent(), PageSizeEnum.A3);
|
|
|
if (!convertJpgStorageList.isEmpty()) {
|
|
|
- copyExamCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
|
|
|
+ copyExamCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
|
|
|
} else {
|
|
|
- copyExamCardDetail.setJpgAttachmentInfo(null);
|
|
|
+ copyExamCard.setJpgAttachment(null);
|
|
|
}
|
|
|
- examCardDetailService.save(copyExamCardDetail);
|
|
|
-
|
|
|
- return copyExamCardId;
|
|
|
+ this.save(copyExamCard);
|
|
|
+ return copyExamCard.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void convertImage(Long id) {
|
|
|
ExamCard examCard = this.getById(id);
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(id);
|
|
|
- if (examCardDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡不存在");
|
|
|
- }
|
|
|
-
|
|
|
- List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCardDetail.getHtmlContent(), PageSizeEnum.A3);
|
|
|
+ List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCard.getHtmlContent(), PageSizeEnum.A3);
|
|
|
if (convertJpgStorageList.size() > 0) {
|
|
|
String jpgAttachmentIds = JSON.toJSONString(convertJpgStorageList);
|
|
|
- UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().set(ExamCardDetail::getJpgAttachmentInfo, jpgAttachmentIds)
|
|
|
- .eq(ExamCardDetail::getId, examCardDetail.getId());
|
|
|
- examCardDetailService.update(updateWrapper);
|
|
|
+ UpdateWrapper<ExamCard> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamCard::getJpgAttachment, jpgAttachmentIds)
|
|
|
+ .eq(ExamCard::getId, id);
|
|
|
+ this.update(updateWrapper);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -478,7 +413,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
|
|
|
// 题卡详细信息
|
|
|
ExamCard examCard = this.getById(id);
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
|
|
|
|
|
|
StringJoiner dirPath = new StringJoiner("");
|
|
|
dirPath = dirPath.add(rootPath).add(File.separator).add(examCard.getTitle()).add(File.separator);
|
|
@@ -487,18 +421,18 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
// 通用模板
|
|
|
if (CardTypeEnum.GENERIC.equals(examCard.getType())) {
|
|
|
if (CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
|
|
|
- htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
|
|
|
+ htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
|
|
|
} else {
|
|
|
BasicCardRule basicCardRule = basicCardRuleService.getById(examCard.getCardRuleId());
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
|
|
|
}
|
|
|
} else {
|
|
|
- List<ExamTask> examTasks = examCardDetailService.getExamTaskByCourseCodeAndCardId(examCard.getSchoolId(), examCard.getCourseCode(), id);
|
|
|
+ List<ExamTask> examTasks = examTaskService.getExamTaskByCourseCodeAndCardId(examCard.getSchoolId(), examCard.getCourseCode(), id);
|
|
|
BasicCardRule basicCardRule = null;
|
|
|
if (!CollectionUtils.isEmpty(examTasks)) {
|
|
|
basicCardRule = basicCardRuleService.getById(examTasks.get(0).getCardRuleId());
|
|
|
}
|
|
|
- htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
|
|
|
+ htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
|
|
|
}
|
|
|
|
|
|
// html文件
|
|
@@ -521,7 +455,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
|
|
|
|
|
|
// jpg文件
|
|
|
- String jpgAttachmentIds = examCardDetail.getJpgAttachmentInfo();
|
|
|
+ String jpgAttachmentIds = examCard.getJpgAttachment();
|
|
|
if (StringUtils.isNotBlank(jpgAttachmentIds)) {
|
|
|
List<JSONObject> jsonObjectList = JSONObject.parseArray(jpgAttachmentIds, JSONObject.class);
|
|
|
for (JSONObject jsonObject : jsonObjectList) {
|
|
@@ -538,7 +472,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
|
|
|
}
|
|
|
|
|
|
// json文件
|
|
|
- String content = examCardDetail.getContent();
|
|
|
+ String content = examCard.getContent();
|
|
|
if (StringUtils.isNotBlank(content)) {
|
|
|
String jsonPath = dirPath + examCard.getTitle() + SystemConstant.JSON_PREFIX;
|
|
|
SystemConstant.createJsonFile(jsonPath, content);
|