from djongo import models


# 气象站基础信息表
class MongoQXZ_Base_Info(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    volt = models.CharField(u'电压', max_length=20, blank=True, null=True)
    rssi = models.CharField(u'信号强度', max_length=20, blank=True, null=True)
    iccid = models.CharField(u'设备卡号', max_length=50, blank=True, null=True)
    lng = models.CharField(u'经度', max_length=50, blank=True, null=True)
    lat = models.CharField(u'纬度', max_length=50, blank=True, null=True)
    led = models.CharField(u'led点阵屏', max_length=10, blank=True, null=True)
    ledinfo = models.CharField(u'led屏幕内容', max_length=100, blank=True, null=True)
    dver = models.CharField(u'设备版本号', max_length=100, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_qxz_base_info"


# 气象站基础信息表
class MongoQXZ_Info_Record(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    volt = models.CharField(u'电压', max_length=20, blank=True, null=True)
    rssi = models.CharField(u'信号强度', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_qxz_info_record"


# 新气象站全部数据记录
class QXZdata_New(models.Model):

    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    uptime = models.IntegerField(default=0)  # 修改时间
    e1 = models.CharField(u'通道1', max_length=30, blank=True, null=True)
    e2 = models.CharField(u'通道2', max_length=30, blank=True, null=True)
    e3 = models.CharField(u'通道3', max_length=30, blank=True, null=True)
    e4 = models.CharField(u'通道4', max_length=30, blank=True, null=True)
    e5 = models.CharField(u'通道5', max_length=30, blank=True, null=True)
    e6 = models.CharField(u'通道6', max_length=30, blank=True, null=True)
    e7 = models.CharField(u'通道7', max_length=30, blank=True, null=True)
    e8 = models.CharField(u'通道8', max_length=30, blank=True, null=True)
    e9 = models.CharField(u'通道9', max_length=30, blank=True, null=True)
    e10 = models.CharField(u'通道10', max_length=30, blank=True, null=True)
    e11 = models.CharField(u'通道11', max_length=30, blank=True, null=True)
    e12 = models.CharField(u'通道12', max_length=30, blank=True, null=True)
    e13 = models.CharField(u'通道13', max_length=30, blank=True, null=True)
    e14 = models.CharField(u'通道14', max_length=30, blank=True, null=True)
    e15 = models.CharField(u'通道15', max_length=30, blank=True, null=True)
    e16 = models.CharField(u'通道16', max_length=30, blank=True, null=True)
    e17 = models.CharField(u'通道17', max_length=30, blank=True, null=True)
    e18 = models.CharField(u'通道18', max_length=30, blank=True, null=True)
    e19 = models.CharField(u'通道19', max_length=30, blank=True, null=True)
    e20 = models.CharField(u'通道20', max_length=30, blank=True, null=True)
    e21 = models.CharField(u'通道21', max_length=30, blank=True, null=True)
    e22 = models.CharField(u'通道22', max_length=30, blank=True, null=True)
    e23 = models.CharField(u'通道23', max_length=30, blank=True, null=True)
    e24 = models.CharField(u'通道24', max_length=30, blank=True, null=True)
    e25 = models.CharField(u'通道25', max_length=30, blank=True, null=True)
    e26 = models.CharField(u'通道26', max_length=30, blank=True, null=True)
    e27 = models.CharField(u'通道27', max_length=30, blank=True, null=True)
    e28 = models.CharField(u'通道28', max_length=30, blank=True, null=True)
    e29 = models.CharField(u'通道29', max_length=30, blank=True, null=True)
    e30 = models.CharField(u'通道30', max_length=30, blank=True, null=True)

    class Meta:
        db_table = "sa_qxz_data"


# 值#enum#通道
# 新气象站配置表
class MongoQXZ_Conf(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    e1 = models.CharField(u'通道1', max_length=30, blank=True, null=True)
    e2 = models.CharField(u'通道2', max_length=30, blank=True, null=True)
    e3 = models.CharField(u'通道3', max_length=30, blank=True, null=True)
    e4 = models.CharField(u'通道4', max_length=30, blank=True, null=True)
    e5 = models.CharField(u'通道5', max_length=30, blank=True, null=True)
    e6 = models.CharField(u'通道6', max_length=30, blank=True, null=True)
    e7 = models.CharField(u'通道7', max_length=30, blank=True, null=True)
    e8 = models.CharField(u'通道8', max_length=30, blank=True, null=True)
    e9 = models.CharField(u'通道9', max_length=30, blank=True, null=True)
    e10 = models.CharField(u'通道10', max_length=30, blank=True, null=True)
    e11 = models.CharField(u'通道11', max_length=30, blank=True, null=True)
    e12 = models.CharField(u'通道12', max_length=30, blank=True, null=True)
    e13 = models.CharField(u'通道13', max_length=30, blank=True, null=True)
    e14 = models.CharField(u'通道14', max_length=30, blank=True, null=True)
    e15 = models.CharField(u'通道15', max_length=30, blank=True, null=True)
    e16 = models.CharField(u'通道16', max_length=30, blank=True, null=True)
    e17 = models.CharField(u'通道17', max_length=30, blank=True, null=True)
    e18 = models.CharField(u'通道18', max_length=30, blank=True, null=True)
    e19 = models.CharField(u'通道19', max_length=30, blank=True, null=True)
    e20 = models.CharField(u'通道20', max_length=30, blank=True, null=True)
    e21 = models.CharField(u'通道21', max_length=30, blank=True, null=True)
    e22 = models.CharField(u'通道22', max_length=30, blank=True, null=True)
    e23 = models.CharField(u'通道23', max_length=30, blank=True, null=True)
    e24 = models.CharField(u'通道24', max_length=30, blank=True, null=True)
    e25 = models.CharField(u'通道25', max_length=30, blank=True, null=True)
    e26 = models.CharField(u'通道26', max_length=30, blank=True, null=True)
    e27 = models.CharField(u'通道27', max_length=30, blank=True, null=True)
    e28 = models.CharField(u'通道28', max_length=30, blank=True, null=True)
    e29 = models.CharField(u'通道29', max_length=30, blank=True, null=True)
    e30 = models.CharField(u'通道30', max_length=30, blank=True, null=True)
    uptime = models.IntegerField(default=0)  # 修改时间

    class Meta:
        db_table = "sa_qxz_conf"

        
        
# 气象站短信预警
class MongoQXZ_Alarm_New(models.Model):
    id = models.AutoField(primary_key=True)
    user_id = models.CharField(u"用户id",max_length=50, default='')
    warning_id = models.CharField(u"预警设置id",max_length=50, default='')
    device_id = models.CharField(u'设备号',max_length=50, default='')
    conf = models.TextField(u'短信配置', blank=True, null=True)
    send_user_id = models.TextField(u'多个联系人id',default='')
    upl_time = models.IntegerField(u'上报时间',default=0)

    class Meta:
        db_table = "sa_qxz_alarm_new"
        
        
# 气象站短信预警记录
class MongoQXZ_Alarm_Log_New(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='') # 设备id
    user_id = models.CharField(u"用户id", max_length=50, default='')
    warning_name = models.CharField(u"预警设置名称",max_length=50, default='')
    ekey = models.TextField(u'通道号', blank=True)
    warning_content = models.TextField(u"预警内容",default='')
    send_user = models.TextField(u"发送用户",default='')
    status = models.IntegerField(u"是否已读",default=0) # 0未读 1已读
    upl_time = models.IntegerField(u'上报时间', default=0)

    class Meta:
        db_table = "sa_qxz_alarm_log_new"



# 气象站开关配置表
class MongoQXZ_Switch(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='') # 设备id
    upl_time = models.IntegerField(u'上报时间', default=0)
    qxz_switch_data = models.TextField(u'气象站开关名字',blank=True, null=True)

    class Meta:
        db_table = "sa_qxz_switch"


# 气象站阈值表
class MongoQXZ_Auto_Switch(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='') # 设备id
    upl_time = models.IntegerField(u'上报时间', default=0)
    qxz_auto = models.TextField(u'气象站阈值', blank=True, null=True)

    class Meta:
        db_table = "sa_qxz_auto_switch"


# 气象站开关定时表
class MongoQXZ_Timing_Switch(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='') # 设备id
    upl_time = models.IntegerField(u'上报时间', default=0)
    qxz_timing = models.TextField(u'气象站开关定时', blank=True, null=True)

    class Meta:
        db_table = "sa_qxz_timing_switch"



class MongoND_qxz_status(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='') # 设备id
    lat = models.CharField(u'纬度',max_length=50)
    lng = models.CharField(u'经度',max_length=50)
    topic = models.CharField(u'列标题',max_length=10,default='10')
    inidepth = models.CharField(u'初始深度',max_length=10,default='10')
    depth = models.CharField(u'层级深度',max_length=50,default='')
    csq = models.CharField(u'信号强度',max_length=10)
    temp = models.CharField(u'土壤温度',max_length=50)
    swc = models.CharField(u'土壤湿度',max_length=50)
    atm = models.CharField(u'大气压强',max_length=10)
    at = models.CharField(u'空气温度',max_length=10)
    ats = models.CharField(u'空气湿度',max_length=10)
    upl_time = models.IntegerField(u'上报时间', default=0)

    class Meta:
        db_table = "sa_nd_qxz_status"


# 新气象站状态记录：
class QXZstatus_New(models.Model):

    id = models.AutoField(primary_key=True)
    device_id = models.CharField(max_length=50, default='')  # 设备id
    is_online = models.CharField(u'在线状态', max_length=5, blank=True,null=True)
    # off_time = models.DateTimeField(u'离线时间', blank=True,null=True)
    # upl_time = models.DateTimeField(u'数据上传时间', default=timezone.now)
    uptime = models.IntegerField(default=0)  # 修改时间
    e1 = models.CharField(u'通道1', max_length=30, blank=True, null=True)
    e2 = models.CharField(u'通道2', max_length=30, blank=True, null=True)
    e3 = models.CharField(u'通道3', max_length=30, blank=True, null=True)
    e4 = models.CharField(u'通道4', max_length=30, blank=True, null=True)
    e5 = models.CharField(u'通道5', max_length=30, blank=True, null=True)
    e6 = models.CharField(u'通道6', max_length=30, blank=True, null=True)
    e7 = models.CharField(u'通道7', max_length=30, blank=True, null=True)
    e8 = models.CharField(u'通道8', max_length=30, blank=True, null=True)
    e9 = models.CharField(u'通道9', max_length=30, blank=True, null=True)
    e10 = models.CharField(u'通道10', max_length=30, blank=True, null=True)
    e11 = models.CharField(u'通道11', max_length=30, blank=True, null=True)
    e12 = models.CharField(u'通道12', max_length=30, blank=True, null=True)
    e13 = models.CharField(u'通道13', max_length=30, blank=True, null=True)
    e14 = models.CharField(u'通道14', max_length=30, blank=True, null=True)
    e15 = models.CharField(u'通道15', max_length=30, blank=True, null=True)
    e16 = models.CharField(u'通道16', max_length=30, blank=True, null=True)
    e17 = models.CharField(u'通道17', max_length=30, blank=True, null=True)
    e18 = models.CharField(u'通道18', max_length=30, blank=True, null=True)
    e19 = models.CharField(u'通道19', max_length=30, blank=True, null=True)
    e20 = models.CharField(u'通道20', max_length=30, blank=True, null=True)
    e21 = models.CharField(u'通道21', max_length=30, blank=True, null=True)
    e22 = models.CharField(u'通道22', max_length=30, blank=True, null=True)
    e23 = models.CharField(u'通道23', max_length=30, blank=True, null=True)
    e24 = models.CharField(u'通道24', max_length=30, blank=True, null=True)
    e25 = models.CharField(u'通道25', max_length=30, blank=True, null=True)
    e26 = models.CharField(u'通道26', max_length=30, blank=True, null=True)
    e27 = models.CharField(u'通道27', max_length=30, blank=True, null=True)
    e28 = models.CharField(u'通道28', max_length=30, blank=True, null=True)
    e29 = models.CharField(u'通道29', max_length=30, blank=True, null=True)
    e30 = models.CharField(u'通道30', max_length=30, blank=True, null=True)
    # lng = models.CharField(u'经度', max_length=50, blank=True)
    # lat = models.CharField(u'维度', max_length=50, blank=True)
    # qxz_picture = models.ImageField(u'气象站图片', upload_to="qxz_photo/", default="qxz_photo/default.png")
    interval = models.CharField(u'设备数据上传时间间隔', max_length=30, blank=True, null=True)

    class Meta:
        db_table = "sa_qxz_status"
        # verbose_name = u'气象站-状态表-新'
        # verbose_name_plural = verbose_name
        # ordering = ['-equip_id__equip_add_time']
        # get_latest_by = 'equip_id__equip_add_time'


# 气象站预警表
class QXZThresholdWarning(models.Model):
    id = models.AutoField(primary_key=True)
    device_id = models.CharField(u"设备id",max_length=50, default='')
    warning_content = models.TextField(u"预警内容",default='')
    ekey = models.CharField(u'通道号',max_length=20, blank=True)
    set_value = models.CharField(u'设置预警值',max_length=20, blank=True)
    current_value = models.CharField(u'当前预警值',max_length=20, blank=True)
    upltime = models.IntegerField(u"预警时间",default=0)
    status = models.IntegerField(u"是否已读",default=0) # 0未读 1已读

    class Meta:
        db_table = "sa_device_threshold_warning"
        