|
|
|
@ -3,13 +3,13 @@ from fastapi import APIRouter, HTTPException, status, Query
|
|
|
|
|
|
|
|
|
|
|
|
from src.plant_transaction_data_simulations.model import PlantTransactionDataSimulations
|
|
|
|
from src.plant_transaction_data_simulations.model import PlantTransactionDataSimulations
|
|
|
|
from src.plant_transaction_data_simulations.schema import (
|
|
|
|
from src.plant_transaction_data_simulations.schema import (
|
|
|
|
PlantTransactionDataPagination,
|
|
|
|
PlantTransactionDataSimulationsPagination,
|
|
|
|
PlantTransactionDataRead,
|
|
|
|
PlantTransactionDataSimulationsRead,
|
|
|
|
PlantChartData,
|
|
|
|
PlantChartDataSimulations,
|
|
|
|
PlantTransactionChart,
|
|
|
|
PlantTransactionChartSimulations,
|
|
|
|
PlantTransactionDataCreate,
|
|
|
|
PlantTransactionDataSimulationsCreate,
|
|
|
|
PlantTransactionDataUpdate,
|
|
|
|
PlantTransactionDataSimulationsUpdate,
|
|
|
|
PlantTransactionFSImport,
|
|
|
|
PlantTransactionFSImportSimulations,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from src.plant_transaction_data_simulations.service import (
|
|
|
|
from src.plant_transaction_data_simulations.service import (
|
|
|
|
get,
|
|
|
|
get,
|
|
|
|
@ -29,7 +29,7 @@ from src.models import StandardResponse
|
|
|
|
router = APIRouter()
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("", response_model=StandardResponse[PlantTransactionDataPagination])
|
|
|
|
@router.get("", response_model=StandardResponse[PlantTransactionDataSimulationsPagination])
|
|
|
|
async def get_transaction_datas(
|
|
|
|
async def get_transaction_datas(
|
|
|
|
db_session: DbSession,
|
|
|
|
db_session: DbSession,
|
|
|
|
common: CommonParameters,
|
|
|
|
common: CommonParameters,
|
|
|
|
@ -49,7 +49,7 @@ async def get_transaction_datas(
|
|
|
|
message="Data retrieved successfully",
|
|
|
|
message="Data retrieved successfully",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/charts", response_model=StandardResponse[PlantChartData])
|
|
|
|
@router.get("/charts", response_model=StandardResponse[PlantChartDataSimulations])
|
|
|
|
async def get_chart_data(db_session: DbSession, common: CommonParameters):
|
|
|
|
async def get_chart_data(db_session: DbSession, common: CommonParameters):
|
|
|
|
chart_data, bep_year, bep_total_lcc = await get_charts(
|
|
|
|
chart_data, bep_year, bep_total_lcc = await get_charts(
|
|
|
|
db_session=db_session, common=common
|
|
|
|
db_session=db_session, common=common
|
|
|
|
@ -71,11 +71,11 @@ async def get_chart_data(db_session: DbSession, common: CommonParameters):
|
|
|
|
|
|
|
|
|
|
|
|
@router.post(
|
|
|
|
@router.post(
|
|
|
|
"/charts/fs/import",
|
|
|
|
"/charts/fs/import",
|
|
|
|
response_model=StandardResponse[List[PlantTransactionDataRead]],
|
|
|
|
response_model=StandardResponse[List[PlantTransactionDataSimulationsRead]],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async def import_fs_chart_data(
|
|
|
|
async def import_fs_chart_data(
|
|
|
|
db_session: DbSession,
|
|
|
|
db_session: DbSession,
|
|
|
|
payload: PlantTransactionFSImport,
|
|
|
|
payload: PlantTransactionFSImportSimulations,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
updated_records, missing_years = await update_fs_charts_from_matrix(
|
|
|
|
updated_records, missing_years = await update_fs_charts_from_matrix(
|
|
|
|
@ -98,7 +98,7 @@ async def import_fs_chart_data(
|
|
|
|
return StandardResponse(data=updated_records, message=message)
|
|
|
|
return StandardResponse(data=updated_records, message=message)
|
|
|
|
|
|
|
|
|
|
|
|
@router.get(
|
|
|
|
@router.get(
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataRead]
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataSimulationsRead]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async def get_transaction_data(db_session: DbSession, transaction_data_id: str):
|
|
|
|
async def get_transaction_data(db_session: DbSession, transaction_data_id: str):
|
|
|
|
transaction_data = await get(
|
|
|
|
transaction_data = await get(
|
|
|
|
@ -115,10 +115,10 @@ async def get_transaction_data(db_session: DbSession, transaction_data_id: str):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.post("", response_model=StandardResponse[PlantTransactionDataRead])
|
|
|
|
@router.post("", response_model=StandardResponse[PlantTransactionDataSimulationsRead])
|
|
|
|
async def create_transaction_data(
|
|
|
|
async def create_transaction_data(
|
|
|
|
db_session: DbSession,
|
|
|
|
db_session: DbSession,
|
|
|
|
transaction_data_in: PlantTransactionDataCreate,
|
|
|
|
transaction_data_in: PlantTransactionDataSimulationsCreate,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
transaction_data_in.created_by = current_user.name
|
|
|
|
transaction_data_in.created_by = current_user.name
|
|
|
|
@ -129,12 +129,12 @@ async def create_transaction_data(
|
|
|
|
return StandardResponse(data=transaction_data, message="Data created successfully")
|
|
|
|
return StandardResponse(data=transaction_data, message="Data created successfully")
|
|
|
|
|
|
|
|
|
|
|
|
@router.put(
|
|
|
|
@router.put(
|
|
|
|
"/bulk", response_model=StandardResponse[List[PlantTransactionDataRead]]
|
|
|
|
"/bulk", response_model=StandardResponse[List[PlantTransactionDataSimulationsRead]]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async def bulk_update_transaction_data(
|
|
|
|
async def bulk_update_transaction_data(
|
|
|
|
db_session: DbSession,
|
|
|
|
db_session: DbSession,
|
|
|
|
ids: List[str],
|
|
|
|
ids: List[str],
|
|
|
|
updates: List[PlantTransactionDataUpdate],
|
|
|
|
updates: List[PlantTransactionDataSimulationsUpdate],
|
|
|
|
current_user: CurrentUser,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
if len(ids) != len(updates):
|
|
|
|
if len(ids) != len(updates):
|
|
|
|
@ -159,12 +159,12 @@ async def bulk_update_transaction_data(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@router.put(
|
|
|
|
@router.put(
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataRead]
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataSimulationsRead]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async def update_transaction_data(
|
|
|
|
async def update_transaction_data(
|
|
|
|
db_session: DbSession,
|
|
|
|
db_session: DbSession,
|
|
|
|
transaction_data_id: str,
|
|
|
|
transaction_data_id: str,
|
|
|
|
transaction_data_in: PlantTransactionDataUpdate,
|
|
|
|
transaction_data_in: PlantTransactionDataSimulationsUpdate,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
current_user: CurrentUser,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
transaction_data = await get(
|
|
|
|
transaction_data = await get(
|
|
|
|
@ -189,7 +189,7 @@ async def update_transaction_data(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.delete(
|
|
|
|
@router.delete(
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataRead]
|
|
|
|
"/{transaction_data_id}", response_model=StandardResponse[PlantTransactionDataSimulationsRead]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
async def delete_transaction_data(db_session: DbSession, transaction_data_id: str):
|
|
|
|
async def delete_transaction_data(db_session: DbSession, transaction_data_id: str):
|
|
|
|
transaction_data = await get(
|
|
|
|
transaction_data = await get(
|
|
|
|
|