from djongo import models


#病虫害知识库
class MongoPestBank(models.Model):
    id = models.AutoField(primary_key=True)
    course = models.CharField(max_length=100, verbose_name="所属科目",   null=True,  blank=True)
    name = models.CharField(max_length=32, verbose_name="病虫害名",null=True,  blank=True)
    img_urls = models.CharField(u'识别出来的图片', max_length=300, null=True,  blank=True)
    prevention = models.TextField(u'防止方法', null=True,  blank=True)
    search = models.IntegerField(verbose_name="搜索排名", default=0)
    code = models.CharField(verbose_name="病虫害区分",  max_length=10, blank=True, null=True)
    # code 1 病害  2 虫害

    class Meta:
        db_table = "sa_pest_bank"
        verbose_name = "病虫害知识库表"
        verbose_name_plural = verbose_name


class MongoPestBankNew(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32, verbose_name="病虫害名",null=True,  blank=True)
    alias = models.CharField(max_length=32, verbose_name="别名",null=True,  blank=True)
    types = models.CharField(max_length=10, verbose_name="区分",null=True,  blank=True) # 1病害 2虫害
    cycle = models.CharField(max_length=32, verbose_name="周期",null=True,  blank=True)
    distribution = models.CharField(max_length=32, verbose_name="分布",null=True,  blank=True)
    pathogen = models.CharField(max_length=32, verbose_name="病原体",null=True,  blank=True)
    features = models.CharField(max_length=100, verbose_name="特征",null=True,  blank=True) # 1病害 2虫害
    habits = models.CharField(max_length=300, verbose_name="习惯",null=True,  blank=True)
    host = models.CharField(max_length=50, verbose_name="寄主",null=True,  blank=True)
    summary = models.CharField(max_length=50, verbose_name="概括",null=True,  blank=True)
    taxonomy = models.CharField(max_length=100, verbose_name="分类",   null=True,  blank=True)
    symptom = models.CharField(max_length=100, verbose_name="症状",   null=True,  blank=True)
    prevention = models.TextField(u'防止方法', null=True,  blank=True)
    img_urls = models.TextField(u'识别出来的图片',  null=True,  blank=True)
    thumb = models.TextField(verbose_name="类似",  blank=True, null=True)
    search = models.IntegerField(verbose_name="搜索排名", default=0)

    class Meta:
        db_table = "sa_pest_bank_new"
        verbose_name = "新病虫害知识库表"
        verbose_name_plural = verbose_name


#病虫害数据补充表
class MongoPestSupplement(models.Model):
    id = models.AutoField(primary_key=True)
    pestbank_id = models.CharField(max_length=50, default='')  # 病虫害知识库id
    user = models.CharField(u'用户', max_length=20, blank=True, null=True)
    content = models.TextField( verbose_name="补充内容",   null=True,  blank=True)
    # 0 未审核 1 审核通过
    review = models.CharField(max_length=5, verbose_name="是否审核", default=0)
    adtime = models.IntegerField(default=0)  # 补充数据时间

    class Meta:
        db_table = "sa_pest_supplement"
        verbose_name = "病虫害补充数据表"
        verbose_name_plural = verbose_name


#病虫害提问表
class MongoPestAnswers(models.Model):
    id = models.AutoField(primary_key=True)
    pestbank_id = models.CharField(max_length=50,blank=True, null=True)  # 病虫害知识库id
    user = models.CharField(u'用户', max_length=20, blank=True, null=True)
    title = models.CharField(u'标题', max_length=20, blank=True, null=True)
    content = models.TextField(verbose_name="问题描述",   null=True,  blank=True)
    img_urls = models.CharField(u'图片路径', max_length=500, null=True,  blank=True)
    lower = models.CharField(u'二级评论', max_length=20, null=True,  blank=True,default=0)
    # 0 普通用户 1 专家
    user_type = models.CharField(u'用户身份', max_length=20,default=0)
    # idea = models.CharField(max_length=300, verbose_name="专家回复",null=True,  blank=True)
    adtime = models.IntegerField(default=0)  # 创建时间
    uptime = models.IntegerField(default=0)  # 回复时间

    class Meta:
        db_table = "sa_pest_answers"
        verbose_name = "病虫害提问表"
        verbose_name_plural = verbose_name


