feat(models): 新增10个生产执行相关SQLAlchemy模型
新增细胞产品、生产工单、生产任务及关联的投入/步骤/试剂/耗材/产出/数据采集等模型类, 支持工单→任务→步骤的relationship关联查询。
This commit is contained in:
1 parent
67ba7c48d5
commit
61f217eea5
2 files changed
+280
No files matched your search
@@ -37,6 +37,16 @@ from app.models.models import (
|
|||||||
BizProcessRouteStepConsumable,
|
BizProcessRouteStepConsumable,
|
||||||
BizProcessRouteStepOutput,
|
BizProcessRouteStepOutput,
|
||||||
BizProcessRouteStepDataCollection,
|
BizProcessRouteStepDataCollection,
|
||||||
|
BizCellProduct,
|
||||||
|
BizProductionWorkOrder,
|
||||||
|
BizProductionTask,
|
||||||
|
BizProductionTaskInput,
|
||||||
|
BizProductionTaskStep,
|
||||||
|
BizProductionTaskStepReagent,
|
||||||
|
BizProductionTaskStepConsumable,
|
||||||
|
BizProductionTaskStepOutput,
|
||||||
|
BizProductionTaskStepDataCollection,
|
||||||
|
BizProductionTaskOutput,
|
||||||
)
|
)
|
||||||
from app.models.research_donation import ( # noqa: F401
|
from app.models.research_donation import ( # noqa: F401
|
||||||
BizResearchDonation,
|
BizResearchDonation,
|
||||||
@@ -92,4 +102,14 @@ __all__ = [
|
|||||||
"BizProcessRouteStepConsumable",
|
"BizProcessRouteStepConsumable",
|
||||||
"BizProcessRouteStepOutput",
|
"BizProcessRouteStepOutput",
|
||||||
"BizProcessRouteStepDataCollection",
|
"BizProcessRouteStepDataCollection",
|
||||||
|
"BizCellProduct",
|
||||||
|
"BizProductionWorkOrder",
|
||||||
|
"BizProductionTask",
|
||||||
|
"BizProductionTaskInput",
|
||||||
|
"BizProductionTaskStep",
|
||||||
|
"BizProductionTaskStepReagent",
|
||||||
|
"BizProductionTaskStepConsumable",
|
||||||
|
"BizProductionTaskStepOutput",
|
||||||
|
"BizProductionTaskStepDataCollection",
|
||||||
|
"BizProductionTaskOutput",
|
||||||
]
|
]
|
||||||
@@ -3,6 +3,7 @@ from datetime import datetime
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
from sqlalchemy import Column, String, DateTime, Integer, Text, CHAR, SmallInteger, Numeric
|
from sqlalchemy import Column, String, DateTime, Integer, Text, CHAR, SmallInteger, Numeric
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -2114,4 +2115,263 @@ class BizProcessRouteStepDataCollection(Base):
|
|||||||
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# 生产执行(细胞产品 / 生产工单 / 生产任务 / 生产步骤 / 投入产出)
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
class BizCellProduct(Base):
|
||||||
|
"""细胞产品 biz_cell_product"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_cell_product"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
product_code = Column(String(64), nullable=False, comment="产品编码")
|
||||||
|
product_name = Column(String(200), nullable=False, comment="产品名称")
|
||||||
|
product_type_id = Column(String(64), nullable=True, comment="产品类型ID")
|
||||||
|
spec_id = Column(String(64), nullable=True, comment="规格ID")
|
||||||
|
batch_no = Column(String(64), nullable=True, comment="批号")
|
||||||
|
storage_slot_id = Column(String(64), nullable=True, comment="库位ID")
|
||||||
|
product_status = Column(String(16), nullable=True, default="zk", comment="产品状态 zk在库 ck出库")
|
||||||
|
source_type = Column(String(32), nullable=True, default="production", comment="来源类型 production生产 qc质检")
|
||||||
|
production_task_id = Column(String(64), nullable=True, comment="生产任务ID")
|
||||||
|
quantity = Column(Numeric(18, 4), nullable=True, comment="数量")
|
||||||
|
unit = Column(String(64), nullable=True, comment="单位")
|
||||||
|
expiry_date = Column(DateTime, nullable=True, comment="有效期")
|
||||||
|
product_images = Column(String(4000), nullable=True, comment="产品图片(逗号分隔URL)")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionWorkOrder(Base):
|
||||||
|
"""生产工单 biz_production_work_order"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_work_order"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
work_order_no = Column(String(32), nullable=False, comment="工单号")
|
||||||
|
reception_id = Column(String(64), nullable=False, comment="接收记录ID")
|
||||||
|
protocol_sample_id = Column(String(64), nullable=False, comment="协议样本ID")
|
||||||
|
collection_protocol_id = Column(String(64), nullable=False, comment="采集协议单ID")
|
||||||
|
protocol_no = Column(String(64), nullable=True, comment="协议号快照")
|
||||||
|
sample_code = Column(String(32), nullable=True, comment="样本编码快照")
|
||||||
|
reception_source = Column(String(20), nullable=False, default="cell_storage", comment="来源类型 cell_storage细胞存储 research_donation科研捐赠")
|
||||||
|
work_order_status = Column(String(16), nullable=False, default="dpz", comment="工单状态 dpz待配置 dpz待派工 jxz执行中 ywc已完成 yzf已作废")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
tasks = relationship("BizProductionTask", backref="work_order", lazy="dynamic")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTask(Base):
|
||||||
|
"""生产任务 biz_production_task"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
task_no = Column(String(32), nullable=False, comment="任务号")
|
||||||
|
work_order_id = Column(String(64), nullable=False, comment="工单ID")
|
||||||
|
task_name = Column(String(200), nullable=True, comment="任务名称")
|
||||||
|
description = Column(String(500), nullable=True, comment="描述")
|
||||||
|
route_id = Column(String(64), nullable=True, comment="工艺路线ID")
|
||||||
|
task_status = Column(String(16), nullable=False, default="dpz", comment="任务状态 dpz待配置 dpz待执行 jxz执行中 ywc已完成")
|
||||||
|
started_time = Column(DateTime, nullable=True, comment="开始时间")
|
||||||
|
completed_time = Column(DateTime, nullable=True, comment="完成时间")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
attachments = Column(String(4000), nullable=True, comment="附件(逗号分隔URL)")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
steps = relationship("BizProductionTaskStep", backref="task", lazy="dynamic")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskInput(Base):
|
||||||
|
"""生产任务投入物 biz_production_task_input"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_input"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
task_id = Column(String(64), nullable=False, comment="任务ID")
|
||||||
|
input_type = Column(String(32), nullable=True, comment="投入物类型 sample样本 reagent试剂 consumable耗材")
|
||||||
|
input_id = Column(String(64), nullable=True, comment="投入物ID")
|
||||||
|
input_code = Column(String(64), nullable=True, comment="投入物编码")
|
||||||
|
input_name = Column(String(200), nullable=True, comment="投入物名称")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskStep(Base):
|
||||||
|
"""生产任务步骤 biz_production_task_step"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_step"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
task_id = Column(String(64), nullable=False, comment="任务ID")
|
||||||
|
step_order = Column(Integer, nullable=True, comment="步骤顺序")
|
||||||
|
process_code = Column(String(64), nullable=True, comment="工序代码")
|
||||||
|
category_id = Column(String(64), nullable=True, comment="工序分类ID")
|
||||||
|
process_name = Column(String(100), nullable=True, comment="工序名称")
|
||||||
|
description = Column(String(500), nullable=True, comment="描述")
|
||||||
|
equipment_name = Column(String(200), nullable=True, comment="预计使用设备名称")
|
||||||
|
estimated_duration = Column(String(100), nullable=True, comment="预估耗时")
|
||||||
|
actual_duration = Column(String(100), nullable=True, comment="实际耗时")
|
||||||
|
sop_ids = Column(String(1000), nullable=True, comment="关联SOP文档id(逗号分隔)")
|
||||||
|
step_status = Column(String(16), nullable=True, default="dzx", comment="步骤状态 dzx待执行 jxz执行中 ywc已完成")
|
||||||
|
started_time = Column(DateTime, nullable=True, comment="开始时间")
|
||||||
|
completed_time = Column(DateTime, nullable=True, comment="完成时间")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskStepReagent(Base):
|
||||||
|
"""生产任务步骤试剂 biz_production_task_step_reagent"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_step_reagent"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
step_id = Column(String(64), nullable=False, comment="步骤ID")
|
||||||
|
reagent_code = Column(String(64), nullable=True, comment="试剂编码")
|
||||||
|
reagent_name = Column(String(100), nullable=True, comment="试剂名称")
|
||||||
|
spec = Column(String(200), nullable=True, comment="规格")
|
||||||
|
standard_usage = Column(String(100), nullable=True, comment="标准用量")
|
||||||
|
actual_usage = Column(String(100), nullable=True, comment="实际用量")
|
||||||
|
unit = Column(String(64), nullable=True, comment="单位")
|
||||||
|
is_key_material = Column(CHAR(1), nullable=True, default="0", comment="是否关键物料(0-否 1-是)")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskStepConsumable(Base):
|
||||||
|
"""生产任务步骤耗材 biz_production_task_step_consumable"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_step_consumable"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
step_id = Column(String(64), nullable=False, comment="步骤ID")
|
||||||
|
consumable_code = Column(String(64), nullable=True, comment="耗材编码")
|
||||||
|
consumable_name = Column(String(100), nullable=True, comment="耗材名称")
|
||||||
|
spec_model = Column(String(200), nullable=True, comment="耗材规格型号")
|
||||||
|
standard_usage = Column(String(100), nullable=True, comment="标准用量")
|
||||||
|
actual_usage = Column(String(100), nullable=True, comment="实际用量")
|
||||||
|
unit = Column(String(64), nullable=True, comment="单位")
|
||||||
|
is_required = Column(CHAR(1), nullable=True, default="1", comment="是否必需(1-必须 0-可选)")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskStepOutput(Base):
|
||||||
|
"""生产任务步骤产出物 biz_production_task_step_output"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_step_output"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
step_id = Column(String(64), nullable=False, comment="步骤ID")
|
||||||
|
output_type_id = Column(String(64), nullable=True, comment="产出类型ID")
|
||||||
|
output_name = Column(String(200), nullable=True, comment="产出物名称")
|
||||||
|
output_barcode = Column(String(200), nullable=True, comment="产出物条码")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskStepDataCollection(Base):
|
||||||
|
"""生产任务步骤数据采集项 biz_production_task_step_data_collection"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_step_data_collection"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
step_id = Column(String(64), nullable=False, comment="步骤ID")
|
||||||
|
collection_name = Column(String(200), nullable=True, comment="采集项名称")
|
||||||
|
unit = Column(String(64), nullable=True, comment="单位")
|
||||||
|
collection_value = Column(String(500), nullable=True, comment="采集值")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
|
class BizProductionTaskOutput(Base):
|
||||||
|
"""生产任务最终产出 biz_production_task_output"""
|
||||||
|
|
||||||
|
__tablename__ = "biz_production_task_output"
|
||||||
|
|
||||||
|
id = Column(String(64), primary_key=True, comment="主键ID")
|
||||||
|
task_id = Column(String(64), nullable=False, comment="任务ID")
|
||||||
|
cell_product_id = Column(String(64), nullable=True, comment="细胞产品ID")
|
||||||
|
storage_slot_id = Column(String(64), nullable=True, comment="库位ID")
|
||||||
|
output_name = Column(String(200), nullable=True, comment="产出物名称")
|
||||||
|
output_barcode = Column(String(200), nullable=True, comment="产出物条码")
|
||||||
|
quantity = Column(Numeric(18, 4), nullable=True, comment="数量")
|
||||||
|
unit = Column(String(64), nullable=True, comment="单位")
|
||||||
|
remark = Column(String(512), nullable=True, comment="备注")
|
||||||
|
attachments = Column(String(4000), nullable=True, comment="附件(逗号分隔URL)")
|
||||||
|
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||||
|
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||||
|
create_by = Column(String(64), nullable=True, comment="创建人id")
|
||||||
|
create_dept_id = Column(String(64), nullable=False, default="", comment="创建人部门ID")
|
||||||
|
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||||
|
update_by = Column(String(64), nullable=True, comment="更新人id")
|
||||||
|
update_time = Column(DateTime, nullable=False, default=datetime.now, onupdate=datetime.now, comment="更新时间")
|
||||||
|
del_flag = Column(SmallInteger, nullable=False, default=0, comment="删除标记")
|
||||||
|
|
||||||
|
|
||||||
from app.models.qc_param import BizQcItemParam, BizQcTaskResult # noqa: E402,F401
|
from app.models.qc_param import BizQcItemParam, BizQcTaskResult # noqa: E402,F401
|
||||||
Reference in new issue
Block a user