scene.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. from sqlalchemy import Column, Integer, String, Text, BigInteger
  2. from database import Base
  3. class Scene(Base):
  4. """总场景表"""
  5. __tablename__ = "scene"
  6. id = Column(BigInteger, primary_key=True, autoincrement=True)
  7. scene_name = Column(String(255), nullable=False, comment="场景名称")
  8. scene_en_name = Column(String(255), default="", comment="场景英文名")
  9. created_at = Column(BigInteger, comment="创建时间")
  10. updated_at = Column(BigInteger, comment="更新时间")
  11. deleted_at = Column(BigInteger, comment="删除时间")
  12. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  13. class FirstScene(Base):
  14. """一级场景表"""
  15. __tablename__ = "first_scene"
  16. id = Column(BigInteger, primary_key=True, autoincrement=True)
  17. first_scene_name = Column(String(255), nullable=False, comment="一级场景名称")
  18. scene_id = Column(BigInteger, nullable=False, comment="场景ID")
  19. created_at = Column(BigInteger, comment="创建时间")
  20. updated_at = Column(BigInteger, comment="更新时间")
  21. deleted_at = Column(BigInteger, comment="删除时间")
  22. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  23. class SecondScene(Base):
  24. """二级场景表"""
  25. __tablename__ = "second_scene"
  26. id = Column(BigInteger, primary_key=True, autoincrement=True)
  27. second_scene_name = Column(String(255), nullable=False, comment="二级场景名称")
  28. first_scene_id = Column(BigInteger, nullable=False, comment="一级场景ID")
  29. created_at = Column(BigInteger, comment="创建时间")
  30. updated_at = Column(BigInteger, comment="更新时间")
  31. deleted_at = Column(BigInteger, comment="删除时间")
  32. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  33. class ThirdScene(Base):
  34. """三级场景表"""
  35. __tablename__ = "third_scene"
  36. id = Column(BigInteger, primary_key=True, autoincrement=True)
  37. third_scene_name = Column(String(255), nullable=False, comment="三级场景名称")
  38. second_scene_id = Column(BigInteger, nullable=False, comment="二级场景ID")
  39. correct_example_image = Column(String(255), default="", comment="正确示例图")
  40. wrong_example_image = Column(String(255), default="", comment="错误示例图")
  41. created_at = Column(BigInteger, comment="创建时间")
  42. updated_at = Column(BigInteger, comment="更新时间")
  43. deleted_at = Column(BigInteger, comment="删除时间")
  44. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  45. class SceneTemplate(Base):
  46. """场景模板表"""
  47. __tablename__ = "scene_template"
  48. id = Column(BigInteger, primary_key=True, autoincrement=True)
  49. scene_name = Column(String(255), nullable=False, comment="场景名称")
  50. scene_type = Column(String(100), nullable=False, comment="场景类型")
  51. scene_desc = Column(Text, comment="场景描述")
  52. model_name = Column(String(255), nullable=False, comment="YOLO模型名称")
  53. created_at = Column(BigInteger, comment="创建时间")
  54. updated_at = Column(BigInteger, comment="更新时间")
  55. deleted_at = Column(BigInteger, comment="删除时间")
  56. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  57. class RecognitionRecord(Base):
  58. """识别记录表"""
  59. __tablename__ = "recognition_record"
  60. id = Column(BigInteger, primary_key=True, autoincrement=True)
  61. original_image_url = Column(Text, nullable=False, comment="原图地址")
  62. recognition_image_url = Column(Text, nullable=False, comment="识别结果图地址")
  63. user_id = Column(BigInteger, nullable=False, comment="用户ID")
  64. scene_type = Column(String(100), default="", comment="场景类型")
  65. hazard_count = Column(Integer, default=0, comment="隐患数量")
  66. current_step = Column(Integer, default=1, comment="当前步骤")
  67. hazard_details = Column(Text, comment="隐患详情JSON")
  68. title = Column(String(255), default="", comment="标题")
  69. description = Column(Text, default="", comment="描述")
  70. labels = Column(String(255), default="", comment="标签")
  71. tag_type = Column(String(255), default="", comment="标签类型")
  72. second_scene = Column(String(1000), default="", comment="详情页的二级场景")
  73. third_scene = Column(String(1000), default="", comment="详情页的三级场景")
  74. scene_match = Column(BigInteger, default=0, comment="场景匹配(0、否,1、是)")
  75. tip_accuracy = Column(BigInteger, default=0, comment="提示准确(0、否,1、是)")
  76. effect_evaluation = Column(BigInteger, default=0, comment="效果评价(1-5)")
  77. user_remark = Column(String(200), default="", comment="用户备注")
  78. created_at = Column(BigInteger, comment="创建时间")
  79. updated_at = Column(BigInteger, comment="更新时间")
  80. deleted_at = Column(BigInteger, comment="删除时间")
  81. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")
  82. class RecognitionRecordSecondScene(Base):
  83. """识别记录对应的二级场景表"""
  84. __tablename__ = "recognition_record_second_scene"
  85. id = Column(BigInteger, primary_key=True, autoincrement=True)
  86. recognition_record_id = Column(BigInteger, nullable=False, comment="识别记录ID")
  87. second_scene_id = Column(BigInteger, nullable=False, comment="二级场景ID")
  88. created_at = Column(BigInteger, comment="创建时间")
  89. updated_at = Column(BigInteger, comment="更新时间")
  90. deleted_at = Column(BigInteger, comment="删除时间")
  91. is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")