|
|
|
@ -166,23 +166,29 @@ async def get_corrective_cost_time_chart(
|
|
|
|
for item in data["data"]
|
|
|
|
for item in data["data"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Group data by month
|
|
|
|
# Initialize all months in the range with 0
|
|
|
|
monthly_data = {}
|
|
|
|
monthly_data = {}
|
|
|
|
for date in date_range:
|
|
|
|
current_date = start_date.replace(day=1)
|
|
|
|
month_key = date.replace(day=1)
|
|
|
|
while current_date <= end_date:
|
|
|
|
if month_key not in monthly_data:
|
|
|
|
monthly_data[current_date] = 0
|
|
|
|
monthly_data[month_key] = 0
|
|
|
|
# Move to next month
|
|
|
|
|
|
|
|
if current_date.month == 12:
|
|
|
|
if date in data_dict and data_dict[date] is not None:
|
|
|
|
current_date = datetime.datetime(current_date.year + 1, 1, 1)
|
|
|
|
monthly_data[month_key] += data_dict[date]
|
|
|
|
else:
|
|
|
|
|
|
|
|
current_date = datetime.datetime(current_date.year, current_date.month + 1, 1)
|
|
|
|
|
|
|
|
|
|
|
|
# Convert monthly data to list
|
|
|
|
# Get the last day's value for each month
|
|
|
|
|
|
|
|
for date in data_dict.keys():
|
|
|
|
|
|
|
|
month_key = datetime.datetime(date.year, date.month, 1)
|
|
|
|
|
|
|
|
if month_key in monthly_data and data_dict[date] is not None:
|
|
|
|
|
|
|
|
# Update only if the value is higher (to get the last day's value)
|
|
|
|
|
|
|
|
monthly_data[month_key] = max(monthly_data[month_key], data_dict[date])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Convert to list maintaining chronological order
|
|
|
|
complete_data = []
|
|
|
|
complete_data = []
|
|
|
|
for month in sorted(monthly_data.keys()):
|
|
|
|
for month in sorted(monthly_data.keys()):
|
|
|
|
complete_data.append(monthly_data[month])
|
|
|
|
complete_data.append(monthly_data[month])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Convert to numpy array
|
|
|
|
# Convert to numpy array
|
|
|
|
monthly_failure = np.array(complete_data)
|
|
|
|
monthly_failure = np.array(complete_data)
|
|
|
|
|
|
|
|
|
|
|
|
@ -270,9 +276,10 @@ async def create_param_and_data(
|
|
|
|
|
|
|
|
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str):
|
|
|
|
async def get_calculation_result(db_session: DbSession, calculation_id: str):
|
|
|
|
start_date = datetime.datetime(2025, 1, 1)
|
|
|
|
start_date = datetime.datetime(2025, 1, 1)
|
|
|
|
end_date = start_date + datetime.timedelta(days=677)
|
|
|
|
end_date = datetime.datetime(2026, 12, 31)
|
|
|
|
|
|
|
|
|
|
|
|
months_num = get_months_between(start_date, end_date)
|
|
|
|
months_num = get_months_between(start_date, end_date)
|
|
|
|
|
|
|
|
|
|
|
|
scope_calculation = await get_calculation_data_by_id(
|
|
|
|
scope_calculation = await get_calculation_data_by_id(
|
|
|
|
db_session=db_session, calculation_id=calculation_id
|
|
|
|
db_session=db_session, calculation_id=calculation_id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -412,7 +419,8 @@ async def create_calculation_result_service(
|
|
|
|
db_session: DbSession, calculation: CalculationData, token: str
|
|
|
|
db_session: DbSession, calculation: CalculationData, token: str
|
|
|
|
) -> CalculationTimeConstrainsRead:
|
|
|
|
) -> CalculationTimeConstrainsRead:
|
|
|
|
start_date = datetime.datetime(2025, 1, 1)
|
|
|
|
start_date = datetime.datetime(2025, 1, 1)
|
|
|
|
end_date = start_date + datetime.timedelta(days=677)
|
|
|
|
end_date = datetime.datetime(2026, 12, 31)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
months_num = get_months_between(start_date, end_date)
|
|
|
|
months_num = get_months_between(start_date, end_date)
|
|
|
|
|
|
|
|
|
|
|
|
|