diff --git a/src/aeros_equipment/service.py b/src/aeros_equipment/service.py index 31c8322..0f2d518 100644 --- a/src/aeros_equipment/service.py +++ b/src/aeros_equipment/service.py @@ -335,7 +335,7 @@ async def update_oh_interval_offset(*, aeros_db_session, overhaul_offset, overha await aeros_db_session.commit() -async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_session:CollectorDbSession ,project_name: str,overhaul_duration, overhaul_interval, offset ,schematic_name: str, custom_input: Optional[dict] = None): +async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_session:CollectorDbSession ,project_name: str,simulation_duration:int ,overhaul_duration, overhaul_interval, offset ,schematic_name: str, custom_input: Optional[dict] = None): log.info("Updating equipment for simulation") aeros_schematic = await get_aeros_schematic_by_name(db_session=db_session, schematic_name=schematic_name) @@ -362,6 +362,16 @@ async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_sess nodes_data = await get_aeros_equipment_by_location_tag( location_tag=reg_nodes, project_name=project_name ) + + def load_json_file(filename: str) -> Dict[str, Any]: + """Load a JSON file and return its content.""" + try: + with open(filename, 'r', encoding='utf-8') as f: + return json.load(f) + except FileNotFoundError: + raise FileNotFoundError(f"JSON file not found: {filename}") + except json.JSONDecodeError as e: + raise ValueError(f"Invalid JSON in file {filename}: {e}") non_repairable = await db_session.execute(Select(ReliabilityPredictNonRepairable)) non_repairable_location_tags = [tag.location_tag for tag in non_repairable.scalars().all()] @@ -372,6 +382,8 @@ async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_sess reqNodeInputs = [] results = defaultdict() + trip_eq = load_json_file("trip_eq.json") + print("Updating Overhaul Offset & Overhaul Interval") await update_oh_interval_offset(aeros_db_session=aeros_db_session, project_name=project_name,overhaul_interval=overhaul_interval, overhaul_offset=offset) @@ -380,7 +392,8 @@ async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_sess # Check if eq already exists in results if eq["equipmentName"] in results.keys(): continue - + + reliabiility = reliability_data.get(eq["equipmentName"], {}) if custom_input and eq["equipmentName"] in custom_input: @@ -390,7 +403,9 @@ async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_sess continue if not custom_param['failure_rate']: continue - + + # Check eq dengan "TRIP" di WO, jika ada masukkan parameter Reliabilitu, jika tidak ada MTBF = duration + eq["cmDisP1"] = custom_param["mttr"] eq["relDisType"] = "Fixed" eq["relDisP1"] = float(custom_param["failure_rate"]) @@ -408,13 +423,21 @@ async def update_equipment_for_simulation(*, db_session: DbSession,aeros_db_sess "oh_duration": overhaul_duration } continue - + eq["cmDisP1"] = reliabiility.get("cmDisP1", 0) - eq["relDisType"] = reliabiility.get("relDisType", "Fixed") - eq["relDisP1"] = reliabiility.get("relDisP1", 0) - eq["relDisP2"] = reliabiility.get("relDisP2", 0) + eq["relDisType"] = "Fixed" + eq["relDisP1"] = simulation_duration + 1 + eq["relDisP2"] = 0 eq["ohDisP1"] = overhaul_duration eq["ohDisUnitCode"] = "UHour" + + if eq["equipmentName"] in trip_eq: + eq["cmDisP1"] = reliabiility.get("cmDisP1", 0) + eq["relDisType"] = reliabiility.get("relDisType", "Fixed") + eq["relDisP1"] = reliabiility.get("relDisP1", 0) + eq["relDisP2"] = reliabiility.get("relDisP2", 0) + eq["ohDisP1"] = overhaul_duration + eq["ohDisUnitCode"] = "UHour" reqNodeInputs.append(eq) results[eq["equipmentName"]] = { diff --git a/src/aeros_equipment/trip_eq.json b/src/aeros_equipment/trip_eq.json new file mode 100644 index 0000000..9f95ae5 --- /dev/null +++ b/src/aeros_equipment/trip_eq.json @@ -0,0 +1,394 @@ +[ + "00CHB-SKR805B", + "4ABS-P910B", + "00CHD-TPR810A", + "00SSB-EV002", + "00CHD-PAN860", + "4LGT-PD951", + "00DS-P978B", + "00CHD-CV809B", + "00RO-CAB225B", + "00CHD-TPR810B", + "3ABS-AG879A", + "00CHD-PAN861", + "4AI-Y514B", + "4AI-Y516A", + "3GG-M851A", + "4ESP-XR802", + "4TR-F303", + "00DS-P978A", + "4LGT-PD952", + "00AGS-HG001", + "00FWP-P003B", + "3AI-Y502B", + "00RP-Z856A", + "00RO-P170D", + "00DS-VF900", + "00DMW-F360B", + "00FF-LBX871", + "4AI-Y503I", + "4ESP-RD823", + "00AC-F501A", + "00CHD-CV810B", + "00WWT-P111A", + "00LSH-F901", + "00DMW-C375B", + "00RO-CAB230A", + "00IA-A001A", + "00FAD-H802A", + "3ESP-TE870A", + "4AL-V701C", + "00APE-TF801A", + "00CHD-CV810A", + "00FAD-A812B", + "00FAD-CT801A", + "3ESP-XR801", + "00ACR-C001A", + "4ABS-AG879C", + "00APC-LV801B", + "00RO-P130B", + "00CHB-SKR805A", + "00RP-Z856B", + "4GG-F853C", + "3AI-Y512B", + "4AI-PAN501B", + "4AL-F501B", + "4ABS-AG931", + "00RP-P972A", + "00PRW-M856A", + "00RP-M856A", + "4ABS-PD861", + "00RO-CAB230D", + "4APC-PD505", + "00DS-VF935", + "4AI-Y506B", + "00RO-AG122D", + "00DS-PD862", + "00RO-P160D", + "00DS-P902B", + "00CHA-CV803B", + "3AI-Y507C", + "00CL-XR001B", + "00FAD-H816A", + "00IA-A001B", + "3AI-Y517A", + "00RO-P170C", + "00SW-P012A", + "00FAD-PD801", + "00WWT-P112B", + "00RO-P110C", + "4BAD-P521B", + "00FAD-C811C", + "00RO-P170A", + "4ESP-CAB831", + "3GG-F854A", + "4EHS-F015A", + "4DP-BM731C", + "00WWT-P112A", + "3ABS-PIX910", + "00LSH-CV852", + "00FAD-DC801", + "3GG-H870", + "3GG-F802A", + "3ABS-AG879C", + "00RP-AG885", + "3ABS-P888A", + "00RO-P230B", + "4ABS-AG879A", + "3AH-P531B", + "00FAD-Z811B", + "00RO-AG122B", + "00DS-M935", + "4ABS-P932B", + "3TR-CAB004B", + "3AI-Y505B", + "00RO-P170B", + "00RO-CAB230B", + "00WWT-SD330A", + "3TR-F305", + "00RO-P230A", + "00APE-MV803A", + "00AC-F005", + "4AI-Y503L", + "4AI-Y504A", + "00RO-CAB225C", + "3EG-E001", + "4AL-V701D", + "00AC-F501B", + "3AI-Y516C", + "00DMW-C375A", + "3SCR-P003A", + "3TR-CAB006", + "3AI-Y504B", + "00FAD-A812A", + "4GG-F805A", + "4BAD-P521A", + "00RO-SRP120A", + "4TR-F302", + "00AC-HS802", + "00FO-P802B", + "3APC-PD508", + "3DP-FDR711B", + "4DP-M712F", + "TJB-0", + "4AI-Y512C", + "00LSH-PAN865", + "4ESP-HH809A", + "3SCR-S002A", + "3AI-Y503R", + "00SW-V112", + "00APC-TF803B", + "3TR-F303", + "3GG-M878A", + "4ESP-XR812", + "4AI-Y507A", + "00AC-F210", + "00CL-XR001A", + "00WD-P010A", + "3ESP-RD821", + "4DP-BM741C", + "00APC-TF801B", + "00FF-V829", + "00PW-P010A", + "4ESP-CAB837", + "3ESP-RD835", + "4ESP-HH815B", + "4ESP-CAB843", + "3ESP-LS853B", + "3GG-F853A", + "00RO-P110D", + "4TR-F301", + "3AI-Y515L", + "4ESP-HH806B", + "4APC-TF810A", + "3AI-Y502L", + "3ESP-XR804", + "00FAD-LBX814", + "4ESP-XR801", + "00AC-HS816", + "00FAD-C811B", + "00DCS-CAB004A", + "00CHD-VS801B", + "00WWT-P262A", + "00RO-P130C", + "4ABS-W914B", + "4ESP-RD835", + "4ESP-XR811", + "00UWTS-P101D", + "00RO-SRP120D", + "00RO-M170D", + "00APC-LV004A", + "00RO-P255D", + "3ABS-AG879B", + "00CHD-CV809A", + "00PRW-P856A", + "00WD-P409B", + "4TR-F306", + "3AI-Y504L", + "3TR-F302", + "3AI-Y501B", + "00FAD-DC802", + "3GG-F853B", + "3AI-Y508B", + "4CW-P011A", + "3ESP-CAB831", + "00FAD-C811A", + "3ESP-HH801B", + "4ESP-CAB844", + "4AI-Y501B", + "4ABS-P888C", + "00DC-PD509", + "3TR-F306", + "00WWT-P380A", + "00CCCW-V006", + "00WWT-P380B", + "3AL-F501A", + "00CHA-FS801A", + "4AI-Y516R", + "00RO-SRP120C", + "4TR-F304", + "00LGT-PD923", + "4GG-F875A", + "3ABS-P910B", + "00RO-SD252A", + "00RO-P110A", + "4DP-FDR711D", + "4ESP-XR807", + "00AC-HS807", + "4GG-F853A", + "4ABS-P910A", + "00WWT-AG371C", + "3GG-P802A", + "3ESP-RD801", + "00LSH-VI851", + "4TR-TF001", + "3ESP-XR802", + "00DS-P937B", + "4AI-Y507C", + "00RP-P995B", + "00RO-P126D", + "00RO-M130A", + "00DS-PD863", + "00WWT-AG151", + "3DP-FDR711C", + "00RO-M170B", + "4ESP-XR809", + "00WWT-F180C", + "3WD-P020B", + "00RP-M856B", + "3GG-P878A", + "3APC-LV851", + "4ESP-XR816", + "00LSH-CR853", + "00AC-F020C", + "00CL-S001B", + "00WD-P409A", + "00FWTS-M103B", + "00DMW-P370A", + "00DS-AG851", + "00AC-F091A", + "00RO-P195B", + "3BAD-P521A", + "3DP-M741F", + "4AI-Y513A", + "4ESP-XR804", + "4AI-Y504H", + "00RO-P140A", + "3SCR-S002B", + "3DP-FDR711E", + "4AL-DPS701A", + "4ESP-CAB832", + "3GG-F875A", + "4TR-F307", + "00WWT-AG371A", + "00RP-P952B", + "00WD-PAN414", + "3GSS-F011A", + "3TR-TF001", + "4AI-Y507B", + "00LSH-M852", + "4ESP-XR808", + "4ESP-RD828", + "3ESP-XR810", + "00DMW-M375A", + "00WWT-P142B", + "4AI-Y514R", + "00SW-V830", + "00DVF-P853A", + "3GG-F804B", + "3TR-F301", + "00AC-F102B", + "4TR-TF005", + "3ESP-HH809A", + "00FAD-H802B", + "3APC-PD505", + "3ESP-RD827", + "4ABS-T931", + "00FAD-CAB815", + "3WD-P020A", + "00WWT-SRP141B", + "00DS-P902A", + "4TR-CAB006", + "3CHF-DC902", + "00FF-V882", + "00FF-FS911", + "00UWTS-P101A", + "3TR-F307", + "00RP-P991A", + "00WWT-AG131", + "3AI-Y505R", + "4AI-Y505R", + "4DP-BM741A", + "3DP-FDR711A", + "3LGT-PD851", + "00RO-AG122A", + "4AI-Y507L", + "3GG-P802B", + "00FAD-A812C", + "3AI-Y508A", + "00DMW-CAB105A", + "00FAD-Z811A", + "00ACR-C001C", + "3APE-MV852", + "00WWT-P142A", + "3GG-F853C", + "00FF-SN816", + "4SCR-P003B", + "3GG-F805A", + "4DP-FDR711E", + "3ESP-XR803", + "4ESP-CAB839", + "00FF-LBX860", + "4APC-TF810B", + "4ESP-HH802B", + "00CHB-CV805B", + "3ABS-W871", + "00RO-M170C", + "00RO-P255C", + "3HM-G511A", + "00DS-W859", + "4TR-F305", + "00WD-P406A", + "3AI-Y516L", + "00DMW-P370B", + "00RO-P140B", + "00DS-P901", + "00RO-P234A", + "00RP-M911A", + "00CHB-CV805A", + "00SSB-EV011", + "3ESP-XR805", + "00RP-P972B", + "3CW-P020A", + "4GG-H870", + "3AI-Y502A", + "4ABS-AG879B", + "4ESP-HH801A", + "3ABS-W866", + "00ACR-C001B", + "4GG-M851B", + "4SCR-S002B", + "00H2-CS002", + "3AI-Y506L", + "00WWT-AG350C", + "4CHF-DC903", + "00FF-MPB880", + "00WWT-P111B", + "4AI-Y511R", + "00AC-F081D", + "4ABS-P932A", + "4GG-M801A", + "00AC-HS804", + "00FMU-P801B", + "3DP-M711C", + "00CL-M001A", + "3AI-Y510C", + "00LGT-PD813", + "4AI-Y513B", + "3GEN-GM001", + "00RO-AG122C", + "4AI-Y515L", + "4AI-Y502B", + "3ABS-W874", + "4AI-Y506A", + "4DP-M712B", + "3AI-Y510R", + "4GG-F854A", + "4DP-PAN712A", + "3ABS-P910A", + "00RO-SRP120B", + "4AI-Y502I", + "3ESP-RD803", + "3AI-Y504R", + "4SCR-W004B", + "00WD-P405B", + "4ESP-CAB821", + "00AGS-T005", + "4GG-F854B", + "00AC-F081F", + "3ABS-AG879D", + "4COTC-P060A", + "4DP-BM731E", + "00LSH-M851", + "3DP-SV701A" +] \ No newline at end of file