from django.db import models
from apps.system.models import CommonBModel, Dict
from simple_history.models import HistoricalRecords
# Create your models here.
class Enterprise(CommonBModel):
    code = models.CharField('工厂编号', max_length=300)
    name = models.CharField('工厂名称',null=True, blank=True, max_length=1000)
    ename =  models.CharField('工厂英文名称',null=True, blank=True, max_length=1000)
    type = models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='工厂类型', related_name= 'enterprise_type')
    legal =  models.CharField('申请单位法人代表',null=True, blank=True, max_length=300)
    production_address =  models.CharField('生产地址',null=True, blank=True, max_length=1000)
    production_eaddress = models.CharField('生产英文地址',null=True, blank=True, max_length=1000)
    production_postcode = models.CharField('生产地址邮编',null=True, blank=True, max_length=100)
    build_time = models.DateField('建厂时间',null=True, blank=True, max_length=200)
    person_count = models.IntegerField('工厂人数',null=True, blank=True, max_length=100)
    ceramics_output = models.IntegerField('陶瓷年产量',null=True, blank=True)
    gassets = models.CharField('固定资产',null=True, blank=True, max_length=100)
    linkman1_name = models.CharField('第1联系人',null=True, blank=True, max_length=300)
    linkman1_duty = models.CharField('第1联系人职务',null=True, blank=True, max_length=300)
    linkman1_email = models.EmailField('第1联系人邮箱',null=True, blank=True, max_length=300)
    linkman1_tel = models.CharField('第1联系人电话',null=True, blank=True, max_length=300)
    linkman1_mobile = models.CharField('第1联系人手机',null=True, blank=True, max_length=300)
    linkman1_fax = models.CharField('第1联系人传真',null=True, blank=True, max_length=300)
    linkman2_name = models.CharField('备用联系人',null=True, blank=True, max_length=300)
    linkman2_email = models.EmailField('备用联系人邮箱',null=True, blank=True, max_length=300)
    linkman2_tel = models.CharField('备用联系人电话',null=True, blank=True, max_length=300)
    linkman2_duty = models.CharField('备用联系人职务',null=True, blank=True, max_length=300)
    linkman2_mobile = models.CharField('备用联系人手机',null=True, blank=True, max_length=300)
    linkman2_fax = models.CharField('备用联系人传真',null=True, blank=True, max_length=300)
    country_code = models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='生产企业所在国家地区代码', related_name= 'enterprise_country_code')
    credit_code = models.CharField('统一社会信用代码',null=True, blank=True, max_length=300)
    # post_name = models.CharField('通信公司',null=True, blank=True, max_length=1000)
    # post_ename = models.CharField('通信公司（英）',null=True, blank=True, max_length=1000)
    registered_address = models.CharField('注册地址',null=True, blank=True, max_length=1000)
    registered_eaddress = models.CharField('注册地址英文',null=True, blank=True, max_length=1000)
    registered_code = models.CharField('注册地址邮编',null=True, blank=True, max_length=1000)
    mailing_address = models.CharField('通信地址',null=True, blank=True, max_length=1000)
    mailing_eaddress = models.CharField('通信英文地址',null=True, blank=True, max_length=1000)
    mailing_code = models.CharField('地址邮编',null=True, blank=True, max_length=300)
    region = models.CharField('地区',null=True, blank=True, max_length=300)
    region_code = models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='地区代码', related_name= 'enterprise_region_code')
    # status = models.CharField('是否受理',null=True, blank=True, max_length=1000)
    # bak1 = models.CharField('',null=True, blank=True, max_length=1000)
    # bak2 = models.CharField('',null=True, blank=True, max_length=1000)
    # bak3 = models.CharField('',null=True, blank=True, max_length=1000)
    professional = models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='所属专业', related_name= 'enterprise_professional')
    qms_person = models.IntegerField('QMS人数',null=True, blank=True)
    ems_person = models.IntegerField('EMS人数',null=True, blank=True)
    pcv_person = models.IntegerField('PCV人数',null=True, blank=True)
    ohs_person = models.IntegerField('OHS人数',null=True, blank=True)
    all_person = models.IntegerField('组织员工数',null=True, blank=True)
    economy_class = models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='经济行业', related_name= 'enterprise_economy_class')
    economy_type =models.ForeignKey(Dict, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='经济类型', related_name= 'enterprise_economy_type')
    business_type = models.CharField('经营范围',null=True, blank=True, max_length=1000)
    credit_rate = models.CharField('企业信誉级别',null=True, blank=True, max_length=300)
    credit_remark = models.CharField('企业信誉级别备注',null=True, blank=True, max_length=1000)
    # xinyu_oper = models.CharField('信誉法人',null=True, blank=True, max_length=1000)
    # xinyu_date = models.CharField('信誉时间',null=True, blank=True, max_length=1000)
    query_code = models.CharField('组织查询码',null=True, blank=True, max_length=1000)
    linkman3_name = models.CharField('ES联系人',null=True, blank=True, max_length=300)
    linkman3_duty = models.CharField('ES联系人职务',null=True, blank=True, max_length=300)
    linkman3_email = models.EmailField('ES联系人邮箱',null=True, blank=True, max_length=300)
    linkman3_tel = models.CharField('ES联系人电话',null=True, blank=True, max_length=300)
    linkman3_mobile = models.CharField('ES联系人手机',null=True, blank=True, max_length=300)
    linkman3_fax = models.CharField('ES联系人传真',null=True, blank=True, max_length=300)

    class Meta:
        verbose_name = '组织信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name