feat(regulatory): 新增法规核查模型与工作流通用字段

This commit is contained in:
2026-06-07 00:23:58 +08:00
parent 665403735a
commit f52dcc197d
8 changed files with 878 additions and 7 deletions

View File

@@ -0,0 +1,479 @@
# Generated by Django 5.2.14 on 2026-06-06 16:22
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
(
"review_agent",
"0002_fileattachment_filesummarybatch_exportedsummaryfile_and_more",
),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="RegulatoryArtifact",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"artifact_type",
models.CharField(
choices=[
("markdown", "Markdown"),
("excel", "Excel"),
("json", "JSON"),
("text", "文本"),
],
max_length=20,
),
),
("name", models.CharField(max_length=160)),
("storage_path", models.CharField(max_length=500)),
(
"content_hash",
models.CharField(blank=True, default="", max_length=128),
),
("metadata", models.JSONField(blank=True, default=dict)),
("created_at", models.DateTimeField(auto_now_add=True)),
],
options={
"db_table": "ra_regulatory_artifact",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="RegulatoryIssue",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("rule_code", models.CharField(blank=True, default="", max_length=120)),
(
"category",
models.CharField(
choices=[
("completeness", "完整性"),
("structure", "章节"),
("consistency", "一致性"),
("rag", "法规依据"),
],
max_length=40,
),
),
(
"severity",
models.CharField(
choices=[
("blocking", "阻断项"),
("high", "高风险"),
("medium", "中风险"),
("low", "低风险"),
("info", "提示"),
],
max_length=20,
),
),
("title", models.CharField(max_length=255)),
("detail", models.TextField(blank=True, default="")),
("suggestion", models.TextField(blank=True, default="")),
(
"status",
models.CharField(
choices=[
("open", "待处理"),
("resolved", "已整改"),
("accepted", "已接受"),
],
default="open",
max_length=20,
),
),
("evidence", models.JSONField(blank=True, default=dict)),
("citations", models.JSONField(blank=True, default=list)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "ra_regulatory_issue",
"ordering": ["severity", "id"],
},
),
migrations.CreateModel(
name="RegulatoryNotificationRecord",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"channel",
models.CharField(
choices=[("mock", "模拟"), ("feishu", "飞书")],
default="mock",
max_length=20,
),
),
("target", models.CharField(blank=True, default="", max_length=160)),
("payload", models.JSONField(blank=True, default=dict)),
(
"status",
models.CharField(
choices=[
("pending", "待发送"),
("sent", "已发送"),
("failed", "失败"),
],
default="pending",
max_length=20,
),
),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
("sent_at", models.DateTimeField(blank=True, null=True)),
],
options={
"db_table": "ra_regulatory_notification_record",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="RegulatoryReviewBatch",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("batch_no", models.CharField(max_length=64, unique=True)),
(
"status",
models.CharField(
choices=[
("pending", "待执行"),
("running", "执行中"),
("success", "成功"),
("failed", "失败"),
],
default="pending",
max_length=20,
),
),
("risk_summary", models.JSONField(blank=True, default=dict)),
("work_dir", models.CharField(blank=True, default="", max_length=500)),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
("started_at", models.DateTimeField(blank=True, null=True)),
("finished_at", models.DateTimeField(blank=True, null=True)),
],
options={
"db_table": "ra_regulatory_review_batch",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="RegulatoryRuleVersion",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("code", models.CharField(max_length=80, unique=True)),
("name", models.CharField(max_length=160)),
("yaml_path", models.CharField(max_length=500)),
("yaml_hash", models.CharField(max_length=128)),
(
"rag_collection",
models.CharField(blank=True, default="", max_length=120),
),
(
"rag_index_version",
models.CharField(blank=True, default="", max_length=80),
),
(
"rag_index_hash",
models.CharField(blank=True, default="", max_length=128),
),
(
"status",
models.CharField(
choices=[
("active", "启用"),
("outdated", "待更新"),
("disabled", "停用"),
],
default="active",
max_length=20,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "ra_regulatory_rule_version",
"ordering": ["-updated_at", "-id"],
},
),
migrations.AddField(
model_name="exportedsummaryfile",
name="export_category",
field=models.CharField(blank=True, default="summary", max_length=40),
),
migrations.AddField(
model_name="exportedsummaryfile",
name="workflow_batch_id",
field=models.PositiveBigIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="exportedsummaryfile",
name="workflow_type",
field=models.CharField(blank=True, default="file_summary", max_length=40),
),
migrations.AddField(
model_name="workflowevent",
name="conversation",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="workflow_events",
to="review_agent.conversation",
),
),
migrations.AddField(
model_name="workflowevent",
name="workflow_batch_id",
field=models.PositiveBigIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="workflowevent",
name="workflow_type",
field=models.CharField(blank=True, default="file_summary", max_length=40),
),
migrations.AddField(
model_name="workflownoderun",
name="node_group",
field=models.CharField(blank=True, default="file_summary", max_length=40),
),
migrations.AddField(
model_name="workflownoderun",
name="workflow_batch_id",
field=models.PositiveBigIntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="workflownoderun",
name="workflow_type",
field=models.CharField(blank=True, default="file_summary", max_length=40),
),
migrations.AlterField(
model_name="exportedsummaryfile",
name="export_type",
field=models.CharField(
choices=[
("markdown", "Markdown"),
("excel", "Excel"),
("json", "JSON"),
],
max_length=20,
),
),
migrations.AlterField(
model_name="workflowevent",
name="batch",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="events",
to="review_agent.filesummarybatch",
),
),
migrations.AlterField(
model_name="workflownoderun",
name="batch",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="node_runs",
to="review_agent.filesummarybatch",
),
),
migrations.AddIndex(
model_name="exportedsummaryfile",
index=models.Index(
fields=["workflow_type", "workflow_batch_id"],
name="idx_ra_export_workflow",
),
),
migrations.AddIndex(
model_name="workflowevent",
index=models.Index(
fields=["workflow_type", "workflow_batch_id", "id"],
name="idx_ra_event_workflow_id",
),
),
migrations.AddIndex(
model_name="workflownoderun",
index=models.Index(
fields=["workflow_type", "workflow_batch_id"],
name="idx_ra_node_workflow",
),
),
migrations.AddField(
model_name="regulatoryreviewbatch",
name="conversation",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="regulatory_review_batches",
to="review_agent.conversation",
),
),
migrations.AddField(
model_name="regulatoryreviewbatch",
name="source_summary_batch",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="regulatory_review_batches",
to="review_agent.filesummarybatch",
),
),
migrations.AddField(
model_name="regulatoryreviewbatch",
name="trigger_message",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="triggered_regulatory_batches",
to="review_agent.message",
),
),
migrations.AddField(
model_name="regulatoryreviewbatch",
name="user",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="review_regulatory_batches",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AddField(
model_name="regulatorynotificationrecord",
name="batch",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="notifications",
to="review_agent.regulatoryreviewbatch",
),
),
migrations.AddField(
model_name="regulatoryissue",
name="batch",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="issues",
to="review_agent.regulatoryreviewbatch",
),
),
migrations.AddField(
model_name="regulatoryartifact",
name="batch",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="artifacts",
to="review_agent.regulatoryreviewbatch",
),
),
migrations.AddIndex(
model_name="regulatoryruleversion",
index=models.Index(
fields=["code", "status"], name="idx_ra_rule_code_status"
),
),
migrations.AddField(
model_name="regulatoryreviewbatch",
name="rule_version",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="review_batches",
to="review_agent.regulatoryruleversion",
),
),
migrations.AddIndex(
model_name="regulatorynotificationrecord",
index=models.Index(
fields=["batch", "status"], name="idx_ra_rr_notify_status"
),
),
migrations.AddIndex(
model_name="regulatoryissue",
index=models.Index(
fields=["batch", "severity"], name="idx_ra_rr_issue_severity"
),
),
migrations.AddIndex(
model_name="regulatoryissue",
index=models.Index(
fields=["batch", "category"], name="idx_ra_rr_issue_category"
),
),
migrations.AddIndex(
model_name="regulatoryartifact",
index=models.Index(
fields=["batch", "artifact_type"], name="idx_ra_rr_artifact_type"
),
),
migrations.AddIndex(
model_name="regulatoryreviewbatch",
index=models.Index(
fields=["conversation", "created_at"], name="idx_ra_rr_batch_conv"
),
),
migrations.AddIndex(
model_name="regulatoryreviewbatch",
index=models.Index(
fields=["user", "created_at"], name="idx_ra_rr_batch_user"
),
),
migrations.AddIndex(
model_name="regulatoryreviewbatch",
index=models.Index(
fields=["status", "created_at"], name="idx_ra_rr_batch_status"
),
),
]