# WPS Arama ve Seçim Mantığı Dokümantasyonu / WPS Search & Selection Logic Documentation Bu belge, `app/Http/Controllers/AutoCompleteType/wps_no2.php` dosyasındaki WPS arama algoritmasının teknik detaylarını ve işleyiş mantığını açıklar. This document serves as the technical documentation for the WPS search algorithm located in `app/Http/Controllers/AutoCompleteType/wps_no2.php`. --- # 🇹🇷 Türkçe Dokümantasyon ## 1. Genel Bakış Bu modül, kullanıcı tarafından sağlanan parametrelere (Çap, Et Kalınlığı, Kaynak Tipi vb.) dayanarak en uygun **WPS (Welding Procedure Specification)** kaydını bulmak için tasarlanmıştır. Sistem, önce uygun **PQR (Prosedür Onay Kaydı)** listesini belirler, ardından bu PQR'lar ve diğer fiziksel kısıtlamalarla WPS tablosunu filtreler. Eşleşme bulunamazsa, sistem "Teşhis Modu"na (Diagnostic Mode) geçerek kullanıcının hangi kriterden dolayı sonuç alamadığını analiz eder. ## 2. Girdi Parametreleri Algoritma aşağıdaki parametreleri kullanır: * **outside_diameter_1**: Boru Dış Çapı (mm) * **wall_thickness_1**: Boru Et Kalınlığı (mm) * **type_of_welds**: Kaynak Tipi (örn: BW, FW) * **pwht**: Isıl İşlem Durumu ('YES' veya 'NO') * **ru_material_group_1**: 1. Malzeme Grubu * **ru_material_group_2**: 2. Malzeme Grubu * **piping_type**: Hat Tipi ("Support" özel durum oluşturur) ## 3. İşleyiş Mantığı ### Adım 1: PQR Seçimi Sistem ilk olarak malzeme gruplarına göre geçerli PQR'ları belirler. * **Aynı Malzeme Grupları**: Eğer Grup 1 ve Grup 2 aynıysa, sistem sadece tekil grubu içeren kayıtları arar ve `+` ile birleştirilmiş karma malzemeleri (dissimilar welds) hariç tutar. * **Farklı Malzeme Grupları**: İki grup birbirinden farklıysa, sistem bunların kombinasyonlarını (`Grup1+Grup2` veya `Grup2+Grup1`) arar. ### Adım 2: WPS Filtreleme Seçilen PQR listesi ve diğer parametreler kullanılarak `w_p_s` tablosunda arama yapılır. 1. **Temel Kriterler**: `approved_date` dolu olmalı ve `pqr_no` bulunan PQR listesinde yer almalıdır. 2. **Et Kalınlığı**: * WPS'in `min_thick` değeri, aranan kalınlığa eşit veya küçük olmalı. * WPS'in `max_thick` değeri, aranan kalınlığa eşit veya büyük olmalı (0 değeri limitsiz kabul edilir). 3. **Dış Çap**: * Eğer hat tipi "Support" **değilse**: `work_type` "PIPE" içermeli ve çap aralıkları (min/max) kontrol edilmelidir. * Eğer hat tipi "Support" **ise**: Sadece `work_type` alanı kontrol edilir, çap kısıtlaması uygulanmaz. 4. **Kaynak Tipi**: `joint_type` birebir eşleşmelidir. 5. **PWHT (Isıl İşlem)**: * **YES**: `pwht_temp_range` ve `pwht_min_time` alanları dolu olmalıdır. * **NO**: Bu alanlar boş veya "0" olmalıdır. ### Adım 3: Hata Analizi (Hiçbir Sonuç Bulunamazsa) Sistem hiçbir WPS bulamazsa, hatanın kaynağını tespit etmek için filtreleri tek tek ve gruplar halinde tekrar çalıştırır. * **Tekil Analiz**: Sadece Çap, sadece Kalınlık, sadece Kaynak Tipi vb. kaç sonuç döndürüyor? * **Kombine Analiz**: (Çap + Kalınlık), (Çap + Kaynak Tipi) vb. kesişim kümeleri kontrol edilir. Bu analiz sonucunda kullanıcıya "Çap uyuyor ama Kaynak Tipi uymuyor" gibi çıkarımlar yapabileceği detaylı bir hata raporu sunulur. --- # 🇬🇧 English Documentation ## 1. Overview This module is designed to find the most appropriate **WPS (Welding Procedure Specification)** record based on user-provided parameters (Diameter, Wall Thickness, Weld Type, etc.). The system first identifies the list of suitable **PQR (Procedure Qualification Records)**, then filters the WPS table using these PQRs and other physical constraints. If no match is found, the system enters "Diagnostic Mode" to analyze which specific criterion caused the failure. ## 2. Input Parameters The algorithm utilizes the following parameters: * **outside_diameter_1**: Pipe Outside Diameter (mm) * **wall_thickness_1**: Pipe Wall Thickness (mm) * **type_of_welds**: Type of Weld (e.g., BW, FW) * **pwht**: Post Weld Heat Treatment status ('YES' or 'NO') * **ru_material_group_1**: Material Group 1 * **ru_material_group_2**: Material Group 2 * **piping_type**: Line Type ("Support" triggers special logic) ## 3. Workflow Logic ### Step 1: PQR Selection The system first determines valid PQRs based on material groups. * **Identical Material Groups**: If Group 1 and Group 2 are the same, the system searches for records containing only that single group, explicitly excluding dissimilar weld combinations containing `+`. * **Different Material Groups**: If the groups differ, the system searches for valid combinations (`Group1+Group2` or `Group2+Group1`). ### Step 2: WPS Filtering Using the selected PQR list and other parameters, the system searches the `w_p_s` table. 1. **Basic Criteria**: `approved_date` must not be null, and `pqr_no` must be in the identified PQR list. 2. **Wall Thickness**: * WPS `min_thick` must be less than or equal to the requested thickness. * WPS `max_thick` must be greater than or equal to the requested thickness (0 is considered unlimited). 3. **Outside Diameter**: * If piping type is **NOT** "Support": `work_type` must contain "PIPE", and diameter ranges (min/max) are checked. * If piping type **IS** "Support": Only `work_type` is checked; diameter constraints are ignored. 4. **Joint Type**: `joint_type` must match valid values exactly. 5. **PWHT**: * **YES**: `pwht_temp_range` and `pwht_min_time` fields must be populated. * **NO**: These fields must be empty or "0". ### Step 3: Error Analysis (If No Results Found) If the system finds no matching WPS, it re-runs filters individually and in groups to identify the root cause. * **Individual Analysis**: How many results do Diameter, Thickness, Joint Type, etc., yield on their own? * **Combined Analysis**: Checks intersection sets like (Diameter + Thickness), (Diameter + Joint Type). Based on this analysis, a detailed error report is generated for the user, allowing them to deduce, for example, that "Diameter matches but Joint Type does not."