From 42f75de9034b87cf669e669389c85d19ffeba9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BD=97?= <华佗@gentronhealth.com> Date: Sun, 17 May 2026 13:32:34 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#516:=20=E6=A0=B9=E5=9B=A0+?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B9=E6=A1=88=E6=91=98=E8=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUG516_ANALYSIS.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 BUG516_ANALYSIS.md diff --git a/BUG516_ANALYSIS.md b/BUG516_ANALYSIS.md new file mode 100644 index 000000000..acf1ffac2 --- /dev/null +++ b/BUG516_ANALYSIS.md @@ -0,0 +1,61 @@ +# Bug #516 深度分析报告 + +## Bug 描述 +[住院医生站-临床医嘱-检验申请] 检验申请单手动填写的"发往科室"与生成的医嘱执行科室不一致 + +## 根因分析 + +### 前端 Bug(`laboratoryTests.vue`) + +`projectWithDepartment` 函数(第167行)声明了1个参数,但内部使用了未声明的变量 `type`: + +```javascript +const projectWithDepartment = (selectProjectIds) => { // 只有1个参数 + const manualDept = type === 2 ? form.targetDepartment : ''; // type 未声明! + ... + if (type === 2 && manualDept) { // type 未声明! +``` + +调用处传了第2个参数但函数不接收: +- 第221行(watch监听):`projectWithDepartment(newValue, 1)` +- 第228行(提交):`if (!projectWithDepartment(transferValue.value, 2))` + +**后果**: +1. `type` 始终为 `undefined`,`type === 2` 永远为 false +2. `manualDept` 永远为空字符串 +3. 用户手动选择的"发往科室"在提交时被清空 +4. 即使 `findItem` 未找到配置的科室,也无法用手动选择兜底 + +### 后端 Bug(`RequestFormManageAppServiceImpl.java`) + +第165-171行: + +```java +Long positionId = activityOrganizationConfig.stream() + .filter(dto -> activitySaveDto.getAdviceDefinitionId().equals(dto.getActivityDefinitionId())) + .map(ActivityOrganizationConfigDto::getOrganizationId).findFirst().orElse(null); +if (positionId == null) { + throw new ServiceException(activitySaveDto.getAdviceDefinitionName() + "未配置当前时间段的执行科室"); +} +serviceRequest.setOrgId(positionId); // 完全忽略前端传的 positionId! +``` + +后端从配置表 `adm_organization_location` 查找执行科室,完全无视前端传来的 `activitySaveDto.positionId`(即用户手动选择的"发往科室")。 + +### 数据流 + +1. 用户在前端选择检验项目 → 触发watch → `projectWithDepartment` 尝试自动设置科室 +2. 用户手动切换"发往科室"下拉框 → `form.targetDepartment` = 肝胆科ID +3. 用户点击提交 → `projectWithDepartment(transferValue.value, 2)` 调用 +4. 因 `type` 未声明,手动选择的科室被清空 → `form.targetDepartment` = '' +5. 前端构建提交参数:`positionId: item.positionId || form.targetDepartment` → 空值 +6. 后端收到请求,从配置表查默认科室(检验科) → `serviceRequest.setOrgId(检验科)` +7. 医嘱列表中"药房/科室"列显示检验科,而非用户选择的肝胆科 + +## 修复方案 + +### 前端修复(1行改动) +在 `projectWithDepartment` 函数签名中添加 `type` 参数。 + +### 后端修复(3行改动) +优先使用前端传来的 `positionId`,配置表作为兜底值。