changed logic in post api of process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Larastan / larastan (pull_request) Failing after 6m21s
Laravel Pint / pint (pull_request) Successful in 5m17s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Larastan / larastan (pull_request) Failing after 6m21s
Laravel Pint / pint (pull_request) Successful in 5m17s
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\User;
|
||||
@@ -667,11 +668,14 @@ class PdfController extends Controller
|
||||
$plantId = $plant->id;
|
||||
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$lineName = $data['line_name'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
$receivedQty = $data['received_quantity'] ?? 0;
|
||||
$scrapQty = $data['scrap_quantity'] ?? 0;
|
||||
$sfgNo = $data['sfg_number'] ?? '';
|
||||
$machineId = $data['machine_id'] ?? '';
|
||||
$rework = $data['rework'] ?? '';
|
||||
$createdBy = $data['created_by'] ?? '';
|
||||
|
||||
// $validated = $request->validate([
|
||||
@@ -701,6 +705,35 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($lineName == null || $lineName == '' || ! $lineName) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
|
||||
if (! $line) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name '{$lineName}' not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineNamePlant = Line::where('name', $lineName)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (! $lineNamePlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Line name '{$lineName}' not found for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineNamePlantId = $lineNamePlant->id;
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -806,18 +839,6 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
@@ -839,25 +860,89 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
try {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineId,
|
||||
'created_by' => $createdBy,
|
||||
]
|
||||
);
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Inserted Successfully',
|
||||
]);
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if($rework != 'Yes' && $rework != 'No'){
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value should be either 'Yes' or 'No'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ($rework == 'Yes')
|
||||
{
|
||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
// 'scrap_quantity' => $scrapQty,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => 1,
|
||||
'updated_by' => $createdBy,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if ($updated == 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No matching record found for rework coil number!',
|
||||
], 404);
|
||||
}
|
||||
else
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Updated Successfully (Rework)',
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineNamePlantId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineId,
|
||||
'rework_status' => 0,
|
||||
'created_by' => $createdBy,
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Record Inserted Successfully',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -866,6 +951,65 @@ class PdfController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function storeLaserPdf(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!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$workflowId = $request->header('work_flow_id');
|
||||
|
||||
if (!$workflowId) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "work_flow_id can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (! $request->hasFile('pdf_file')) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No PDF file provided!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $file = $request->file('pdf_file');
|
||||
// $filename = $file->getClientOriginalName();
|
||||
|
||||
// $filePath = $file->storeAs(
|
||||
// 'uploads/LaserDocs',
|
||||
// $filename,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
$filename = $workflowId . '.pdf';
|
||||
|
||||
$filePath = 'uploads/LaserDocs/' . $filename;
|
||||
|
||||
if (Storage::disk('local')->exists($filePath)) {
|
||||
Storage::disk('local')->delete($filePath);
|
||||
}
|
||||
|
||||
Storage::disk('local')->putFileAs(
|
||||
'uploads/LaserDocs',
|
||||
$filename,
|
||||
'local'
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Laser document pdf file replaced successfully!',
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user