# Generated by Django 5.2.9 on 2026-01-01 07:00

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("policy", "0002_policylevelkeywordmodel_rsssourceconfigmodel_and_more"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="PolicyAuditQueue",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("urgent", "紧急"),
                            ("high", "高"),
                            ("normal", "普通"),
                            ("low", "低"),
                        ],
                        default="normal",
                        max_length=20,
                        verbose_name="优先级",
                    ),
                ),
                (
                    "assigned_at",
                    models.DateTimeField(blank=True, null=True, verbose_name="分配时间"),
                ),
                (
                    "due_date",
                    models.DateTimeField(blank=True, null=True, verbose_name="期望完成时间"),
                ),
                (
                    "auto_rejection_reason",
                    models.TextField(blank=True, verbose_name="自动拒绝原因"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
            ],
            options={
                "verbose_name": "政策审核队列",
                "verbose_name_plural": "政策审核队列",
                "db_table": "policy_audit_queue",
                "ordering": ["priority", "-created_at"],
            },
        ),
        migrations.AddField(
            model_name="policylog",
            name="ai_confidence",
            field=models.FloatField(
                blank=True,
                help_text="0.0-1.0，高于阈值自动通过",
                null=True,
                verbose_name="AI置信度",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="audit_status",
            field=models.CharField(
                choices=[
                    ("pending_review", "待审核"),
                    ("auto_approved", "AI自动通过"),
                    ("manual_approved", "人工通过"),
                    ("rejected", "已拒绝"),
                ],
                db_index=True,
                default="pending_review",
                max_length=20,
                verbose_name="审核状态",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="info_category",
            field=models.CharField(
                choices=[
                    ("macro", "宏观政策"),
                    ("sector", "板块政策"),
                    ("individual", "个股舆情"),
                    ("sentiment", "市场情绪"),
                    ("other", "其他"),
                ],
                db_index=True,
                default="macro",
                max_length=20,
                verbose_name="信息分类",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="is_blacklist",
            field=models.BooleanField(
                default=False, help_text="标记为黑名单的政策", verbose_name="黑名单标记"
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="is_whitelist",
            field=models.BooleanField(
                default=False, help_text="标记为白名单的政策", verbose_name="白名单标记"
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="processing_metadata",
            field=models.JSONField(
                blank=True,
                default=dict,
                help_text='\n        {\n            "ai_model_used": "gpt-4",\n            "ai_processing_time_ms": 1234,\n            "ai_tokens_used": 1500,\n            "extraction_method": "ai|keyword"\n        }\n        ',
                verbose_name="处理元数据",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="review_notes",
            field=models.TextField(blank=True, verbose_name="审核备注"),
        ),
        migrations.AddField(
            model_name="policylog",
            name="reviewed_at",
            field=models.DateTimeField(blank=True, null=True, verbose_name="审核时间"),
        ),
        migrations.AddField(
            model_name="policylog",
            name="reviewed_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="reviewed_policies",
                to=settings.AUTH_USER_MODEL,
                verbose_name="审核人",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="risk_impact",
            field=models.CharField(
                choices=[
                    ("high_risk", "高风险"),
                    ("medium_risk", "中风险"),
                    ("low_risk", "低风险"),
                    ("unknown", "未知"),
                ],
                default="unknown",
                max_length=20,
                verbose_name="风险影响",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="rss_item_guid",
            field=models.CharField(
                blank=True, db_index=True, max_length=500, verbose_name="RSS条目GUID"
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="rss_source",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="policy_logs",
                to="policy.rsssourceconfigmodel",
                verbose_name="RSS来源",
            ),
        ),
        migrations.AddField(
            model_name="policylog",
            name="structured_data",
            field=models.JSONField(
                blank=True,
                default=dict,
                help_text='\n        {\n            "policy_subject": "政策主体",\n            "policy_object": "政策客体",\n            "effective_date": "YYYY-MM-DD",\n            "expiry_date": "YYYY-MM-DD",\n            "conditions": ["条件1", "条件2"],\n            "impact_scope": "national|regional|sector|specific",\n            "affected_sectors": ["板块1", "板块2"],\n            "affected_stocks": ["股票代码1", "股票代码2"],\n            "sentiment": "positive|negative|neutral",\n            "sentiment_score": -1.0到1.0,\n            "keywords": ["关键词1", "关键词2"],\n            "summary": "政策摘要"\n        }\n        ',
                verbose_name="结构化数据",
            ),
        ),
        migrations.AddIndex(
            model_name="policylog",
            index=models.Index(fields=["-event_date"], name="policy_log_event_d_8975ec_idx"),
        ),
        migrations.AddIndex(
            model_name="policylog",
            index=models.Index(fields=["level", "-event_date"], name="policy_log_level_d5b426_idx"),
        ),
        migrations.AddIndex(
            model_name="policylog",
            index=models.Index(fields=["info_category"], name="policy_log_info_ca_c35b40_idx"),
        ),
        migrations.AddIndex(
            model_name="policylog",
            index=models.Index(fields=["audit_status"], name="policy_log_audit_s_98a59f_idx"),
        ),
        migrations.AddIndex(
            model_name="policylog",
            index=models.Index(fields=["rss_item_guid"], name="policy_log_rss_ite_a5fc56_idx"),
        ),
        migrations.AddField(
            model_name="policyauditqueue",
            name="assigned_to",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="assigned_audits",
                to=settings.AUTH_USER_MODEL,
                verbose_name="分配给",
            ),
        ),
        migrations.AddField(
            model_name="policyauditqueue",
            name="policy_log",
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="audit_queue",
                to="policy.policylog",
                verbose_name="关联政策日志",
            ),
        ),
        migrations.AddIndex(
            model_name="policyauditqueue",
            index=models.Index(
                fields=["priority", "-created_at"], name="policy_audi_priorit_2bcb42_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="policyauditqueue",
            index=models.Index(fields=["assigned_to"], name="policy_audi_assigne_ee696d_idx"),
        ),
    ]
