feat(application-form-fill): 新增自动填表批次模型

This commit is contained in:
2026-06-07 18:20:14 +08:00
parent f48277aea7
commit 74cbe349a8
5 changed files with 716 additions and 5 deletions

View File

@@ -0,0 +1,353 @@
# Generated by Django 5.2.14 on 2026-06-07 10:19
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("review_agent", "0005_alter_regulatoryissue_status"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AlterField(
model_name="exportedsummaryfile",
name="export_type",
field=models.CharField(
choices=[
("markdown", "Markdown"),
("excel", "Excel"),
("json", "JSON"),
("word", "Word"),
("pdf", "PDF"),
],
max_length=20,
),
),
migrations.CreateModel(
name="ApplicationFormFillBatch",
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", "执行中"),
("waiting_user", "等待用户"),
("success", "成功"),
("partial_success", "部分成功"),
("failed", "失败"),
("cancelled", "已取消"),
],
default="pending",
max_length=30,
),
),
("requested_templates", models.JSONField(blank=True, default=list)),
("selected_templates", models.JSONField(blank=True, default=list)),
("output_types", models.JSONField(blank=True, default=list)),
(
"registration_type",
models.CharField(blank=True, default="", max_length=80),
),
(
"registration_type_source",
models.CharField(
choices=[
("user_message", "用户话语"),
("regulatory_batch", "法规核查批次"),
("file_extract", "文件抽取"),
("unknown", "未知"),
],
default="unknown",
max_length=40,
),
),
(
"product_name",
models.CharField(blank=True, default="", max_length=200),
),
("conflict_summary", models.JSONField(blank=True, default=list)),
("risk_notes", models.JSONField(blank=True, default=list)),
(
"template_config_version",
models.CharField(blank=True, default="", max_length=80),
),
(
"template_config_hash",
models.CharField(blank=True, default="", max_length=128),
),
("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)),
("archived_at", models.DateTimeField(blank=True, null=True)),
("is_deleted", models.BooleanField(default=False)),
(
"conversation",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="application_form_fill_batches",
to="review_agent.conversation",
),
),
(
"source_regulatory_batch",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="application_form_fill_batches",
to="review_agent.regulatoryreviewbatch",
),
),
(
"source_summary_batch",
models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="application_form_fill_batches",
to="review_agent.filesummarybatch",
),
),
(
"trigger_message",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="triggered_application_form_fill_batches",
to="review_agent.message",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="review_application_form_fill_batches",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_application_form_fill_batch",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="ApplicationFormFillArtifact",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"artifact_type",
models.CharField(
choices=[
("template_copy", "模板副本"),
("field_extract_result", "字段抽取结果"),
("merged_fields", "字段合并结果"),
("traceability", "追溯清单"),
("filled_template", "已填模板"),
("notification_record", "通知记录"),
],
max_length=60,
),
),
(
"file_format",
models.CharField(
choices=[
("json", "JSON"),
("excel", "Excel"),
("docx", "DOCX"),
("pdf", "PDF"),
("markdown", "Markdown"),
],
max_length=20,
),
),
("name", models.CharField(max_length=160)),
("file_name", models.CharField(max_length=255)),
("storage_path", models.CharField(max_length=500)),
("file_size", models.BigIntegerField(default=0)),
(
"content_hash",
models.CharField(blank=True, default="", max_length=128),
),
("metadata", models.JSONField(blank=True, default=dict)),
(
"created_by_node",
models.CharField(blank=True, default="", max_length=60),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("is_deleted", models.BooleanField(default=False)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="artifacts",
to="review_agent.applicationformfillbatch",
),
),
],
options={
"db_table": "ra_application_form_fill_artifact",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="ApplicationFormFillNotificationRecord",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"channel",
models.CharField(
choices=[
("feishu_cli", "飞书 CLI"),
("feishu_api", "飞书 API"),
("mock", "模拟"),
],
default="mock",
max_length=30,
),
),
("template_codes", models.JSONField(blank=True, default=list)),
("export_ids", models.JSONField(blank=True, default=list)),
("message_summary", models.TextField(blank=True, default="")),
(
"send_status",
models.CharField(
choices=[
("pending", "待发送"),
("success", "成功"),
("failed", "失败"),
],
default="pending",
max_length=20,
),
),
("retry_count", models.PositiveIntegerField(default=0)),
(
"external_message_id",
models.CharField(blank=True, default="", max_length=120),
),
("error_message", models.TextField(blank=True, default="")),
("sent_at", models.DateTimeField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("is_deleted", models.BooleanField(default=False)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="notifications",
to="review_agent.applicationformfillbatch",
),
),
(
"recipient",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="application_form_fill_notifications",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_application_form_fill_notification_record",
"ordering": ["-created_at", "-id"],
},
),
migrations.AddIndex(
model_name="applicationformfillbatch",
index=models.Index(
fields=["conversation", "status"], name="idx_ra_aff_batch_conv_status"
),
),
migrations.AddIndex(
model_name="applicationformfillbatch",
index=models.Index(
fields=["source_summary_batch"], name="idx_ra_aff_batch_summary"
),
),
migrations.AddIndex(
model_name="applicationformfillbatch",
index=models.Index(
fields=["source_regulatory_batch"], name="idx_ra_aff_batch_regulatory"
),
),
migrations.AddIndex(
model_name="applicationformfillbatch",
index=models.Index(
fields=["user", "created_at"], name="idx_ra_aff_batch_user_created"
),
),
migrations.AddIndex(
model_name="applicationformfillbatch",
index=models.Index(fields=["created_at"], name="idx_ra_aff_batch_created"),
),
migrations.AddIndex(
model_name="applicationformfillartifact",
index=models.Index(
fields=["batch", "artifact_type"], name="idx_ra_aff_artifact_batch_type"
),
),
migrations.AddIndex(
model_name="applicationformfillartifact",
index=models.Index(
fields=["file_format"], name="idx_ra_aff_artifact_format"
),
),
migrations.AddIndex(
model_name="applicationformfillartifact",
index=models.Index(
fields=["created_at"], name="idx_ra_aff_artifact_created"
),
),
migrations.AddIndex(
model_name="applicationformfillnotificationrecord",
index=models.Index(
fields=["batch", "created_at"], name="idx_ra_aff_notify_batch"
),
),
migrations.AddIndex(
model_name="applicationformfillnotificationrecord",
index=models.Index(
fields=["recipient", "send_status"], name="idx_ra_aff_notify_recipient"
),
),
migrations.AddIndex(
model_name="applicationformfillnotificationrecord",
index=models.Index(
fields=["send_status", "retry_count"], name="idx_ra_aff_notify_status"
),
),
]