Summary: - Refactor timeline API to read from qc_field_status (SSOT) instead of qc_logs - Add field-issues paginated API with severity/dimension/recordId filters - Add LEFT JOIN field_metadata + qc_event_status for Chinese display names - Implement per-project ChatOrchestrator cache and SessionMemory isolation - Redesign admin IIT config tabs (REDCap -> Fields -> KB -> Rules -> Members) - Add AI-powered QC rule generation (D3 programmatic + D1/D5/D6 LLM-based) - Add clickable warning/critical detail Modal in ReportsPage - Auto-dispatch eQuery after batch QC via DailyQcOrchestrator - Update module status documentation to v3.2 Backend changes: - iitQcCockpitController: rewrite getTimeline from qc_field_status, add getFieldIssues - iitQcCockpitRoutes: add field-issues route - ChatOrchestrator: per-projectId cached instances - SessionMemory: keyed by userId::projectId - WechatCallbackController: resolve projectId from iitUserMapping - iitRuleSuggestionService: dimension-based suggest + generateD3Rules - iitBatchController: call DailyQcOrchestrator after batch QC Frontend changes: - AiStreamPage: adapt to new timeline structure with dimension tags - ReportsPage: clickable stats cards with issue detail Modal - IitProjectDetailPage: reorder tabs, add AI rule generation UI - iitProjectApi: add TimelineIssue, FieldIssueItem types and APIs Status: TypeScript compilation verified, no new lint errors Made-with: Cursor
133 lines
3.3 KiB
JavaScript
133 lines
3.3 KiB
JavaScript
/**
|
||
* 初始化 modules 表数据
|
||
*
|
||
* 运行: node scripts/seed-modules.js
|
||
*/
|
||
|
||
import { PrismaClient } from '@prisma/client';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
const MODULES = [
|
||
{
|
||
code: 'RVW',
|
||
name: '智能审稿',
|
||
description: '基于AI的稿件自动审查系统,支持稿约规范性评估和方法学评估',
|
||
icon: 'FileTextOutlined',
|
||
is_active: true,
|
||
sort_order: 1,
|
||
},
|
||
{
|
||
code: 'PKB',
|
||
name: '个人知识库',
|
||
description: '个人文档管理与智能检索系统,支持多格式文档上传和语义搜索',
|
||
icon: 'BookOutlined',
|
||
is_active: true,
|
||
sort_order: 2,
|
||
},
|
||
{
|
||
code: 'ASL',
|
||
name: '智能文献',
|
||
description: '文献筛选与管理系统,支持批量导入、AI辅助筛选和全文复筛',
|
||
icon: 'ReadOutlined',
|
||
is_active: true,
|
||
sort_order: 3,
|
||
},
|
||
{
|
||
code: 'DC',
|
||
name: '数据清洗',
|
||
description: '智能数据清洗与整理工具,支持双模型提取和AI辅助数据处理',
|
||
icon: 'DatabaseOutlined',
|
||
is_active: true,
|
||
sort_order: 4,
|
||
},
|
||
{
|
||
code: 'IIT',
|
||
name: 'CRA质控',
|
||
description: 'IIT项目管理系统,支持REDCap集成和项目协作',
|
||
icon: 'ProjectOutlined',
|
||
is_active: true,
|
||
sort_order: 5,
|
||
},
|
||
{
|
||
code: 'AIA',
|
||
name: '智能问答',
|
||
description: 'AI智能问答助手,提供临床研究相关问题的智能解答',
|
||
icon: 'RobotOutlined',
|
||
is_active: true,
|
||
sort_order: 6,
|
||
},
|
||
{
|
||
code: 'SSA',
|
||
name: '智能统计分析',
|
||
description: 'AI驱动的智能统计分析系统,提供高级统计方法和自动化分析',
|
||
icon: 'BarChartOutlined',
|
||
is_active: true,
|
||
sort_order: 7,
|
||
},
|
||
{
|
||
code: 'ST',
|
||
name: '统计工具',
|
||
description: '统计分析工具集,提供常用统计方法和数据可视化功能',
|
||
icon: 'LineChartOutlined',
|
||
is_active: true,
|
||
sort_order: 8,
|
||
},
|
||
{
|
||
code: 'RM',
|
||
name: '研究管理',
|
||
description: '研究项目管理系统,支持项目全流程管理',
|
||
icon: 'ProjectOutlined',
|
||
is_active: true,
|
||
sort_order: 9,
|
||
},
|
||
{
|
||
code: 'AIA_PROTOCOL',
|
||
name: '全流程研究方案制定',
|
||
description: 'AI问答模块内的Protocol Agent功能,可按用户/租户独立配置开关',
|
||
icon: 'ExperimentOutlined',
|
||
is_active: true,
|
||
sort_order: 100,
|
||
},
|
||
];
|
||
|
||
async function main() {
|
||
console.log('🚀 开始初始化 modules 表...\n');
|
||
|
||
for (const module of MODULES) {
|
||
const result = await prisma.modules.upsert({
|
||
where: { code: module.code },
|
||
update: {
|
||
name: module.name,
|
||
description: module.description,
|
||
icon: module.icon,
|
||
is_active: module.is_active,
|
||
sort_order: module.sort_order,
|
||
},
|
||
create: module,
|
||
});
|
||
console.log(`✅ ${result.code} - ${result.name}`);
|
||
}
|
||
|
||
console.log('\n========== 当前 modules 表数据 ==========\n');
|
||
|
||
const allModules = await prisma.modules.findMany({
|
||
orderBy: { sort_order: 'asc' },
|
||
});
|
||
|
||
console.table(allModules.map(m => ({
|
||
代码: m.code,
|
||
名称: m.name,
|
||
描述: m.description?.substring(0, 30) + '...',
|
||
状态: m.is_active ? '✅ 上线' : '❌ 下线',
|
||
排序: m.sort_order,
|
||
})));
|
||
|
||
console.log('\n✨ 初始化完成!');
|
||
}
|
||
|
||
main()
|
||
.catch(console.error)
|
||
.finally(() => prisma.$disconnect());
|
||
|