İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
use App\Models\WeldLog;
|
||||
use App\Models\NdeMatrix;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
$id = $request['key'];
|
||||
|
||||
Log::debug("NDE Matrix güncelleme işlemi başlatıldı", [
|
||||
'istek_id' => $id,
|
||||
'request' => $request
|
||||
]);
|
||||
|
||||
$ndeMatrices = NdeMatrix::where("id", $id)->get();
|
||||
|
||||
Log::debug("NDE Matrix kayıtları çekildi", [
|
||||
'matrix_count' => $ndeMatrices->count(),
|
||||
'matrix_examples' => $ndeMatrices->take(2)->toArray()
|
||||
]);
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach($ndeMatrices as $ndeMatrix) {
|
||||
|
||||
$data = [
|
||||
'vt_scope' => 100,
|
||||
'rt_scope' => $ndeMatrix->rt,
|
||||
'ut_scope' => $ndeMatrix->ut,
|
||||
'mt_scope' => $ndeMatrix->mt,
|
||||
'pt_scope' => $ndeMatrix->pt,
|
||||
'pmi_scope' => $ndeMatrix->pmi,
|
||||
'ht_scope' => $ndeMatrix->ht,
|
||||
'pwht' => $ndeMatrix->pwht_field,
|
||||
'ferrite_scope' => $ndeMatrix->fn,
|
||||
'ndt_percent' => $ndeMatrix->ndt,
|
||||
'operating_temperature_s' => $ndeMatrix->operation_temp,
|
||||
'operating_pressure_mpa' => $ndeMatrix->operations_pressure_kg,
|
||||
//'piping_class' => $ndeMatrix->piping_class_according_to_gost,
|
||||
'fluid_group' => $ndeMatrix->piping_group,
|
||||
'main_material' => $ndeMatrix->material,
|
||||
// 'service_category' => $ndeMatrix->piping_group,
|
||||
'updated_at' => simdi()
|
||||
];
|
||||
|
||||
Log::debug("WeldLog güncelleme verisi hazırlanıyor", [
|
||||
'line_number' => $ndeMatrix->line,
|
||||
'type_of_joint' => $ndeMatrix->type_of_joint,
|
||||
'update_data' => $data
|
||||
]);
|
||||
|
||||
$result = db("weld_logs")
|
||||
->where("line_number", $ndeMatrix->line)
|
||||
->where("type_of_welds", $ndeMatrix->type_of_joint)
|
||||
->update($data);
|
||||
|
||||
Log::debug("WeldLog güncelleme sonucu", [
|
||||
'line_number' => $ndeMatrix->line,
|
||||
'type_of_joint' => $ndeMatrix->type_of_joint,
|
||||
'guncellenen_kayit_sayisi' => $result
|
||||
]);
|
||||
|
||||
// NDT Log Tablolarını Senkronize Et (Control Standart & Naks Technology)
|
||||
$testTypes = log_test_types();
|
||||
foreach ($testTypes as $key => $tableName) {
|
||||
// Tablolar migration ile güncellendiği için direct update atıyoruz
|
||||
// line_number eşleşmesi üzerinden matrix standartlarını loglara basar
|
||||
db($tableName)
|
||||
->where("line_number", $ndeMatrix->line)
|
||||
->where("type_of_welds", $ndeMatrix->type_of_joint)
|
||||
->update([
|
||||
'control_standart' => $ndeMatrix->control_standart,
|
||||
]);
|
||||
}
|
||||
|
||||
$count += $result;
|
||||
}
|
||||
|
||||
$ndeMatrices = DB::table('nde_matrices')
|
||||
->join('weld_logs', function($join) {
|
||||
$join->on('nde_matrices.line', '=', 'weld_logs.line_number')
|
||||
->on('nde_matrices.design_area', '=', 'weld_logs.design_area');
|
||||
})
|
||||
->whereNull('nde_matrices.project'); // project sütunu boş olanları bul
|
||||
|
||||
$ndeMatrices = $ndeMatrices
|
||||
->update([
|
||||
'nde_matrices.project' => DB::raw('weld_logs.project') // weld_logs tablosundaki project değeri ile güncelle
|
||||
]);
|
||||
|
||||
Log::debug("NDE Matrix güncelleme işlemi tamamlandı", [
|
||||
'toplam_guncellenen_kayit' => $count
|
||||
]);
|
||||
dump("WeldLog updated rows: $count");
|
||||
|
||||
// Request NDT Cache tetiklemesi
|
||||
if(function_exists('dispatchCacheBladeViews')) {
|
||||
dispatchCacheBladeViews([
|
||||
[
|
||||
'view' => 'admin-ajax.request-ndt-no-cache',
|
||||
'cache' => 'request-ndt'
|
||||
]
|
||||
]);
|
||||
Log::info("NDE Matrix update triggered request-ndt cache update.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user