提交
This commit is contained in:
1 parent
15ed25e33b
commit
dc31968204
143 files changed
+15823
-9989
No files matched your search
@@ -264,10 +264,25 @@ class ReceptionCheckSubmit(BaseModel):
|
||||
checked: bool = False
|
||||
|
||||
|
||||
class SampleReceptionUpdateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
reception_time: str = Field(..., alias="receptionTime")
|
||||
handler_user_id: Optional[str] = Field(None, alias="handlerUserId")
|
||||
handler_name: Optional[str] = Field(None, alias="handlerName")
|
||||
receive_temperature: Optional[str] = Field(None, alias="receiveTemperature")
|
||||
volume_ml: Optional[float] = Field(None, alias="volumeMl")
|
||||
net_weight_g: Optional[float] = Field(None, alias="netWeightG")
|
||||
checks: List[ReceptionCheckSubmit] = Field(default_factory=list)
|
||||
accept_conclusion: str = Field(..., alias="acceptConclusion")
|
||||
receive_attachments: Optional[str] = Field(None, alias="receiveAttachments")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class SampleReceptionCreateBody(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
protocol_sample_id: str = Field(..., alias="protocolSampleId")
|
||||
protocol_sample_id: Optional[str] = Field(None, alias="protocolSampleId")
|
||||
reception_time: str = Field(..., alias="receptionTime")
|
||||
handler_user_id: Optional[str] = Field(None, alias="handlerUserId")
|
||||
handler_name: Optional[str] = Field(None, alias="handlerName")
|
||||
@@ -326,3 +341,87 @@ async def post_sample_reception(
|
||||
return error_response(str(e))
|
||||
except Exception as e:
|
||||
return error_response(str(e))
|
||||
|
||||
|
||||
@router.put("/sample-receptions/{reception_id}")
|
||||
async def put_sample_reception(
|
||||
reception_id: str,
|
||||
body: SampleReceptionUpdateBody,
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
user_id = _get_current_user_id(user)
|
||||
rt = parse_datetime(body.reception_time)
|
||||
if not rt:
|
||||
return error_response("样本接收时间格式无效")
|
||||
checks_payload = [
|
||||
{"checkItemId": c.check_item_id, "checked": c.checked} for c in body.checks
|
||||
]
|
||||
obj = sr_svc.update_sample_reception(
|
||||
db,
|
||||
reception_id=reception_id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user_id,
|
||||
reception_time=rt,
|
||||
handler_user_id=body.handler_user_id or user_id,
|
||||
handler_name=body.handler_name,
|
||||
receive_temperature=body.receive_temperature,
|
||||
volume_ml=body.volume_ml,
|
||||
net_weight_g=body.net_weight_g,
|
||||
checks=checks_payload,
|
||||
accept_conclusion=body.accept_conclusion,
|
||||
receive_attachments=body.receive_attachments,
|
||||
remark=body.remark,
|
||||
)
|
||||
detail = sr_svc.get_reception_by_id(db, obj.id, tenant_no)
|
||||
return success_response(detail or {"id": obj.id})
|
||||
except PermissionError as e:
|
||||
return error_response(str(e), code=403)
|
||||
except ValueError as e:
|
||||
return error_response(str(e))
|
||||
except Exception as e:
|
||||
return error_response(str(e))
|
||||
|
||||
|
||||
@router.put("/sample-receptions/{reception_id}")
|
||||
async def put_sample_reception(
|
||||
reception_id: str,
|
||||
body: SampleReceptionUpdateBody,
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
user_id = _get_current_user_id(user)
|
||||
rt = parse_datetime(body.reception_time)
|
||||
if not rt:
|
||||
return error_response("样本接收时间格式无效")
|
||||
checks_payload = [
|
||||
{"checkItemId": c.check_item_id, "checked": c.checked} for c in body.checks
|
||||
]
|
||||
obj = sr_svc.update_sample_reception(
|
||||
db,
|
||||
reception_id=reception_id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user_id,
|
||||
reception_time=rt,
|
||||
handler_user_id=body.handler_user_id or user_id,
|
||||
handler_name=body.handler_name,
|
||||
receive_temperature=body.receive_temperature,
|
||||
volume_ml=body.volume_ml,
|
||||
net_weight_g=body.net_weight_g,
|
||||
checks=checks_payload,
|
||||
accept_conclusion=body.accept_conclusion,
|
||||
receive_attachments=body.receive_attachments,
|
||||
remark=body.remark,
|
||||
)
|
||||
detail = sr_svc.get_reception_by_id(db, obj.id, tenant_no)
|
||||
return success_response(detail or {"id": obj.id})
|
||||
except PermissionError as e:
|
||||
return error_response(str(e), code=403)
|
||||
except ValueError as e:
|
||||
return error_response(str(e))
|
||||
except Exception as e:
|
||||
return error_response(str(e))
|
||||
Reference in new issue
Block a user