# Generated by Django 3.0.7 on 2020-07-31 06:48

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('system', '0024_auto_20200716_0927'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('crm', '0009_remove_enterpriseaddress_provincecode'),
        ('certset', '0010_auto_20200731_1418'),
    ]

    operations = [
        migrations.CreateModel(
            name='Application',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=100, verbose_name='申请编号')),
                ('apply_date', models.DateField(blank=True, null=True, verbose_name='申请日期')),
                ('accept_date', models.DateField(blank=True, null=True, verbose_name='受理日期')),
                ('applicant_v', django.contrib.postgres.fields.jsonb.JSONField(verbose_name='申请方')),
                ('manufacturer_v', django.contrib.postgres.fields.jsonb.JSONField(blank=True, verbose_name='制造商')),
                ('factory_v', django.contrib.postgres.fields.jsonb.JSONField(blank=True, verbose_name='生产厂')),
                ('status', models.CharField(choices=[('草稿', '草稿'), ('已申请', '已申请'), ('已受理', '已受理'), ('进行中', '进行中'), ('已中止', '已中止'), ('已完成', '已完成')], default='草稿', max_length=50, verbose_name='申请状态')),
                ('evresult', models.CharField(choices=[('合格', '合格'), ('不合格', '不合格'), ('有条件放行', '有条件放行')], default='合格', max_length=50, verbose_name='评审结论')),
                ('evremark', models.TextField(blank=True, verbose_name='备注')),
                ('applicant', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='application_applicant', to='crm.Enterprise')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_belong_dept', to='system.Organization', verbose_name='所属部门')),
                ('cert_field', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_cert_field', to='system.Dict', verbose_name='认证领域')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
            ],
            options={
                'verbose_name': '认证主申请',
                'verbose_name_plural': '认证主申请',
            },
        ),
        migrations.CreateModel(
            name='Project',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_belong_dept', to='system.Organization', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Unit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('factory_v', django.contrib.postgres.fields.jsonb.JSONField(blank=True, verbose_name='生产厂')),
                ('name', models.CharField(max_length=200, verbose_name='单元名称')),
                ('description', models.TextField(blank=True, verbose_name='单元描述')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='unit_belong_dept', to='system.Organization', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='unit_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('factory', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='crm.Enterprise')),
                ('subapplication', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='project.Application', verbose_name='所属子申请')),
                ('unittype', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='certset.UnitType', verbose_name='单元类型')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='unit_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'verbose_name': '认证单元',
                'verbose_name_plural': '认证单元',
            },
        ),
        migrations.CreateModel(
            name='SubApplication',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('number', models.CharField(max_length=100, verbose_name='子申请编号')),
                ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subapplication_application', to='project.Application')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subapplication_belong_dept', to='system.Organization', verbose_name='所属部门')),
                ('cccpv_class', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='subapplication_cccpv_class', to='system.Dict', verbose_name='涉及CCC/PV分类')),
                ('cert_field', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='subapplication_cert_field', to='system.Dict', verbose_name='认证领域')),
                ('cnas_scopes', models.ManyToManyField(related_name='subapplication_cnas_sopes', to='system.Dict', verbose_name='涉及cnas分类')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subapplication_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('project', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subapplication_project', to='project.Project')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subapplication_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'verbose_name': '认证子申请',
                'verbose_name_plural': '认证子申请',
            },
        ),
        migrations.CreateModel(
            name='EvaluationDetail',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
                ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
                ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
                ('result', models.CharField(choices=[('符合', '符合'), ('不符合', '不符合'), ('不适用', '不适用'), ('需说明', '需说明')], default='符合', max_length=50, verbose_name='评审结果')),
                ('remark', models.TextField(blank=True, verbose_name='备注')),
                ('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='project.Application')),
                ('belong_dept', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluationdetail_belong_dept', to='system.Organization', verbose_name='所属部门')),
                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluationdetail_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='certset.EvaluationItem', verbose_name='项目内容')),
                ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evaluationdetail_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')),
            ],
            options={
                'verbose_name': '评审记录详情',
                'verbose_name_plural': '评审记录详情',
            },
        ),
        migrations.AddField(
            model_name='application',
            name='evdetail',
            field=models.ManyToManyField(through='project.EvaluationDetail', to='certset.EvaluationItem', verbose_name='评审详细记录'),
        ),
        migrations.AddField(
            model_name='application',
            name='factory',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_factory', to='crm.Enterprise'),
        ),
        migrations.AddField(
            model_name='application',
            name='manufacturer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_manufacturer', to='crm.Enterprise'),
        ),
        migrations.AddField(
            model_name='application',
            name='update_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='application_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人'),
        ),
    ]
