ab21541dc210180d1fef5b4351e416ee5c5be0db..9978298937fb8a34faf8af9af6c893fcb5ddeb27
2 天以前 liusheng
查询预约时间SQL修改
997829 对比 | 目录
2 天以前 liusheng
模板提交
d1bb20 对比 | 目录
2 天以前 liusheng
模板提交
2e455d 对比 | 目录
2 天以前 liusheng
新增访问路径
546d3f 对比 | 目录
2 天以前 liusheng
新增访问路径
6fd341 对比 | 目录
2 天以前 liusheng
新增访问路径
a1e36f 对比 | 目录
已修改2个文件
已添加1个文件
159 ■■■■ 文件已修改
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/WebConfig.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/freemark/TemplateCreateController.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/config/WebConfig.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package cn.lihu.jh.module.ecg.config;
import cn.lihu.jh.module.infra.dal.dataobject.config.ConfigDO;
import cn.lihu.jh.module.infra.service.config.ConfigService;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Resource
    private ConfigService configService;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        ConfigDO configByKey = configService.getConfigByKey("file.upload.path");
        // é…ç½® /profile/** æ˜ å°„到文件系统路径
        registry.addResourceHandler("/profile/**").addResourceLocations("file:" + configByKey.getValue() + "/");
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/freemark/TemplateCreateController.java
@@ -2,6 +2,7 @@
import cn.lihu.jh.module.ecg.dal.dataobject.appointment.AppointmentDO;
import cn.lihu.jh.module.ecg.service.appointment.AppointmentService;
import cn.lihu.jh.module.infra.service.config.ConfigService;
import freemarker.template.Configuration;
import freemarker.template.Template;
import io.swagger.v3.oas.annotations.Operation;
@@ -14,12 +15,12 @@
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.io.BufferedWriter;
import java.io.File;
import java.io.StringWriter;
import java.io.Writer;
import java.time.LocalDate;
import java.time.Period;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
@@ -32,6 +33,8 @@
    @Resource
    private AppointmentService appointmentService;
    @Resource
    private ConfigService configService;
    private static Configuration configuration = null;
