From e828bbe5706e54c1225840faa84b38be794c02d0 Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Tue, 15 Jul 2025 11:43:11 +0700 Subject: [PATCH] add requests --- src/api.py | 8 ++++---- src/equipment_workscope_group/schema.py | 7 +++---- src/equipment_workscope_group/service.py | 5 ++++- src/overhaul_gantt/service.py | 6 ------ src/workscope_group/schema.py | 9 +++++++++ src/workscope_group_maintenance_type/model.py | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/api.py b/src/api.py index c3a702f..9070bb5 100644 --- a/src/api.py +++ b/src/api.py @@ -23,7 +23,7 @@ from src.equipment_workscope_group.router import router as equipment_workscope_g # from src.scope_equipment.router import router as scope_equipment_router # from src.scope_equipment_job.router import router as scope_equipment_job_router # from src.overhaul_schedule.router import router as overhaul_schedule_router -# from src.overhaul_gantt.router import router as gantt_router +from src.overhaul_gantt.router import router as gantt_router # from src.overhaul_scope.router import router as scope_router @@ -111,9 +111,9 @@ authenticated_api_router.include_router( # job_overhaul_router, prefix="/overhaul-jobs", tags=["job", "overhaul"] # ) -# authenticated_api_router.include_router( -# gantt_router, prefix="/overhaul-gantt", tags=["gantt"] -# ) +authenticated_api_router.include_router( + gantt_router, prefix="/overhaul-gantt", tags=["gantt"] +) # authenticated_api_router.include_router( # overhaul_history_router, prefix="/overhaul-history", tags=["overhaul_history"] diff --git a/src/equipment_workscope_group/schema.py b/src/equipment_workscope_group/schema.py index 397fa91..19b9890 100644 --- a/src/equipment_workscope_group/schema.py +++ b/src/equipment_workscope_group/schema.py @@ -10,8 +10,7 @@ from src.overhaul_scope.schema import ScopeRead class ScopeEquipmentJobBase(DefultBase): - assetnum: Optional[str] = Field(None, description="Assetnum is required") - + pass class ScopeEquipmentJobCreate(ScopeEquipmentJobBase): job_ids: Optional[List[UUID]] = [] @@ -34,8 +33,8 @@ class OverhaulJob(DefultBase): class ScopeEquipmentJobRead(ScopeEquipmentJobBase): id: UUID - job: ActivityMasterRead - overhaul_jobs: List[OverhaulJob] = [] + workscope_group: Optional[ActivityMasterRead] + location_tag: str class ScopeEquipmentJobPagination(Pagination): diff --git a/src/equipment_workscope_group/service.py b/src/equipment_workscope_group/service.py index 42e5137..44469b2 100644 --- a/src/equipment_workscope_group/service.py +++ b/src/equipment_workscope_group/service.py @@ -11,6 +11,9 @@ from src.database.service import CommonParameters, search_filter_sort_paginate from src.overhaul_activity.model import OverhaulActivity from src.standard_scope.model import MasterEquipment from src.standard_scope.service import get_equipment_level_by_no +from src.workscope_group.model import MasterActivity +from src.workscope_group_maintenance_type.model import WorkscopeOHType +from src.overhaul_scope.model import MaintenanceType from .model import EquipmentWorkscopeGroup from .schema import ScopeEquipmentJobCreate @@ -53,7 +56,7 @@ async def get_all(*, common, location_tag: str, scope: Optional[str] = None): """Returns all documents.""" query = ( Select(EquipmentWorkscopeGroup) - .where(EquipmentWorkscopeGroup.location_tag == location_tag) + .where(EquipmentWorkscopeGroup.location_tag == location_tag).filter(EquipmentWorkscopeGroup.workscope_group_id.is_not(None)) ) if scope: diff --git a/src/overhaul_gantt/service.py b/src/overhaul_gantt/service.py index 561c5ee..ae69552 100644 --- a/src/overhaul_gantt/service.py +++ b/src/overhaul_gantt/service.py @@ -4,12 +4,6 @@ from fastapi import HTTPException, status from sqlalchemy import Delete, Select, func from sqlalchemy.orm import selectinload -from src.auth.service import CurrentUser -from src.database.core import DbSession -from src.database.service import search_filter_sort_paginate -from src.scope_equipment_job.model import ScopeEquipmentJob -from src.overhaul_activity.model import OverhaulActivity - # from .model import OverhaulSchedule # from .schema import OverhaulScheduleCreate, OverhaulScheduleUpdate from .utils import get_google_creds, get_spreatsheed_service, process_spreadsheet_data diff --git a/src/workscope_group/schema.py b/src/workscope_group/schema.py index afe9cab..7463cd7 100644 --- a/src/workscope_group/schema.py +++ b/src/workscope_group/schema.py @@ -23,12 +23,21 @@ class ActivityMasterTasks(DefultBase): description: str +class OHType(DefultBase): + code: str + name: str + +class ActivityOHType(DefultBase): + oh_type: OHType + + class ActivityMasterRead(ActivityMaster): id: UUID workscope: str system: str subsystem: str tasks: List[ActivityMasterTasks] + oh_types: List[ActivityOHType] class ActivityMasterPagination(Pagination): diff --git a/src/workscope_group_maintenance_type/model.py b/src/workscope_group_maintenance_type/model.py index d8f1597..450ed1f 100644 --- a/src/workscope_group_maintenance_type/model.py +++ b/src/workscope_group_maintenance_type/model.py @@ -15,4 +15,4 @@ class WorkscopeOHType(Base): maintenance_type_id = Column(UUID(as_uuid=True), ForeignKey('oh_ms_maintenance_type.id')) workscope_group = relationship('MasterActivity', back_populates='oh_types') - oh_type = relationship('MaintenanceType') + oh_type = relationship('MaintenanceType', lazy='selectin')