287 lines
13 KiB
Python
287 lines
13 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, String, DateTime, Integer, Text, ForeignKey, Index, BigInteger
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database import Base
|
|
|
|
|
|
class Event(Base):
|
|
__tablename__ = "event"
|
|
|
|
eventId = Column(String(50), primary_key=True)
|
|
tenantInfoId = Column(String(100))
|
|
reportEventId = Column(String(100))
|
|
number = Column(String(20))
|
|
name = Column(String(20))
|
|
eclassify = Column(String(5))
|
|
operationType = Column(String(5))
|
|
etype = Column(String(20))
|
|
etypeName = Column(String(20))
|
|
enTypeName = Column(String(30))
|
|
hkTypeName = Column(String(20))
|
|
reportStatus = Column(String(5))
|
|
results = Column(String(5))
|
|
insDate = Column(DateTime)
|
|
insDateShow = Column(DateTime)
|
|
updDate = Column(DateTime)
|
|
updDateShow = Column(DateTime)
|
|
fileType = Column(String(5))
|
|
area = Column(String(20))
|
|
floor = Column(String(10))
|
|
map = Column(String(20))
|
|
staffId = Column(String(40))
|
|
targetUserId = Column(String(40))
|
|
position = Column(String(100))
|
|
actualStaffName = Column(String(20))
|
|
targetStaffName = Column(String(20))
|
|
routeName = Column(String(20))
|
|
phoneAddress = Column(String(500))
|
|
width = Column(String(10))
|
|
height = Column(String(10))
|
|
resolution = Column(String(10))
|
|
originX = Column(String(20))
|
|
originY = Column(String(20))
|
|
imgList = Column(String(500))
|
|
robotType = Column(String(5))
|
|
eventFloor = Column(String(10))
|
|
floorName = Column(String(10))
|
|
coordId = Column(String(40))
|
|
coord = Column(String(40))
|
|
coordName = Column(String(30))
|
|
positonName = Column(String(20))
|
|
processingRemark = Column(String(300))
|
|
carId = Column(String(40))
|
|
parkingSpaceType = Column(String(10))
|
|
parkingSpaceNumber = Column(String(40))
|
|
carNumber = Column(String(40))
|
|
eno = Column(String(40))
|
|
instrument = Column(String(40))
|
|
evideo = Column(String(40))
|
|
createTime = Column(DateTime, default=datetime.now, comment='本地后台创建时间')
|
|
updateTime = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='本地后台更新时间')
|
|
|
|
# 关系
|
|
images = relationship("Image", back_populates="event", cascade="all, delete", passive_deletes=True)
|
|
temperatures = relationship("Temperature", back_populates="event", cascade="all, delete", passive_deletes=True)
|
|
process_logs = relationship("ProcessLog", back_populates="event", cascade="all, delete", passive_deletes=True)
|
|
messages = relationship("Message", back_populates="event", cascade="all, delete", passive_deletes=True)
|
|
|
|
|
|
class Image(Base):
|
|
__tablename__ = "image"
|
|
|
|
imageId = Column(BigInteger, primary_key=True, autoincrement=True, comment='图片ID')
|
|
eventId = Column(String(50), ForeignKey('event.eventId', ondelete="CASCADE"), nullable=False, comment='关联事件ID')
|
|
imageUrl = Column(String(500), nullable=False, comment='图片URL')
|
|
localPath = Column(String(500), comment='本地存储路径')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
|
|
# 关系
|
|
event = relationship("Event", back_populates="images" )
|
|
temperatures = relationship("Temperature", back_populates="image")
|
|
|
|
__table_args__ = (
|
|
Index('idx_image_event_id', 'eventId'),
|
|
)
|
|
|
|
|
|
class Temperature(Base):
|
|
__tablename__ = "temperature"
|
|
|
|
tempId = Column(BigInteger, primary_key=True, autoincrement=True, comment='温度记录ID')
|
|
eventId = Column(String(50), ForeignKey('event.eventId', ondelete="CASCADE"), nullable=False, comment='关联事件ID')
|
|
imageId = Column(BigInteger, ForeignKey('image.imageId', ondelete="CASCADE"), nullable=False, comment='关联图片ID')
|
|
temperature = Column(String(100), nullable=False, comment='温度值')
|
|
status = Column(String(5), comment='温度是否正常')
|
|
confidence = Column(String(40), nullable=False, comment='识别置信度')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
|
|
# 关系
|
|
event = relationship("Event", back_populates="temperatures")
|
|
image = relationship("Image", back_populates="temperatures")
|
|
|
|
__table_args__ = (
|
|
Index('idx_temp_event_id', 'eventId'),
|
|
Index('idx_temp_create_time', 'createTime'),
|
|
)
|
|
|
|
|
|
class ProcessLog(Base):
|
|
__tablename__ = "process_log"
|
|
|
|
logId = Column(BigInteger, primary_key=True, autoincrement=True, comment='日志ID')
|
|
eventId = Column(String(50), ForeignKey('event.eventId', ondelete="CASCADE"), nullable=False, comment='关联事件ID')
|
|
processStatus = Column(Integer, nullable=False, comment='处理状态')
|
|
errorMessage = Column(Text, comment='错误信息')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
|
|
# 关系
|
|
event = relationship("Event", back_populates="process_logs")
|
|
|
|
__table_args__ = (
|
|
Index('idx_log_event_id', 'eventId'),
|
|
Index('idx_log_create_time', 'createTime'),
|
|
)
|
|
|
|
class Message(Base):
|
|
__tablename__ = "message"
|
|
|
|
messageId = Column(BigInteger, primary_key=True, autoincrement=True, comment='消息ID')
|
|
eventId = Column(String(50), ForeignKey('event.eventId', ondelete="CASCADE"), nullable=False, comment='关联事件ID')
|
|
messageType = Column(String(5), comment='消息类型')
|
|
eventType = Column(String(5), comment='事件类型')
|
|
handle = Column(String(5), default='0', comment='是否处理' )
|
|
remark = Column(String(500), comment='备注')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
updateTime = Column(DateTime, default=datetime.now, nullable=False, comment='更新时间')
|
|
|
|
event = relationship("Event", back_populates="messages")
|
|
|
|
__table_args__ = (
|
|
Index('idx_message_event_id', 'eventId'),
|
|
Index('idx_message_create_time', 'createTime'),
|
|
Index('idx_message_update_time', 'updateTime'),
|
|
)
|
|
|
|
|
|
class Robot(Base):
|
|
__tablename__ = "robot"
|
|
|
|
robotId = Column(String(100), primary_key=True, comment='机器人ID')
|
|
number = Column(String(50), comment='机器人名称/名称')
|
|
groupingId = Column(String(100), comment='分组ID')
|
|
onlineStatus = Column(String(5), comment='在线状态')
|
|
status = Column(String(5), comment='机器人状态')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
updateTime = Column(DateTime, default=datetime.now, nullable=False, comment='更新时间')
|
|
|
|
# info_records = relationship(
|
|
# "RobotInfo",
|
|
# back_populates="robot",
|
|
# cascade="all, delete-orphan" # 可选:级联删除关联记录
|
|
# )
|
|
|
|
|
|
class RobotInfo(Base):
|
|
__tablename__ = "robot_info"
|
|
|
|
robotInfoId = Column(BigInteger, primary_key=True, autoincrement=True, comment='机器人信息ID')
|
|
robotId = Column(String(100), ForeignKey('robot.robotId', ondelete="CASCADE"), nullable=False, comment='关联机器人ID')
|
|
number = Column(String(50), comment="机器人名")
|
|
hkStstusName = Column(String(20), comment='香港状态名称')
|
|
code = Column(String(5), comment='状态码')
|
|
errorType = Column(String(5), comment='错误类型')
|
|
remoteControl = Column(String(5), comment='远程控制状态')
|
|
buttonStop = Column(String(5), comment='按钮停止状态')
|
|
vertical = Column(String(5), comment='垂直状态')
|
|
versionName = Column(String(50), comment='版本名称')
|
|
theta = Column(String(20), comment='角度')
|
|
speed = Column(String(5), comment='速度')
|
|
routeName = Column(String(20), comment='路线名称')
|
|
charingTaskStatus = Column(String(5), comment='充电任务状态')
|
|
socketType = Column(String(5), comment='插座类型')
|
|
horizontal = Column(String(5), comment='水平状态')
|
|
ststusName = Column(String(20), comment='状态名称')
|
|
enStstusName = Column(String(20), comment='英文状态名称')
|
|
aistatus = Column(String(5), comment='AI状态')
|
|
pm2_5 = Column(String(20), comment='PM2.5')
|
|
temperature = Column(String(20), comment='温度')
|
|
humidity = Column(String(20), comment='湿度')
|
|
power = Column(String(5), comment='电量')
|
|
floor = Column(String(5), comment='楼层')
|
|
map = Column(String(20), comment='地图')
|
|
mileage = Column(String(5), comment='里程')
|
|
area = Column(String(5), comment='区域')
|
|
nextTaskTime = Column(String(20), comment='下一个任务时间')
|
|
address = Column(String(500), comment='地址')
|
|
fromUserId = Column(String(100), comment='用户ID')
|
|
ip = Column(String(50), comment='IP地址')
|
|
pm10 = Column(String(20), comment='PM10')
|
|
index = Column(String(20), comment='索引')
|
|
message = Column(String(500), comment='消息')
|
|
versionCode = Column(String(50), comment='版本代码')
|
|
videoStatus = Column(String(5), comment='视频状态')
|
|
voltage = Column(String(20), comment='电压')
|
|
focal = Column(String(20), comment='焦距')
|
|
ststus = Column(String(5), comment='状态')
|
|
positon = Column(String(100), comment='位置')
|
|
robotType = Column(String(20), comment='机器人类型')
|
|
clearCharingTaskTime = Column(String(20), comment='清除充电任务时间')
|
|
cmd = Column(String(20), comment='命令')
|
|
vehicleid = Column(String(100), comment='车辆ID')
|
|
device = Column(String(100), comment='设备')
|
|
status = Column(String(5), comment='状态')
|
|
flvPtz = Column(String(500), comment="流")
|
|
flvTherm = Column(String(500), comment="流")
|
|
flvThermLight = Column(String(500), comment="流")
|
|
|
|
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
updateTime = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
|
|
|
# robot = relationship("Robot", back_populates="robot_info")
|
|
|
|
__table_args__ = (
|
|
Index('idx_robot_info_robot_id', 'robotId'),
|
|
Index('idx_robot_info_create_time', 'createTime'),
|
|
Index('idx_robot_info_update_time', 'updateTime'),
|
|
)
|
|
|
|
|
|
class Group(Base):
|
|
__tablename__ = "group"
|
|
groupingId = Column(String(100), primary_key=True, comment="分组id")
|
|
name = Column(String(20), comment="组名")
|
|
|
|
# 后续可能要单独拆分一张表
|
|
tenantInfoId = Column(String(100), comment="租户Id")
|
|
|
|
|
|
# 组和机器人对应表
|
|
class GroupRobot(Base):
|
|
__tablename__ = "group_robot"
|
|
|
|
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="id主键")
|
|
groupingId = Column(String(100), ForeignKey('group.groupingId', ondelete="CASCADE"),comment='分组ID')
|
|
robotId = Column(String(100), ForeignKey("robot.robotId", ondelete="CASCADE"), comment='机器人ID')
|
|
|
|
class Task(Base):
|
|
__tablename__ = "task"
|
|
|
|
robotId = Column(String(100), primary_key=True, comment='机器人ID')
|
|
robotNumber = Column(String(50), comment='机器人编号')
|
|
routeNumber = Column(String(50), comment='路线编号')
|
|
routeId = Column(String(100), comment='路线ID')
|
|
coordId = Column(String(100), comment='坐标ID')
|
|
camera = Column(String(100), comment='摄像头信息')
|
|
speed = Column(String(10), comment='速度')
|
|
times = Column(String(100), comment='执行时间')
|
|
timeQuantum = Column(String(100), comment='时间段')
|
|
phoneAddress = Column(String(500), comment='图片地址')
|
|
originX = Column(String(20), comment='原点X坐标')
|
|
originY = Column(String(20), comment='原点Y坐标')
|
|
resolution = Column(String(20), comment='分辨率')
|
|
width = Column(String(10), comment='宽度')
|
|
height = Column(String(10), comment='高度')
|
|
patrolType = Column(String(5), comment='巡逻类型')
|
|
coord = Column(String(100), comment='坐标')
|
|
points = Column(String(1000), comment='点位信息')
|
|
secondaryPoints = Column(String(1000), comment='次要点位信息')
|
|
trackPoints = Column(String(1000), comment='轨迹点位信息')
|
|
area = Column(String(50), comment='区域')
|
|
floor = Column(String(20), comment='楼层')
|
|
patrolVersion = Column(Integer, comment='巡逻版本')
|
|
routeVersion = Column(Integer, comment='路线版本')
|
|
tenantId = Column(String(100), comment='租户ID')
|
|
robotType = Column(String(10), comment='机器人类型')
|
|
patrolMode = Column(String(5), comment='巡逻模式')
|
|
chargePower = Column(String(10), comment='充电功率')
|
|
runPower = Column(String(10), comment='运行功率')
|
|
inDoorPatrolList = Column(String(1000), comment='室内巡逻列表')
|
|
createTime = Column(DateTime, default=datetime.now, nullable=False, comment='创建时间')
|
|
updateTime = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
|
|
|
__table_args__ = (
|
|
{'comment': '机器人任务表'},
|
|
)
|
|
|
|
|