diff --git a/yudao-module-inspect/yudao-module-inspect-biz/pom.xml b/yudao-module-inspect/yudao-module-inspect-biz/pom.xml index 259ec43..1572da7 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/pom.xml +++ b/yudao-module-inspect/yudao-module-inspect-biz/pom.xml @@ -84,5 +84,29 @@ poi-ooxml 5.2.3 + + + + org.jodconverter + jodconverter-core + 4.2.0 + + + org.jodconverter + jodconverter-local + 4.2.0 + + + org.jodconverter + jodconverter-spring-boot-starter + 4.2.0 + + + + + org.libreoffice + ridl + 5.4.2 + \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java index 2135a3e..b69d7c7 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java @@ -656,14 +656,14 @@ public class InspectPatientController { @GetMapping("/createPatientInspectDataReport") @Operation(summary = "创建患者体检报告单") - public CommonResult> createPatientInspectDataReport(String medicalSn) { + public CommonResult> createPatientInspectDataReport(@RequestParam String medicalSn) { Map outRes = patientService.createPatientInspectDataReport(medicalSn); return success(outRes); } @GetMapping("/getPatientInspectDataReport") @Operation(summary = "获取患者体检报告单") - public CommonResult> getPatientInspectDataReport(String medicalSn) { + public CommonResult> getPatientInspectDataReport(@RequestParam String medicalSn) { patientService.getPatientInspectDataReport(medicalSn); return success(null); } diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java index 661f96c..2477b98 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java @@ -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();