@@ -40,9 +43,10 @@
        configuration.setDefaultEncoding("utf-8");
    }
    @Operation(summary = "知情同意运动试验")
    @GetMapping(value = "/download/{id}")
    public void downloadInfo(@PathVariable("id") Long id, HttpServletResponse response) {
    public Map<String, Object> downloadInfo(@PathVariable("id") Long id) {
        log.info("知情同意运动试验:{}", id);
        try {
@@ -52,36 +56,48 @@
            String filePath = getClass().getResource("/template/").getPath();
            configuration.setDirectoryForTemplateLoading(new File(filePath));
            // ç¡®ä¿æ¨¡æ¿æ˜¯Word XML格式
            Template t = configuration.getTemplate("知情同意运动试验.ftl");
            String timestamp = String.valueOf(System.currentTimeMillis());
            String fileName = "知情同意运动试验-" + appointment.getPatName() + "-" + timestamp + ".doc";
            String time = String.valueOf(System.currentTimeMillis());
            String fileName = "平板运动心电图知情同意书-" + appointment.getPatName() + "-" + time + ".doc";
            // è®¾ç½®å“åº”头,告诉浏览器进行下载
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/msword"); // Word文档类型
            response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
            // å°†æ¨¡æ¿æ¸²æŸ“结果写入StringWriter
            StringWriter stringWriter = new StringWriter();
            try (Writer out = new BufferedWriter(stringWriter)) {
                t.process(dataMap, out);
            }
            // ç›´æŽ¥è¾“出到response的输出流
            Writer out = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
            t.process(dataMap, out);
            out.flush();
            out.close();
            String xmlContent = stringWriter.toString();
            // è¿”回结果
            Map<String, Object> result = new HashMap<>();
            Map<String, Object> result1 = new HashMap<>();
            result.put("success", true);
            result.put("fileName", fileName);
            result.put("fileContent", xmlContent);
            result.put("fileType", "application/msword");
            result1.put("code", 200);
            result1.put("data", result);
            result1.put("msg", "success");
            log.info("Word XML内容生成成功");
            return result1;
        } catch (Exception e) {
            log.error("下载知情同意运动试验文档失败", e);
            try {
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "文档生成失败");
            } catch (IOException ex) {
                log.error("发送错误响应失败", ex);
            }
            log.error("生成平板运动心电图知情同意书失败", e);
            Map<String, Object> result = new HashMap<>();
            result.put("code", 500);
            result.put("data", null);
            result.put("msg", "文档生成失败: " + e.getMessage());
            return result;
        }
    }
    @Operation(summary = "食管心脏电生理知情同意书")
    @GetMapping(value = "/downloadesophagus/{id}")
    public void downloadEsophagusInfo(@PathVariable("id") Long id, HttpServletResponse response) {
    public Map<String, Object> downloadEsophagusInfo(@PathVariable("id") Long id) {
        log.info("食管心脏电生理知情同意书:{}", id);
        try {
@@ -91,29 +107,43 @@
            String filePath = getClass().getResource("/template/").getPath();
            configuration.setDirectoryForTemplateLoading(new File(filePath));
            // ç¡®ä¿æ¨¡æ¿æ˜¯Word XML格式
            Template t = configuration.getTemplate("食管心脏电生理知情同意书.ftl");
            String timestamp = String.valueOf(System.currentTimeMillis());
            String fileName = "食管心脏电生理知情同意书-" + appointment.getPatName() + "-" + timestamp + ".doc";
            String time = String.valueOf(System.currentTimeMillis());
            String fileName = "食管心脏电生理知情同意书-" + appointment.getPatName() + "-" + time + ".doc";
            // è®¾ç½®å“åº”头,告诉浏览器进行下载
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/msword"); // Word文档类型
            response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
            // å°†æ¨¡æ¿æ¸²æŸ“结果写入StringWriter
            StringWriter stringWriter = new StringWriter();
            try (Writer out = new BufferedWriter(stringWriter)) {
                t.process(dataMap, out);
            }
            // ç›´æŽ¥è¾“出到response的输出流
            Writer out = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
            t.process(dataMap, out);
            out.flush();
            out.close();
            String xmlContent = stringWriter.toString();
            // è¿”回结果
            Map<String, Object> result1 = new HashMap<>();
            Map<String, Object> result = new HashMap<>();
            result.put("success", true);
            result.put("fileName", fileName);
            result.put("fileContent", xmlContent);
            result.put("fileType", "application/msword");
            result1.put("code", 200);
            result1.put("data", result);
            result1.put("msg", "success");
            log.info("食管心脏电生理知情同意书Word XML内容生成成功");
            return result1;
        } catch (Exception e) {
            log.error("下载食管心脏电生理知情同意书文档失败", e);
            try {
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "文档生成失败");
            } catch (IOException ex) {
                log.error("发送错误响应失败", ex);
            }
            log.error("生成食管心脏电生理知情同意书失败", e);
            Map<String, Object> result = new HashMap<>();
            result.put("code", 500);
            result.put("data", null);
            result.put("msg", "文档生成失败: " + e.getMessage());
            return result;
        }
    }
