Merge develop into test - sync latest code

This commit is contained in:
2026-04-10 12:31:19 +08:00
1255 changed files with 107256 additions and 24904 deletions

71
test_fix.js Normal file
View File

@@ -0,0 +1,71 @@
const { Pool } = require('pg');
const pool = new Pool({
host: '47.116.196.11',
port: 15432,
database: 'postgresql',
user: 'postgresql',
password: 'Jchl1528'
});
async function testFix() {
try {
console.log('=== 测试手术安排关联修复 ===\n');
// 1. 测试新的 JOIN 条件
const result = await pool.query(`
SELECT
os.schedule_id,
os.oper_code,
os.apply_id,
cs.id as surgery_id,
cs.surgery_no,
cs.apply_dept_name,
cs.main_surgeon_name,
CASE
WHEN cs.id IS NOT NULL THEN '✅ 关联成功'
ELSE '❌ 未找到关联'
END as status
FROM hisdev.op_schedule os
LEFT JOIN hisdev.cli_surgery cs
ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
WHERE os.delete_flag = '0'
ORDER BY os.create_time DESC
LIMIT 10
`);
console.log('手术安排与手术申请关联情况(使用 oper_code = surgery_no');
console.table(result.rows);
// 2. 统计关联成功率
const stats = await pool.query(`
SELECT
COUNT(*) as total,
COUNT(CASE WHEN cs.id IS NOT NULL THEN 1 END) as matched,
COUNT(CASE WHEN cs.id IS NULL THEN 1 END) as unmatched,
ROUND(COUNT(CASE WHEN cs.id IS NOT NULL THEN 1 END) * 100.0 / COUNT(*), 2) as match_rate
FROM hisdev.op_schedule os
LEFT JOIN hisdev.cli_surgery cs
ON os.oper_code = cs.surgery_no AND cs.delete_flag = '0'
WHERE os.delete_flag = '0'
`);
console.log('\n=== 关联统计 ===');
console.log(`总计: ${stats.rows[0].total}`);
console.log(`关联成功: ${stats.rows[0].matched}`);
console.log(`未找到关联: ${stats.rows[0].unmatched}`);
console.log(`关联成功率: ${stats.rows[0].match_rate}%`);
if (parseInt(stats.rows[0].matched) > 0) {
console.log('\n✅ 修复成功!手术安排现在能正确关联到手术申请,申请科室和主刀医生可以正常显示。');
} else {
console.log('\n⚠ 没有关联成功的记录,请检查数据。');
}
} catch (err) {
console.error('测试失败:', err.message);
} finally {
pool.end();
}
}
testFix();