|
@@ -8,9 +8,9 @@
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.core.print.common.SysProperty;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
|
-import cn.com.qmth.examcloud.core.print.common.upyun.SystemProperty;
|
|
|
import cn.com.qmth.examcloud.core.print.common.upyun.UpYunClient;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.*;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.*;
|
|
@@ -26,7 +26,6 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -56,13 +55,10 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
@Autowired
|
|
|
private ExamQuestionStructureService examQuestionStructureService;
|
|
|
@Autowired
|
|
|
- private SystemProperty systemProperty;
|
|
|
+ private SysProperty sysProperty;
|
|
|
@Autowired
|
|
|
private UpYunClient upYunClient;
|
|
|
|
|
|
- @Value("${$question.url.prefix}")
|
|
|
- private String QUESTION_URL_PREFIX;//题库访问地址前缀
|
|
|
-
|
|
|
@Override
|
|
|
public List<CoursePaperLessInfo> getCoursePaperList(CoursePaperQuery query) {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
@@ -114,8 +110,8 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
//试卷页面地址和答案页面地址
|
|
|
//String title = urlParamEncode(coursePaper.getPaperName());
|
|
|
- final String paperHtmlUrl = QUESTION_URL_PREFIX.concat("/api/ecs_ques/paper/pdf/").concat(coursePaper.getPaperId());
|
|
|
- final String answerHtmlUrl = QUESTION_URL_PREFIX.concat("/api/ecs_ques/paper/answer/pdf/").concat(coursePaper.getPaperId());
|
|
|
+ final String paperHtmlUrl = sysProperty.getQuestionUrlPrefix().concat("/api/ecs_ques/paper/pdf/").concat(coursePaper.getPaperId());
|
|
|
+ final String answerHtmlUrl = sysProperty.getQuestionUrlPrefix().concat("/api/ecs_ques/paper/answer/pdf/").concat(coursePaper.getPaperId());
|
|
|
|
|
|
CoursePaper oldCoursePaper = coursePaperRepository.findByExamIdAndPaperId(coursePaper.getExamId(), coursePaper.getPaperId());
|
|
|
if (oldCoursePaper != null) {
|
|
@@ -155,7 +151,7 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
//将试卷和答案页面转换为PDF文件
|
|
|
//final String rootDir = Constants.rootFileDir();
|
|
|
- final String rootDir = systemProperty.getTempDir();
|
|
|
+ final String rootDir = sysProperty.getTempDir();
|
|
|
final String paperPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
|
final String answerPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
|
FileUtils.makeDirs(rootDir);
|
|
@@ -168,13 +164,13 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
final String title = String.format("?examName=%s", this.urlParamEncode(printingProject.getExamName()));
|
|
|
|
|
|
- boolean paperResult = ElectronUtils.toPdf(systemProperty.getProfile(), systemProperty.getDir(), coursePaper.getPaperHtmlUrl() + title, paperPdfPath);
|
|
|
+ boolean paperResult = ElectronUtils.toPdf(sysProperty.getProfile(), sysProperty.getDir(), coursePaper.getPaperHtmlUrl() + title, paperPdfPath);
|
|
|
if (!paperResult) {
|
|
|
log.warn(String.format("试卷页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- boolean answerResult = ElectronUtils.toPdf(systemProperty.getProfile(), systemProperty.getDir(), coursePaper.getAnswerHtmlUrl() + title, answerPdfPath);
|
|
|
+ boolean answerResult = ElectronUtils.toPdf(sysProperty.getProfile(), sysProperty.getDir(), coursePaper.getAnswerHtmlUrl() + title, answerPdfPath);
|
|
|
if (!answerResult) {
|
|
|
log.warn(String.format("答案页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
|
continue;
|
|
@@ -478,7 +474,7 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
//文件存放目录
|
|
|
//final String targetDir = Constants.rootFileDir() + "/" + FileUtils.randomUUID();
|
|
|
- final String targetDir = systemProperty.getTempDir() + "/" + FileUtils.randomUUID();
|
|
|
+ final String targetDir = sysProperty.getTempDir() + "/" + FileUtils.randomUUID();
|
|
|
FileUtils.makeDirs(targetDir);
|
|
|
|
|
|
//优先处理试卷或答案文件(需要网络下载)
|