ikinci temizlik tamamlandı
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
use App\Models\NdeMatrix;
|
||||
$lastIdPrefix = "weld-logs-empty-sync";
|
||||
$lastId = 0;
|
||||
|
||||
if(Cache::has($lastIdPrefix)) {
|
||||
$lastId = Cache::get($lastIdPrefix);
|
||||
}
|
||||
|
||||
//dump("$lastIdPrefix $lastId");
|
||||
|
||||
Log::debug("$lastIdPrefix start " . simdi());
|
||||
$ndeMatrixs = NdeMatrix::whereDate("updated_at", ">=", $oneMinuteAgo)->get();
|
||||
|
||||
|
||||
$ndeDatas = [];
|
||||
|
||||
foreach($ndeMatrixs AS $ndeMatrix) {
|
||||
$ndeDatas[$ndeMatrix->line][$ndeMatrix->type_of_joint] = [
|
||||
'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,
|
||||
'ferrite_scope' => $ndeMatrix->fn,
|
||||
'ndt_percent' => $ndeMatrix->ndt,
|
||||
];
|
||||
}
|
||||
DB::beginTransaction();
|
||||
$weldLogs = db("weld_logs")->whereNull("ndt_percent")->groupBy("line_number", "type_of_welds")->get();
|
||||
$count = 0;
|
||||
$say = 0;
|
||||
try {
|
||||
foreach($weldLogs AS $weldLog) {
|
||||
|
||||
if(isset($ndeDatas[$weldLog->line_number][$weldLog->type_of_welds])) {
|
||||
$updateData = $ndeDatas[$weldLog->line_number][$weldLog->type_of_welds];
|
||||
db("weld_logs")
|
||||
->where("line_number", $weldLog->line_number)
|
||||
->where("type_of_welds", $weldLog->type_of_welds)
|
||||
->update($updateData);
|
||||
$count++;
|
||||
|
||||
/*
|
||||
if($say == $commitSize) {
|
||||
DB::commit();
|
||||
DB::beginTransaction();
|
||||
$say = 0;
|
||||
}
|
||||
*/
|
||||
$say++;
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
//dump($th);
|
||||
DB::rollback();
|
||||
}
|
||||
|
||||
Log::debug("$lastIdPrefix finish " . simdi());
|
||||
//dump("$count weldlog data is updated");
|
||||
?>
|
||||
Reference in New Issue
Block a user