26-7-31-1

This commit is contained in:
shuai
2026-07-31 12:27:41 +08:00
commit 9b8b8b57b3
142 changed files with 22408 additions and 0 deletions
+213
View File
@@ -0,0 +1,213 @@
# 智慧医院管理系统 - 项目探索报告
> 生成日期:2026-07-22
> 项目路径:`E:\桌面\实训项目\smart-hospital`
---
## 1. 项目概述
一个基于 **Spring Boot** 的教学/实训级 Web 应用,融合 **AI 辅助诊断** 概念,覆盖医院核心业务链条:
**登录 → 患者管理 → 影像检查 + AI 诊断 → 电子病历 + AI 辅助决策**
规模轻量:源码约 **43 KB**,共 **23 个 Java 文件** + **5 个 Thymeleaf 页面**。
> ⚠️ AI 部分为**规则模拟实现**——通过关键字匹配和随机结果生成,并非真实模型调用,属于教学演示性质。
---
## 2. 技术栈
### 后端
- **语言**:Java 17
- **框架**:Spring Boot 2.7.0(Spring MVC、Spring Data JPA、`@EnableAsync`)
- **ORM**:Hibernate(JPA 注解),`ddl-auto: update`
- **数据库**:MySQL 8.0.33(`com.mysql.cj.jdbc.Driver`)
- **工具库**:Lombok(`@Data`)、Gson 2.9.0
- **构建**:Maven(含 `mvnw` 包装脚本)
- **并发**:`ExecutorService` 固定线程池(5 线程)+ `CompletableFuture`
### 前端
- **模板引擎**:Thymeleaf(服务端渲染)
- **UI 框架**:Bootstrap 5.3.0(CDN 引入)
- **交互**:原生 JavaScript `fetch` 调用 REST 接口,轮询获取诊断结果
### 未使用
Spring Security、Redis、Swagger、MyBatis、Vue/React
---
## 3. 项目结构
```
smart-hospital/
├── smart——hospital.sql # 数据库初始化脚本
└── smart-hospital/ # Maven 项目根
├── pom.xml
├── mvnw, mvnw.cmd
├── src/main/java/com/hospital/
│ ├── SmartHospitalApplication.java # 启动类
│ ├── controller/ # 3 个 Controller
│ ├── service/ # 2 个 Service
│ ├── model/ # 11 个实体/DTO
│ └── repository/ # 6 个 JPA Repository
├── src/main/resources/
│ ├── application.yml
│ └── templates/ # 5 个 Thymeleaf 页面
└── src/test/java/com/hospital/
└── SmartHospitalApplicationTests.java
```
---
## 4. 核心模块 / 功能
### 页面模块(Thymeleaf)
| 路径 | 功能 |
|---|---|
| `/login` | 登录/登出(测试账号 `doctor1 / pass123`) |
| `/dashboard` | 仪表盘(患者/影像/病历计数) |
| `/patients` | 患者列表(分页) |
| `/imaging` | 影像检查记录 + AI 诊断触发 + 结果轮询 |
| `/emrs` | 电子病历列表 |
### 业务模块
- **用户与权限**:三种角色 `DOCTOR / RADIOLOGIST / ADMIN`,权限仅通过 `HttpSession` 判断登录状态
- **患者管理**:CRUD 骨架(当前仅列表查询)
- **影像诊断(AI)**:异步任务 `PENDING → ANALYZING → COMPLETED / ERROR`,返回诊断文本 + 置信度(85%-99%)
- **电子病历 + 决策支持**:新建 EMR 时联动生成治疗方案、用药建议、风险评估、药物冲突提示
---
## 5. 数据库设计(6 张表)
数据库 `smart_hospital`(utf8mb4):
| 表名 | 用途 | 关键字段 |
|---|---|---|
| `users` | 医护用户 | `role`(DOCTOR/RADIOLOGIST/ADMIN),`username` 唯一 |
| `patients` | 患者 | `gender`、`id_card` 唯一 |
| `imaging_records` | 影像检查记录 | `study_type`(X_RAY/CT/MRI/ULTRASOUND)、`status`、`ai_diagnosis`、`ai_confidence` |
| `ai_diagnosis_results` | AI 诊断结果 | `diagnosis_text`、`confidence_score`、`findings`、`recommendations`、`model_version` |
| `electronic_medical_records` | 电子病历 | 主诉/现病史/查体/诊断/治疗方案/用药/随访/AI 建议 |
| `decision_support_records` | 辅助决策记录 | `query_text`、`ai_response`、`doctor_feedback` |
### 关系简图
```
users ─┐
├─→ imaging_records → ai_diagnosis_results
patients ─┘
users ─┐
├─→ electronic_medical_records → decision_support_records
patients ─┘
```
---
## 6. API 接口
### REST 接口(`@RestController`,均带 `@CrossOrigin(origins = "*")`)
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | `/api/ai-diagnosis/analyze/{recordId}` | 提交某条影像记录的 AI 诊断任务(异步) |
| GET | `/api/ai-diagnosis/result/{recordId}` | 查询 AI 诊断结果 |
| POST | `/api/emr/create` | 创建电子病历 + 返回 AI 辅助决策 |
| GET | `/api/emr/{emrId}/ai-suggestions` | 获取指定病历的 AI 决策建议 |
### 页面路由
`GET /login`、`POST /login`、`GET /logout`、`GET /dashboard`、`GET /patients`、`GET /imaging`、`GET /emrs`(均支持 `page`、`size` 分页参数)
---
## 7. 配置说明
**关键配置**(`application.yml`):
- MySQL:`jdbc:mysql://localhost:3306/smart_hospital`,`root / 123456`
- JPA:`ddl-auto: update`,`show-sql: false`
- Server 端口:`8080`
- 自定义参数(**目前代码中未被读取**):
- `ai.diagnosis.enabled`、`max-concurrent-tasks: 5`、`timeout-seconds: 300`、`confidence-threshold: 0.85`
- `imaging.storage.path: ./uploads/images`、`max-file-size: 50MB`
---
## 8. 构建与运行
**先决条件**:JDK 17、MySQL 8.x(默认 `root / 123456`)
**步骤**:
1. 执行 `smart——hospital.sql` 初始化数据库
2. 在项目根下运行:
```powershell
mvnw.cmd spring-boot:run
```
或打包后运行:
```powershell
mvnw.cmd package
java -jar target/smart-hospital-1.0.0.jar
```
3. 打开 `http://localhost:8080/login`,账号 `doctor1 / pass123`
**缺失**:无 `README.md`、无 Docker / CI 配置。
---
## 9. 代码规模
| 分类 | 数量 |
|---|---|
| Java 源文件 | 23(Application 1、Controller 3、Service 2、Model 11、Repository 6、Test 1) |
| Thymeleaf 模板 | 5 |
| 配置文件 | `application.yml` + `pom.xml` |
| SQL 脚本 | 1(约 100 行) |
| **源码总量** | **约 43 KB** |
---
## 10. 技术亮点与潜在问题
### ✅ 亮点
- **分层清晰**:Controller / Service / Repository / Model 四层结构标准
- **异步处理**:AI 诊断走 `@EnableAsync` + `CompletableFuture` + 独立线程池
- **前端轮询**:`imaging.html` 用定时 `fetch` 轮询任务状态,交互思路完整
- **数据库设计合理**:外键、枚举、时间戳完善
- **Lombok** 简化了实体样板代码
### ⚠️ 潜在问题
| 问题 | 说明 |
|---|---|
| **AI 是伪实现** | 关键字 + `Math.random()` 生成结果;`model_version` 硬编码 `"AI-DIAG-V2.1"` |
| **安全性差** | 密码明文存储;未使用 Spring Security;`@CrossOrigin(*)` 全开 |
| **权限缺失** | 角色定义了,但业务代码不区分角色 |
| **登录效率低** | `userRepository.findAll().stream()` 全表遍历比对用户名 |
| **配置未落地** | `ai.diagnosis.*`、`imaging.storage.*` 无 `@Value` / `@ConfigurationProperties` 读取 |
| **线程池未托管** | 手动 `new`,未在应用关闭时优雅停止 |
| **缺少全局异常处理** | Controller 直接 `throw RuntimeException` |
| **业务功能不完整** | 只有列表查询页面,缺新增/编辑/删除、影像上传等 UI |
| **测试极简** | 仅一个空的 `contextLoads()` |
| **文件命名瑕疵** | SQL 文件名用了**中文破折号** `——`,跨平台易出错 |
| **`target/` 已提交** | 编译产物被跟踪进版本控制 |
---
## 11. 关键文件路径速查
| 文件 | 路径 |
|---|---|
| 启动类 | `smart-hospital\src\main\java\com\hospital\SmartHospitalApplication.java` |
| 配置 | `smart-hospital\src\main\resources\application.yml` |
| 构建 | `smart-hospital\pom.xml` |
| 数据库脚本 | `smart——hospital.sql` |
| AI 诊断服务 | `smart-hospital\src\main\java\com\hospital\service\AIDiagnosisService.java` |
| 决策支持服务 | `smart-hospital\src\main\java\com\hospital\service\DecisionSupportService.java` |
| 页面控制器 | `smart-hospital\src\main\java\com\hospital\controller\PageController.java` |
---
## 12. 总体评价
一个**结构规范、覆盖完整业务链条**的教学演示项目。核心技术栈标准(Spring Boot + JPA + Thymeleaf + MySQL),业务模型设计得体,但在**安全、权限、真实 AI 能力、异常处理和 CRUD 完整度**方面都存在明显扩展空间。
**非常适合作为二次开发或课程改造的起点。**