Added quality part validation api with validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 22s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 25s
Laravel Pint / pint (pull_request) Successful in 2m34s
Laravel Larastan / larastan (pull_request) Failing after 6m6s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 22s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 25s
Laravel Pint / pint (pull_request) Successful in 2m34s
Laravel Larastan / larastan (pull_request) Failing after 6m6s
This commit is contained in:
@@ -276,6 +276,123 @@ class StickerMasterController extends Controller
|
|||||||
return response()->json($output, 200);
|
return response()->json($output, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_quality_master(Request $request)
|
||||||
|
{
|
||||||
|
$expectedUser = env('API_AUTH_USER');
|
||||||
|
$expectedPw = env('API_AUTH_PW');
|
||||||
|
$header_auth = $request->header('Authorization');
|
||||||
|
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||||
|
|
||||||
|
if ('Bearer '.$expectedToken != $header_auth) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Invalid authorization token!',
|
||||||
|
], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantCode = $request->header('plant-code');
|
||||||
|
$itemCode = $request->header('item-code');
|
||||||
|
|
||||||
|
if ($plantCode == null || $plantCode == '') {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Plant code can't be empty!",
|
||||||
|
], 400);
|
||||||
|
} elseif (! is_numeric($plantCode)) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Plant code should contain only numeric values!',
|
||||||
|
], 400);
|
||||||
|
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Plant code must be between 4 and 7 digits only!',
|
||||||
|
], 400);
|
||||||
|
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Invalid plant code found!',
|
||||||
|
], 400);
|
||||||
|
} elseif ($itemCode == null || $itemCode == '') {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Item Code can't be empty!",
|
||||||
|
], 400);
|
||||||
|
} elseif (Str::length($itemCode) < 6 || ! ctype_alnum($itemCode)) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Invalid item code found!',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
|
if (! $plant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Plant Code not found!',
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantId = $plant->id;
|
||||||
|
|
||||||
|
$item = Item::where('code', $itemCode)->first();
|
||||||
|
|
||||||
|
if (! $item) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Item Code not found in item table!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||||
|
|
||||||
|
if (! $item) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Item Code not found for the plant : '$plant->name' in item table!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemId = $item->id;
|
||||||
|
|
||||||
|
$description = $item ? $item->description : '';
|
||||||
|
|
||||||
|
$uom = $item ? $item->uom : '';
|
||||||
|
|
||||||
|
// $category = $item ? $item->category : '';
|
||||||
|
|
||||||
|
$stickerMaster = StickerMaster::where('item_id', $itemId)->first();
|
||||||
|
|
||||||
|
if (! $stickerMaster) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Item Code not found in sticker master table!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||||
|
|
||||||
|
if (! $stickerMaster) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Item Code not found for the plant : '$plant->name' in sticker master table!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = [
|
||||||
|
'item_description' => $description ?? '',
|
||||||
|
'uom' => $uom ?? '',
|
||||||
|
'Part_Validation_1' => $stickerMaster?->part_validation1 ?? '',
|
||||||
|
'Part_Validation_2' => $stickerMaster?->part_validation2 ?? '',
|
||||||
|
'Part_Validation_3' => $stickerMaster?->part_validation3 ?? '',
|
||||||
|
'Part_Validation_4' => $stickerMaster?->part_validation4 ?? '',
|
||||||
|
'Part_Validation_5' => $stickerMaster?->part_validation5 ?? '',
|
||||||
|
];
|
||||||
|
|
||||||
|
return response()->json($output, 200);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ Route::get('get-pdf', [PdfController::class, 'getPdf']); // processorder/get-pdf
|
|||||||
|
|
||||||
// ..Part Validation - Characteristics
|
// ..Part Validation - Characteristics
|
||||||
|
|
||||||
|
Route::get('laser/item/get-quality-master-data', [StickerMasterController::class, 'get_quality_master']);
|
||||||
|
|
||||||
|
// ..Part Validation - Characteristics
|
||||||
|
|
||||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||||
|
|
||||||
// ..Laser Route to SAP
|
// ..Laser Route to SAP
|
||||||
|
|||||||
Reference in New Issue
Block a user