feat(iit): Complete V3.1 QC engine + GCP business reports + AI timeline + bug fixes
V3.1 QC Engine: - QcExecutor unified entry + D1-D7 dimension engines + three-level aggregation - HealthScoreEngine + CompletenessEngine + ProtocolDeviationEngine + QcAggregator - B4 flexible cron scheduling (project-level cronExpression + pg-boss dispatcher) - Prisma migrations for qc_field_status, event_status, project_stats GCP Business Reports (Phase A - 4 reports): - D1 Eligibility: record_summary full list + qc_field_status D1 overlay - D2 Completeness: data entry rate and missing rate aggregation - D3/D4 Query Tracking: severity distribution from qc_field_status - D6 Protocol Deviation: D6 dimension filtering - 4 frontend table components + ReportsPage 5-tab restructure AI Timeline Enhancement: - SkillRunner outputs totalRules (33 actual rules vs 1 skill) - iitQcCockpitController severity mapping fix (critical->red, warning->yellow) - AiStreamPage expandable issue detail table with Chinese labels - Event label localization (eventLabel from backend) Business-side One-click Batch QC: - DashboardPage batch QC button with SyncOutlined icon - Auto-refresh QcReport cache after batch execution Bug Fixes: - dimension_code -> rule_category in 4 SQL queries - D1 eligibility data source: record_summary full + qc_field_status overlay - Timezone UTC -> Asia/Shanghai (QcReportService toBeijingTime helper) - Pass rate calculation: passed/totalEvents instead of passed/totalRecords Docs: - Update IIT module status with GCP reports and bug fix milestones - Update system status doc v6.6 with IIT progress Tested: Backend compiles, frontend linter clean, batch QC verified Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
-- V3.1 Batch C: 项目健康度评分 — qc_project_stats 加维度通过率 + 健康度评分
|
||||
-- 全部 ADD COLUMN,向后兼容,零停机
|
||||
|
||||
ALTER TABLE "iit_schema"."qc_project_stats"
|
||||
ADD COLUMN IF NOT EXISTS "d1_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d2_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d3_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d5_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d6_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d7_pass_rate" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "health_score" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "health_grade" TEXT,
|
||||
ADD COLUMN IF NOT EXISTS "dimension_detail" JSONB NOT NULL DEFAULT '{}';
|
||||
@@ -0,0 +1,60 @@
|
||||
-- V3.1 QC Engine Architecture Upgrade — Batch B: Event-level aggregation layer
|
||||
-- 本迁移全部为 ADD COLUMN / CREATE TABLE,向后兼容,零停机
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 1. 新增表:qc_event_status(事件级质控状态,由 qc_field_status 聚合)
|
||||
----------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS "iit_schema"."qc_event_status" (
|
||||
"id" TEXT NOT NULL,
|
||||
"project_id" TEXT NOT NULL,
|
||||
"record_id" TEXT NOT NULL,
|
||||
"event_id" TEXT NOT NULL,
|
||||
"event_label" TEXT,
|
||||
"status" TEXT NOT NULL,
|
||||
"fields_total" INTEGER NOT NULL DEFAULT 0,
|
||||
"fields_passed" INTEGER NOT NULL DEFAULT 0,
|
||||
"fields_failed" INTEGER NOT NULL DEFAULT 0,
|
||||
"fields_warning" INTEGER NOT NULL DEFAULT 0,
|
||||
"d1_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"d2_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"d3_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"d5_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"d6_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"d7_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
"forms_checked" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
||||
"top_issues" JSONB NOT NULL DEFAULT '[]',
|
||||
"triggered_by" TEXT NOT NULL,
|
||||
"last_qc_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "qc_event_status_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "uq_event_status"
|
||||
ON "iit_schema"."qc_event_status"("project_id", "record_id", "event_id");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "idx_es_record"
|
||||
ON "iit_schema"."qc_event_status"("project_id", "record_id");
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "idx_es_status"
|
||||
ON "iit_schema"."qc_event_status"("project_id", "status");
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- 2. 改造表:record_summary 加聚合字段
|
||||
----------------------------------------------------------------------
|
||||
ALTER TABLE "iit_schema"."record_summary"
|
||||
ADD COLUMN IF NOT EXISTS "events_total" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "events_passed" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "events_failed" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "events_warning" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "fields_total" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "fields_passed" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "fields_failed" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d1_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d2_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d3_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d5_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d6_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "d7_issues" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN IF NOT EXISTS "top_issues" JSONB NOT NULL DEFAULT '[]';
|
||||
@@ -0,0 +1,64 @@
|
||||
-- V3.1 QC Engine Architecture Upgrade: Five-level data structure (Batch A)
|
||||
-- Changes:
|
||||
-- 1. New table: qc_field_status (five-level coordinate QC status)
|
||||
-- 2. qc_logs: add instance_id column
|
||||
-- 3. equery: add instance_id column
|
||||
-- 4. field_mapping: add semantic_label, form_name, rule_category columns
|
||||
-- All new columns have defaults or are nullable — backward compatible, zero downtime
|
||||
|
||||
-- ============================================================
|
||||
-- 1. Create qc_field_status table (five-level coordinate)
|
||||
-- ============================================================
|
||||
CREATE TABLE "iit_schema"."qc_field_status" (
|
||||
"id" TEXT NOT NULL,
|
||||
"project_id" TEXT NOT NULL,
|
||||
"record_id" TEXT NOT NULL,
|
||||
"event_id" TEXT NOT NULL,
|
||||
"form_name" TEXT NOT NULL,
|
||||
"instance_id" INTEGER NOT NULL DEFAULT 1,
|
||||
"field_name" TEXT NOT NULL,
|
||||
"status" TEXT NOT NULL,
|
||||
"rule_id" TEXT,
|
||||
"rule_name" TEXT,
|
||||
"rule_category" TEXT,
|
||||
"severity" TEXT,
|
||||
"message" TEXT,
|
||||
"actual_value" TEXT,
|
||||
"expected_value" TEXT,
|
||||
"source_qc_log_id" TEXT,
|
||||
"triggered_by" TEXT NOT NULL,
|
||||
"last_qc_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "qc_field_status_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Unique constraint: one status per five-level coordinate
|
||||
CREATE UNIQUE INDEX "uq_field_status" ON "iit_schema"."qc_field_status"("project_id", "record_id", "event_id", "form_name", "instance_id", "field_name");
|
||||
|
||||
-- Query indexes
|
||||
CREATE INDEX "idx_fs_record" ON "iit_schema"."qc_field_status"("project_id", "record_id");
|
||||
CREATE INDEX "idx_fs_event" ON "iit_schema"."qc_field_status"("project_id", "record_id", "event_id");
|
||||
CREATE INDEX "idx_fs_status" ON "iit_schema"."qc_field_status"("project_id", "status");
|
||||
CREATE INDEX "idx_fs_category" ON "iit_schema"."qc_field_status"("project_id", "rule_category");
|
||||
|
||||
-- ============================================================
|
||||
-- 2. qc_logs: add instance_id (default 1, backward compatible)
|
||||
-- ============================================================
|
||||
ALTER TABLE "iit_schema"."qc_logs"
|
||||
ADD COLUMN "instance_id" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- ============================================================
|
||||
-- 3. equery: add instance_id (default 1, backward compatible)
|
||||
-- ============================================================
|
||||
ALTER TABLE "iit_schema"."equery"
|
||||
ADD COLUMN "instance_id" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- ============================================================
|
||||
-- 4. field_mapping: add V3.1 columns (all nullable)
|
||||
-- ============================================================
|
||||
ALTER TABLE "iit_schema"."field_mapping"
|
||||
ADD COLUMN "semantic_label" TEXT,
|
||||
ADD COLUMN "form_name" TEXT,
|
||||
ADD COLUMN "rule_category" TEXT;
|
||||
Reference in New Issue
Block a user