269 lines
11 KiB
Python
269 lines
11 KiB
Python
from datetime import datetime
|
||
from sqlalchemy import Column, String, Integer, BigInteger, DateTime, Boolean, ForeignKey, JSON
|
||
from sqlalchemy.orm import relationship
|
||
from config.database import Base
|
||
|
||
|
||
class TestPermission(Base):
|
||
"""
|
||
测试权限配置表 - 谁可以测什么
|
||
"""
|
||
__tablename__ = 'test_permission'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='权限ID')
|
||
user_id = Column(BigInteger, nullable=False, comment='用户ID')
|
||
|
||
# 可选限制条件
|
||
eut_type_id = Column(BigInteger, nullable=True, comment='产品类型限制(可选)')
|
||
test_category_id = Column(BigInteger, nullable=True, comment='测试类别限制(可选)')
|
||
|
||
# 权限类型
|
||
permission_type = Column(String(20), default='TESTER', comment='权限类型: TESTER=测试人')
|
||
|
||
# 领取限制
|
||
can_claim = Column(Boolean, default=True, comment='是否可领取工单')
|
||
max_concurrent = Column(Integer, default=5, comment='最大并行工单数')
|
||
|
||
# 优先级权重(用于排序)
|
||
priority_weight = Column(Integer, default=1, comment='优先级权重')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
update_by = Column(String(64), default='', comment='更新者')
|
||
update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||
del_flag = Column(String(1), default='0', comment='删除标志')
|
||
|
||
__table_args__ = {'comment': '测试权限配置表'}
|
||
|
||
|
||
class TestCategoryDetail(Base):
|
||
"""
|
||
测试类别详细配置表 - 仅叶子节点(测试项目)需要
|
||
"""
|
||
__tablename__ = 'test_category_detail'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='详情ID')
|
||
category_id = Column(BigInteger, nullable=False, comment='关联测试类别ID')
|
||
|
||
# 测试条件参数模板(JSON格式)
|
||
# 示例: [{"field": "temperature", "label": "温度", "unit": "°C", "type": "number", "required": true}]
|
||
condition_fields = Column(JSON, nullable=True, comment='测试条件字段定义')
|
||
|
||
# 测试结果字段定义(JSON格式)
|
||
# 示例: [{"field": "voltage", "label": "电压", "type": "number", "unit": "V"}]
|
||
result_fields = Column(JSON, nullable=True, comment='测试结果字段定义')
|
||
|
||
# 原始数据配置
|
||
allow_raw_data = Column(Boolean, default=True, comment='是否允许提交原始数据')
|
||
raw_data_fields = Column(JSON, nullable=True, comment='原始数据字段定义')
|
||
|
||
# 测试步骤模板
|
||
step_template = Column(JSON, nullable=True, comment='测试步骤模板')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
update_by = Column(String(64), default='', comment='更新者')
|
||
update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||
del_flag = Column(String(1), default='0', comment='删除标志')
|
||
|
||
__table_args__ = {'comment': '测试类别详细配置表'}
|
||
|
||
|
||
class ReportPermission(Base):
|
||
"""
|
||
报告权限配置表 - 谁可以编写/审核报告
|
||
"""
|
||
__tablename__ = 'report_permission'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='权限ID')
|
||
user_id = Column(BigInteger, nullable=False, comment='用户ID')
|
||
|
||
# 权限类型: WRITER=编写人, REVIEWER_1=一审, REVIEWER_2=二审, REVIEWER_3=三审
|
||
permission_type = Column(String(20), nullable=False, comment='权限类型')
|
||
|
||
# 适用测试类别(可选)
|
||
test_category_id = Column(BigInteger, nullable=True, comment='测试类别限制')
|
||
|
||
# 领取限制
|
||
can_claim = Column(Boolean, default=True, comment='是否可领取')
|
||
max_concurrent = Column(Integer, default=3, comment='最大并行报告数')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
update_by = Column(String(64), default='', comment='更新者')
|
||
update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||
del_flag = Column(String(1), default='0', comment='删除标志')
|
||
|
||
__table_args__ = {'comment': '报告权限配置表'}
|
||
|
||
|
||
class TestReport(Base):
|
||
"""
|
||
测试报告表
|
||
"""
|
||
__tablename__ = 'test_report'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='报告ID')
|
||
report_no = Column(String(50), unique=True, nullable=False, comment='报告编号')
|
||
|
||
# 报告类型: CATEGORY=按大类, ITEM=按子项
|
||
report_type = Column(String(20), nullable=False, comment='报告类型')
|
||
|
||
# 关联
|
||
category_id = Column(BigInteger, nullable=False, comment='测试大类ID')
|
||
item_id = Column(BigInteger, nullable=True, comment='测试子项ID')
|
||
|
||
# 优先级
|
||
priority = Column(Integer, default=1, comment='优先级')
|
||
|
||
# 编写人(可领取)
|
||
writer_id = Column(BigInteger, nullable=True, comment='编写人ID')
|
||
claimed_by_writer_at = Column(DateTime, nullable=True, comment='编写人领取时间')
|
||
|
||
# 一审
|
||
reviewer_1_id = Column(BigInteger, nullable=True, comment='一审人ID')
|
||
review_1_status = Column(String(20), nullable=True, comment='一审状态')
|
||
review_1_at = Column(DateTime, nullable=True, comment='一审时间')
|
||
review_1_comment = Column(String(500), nullable=True, comment='一审意见')
|
||
|
||
# 二审
|
||
reviewer_2_id = Column(BigInteger, nullable=True, comment='二审人ID')
|
||
review_2_status = Column(String(20), nullable=True, comment='二审状态')
|
||
review_2_at = Column(DateTime, nullable=True, comment='二审时间')
|
||
review_2_comment = Column(String(500), nullable=True, comment='二审意见')
|
||
|
||
# 三审
|
||
reviewer_3_id = Column(BigInteger, nullable=True, comment='三审人ID')
|
||
review_3_status = Column(String(20), nullable=True, comment='三审状态')
|
||
review_3_at = Column(DateTime, nullable=True, comment='三审时间')
|
||
review_3_comment = Column(String(500), nullable=True, comment='三审意见')
|
||
|
||
# 报告状态
|
||
status = Column(String(20), default='PENDING_WRITE', comment='报告状态')
|
||
|
||
# 当前版本
|
||
current_version_id = Column(BigInteger, nullable=True, comment='当前版本ID')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
update_by = Column(String(64), default='', comment='更新者')
|
||
update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||
del_flag = Column(String(1), default='0', comment='删除标志')
|
||
|
||
__table_args__ = {'comment': '测试报告表'}
|
||
|
||
|
||
class ReportWorkOrderRelation(Base):
|
||
"""
|
||
报告工单关联表
|
||
"""
|
||
__tablename__ = 'report_work_order_relation'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='关联ID')
|
||
report_id = Column(BigInteger, nullable=False, comment='报告ID')
|
||
work_order_id = Column(BigInteger, nullable=False, comment='工单ID')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
|
||
__table_args__ = {'comment': '报告工单关联表'}
|
||
|
||
|
||
class TestReportVersion(Base):
|
||
"""
|
||
报告版本表 - 留痕
|
||
"""
|
||
__tablename__ = 'test_report_version'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='版本ID')
|
||
report_id = Column(BigInteger, nullable=False, comment='关联报告ID')
|
||
version_no = Column(Integer, nullable=False, comment='版本号')
|
||
|
||
# 报告内容
|
||
content = Column(JSON, nullable=False, comment='报告内容')
|
||
|
||
# 提交信息
|
||
submitted_by = Column(BigInteger, nullable=False, comment='提交人ID')
|
||
submitted_at = Column(DateTime, nullable=False, comment='提交时间')
|
||
submit_comment = Column(String(500), nullable=True, comment='提交说明')
|
||
|
||
# 审核结果
|
||
review_result = Column(String(20), nullable=True, comment='审核结果')
|
||
reviewed_by = Column(BigInteger, nullable=True, comment='审核人ID')
|
||
reviewed_at = Column(DateTime, nullable=True, comment='审核时间')
|
||
review_comment = Column(String(1000), nullable=True, comment='审核意见')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
|
||
__table_args__ = {'comment': '报告版本表'}
|
||
|
||
|
||
class WorkOrderRetestRecord(Base):
|
||
"""
|
||
工单重测记录表 - 留痕
|
||
"""
|
||
__tablename__ = 'work_order_retest_record'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='记录ID')
|
||
work_order_id = Column(BigInteger, nullable=False, comment='关联工单ID')
|
||
|
||
# 触发来源
|
||
trigger_source = Column(String(20), nullable=False, comment='触发来源')
|
||
triggered_by = Column(BigInteger, nullable=False, comment='触发人ID')
|
||
triggered_at = Column(DateTime, nullable=False, comment='触发时间')
|
||
|
||
# 重测原因
|
||
reason = Column(String(500), nullable=False, comment='重测原因')
|
||
report_id = Column(BigInteger, nullable=True, comment='关联报告ID')
|
||
review_comment = Column(String(500), nullable=True, comment='审核意见')
|
||
|
||
# 重测前状态快照
|
||
previous_status = Column(Integer, nullable=False, comment='重测前状态')
|
||
previous_result = Column(JSON, nullable=True, comment='重测前结果快照')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
update_by = Column(String(64), default='', comment='更新者')
|
||
update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')
|
||
del_flag = Column(String(1), default='0', comment='删除标志')
|
||
|
||
__table_args__ = {'comment': '工单重测记录表'}
|
||
|
||
|
||
class ReportReviewRecord(Base):
|
||
"""
|
||
报告审核记录表 - 留痕
|
||
"""
|
||
__tablename__ = 'report_review_record'
|
||
|
||
id = Column(BigInteger, primary_key=True, autoincrement=True, comment='记录ID')
|
||
report_id = Column(BigInteger, nullable=False, comment='关联报告ID')
|
||
version_id = Column(BigInteger, nullable=False, comment='关联版本ID')
|
||
|
||
# 审核信息
|
||
review_level = Column(Integer, nullable=False, comment='审核级别')
|
||
reviewer_id = Column(BigInteger, nullable=False, comment='审核人ID')
|
||
reviewed_at = Column(DateTime, nullable=False, comment='审核时间')
|
||
|
||
# 审核结果
|
||
action = Column(String(20), nullable=False, comment='审核动作')
|
||
comment = Column(String(1000), nullable=True, comment='审核意见')
|
||
|
||
# 报告内容快照
|
||
report_content_snapshot = Column(JSON, nullable=True, comment='报告内容快照')
|
||
retest_work_order_ids = Column(JSON, nullable=True, comment='指定重测工单ID列表')
|
||
|
||
# 若依标准字段
|
||
create_by = Column(String(64), default='', comment='创建者')
|
||
create_time = Column(DateTime, default=datetime.now, comment='创建时间')
|
||
|
||
__table_args__ = {'comment': '报告审核记录表'}
|