提交
This commit is contained in:
1 parent
14f1a84bb3
commit
d387ba4017
34 files changed
+6155
-3865
No files matched your search
@@ -1271,7 +1271,7 @@ async def get_production_work_order(
|
||||
wo = production_work_order_svc.get_production_work_order(db, wo_id, tenant_no)
|
||||
if not wo:
|
||||
return error_response(404, "工单不存在")
|
||||
return success_response(production_work_order_svc._wo_to_dict(wo))
|
||||
return success_response(production_work_order_svc._wo_to_response_dict(db, wo))
|
||||
|
||||
|
||||
@router.put("/production-work-orders/{wo_id}/complete")
|
||||
@@ -1286,7 +1286,7 @@ async def complete_production_work_order(
|
||||
wo = production_work_order_svc.complete_production_work_order(
|
||||
db, wo_id, tenant_no, user.get("user_id"), body,
|
||||
)
|
||||
return success_response(production_work_order_svc._wo_to_dict(wo), message="操作成功")
|
||||
return success_response(production_work_order_svc._wo_to_response_dict(db, wo), message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
@@ -1549,12 +1549,16 @@ async def set_production_task_outputs(
|
||||
|
||||
@router.get("/cell-products/next-code")
|
||||
async def get_next_cell_product_code(
|
||||
count: int = Query(1, ge=1, le=50),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
code = cell_product_svc.get_next_code(db, tenant_no)
|
||||
return success_response({"code": code})
|
||||
if count <= 1:
|
||||
code = cell_product_svc.get_next_code(db, tenant_no)
|
||||
return success_response({"code": code})
|
||||
codes = cell_product_svc.reserve_next_codes(db, tenant_no, count)
|
||||
return success_response({"codes": codes, "code": codes[0] if codes else ""})
|
||||
|
||||
|
||||
@router.get("/cell-products")
|
||||
@@ -1606,12 +1610,42 @@ async def create_cell_product(
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
obj = cell_product_svc.create_cell_product(
|
||||
db, tenant_no=tenant_no, user_id=user.get("user_id"),
|
||||
create_dept_id="", data=body,
|
||||
)
|
||||
items = body.items or []
|
||||
qty = int(body.quantity) if body.quantity is not None else 1
|
||||
qty = max(1, min(qty, 50))
|
||||
if items:
|
||||
created = cell_product_svc.create_cell_products_batch(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id="",
|
||||
data=body,
|
||||
items=items,
|
||||
)
|
||||
elif qty > 1:
|
||||
created = cell_product_svc.create_cell_products_by_quantity(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id="",
|
||||
data=body,
|
||||
count=qty,
|
||||
)
|
||||
else:
|
||||
obj = cell_product_svc.create_cell_product(
|
||||
db, tenant_no=tenant_no, user_id=user.get("user_id"),
|
||||
create_dept_id="", data=body,
|
||||
)
|
||||
return success_response(
|
||||
cell_product_svc.product_to_response(db, tenant_no, obj), message="创建成功"
|
||||
)
|
||||
resp_list = [
|
||||
cell_product_svc.product_to_response(db, tenant_no, obj) for obj in created
|
||||
]
|
||||
n = len(created)
|
||||
return success_response(
|
||||
cell_product_svc.product_to_response(db, tenant_no, obj), message="创建成功"
|
||||
{"list": resp_list, "count": n},
|
||||
message=f"成功创建 {n} 份细胞产品",
|
||||
)
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
Reference in new issue
Block a user