65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\LineListTriggers\Triggers;
|
|
|
|
use App\Services\LineListTriggers\Base\BaseLineListTrigger;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* WeldLog Fields Sync Trigger
|
|
*
|
|
* Synchronizes 15+ fields from Line Lists to WeldLogs
|
|
* Updates all weld logs with matching line_number
|
|
*/
|
|
class WeldLogFieldsSyncTrigger extends BaseLineListTrigger
|
|
{
|
|
public function getName(): string
|
|
{
|
|
return 'WeldLog Fields Sync';
|
|
}
|
|
|
|
public function getDependentFields(): array
|
|
{
|
|
return []; // Always run - syncs all line list fields
|
|
}
|
|
|
|
protected function process($lineListData, $beforeData, array $context): array
|
|
{
|
|
$data = [
|
|
'painting_cycle' => $lineListData->painting_cycle,
|
|
'main_nps' => $lineListData->dn,
|
|
'fluid_code' => $lineListData->fluid_code,
|
|
'service_category' => $lineListData->category,
|
|
'fluid_group' => $lineListData->fluid_group,
|
|
'piping_class' => $lineListData->pipe_material_class,
|
|
'external_finish_type' => $lineListData->external_finish_type,
|
|
'circuit_number' => $lineListData->circuit_number,
|
|
'p_id' => $lineListData->p_id,
|
|
'type_of_test' => $lineListData->test_media,
|
|
'test_pressure' => $lineListData->test_pressure_mpa,
|
|
'line_specification' => $lineListData->line_specification,
|
|
'design_pressure_mpa' => $lineListData->design_pressure_mpa,
|
|
'design_temperature_s' => $lineListData->design_temperature,
|
|
'operating_pressure_mpa' => $lineListData->working_pressure_mpa,
|
|
'operating_temperature_s' => $lineListData->working_temperature,
|
|
'ndt_percent' => $lineListData->ndt,
|
|
];
|
|
|
|
$result = db("weld_logs")
|
|
->where("line_number", $lineListData->line_no)
|
|
->update($data);
|
|
|
|
Log::debug("WeldLog güncellendi", [
|
|
'line_number' => $lineListData->line_no,
|
|
'affected_rows' => $result
|
|
]);
|
|
|
|
return [
|
|
'success' => true,
|
|
'updated_records' => $result
|
|
];
|
|
}
|
|
}
|
|
|
|
|