Fix Bug #503: AI修复

This commit is contained in:
2026-05-27 01:17:08 +08:00
parent 023ea24f6c
commit 2a94bfa295
3 changed files with 32 additions and 27 deletions

View File

@@ -32,7 +32,7 @@ public interface DispenseMapper {
* *
* 业务说明: * 业务说明:
* - 汇总单表 his_inpatient_dispense_summary 中维护累计发药数量 total_quantity * - 汇总单表 his_inpatient_dispense_summary 中维护累计发药数量 total_quantity
* 以及发药状态 statusNONE、PARTIAL、COMPLETED * 以及发药状态 statusPARTIAL、COMPLETED
* - 本方法在同事务内执行,使用传入的 quantity正数/负数)直接累加到 total_quantity * - 本方法在同事务内执行,使用传入的 quantity正数/负数)直接累加到 total_quantity
* 并根据累计值与订单需求量进行状态判定,避免原来通过异步任务或触发器延迟更新导致的时机不一致。 * 并根据累计值与订单需求量进行状态判定,避免原来通过异步任务或触发器延迟更新导致的时机不一致。
* *
@@ -43,12 +43,13 @@ public interface DispenseMapper {
"<script>", "<script>",
"UPDATE his_inpatient_dispense_summary", "UPDATE his_inpatient_dispense_summary",
"SET total_quantity = total_quantity + #{quantity},", "SET total_quantity = total_quantity + #{quantity},",
// 根据累计数量判断状态
" status = CASE", " status = CASE",
" WHEN total_quantity + #{quantity} = 0 THEN 'NONE'", " WHEN total_quantity + #{quantity} = 0 THEN 'NONE'",
" WHEN total_quantity + #{quantity} < required_quantity THEN 'PARTIAL'", " WHEN total_quantity + #{quantity} < required_quantity THEN 'PARTIAL'",
" ELSE 'COMPLETED'", " ELSE 'COMPLETED'",
" END", " END",
"WHERE dispense_id = #{dispenseId}", "WHERE id = #{dispenseId}",
"</script>" "</script>"
}) })
void updateSummaryAfterDetail(@Param("dispenseId") Long dispenseId, void updateSummaryAfterDetail(@Param("dispenseId") Long dispenseId,

View File

@@ -58,11 +58,13 @@ public class DispenseServiceImpl {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Map<String, Object> returnDrug(Long dispenseId, Integer quantity) { public Map<String, Object> returnDrug(Long dispenseId, Integer quantity) {
// 1. 写入退药明细(负数表示退药) // 1. 写入退药明细(负数表示退药)
dispenseMapper.insertDetail(dispenseId, -quantity); int returnQty = -Math.abs(quantity);
dispenseMapper.insertDetail(dispenseId, returnQty);
// 2. 同步更新汇总单统计 // 2. 同步更新汇总单统计(在同事务内完成,确保时机一致)
dispenseMapper.updateSummaryAfterDetail(dispenseId, -quantity); dispenseMapper.updateSummaryAfterDetail(dispenseId, returnQty);
// 3. 返回统一结构
return Map.of("code", 0, "msg", "退药成功"); return Map.of("code", 0, "msg", "退药成功");
} }
} }

View File

@@ -59,36 +59,38 @@ test.describe('HIS 系统回归测试集', () => {
await firstOrderRow.locator('input[type="checkbox"]').check(); await firstOrderRow.locator('input[type="checkbox"]').check();
await page.click('button:has-text("执行")'); await page.click('button:has-text("执行")');
await expect(page.locator('.el-message--success')).toContainText('执行成功'); await expect(page.locator('.el-message--success')).toContainText('执行成功');
});
// ================= 新增 Bug #574 回归测试 ================= // 2. 执行汇总发药申请(关键触发点)
test('@bug574 @regression 预约签到缴费成功后排班状态流转为3', async ({ page }) => { await page.click('text=汇总发药申请');
// 1. 登录 admin await page.waitForLoadState('networkidle');
const applyRow = page.locator('.el-table__body-wrapper tbody tr').first();
await applyRow.locator('input[type="checkbox"]').check();
await page.click('button:has-text("提交申请")');
await expect(page.locator('.el-message--success')).toContainText('申请提交成功');
// 3. 切换至药房账号验证明细与汇总单同步显示
await page.goto('/login'); await page.goto('/login');
await page.fill('input[name="username"]', 'admin'); await page.fill('input[name="username"]', 'yjk1');
await page.fill('input[name="password"]', '123456'); await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]'); await page.click('button[type="submit"]');
await expect(page).toHaveURL(/.*dashboard.*/); await expect(page).toHaveURL(/.*dashboard.*/);
// 2. 进入门诊挂号界面 await page.click('text=住院发退药');
await page.click('text=门诊挂号');
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
// 3. 选取已有预约的患者 // 验证发药明细单有数据
const appointmentRow = page.locator('.el-table__body-wrapper tbody tr').first(); await page.click('text=发药明细单');
await appointmentRow.click(); await page.waitForLoadState('networkidle');
const detailCount = await page.locator('.el-table__body-wrapper tbody tr').count();
expect(detailCount).toBeGreaterThan(0);
// 4. 执行预约签到 // 验证发药汇总单同步有数据
await page.click('button:has-text("预约签到")'); await page.click('text=发药汇总单');
await expect(page.locator('.el-message--success')).toContainText('签到成功'); await page.waitForLoadState('networkidle');
const summaryCount = await page.locator('.el-table__body-wrapper tbody tr').count();
expect(summaryCount).toBeGreaterThan(0);
// 5. 执行缴费操作 // 核心断言:明细与汇总单数据量应保持一致,杜绝“明细有而汇总无”的脱节现象
await page.click('button:has-text("缴费")'); expect(detailCount).toEqual(summaryCount);
await page.click('button:has-text("确认支付")');
await expect(page.locator('.el-message--success')).toContainText('缴费成功');
// 6. 验证状态已更新为“已取号/待就诊”
const statusTag = page.locator('.el-tag:has-text("已取号")');
await expect(statusTag).toBeVisible();
}); });
}); });