ranjith-dev #928
@@ -8,6 +8,8 @@ use App\Models\LeakTestReading;
|
||||
use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\PumpTestingEntry;
|
||||
use App\Models\PumpTestingMaster;
|
||||
use App\Models\TestingPanelReading;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -1061,6 +1063,658 @@ class TestingPanelController extends Controller
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
public function get_pump_master(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$pumpCode = $request->header('pump-code');
|
||||
// $description = $item ? $item->description : '';
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
} elseif ($pumpCode == null || $pumpCode == '' || ! $pumpCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($pumpCode) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
$plantName = $plant->name;
|
||||
|
||||
$item = Item::where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in item master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in item master table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$description = $item ? $item->description : '';
|
||||
|
||||
// $category = $item ? $item->category : '';
|
||||
|
||||
$pumpTestingMaster = PumpTestingMaster::where('item_id', $itemId)->first();
|
||||
|
||||
if (! $pumpTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in pump testing master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$pumpTestingMaster = PumpTestingMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $pumpTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in pump testing master table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'pump_type' => ($pumpCode == '123456') ? 'SAMPLE TYPE' : $description,
|
||||
'head' => $pumpTestingMaster->head ?? '',
|
||||
'head_type' => $pumpTestingMaster->head_type ?? '',
|
||||
'discharge' => $pumpTestingMaster->discharge ?? '',
|
||||
'discharge_type' => $pumpTestingMaster->discharge_type ?? '',
|
||||
'motor_efficiency' => $pumpTestingMaster->motor_efficiency ?? '',
|
||||
'pump_efficiency' => $pumpTestingMaster->pump_efficiency ?? '',
|
||||
'speed' => $pumpTestingMaster->speed ?? '',
|
||||
'frequency' => $pumpTestingMaster->frequency ?? '',
|
||||
'i_max' => $pumpTestingMaster->i_max ?? '',
|
||||
'p_input' => $pumpTestingMaster->p_input ?? '',
|
||||
'delivery_size' => $pumpTestingMaster->delivery_size ?? '',
|
||||
'no_of_stages' => $pumpTestingMaster->no_of_stages ?? '',
|
||||
'size' => $pumpTestingMaster->size ?? '',
|
||||
'maximum_head' => $pumpTestingMaster->maximum_head ?? '',
|
||||
'motor_type' => $pumpTestingMaster->motor_type ?? '',
|
||||
'motor_code' => $pumpTestingMaster->motor_code ?? '',
|
||||
'kw_hp' => $pumpTestingMaster->kw_hp ?? '',
|
||||
'connection_type' => $pumpTestingMaster->connection_type ?? '',
|
||||
'voltage' => $pumpTestingMaster->voltage ?? '',
|
||||
'phase' => $pumpTestingMaster->phase ?? '',
|
||||
'oh_minimum' => $pumpTestingMaster->oh_minimum ?? '',
|
||||
'oh_maximum' => $pumpTestingMaster->oh_maximum ?? '',
|
||||
'current_minimum' => $pumpTestingMaster->current_minimum ?? '',
|
||||
'current_maximum' => $pumpTestingMaster->current_maximum ?? '',
|
||||
'class_of_insulation' => $pumpTestingMaster->class_of_insulation ?? '',
|
||||
'testing_code' => $pumpTestingMaster->testing_code ?? '',
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
public function get_pump_entry(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$pumpCode = $request->header('pump-code');
|
||||
$pumpSerial = $request->header('pump-serial-number');
|
||||
$testedType = $request->header('tested-type') ?? 'Pump Performance Test';
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
} elseif ($pumpCode == null || $pumpCode == '' || ! $pumpCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($pumpCode) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
} elseif ($pumpSerial == null || $pumpSerial == '' || ! $pumpSerial) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($pumpSerial) < 9) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should contain minimum 9 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($pumpSerial)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $pumpSerial)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should not begin with '0' or letter!",
|
||||
], 404);
|
||||
} elseif ($testedType == null || $testedType == '' || ! $testedType) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Tested type can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
$plantName = $plant->name;
|
||||
|
||||
$item = Item::where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in item master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in item master table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
// $description = $item ? $item->description : '';
|
||||
|
||||
$pumpTestingMaster = PumpTestingMaster::where('item_id', $itemId)->first();
|
||||
|
||||
if (! $pumpTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in pump testing master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$pumpTestingMaster = PumpTestingMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $pumpTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in pump testing master table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$pumpMasterId = $pumpTestingMaster->id;
|
||||
|
||||
$pumpTestingEntry = PumpTestingEntry::where('pump_testing_master_id', $pumpMasterId)->first();
|
||||
|
||||
if (! $pumpTestingEntry) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in pump testing entry table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$pumpTestingEntry = PumpTestingEntry::where('plant_id', $plantId)->where('pump_testing_master_id', $pumpMasterId)->first();
|
||||
|
||||
if (! $pumpTestingEntry) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in pump testing entry table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entries = $result['pump_entries'] ?? [];
|
||||
|
||||
if (empty($entries)) {
|
||||
$entries = [
|
||||
[
|
||||
'sl_no' => '1',
|
||||
'voltage' => '415',
|
||||
'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',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$output = [
|
||||
'tested_date' => $result['tested_date'] ?? '2026-07-16',
|
||||
// 'tested_type' => $result['tested_type'] ?? 'Pump Performance Test',
|
||||
'correction_head' => $result['correction_head'] ?? '5.0',
|
||||
'pump_entries' => array_map(function ($entry) {
|
||||
return [
|
||||
'sl_no' => $entry['sl_no'] ?? '',
|
||||
'voltage' => $entry['voltage'] ?? '',
|
||||
'frequency' => $entry['frequency'] ?? '',
|
||||
'speed' => $entry['speed'] ?? '',
|
||||
'head' => $entry['head'] ?? '',
|
||||
'flow_reading' => $entry['flow_reading'] ?? '',
|
||||
'current' => $entry['current'] ?? '',
|
||||
'watt' => $entry['watt'] ?? '',
|
||||
'tested_by' => $entry['created_by'] ?? '',
|
||||
'created_datetime' => $entry['created_at'] ?? '',
|
||||
];
|
||||
}, $entries ?? []),
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
public function get_pump_result(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$pumpCode = $request->header('pump-code');
|
||||
$pumpSerial = $request->header('pump-serial-number');
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
} elseif ($pumpCode == null || $pumpCode == '' || ! $pumpCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($pumpCode) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $pumpCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code '{$pumpCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
} elseif ($pumpSerial == null || $pumpSerial == '' || ! $pumpSerial) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($pumpSerial) < 9) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should contain minimum 9 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($pumpSerial)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $pumpSerial)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump serial number '{$pumpSerial}' should not begin with '0' or letter!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
$plantName = $plant->name;
|
||||
|
||||
$item = Item::where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Pump code not found in item master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $pumpCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Pump code not found in item master table for the plant : '$plantName'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$description = $item ? $item->description : '';
|
||||
|
||||
$category = $item ? $item->category : '';
|
||||
|
||||
// $pumpTestingMaster = PumpTestingMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $pumpTestingMaster) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => 'Pump code not found in pump testing master table!',
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
// $pumpTestingMaster = PumpTestingMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $pumpTestingMaster) {
|
||||
// return response()->json([
|
||||
// 'status_code' => 'ERROR',
|
||||
// 'status_description' => "Pump code not found in pump testing master table for the plant : '$plantName'!",
|
||||
// ], 404);
|
||||
// }
|
||||
|
||||
$entries = $result['pump_entries'] ?? [];
|
||||
|
||||
if (empty($entries)) {
|
||||
$entries = [
|
||||
[
|
||||
'sl_no' => '1',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.02',
|
||||
'speed' => '2976',
|
||||
'head' => '5',
|
||||
'flow_reading' => '18.75',
|
||||
'current' => '61.8',
|
||||
'watt' => '40730',
|
||||
],
|
||||
[
|
||||
'sl_no' => '2',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.05',
|
||||
'speed' => '2976',
|
||||
'head' => '100',
|
||||
'flow_reading' => '18.71',
|
||||
'current' => '72.7',
|
||||
'watt' => '47100',
|
||||
],
|
||||
[
|
||||
'sl_no' => '3',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.04',
|
||||
'speed' => '2975',
|
||||
'head' => '150',
|
||||
'flow_reading' => '17.65',
|
||||
'current' => '76.3',
|
||||
'watt' => '48000',
|
||||
],
|
||||
[
|
||||
'sl_no' => '4',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.02',
|
||||
'speed' => '2974',
|
||||
'head' => '200',
|
||||
'flow_reading' => '15.65',
|
||||
'current' => '74',
|
||||
'watt' => '47760',
|
||||
],
|
||||
[
|
||||
'sl_no' => '5',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.04',
|
||||
'speed' => '2977',
|
||||
'head' => '250',
|
||||
'flow_reading' => '12.51',
|
||||
'current' => '68.2',
|
||||
'watt' => '45240',
|
||||
],
|
||||
[
|
||||
'sl_no' => '6',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50',
|
||||
'speed' => '2979',
|
||||
'head' => '270',
|
||||
'flow_reading' => '11.53',
|
||||
'current' => '65.5',
|
||||
'watt' => '43050',
|
||||
],
|
||||
[
|
||||
'sl_no' => '7',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.05',
|
||||
'speed' => '2983',
|
||||
'head' => '300',
|
||||
'flow_reading' => '8.65',
|
||||
'current' => '57.4',
|
||||
'watt' => '37460',
|
||||
],
|
||||
[
|
||||
'sl_no' => '8',
|
||||
'voltage' => '415',
|
||||
'frequency' => '50.03',
|
||||
'speed' => '2990',
|
||||
'head' => '325',
|
||||
'flow_reading' => '0',
|
||||
'current' => '35.8',
|
||||
'watt' => '21300',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$output = [
|
||||
'tested_date' => $result['tested_date'] ?? '2026-07-16',
|
||||
'test_type' => $result['test-type'] ?? 'Pump Performance Test',
|
||||
'correction_head' => $result['correction_head'] ?? '5.0',
|
||||
'pump_entries' => array_map(function ($entry) {
|
||||
return [
|
||||
'sl_no' => $entry['sl_no'] ?? '',
|
||||
'voltage' => $entry['voltage'] ?? '',
|
||||
'frequency' => $entry['frequency'] ?? '',
|
||||
'speed' => $entry['speed'] ?? '',
|
||||
'head' => $entry['head'] ?? '',
|
||||
'flow_reading' => $entry['flow_reading'] ?? '',
|
||||
'current' => $entry['current'] ?? '',
|
||||
'watt' => $entry['watt'] ?? '',
|
||||
];
|
||||
}, $entries ?? []),
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user