Files
zyt/CHECK_ROSTER_DATA.sql
T
2026-03-04 15:32:30 +08:00

170 lines
3.5 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 检查医生排班数据的SQL脚本
-- 1. 检查医生ID=3的所有排班
SELECT
id,
doctor_id,
date,
period,
CASE period
WHEN 1 THEN '上午'
WHEN 2 THEN '下午'
ELSE '未知'
END as period_name,
status,
CASE status
WHEN 1 THEN '出诊'
WHEN 2 THEN '停诊'
WHEN 3 THEN '休息'
WHEN 4 THEN '请假'
ELSE '未知'
END as status_name,
quota,
max_patients,
booked_count,
create_time,
update_time
FROM zyt_doctor_roster
WHERE doctor_id = 3
ORDER BY date ASC, period ASC;
-- 2. 检查医生ID=3在2026-03-06的排班
SELECT
id,
doctor_id,
date,
period,
CASE period
WHEN 1 THEN '上午'
WHEN 2 THEN '下午'
ELSE '未知'
END as period_name,
status,
CASE status
WHEN 1 THEN '出诊'
WHEN 2 THEN '停诊'
WHEN 3 THEN '休息'
WHEN 4 THEN '请假'
ELSE '未知'
END as status_name,
quota,
max_patients,
booked_count
FROM zyt_doctor_roster
WHERE doctor_id = 3
AND date = '2026-03-06';
-- 3. 检查医生ID=3在2026-03-06的出诊排班(status=1
SELECT
id,
doctor_id,
date,
period,
CASE period
WHEN 1 THEN '上午'
WHEN 2 THEN '下午'
ELSE '未知'
END as period_name,
status,
quota,
max_patients,
booked_count
FROM zyt_doctor_roster
WHERE doctor_id = 3
AND date = '2026-03-06'
AND status = 1;
-- 4. 检查医生ID=3在2026-03-04到2026-03-06的所有排班
SELECT
date,
period,
CASE period
WHEN 1 THEN '上午'
WHEN 2 THEN '下午'
ELSE '未知'
END as period_name,
status,
CASE status
WHEN 1 THEN '出诊'
WHEN 2 THEN '停诊'
WHEN 3 THEN '休息'
WHEN 4 THEN '请假'
ELSE '未知'
END as status_name,
quota,
max_patients,
booked_count
FROM zyt_doctor_roster
WHERE doctor_id = 3
AND date BETWEEN '2026-03-04' AND '2026-03-06'
ORDER BY date ASC, period ASC;
-- 5. 如果没有数据,添加测试数据
-- 取消下面的注释来添加测试排班
/*
-- 添加医生ID=3在2026-03-06的排班
INSERT INTO zyt_doctor_roster (
doctor_id,
date,
period,
status,
quota,
max_patients,
booked_count,
create_time,
update_time
) VALUES
-- 上午出诊
(3, '2026-03-06', 1, 1, 20, 20, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
-- 下午出诊
(3, '2026-03-06', 2, 1, 20, 20, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
*/
-- 6. 检查医生ID=3在2026-03-06的预约情况
SELECT
id,
doctor_id,
patient_id,
appointment_date,
appointment_time,
status,
CASE status
WHEN 1 THEN '已预约'
WHEN 2 THEN '已取消'
WHEN 3 THEN '已完成'
ELSE '未知'
END as status_name,
create_time
FROM zyt_doctor_appointment
WHERE doctor_id = 3
AND appointment_date = '2026-03-06'
ORDER BY appointment_time ASC;
-- 7. 统计医生ID=3的排班情况
SELECT
status,
CASE status
WHEN 1 THEN '出诊'
WHEN 2 THEN '停诊'
WHEN 3 THEN '休息'
WHEN 4 THEN '请假'
ELSE '未知'
END as status_name,
COUNT(*) as count
FROM zyt_doctor_roster
WHERE doctor_id = 3
GROUP BY status;
-- 8. 检查所有医生的基本信息
SELECT
a.id,
a.name,
a.account,
ar.role_id,
a.disable
FROM zyt_admin a
INNER JOIN zyt_admin_role ar ON a.id = ar.admin_id
WHERE ar.role_id = 1
ORDER BY a.id ASC;