报告改成读取指定目录下的
This commit is contained in:
@@ -86,6 +86,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -600,7 +601,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
// 读取模板文件
|
// 读取模板文件
|
||||||
ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ReportConstant.DOCX);
|
// ClassPathResource resource = new ClassPathResource("/model/" + reportName.getCode() + ReportConstant.DOCX);
|
||||||
|
FileSystemResource resource = new FileSystemResource(templatePath + File.separator + reportName.getCode() + ReportConstant.DOCX);
|
||||||
try (InputStream inputStream = resource.getInputStream()) {
|
try (InputStream inputStream = resource.getInputStream()) {
|
||||||
// 加载Word文档
|
// 加载Word文档
|
||||||
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
|
XWPFDocument baseModelDocument = new XWPFDocument(inputStream);
|
||||||
@@ -1525,12 +1527,13 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
//String scriptId = adPlan.getScriptId();
|
//String scriptId = adPlan.getScriptId();
|
||||||
Integer devChns = pqDevVO.getDevChns();
|
Integer devChns = pqDevVO.getDevChns();
|
||||||
for (int i = 1; i <= devChns; i++) {
|
for (int i = 1; i <= devChns; i++) {
|
||||||
String path = "/model/report_table.docx";
|
String path = "/report_table.docx";
|
||||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||||
if (devType.getName().equals("PQ-COM")) {
|
if (devType.getName().equals("PQ-COM")) {
|
||||||
path = "/model/report_table - PQ-COM.docx";
|
path = "/report_table - PQ-COM.docx";
|
||||||
}
|
}
|
||||||
ClassPathResource resource = new ClassPathResource(path);
|
// ClassPathResource resource = new ClassPathResource(path);
|
||||||
|
FileSystemResource resource = new FileSystemResource(templatePath + path);
|
||||||
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream());
|
||||||
|
|
||||||
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam();
|
||||||
|
|||||||
Reference in New Issue
Block a user