Improve AI logic
This commit is contained in:
@@ -38,18 +38,24 @@ from app.services.moq_aggregator import MOQAggregator
|
||||
from app.services.supplier_selector import SupplierSelector
|
||||
from app.core.dependencies import get_db, get_current_tenant_id
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from shared.routing import RouteBuilder
|
||||
import structlog
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
router = APIRouter(prefix="/replenishment-plans", tags=["Replenishment Planning"])
|
||||
# Create route builder for consistent URL structure
|
||||
route_builder = RouteBuilder('procurement')
|
||||
router = APIRouter(tags=["replenishment-planning"])
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Replenishment Plan Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.post("/generate", response_model=GenerateReplenishmentPlanResponse)
|
||||
@router.post(
|
||||
route_builder.build_operations_route("replenishment-plans/generate"),
|
||||
response_model=GenerateReplenishmentPlanResponse
|
||||
)
|
||||
async def generate_replenishment_plan(
|
||||
request: GenerateReplenishmentPlanRequest,
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
@@ -91,7 +97,10 @@ async def generate_replenishment_plan(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("", response_model=List[ReplenishmentPlanSummary])
|
||||
@router.get(
|
||||
route_builder.build_operations_route("replenishment-plans"),
|
||||
response_model=List[ReplenishmentPlanSummary]
|
||||
)
|
||||
async def list_replenishment_plans(
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
skip: int = Query(0, ge=0),
|
||||
@@ -123,7 +132,10 @@ async def list_replenishment_plans(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/{plan_id}", response_model=ReplenishmentPlanResponse)
|
||||
@router.get(
|
||||
route_builder.build_resource_detail_route("replenishment-plans", "plan_id"),
|
||||
response_model=ReplenishmentPlanResponse
|
||||
)
|
||||
async def get_replenishment_plan(
|
||||
plan_id: UUID = Path(...),
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
@@ -155,7 +167,10 @@ async def get_replenishment_plan(
|
||||
# Inventory Projection Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.post("/inventory-projections/project", response_model=ProjectInventoryResponse)
|
||||
@router.post(
|
||||
route_builder.build_operations_route("replenishment-plans/inventory-projections/project"),
|
||||
response_model=ProjectInventoryResponse
|
||||
)
|
||||
async def project_inventory(
|
||||
request: ProjectInventoryRequest,
|
||||
tenant_id: UUID = Depends(get_current_tenant_id)
|
||||
@@ -212,7 +227,10 @@ async def project_inventory(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/inventory-projections", response_model=List[InventoryProjectionResponse])
|
||||
@router.get(
|
||||
route_builder.build_operations_route("replenishment-plans/inventory-projections"),
|
||||
response_model=List[InventoryProjectionResponse]
|
||||
)
|
||||
async def list_inventory_projections(
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
ingredient_id: Optional[UUID] = None,
|
||||
@@ -250,7 +268,10 @@ async def list_inventory_projections(
|
||||
# Safety Stock Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.post("/safety-stock/calculate", response_model=SafetyStockResponse)
|
||||
@router.post(
|
||||
route_builder.build_operations_route("replenishment-plans/safety-stock/calculate"),
|
||||
response_model=SafetyStockResponse
|
||||
)
|
||||
async def calculate_safety_stock(
|
||||
request: SafetyStockRequest,
|
||||
tenant_id: UUID = Depends(get_current_tenant_id)
|
||||
@@ -282,7 +303,10 @@ async def calculate_safety_stock(
|
||||
# Supplier Selection Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.post("/supplier-selections/evaluate", response_model=SupplierSelectionResult)
|
||||
@router.post(
|
||||
route_builder.build_operations_route("replenishment-plans/supplier-selections/evaluate"),
|
||||
response_model=SupplierSelectionResult
|
||||
)
|
||||
async def evaluate_supplier_selection(
|
||||
request: SupplierSelectionRequest,
|
||||
tenant_id: UUID = Depends(get_current_tenant_id)
|
||||
@@ -317,7 +341,10 @@ async def evaluate_supplier_selection(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/supplier-allocations", response_model=List[SupplierAllocationResponse])
|
||||
@router.get(
|
||||
route_builder.build_operations_route("replenishment-plans/supplier-allocations"),
|
||||
response_model=List[SupplierAllocationResponse]
|
||||
)
|
||||
async def list_supplier_allocations(
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
requirement_id: Optional[UUID] = None,
|
||||
@@ -353,7 +380,10 @@ async def list_supplier_allocations(
|
||||
# MOQ Aggregation Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.post("/moq-aggregation/aggregate", response_model=MOQAggregationResponse)
|
||||
@router.post(
|
||||
route_builder.build_operations_route("replenishment-plans/moq-aggregation/aggregate"),
|
||||
response_model=MOQAggregationResponse
|
||||
)
|
||||
async def aggregate_for_moq(
|
||||
request: MOQAggregationRequest,
|
||||
tenant_id: UUID = Depends(get_current_tenant_id)
|
||||
@@ -402,7 +432,10 @@ async def aggregate_for_moq(
|
||||
# Analytics Endpoints
|
||||
# ============================================================
|
||||
|
||||
@router.get("/analytics", response_model=ReplenishmentAnalytics)
|
||||
@router.get(
|
||||
route_builder.build_analytics_route("replenishment-plans"),
|
||||
response_model=ReplenishmentAnalytics
|
||||
)
|
||||
async def get_replenishment_analytics(
|
||||
tenant_id: UUID = Depends(get_current_tenant_id),
|
||||
start_date: Optional[date] = None,
|
||||
|
||||
Reference in New Issue
Block a user