Merge pull request 'Updated pump testing entry get api function with validation' (#938) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Reviewed-on: #938
This commit was merged in pull request #938.
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Models\PumpTestingEntry;
|
|||||||
use App\Models\PumpTestingMaster;
|
use App\Models\PumpTestingMaster;
|
||||||
use App\Models\TestingPanelReading;
|
use App\Models\TestingPanelReading;
|
||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
@@ -1287,7 +1288,7 @@ class TestingPanelController extends Controller
|
|||||||
if (! $plant) {
|
if (! $plant) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Plant not found!',
|
'status_description' => "Plant code : '$plantCode' not found!",
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1299,7 +1300,7 @@ class TestingPanelController extends Controller
|
|||||||
if (! $item) {
|
if (! $item) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Pump code not found in item master table!',
|
'status_description' => "Pump code : '$pumpCode' not found in item master table!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1308,7 +1309,7 @@ class TestingPanelController extends Controller
|
|||||||
if (! $item) {
|
if (! $item) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Pump code not found in item master table for the plant : '$plantName'!",
|
'status_description' => "Pump code : '$pumpCode' not found in item master table for the plant : '$plantName'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1321,7 +1322,7 @@ class TestingPanelController extends Controller
|
|||||||
if (! $pumpTestingMaster) {
|
if (! $pumpTestingMaster) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Pump code not found in pump testing master table!',
|
'status_description' => "Pump code : '$pumpCode' not found in pump testing master table!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1330,151 +1331,67 @@ class TestingPanelController extends Controller
|
|||||||
if (! $pumpTestingMaster) {
|
if (! $pumpTestingMaster) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Pump code not found in pump testing master table for the plant : '$plantName'!",
|
'status_description' => "Pump code : '$pumpCode' not found in pump testing master table for the plant : '$plantName'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pumpMasterId = $pumpTestingMaster->id;
|
$pumpMasterId = $pumpTestingMaster->id;
|
||||||
|
|
||||||
$pumpTestingEntry = PumpTestingEntry::where('pump_testing_master_id', $pumpMasterId)->first();
|
$pumpTestingEntry = PumpTestingEntry::where('pump_serial_number', $pumpSerial)->first();
|
||||||
|
|
||||||
if (! $pumpTestingEntry) {
|
if (! $pumpTestingEntry) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Pump code not found in pump testing entry table!',
|
'status_description' => "Pump serial number : '$pumpSerial' not found in pump testing entry table!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pumpTestingEntry = PumpTestingEntry::where('plant_id', $plantId)->where('pump_testing_master_id', $pumpMasterId)->first();
|
$pumpTestingEntry = PumpTestingEntry::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->first();
|
||||||
|
|
||||||
if (! $pumpTestingEntry) {
|
if (! $pumpTestingEntry) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Pump code not found in pump testing entry table for the plant : '$plantName'!",
|
'status_description' => "Pump serial number : '$pumpSerial' not found in pump testing entry table for the plant : '$plantName'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entries = $result['pump_entries'] ?? [];
|
$pumpTestingEntry = PumpTestingEntry::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->where('pump_testing_master_id', $pumpMasterId)->first();
|
||||||
|
|
||||||
if (empty($entries)) {
|
if (! $pumpTestingEntry) {
|
||||||
$entries = [
|
return response()->json([
|
||||||
[
|
'status_code' => 'ERROR',
|
||||||
'sl_no' => '1',
|
'status_description' => "Pump serial number : '$pumpSerial' with Pump code : '$pumpCode' not found in pump testing entry table for the plant : '$plantName'!",
|
||||||
'voltage' => '415',
|
], 404);
|
||||||
'frequency' => '50.02',
|
|
||||||
'speed' => '2976',
|
|
||||||
'head' => '5',
|
|
||||||
'flow_reading' => '18.75',
|
|
||||||
'current' => '61.8',
|
|
||||||
'watt' => '40730',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '2',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.05',
|
|
||||||
'speed' => '2976',
|
|
||||||
'head' => '100',
|
|
||||||
'flow_reading' => '18.71',
|
|
||||||
'current' => '72.7',
|
|
||||||
'watt' => '47100',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '3',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.04',
|
|
||||||
'speed' => '2975',
|
|
||||||
'head' => '150',
|
|
||||||
'flow_reading' => '17.65',
|
|
||||||
'current' => '76.3',
|
|
||||||
'watt' => '48000',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '4',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.02',
|
|
||||||
'speed' => '2974',
|
|
||||||
'head' => '200',
|
|
||||||
'flow_reading' => '15.65',
|
|
||||||
'current' => '74',
|
|
||||||
'watt' => '47760',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '5',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.04',
|
|
||||||
'speed' => '2977',
|
|
||||||
'head' => '250',
|
|
||||||
'flow_reading' => '12.51',
|
|
||||||
'current' => '68.2',
|
|
||||||
'watt' => '45240',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '6',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50',
|
|
||||||
'speed' => '2979',
|
|
||||||
'head' => '270',
|
|
||||||
'flow_reading' => '11.53',
|
|
||||||
'current' => '65.5',
|
|
||||||
'watt' => '43050',
|
|
||||||
'created_by' => 'test',
|
|
||||||
'created_at' => '2026-07-16 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '7',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.05',
|
|
||||||
'speed' => '2983',
|
|
||||||
'head' => '300',
|
|
||||||
'flow_reading' => '8.65',
|
|
||||||
'current' => '57.4',
|
|
||||||
'watt' => '37460',
|
|
||||||
'created_by' => 'Dhanabalan S',
|
|
||||||
'created_at' => '2026-07-17 00:00:00',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'sl_no' => '8',
|
|
||||||
'voltage' => '415',
|
|
||||||
'frequency' => '50.03',
|
|
||||||
'speed' => '2990',
|
|
||||||
'head' => '325',
|
|
||||||
'flow_reading' => '0',
|
|
||||||
'current' => '35.8',
|
|
||||||
'watt' => '21300',
|
|
||||||
'created_by' => 'Dhanabalan S',
|
|
||||||
'created_at' => '2026-07-17 00:00:00',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pumpTestingEntry = PumpTestingEntry::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->where('pump_testing_master_id', $pumpMasterId)->where('tested_type', $testedType)->first();
|
||||||
|
|
||||||
|
if (! $pumpTestingEntry) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Pump serial number : '$pumpSerial' with Tested type : '$testedType' not found in pump testing entry table for the plant : '$plantName'!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pumpTestingEntries = PumpTestingEntry::where('plant_id', $plantId)->where('pump_serial_number', $pumpSerial)->where('pump_testing_master_id', $pumpMasterId)->where('tested_type', $testedType)->get()->toArray();
|
||||||
|
|
||||||
$output = [
|
$output = [
|
||||||
'tested_date' => $result['tested_date'] ?? '2026-07-16',
|
'tested_date' => $pumpTestingEntry->tested_date ?? '', // $result['tested_date'] ?? '2026-07-16'
|
||||||
// 'tested_type' => $result['tested_type'] ?? 'Pump Performance Test',
|
'correction_head' => $pumpTestingEntry->correction_head ?? '', // $result['correction_head'] ?? '5.0',
|
||||||
'correction_head' => $result['correction_head'] ?? '5.0',
|
|
||||||
'pump_entries' => array_map(function ($entry) {
|
'pump_entries' => array_map(function ($entry) {
|
||||||
return [
|
return [
|
||||||
'sl_no' => $entry['sl_no'] ?? '',
|
'sl_no' => $entry['sl_no'] ?? '',
|
||||||
'voltage' => $entry['voltage'] ?? '',
|
'voltage' => $entry['voltage'] ?? '',
|
||||||
'frequency' => $entry['frequency'] ?? '',
|
'frequency' => $entry['frequency'] ?? '',
|
||||||
'speed' => $entry['speed'] ?? '',
|
'speed' => $entry['speed'] ?? '',
|
||||||
'head' => $entry['head'] ?? '',
|
'd_head' => $entry['head'] ?? '',
|
||||||
'flow_reading' => $entry['flow_reading'] ?? '',
|
'flow_reading' => $entry['flow_reading'] ?? '',
|
||||||
'current' => $entry['current'] ?? '',
|
'current' => $entry['current'] ?? '',
|
||||||
'watt' => $entry['watt'] ?? '',
|
'watt' => $entry['watt'] ?? '',
|
||||||
'tested_by' => $entry['created_by'] ?? '',
|
'tested_by' => $entry['created_by'] ?? '',
|
||||||
'created_datetime' => $entry['created_at'] ?? '',
|
'created_datetime' => ! empty($entry['created_at']) ? Carbon::parse($entry['created_at'])->setTimezone('Asia/Kolkata')->format('Y-m-d H:i:s') : '',
|
||||||
];
|
];
|
||||||
}, $entries ?? []),
|
}, $pumpTestingEntries ?? []),
|
||||||
];
|
];
|
||||||
|
|
||||||
return response()->json($output, 200);
|
return response()->json($output, 200);
|
||||||
|
|||||||
Reference in New Issue
Block a user