from djongo import models


#基地表
class MongoBase(models.Model):
    id = models.AutoField(primary_key=True)
    base_user = models.CharField(u"基地所属用户",max_length=20, null=True,  blank=True)
    base_name = models.CharField(u"基地名称",max_length=20, null=True,  blank=True)
    base_charge = models.CharField(u"负责人",max_length=20, null=True,  blank=True)
    base_phone = models.CharField(u'联系电话', max_length=20, null=True,  blank=True)
    base_img = models.CharField(u"基地图片", max_length=500, null=True,  blank=True)
    base_area = models.CharField(u"基地面积", max_length=10, null=True,  blank=True)
    base_equip = models.TextField(u"绑定设备", null=True,  blank=True)
    base_describe = models.TextField(u"基地描述", null=True,  blank=True)
    lng = models.CharField(u'经度',max_length=50, null=True,  blank=True)  # 经度
    lat = models.CharField(u'纬度',max_length=50, null=True,  blank=True)  # 纬度
    addtime = models.IntegerField(default=0)  # 基地创建时间

    class Meta:
        db_table = "sa_base_table"


# 农场信息表
class MongoFarmInfo(models.Model):
    id = models.AutoField(primary_key=True)
    farmname = models.CharField(u'农场名称', max_length=50, default='')
    farmaddr = models.CharField(u'农场地址', max_length=50, default='')
    farmdesc = models.CharField(u'农场描述', max_length=50, default='')
    farmarea = models.CharField(u'农场面积', max_length=50, default='')
    farmframe = models.CharField(u'农场坐标点', max_length=200, default='')
    user = models.CharField(u'所属用户', max_length=50, default='')
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_farm_info_record"


# 地块基础信息表
class MongoLandInfo(models.Model):
    id = models.AutoField(primary_key=True)
    farm = models.CharField(u'地块编号', max_length=50, default='')
    landname = models.CharField(u'地块名称', max_length=20, blank=True, null=True)
    landaddr = models.TextField(u'地块地址',default="")
    landarea = models.CharField(u'地块面积', max_length=20, blank=True, null=True)
    user = models.CharField(u'种植人', max_length=20, default=1)
    tel = models.CharField(u'联系方式', max_length=15, default="")
    is_delete = models.IntegerField(u"删除", default=1)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_land_info"


