UPDATE
This commit is contained in:
@@ -169,6 +169,57 @@ class SensorData(SensorPayloadMixin, models.Model):
|
||||
return [assignment.plant for assignment in self.plant_assignments.select_related("plant").order_by("position", "id")]
|
||||
|
||||
|
||||
class Device(models.Model):
|
||||
"""نسخه نرمالشده هر سنسور داخل farm_data_sensordata."""
|
||||
|
||||
farm = models.ForeignKey(
|
||||
SensorData,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="devices",
|
||||
db_column="farm_uuid",
|
||||
)
|
||||
location = models.ForeignKey(
|
||||
"location_data.SoilLocation",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="devices",
|
||||
db_column="location_id",
|
||||
help_text="location مرتبط با این device",
|
||||
)
|
||||
sensor_name = models.CharField(
|
||||
max_length=64,
|
||||
db_index=True,
|
||||
help_text='نام سنسور مثل "sensor-7-1"',
|
||||
)
|
||||
payload = models.JSONField(
|
||||
default=dict,
|
||||
blank=True,
|
||||
help_text="payload همان سنسور",
|
||||
)
|
||||
cluster_uuid = models.UUIDField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="uuid کلاستر داخل location برای این سنسور",
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "farm_data_device"
|
||||
ordering = ["sensor_name", "id"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["farm", "sensor_name"],
|
||||
name="farm_data_unique_device_per_farm_sensor",
|
||||
)
|
||||
]
|
||||
verbose_name = "device"
|
||||
verbose_name_plural = "devices"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.farm_id}::{self.sensor_name}"
|
||||
|
||||
|
||||
class PlantCatalogSnapshot(models.Model):
|
||||
"""
|
||||
کپی خواندنی از کاتالوگ گیاه Backend برای مصرف ماژولهای AI.
|
||||
|
||||
Reference in New Issue
Block a user