From 767afe483f7bde1c438deb17e97ec44eb9ff2e58 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期六, 17 一月 2026 10:03:36 +0800
Subject: [PATCH] 检测信息导出
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 218 insertions(+), 4 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java
index ba38508..7eddf6a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysInspectionController.java
@@ -8,10 +8,13 @@
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.TCrmClinic;
+import com.ruoyi.system.model.TSysAppUser;
import com.ruoyi.system.model.TSysInspection;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.TCrmClinicService;
+import com.ruoyi.system.service.TSysAppUserService;
import com.ruoyi.system.service.TSysInspectionService;
+import com.ruoyi.web.controller.tool.WordUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,9 +23,7 @@
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
/**
* <p>
@@ -41,12 +42,16 @@
private final TokenService tokenService;
private final TCrmClinicService crmClinicService;
private final ISysUserService sysUserService;
+ private final TSysAppUserService sysAppUserService;
+ private final WordUtil wordUtil;
@Autowired
- public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TCrmClinicService crmClinicService, ISysUserService sysUserService) {
+ public TSysInspectionController(TSysInspectionService sysInspectionService, TokenService tokenService, TCrmClinicService crmClinicService, ISysUserService sysUserService, TSysAppUserService sysAppUserService, WordUtil wordUtil) {
this.sysInspectionService = sysInspectionService;
this.tokenService = tokenService;
this.crmClinicService = crmClinicService;
this.sysUserService = sysUserService;
+ this.sysAppUserService = sysAppUserService;
+ this.wordUtil = wordUtil;
}
// /**
@@ -143,5 +148,214 @@
return R.ok(sysInspectionService.removeByIds(ids));
}
+ @Log(title = "用户检测信息管理信息-导出检测信息", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "导出检测信息")
+ @GetMapping(value = "/exportInspection")
+ public R<String> exportInspection(@RequestParam String id) {
+ TSysInspection sysInspection = sysInspectionService.getById(id);
+ // 查询诊所信息
+ TCrmClinic crmClinic = crmClinicService.getById(sysInspection.getClinicId());
+ if(Objects.isNull(crmClinic)){
+ return R.fail("诊所信息不存在");
+ }
+ Map<String, Object> templateParam = new HashMap<>();
+ fill(templateParam, "clinicName", crmClinic.getClinicName());
+ // 住院次数
+ if(StringUtils.hasLength(sysInspection.getHospitalizationCount())){
+ fill(templateParam, "hospitalizationCount", sysInspection.getHospitalizationCount());
+ }
+ // 住院编号
+ if(StringUtils.hasLength(sysInspection.getHospitalizationNumber())){
+ fill(templateParam, "hospitalizationNumber", sysInspection.getHospitalizationNumber());
+ }
+ // 姓名
+ if(StringUtils.hasLength(sysInspection.getNickName())){
+ fill(templateParam, "nickName", sysInspection.getNickName());
+ }
+ // 出生地
+ if(StringUtils.hasLength(sysInspection.getBirthplace())){
+ fill(templateParam, "birthplace", sysInspection.getBirthplace());
+ }
+ // 性别
+ if(Objects.nonNull(sysInspection.getSex())){
+ if(sysInspection.getSex() == 1){
+ fill(templateParam, "sex", "男");
+ }else{
+ fill(templateParam, "sex", "女");
+ }
+ }
+ // 民族
+ if(StringUtils.hasLength(sysInspection.getNation())){
+ fill(templateParam, "nation", sysInspection.getNation());
+ }
+ // 年龄
+ if(Objects.nonNull(sysInspection.getAge())){
+ fill(templateParam, "age", sysInspection.getAge());
+ }
+ // 入院日期
+ if(StringUtils.hasLength(sysInspection.getAdmissionDate())){
+ fill(templateParam, "admissionDate", sysInspection.getAdmissionDate());
+ }
+ // 婚姻状况
+ if(Objects.nonNull(sysInspection.getMaritalStatus())){
+ fill(templateParam, "maritalStatus", sysInspection.getMaritalStatus());
+ }
+ // 记录日期
+ if(StringUtils.hasLength(sysInspection.getRecordDate())){
+ fill(templateParam, "recordDate", sysInspection.getRecordDate());
+ }
+ // 职业
+ if(StringUtils.hasLength(sysInspection.getOccupation())){
+ fill(templateParam, "occupation", sysInspection.getOccupation());
+ }
+ // 病史陈述者
+ if(StringUtils.hasLength(sysInspection.getHistoryNarrator())){
+ fill(templateParam, "historyNarrator", sysInspection.getHistoryNarrator());
+ }
+ // 主诉
+ if(StringUtils.hasLength(sysInspection.getChiefComplaint())){
+ fill(templateParam, "chiefComplaint", sysInspection.getChiefComplaint());
+ }
+ // 现病史
+ if(StringUtils.hasLength(sysInspection.getPresentHistory())){
+ fill(templateParam, "presentHistory", sysInspection.getPresentHistory());
+ }
+ // 既往史
+ if(StringUtils.hasLength(sysInspection.getPastMedicalHistory())){
+ fill(templateParam, "pastMedicalHistory", sysInspection.getPastMedicalHistory());
+ }
+ // 月经史
+ if(StringUtils.hasLength(sysInspection.getMenstrualHistory())){
+ fill(templateParam, "menstrualHistory", sysInspection.getMenstrualHistory());
+ }
+ // 婚育史
+ if(StringUtils.hasLength(sysInspection.getObstetricHistory())){
+ fill(templateParam, "obstetricHistory", sysInspection.getObstetricHistory());
+ }
+ // 家族史
+ if(StringUtils.hasLength(sysInspection.getFamilyHistory())){
+ fill(templateParam, "familyHistory", sysInspection.getFamilyHistory());
+ }
+ // 体温
+ if(StringUtils.hasLength(sysInspection.getBodyTemperature())){
+ fill(templateParam, "bodyTemperature", sysInspection.getBodyTemperature());
+ }
+ // 脉搏
+ if(StringUtils.hasLength(sysInspection.getPulse())){
+ fill(templateParam, "pulse", sysInspection.getPulse());
+ }
+ // 呼吸
+ if(StringUtils.hasLength(sysInspection.getBreathe())){
+ fill(templateParam, "breathe", sysInspection.getBreathe());
+ }
+ // 血压
+ if(StringUtils.hasLength(sysInspection.getBloodPressure())){
+ fill(templateParam, "bloodPressure", sysInspection.getBloodPressure());
+ }
+ // 一般情况
+ if(StringUtils.hasLength(sysInspection.getGeneralSituation())){
+ fill(templateParam, "generalSituation", sysInspection.getGeneralSituation());
+ }
+
+ String url = wordUtil.generatePdf(
+ "/usr/local/project/template/",
+ "病历-样例.docx",
+ templateParam,
+ "病历-"+sysInspection.getNickName(),
+ "/usr/local/project/template/");
+ // windows
+// String url = wordUtil.generatePdf(
+// "E:\\WXWork\\1688857451467088\\Cache\\File\\2026-01\\",
+// "病历-样例.docx",
+// templateParam,
+// "病历-样例-temp",
+// "E:\\WXWork\\1688857451467088\\Cache\\File\\2026-01\\");
+ return R.ok(url);
+ }
+
+ @Log(title = "用户检测信息管理信息-导出处方信息", businessType = BusinessType.UPDATE)
+ @ApiOperation(value = "导出处方信息")
+ @GetMapping(value = "/exportPrescription")
+ public R<String> exportPrescription(@RequestParam String id) {
+ TSysInspection sysInspection = sysInspectionService.getById(id);
+ // 查询诊所信息
+ TCrmClinic crmClinic = crmClinicService.getById(sysInspection.getClinicId());
+ if(Objects.isNull(crmClinic)){
+ return R.fail("诊所信息不存在");
+ }
+ Map<String, Object> templateParam = new HashMap<>();
+ fill(templateParam, "clinicName", crmClinic.getClinicName());
+ // 住院编号
+ if(StringUtils.hasLength(sysInspection.getPrescriptionNumber())){
+ fill(templateParam, "prescriptionNumber", sysInspection.getPrescriptionNumber());
+ }
+ // 科室
+ if(StringUtils.hasLength(sysInspection.getDepartmentName())){
+ fill(templateParam, "departmentName", sysInspection.getDepartmentName());
+ }
+ // 处方时间
+ if(StringUtils.hasLength(sysInspection.getPrescriptionTime())){
+ fill(templateParam, "prescriptionTime", sysInspection.getPrescriptionTime());
+ }
+ // 姓名
+ if(StringUtils.hasLength(sysInspection.getNickName())){
+ fill(templateParam, "nickName", sysInspection.getNickName());
+ }
+ // 性别
+ if(Objects.nonNull(sysInspection.getSex())){
+ if(sysInspection.getSex() == 1){
+ fill(templateParam, "sex", "男");
+ }else{
+ fill(templateParam, "sex", "女");
+ }
+ }
+ // 年龄
+ if(Objects.nonNull(sysInspection.getAge())){
+ fill(templateParam, "age", sysInspection.getAge());
+ }
+ // 门诊病历号
+ if(StringUtils.hasLength(sysInspection.getId())){
+ fill(templateParam, "id", sysInspection.getId());
+ }
+ // 单位或家庭住址
+ if(Objects.nonNull(sysInspection.getHomeAddress())){
+ fill(templateParam, "homeAddress", sysInspection.getHomeAddress());
+ }
+ // 临床诊断及证型
+ if(StringUtils.hasLength(sysInspection.getClinicalDiagnosis())){
+ fill(templateParam, "clinicalDiagnosis", sysInspection.getClinicalDiagnosis());
+ }
+ // 处方内容
+ if(StringUtils.hasLength(sysInspection.getPrescriptionContent())){
+ fill(templateParam, "prescriptionContent", sysInspection.getPrescriptionContent());
+ }
+ // 备注
+ if(StringUtils.hasLength(sysInspection.getRemarks())){
+ fill(templateParam, "remarks", sysInspection.getRemarks());
+ }
+
+ String url = wordUtil.generatePdf(
+ "/usr/local/project/template/",
+ "处方单-样例.docx",
+ templateParam,
+ "处方单-"+sysInspection.getNickName(),
+ "/usr/local/project/template/");
+ // windows
+// String url = wordUtil.generatePdf(
+// "E:\\WXWork\\1688857451467088\\Cache\\File\\2026-01\\",
+// "处方单-样例.docx",
+// templateParam,
+// "处方单-样例-temp",
+// "E:\\WXWork\\1688857451467088\\Cache\\File\\2026-01\\");
+ return R.ok(url);
+ }
+
+ private void fill(Map<String, Object> templateParam, String key, Object value) {
+ if (com.ruoyi.common.utils.StringUtils.isEmpty(key)){
+ throw new RuntimeException("key不能为空");
+ }
+ templateParam.put("${"+key+"}", value != null ? value : "");
+ }
+
}
--
Gitblit v1.7.1