@@ -135,4 +165,20 @@
        return Period.between(birthdayStr, LocalDate.now()).getYears();
    }
    public void createPath(String uploadPath) {
        // ç¡®ä¿è·¯å¾„以斜杠结尾
        if (!uploadPath.endsWith("/") && !uploadPath.endsWith("\\")) {
            uploadPath += "/";
        }
        // åˆ›å»ºç›®å½•(如果不存在)
        File uploadDir = new File(uploadPath);
        if (!uploadDir.exists()) {
            boolean created = uploadDir.mkdirs();
            if (created) {
                log.info("创建目录成功: {}", uploadPath);
            }
        }
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/appointment/AppointmentMapper.java
@@ -23,9 +23,7 @@
public interface AppointmentMapper extends BaseMapperX<AppointmentDO> {
    default PageResult<AppointmentDO> selectPage(AppointmentPageReqVO reqVO) {
        LambdaQueryWrapperX<AppointmentDO> wrapper = (LambdaQueryWrapperX<AppointmentDO>)
                new LambdaQueryWrapperX<AppointmentDO>().
                        eqIfPresent(AppointmentDO::getPatId, reqVO.getPatId()).likeIfPresent(AppointmentDO::getPatName, reqVO.getPatName()).eqIfPresent(AppointmentDO::getPatGender, reqVO.getPatGender()).eqIfPresent(AppointmentDO::getPatBirthday, reqVO.getPatBirthday()).eqIfPresent(AppointmentDO::getPatMobile, reqVO.getPatMobile()).eqIfPresent(AppointmentDO::getPatPhone, reqVO.getPatPhone()).eqIfPresent(AppointmentDO::getPatIdentityId, reqVO.getPatIdentityId()).eqIfPresent(AppointmentDO::getPatAddr, reqVO.getPatAddr()).eqIfPresent(AppointmentDO::getPatDeptCode, reqVO.getPatDeptCode()).eqIfPresent(AppointmentDO::getPatDeptDesc, reqVO.getPatDeptDesc()).eqIfPresent(AppointmentDO::getPatWardCode, reqVO.getPatWardCode()).eqIfPresent(AppointmentDO::getPatWardDesc, reqVO.getPatWardDesc()).eqIfPresent(AppointmentDO::getBookDate, reqVO.getBookDate()).eqIfPresent(AppointmentDO::getBookTimeslot, reqVO.getBookTimeslot()).eqIfPresent(AppointmentDO::getBookCheckType, reqVO.getBookCheckType()).eqIfPresent(AppointmentDO::getBookSrc, reqVO.getBookSrc()).eqIfPresent(AppointmentDO::getPaid, reqVO.getPaid()).eqIfPresent(AppointmentDO::getApplyNo, reqVO.getApplyNo()).eqIfPresent(AppointmentDO::getEpisodeId, reqVO.getEpisodeId()).inIfPresent(AppointmentDO::getStatus, reqVO.getStatus())
        LambdaQueryWrapperX<AppointmentDO> wrapper = (LambdaQueryWrapperX<AppointmentDO>) new LambdaQueryWrapperX<AppointmentDO>().eqIfPresent(AppointmentDO::getPatId, reqVO.getPatId()).likeIfPresent(AppointmentDO::getPatName, reqVO.getPatName()).eqIfPresent(AppointmentDO::getPatGender, reqVO.getPatGender()).eqIfPresent(AppointmentDO::getPatBirthday, reqVO.getPatBirthday()).eqIfPresent(AppointmentDO::getPatMobile, reqVO.getPatMobile()).eqIfPresent(AppointmentDO::getPatPhone, reqVO.getPatPhone()).eqIfPresent(AppointmentDO::getPatIdentityId, reqVO.getPatIdentityId()).eqIfPresent(AppointmentDO::getPatAddr, reqVO.getPatAddr()).eqIfPresent(AppointmentDO::getPatDeptCode, reqVO.getPatDeptCode()).eqIfPresent(AppointmentDO::getPatDeptDesc, reqVO.getPatDeptDesc()).eqIfPresent(AppointmentDO::getPatWardCode, reqVO.getPatWardCode()).eqIfPresent(AppointmentDO::getPatWardDesc, reqVO.getPatWardDesc()).eqIfPresent(AppointmentDO::getBookDate, reqVO.getBookDate()).eqIfPresent(AppointmentDO::getBookTimeslot, reqVO.getBookTimeslot()).eqIfPresent(AppointmentDO::getBookCheckType, reqVO.getBookCheckType()).eqIfPresent(AppointmentDO::getBookSrc, reqVO.getBookSrc()).eqIfPresent(AppointmentDO::getPaid, reqVO.getPaid()).eqIfPresent(AppointmentDO::getApplyNo, reqVO.getApplyNo()).eqIfPresent(AppointmentDO::getEpisodeId, reqVO.getEpisodeId()).inIfPresent(AppointmentDO::getStatus, reqVO.getStatus())
                // âœ… æ–°å¢žï¼šcreateTime åŒºé—´æŸ¥è¯¢
                .betweenIfPresent(AppointmentDO::getCreateTime, reqVO.getCreateTimeStart(), reqVO.getCreateTimeEnd()).betweenIfPresent(AppointmentDO::getRegisterDate, reqVO.getRegisterDateStart(), reqVO.getRegisterDateEnd());
        // åŠ¨æ€æŽ’åº
@@ -41,7 +39,7 @@
    @Select("select * from lihu.appointment where pat_id = #{patId} and to_days(book_date) = to_days(Now())")
    List<AppointmentDO> getCurrentPatId(String patId);
    @Select("select * from lihu.appointment where (apply_no = #{code} or episode_id= #{code} or hospital_no =#{code} or pat_identity_id=#{code}) and to_days(book_date) = to_days(Now())")
    @Select("select * from lihu.appointment where (apply_no = #{code} or episode_id= #{code} or hospital_no =#{code} or pat_identity_id=#{code}) and book_date >= CURDATE() and book_date <= DATE_ADD(CURDATE(), INTERVAL 3 DAY)")
    List<AppointmentDO> getCurrentCode(String code);
    @Select("select * from lihu.appointment where pat_id = #{patId} and book_check_type = #{checkType} and to_days(book_date) = to_days(Now()) limit 1")