592 lines
23 KiB
PHP
592 lines
23 KiB
PHP
<?php
|
||
use App\Models\TestPackage;
|
||
use App\Models\PunchList;
|
||
use App\Models\TestPackBaseStatus;
|
||
use Illuminate\Support\Facades\Log;
|
||
$cachePrefix = 'sync-from-weldlog-to-test-pack';
|
||
$weldLogs = db("weld_logs")->orderBy("test_package_no", "DESC");
|
||
|
||
if(isset($id))
|
||
{
|
||
$weldLogs = $weldLogs->where("id", $id);
|
||
}
|
||
|
||
if(isset($test_package_no))
|
||
{
|
||
Log::info("specitif test_package_no run: " . $test_package_no);
|
||
$weldLogs = $weldLogs->where("test_package_no", $test_package_no);
|
||
}
|
||
|
||
|
||
$weldLogs = $weldLogs->get();
|
||
$repairLogs = db("repair_logs");
|
||
if(isset($test_package_no))
|
||
{
|
||
$repairLogs = $repairLogs->where("test_package_no", $test_package_no);
|
||
}
|
||
$repairLogs = $repairLogs->get();
|
||
$supports = db("supports");
|
||
$supports = $supports->get();
|
||
|
||
$punchLists = db("punch_lists");
|
||
if(isset($test_package_no))
|
||
{
|
||
$punchLists = $punchLists->where("test_package", $test_package_no);
|
||
}
|
||
$punchLists = $punchLists->get();
|
||
|
||
$logTypes = array_keys(log_test_types());
|
||
$repairDatas = [];
|
||
|
||
if(!isset($commitSize))
|
||
{
|
||
$commitSize = $weldLogs->count();
|
||
}
|
||
|
||
foreach($repairLogs AS $repairLog)
|
||
{
|
||
if(!isset($repairDatas[$repairLog->iso_number]))
|
||
$repairDatas[$repairLog->iso_number] = 0;
|
||
|
||
if($repairLog->repair_status == "Not Done" || trim($repairLog->repair_status) == "")
|
||
{
|
||
$repairDatas[$repairLog->iso_number]++;
|
||
}
|
||
}
|
||
|
||
$isoToTP = db("weld_logs")->select('test_package_no', 'line_number');
|
||
if(isset($test_package_no))
|
||
{
|
||
$isoToTP = $isoToTP->where("test_package_no", $test_package_no);
|
||
}
|
||
$isoToTP = $isoToTP ->pluck('test_package_no', 'line_number');
|
||
|
||
$supportStats = [];
|
||
$supportStatsTP = [];
|
||
|
||
foreach($supports AS $support)
|
||
{
|
||
$tpNo = @$isoToTP[$support->line_number];
|
||
|
||
if(!isset($supportStatsTP[$tpNo]['support_remaining']))
|
||
{
|
||
$supportStatsTP[$tpNo]['support_remaining'] = 0;
|
||
$supportStatsTP[$tpNo]['welded_support_quantity'] = 0;
|
||
$supportStatsTP[$tpNo]['support_progress'] = 0;
|
||
}
|
||
|
||
if(!isset($supportStats[$support->line_number]['support_remaining']))
|
||
$supportStats[$support->line_number]['support_remaining'] = 0;
|
||
|
||
if(!isset($supportStats[$support->line_number]['welded_support_quantity']))
|
||
$supportStats[$support->line_number]['welded_support_quantity'] = 0;
|
||
|
||
if(!isset($supportStats[$support->line_number]['support_progress']))
|
||
$supportStats[$support->line_number]['support_progress'] = 0;
|
||
|
||
if(!rejected_date($support->weld_or_assembled_date) && $support->erection_type == "Weld")
|
||
{
|
||
$supportStats[$support->line_number]['welded_support_quantity']+= $support->quantity;
|
||
$supportStatsTP[$tpNo]['welded_support_quantity']+= $support->quantity;
|
||
} else {
|
||
$supportStats[$support->line_number]['support_remaining']+= $support->quantity;
|
||
$supportStatsTP[$tpNo]['support_remaining']+= $support->quantity;
|
||
}
|
||
|
||
if($supportStats[$support->line_number]['welded_support_quantity'] > 0) {
|
||
$supportStats[$support->line_number]['support_progress'] =
|
||
100 - ($supportStats[$support->line_number]['support_remaining'] * 100) /
|
||
($supportStats[$support->line_number]['welded_support_quantity'] + $supportStats[$support->line_number]['support_remaining']);
|
||
} else {
|
||
$supportStats[$support->line_number]['support_progress'] = 0; // Eğer welded_support_quantity sıfırsa
|
||
}
|
||
|
||
if($supportStatsTP[$tpNo]['welded_support_quantity'] > 0) {
|
||
$supportStatsTP[$tpNo]['support_progress'] =
|
||
100 - ($supportStatsTP[$tpNo]['support_remaining'] * 100) /
|
||
($supportStatsTP[$tpNo]['welded_support_quantity'] + $supportStatsTP[$tpNo]['support_remaining']);
|
||
} else {
|
||
$supportStatsTP[$tpNo]['support_progress'] = 0; // Eğer welded_support_quantity sıfırsa
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
$testTypeToMedium = [
|
||
'PNEUMATIC' => 'Air',
|
||
'HYDRAULIC' => 'Water',
|
||
'VISUAL' => '-',
|
||
'ACUISTIC' => '-',
|
||
];
|
||
|
||
Log::debug("$cachePrefix start " . simdi());
|
||
|
||
TestPackage::where(function($query) {
|
||
$query->where("test_package_number", "")->orWhereNull("test_package_number");
|
||
})->where(function($query) {
|
||
$query->where("is_manual", 0)->orWhereNull("is_manual");
|
||
})->delete();
|
||
|
||
TestPackBaseStatus::where(function($query) {
|
||
$query->where("test_package_no", "")->orWhereNull("test_package_no");
|
||
})->where(function($query) {
|
||
$query->where("is_manual", 0)->orWhereNull("is_manual");
|
||
})->delete();
|
||
|
||
$count = 0;
|
||
$say = 0;
|
||
|
||
|
||
DB::beginTransaction();
|
||
try {
|
||
|
||
|
||
|
||
$stats = [];
|
||
$quantity_of_iso = [];
|
||
$punchListNumbers = [];
|
||
foreach($punchLists AS $punchList) {
|
||
$drawingNo = $punchList->line_isometric_no;
|
||
|
||
if(!isset($stats[$drawingNo][$punchList->test_package]['punch_a_quantity']))
|
||
$stats[$drawingNo][$punchList->test_package]['punch_a_quantity'] = 0;
|
||
|
||
if(!isset($stats[$drawingNo][$punchList->test_package]['punch_b_quantity']))
|
||
$stats[$drawingNo][$punchList->test_package]['punch_b_quantity'] = 0;
|
||
|
||
if(!isset($stats[$drawingNo][$punchList->test_package]['punch_c_quantity']))
|
||
$stats[$drawingNo][$punchList->test_package]['punch_c_quantity'] = 0;
|
||
|
||
if(!isset($punchListNumbers[$punchList->test_package]))
|
||
$punchListNumbers[$punchList->test_package] = [];
|
||
|
||
if(!in_array($punchList->punch_list_no, $punchListNumbers[$punchList->test_package]))
|
||
$punchListNumbers[$punchList->test_package][] = $punchList->punch_list_no;
|
||
|
||
if(!isset($stats[$punchList->test_package]['punch_a_open_quantity']))
|
||
$stats[$punchList->test_package]['punch_a_open_quantity'] = 0;
|
||
|
||
if(!isset($stats[$punchList->test_package]['punch_b_open_quantity']))
|
||
$stats[$punchList->test_package]['punch_b_open_quantity'] = 0;
|
||
|
||
if(!isset($stats[$punchList->test_package]['punch_c_open_quantity']))
|
||
$stats[$punchList->test_package]['punch_c_open_quantity'] = 0;
|
||
|
||
|
||
if($punchList->category == "A") {
|
||
if($punchList->status == "Open") {
|
||
$stats[$punchList->test_package]['punch_a_open_quantity']++;
|
||
}
|
||
|
||
$stats[$drawingNo][$punchList->test_package]['punch_a_quantity']++;
|
||
}
|
||
|
||
|
||
if($punchList->category == "B") {
|
||
if($punchList->status == "Open") {
|
||
$stats[$punchList->test_package]['punch_b_open_quantity']++;
|
||
}
|
||
|
||
$stats[$drawingNo][$punchList->test_package]['punch_b_quantity']++;
|
||
}
|
||
|
||
|
||
if($punchList->category == "C") {
|
||
if($punchList->status == "Open") {
|
||
$stats[$punchList->test_package]['punch_c_open_quantity']++;
|
||
}
|
||
$stats[$drawingNo][$punchList->test_package]['punch_c_quantity']++;
|
||
|
||
|
||
}
|
||
|
||
$stats[$punchList->test_package]['found_date'] = $punchList?->found_date ?? "";
|
||
$stats[$punchList->test_package]['punch_list'] = $punchList?->punch_list ?? "";
|
||
|
||
}
|
||
|
||
$addedSheet = [];
|
||
|
||
foreach($weldLogs AS $weldLog) {
|
||
$jointNo = $weldLog->no_of_the_joint_as_per_as_built_survey;
|
||
|
||
$goldenJoints = 0;
|
||
$goldenJoints2 = 0;
|
||
|
||
|
||
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['goldenJoints']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['goldenJoints'] = 0;
|
||
|
||
if(!isset($quantity_of_iso[$weldLog->test_package_no]['total_qty']))
|
||
$quantity_of_iso[$weldLog->test_package_no]['total_qty'] = 0;
|
||
|
||
if(!isset($addedSheet[$weldLog->test_package_no]))
|
||
$addedSheet[$weldLog->test_package_no] = [];
|
||
|
||
if(!in_array($weldLog->quantity_of_iso, $addedSheet[$weldLog->test_package_no])) {
|
||
$quantity_of_iso[$weldLog->test_package_no]['total_qty']++;
|
||
$addedSheet[$weldLog->test_package_no][] = $weldLog->quantity_of_iso;
|
||
}
|
||
|
||
|
||
|
||
if(!isset($quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_qty']))
|
||
$quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_qty'] = 0;
|
||
|
||
if(!isset($addedSheet[$weldLog->iso_number][$weldLog->test_package_no]))
|
||
$addedSheet[$weldLog->iso_number][$weldLog->test_package_no] = [];
|
||
|
||
if(!in_array($weldLog->quantity_of_iso, $addedSheet[$weldLog->iso_number][$weldLog->test_package_no])) {
|
||
$quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_qty']++;
|
||
$addedSheet[$weldLog->iso_number][$weldLog->test_package_no][] = $weldLog->quantity_of_iso;
|
||
}
|
||
|
||
|
||
$backlogs = [
|
||
'rt_backlog',
|
||
'ut_backlog',
|
||
'mt_backlog',
|
||
'pmi_backlog',
|
||
'vt_backlog',
|
||
'pt_backlog',
|
||
'ferrit_backlog',
|
||
'pwht_backlog',
|
||
'total_backlog',
|
||
];
|
||
|
||
foreach($backlogs AS $backlog)
|
||
{
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no][$backlog]))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no][$backlog] = 0;
|
||
|
||
if(!isset($stats[$weldLog->test_package_no][$backlog]))
|
||
$stats[$weldLog->test_package_no][$backlog] = 0;
|
||
|
||
}
|
||
|
||
if(!isset($stats[$weldLog->test_package_no]['total_backlog']))
|
||
$stats[$weldLog->test_package_no]['total_backlog'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->test_package_no]['goldenJoints']))
|
||
$stats[$weldLog->test_package_no]['goldenJoints'] = 0;
|
||
|
||
if(strpos(strtoupper($jointNo), "GJ") !== false) {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['goldenJoints']++;
|
||
$stats[$weldLog->test_package_no]['goldenJoints']++;
|
||
}
|
||
if(!isset($quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_iso_quantity']))
|
||
$quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_iso_quantity'] = 0;
|
||
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['rt_ut_status']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['rt_ut_status'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['remaining_wdi']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['remaining_wdi'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['total_wdi']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_wdi'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['total_complated_wdi']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_complated_wdi'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['total_joint_qty']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_joint_qty'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['total_welded_joint_qty']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_welded_joint_qty'] = 0;
|
||
|
||
if(!isset($stats[$weldLog->iso_number][$weldLog->test_package_no]['welded_support_quantity']))
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['welded_support_quantity'] = 0;
|
||
|
||
foreach($logTypes AS $logType) {
|
||
$weldLogArray = (Array) $weldLog;
|
||
$stats[$weldLog->test_package_no]['total_backlog'] += (float) $weldLogArray[$logType . "_scope"];
|
||
}
|
||
|
||
|
||
if(!isset($addedSheet[$weldLog->iso_number][$weldLog->test_package_no]['total_iso']))
|
||
$addedSheet[$weldLog->iso_number][$weldLog->test_package_no]['total_iso'] = [];
|
||
|
||
if(!in_array($weldLog->quantity_of_iso, $addedSheet[$weldLog->iso_number][$weldLog->test_package_no]['total_iso']))
|
||
{
|
||
$quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_iso_quantity']++;
|
||
$addedSheet[$weldLog->iso_number][$weldLog->test_package_no]['total_iso'][] = $weldLog->quantity_of_iso;
|
||
}
|
||
|
||
|
||
|
||
//welded_support_quantity
|
||
|
||
|
||
if(rejected_date($weldLog->welding_date)) {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['remaining_wdi'] += (float) $weldLog->nps_1;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->rt_test_date)) {
|
||
// $stats[$weldLog->iso_number][$weldLog->test_package_no]['rt_ut_done']++;
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['rt_backlog']++;
|
||
$stats[$weldLog->test_package_no]['rt_backlog']++;
|
||
|
||
}
|
||
|
||
|
||
|
||
if(!rejected_date($weldLog->ut_test_date)) {
|
||
// $stats[$weldLog->iso_number][$weldLog->test_package_no]['rt_ut_done']++;
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['ut_backlog']++;
|
||
$stats[$weldLog->test_package_no]['ut_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->pwht_test_date)) {
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['pwht_backlog']++;
|
||
$stats[$weldLog->test_package_no]['pwht_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->pmi_test_date)) {
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['pmi_backlog']++;
|
||
$stats[$weldLog->test_package_no]['pmi_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->ferrite_test_date)) {
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['ferrit_backlog']++;
|
||
$stats[$weldLog->test_package_no]['ferrit_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->pt_test_date)) {
|
||
//$stats[$weldLog->iso_number][$weldLog->test_package_no]['mt_pt_done']++;
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['pt_backlog']++;
|
||
$stats[$weldLog->test_package_no]['pt_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->mt_test_date)) {
|
||
//$stats[$weldLog->iso_number][$weldLog->test_package_no]['mt_pt_done']++;
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['mt_backlog']++;
|
||
$stats[$weldLog->test_package_no]['mt_backlog']++;
|
||
}
|
||
|
||
if(!rejected_date($weldLog->vt_test_date)) {
|
||
//$stats[$weldLog->iso_number][$weldLog->test_package_no]['mt_pt_done']++;
|
||
|
||
} else {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['vt_backlog']++;
|
||
$stats[$weldLog->test_package_no]['vt_backlog']++;
|
||
}
|
||
|
||
|
||
|
||
if(!rejected_date($weldLog->welding_date)) {
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_complated_wdi'] += (float) $weldLog->nps_1;
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_welded_joint_qty']++;
|
||
}
|
||
|
||
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_wdi'] += (float) $weldLog->nps_1;
|
||
|
||
$stats[$weldLog->iso_number][$weldLog->test_package_no]['total_joint_qty'] ++;
|
||
|
||
|
||
}
|
||
|
||
|
||
$ndtCalculationParams = [
|
||
'type' => 'test_packs',
|
||
];
|
||
|
||
if(isset($test_package_no)) {
|
||
$ndtCalculationParams['test_package_no'] = $test_package_no;
|
||
}
|
||
|
||
$ndtCalculation = j(view('admin-ajax.ndt-calculation-no-cache', $ndtCalculationParams)->render());
|
||
|
||
$tpStats = $ndtCalculation['tpStats'];
|
||
$tpIsoStats = $ndtCalculation['tpISOStats'];
|
||
|
||
|
||
foreach($weldLogs AS $weldLog) {
|
||
//if($weldLog->test_package_no != "") {
|
||
|
||
try {
|
||
$punchListData = implode(",", $punchListNumbers[$weldLog->test_package_no]);
|
||
} catch (\Throwable $th) {
|
||
$punchListData = "";
|
||
}
|
||
|
||
$thisStats = @$stats[$weldLog->test_package_no];
|
||
$thisTpStats = @$tpStats[$weldLog->test_package_no];
|
||
$thisTpISOStats = @$tpIsoStats[$weldLog->test_package_no][$weldLog->iso_number];
|
||
$thisSupportStats = @$supportStatsTP[$weldLog->test_package_no];
|
||
|
||
$thisTotalBacklog =
|
||
(@$thisTpStats['vt'] ?? 0) +
|
||
(@$thisTpStats['ut'] ?? 0) +
|
||
(@$thisTpStats['mt'] ?? 0) +
|
||
(@$thisTpStats['pmi'] ?? 0) +
|
||
(@$thisTpStats['pt'] ?? 0) +
|
||
(@$thisTpStats['rt'] ?? 0) +
|
||
(@$thisTpStats['pwht'] ?? 0) +
|
||
(@$thisTpStats['ferrite'] ?? 0);
|
||
|
||
$testPackageData = [
|
||
'unit' => $weldLog->design_area,
|
||
'test_package_number' => $weldLog->test_package_no,
|
||
'discipline' => $weldLog->piping_type,
|
||
'circuit_number' => $weldLog->circuit_number,
|
||
'p_id' => $weldLog->p_id,
|
||
'iso_quantity' => $quantity_of_iso[$weldLog->test_package_no]['total_qty'],//$weldLog->quantity_of_iso, //burada qty toplam sayı gelmeli
|
||
// 'subcontractor' => $weldLog->ste_subcontractor,
|
||
'test_type' => $weldLog->type_of_test,
|
||
'test_medium' => @$testTypeToMedium[strtoupper($weldLog->type_of_test)],
|
||
'test_pressure' => $weldLog->test_pressure,
|
||
'golden_joints' => @$stats[$weldLog->test_package_no]['goldenJoints'],
|
||
'walkdown_date' => @$stats[$weldLog->test_package_no]['found_date'],
|
||
'punch_list' => $punchListData,
|
||
|
||
'welded_support_quantity' => @$thisSupportStats['welded_support_quantity'],
|
||
'support_remaining' => @$thisSupportStats['support_remaining'],
|
||
'support_progress' => @$thisSupportStats['support_progress'],
|
||
|
||
'a_punch_point_open' => @$stats[$weldLog->test_package_no]['punch_a_open_quantity'],
|
||
'b_punch_point_open' => @$stats[$weldLog->test_package_no]['punch_b_open_quantity'],
|
||
'c_punch_point_open' => @$stats[$weldLog->test_package_no]['punch_c_open_quantity'],
|
||
|
||
'vt_backlog' => @$thisTpStats['vt'],
|
||
'ut_backlog' => @$thisTpStats['ut'],
|
||
'mt_backlog' => @$thisTpStats['mt'],
|
||
'pmi_backlog' => @$thisTpStats['pmi'],
|
||
'pt_backlog' => @$thisTpStats['pt'],
|
||
'rt_backlog' => @$thisTpStats['rt'],
|
||
'pwht_backlog' => @$thisTpStats['pwht'],
|
||
'ferrit_backlog' => @$thisTpStats['ferrite'],
|
||
'ndt_status' => @$thisTotalBacklog == 0 ? "Completed" : "Not Completed",
|
||
];
|
||
|
||
$thisStats = @$stats[$weldLog->iso_number][$weldLog->test_package_no];
|
||
$thisSupportStats = @$supportStats[$weldLog->iso_number];
|
||
|
||
try {
|
||
$pipeProgress = round($thisStats['total_complated_wdi'] * 100 / $thisStats['total_wdi'], 2);
|
||
} catch (\Throwable $th) {
|
||
$pipeProgress = 0;
|
||
}
|
||
|
||
try {
|
||
$repairQty = $repairDatas[$weldLog->iso_number];
|
||
} catch (\Throwable $th) {
|
||
$repairQty = 0;
|
||
}
|
||
|
||
|
||
$testPackBaseStatusData = [
|
||
'area' => $weldLog->project,
|
||
'drawing_no' => $weldLog->iso_number,
|
||
'test_package_no' => $weldLog->test_package_no,
|
||
'discipline' => $weldLog->piping_type,
|
||
'iso_qty' => $quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_qty'], //burada qty toplam sayı gelmeli
|
||
// 'subcontractor' => $weldLog->ste_subcontractor,
|
||
'test_type' => $weldLog->type_of_test,
|
||
'test_medium' => @$testTypeToMedium[strtoupper($weldLog->type_of_test)],
|
||
'test_pressure_mpa' => $weldLog->test_pressure,
|
||
'tp_status' => '', // bu data test pack base stat. girilecek
|
||
'total_iso_quantity' => $quantity_of_iso[$weldLog->iso_number][$weldLog->test_package_no]['total_iso_quantity'],
|
||
// 'welding_status' => '',
|
||
'remaining_wdi' => $thisStats['remaining_wdi'],
|
||
'total_wdi' => $thisStats['total_wdi'],
|
||
'total_complated_wdi' => $thisStats['total_complated_wdi'],
|
||
'pipe_progress' => $pipeProgress,
|
||
'total_joint_qty' => $thisStats['total_joint_qty'],
|
||
'total_welded_joint_qty' => $thisStats['total_welded_joint_qty'],
|
||
'welded_support_quantity' => @$thisSupportStats['welded_support_quantity'],
|
||
'support_remaining' => @$thisSupportStats['support_remaining'],
|
||
'support_progress' => @$thisSupportStats['support_progress'],
|
||
'punch_a_quantity' => @$thisStats['punch_a_quantity'], //punch listteki a lar
|
||
'punch_b_quantity' => @$thisStats['punch_b_quantity'],
|
||
'punch_c_quantity' => @$thisStats['punch_c_quantity'],
|
||
// 'repair_qty' => $repairQty,
|
||
'rt_ut_status' => $thisStats['rt_ut_status'],
|
||
'rt_backlog' => @$thisTpISOStats['rt'],
|
||
'ut_backlog' => @$thisTpISOStats['ut'],
|
||
'mt_backlog' => @$thisTpISOStats['mt'],
|
||
'pmi_backlog' => @$thisTpISOStats['pmi'],
|
||
'vt_backlog' => @$thisTpISOStats['vt'],
|
||
'pt_backlog' => @$thisTpISOStats['pt'],
|
||
'pwht_backlog' => @$thisTpISOStats['pwht'],
|
||
'ferrit_backlog' => @$thisTpISOStats['ferrite'],
|
||
];
|
||
|
||
|
||
$testPackWhereData = [
|
||
'test_package_number' => $weldLog->test_package_no
|
||
];
|
||
|
||
$testPackBaseStatusWhereData = [
|
||
'test_package_no' => $weldLog->test_package_no,
|
||
'drawing_no' => $weldLog->iso_number,
|
||
];
|
||
|
||
if($weldLog->test_package_no != "") {
|
||
if(!is_null($weldLog->test_package_no)) {
|
||
|
||
/*
|
||
TestPackBaseStatus::where([
|
||
'test_package_no' => "",
|
||
'drawing_no' => $weldLog->iso_number,
|
||
])->delete();
|
||
|
||
TestPackage::where([
|
||
'test_package_number' => "",
|
||
])->delete();
|
||
*/
|
||
}
|
||
|
||
}
|
||
|
||
|
||
TestPackage::updateOrCreate($testPackWhereData, $testPackageData);
|
||
TestPackBaseStatus::updateOrCreate($testPackBaseStatusWhereData, $testPackBaseStatusData);
|
||
|
||
if($say == $commitSize) {
|
||
|
||
DB::commit();
|
||
DB::beginTransaction();
|
||
$say = 0;
|
||
}
|
||
$say++;
|
||
|
||
$count++;
|
||
// }
|
||
|
||
}
|
||
|
||
DB::commit();
|
||
|
||
//dump("$count Data has been sync from WeldLog ==> Test Packages");
|
||
|
||
Log::debug("$count Data has been sync from WeldLog ==> Test Packages");
|
||
Log::debug("$cachePrefix finish " . simdi());
|
||
|
||
} catch (\Throwable $th) {
|
||
DB::rollback();
|
||
dump($th);
|
||
Log::error($th->getMessage());
|
||
}
|
||
|
||
|
||
|
||
?>
|