| | |
| | | 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,classpath,数据库教程装载, |
| | |
| | | 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) { |
| | |
| | | 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,classpath,数据库教程装载, |
| | | 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())); |
| | |
| | | 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()); |
| | | |
| | | } |
| | | |