From 37122b00b760823b202664325ce7b4361d9bd558 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 20 十一月 2025 17:41:08 +0800
Subject: [PATCH] 新增食管心脏电生理知情同意书

---
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/freemark/TemplateCreateController.java |   49 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/freemark/TemplateCreateController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/freemark/TemplateCreateController.java
index a56b309..9493bf4 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/freemark/TemplateCreateController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/freemark/TemplateCreateController.java
@@ -44,7 +44,8 @@
         log.info("鐭ユ儏鍚屾剰杩愬姩璇曢獙锛歿}", id);
         try {
             Map dataMap = new HashMap();
-            getData(dataMap, id);
+            AppointmentDO appointment = appointmentService.getAppointment(id);
+            getData(dataMap, appointment);
             String filePath = getClass().getResource("/template/").getPath();
             System.out.println(filePath);
             //璁剧疆妯℃湰瑁呯疆鏂规硶鍜岃矾寰�,FreeMarker鏀寔澶氱妯℃澘瑁呰浇鏂规硶銆傚彲浠ラ噸servlet锛宑lasspath锛屾暟鎹簱鏁欑▼瑁呰浇锛�
@@ -54,16 +55,16 @@
             t = configuration.getTemplate("鐭ユ儏鍚屾剰杩愬姩璇曢獙.ftl");
 
             String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
-            String name = "鐭ユ儏鍚屾剰杩愬姩璇曢獙" + year;
+            String name = "鐭ユ儏鍚屾剰杩愬姩璇曢獙-" + appointment.getPatName() + "-" + year;
 
             //杈撳嚭鏂囨。璺緞鍙婂悕绉�
-            File outFile = new File("D:/download/" + name + ".doc");
+            File outFile = new File("D:/" + name + ".doc");
             Writer out = null;
             out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"));
             t.process(dataMap, out);
 
             Map<String, Object> map = new HashMap<>();
-            map.put("downloadUrl", "D:/download/" + name + ".doc");
+            map.put("downloadUrl", "D:/" + name + ".doc");
             map.put("downloadName", name + ".doc");
             return map;
         } catch (Exception e) {
@@ -72,9 +73,43 @@
         return null;
     }
 
-    private void getData(Map dataMap, Long id) {
-        AppointmentDO appointment = appointmentService.getAppointment(id);
 
+    @Operation(summary = "椋熺蹇冭剰鐢电敓鐞嗙煡鎯呭悓鎰忎功")
+    @GetMapping(value = "/downloadesophagus/{id}")
+    public Map downloadEsophagusInfo(@PathVariable("id") Long id) {
+        log.info("椋熺蹇冭剰鐢电敓鐞嗙煡鎯呭悓鎰忎功锛歿}", id);
+        try {
+            Map dataMap = new HashMap();
+            AppointmentDO appointment = appointmentService.getAppointment(id);
+            getData(dataMap, appointment);
+            String filePath = getClass().getResource("/template/").getPath();
+            System.out.println(filePath);
+            //璁剧疆妯℃湰瑁呯疆鏂规硶鍜岃矾寰�,FreeMarker鏀寔澶氱妯℃澘瑁呰浇鏂规硶銆傚彲浠ラ噸servlet锛宑lasspath锛屾暟鎹簱鏁欑▼瑁呰浇锛�
+            configuration.setDirectoryForTemplateLoading(new File(filePath));
+            Template t = null;
+            //鎹愮尞琛�.ftl涓鸿瑁呰浇鐨勬ā鏉�
+            t = configuration.getTemplate("椋熺蹇冭剰鐢电敓鐞嗙煡鎯呭悓鎰忎功.ftl");
+
+            String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
+            String name = "椋熺蹇冭剰鐢电敓鐞嗙煡鎯呭悓鎰忎功-" + appointment.getPatName() + "-" + year;
+
+            //杈撳嚭鏂囨。璺緞鍙婂悕绉�
+            File outFile = new File("D:/" + name + ".doc");
+            Writer out = null;
+            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"));
+            t.process(dataMap, out);
+
+            Map<String, Object> map = new HashMap<>();
+            map.put("downloadUrl", "D:/" + name + ".doc");
+            map.put("downloadName", name + ".doc");
+            return map;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private void getData(Map dataMap, AppointmentDO appointment) {
         dataMap.put("name", StringUtils.isEmpty(appointment.getPatName()) ? "" : appointment.getPatName());
         dataMap.put("sex", appointment.getPatGender() == null ? "" : appointment.getPatGender() == 1 ? "鐢�" : "濂�");
         dataMap.put("age", appointment.getPatBirthday() == null ? "" : calculateAge(appointment.getPatBirthday()));
@@ -83,6 +118,8 @@
         dataMap.put("badNo", StringUtils.isEmpty(appointment.getPatBedNo()) ? "" : appointment.getPatBedNo());
         dataMap.put("birthday", appointment.getPatBirthday() == null ? "" : appointment.getPatBirthday());
         dataMap.put("doctor", StringUtils.isEmpty(appointment.getDoctor()) ? "" : appointment.getDoctor());
+        dataMap.put("deptName", StringUtils.isEmpty(appointment.getPatDeptDesc()) ? "" : appointment.getPatDeptDesc());
+        dataMap.put("episodeId", StringUtils.isEmpty(appointment.getEpisodeId()) ? "" : appointment.getEpisodeId());
 
     }
 

--
Gitblit v1.9.3