|
|
import datetime
|
|
|
from app.lib.Utils import Utils
|
|
|
from app.models.Base_model import Base
|
|
|
from sqlalchemy import Column, String, Integer, Float,Table, ForeignKey
|
|
|
from sqlalchemy.orm import relationship, backref
|
|
|
|
|
|
|
|
|
# 用户表
|
|
|
class EntityUser(Base):
|
|
|
__tablename__ = 'user'
|
|
|
|
|
|
user_id = Column(String(50), primary_key=True, comment="用户id")
|
|
|
user_name = Column(String(50), comment="用户昵称")
|
|
|
user_pwd = Column(String(50), comment="密码")
|
|
|
real_name = Column(String(50), comment="真实姓名")
|
|
|
user_sex = Column(Integer, comment="用户性别")
|
|
|
role_id = Column(String(50), comment="角色id")
|
|
|
user_phone = Column(String(50), comment="手机号")
|
|
|
remark = Column(String(500), comment="备用字段")
|
|
|
created_time = Column(String(50), default=Utils.get_time(), comment="用户创建时间")
|
|
|
update_time = Column(String(50), comment="用户更新时间")
|
|
|
is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
|
|
|
|
|
|
# 设备配置表
|
|
|
class DeviceConfig(Base):
|
|
|
__tablename__ = 'device_config'
|
|
|
|
|
|
id = Column(String(50), primary_key=True, comment="id")
|
|
|
box_temperature = Column(Float, comment="设备温度")
|
|
|
surface_temperature = Column(Float, comment="表面温度")
|
|
|
door_status = Column(Integer, comment="门状态")
|
|
|
light_status = Column(Integer, comment="灯光状态")
|
|
|
fan_status = Column(Integer, comment="风扇状态")
|
|
|
warning_light_status = Column(Integer, comment="报警灯状态")
|
|
|
lock_status = Column(Integer, comment="锁状态")
|
|
|
|
|
|
|
|
|
# 材料表
|
|
|
class ExperimentSpecimen(Base):
|
|
|
__tablename__ = "experiment_specimen"
|
|
|
|
|
|
id = Column(String(50), comment="id", primary_key=True)
|
|
|
specimen_name = Column(String(50), comment="样品名称")
|
|
|
battery_type = Column(String(50), comment="电池型号")
|
|
|
specimen_num = Column(String(50), comment="样品编号")
|
|
|
battery_specification = Column(String(255), comment="电池规格")
|
|
|
battery_manufacturers = Column(String(500), comment="电池厂家")
|
|
|
remark = Column(String(500), comment="备注")
|
|
|
|
|
|
created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
update_time = Column(String(50), comment="更新时间")
|
|
|
user_id = Column(String(50), comment="创建人")
|
|
|
user_name = Column(String(50), comment="用户昵称")
|
|
|
|
|
|
is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
md5 = Column(String(256), comment="md5值 样品名称+电池型号+样品编号+电池规格+电池厂家+备注")
|
|
|
|
|
|
|
|
|
# 实验信息表
|
|
|
class ExperimentInfo(Base):
|
|
|
__tablename__ = "experiment_info"
|
|
|
|
|
|
id = Column(String(50), comment="id", primary_key=True)
|
|
|
specimen_name = Column(String(50), comment="样品名称")
|
|
|
battery_type = Column(String(50), comment="电池型号")
|
|
|
specimen_num = Column(String(50), comment="样品编号")
|
|
|
battery_specification = Column(String(255), comment="电池规格")
|
|
|
battery_manufacturers = Column(String(500), comment="电池厂家")
|
|
|
remark = Column(String(500), comment="备注")
|
|
|
temperature = Column(Float, comment="设置温度")
|
|
|
expose_time = Column(Float, comment="暴露时间")
|
|
|
put_time = Column(Float, comment="放置时间")
|
|
|
short_circuit_param = Column(Float, comment="短路参数")
|
|
|
desc = Column(String(500), comment="描述")
|
|
|
|
|
|
created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
update_time = Column(String(50), comment="更新时间")
|
|
|
end_time = Column(String(50), comment="结束时间")
|
|
|
user_id = Column(String(50), comment="创建人")
|
|
|
user_name = Column(String(50), comment="用户昵称")
|
|
|
|
|
|
is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
state = Column(Integer, default=0, comment="状态 0:未开始 1:进行中 2:已完成 3:已取消")
|
|
|
|
|
|
specimen_id = Column(String(50), comment="材料表id")
|
|
|
channel_id = Column(String(256), comment="通道表id")
|
|
|
|
|
|
|
|
|
# 实验记录报表
|
|
|
class ExperimentReport(Base):
|
|
|
__tablename__ = "experiment_report"
|
|
|
|
|
|
id = Column(String(50), comment="id", primary_key=True)
|
|
|
experiment_id = Column(String(50), comment="实验表id")
|
|
|
channel_id = Column(String(50), comment="通道表id")
|
|
|
time = Column(Integer, default=0, comment="进行时间")
|
|
|
experiment_temperature = Column(Float, comment="实验温度")
|
|
|
surface_temperature = Column(Float, comment="表面温度")
|
|
|
battery_voltage = Column(Float, comment="电池电压")
|
|
|
battery_electricity = Column(Float, comment="电池电流")
|
|
|
recharge_capacity = Column(Float, comment="充电容量")
|
|
|
discharging_capacity = Column(Float, comment="放电容量")
|
|
|
internal_resistance = Column(Float, comment="内阻")
|
|
|
|
|
|
|
|
|
|
|
|
# 通道表
|
|
|
class Channel(Base):
|
|
|
__tablename__ = "channel"
|
|
|
|
|
|
id = Column(String(50), comment="id", primary_key=True)
|
|
|
name = Column(String(50), comment="通道名称")
|
|
|
status = Column(Integer, comment="状态 0:未使用 1:使用中")
|
|
|
last_start_time = Column(String(50), comment="最后开始时间")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 角色表
|
|
|
class EntityRole(Base):
|
|
|
__tablename__ = 'role'
|
|
|
|
|
|
role_id = Column(String(50), primary_key=True, comment="角色id")
|
|
|
role_name = Column(String(50), comment="角色名称")
|
|
|
role_code = Column(String(50), comment="角色代号")
|
|
|
role_level = Column(Integer, comment="角色等级")
|
|
|
remark = Column(String(500), comment="备用字段")
|
|
|
created_time = Column(String(50), default=Utils.get_time(), comment="角色创建时间")
|
|
|
update_time = Column(String(50), comment="角色更新时间")
|
|
|
is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
|
|
|
|
|
|
specimen_experiment = Table('specimen_experiment', Base.metadata,
|
|
|
Column('specimen_id', Integer, ForeignKey('specimen.specimen_id')),
|
|
|
Column('experiment_id', Integer, ForeignKey('experiment.experiment_id'))
|
|
|
)
|
|
|
|
|
|
|
|
|
# # 证物表
|
|
|
# class EntitySpecimen(Base):
|
|
|
# __tablename__ = "specimen"
|
|
|
#
|
|
|
# specimen_id = Column(String(50), comment="物品id", primary_key=True)
|
|
|
# specimen_name = Column(String(50), comment="物品名称")
|
|
|
# specimen_code = Column(String(50), comment="物品编号")
|
|
|
# specimen_type = Column(String(50), comment="物品类型")
|
|
|
# specimen_origin = Column(String(255), comment="物品来源")
|
|
|
# specimen_desc = Column(String(500), comment="物品描述")
|
|
|
# storage_location = Column(String(255), comment="存放位置")
|
|
|
# remark = Column(String(500), comment="备注")
|
|
|
# rfid = Column(String(50), comment="条码")
|
|
|
#
|
|
|
# inventory_status = Column(Integer, comment="库存状态") # 1,在库,2,出库
|
|
|
# rfid_state = Column(Integer, comment="条码状态") # 1,已绑定;2,未绑定
|
|
|
# '''
|
|
|
# 0:未消毒:没有消毒过;
|
|
|
# 1:三天内已消毒:在3天之内有消毒记录;
|
|
|
# 2:一周内已消毒:在7天之内有消毒记录;
|
|
|
# 3:一月内已消毒:在30天之内有消毒记录;
|
|
|
# 4:三月内已消毒:在90天之内有消毒记录;
|
|
|
# 5:半年内已消毒:在180天之内有消毒记录;
|
|
|
# 6:一年内已消毒:在365天之内有消毒记录;
|
|
|
# 7:超过一年未消毒:最近一次消毒已超过365天
|
|
|
# '''
|
|
|
# disinfection_state = Column(Integer, comment="消毒状态")
|
|
|
#
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
# user_id = Column(String(50), comment="创建人")
|
|
|
# user_name = Column(String(50), comment="用户昵称")
|
|
|
#
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
#
|
|
|
# last_disinf_time = Column(String(50), comment="最新一次消毒时间")
|
|
|
#
|
|
|
# experiments = relationship('EntityExperiment', secondary=specimen_experiment, back_populates='specimens')
|
|
|
#
|
|
|
#
|
|
|
# def to_dict(self):
|
|
|
# return dict(id=self.specimen_id, specimen_name = self.specimen_name, specimen_code=self.specimen_code,
|
|
|
# specimen_type=self.specimen_type, specimen_origin=self.specimen_origin,
|
|
|
# specimen_desc=self.specimen_desc, storage_location=self.storage_location,
|
|
|
# remark=self.remark, rfid=self.rfid, inventory_status=self.inventory_status,
|
|
|
# rfid_state=self.rfid_state, disinfection_state=self.disinfection_state,
|
|
|
# last_disinf_time = self.last_disinf_time,
|
|
|
# created_time=self.created_time, user_name=self.user_name)
|
|
|
#
|
|
|
# class EntityUseLog(Base):
|
|
|
# __tablename__ = "use_log"
|
|
|
# record_id = Column(String(50), comment="记录id",primary_key=True)
|
|
|
# specimen_id = Column(String(50), comment="物品id")
|
|
|
# specimen_name = Column(String(50), comment="物品名称")
|
|
|
# specimen_code = Column(String(50), comment="物品编号")
|
|
|
# operation_type = Column(String(50), comment="操作类型")
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
# user_id = Column(String(50), comment="创建人")
|
|
|
# user_name = Column(String(50), comment="用户昵称")
|
|
|
#
|
|
|
#
|
|
|
# class EntityTerminal(Base):
|
|
|
# __tablename__ = "terminals"
|
|
|
#
|
|
|
# id = Column(String(50), comment="id",primary_key=True)
|
|
|
# name = Column(String(50), comment="名称")
|
|
|
# title = Column(String(50), comment="标题")
|
|
|
# login_count = Column(Integer, comment="核验账号数")
|
|
|
# index_of_user = Column(Integer, comment="以第几人为使用者")
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
#
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
#
|
|
|
#
|
|
|
#
|
|
|
# class EntityWaitDisinfSpecimen(Base):
|
|
|
# __tablename__ = "wait_disinf_specimen"
|
|
|
# '''
|
|
|
# 待消毒物品记录 因一个证物可以在同一时间段被消毒多次
|
|
|
# '''
|
|
|
#
|
|
|
# record_id = Column(String(50), comment="记录id",primary_key=True)
|
|
|
# specimen_id = Column(String(50), comment="物品id")
|
|
|
#
|
|
|
# specimen_name = Column(String(50), comment="物品名称")
|
|
|
# specimen_code = Column(String(50), comment="物品编号")
|
|
|
# specimen_type = Column(String(50), comment="物品类型")
|
|
|
# specimen_origin = Column(String(255), comment="物品来源")
|
|
|
# specimen_desc = Column(String(500), comment="物品描述")
|
|
|
# storage_location = Column(String(255), comment="存放位置")
|
|
|
# remark = Column(String(500), comment="备注")
|
|
|
# rfid = Column(String(50), comment="条码")
|
|
|
#
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
# user_id = Column(String(50), comment="创建人")
|
|
|
# user_name = Column(String(50), comment="用户昵称")
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
# done = Column(Integer, default=0, comment="是否完成") # 0 未完成,1 已完成
|
|
|
# disinf_type = Column(Integer, comment="消毒类型") # 1 入库消毒,2 出库消毒,3 其他
|
|
|
#
|
|
|
#
|
|
|
# # 试验配置表 每个员工可以自定多个配置,以方便后续消毒操作
|
|
|
# class EntityExperimentConfig(Base):
|
|
|
# __tablename__ = "experiment_config"
|
|
|
#
|
|
|
# config_id = Column(String(), comment="id",primary_key=True)
|
|
|
# ozone_disinf = Column(Integer, comment="臭氧消毒")
|
|
|
# uv_disinf = Column(Integer, comment="紫外线消毒")
|
|
|
# ozone_conc = Column(String(50), comment="臭氧浓度")
|
|
|
# disinf_time = Column(String(50), comment="消毒时间")
|
|
|
# temperature = Column(String(50), comment="温度")
|
|
|
# humidity = Column(String(50), comment="湿度")
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
# user_id = Column(String(50), comment="创建人")
|
|
|
# user_name = Column(String(50), comment="用户昵称")
|
|
|
#
|
|
|
# config_name = Column(String(50), comment="配置名称")
|
|
|
# config_desc = Column(String(500), comment="配置描述")
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
#
|
|
|
#
|
|
|
# # 试验表
|
|
|
# class EntityExperiment(Base):
|
|
|
# __tablename__ = "experiment"
|
|
|
#
|
|
|
# experiment_id = Column(String(50), comment="消毒流程id", primary_key=True)
|
|
|
# name = Column(String(50), comment="名称")
|
|
|
#
|
|
|
# ozone_disinf = Column(Integer, comment="臭氧消毒")
|
|
|
# uv_disinf = Column(Integer, comment="紫外线消毒")
|
|
|
# ozone_conc = Column(String(50), comment="臭氧浓度")
|
|
|
# disinf_time = Column(String(50), comment="消毒时间")
|
|
|
# temperature = Column(String(50), comment="浓度")
|
|
|
# humidity = Column(String(50), comment="湿度")
|
|
|
#
|
|
|
# remark = Column(String(500), comment="备注信息")
|
|
|
# created_time = Column(String(50), default=Utils.get_time(), comment="创建时间")
|
|
|
# update_time = Column(String(50), comment="更新时间")
|
|
|
#
|
|
|
# user_id = Column(String(50), comment="创建人")
|
|
|
# user_name = Column(String(50), comment="用户昵称")
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
# state = Column(Integer, default=0, comment="状态")
|
|
|
#
|
|
|
# specimens = relationship('EntitySpecimen', secondary=specimen_experiment, back_populates='experiments')
|
|
|
#
|
|
|
# def to_dict(self):
|
|
|
# return dict(id=self.experiment_id, ozone_disinf=self.ozone_disinf, uv_disinf=self.uv_disinf,
|
|
|
# ozone_conc=self.ozone_conc, disinf_time=self.disinf_time, temperature=self.temperature,
|
|
|
# humidity=self.humidity, remark=self.remark, created_time=self.created_time, user_name=self.user_name)
|
|
|
#
|
|
|
#
|
|
|
# # 试验记录信息表
|
|
|
# class EntityExperimentRecord(Base):
|
|
|
# __tablename__ = "experiment_record"
|
|
|
#
|
|
|
# record_id = Column(String(50), comment="记录id", primary_key=True)
|
|
|
# update_time = Column(String(50), comment="试验记录更新时间")
|
|
|
# is_enabled = Column(Integer, default=0, comment="是否禁用或删除")
|
|
|
|