|
|
|
|
@ -233,6 +233,13 @@ async def get_master_by_assetnum(
|
|
|
|
|
yeardata_records = yeardata_result.scalars().all()
|
|
|
|
|
yeardata_dict = {y.year: y for y in yeardata_records}
|
|
|
|
|
|
|
|
|
|
maximo_record = await _fetch_joined_maximo_records(
|
|
|
|
|
session=collector_db_session, assetnum=assetnum
|
|
|
|
|
)
|
|
|
|
|
joined_maximo_record = await _fetch_joined_maximo_records(
|
|
|
|
|
session=collector_db_session, assetnum=assetnum
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Compute asset criticality per record/year and attach to each record.
|
|
|
|
|
# Use safe attribute access for Yeardata; if a value or attribute is missing,
|
|
|
|
|
# fall back to 0 so N/A data does not raise AttributeError.
|
|
|
|
|
@ -267,7 +274,7 @@ async def get_master_by_assetnum(
|
|
|
|
|
asset_criticality = ens * (0.07 * bpp_system) + (dmn - ens * extra_fuel_cost)
|
|
|
|
|
|
|
|
|
|
# if NaN or None, return 0
|
|
|
|
|
if asset_criticality is None or (isinstance(asset_criticality, float) and math.isnan(asset_criticality)):
|
|
|
|
|
if (joined_maximo_record is None or maximo_record is None) and asset_criticality is None or (isinstance(asset_criticality, float) and math.isnan(asset_criticality)):
|
|
|
|
|
asset_criticality = 0.0
|
|
|
|
|
|
|
|
|
|
setattr(record, "asset_criticality", asset_criticality)
|
|
|
|
|
@ -286,12 +293,7 @@ async def get_master_by_assetnum(
|
|
|
|
|
min_seq = equipment_record.minimum_eac_seq if equipment_record else None
|
|
|
|
|
min_eac_year = equipment_record.minimum_eac_year if equipment_record else None
|
|
|
|
|
|
|
|
|
|
maximo_record = await _fetch_joined_maximo_records(
|
|
|
|
|
session=collector_db_session, assetnum=assetnum
|
|
|
|
|
)
|
|
|
|
|
joined_maximo_record = await _fetch_joined_maximo_records(
|
|
|
|
|
session=collector_db_session, assetnum=assetnum
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
min_eac_disposal_cost = next(
|
|
|
|
|
(record.eac_disposal_cost for record in records if record.tahun == min_eac_year),
|
|
|
|
|
None,
|
|
|
|
|
|