now associating a dewar to a slot
This commit is contained in:
@ -87,4 +87,22 @@ async def scan_dewar(event_data: LogisticsEventCreate, db: Session = Depends(get
|
||||
def log_event(db: Session, dewar_id: int, slot_id: int, event_type: str):
|
||||
new_event = LogisticsEventModel(dewar_id=dewar_id, slot_id=slot_id, event_type=event_type)
|
||||
db.add(new_event)
|
||||
db.commit()
|
||||
db.commit()
|
||||
|
||||
|
||||
@router.post("/dewar/refill", response_model=dict)
|
||||
async def refill_dewar(qr_code: str, db: Session = Depends(get_db)):
|
||||
dewar = db.query(DewarModel).filter(DewarModel.unique_id == qr_code).first()
|
||||
if not dewar:
|
||||
raise HTTPException(status_code=404, detail="Dewar not found")
|
||||
|
||||
# Process refill
|
||||
dewar.last_refill = datetime.now()
|
||||
new_event = LogisticsEventModel(
|
||||
dewar_id=dewar.id, slot_id=None, # No specific slot, as it's a refill event
|
||||
event_type="refill",
|
||||
action_details=f"{dewar.unique_id} refilled"
|
||||
)
|
||||
db.add(new_event)
|
||||
db.commit()
|
||||
return {"message": "Dewar refilled successfully"}
|
Reference in New Issue
Block a user