|
@@ -21,6 +21,7 @@ import cn.com.qmth.examcloud.core.print.repository.PrintingProjectRepository;
|
|
import cn.com.qmth.examcloud.core.print.service.CoursePaperService;
|
|
import cn.com.qmth.examcloud.core.print.service.CoursePaperService;
|
|
import cn.com.qmth.examcloud.core.print.service.ExamQuestionStructureService;
|
|
import cn.com.qmth.examcloud.core.print.service.ExamQuestionStructureService;
|
|
import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.*;
|
|
import cn.com.qmth.examcloud.core.print.service.bean.coursepaper.*;
|
|
|
|
+import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -45,17 +46,27 @@ import static cn.com.qmth.examcloud.core.print.common.Constants.*;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class CoursePaperServiceImpl implements CoursePaperService {
|
|
public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
+
|
|
private static final Logger log = LoggerFactory.getLogger(CoursePaperServiceImpl.class);
|
|
private static final Logger log = LoggerFactory.getLogger(CoursePaperServiceImpl.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private PrintingProjectRepository printingProjectRepository;
|
|
private PrintingProjectRepository printingProjectRepository;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private CoursePaperRepository coursePaperRepository;
|
|
private CoursePaperRepository coursePaperRepository;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private CourseStatisticRepository courseStatisticRepository;
|
|
private CourseStatisticRepository courseStatisticRepository;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private ExamQuestionStructureService examQuestionStructureService;
|
|
private ExamQuestionStructureService examQuestionStructureService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SystemProperties systemProperties;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SysProperty sysProperty;
|
|
private SysProperty sysProperty;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private UpYunClient upYunClient;
|
|
private UpYunClient upYunClient;
|
|
|
|
|
|
@@ -151,7 +162,7 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
//将试卷和答案页面转换为PDF文件
|
|
//将试卷和答案页面转换为PDF文件
|
|
//final String rootDir = Constants.rootFileDir();
|
|
//final String rootDir = Constants.rootFileDir();
|
|
- final String rootDir = sysProperty.getTempDir();
|
|
|
|
|
|
+ final String rootDir = systemProperties.getTempDataDir();
|
|
final String paperPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
final String paperPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
final String answerPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
final String answerPdfPath = rootDir + "/" + FileUtils.randomUUID() + SUFFIX_PDF;
|
|
FileUtils.makeDirs(rootDir);
|
|
FileUtils.makeDirs(rootDir);
|
|
@@ -164,13 +175,15 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
final String title = String.format("?examName=%s", this.urlParamEncode(printingProject.getExamName()));
|
|
final String title = String.format("?examName=%s", this.urlParamEncode(printingProject.getExamName()));
|
|
|
|
|
|
- boolean paperResult = ElectronUtils.toPdf(sysProperty.getProfile(), sysProperty.getDir(), coursePaper.getPaperHtmlUrl() + title, paperPdfPath);
|
|
|
|
|
|
+ boolean paperResult = ElectronUtils.toPdf(systemProperties.getProfile(), systemProperties.getDataDir(),
|
|
|
|
+ coursePaper.getPaperHtmlUrl() + title, paperPdfPath);
|
|
if (!paperResult) {
|
|
if (!paperResult) {
|
|
log.warn(String.format("试卷页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
log.warn(String.format("试卷页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- boolean answerResult = ElectronUtils.toPdf(sysProperty.getProfile(), sysProperty.getDir(), coursePaper.getAnswerHtmlUrl() + title, answerPdfPath);
|
|
|
|
|
|
+ boolean answerResult = ElectronUtils.toPdf(systemProperties.getProfile(), systemProperties.getDataDir(),
|
|
|
|
+ coursePaper.getAnswerHtmlUrl() + title, answerPdfPath);
|
|
if (!answerResult) {
|
|
if (!answerResult) {
|
|
log.warn(String.format("答案页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
log.warn(String.format("答案页面转换PDF文件失败!paperId = %s", coursePaper.getPaperId()));
|
|
continue;
|
|
continue;
|
|
@@ -474,7 +487,7 @@ public class CoursePaperServiceImpl implements CoursePaperService {
|
|
|
|
|
|
//文件存放目录
|
|
//文件存放目录
|
|
//final String targetDir = Constants.rootFileDir() + "/" + FileUtils.randomUUID();
|
|
//final String targetDir = Constants.rootFileDir() + "/" + FileUtils.randomUUID();
|
|
- final String targetDir = sysProperty.getTempDir() + "/" + FileUtils.randomUUID();
|
|
|
|
|
|
+ final String targetDir = systemProperties.getTempDataDir() + "/" + FileUtils.randomUUID();
|
|
FileUtils.makeDirs(targetDir);
|
|
FileUtils.makeDirs(targetDir);
|
|
|
|
|
|
//优先处理试卷或答案文件(需要网络下载)
|
|
//优先处理试卷或答案文件(需要网络下载)
|