yxh
2026-09-18 0fa1f4767affcd1879709ebea630016356836c75
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/freemark/TemplateCreateController.java
@@ -41,6 +41,8 @@
    public TemplateCreateController() {
        configuration = new Configuration();
        configuration.setDefaultEncoding("utf-8");
        // 使用classpath加载模板,而不是文件系统
        configuration.setClassForTemplateLoading(this.getClass(), "/template");
    }
@@ -54,8 +56,6 @@
            AppointmentDO appointment = appointmentService.getAppointment(id);
            getData(dataMap, appointment);
            String filePath = getClass().getResource("/template/").getPath();
            configuration.setDirectoryForTemplateLoading(new File(filePath));
            // 确保模板是Word XML格式
            Template t = configuration.getTemplate("知情同意运动试验.ftl");
@@ -105,8 +105,6 @@
            AppointmentDO appointment = appointmentService.getAppointment(id);
            getData(dataMap, appointment);
            String filePath = getClass().getResource("/template/").getPath();
            configuration.setDirectoryForTemplateLoading(new File(filePath));
            // 确保模板是Word XML格式
            Template t = configuration.getTemplate("食管心脏电生理知情同意书.ftl");
@@ -153,7 +151,18 @@
        dataMap.put("age", appointment.getPatBirthday() == null ? "" : calculateAge(appointment.getPatBirthday()));
        dataMap.put("inhospno", StringUtils.isEmpty(appointment.getHospitalNo()) ? "" : appointment.getHospitalNo());
        dataMap.put("idNo", StringUtils.isEmpty(appointment.getPatId()) ? "" : appointment.getPatId());
        dataMap.put("badNo", StringUtils.isEmpty(appointment.getPatBedNo()) ? "" : appointment.getPatBedNo());
        String ward = StringUtils.isEmpty(appointment.getPatWardDesc()) ? "" : appointment.getPatWardDesc();
        String bed = StringUtils.isEmpty(appointment.getPatBedNo()) ? "" : appointment.getPatBedNo();
        // 如果两个都有值,中间加空格;如果只有一个有值,就不加空格
        String badNo = "";
        if (!ward.isEmpty() && !bed.isEmpty()) {
            badNo = ward + " " + bed;
        } else {
            badNo = ward + bed;
        }
        dataMap.put("badNo", badNo);
        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());