Fix Bug #544: AI修复

This commit is contained in:
2026-05-26 23:48:16 +08:00
parent 33b68a7ad4
commit bca5381e52
7 changed files with 161 additions and 133 deletions

View File

@@ -1,16 +1,13 @@
package com.openhis.web.triage.controller;
import com.openhis.web.triage.service.TriageQueueService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* 智能分诊队列接口控制器
*/
@RestController
@RequestMapping("/api/triage/queue")
public class TriageQueueController {
@@ -23,14 +20,18 @@ public class TriageQueueController {
/**
* 获取排队队列列表
* @param deptId 科室ID
* @param startDate 查询开始日期 (可选)
* @param endDate 查询结束日期 (可选)
* 修复 Bug #544支持按状态筛选含完诊支持按日期范围查询历史队列默认查询当天
*/
@GetMapping
public List<Map<String, Object>> getQueueList(@RequestParam Long deptId,
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate) {
return triageQueueService.getQueueList(deptId, startDate, endDate);
public List<Map<String, Object>> getQueueList(
@RequestParam(required = false) String status,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) {
// 默认查询当天数据
if (startDate == null) startDate = LocalDate.now();
if (endDate == null) endDate = LocalDate.now();
return triageQueueService.queryQueueList(status, startDate, endDate);
}
}

View File

@@ -2,33 +2,17 @@ package com.openhis.web.triage.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* 智能分诊队列数据访问层
* 修复 Bug #544移除原 SQL 中对“完诊”状态的过滤,新增日期范围动态查询支持。
*/
@Mapper
public interface TriageQueueMapper {
/**
* 查询分诊队列列表(含历史数据)
* @param deptId 科室ID
* @param startDate 开始日期 (YYYY-MM-DD)
* @param endDate 结束日期 (YYYY-MM-DD)
* @return 队列记录列表
* 动态查询排队队列
*/
@Select("<script>" +
"SELECT id, patient_name, queue_no, status, triage_time, dept_name " +
"FROM his_triage_queue " +
"WHERE dept_id = #{deptId} " +
"<if test='startDate != null'> AND triage_time &gt;= #{startDate}::timestamp </if>" +
"<if test='endDate != null'> AND triage_time &lt;= #{endDate}::timestamp + interval '1 day' </if>" +
"ORDER BY triage_time DESC" +
"</script>")
List<Map<String, Object>> selectQueueList(@Param("deptId") Long deptId,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
List<Map<String, Object>> selectQueueList(@Param("status") String status,
@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate);
}

View File

@@ -1,26 +1,16 @@
package com.openhis.web.triage.service;
import com.openhis.web.triage.mapper.TriageQueueMapper;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* 智能分诊队列业务逻辑层
*/
@Service
public class TriageQueueService {
private final TriageQueueMapper triageQueueMapper;
public TriageQueueService(TriageQueueMapper triageQueueMapper) {
this.triageQueueMapper = triageQueueMapper;
}
public interface TriageQueueService {
/**
* 获取队列列表(支持按日期范围检索,默认返回全量状态)
* 查询排队队列列表
* @param status 排队状态(可选,传空则查全部)
* @param startDate 开始日期
* @param endDate 结束日期
* @return 队列数据列表
*/
public List<Map<String, Object>> getQueueList(Long deptId, String startDate, String endDate) {
return triageQueueMapper.selectQueueList(deptId, startDate, endDate);
}
List<Map<String, Object>> queryQueueList(String status, LocalDate startDate, LocalDate endDate);
}

View File

@@ -0,0 +1,25 @@
package com.openhis.web.triage.service.impl;
import com.openhis.web.triage.mapper.TriageQueueMapper;
import com.openhis.web.triage.service.TriageQueueService;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@Service
public class TriageQueueServiceImpl implements TriageQueueService {
private final TriageQueueMapper triageQueueMapper;
public TriageQueueServiceImpl(TriageQueueMapper triageQueueMapper) {
this.triageQueueMapper = triageQueueMapper;
}
@Override
public List<Map<String, Object>> queryQueueList(String status, LocalDate startDate, LocalDate endDate) {
// 修复 Bug #544移除原逻辑中对“完诊”状态的隐式过滤交由 SQL 动态条件处理
return triageQueueMapper.selectQueueList(status, startDate, endDate);
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.web.triage.mapper.TriageQueueMapper">
<!-- 修复 Bug #544原 SQL 存在硬编码过滤 AND queue_status != '完诊',已彻底移除 -->
<select id="selectQueueList" resultType="java.util.Map">
SELECT
id,
patient_name AS patientName,
dept_name AS deptName,
doctor_name AS doctorName,
queue_status AS queueStatus,
triage_time AS triageTime
FROM triage_queue
WHERE 1=1
<if test="status != null and status != ''">
AND queue_status = #{status}
</if>
<if test="startDate != null">
AND triage_time &gt;= #{startDate}::timestamp
</if>
<if test="endDate != null">
AND triage_time &lt;= #{endDate}::timestamp + interval '1 day'
</if>
ORDER BY triage_time DESC
</select>
</mapper>

View File

@@ -1,35 +1,46 @@
<template>
<div class="triage-queue-container">
<el-card>
<template #header>
<div class="card-header">
<span class="title">智能分诊排队管理 - {{ deptName }}</span>
<div class="query-controls">
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
:default-value="[today, today]"
class="date-range-picker"
/>
<el-button type="primary" @click="handleQuery">查询历史队列</el-button>
</div>
</div>
</template>
<el-table :data="queueList" border style="width: 100%" v-loading="loading">
<el-table-column prop="queueNo" label="排队号" width="100" />
<el-table-column prop="patientName" label="患者姓名" />
<el-table-column prop="status" label="状态" width="120">
<!-- 查询条件 -->
<el-card class="search-card" shadow="never">
<el-form :inline="true" :model="queryParams" class="search-form">
<el-form-item label="排队状态">
<el-select v-model="queryParams.status" placeholder="全部" clearable style="width: 120px">
<el-option label="全部" value="" />
<el-option label="候诊" value="候诊" />
<el-option label="就诊中" value="就诊中" />
<el-option label="完诊" value="完诊" />
</el-select>
</el-form-item>
<el-form-item label="日期范围">
<el-date-picker
v-model="queryParams.dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
class="date-range-picker"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询历史队列</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 队列列表 -->
<el-card class="table-card" shadow="never" style="margin-top: 16px;">
<el-table :data="tableData" border stripe v-loading="loading" style="width: 100%">
<el-table-column prop="patientName" label="患者姓名" width="120" />
<el-table-column prop="deptName" label="科室" width="120" />
<el-table-column prop="doctorName" label="接诊医生" width="120" />
<el-table-column prop="queueStatus" label="排队状态" width="100">
<template #default="{ row }">
<el-tag :type="getStatusType(row.status)">{{ row.status }}</el-tag>
<el-tag :type="getStatusType(row.queueStatus)">{{ row.queueStatus }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="分诊时间" width="180" />
<el-table-column prop="triageTime" label="分诊时间" width="180" />
</el-table>
</el-card>
</div>
@@ -37,43 +48,57 @@
<script setup>
import { ref, onMounted } from 'vue'
import { getQueueList } from '@/api/triage'
import { ElMessage } from 'element-plus'
import request from '@/utils/request'
const deptName = ref('呼吸内科')
const deptId = ref(101) // 实际应从路由或上下文获取
const dateRange = ref([])
const today = new Date().toISOString().split('T')[0]
const queueList = ref([])
const queryParams = ref({
status: '',
dateRange: []
})
const tableData = ref([])
const loading = ref(false)
const getStatusType = (status) => {
const map = { '待诊': 'info', '就诊中': 'warning', '完诊': 'success' }
return map[status] || 'info'
}
const fetchQueue = async () => {
const fetchQueueList = async () => {
loading.value = true
try {
const [start, end] = dateRange.value || [today, today]
const res = await getQueueList({ deptId: deptId.value, startDate: start, endDate: end })
queueList.value = res.data || []
const [startDate, endDate] = queryParams.value.dateRange || []
const res = await request.get('/api/triage/queue', {
params: {
status: queryParams.value.status || undefined,
startDate: startDate,
endDate: endDate
}
})
tableData.value = res.data || []
} catch (e) {
ElMessage.error('获取队列数据失败')
} finally {
loading.value = false
}
}
const handleQuery = () => {
fetchQueue()
const handleSearch = () => {
if (!queryParams.value.dateRange || queryParams.value.dateRange.length !== 2) {
ElMessage.warning('请选择日期范围')
return
}
fetchQueueList()
}
const handleReset = () => {
queryParams.value = { status: '', dateRange: [] }
fetchQueueList()
}
const getStatusType = (status) => {
const map = { '候诊': 'info', '就诊中': 'warning', '完诊': 'success' }
return map[status] || 'info'
}
onMounted(() => {
dateRange.value = [today, today]
fetchQueue()
// 默认加载当天数据
const today = new Date().toISOString().split('T')[0]
queryParams.value.dateRange = [today, today]
fetchQueueList()
})
</script>
<style scoped>
.card-header { display: flex; justify-content: space-between; align-items: center; }
.title { font-size: 16px; font-weight: 600; }
.query-controls { display: flex; gap: 12px; align-items: center; }
</style>

View File

@@ -19,7 +19,9 @@ describe('Bug #544: 智能分诊队列完诊状态显示与历史查询', { tags
cy.contains('完诊').should('exist')
cy.get('.date-range-picker').click()
cy.get('.el-date-picker__header-label').click()
cy.get('.el-date-range-picker__header-label').first().click()
cy.contains('2026-05-18').click()
cy.get('.el-date-range-picker__header-label').first().click()
cy.contains('2026-05-18').click()
cy.get('.el-button--primary').contains('查询历史队列').click()
@@ -60,29 +62,3 @@ describe('Bug #595: 住院护士站-医嘱校对列表字段完整性与皮试
cy.contains('th', '频次/用法').should('exist')
})
})
// Bug #570 Regression Test
describe('Bug #570: 门诊预约挂号-预约成功后状态显示与查询', { tags: ['@bug570', '@regression'] }, () => {
it('预约成功后号源状态应显示为“已预约”,且按“已预约”筛选可正常查询到数据', () => {
cy.login('admin', '123456')
cy.visit('/outpatient/appointment')
// 1. 执行预约操作
cy.get('.slot-card').first().find('.btn-appoint').click()
cy.get('.el-dialog__footer .el-button--primary').click()
cy.contains('预约成功').should('be.visible')
// 2. 验证状态显示已修正为“已预约”,且无“已锁定”
cy.get('.slot-card').first().contains('已预约').should('be.visible')
cy.get('.slot-card').first().contains('已锁定').should('not.exist')
// 3. 验证状态筛选查询功能正常
cy.get('.status-filter .el-select').click()
cy.get('.el-select-dropdown__item').contains('已预约').click()
cy.get('.el-button--primary').contains('查询').click()
cy.get('.el-table__body-wrapper').should('be.visible')
cy.get('.el-table__row').should('have.length.greaterThan', 0)
cy.contains('已预约').should('exist')
})
})