#专家单位与院校
class MongoCooperationUnit(models.Model):
    id = models.AutoField(primary_key=True)
    briefing = models.TextField(u'简介', blank=True, null=True)
    name = models.CharField(u'名称', max_length=20, blank=True, null=True)
    img_urls = models.CharField(u'图片路径', max_length=300, null=True,  blank=True)
    code = models.CharField(u'单位与院校与专家', max_length=10, null=True,  blank=True)
    # code 1 单位  2 院校   3 专家
    class Meta:
        db_table = "sa_cooperation_unit"
        verbose_name = "专家单位与院校表"
        verbose_name_plural = verbose_name


#预警列表:
class MongoAlarm_Record(models.Model):
    id = models.AutoField(primary_key=True)
    equip_id = models.CharField(max_length=50)  #  设备id
    alarm_time = models.IntegerField(default=0) #  添加时间
    equip_type = models.CharField(max_length=50)  #  设备类型
    alarm_desc = models.TextField(u'预警描述', blank=True, null=True)

    class Meta:
        db_table = "sa_alarm_record"
        verbose_name = "设备预警"
        verbose_name_plural = verbose_name


# 用户操作日志：
class MongoMake_Log(models.Model):
    id = models.AutoField(primary_key=True)
    log_user = models.CharField(u'用户名', max_length=50, null=True, blank=True)
    log_time = models.IntegerField(default=0)  # 操作时间
    log_ip = models.CharField(u'IP地址', max_length=100, null=True, blank=True)
    log_desc = models.CharField(u'操作描述', max_length=100, null=True, blank=True)

    class Meta:
        db_table = "sa_make_log"
        verbose_name = u'用户操作日志表'
        verbose_name_plural = verbose_name


# 主题定制
class MongoRole_Table(models.Model):
    id = models.AutoField(primary_key=True)
    role_describe = models.CharField(u'角色描述', max_length=50, null=True, blank=True)
    role_cre_time = models.IntegerField(default=0)  # 角色添加时间
    role_cre_user = models.CharField(u'角色创建者', max_length=20, null=True, blank=True)
    role_logo = models.CharField(u'首页logo', max_length=200, default="/data/home_logo/log.jpg")
    role_footer = models.TextField(u'首页footer信息', default="Copyright©2007-2019 All Rrights Resvered　版权所有：河南云飞科技发展有限公司")
    role_header = models.TextField(u'首页header信息', default="智慧农业大数据平台")
    qr_show = models.BooleanField(default=True)

    class Meta:
        db_table = "sa_role_table"
        verbose_name = u'用户组列表'
        verbose_name_plural = verbose_name


# 投屏主题定制
class MongoRole_Projection(models.Model):
    RTid = models.PositiveIntegerField(default=0,unique=True)   # 主题ID
    role_company = models.CharField(u'公司名称', max_length=50, null=True, blank=True)
    projection_index_title = models.TextField(u'首页标题', default="5G+智慧农业云平台")
    projection_bzy_title = models.TextField(u'孢子仪标题', default="智能孢子监测系统")
    projection_fb_title = models.TextField(u'设备分布标题', default="设备分布展示")
    projection_zh_title = models.TextField(u'设备综合标题', default="数字监测预警系统")
    projection_cbd_title = models.TextField(u'测报灯标题', default="虫情测报系统")
    projection_qxz_title = models.TextField(u'气象站标题', default="气象监测系统")
    water_title = models.TextField(u'水肥默认标题', default="水肥一体控制系统展示大屏")
    elect_title = models.TextField(u'水电默认标题', default="机井水电双控系统展示大屏")
    wheat_scab = models.TextField(u'小麦赤霉病默认标题', default="小麦赤霉病检测平台")
    water_fertilizer_control = models.TextField(u'水肥一体控制默认标题', default="水肥一体控制系统(X)")

    class Meta:
        db_table = "sa_role_projection"
        verbose_name = u'投屏主题'
        verbose_name_plural = verbose_name


class MongoPest_distribute(models.Model):
    id = models.AutoField(primary_key=True)
    pest_name = models.CharField(max_length=50)     # 害虫名称
    province = models.CharField(u'害虫统计  省', max_length=50, default='')     # 省份
    city = models.CharField(u'害虫统计  市', max_length=50, default='')     # 市
    avg_num = models.CharField(max_length=10)        # 平均分布密度
    uptime = models.IntegerField(default=0)     # 统计更新时间 

    class Meta:
        db_table = "sa_pest_distribute"
        verbose_name = "害虫地域密度"
        verbose_name_plural = verbose_name