| | |
| | | public TemplateCreateController() { |
| | | configuration = new Configuration(); |
| | | configuration.setDefaultEncoding("utf-8"); |
| | | // 使用classpath加载模板,而不是文件系统 |
| | | configuration.setClassForTemplateLoading(this.getClass(), "/template"); |
| | | } |
| | | |
| | | |
| | |
| | | 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"); |
| | |
| | | } |
| | | |
| | | @Operation(summary = "食管心脏电生理知情同意书") |
| | | @GetMapping(value = "/downloadEsophagus/{id}") |
| | | @GetMapping(value = "/downloadesophagus/{id}") |
| | | public Map<String, Object> downloadEsophagusInfo(@PathVariable("id") Long id) { |
| | | log.info("食管心脏电生理知情同意书:{}", id); |
| | | |
| | |
| | | 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"); |
| | |
| | | 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()); |