模板修改
This commit is contained in:
parent
e9924bb232
commit
433a64203c
@ -84,5 +84,29 @@
|
|||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>5.2.3</version>
|
<version>5.2.3</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@ -656,14 +656,14 @@ public class InspectPatientController {
|
|||||||
|
|
||||||
@GetMapping("/createPatientInspectDataReport")
|
@GetMapping("/createPatientInspectDataReport")
|
||||||
@Operation(summary = "创建患者体检报告单")
|
@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);
|
Map<String, Object> outRes = patientService.createPatientInspectDataReport(medicalSn);
|
||||||
return success(outRes);
|
return success(outRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getPatientInspectDataReport")
|
@GetMapping("/getPatientInspectDataReport")
|
||||||
@Operation(summary = "获取患者体检报告单")
|
@Operation(summary = "获取患者体检报告单")
|
||||||
public CommonResult<Map<String, Object>> getPatientInspectDataReport(String medicalSn) {
|
public CommonResult<Map<String, Object>> getPatientInspectDataReport(@RequestParam String medicalSn) {
|
||||||
patientService.getPatientInspectDataReport(medicalSn);
|
patientService.getPatientInspectDataReport(medicalSn);
|
||||||
return success(null);
|
return success(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,10 @@ import freemarker.template.Template;
|
|||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
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.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -361,7 +365,10 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
|||||||
}};
|
}};
|
||||||
XWPFDocument document = null;
|
XWPFDocument document = null;
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
FileOutputStream fos = null;
|
ByteArrayOutputStream fos = null;
|
||||||
|
InputStream fos_in = null;
|
||||||
|
LocalOfficeManager officeManager = null;
|
||||||
|
DocumentConverter converter = null;
|
||||||
try {
|
try {
|
||||||
//参数校验
|
//参数校验
|
||||||
if (medicalSn == null || medicalSn.trim().equals("")) {
|
if (medicalSn == null || medicalSn.trim().equals("")) {
|
||||||
@ -451,6 +458,7 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
|||||||
//其它参数
|
//其它参数
|
||||||
ConfigDO configInfo_bgmb = configService.getConfigByKey("url.bgmb");
|
ConfigDO configInfo_bgmb = configService.getConfigByKey("url.bgmb");
|
||||||
ConfigDO configInfo_bgcf = configService.getConfigByKey("url.bgcf");
|
ConfigDO configInfo_bgcf = configService.getConfigByKey("url.bgcf");
|
||||||
|
ConfigDO configInfo_LibreOffice = configService.getConfigByKey("url.LibreOffice");
|
||||||
String ageStr = "";
|
String ageStr = "";
|
||||||
String pnameStr = "";
|
String pnameStr = "";
|
||||||
if (patientInfo != null) {
|
if (patientInfo != null) {
|
||||||
@ -559,18 +567,42 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
|||||||
throw new Exception("模板内容数据为空!");
|
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;
|
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);
|
document.write(fos);
|
||||||
File file = new File(fosPath);
|
fos_in = new ByteArrayInputStream(fos.toByteArray());
|
||||||
file.setReadOnly();
|
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) {
|
} catch (Exception ex) {
|
||||||
outRes.put("code", -200);
|
outRes.put("code", -200);
|
||||||
outRes.put("msg", "");
|
outRes.put("msg", "");
|
||||||
} finally {
|
} finally {
|
||||||
|
try {
|
||||||
|
if (officeManager != null && officeManager.isRunning()) {
|
||||||
|
officeManager.stop();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (fos_in != null)
|
||||||
|
fos_in.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (fos != null)
|
if (fos != null)
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user