From 5e3ee9e4c85ff38e28987b5d6617c4d51d01d94c Mon Sep 17 00:00:00 2001 From: Euni4U <958079825@qq.com> Date: Tue, 8 Apr 2025 11:09:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BD=93=E6=A3=80=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=94=9F=E6=88=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InspectPatientController.java | 115 +++++++++++++++++- .../vo/InspectPatientPageReqVO.java | 5 +- .../vo/InspectPatientRespVO.java | 2 +- .../vo/InspectPatientSaveReqVO.java | 5 +- .../inspectpatient/InspectPatientDO.java | 6 + .../inspectpatient/InspectPatientService.java | 8 ++ .../InspectPatientServiceImpl.java | 16 ++- 7 files changed, 146 insertions(+), 11 deletions(-) diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java index c07b580..9118169 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java @@ -75,6 +75,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import cn.iocoder.yudao.module.inspect.service.inspectapplylog.InspectApplylogService; import org.springframework.format.annotation.DateTimeFormat; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; + @Tag(name = "管理后台 - 患者信息") @RestController @RequestMapping("/inspect/patient") @@ -475,14 +477,11 @@ public class InspectPatientController { applylogService.createApplylog(logVO); //获取配置项地址 - //ConfigDO config = configService.getConfigByKey("url.applytj"); + ConfigDO config = configService.getConfigByKey("url.applytj"); // 发送 POST 请求 - //String url = config.getValue(); - //获取头像地址 - //ConfigDO headconfig = configService.getConfigByKey("url.head"); - //String headurl = headconfig.getValue(); + String url = config.getValue(); - //String response = HttpUtils.postJson(url, jsonRequestBody); + String response = HttpUtils.postJson(url, jsonRequestBody); // 记录接口返回值 InspectApplylogSaveReqVO responseLogVO = new InspectApplylogSaveReqVO(); @@ -1230,4 +1229,108 @@ public class InspectPatientController { patientService.isprintupdate(medicalSn, printtime); return success(true); } + + @GetMapping("/generateReport") + @Operation(summary = "生成体检报告") + public CommonResult generateReport(@RequestParam("medicalSn") String medicalSn) { + try { + // 先获取患者信息,检查status + InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn); + if (patientDO == null) { + return success("未找到该患者信息"); + } + + // 检查患者的检查状态 + if (patientDO.getStatus() == null || patientDO.getStatus() != 1) { + return success("患者未完成检查,无法生成报告"); + } + + // 构建请求JSON + Map requestBody = new HashMap<>(); + requestBody.put("medicalSn", medicalSn); + + // 将Map转换为JSON字符串 + ObjectMapper objectMapper = new ObjectMapper(); + String jsonRequestBody = objectMapper.writeValueAsString(requestBody); + + // 发送POST请求 + String url = "http://114.55.171.231:48085/api/report/generate"; + String response = HttpUtils.postJson(url, jsonRequestBody); + if(response!=null) { + // 解析响应,如果成功则保存PDF URL + try { + Map responseMap = objectMapper.readValue(response, Map.class); + if (responseMap != null && responseMap.containsKey("success") && responseMap.get("success").equals(true)) { + // 构建PDF URL + String pdfUrl = "https://114.55.171.231:48082/reportpdfs/" + medicalSn + "-" + patientDO.getPName() + ".pdf"; + + // 更新pdfurl字段 + InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO(); + updateReqVO.setMedicalSn(medicalSn); + updateReqVO.setPdfurl(pdfUrl); + + // 调用服务更新数据 + patientService.updatePatientPdfUrl(updateReqVO); + + return success("报告生成成功,URL已保存: " + pdfUrl); + } + + } catch (Exception e) { + // 如果解析响应失败,仅记录日志但不中断流程 + e.printStackTrace(); + } + } + + return success(response); + } catch (Exception e) { + e.printStackTrace(); + return success("生成报告失败:" + e.getMessage()); + } + } + + @PutMapping("/updateReportUrl") + @Operation(summary = "更新患者体检报告URL") + public CommonResult updateReportUrl(@RequestParam("medicalSn") String medicalSn, + @RequestParam("pdfUrl") String pdfUrl) { + try { + // 获取患者信息 + InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn); + if (patientDO == null) { + return success(false, "未找到该患者信息"); + } + + // 更新pdfurl字段 + InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO(); + updateReqVO.setMedicalSn(medicalSn); + updateReqVO.setPdfurl(pdfUrl); + + // 调用服务更新数据 + patientService.updatePatientPdfUrl(updateReqVO); + + return success(true); + } catch (Exception e) { + e.printStackTrace(); + return success(false, "更新报告URL失败:" + e.getMessage()); + } + } + @GetMapping("/getReportUrl") + @Operation(summary = "获取患者体检报告URL") + public CommonResult getReportUrl(@RequestParam("cardId") String cardId) { + try { + // 根据身份证查询患者信息 + InspectPatientDO patientDO = patientService.getPatientByCardId(cardId); + + // 如果找不到患者记录或者pdfurl为空,返回暂无报告 + if (patientDO == null || patientDO.getPdfurl() == null || patientDO.getPdfurl().trim().isEmpty()) { + // 返回null作为data,并设置msg为"暂无报告" + return success(null, "暂无报告"); + } + + // 返回PDF报告URL到data字段 + return success(patientDO.getPdfurl(), "成功"); + } catch (Exception e) { + e.printStackTrace(); + return success(null, "查询异常:" + e.getMessage()); + } + } } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientPageReqVO.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientPageReqVO.java index 5e14770..0d828a1 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientPageReqVO.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientPageReqVO.java @@ -132,9 +132,12 @@ public class InspectPatientPageReqVO extends PageParam { private LocalDateTime[] printTimeRange; @Schema(description = "总检医生id") - private Integer chiefinspectorid; + private String chiefinspectorid; @Schema(description = "总检医生") private String chiefinspector; + @Schema(description = "报告地址") + private String pdfurl; + } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientRespVO.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientRespVO.java index 6c2fba7..5bb2cd6 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientRespVO.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientRespVO.java @@ -145,7 +145,7 @@ public class InspectPatientRespVO { private LocalDateTime printtime; @Schema(description = "总检医生id") - private Integer chiefinspectorid; + private String chiefinspectorid; @Schema(description = "总检医生") private String chiefinspector; diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientSaveReqVO.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientSaveReqVO.java index 33d4650..e885f49 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientSaveReqVO.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/InspectPatientSaveReqVO.java @@ -118,8 +118,11 @@ public class InspectPatientSaveReqVO { private LocalDateTime printtime; @Schema(description = "总检医生id") - private Integer chiefinspectorid; + private String chiefinspectorid; @Schema(description = "总检医生") private String chiefinspector; + + @Schema(description = "报告地址") + private String pdfurl; } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/dal/dataobject/inspectpatient/InspectPatientDO.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/dal/dataobject/inspectpatient/InspectPatientDO.java index 73661d6..984d0ad 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/dal/dataobject/inspectpatient/InspectPatientDO.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/dal/dataobject/inspectpatient/InspectPatientDO.java @@ -207,5 +207,11 @@ public class InspectPatientDO { @JsonFormat(pattern = "yyyy-MM-dd yyyy-MM-dd HH:mm:ss") private LocalDateTime printtime; + /** + * 报告地址 + */ + @TableField("pdfurl") + private String pdfurl; + } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientService.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientService.java index d492d0a..66816de 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientService.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientService.java @@ -76,6 +76,11 @@ public interface InspectPatientService { * */ InspectPatientDO getPatientInfo(String medicalSn); + /* + * 根据体检编号更新PDF报告URL + * */ + void updatePatientPdfUrl(@Valid InspectPatientSaveReqVO updateReqVO); + /* * 根据体检编号更新数据 * */ @@ -115,4 +120,7 @@ public interface InspectPatientService { * 获取患者体检报告单 */ Map getPatientInspectDataReport(String medicalSn); + + //根据身份证号获取患者信息 + InspectPatientDO getPatientByCardId(String cardId); } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java index 5b528a7..ce73dc8 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/service/inspectpatient/InspectPatientServiceImpl.java @@ -184,8 +184,13 @@ public class InspectPatientServiceImpl implements InspectPatientService { } - - + @Override + public void updatePatientPdfUrl(InspectPatientSaveReqVO updateReqVO) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(InspectPatientDO::getMedicalSn, updateReqVO.getMedicalSn()); + updateWrapper.set(InspectPatientDO::getPdfurl, updateReqVO.getPdfurl()); + patientMapper.update(null, updateWrapper); + } @Override public PageResult getPatientPage(InspectPatientPageReqVO pageReqVO) { @@ -701,4 +706,11 @@ public class InspectPatientServiceImpl implements InspectPatientService { public Map getPatientInspectDataReport(String medicalSn) { return null; } + + @Override + public InspectPatientDO getPatientByCardId(String cardId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectPatientDO::getCardId, cardId); + return patientMapper.selectOne(queryWrapper); + } } \ No newline at end of file