Add OpenBin returns neu BIN Number form port
This commit is contained in:
1 parent
da522ffac6
commit
b9185263ec
3 files changed
+75
-22
No files matched your search
@@ -135,3 +135,6 @@ dmypy.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/.devcontainer/
|
||||
|
||||
# tosca_src
|
||||
/tosca_src
|
||||
@@ -48,6 +48,14 @@ def update_bin_content(db: Session, bin_id: str, content_code: int):
|
||||
db.refresh(db_bin)
|
||||
return db_bin
|
||||
|
||||
def get_next_empty_bin(db: Session):
|
||||
"""
|
||||
Get the next available empty bin (content_code = 0 or None).
|
||||
"""
|
||||
return db.query(models.Bin).filter(
|
||||
(models.Bin.content_code == 0) | (models.Bin.content_code == None)
|
||||
).first()
|
||||
|
||||
# --- Port CRUD ---
|
||||
|
||||
def get_port(db: Session, port_id: str):
|
||||
|
||||
+64
-22
@@ -80,12 +80,17 @@ app = FastAPI(
|
||||
- Port management (INBOUND, OUTBOUND, OFF modes)
|
||||
- Task and TaskGroup management
|
||||
- Background simulation engine
|
||||
- Automatic empty bin allocation for warehouse inbound processes
|
||||
|
||||
**XML Commands Supported (case-insensitive):**
|
||||
- CreateTaskgroup, GetTaskInfo, DeleteTaskgroup, GetNextTask
|
||||
- GetBinInfo, OpenBin, CloseBin, SetBinContentCode
|
||||
- GetBinInfo, OpenBin (by Bin ID or Port ID), CloseBin, SetBinContentCode
|
||||
- SetPortMode
|
||||
|
||||
**Wareneingang (Inbound) Support:**
|
||||
- OpenBin with Port ID automatically returns next available empty bin
|
||||
- Compatible with PL/SQL packages expecting /response/params/bin_id format
|
||||
|
||||
**Admin Endpoints:**
|
||||
- Bin CRUD operations and bulk generation
|
||||
- Port management
|
||||
@@ -120,14 +125,14 @@ async def handle_xml_request(request: Request, db: Session = Depends(get_db)):
|
||||
|
||||
**Bin Management:**
|
||||
- GetBinInfo / getbininfo: Get information about a specific bin
|
||||
- OpenBin / openbin: Open a bin (logs the action)
|
||||
- OpenBin / openbin: Open a bin by Bin ID OR request next empty bin for a port
|
||||
- CloseBin / closebin: Close a bin (logs the action)
|
||||
- SetBinContentCode / setbincontentcode: Set the content code of a bin
|
||||
|
||||
**Port Management:**
|
||||
- SetPortMode / setportmode: Set the mode of a port (INBOUND, OUTBOUND, OFF)
|
||||
|
||||
**Example XML Request for OpenBin (case-insensitive):**
|
||||
**Example XML Request for OpenBin by Bin ID:**
|
||||
```xml
|
||||
<AutoStore>
|
||||
<OpenBin>
|
||||
@@ -136,11 +141,20 @@ async def handle_xml_request(request: Request, db: Session = Depends(get_db)):
|
||||
</AutoStore>
|
||||
```
|
||||
|
||||
**Example XML Request for OpenBin by Port (gets next empty bin):**
|
||||
```xml
|
||||
<AutoStore>
|
||||
<OpenBin>
|
||||
<Port>1</Port>
|
||||
</OpenBin>
|
||||
</AutoStore>
|
||||
```
|
||||
|
||||
**Alternative (lowercase):**
|
||||
```xml
|
||||
<AutoStore>
|
||||
<openbin>
|
||||
<Bin>A100000</Bin>
|
||||
<Port>1</Port>
|
||||
</openbin>
|
||||
</AutoStore>
|
||||
```
|
||||
@@ -385,29 +399,57 @@ async def handle_xml_request(request: Request, db: Session = Depends(get_db)):
|
||||
open_bin_data = autostore_data[command_key]
|
||||
|
||||
if not open_bin_data or not isinstance(open_bin_data, dict):
|
||||
raise HTTPException(status_code=400, detail="Bin ID is required for OpenBin.")
|
||||
raise HTTPException(status_code=400, detail="Port ID or Bin ID is required for OpenBin.")
|
||||
|
||||
port_id = open_bin_data.get("Port")
|
||||
bin_id = open_bin_data.get("Bin")
|
||||
|
||||
if not bin_id:
|
||||
raise HTTPException(status_code=400, detail="Bin ID is required for OpenBin.")
|
||||
|
||||
# Check if bin exists
|
||||
bin_obj = crud.get_bin(db, bin_id=bin_id)
|
||||
if not bin_obj:
|
||||
raise ValueError(f"Bin not found: {bin_id}")
|
||||
|
||||
# Log the open bin action
|
||||
logger.info(f"OpenBin command received for bin: {bin_id}")
|
||||
|
||||
response_dict = {
|
||||
"AutoStore": {
|
||||
"OpenBin": {
|
||||
"Bin": bin_id,
|
||||
"Success": True
|
||||
if port_id:
|
||||
# Port-basierter Zugriff: Hole nächste verfügbare Bin für Port
|
||||
logger.info(f"OpenBin command received for port: {port_id}")
|
||||
|
||||
# Prüfe ob Port existiert
|
||||
port = crud.get_port(db, port_id=port_id)
|
||||
if not port:
|
||||
raise ValueError(f"Port not found: {port_id}")
|
||||
|
||||
# Hole nächste verfügbare leere Bin (content_code = 0 oder None)
|
||||
next_bin = crud.get_next_empty_bin(db)
|
||||
if not next_bin:
|
||||
raise ValueError("No empty bins available")
|
||||
|
||||
# TODO: Bin zum Port zuweisen in der Datenbank
|
||||
|
||||
# Antwort im erwarteten Format für PL/SQL
|
||||
response_dict = {
|
||||
"response": {
|
||||
"params": {
|
||||
"bin_id": next_bin.id,
|
||||
"port_id": port_id,
|
||||
"success": True
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elif bin_id:
|
||||
# Bin-basierter Zugriff (wie bisher)
|
||||
logger.info(f"OpenBin command received for bin: {bin_id}")
|
||||
|
||||
bin_obj = crud.get_bin(db, bin_id=bin_id)
|
||||
if not bin_obj:
|
||||
raise ValueError(f"Bin not found: {bin_id}")
|
||||
|
||||
response_dict = {
|
||||
"response": {
|
||||
"params": {
|
||||
"bin_id": bin_id,
|
||||
"success": True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail="Either Port ID or Bin ID is required for OpenBin.")
|
||||
|
||||
elif command == "closebin":
|
||||
close_bin_data = autostore_data[command_key]
|
||||
|
||||
Reference in new issue
Block a user