# 追溯码表
class MongoAscendCode(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farmid = models.CharField(u'基地id', max_length=50, default='')
    landid = models.CharField(u'地块id', max_length=50, default='')
    farmname = models.CharField(u'基地名称', max_length=20, blank=True, null=True)
    landname = models.CharField(u'地块名称', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    is_pick = models.IntegerField(u'是否采收', default=0)  # 0未采收 1已采收
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_ascendcode"


# 作物信息表
class MongoPlantInfo(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    batch = models.CharField(u'图片', max_length=20, blank=True, null=True)
    planttype = models.CharField(u'品种', max_length=20, blank=True, null=True)
    plantname = models.CharField(u'作物名称', max_length=20, blank=True, null=True)
    pickcode = models.CharField(u'显示颜色', max_length=20, default='0')  # 0未采收  1已采收
    is_delete = models.IntegerField(u'是否删除', default=1)  # 0删除 1 未删除
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_plant_info"


# 种植作物
class LandPlanInfo(models.Model):
    id = models.AutoField(primary_key=True)
    land_id = models.IntegerField("地块ID", default=1)
    plan_id = models.IntegerField("作物ID", default=0)
    recovery_kg = models.IntegerField("采收重量", default=0)
    recovery_time = models.IntegerField("采收时间", default=0)
    plan_time = models.IntegerField("种植时间", default=0)
    addtime = models.IntegerField("添加时间", default=0)
    status = models.CharField("作物状态", max_length=16, default="")
    is_delete = models.IntegerField(u'是否删除', default=1)  # 0删除 1 未删除

    class Meta:
        db_table = "sa_land_plan"



# 地块施肥表
class MongoAreaManure(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'操作地块', max_length=50, default='')
    manureuse = models.CharField(u'肥料用量', max_length=50, default='')
    batch = models.CharField(u'批次名称', max_length=20, blank=True, null=True)
    itemname = models.CharField(u'肥料名称', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_manura_info"


# 地块浇水表
class MongoAreaIrrigate(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'操作地块', max_length=50, default='')
    batch = models.CharField(u'批次名称', max_length=20, blank=True, null=True)
    area = models.CharField(u'灌溉面积', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_irrigate_info"


# 地块喷药表
class MongoAreaMedi(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'操作地块', max_length=50, default='')
    batch = models.CharField(u'批次名称', max_length=20, blank=True, null=True)
    mediname = models.CharField(u'药品名称', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_medi_info"


# 地块采收表
class MongoAreaPick(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    pickname = models.CharField(u'采收名称', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'操作地块', max_length=50, default='')
    batch = models.CharField(u'批次名称', max_length=20, blank=True, null=True)
    picktotal = models.CharField(u'采收总量', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_pick_info"


# 肥料入库表
class MongoPutStock(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'所属地块', max_length=50, default='')
    suppliesname = models.CharField(u'物料名称', max_length=50, default='')
    suppliescode = models.CharField(u'物料编号', max_length=50, default='')
    typename = models.CharField(u'品类', max_length=50, default='')
    stockbatch = models.CharField(u'入库批次', max_length=20, blank=True, null=True)
    stocknum = models.CharField(u'入库数量', max_length=20, blank=True, null=True)
    firm = models.CharField(u'生产企业', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_put_stock_info"


# 肥料出库表
class MongoOutStock(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'所属地块', max_length=50, default='')
    suppliesname = models.CharField(u'物料名称', max_length=50, default='')
    suppliescode = models.CharField(u'物料编号', max_length=50, default='')
    typename = models.CharField(u'品类', max_length=50, default='')
    stockbatch = models.CharField(u'出库批次', max_length=20, blank=True, null=True)
    stocknum = models.CharField(u'出库数量', max_length=20, blank=True, null=True)
    firm = models.CharField(u'生产企业', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_out_stock_info"


# 肥料库存表
class MongoStockInfo(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    farm = models.CharField(u'所属基地', max_length=50, default='')
    land = models.CharField(u'所属地块', max_length=50, default='')
    suppliesname = models.CharField(u'物料名称', max_length=50, default='')
    suppliescode = models.CharField(u'物料编号', max_length=50, default='')
    typename = models.CharField(u'品类', max_length=50, default='')
    stockbatch = models.CharField(u'库存', max_length=20, blank=True, null=True)
    stocknum = models.CharField(u'库存数量', max_length=20, blank=True, null=True)
    firm = models.CharField(u'生产企业', max_length=20, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_stock_info"


# 地块作业表
class MongoAreaJob(models.Model):
    id = models.AutoField(primary_key=True)
    land = models.IntegerField(u'操作地块', default=0)
    batch = models.CharField(u'图片', max_length=64, blank=True, null=True)
    jobname = models.TextField(u'操作事项', blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_job_info"


# 售卖信息表
class MongoSellInfo(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    sellname = models.CharField(u'产品名称', max_length=20, blank=True, null=True)
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    selltime = models.CharField(u'售卖时间', max_length=30, blank=True, null=True)
    batch = models.CharField(u'售卖批次', max_length=30, blank=True, null=True)
    sellnum = models.CharField(u'售卖数量', max_length=30, blank=True, null=True)
    clientname = models.CharField(u'客户名称', max_length=30, blank=True, null=True)
    clienttel = models.CharField(u'客户电话', max_length=30, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_sell_info"


# 运输信息表
class MongoTransportInfo(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    transname = models.CharField(u'产品名称', max_length=30, blank=True, null=True)
    stime = models.CharField(u'发货时间', max_length=30, blank=True, null=True)
    etime = models.CharField(u'到货时间', max_length=30, blank=True, null=True)
    saddr = models.CharField(u'发货地点', max_length=30, blank=True, null=True)
    province = models.CharField(u'省-到货地点', max_length=30, blank=True, null=True)
    city = models.CharField(u'市-到货地点', max_length=30, blank=True, null=True)
    area = models.CharField(u'县-到货地点', max_length=30, blank=True, null=True)
    eaddr = models.CharField(u'到货地点', max_length=30, blank=True, null=True)
    detailaddr = models.CharField(u'详细到货地址', max_length=100, blank=True, null=True)
    trans = models.CharField(u'运输方法', max_length=30, blank=True, null=True)
    batch = models.CharField(u'批次名称', max_length=30, blank=True, null=True)
    user = models.CharField(u'操作人', max_length=20, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_transport_info"


# 产品信息表
class MongoProductInfo(models.Model):
    id = models.AutoField(primary_key=True)
    # 此处预留追溯码
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    productphoto = models.CharField(u'产品图片', max_length=500, blank=True, null=True)
    productdesc = models.CharField(u'产品描述', max_length=500, blank=True, null=True)
    photo1 = models.CharField(u'生长期1', max_length=500, blank=True, null=True)
    photo2 = models.CharField(u'生长期2', max_length=500, blank=True, null=True)
    photo3 = models.CharField(u'生长期3', max_length=500, blank=True, null=True)
    photo4 = models.CharField(u'生长期4', max_length=500, blank=True, null=True)
    photo5 = models.CharField(u'生长期5', max_length=500, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_product_info"


# 质检信息表
class MongoQualityInfo(models.Model):
    id = models.AutoField(primary_key=True)
    backcode = models.CharField(u'溯源码', max_length=50, default='')
    qualitydesc = models.CharField(u'质检标题', max_length=30, blank=True, null=True)
    qualityphoto = models.CharField(u'质检图片', max_length=300, blank=True, null=True)
    uptime = models.IntegerField(u'操作时间', default=0)  # 修改时间

    class Meta:
        db_table = "sa_quality_info"


# 美丽乡村
class CountryModel(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField("标题", max_length=32, default="")
    introduce = models.TextField("简介", default="")
    content = models.TextField("正文", default="")
    uptime = models.IntegerField("添加时间", default=0)
    cover_img = models.CharField("封面", max_length=64, default="")
    is_delete = models.IntegerField("是否删除", default=1)
    

    class Meta:
        db_table = "sa_country"


# 作物生长周期
class PlanWeekend(models.Model):
    id = models.AutoField(primary_key=True)
    plan_id=models.IntegerField("作物id", default=1)
    name = models.CharField("周期名称", max_length=32, default="")
    start_time = models.CharField("开始时间", max_length=32, default="")
    end_time = models.CharField("结束时间", max_length=32, default="")
    pest = models.TextField("虫害", default="")
    pick = models.TextField("病害", default="")
    mark = models.CharField("备注", max_length=64,  default="")
    is_delete = models.IntegerField("是否删除", default=1)

    class Meta:
        db_table = "sa_plan_weekend"