203 lines
8.8 KiB
Python
203 lines
8.8 KiB
Python
|
# coding:utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
import os
|
||
|
import uuid
|
||
|
from django.contrib.gis.db import models
|
||
|
from g214 import settings
|
||
|
|
||
|
|
||
|
def content_file_name(instance, filename):
|
||
|
_, ext = os.path.splitext(filename)
|
||
|
instance.filename = filename
|
||
|
filename = str(uuid.uuid4()) + ext
|
||
|
|
||
|
return os.path.join('sources', filename)
|
||
|
|
||
|
|
||
|
# 试验场
|
||
|
class Land(models.Model):
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
name = models.CharField(u"名称", max_length=256, blank=True, null=True)
|
||
|
code = models.CharField(u"编号", max_length=256, blank=True, null=True)
|
||
|
length = models.FloatField(u"长度", blank=True, null=True)
|
||
|
width = models.FloatField(u"宽度", blank=True, null=True)
|
||
|
high = models.FloatField(u"高度", blank=True, null=True)
|
||
|
the_geom = models.PointField(u"坐标", blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.name
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'试验场'
|
||
|
|
||
|
|
||
|
# 仪器
|
||
|
class Equipment(models.Model):
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
code = models.CharField(u"编号", max_length=256, blank=True, null=True)
|
||
|
name = models.CharField(u"名称", max_length=256, blank=True, null=True)
|
||
|
description = models.CharField(u"描述", max_length=256, blank=True, null=True)
|
||
|
comment = models.CharField(u"备注", max_length=256, blank=True, null=True)
|
||
|
model = models.CharField(u"型号", max_length=256, blank=True, null=True)
|
||
|
unit = models.CharField(u"单位", max_length=256, blank=True, null=True)
|
||
|
producer = models.CharField(u"生产厂商", max_length=256, blank=True, null=True)
|
||
|
land = models.ForeignKey(Land, blank=True, null=True)
|
||
|
the_geom = models.PointField(u"坐标", blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.name
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'仪器'
|
||
|
|
||
|
|
||
|
# 截面
|
||
|
class Section(models.Model):
|
||
|
OWNER_CHOICES = (
|
||
|
('land', u'观测基地'),
|
||
|
('road', u'G214沿线'),
|
||
|
)
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
code = models.CharField(u"编号", max_length=256, blank=True, null=True)
|
||
|
name = models.CharField(u"名称", max_length=256, blank=True, null=True)
|
||
|
land = models.ForeignKey(Land, blank=True, null=True, verbose_name=u'所属场地')
|
||
|
owner = models.CharField(u"所属", max_length=256, choices=OWNER_CHOICES, null=True)
|
||
|
type = models.CharField(u"类型", max_length=256, blank=True, null=True)
|
||
|
thermometer = models.IntegerField(u"温度计个数", blank=True, null=True)
|
||
|
reinforcement = models.IntegerField(u"钢筋计个数", blank=True, null=True)
|
||
|
shift = models.IntegerField(u"位移个数", blank=True, null=True)
|
||
|
strain = models.IntegerField(u"应变个数", blank=True, null=True)
|
||
|
humidity = models.IntegerField(u"水分个数", blank=True, null=True)
|
||
|
the_geom = models.PointField(u"坐标", blank=True, null=True)
|
||
|
rtu = models.BooleanField(u"采集仪", default=False)
|
||
|
box = models.BooleanField(u"保护箱", default=False)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.name
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'截面'
|
||
|
|
||
|
|
||
|
# 孔
|
||
|
class Drilling(models.Model):
|
||
|
CATEGORY_CHOICES = ((1, u"竖向测温孔"), (2, u"天然孔"), (3, u"横孔"))
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
code = models.CharField(u"编号", max_length=256, blank=True, null=True)
|
||
|
name = models.CharField(u"名称", max_length=256, blank=True, null=True)
|
||
|
type = models.IntegerField(u"类型", choices=CATEGORY_CHOICES)
|
||
|
depth = models.FloatField(u"深度", blank=True, null=True)
|
||
|
the_geom = models.PointField(u"坐标", blank=True, null=True)
|
||
|
filename = models.CharField(u"文件名", max_length=256, blank=True, null=True)
|
||
|
file = models.FileField(u"文件", upload_to=content_file_name, blank=True, null=True)
|
||
|
section = models.ForeignKey(Section, blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.name
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'钻孔'
|
||
|
|
||
|
|
||
|
# 探头
|
||
|
class Probe(models.Model):
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
code = models.CharField(u"编号", max_length=256, blank=True, null=True)
|
||
|
name = models.CharField(u"名称", max_length=256, blank=True, null=True)
|
||
|
type = models.CharField(u"类型", max_length=256, blank=True, null=True)
|
||
|
depth = models.FloatField(u"深度", blank=True, null=True)
|
||
|
unit = models.CharField(u'工程单位', max_length=128, blank=True, null=True)
|
||
|
factor1 = models.CharField(u'factor1', max_length=32, blank=True, null=True)
|
||
|
factor2 = models.CharField(u'factor2', max_length=32, blank=True, null=True)
|
||
|
factor3 = models.CharField(u'factor3', max_length=32, blank=True, null=True)
|
||
|
factor4 = models.CharField(u'factor4', max_length=32, blank=True, null=True)
|
||
|
factor5 = models.CharField(u'factor5', max_length=32, blank=True, null=True)
|
||
|
factor6 = models.CharField(u'factor6', max_length=32, blank=True, null=True)
|
||
|
drilling = models.ForeignKey(Drilling, blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.name
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'探头'
|
||
|
|
||
|
|
||
|
# 探头数据
|
||
|
class ProbeData(models.Model):
|
||
|
id = models.UUIDField("id", primary_key=True, default=uuid.uuid4)
|
||
|
recorded = models.DateTimeField(u'采集日期', blank=True, null=True)
|
||
|
land_name = models.CharField(u'实验场名称', max_length=128, blank=True, null=True)
|
||
|
land_code = models.CharField(u'实验场编码', max_length=64, blank=True, null=True)
|
||
|
section_name = models.CharField(u'断面名称', max_length=128, blank=True, null=True)
|
||
|
section_code = models.CharField(u'断面编码', max_length=64, blank=True, null=True)
|
||
|
drilling_name = models.CharField(u'钻孔名称', max_length=128, blank=True, null=True)
|
||
|
drilling_code = models.CharField(u'钻孔编码', max_length=64, blank=True, null=True)
|
||
|
probe_name = models.CharField(u'探头名称', max_length=128, blank=True, null=True)
|
||
|
probe_code = models.CharField(u'探头编码', max_length=64, blank=True, null=True)
|
||
|
value1 = models.FloatField(u'值1', blank=True, null=True)
|
||
|
value2 = models.FloatField(u'值2', blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.recorded.strftime('%Y-%m-%d')
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'探头数据'
|
||
|
|
||
|
|
||
|
# 原始资料
|
||
|
class Sources(models.Model):
|
||
|
CATEGORY_CHOICES = (
|
||
|
(u'平面图', u'平面图'),
|
||
|
(u'断面图', u'断面图'),
|
||
|
)
|
||
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||
|
filename = models.CharField(u'文件名', max_length=256, blank=True, null=True)
|
||
|
file = models.FileField(u'文件', upload_to=content_file_name, blank=True, null=True)
|
||
|
category = models.CharField(u'文件分类', max_length=256, blank=True, null=True, choices=CATEGORY_CHOICES)
|
||
|
land = models.ForeignKey(Land, verbose_name=u"所属场地", blank=True, null=True)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'原始资料'
|
||
|
|
||
|
|
||
|
# 土工实验报告(含水率)
|
||
|
class SoilTest(models.Model):
|
||
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||
|
drilling_code = models.CharField(u'钻孔标号', max_length=256, blank=True, null=True)
|
||
|
sample_code = models.CharField(u'取样编号', max_length=256, blank=True, null=True)
|
||
|
top_depth = models.CharField(u'取样顶深', max_length=256, blank=True, null=True)
|
||
|
sample_length = models.CharField(u'取样长度', max_length=256, blank=True, null=True)
|
||
|
sample_type = models.CharField(u'取样类型', max_length=256, blank=True, null=True)
|
||
|
water_content = models.CharField(u'含水率', max_length=256, blank=True, null=True)
|
||
|
drilling = models.ForeignKey(Drilling, verbose_name=u'所属钻孔', blank=True, null=True)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'土工实验报告'
|
||
|
|
||
|
|
||
|
# 标准气象站
|
||
|
class Meteorological(models.Model):
|
||
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||
|
title = models.CharField(u'标题', max_length=256, blank=True, null=True)
|
||
|
filename = models.CharField(u'文件名', max_length=256, blank=True, null=True)
|
||
|
file = models.FileField(u'文件', upload_to=content_file_name, blank=True, null=True)
|
||
|
|
||
|
created = models.DateField(u'创建日期', auto_now_add=True, blank=True, null=True)
|
||
|
updated = models.DateField(u'更新日期', auto_now=True, blank=True, null=True)
|
||
|
|
||
|
def __unicode__(self):
|
||
|
return self.title
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'标准气象站'
|
||
|
|
||
|
|
||
|
class MeteorologicalImage(models.Model):
|
||
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||
|
image = models.ImageField(u'图片', upload_to='image', blank=True, null=True)
|
||
|
meteorological = models.ForeignKey(Meteorological, verbose_name=u'所属气象站', blank=True, null=True)
|
||
|
|
||
|
class Meta:
|
||
|
verbose_name_plural = u'标准气象站图片'
|