模板修改
This commit is contained in:
parent
e9924bb232
commit
433a64203c
@ -84,5 +84,29 @@
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jodconverter -->
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-core</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-local</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jodconverter</groupId>
|
||||
<artifactId>jodconverter-spring-boot-starter</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- libreoffice -->
|
||||
<dependency>
|
||||
<groupId>org.libreoffice</groupId>
|
||||
<artifactId>ridl</artifactId>
|
||||
<version>5.4.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -656,14 +656,14 @@ public class InspectPatientController {
|
||||
|
||||
@GetMapping("/createPatientInspectDataReport")
|
||||
@Operation(summary = "创建患者体检报告单")
|
||||
public CommonResult<Map<String, Object>> createPatientInspectDataReport(String medicalSn) {
|
||||
public CommonResult<Map<String, Object>> createPatientInspectDataReport(@RequestParam String medicalSn) {
|
||||
Map<String, Object> outRes = patientService.createPatientInspectDataReport(medicalSn);
|
||||
return success(outRes);
|
||||
}
|
||||
|
||||
@GetMapping("/getPatientInspectDataReport")
|
||||
@Operation(summary = "获取患者体检报告单")
|
||||
public CommonResult<Map<String, Object>> getPatientInspectDataReport(String medicalSn) {
|
||||
public CommonResult<Map<String, Object>> getPatientInspectDataReport(@RequestParam String medicalSn) {
|
||||
patientService.getPatientInspectDataReport(medicalSn);
|
||||
return success(null);
|
||||
}
|
||||
|
||||
@ -20,6 +20,10 @@ import freemarker.template.Template;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.jodconverter.DocumentConverter;
|
||||
import org.jodconverter.LocalConverter;
|
||||
import org.jodconverter.document.DefaultDocumentFormatRegistry;
|
||||
import org.jodconverter.office.LocalOfficeManager;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -361,7 +365,10 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
}};
|
||||
XWPFDocument document = null;
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
ByteArrayOutputStream fos = null;
|
||||
InputStream fos_in = null;
|
||||
LocalOfficeManager officeManager = null;
|
||||
DocumentConverter converter = null;
|
||||
try {
|
||||
//参数校验
|
||||
if (medicalSn == null || medicalSn.trim().equals("")) {
|
||||
@ -451,6 +458,7 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
//其它参数
|
||||
ConfigDO configInfo_bgmb = configService.getConfigByKey("url.bgmb");
|
||||
ConfigDO configInfo_bgcf = configService.getConfigByKey("url.bgcf");
|
||||
ConfigDO configInfo_LibreOffice = configService.getConfigByKey("url.LibreOffice");
|
||||
String ageStr = "";
|
||||
String pnameStr = "";
|
||||
if (patientInfo != null) {
|
||||
@ -559,18 +567,42 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
throw new Exception("模板内容数据为空!");
|
||||
}
|
||||
|
||||
//保存word
|
||||
String fosPath_file = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".docx";
|
||||
//保存文件
|
||||
String fosPath_file = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".pdf";
|
||||
String fosPath = configInfo_bgcf.getValue() + "\\" + fosPath_file;
|
||||
outRes.put("msg", "https://pacs.gw12320.com/video/" + fosPath_file);
|
||||
fos = new FileOutputStream(fosPath);
|
||||
|
||||
fos = new ByteArrayOutputStream();
|
||||
document.write(fos);
|
||||
File file = new File(fosPath);
|
||||
file.setReadOnly();
|
||||
fos_in = new ByteArrayInputStream(fos.toByteArray());
|
||||
officeManager = LocalOfficeManager.builder()
|
||||
.officeHome(configInfo_LibreOffice.getValue() + "\\")
|
||||
.portNumbers(8131)
|
||||
.maxTasksPerProcess(100)
|
||||
.build();
|
||||
officeManager.start();
|
||||
converter = LocalConverter.make(officeManager);
|
||||
converter.convert(fos_in)
|
||||
.as(DefaultDocumentFormatRegistry.DOCX)
|
||||
.to(new File(fosPath))
|
||||
.as(DefaultDocumentFormatRegistry.PDF)
|
||||
.execute();
|
||||
|
||||
outRes.put("msg", "https://pacs.gw12320.com/video/" + fosPath_file);
|
||||
} catch (Exception ex) {
|
||||
outRes.put("code", -200);
|
||||
outRes.put("msg", "");
|
||||
} finally {
|
||||
try {
|
||||
if (officeManager != null && officeManager.isRunning()) {
|
||||
officeManager.stop();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (fos_in != null)
|
||||
fos_in.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user