feat(market): 完善临床科研与委托加工上线能力
补齐项目组负责人审批、费用信息、合作客户、生产出库菜单、申请单号 LCKY 前缀及配套 SQL 迁移,并同步相关前后端与单测。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7a3c58ed99
commit
c22a0d1eb0
77 files changed
+8375
-1869
No files matched your search
@@ -15,12 +15,14 @@ from app.crud import collection_region as region_svc
|
||||
from app.crud import collection_protocol as collection_protocol_svc
|
||||
from app.crud import collection_protocol_no as protocol_no_svc
|
||||
from app.crud import customer as customer_svc
|
||||
from app.crud import partner_customer as partner_customer_svc
|
||||
from app.crud import sample_code as sample_code_svc
|
||||
from app.models.models import (
|
||||
BizCellSampleType,
|
||||
BizCollectionProtocolNo,
|
||||
BizCollectionRegion,
|
||||
BizCustomer,
|
||||
BizPartnerCustomer,
|
||||
BizSampleCode,
|
||||
SysUser,
|
||||
)
|
||||
@@ -218,6 +220,134 @@ async def delete_customer(
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 合作客户(临床科研 / 委托加工)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class PartnerCustomerCreateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
customer_name: str = Field(..., alias="customerName")
|
||||
customer_contact: str = Field(..., alias="customerContact")
|
||||
customer_phone: str = Field(..., alias="customerPhone")
|
||||
order_num: Optional[int] = Field(0, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class PartnerCustomerUpdateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||
order_num: Optional[int] = Field(None, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
@router.get("/partner-customers")
|
||||
async def list_partner_customers(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=200, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
user: dict = Depends(require_menu_code("biz:customer:list")),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
query = db.query(BizPartnerCustomer).filter(
|
||||
BizPartnerCustomer.del_flag == 0,
|
||||
BizPartnerCustomer.tenant_no == tenant_no,
|
||||
)
|
||||
if keyword:
|
||||
kw = keyword.strip()
|
||||
if kw:
|
||||
like = f"%{kw}%"
|
||||
query = query.filter(
|
||||
or_(
|
||||
BizPartnerCustomer.customer_name.like(like),
|
||||
BizPartnerCustomer.customer_contact.like(like),
|
||||
BizPartnerCustomer.customer_phone.like(like),
|
||||
)
|
||||
)
|
||||
query = apply_data_scope(query, BizPartnerCustomer, user, db, tenant_no)
|
||||
total = query.count()
|
||||
items = (
|
||||
query.order_by(BizPartnerCustomer.create_time.desc())
|
||||
.offset((page - 1) * pageSize)
|
||||
.limit(pageSize)
|
||||
.all()
|
||||
)
|
||||
result_list = [partner_customer_svc._row_to_dict(r) for r in items]
|
||||
tp = partner_customer_svc.total_pages(total, pageSize)
|
||||
return success_response(
|
||||
{"list": result_list, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp}
|
||||
)
|
||||
|
||||
|
||||
@router.post("/partner-customers")
|
||||
async def create_partner_customer(
|
||||
body: PartnerCustomerCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
obj = partner_customer_svc.create_partner_customer(
|
||||
db,
|
||||
customer_name=body.customer_name,
|
||||
customer_contact=body.customer_contact,
|
||||
customer_phone=body.customer_phone,
|
||||
tenant_no=tenant_no,
|
||||
order_num=body.order_num,
|
||||
remark=body.remark,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("dept_id") or "",
|
||||
)
|
||||
return success_response(partner_customer_svc._row_to_dict(obj), message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/partner-customers/{customer_id}")
|
||||
async def update_partner_customer(
|
||||
customer_id: str,
|
||||
body: PartnerCustomerUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
payload: dict[str, Any] = body.model_dump(exclude_unset=True, by_alias=False)
|
||||
obj = partner_customer_svc.update_partner_customer(
|
||||
db,
|
||||
customer_id,
|
||||
customer_name=payload.get("customer_name"),
|
||||
customer_contact=payload.get("customer_contact"),
|
||||
customer_phone=payload.get("customer_phone"),
|
||||
order_num=payload.get("order_num"),
|
||||
remark=payload.get("remark"),
|
||||
user_id=user.get("user_id"),
|
||||
tenant_no=tenant_no,
|
||||
)
|
||||
return success_response(partner_customer_svc._row_to_dict(obj), message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/partner-customers/{customer_id}")
|
||||
async def delete_partner_customer(
|
||||
customer_id: str,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
partner_customer_svc.soft_delete_partner_customer(db, customer_id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 细胞样本类型
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
+125
-1
@@ -298,7 +298,7 @@ STATIC_MENU_TREE = [
|
||||
],
|
||||
},
|
||||
|
||||
# 临床科研
|
||||
# 临床科研(与 sqxp.ts / 委托加工成对:申请、审批、费用、出库放行)
|
||||
{
|
||||
"id": "BEX00000000000000000000000000001",
|
||||
"name": "BasicExperiment",
|
||||
@@ -322,6 +322,30 @@ STATIC_MENU_TREE = [
|
||||
"menuCode": "basic-experiment:application:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "BEX00000000000000000000000000006",
|
||||
"name": "BasicExperimentApproval",
|
||||
"path": "approval",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {
|
||||
"title": "临床科研审批",
|
||||
"keepAlive": True,
|
||||
"menuCode": "basic-experiment:approval:list",
|
||||
"bizType": "basic_experiment",
|
||||
"approvalOnly": True,
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "BEX00000000000000000000000000005",
|
||||
"name": "BasicExperimentFeeInfo",
|
||||
"path": "fee-info",
|
||||
"component": "/pilot-service/fee-info/index",
|
||||
"meta": {
|
||||
"title": "费用信息",
|
||||
"keepAlive": True,
|
||||
"menuCode": "basic-experiment:fee-info:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "BEX00000000000000000000000000003",
|
||||
"name": "BasicExperimentPaymentConfirm",
|
||||
@@ -330,6 +354,7 @@ STATIC_MENU_TREE = [
|
||||
"meta": {
|
||||
"title": "缴退费财务确认",
|
||||
"keepAlive": True,
|
||||
"isHide": True,
|
||||
"menuCode": "basic-experiment:payment-confirm:list",
|
||||
},
|
||||
},
|
||||
@@ -346,6 +371,79 @@ STATIC_MENU_TREE = [
|
||||
},
|
||||
],
|
||||
},
|
||||
# 委托加工(复用临床科研页面,bizType=contract_processing)
|
||||
{
|
||||
"id": "CPG00000000000000000000000000001",
|
||||
"name": "ContractProcessing",
|
||||
"path": "contract-processing",
|
||||
"component": "",
|
||||
"meta": {
|
||||
"title": "委托加工",
|
||||
"icon": "ri:tools-line",
|
||||
"keepAlive": False,
|
||||
"roles": ["admin"],
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "CPG00000000000000000000000000002",
|
||||
"name": "ContractProcessingApplication",
|
||||
"path": "application",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {
|
||||
"title": "委托加工申请单",
|
||||
"keepAlive": True,
|
||||
"menuCode": "contract-processing:application:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "CPG00000000000000000000000000006",
|
||||
"name": "ContractProcessingApproval",
|
||||
"path": "approval",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {
|
||||
"title": "委托加工审批",
|
||||
"keepAlive": True,
|
||||
"menuCode": "contract-processing:approval:list",
|
||||
"bizType": "contract_processing",
|
||||
"approvalOnly": True,
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "CPG00000000000000000000000000005",
|
||||
"name": "ContractProcessingFeeInfo",
|
||||
"path": "fee-info",
|
||||
"component": "/pilot-service/fee-info/index",
|
||||
"meta": {
|
||||
"title": "费用信息",
|
||||
"keepAlive": True,
|
||||
"menuCode": "contract-processing:fee-info:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "CPG00000000000000000000000000003",
|
||||
"name": "ContractProcessingPaymentConfirm",
|
||||
"path": "payment-confirm",
|
||||
"component": "/pilot-service/clinical-payment-confirm/index",
|
||||
"meta": {
|
||||
"title": "缴退费财务确认",
|
||||
"keepAlive": True,
|
||||
"isHide": True,
|
||||
"menuCode": "contract-processing:payment-confirm:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "CPG00000000000000000000000000004",
|
||||
"name": "ContractProcessingOutboundRelease",
|
||||
"path": "outbound-release-review",
|
||||
"component": "/pilot-service/outbound-release-review/index",
|
||||
"meta": {
|
||||
"title": "出库放行审核",
|
||||
"keepAlive": True,
|
||||
"menuCode": "contract-processing:outbound-release-review:list",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
# 器械销售(市场侧栏末位)
|
||||
{
|
||||
"id": "DEV00000000000000000000000000001",
|
||||
@@ -601,6 +699,32 @@ STATIC_MENU_TREE = [
|
||||
"menuCode": "production:waste-output:list",
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "PRD00000000000000000000000000001",
|
||||
"name": "ProductionBasicExperimentOutbound",
|
||||
"path": "basic-experiment-outbound",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {
|
||||
"title": "临床科研出库",
|
||||
"keepAlive": True,
|
||||
"menuCode": "production:basic-experiment-outbound:list",
|
||||
"bizType": "basic_experiment",
|
||||
"productionOutbound": True,
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "PRD00000000000000000000000000002",
|
||||
"name": "ProductionContractProcessingOutbound",
|
||||
"path": "contract-processing-outbound",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {
|
||||
"title": "委托加工出库",
|
||||
"keepAlive": True,
|
||||
"menuCode": "production:contract-processing-outbound:list",
|
||||
"bizType": "contract_processing",
|
||||
"productionOutbound": True,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
# 生产基础信息
|
||||
|
||||
@@ -25,6 +25,35 @@ def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
def _access_pilot_application(
|
||||
db: Session,
|
||||
tenant_no: str,
|
||||
user: dict,
|
||||
app_id: str,
|
||||
*,
|
||||
lock: bool = False,
|
||||
for_approval: bool = False,
|
||||
):
|
||||
"""科研类走项目组可见性;其它业务走通用数据权限。"""
|
||||
q = db.query(BizPilotApplication).filter(
|
||||
BizPilotApplication.id == app_id,
|
||||
BizPilotApplication.tenant_no == tenant_no,
|
||||
BizPilotApplication.del_flag == 0,
|
||||
)
|
||||
if lock:
|
||||
q = q.populate_existing().with_for_update()
|
||||
row = q.first()
|
||||
if row is None:
|
||||
raise HTTPException(404, "单据不存在或无权访问")
|
||||
if pilot_application.requires_leader_approval(row.biz_type):
|
||||
if not pilot_application.user_can_access_research_application(
|
||||
db, tenant_no, user, row, for_approval=for_approval
|
||||
):
|
||||
raise HTTPException(404, "单据不存在或无权访问")
|
||||
return row
|
||||
return accessible_order(db, BizPilotApplication, tenant_no, user, app_id, lock=lock)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Pydantic Schemas
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -236,8 +265,11 @@ async def api_list_applications(
|
||||
keyword: Optional[str] = Query(None, alias="keyword"),
|
||||
channelId: Optional[str] = Query(None, alias="channelId"),
|
||||
applicationStatus: Optional[str] = Query(None, alias="applicationStatus"),
|
||||
approvalStatus: Optional[str] = Query(None, alias="approvalStatus"),
|
||||
pendingMine: Optional[bool] = Query(False, alias="pendingMine"),
|
||||
channelServiceOrderId: Optional[str] = Query(None, alias="channelServiceOrderId"),
|
||||
bizType: Optional[str] = Query(None, alias="bizType"),
|
||||
forApproval: Optional[bool] = Query(False, alias="forApproval"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -251,10 +283,13 @@ async def api_list_applications(
|
||||
page_size=pageSize,
|
||||
channel_id=channelId,
|
||||
application_status=applicationStatus,
|
||||
approval_status=approvalStatus,
|
||||
pending_mine=bool(pendingMine),
|
||||
channel_service_order_id=channelServiceOrderId,
|
||||
keyword=keyword,
|
||||
biz_type=bizType,
|
||||
user_info=user,
|
||||
for_approval=bool(forApproval),
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
@@ -266,7 +301,10 @@ async def api_get_application(
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
accessible_order(db, BizPilotApplication, tenant_no, user, id)
|
||||
try:
|
||||
_access_pilot_application(db, tenant_no, user, id)
|
||||
except HTTPException as e:
|
||||
return error_response(e.status_code, e.detail)
|
||||
result = pilot_application.get_application(db, app_id=id, tenant_no=tenant_no)
|
||||
if result is None:
|
||||
return error_response(404, "申请单不存在")
|
||||
@@ -312,7 +350,7 @@ async def api_update_application(
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
accessible_order(db, BizPilotApplication, tenant_no, user, body.id, lock=True)
|
||||
_access_pilot_application(db, tenant_no, user, body.id, lock=True)
|
||||
data = {}
|
||||
if "project_id" in body.model_fields_set:
|
||||
data["projectId"] = body.project_id
|
||||
@@ -334,6 +372,8 @@ async def api_update_application(
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
except HTTPException as e:
|
||||
return error_response(e.status_code, e.detail)
|
||||
|
||||
|
||||
@router.post("/pilot-application/save")
|
||||
@@ -390,13 +430,13 @@ async def api_save_application(
|
||||
|
||||
if (
|
||||
not is_edit
|
||||
and biz_type in ("clinical_application", "basic_experiment", "contract_processing")
|
||||
and biz_type == "clinical_application"
|
||||
and not app_data["channelId"]
|
||||
):
|
||||
return error_response(400, "请选择渠道")
|
||||
|
||||
if is_edit:
|
||||
accessible_order(db, BizPilotApplication, tenant_no, user, body.id, lock=True)
|
||||
_access_pilot_application(db, tenant_no, user, body.id, lock=True)
|
||||
if is_edit:
|
||||
app_result = pilot_application.update_application(
|
||||
db,
|
||||
@@ -517,6 +557,41 @@ async def api_start_application(
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
class ApplicationApproveBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
id: str
|
||||
approval_status: str = Field(..., alias="approvalStatus")
|
||||
approval_remark: Optional[str] = Field(None, alias="approvalRemark")
|
||||
|
||||
|
||||
@router.post("/pilot-application/approve")
|
||||
async def api_approve_application(
|
||||
body: ApplicationApproveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
_access_pilot_application(
|
||||
db, tenant_no, user, body.id, lock=True, for_approval=True
|
||||
)
|
||||
result = pilot_application.approve_application(
|
||||
db,
|
||||
app_id=body.id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
approval_status=body.approval_status,
|
||||
approval_remark=body.approval_remark,
|
||||
is_super_admin=pilot_application._is_super_admin_user(user),
|
||||
)
|
||||
return success_response(result, message="审批成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
except HTTPException as e:
|
||||
return error_response(e.status_code, e.detail)
|
||||
|
||||
|
||||
@router.post("/pilot-application/complete")
|
||||
async def api_complete_application(
|
||||
body: IdBody,
|
||||
@@ -869,6 +944,32 @@ class ScheduleIdBody(BaseModel):
|
||||
scheduleId: str
|
||||
|
||||
|
||||
def _assert_schedule_app_approved(db: Session, schedule_id: str, tenant_no: str) -> None:
|
||||
from app.models.models import BizPilotInfusionPlan, BizPilotInfusionSchedule
|
||||
|
||||
row = (
|
||||
db.query(BizPilotApplication)
|
||||
.join(
|
||||
BizPilotInfusionPlan,
|
||||
BizPilotInfusionPlan.pilot_application_id == BizPilotApplication.id,
|
||||
)
|
||||
.join(
|
||||
BizPilotInfusionSchedule,
|
||||
BizPilotInfusionSchedule.infusion_plan_id == BizPilotInfusionPlan.id,
|
||||
)
|
||||
.filter(
|
||||
BizPilotInfusionSchedule.id == schedule_id,
|
||||
BizPilotInfusionSchedule.tenant_no == tenant_no,
|
||||
BizPilotInfusionSchedule.del_flag == 0,
|
||||
BizPilotInfusionPlan.del_flag == 0,
|
||||
BizPilotApplication.del_flag == 0,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if row:
|
||||
pilot_application.assert_research_leader_approved(row)
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/create-production-work-order")
|
||||
async def api_create_outbound_production(
|
||||
body: ScheduleIdBody,
|
||||
@@ -877,6 +978,7 @@ async def api_create_outbound_production(
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
_assert_schedule_app_approved(db, body.scheduleId, tenant_no)
|
||||
from app.crud import production_work_order as pwo_svc
|
||||
|
||||
from app.crud.qc_work_order import resolve_outbound_biz_type_for_schedule
|
||||
@@ -915,6 +1017,7 @@ async def api_create_outbound_qc(
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
_assert_schedule_app_approved(db, body.scheduleId, tenant_no)
|
||||
from app.crud import qc_work_order as qc_svc
|
||||
|
||||
from app.crud.qc_work_order import resolve_outbound_biz_type_for_schedule
|
||||
@@ -937,3 +1040,126 @@ async def api_create_outbound_qc(
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 临床科研 / 委托加工 · 自定义业务类型
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ContractProcessingCategoryCreateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
category_name: str = Field(..., alias="categoryName")
|
||||
biz_type: str = Field(..., alias="bizType", description="basic_experiment | contract_processing")
|
||||
order_num: Optional[int] = Field(None, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class ContractProcessingCategoryUpdateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
category_name: Optional[str] = Field(None, alias="categoryName")
|
||||
order_num: Optional[int] = Field(None, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
@router.get("/contract-processing-categories")
|
||||
async def list_contract_processing_categories(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(100, ge=1, le=200, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
bizType: str = Query(..., alias="bizType", description="basic_experiment | contract_processing"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
from app.crud import contract_processing_category as cat_svc
|
||||
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
rows, total = cat_svc.list_categories(
|
||||
db,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
keyword=keyword,
|
||||
tenant_no=tenant_no,
|
||||
biz_type=bizType,
|
||||
)
|
||||
return success_response(
|
||||
{
|
||||
"list": rows,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"pageSize": pageSize,
|
||||
"totalPages": cat_svc.total_pages(total, pageSize),
|
||||
}
|
||||
)
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/contract-processing-categories")
|
||||
async def create_contract_processing_category(
|
||||
body: ContractProcessingCategoryCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
from app.crud import contract_processing_category as cat_svc
|
||||
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
obj = cat_svc.create_category(
|
||||
db,
|
||||
category_name=body.category_name,
|
||||
biz_type=body.biz_type,
|
||||
tenant_no=tenant_no,
|
||||
order_num=body.order_num,
|
||||
remark=body.remark,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("dept_id") or "",
|
||||
)
|
||||
return success_response(cat_svc._row_to_dict(obj), message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/contract-processing-categories/{category_id}")
|
||||
async def update_contract_processing_category(
|
||||
category_id: str,
|
||||
body: ContractProcessingCategoryUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
from app.crud import contract_processing_category as cat_svc
|
||||
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
payload = body.model_dump(exclude_unset=True, by_alias=False)
|
||||
obj = cat_svc.update_category(
|
||||
db,
|
||||
category_id,
|
||||
category_name=payload.get("category_name"),
|
||||
order_num=payload.get("order_num"),
|
||||
remark=payload.get("remark"),
|
||||
user_id=user.get("user_id"),
|
||||
tenant_no=tenant_no,
|
||||
)
|
||||
return success_response(cat_svc._row_to_dict(obj), message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/contract-processing-categories/{category_id}")
|
||||
async def delete_contract_processing_category(
|
||||
category_id: str,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
from app.crud import contract_processing_category as cat_svc
|
||||
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
cat_svc.soft_delete_category(db, category_id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -136,6 +136,8 @@ class CellProductSpecCreateBody(BaseModel):
|
||||
|
||||
spec_code: str = Field(..., alias="specCode")
|
||||
spec_name: str = Field(..., alias="specName")
|
||||
cell_count_qianwan: float = Field(..., alias="cellCountQianwan")
|
||||
fill_volume_ml: float = Field(..., alias="fillVolumeMl")
|
||||
order_num: Optional[int] = Field(0, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
@@ -145,6 +147,8 @@ class CellProductSpecUpdateBody(BaseModel):
|
||||
|
||||
spec_code: Optional[str] = Field(None, alias="specCode")
|
||||
spec_name: Optional[str] = Field(None, alias="specName")
|
||||
cell_count_qianwan: Optional[float] = Field(None, alias="cellCountQianwan")
|
||||
fill_volume_ml: Optional[float] = Field(None, alias="fillVolumeMl")
|
||||
order_num: Optional[int] = Field(None, alias="orderNum")
|
||||
remark: Optional[str] = None
|
||||
|
||||
@@ -179,6 +183,8 @@ async def create_cell_product_spec(
|
||||
db,
|
||||
spec_code=body.spec_code,
|
||||
spec_name=body.spec_name,
|
||||
cell_count_qianwan=body.cell_count_qianwan,
|
||||
fill_volume_ml=body.fill_volume_ml,
|
||||
tenant_no=tenant_no,
|
||||
order_num=body.order_num,
|
||||
remark=body.remark,
|
||||
@@ -204,6 +210,8 @@ async def update_cell_product_spec(
|
||||
row_id,
|
||||
spec_code=payload.get("spec_code"),
|
||||
spec_name=payload.get("spec_name"),
|
||||
cell_count_qianwan=payload.get("cell_count_qianwan"),
|
||||
fill_volume_ml=payload.get("fill_volume_ml"),
|
||||
order_num=payload.get("order_num"),
|
||||
remark=payload.get("remark"),
|
||||
user_id=user.get("user_id"),
|
||||
|
||||
@@ -49,9 +49,7 @@ from app.schemas.production_work_order import (
|
||||
ProductionWorkOrderCreate,
|
||||
ProductionWorkOrderConfigureBody,
|
||||
ProductionWorkOrderUpdate,
|
||||
ProductionDeliveryCellOutboundBody,
|
||||
)
|
||||
from app.crud import outbound_handover as outbound_handover_svc
|
||||
from app.schemas.production_task_set import (
|
||||
ProductionTaskSetCreateBody,
|
||||
ProductionTaskSetFromWorkOrderBody,
|
||||
@@ -2027,56 +2025,6 @@ async def list_production_work_order_cell_product_options(
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/production-work-orders/{wo_id}/delivery-cell-outbound")
|
||||
async def get_production_delivery_cell_outbound_api(
|
||||
wo_id: str,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""临床科研出库工单 — 获取已确认的交付出库细胞。"""
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = outbound_handover_svc.get_production_delivery_cell_outbound(
|
||||
db, wo_id, tenant_no
|
||||
)
|
||||
return success_response(data)
|
||||
except HTTPException as e:
|
||||
return error_response(e.status_code, e.detail)
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/production-work-orders/{wo_id}/delivery-cell-outbound")
|
||||
async def save_production_delivery_cell_outbound_api(
|
||||
wo_id: str,
|
||||
body: ProductionDeliveryCellOutboundBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""临床科研出库工单 — 确认出库细胞(写台账并联动库存)。"""
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = outbound_handover_svc.save_production_delivery_cell_outbound(
|
||||
db,
|
||||
wo_id,
|
||||
cells=body.cells or [],
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id") or "",
|
||||
create_dept_id=user.get("dept_id") or "",
|
||||
)
|
||||
db.commit()
|
||||
return success_response(data, message="出库细胞已确认")
|
||||
except HTTPException as e:
|
||||
db.rollback()
|
||||
return error_response(e.status_code, e.detail)
|
||||
except ValueError as e:
|
||||
db.rollback()
|
||||
return error_response(400, str(e))
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/production-work-orders/{wo_id}/qc-info")
|
||||
async def get_production_work_order_qc_info_api(
|
||||
wo_id: str,
|
||||
|
||||
@@ -68,7 +68,7 @@ class Snapshot(BaseModel):
|
||||
|
||||
|
||||
class AssignmentBody(PreviewBody):
|
||||
reason: str = Field(min_length=1, max_length=512)
|
||||
reason: Optional[str] = Field(default='', max_length=512)
|
||||
expectedAssignments: List[Snapshot]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user