Changed logic in post api and get api of process order #243
@@ -7,6 +7,7 @@ use App\Models\GrMaster;
|
|||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\ItemCharacteristic;
|
use App\Models\ItemCharacteristic;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProcessOrder;
|
use App\Models\ProcessOrder;
|
||||||
use App\Models\StickerDetail;
|
use App\Models\StickerDetail;
|
||||||
@@ -540,7 +541,7 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$processOrder = $request->header('process-order');
|
$processOrder = $request->header('process-order');
|
||||||
|
|
||||||
// $machineName = $request->header('machine-name');
|
$machineName = $request->header('machine-name');
|
||||||
|
|
||||||
if (! $plantCode) {
|
if (! $plantCode) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -575,6 +576,7 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$proOrdAgPlant = ProcessOrder::where('plant_id', $plantId)
|
$proOrdAgPlant = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
|
->latest()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $proOrdAgPlant) {
|
if (! $proOrdAgPlant) {
|
||||||
@@ -584,61 +586,185 @@ class PdfController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = $proOrdAgPlant->item;
|
$coil = $proOrdAgPlant->coil_number;
|
||||||
|
|
||||||
$processOrderRecords = ProcessOrder::with('item')
|
if($coil != 0){
|
||||||
->where('plant_id', $plant->id)
|
$proOrdAgPlantMachine = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->get();
|
->where('machine_name', $machineName)
|
||||||
|
|
||||||
$lastRecord = ProcessOrder::with('item')
|
|
||||||
->where('plant_id', $plant->id)
|
|
||||||
->where('process_order', $processOrder)
|
|
||||||
->orderBy('id', 'desc')
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$lastRecord1 = ProcessOrder::with('item')
|
if (!$proOrdAgPlantMachine) {
|
||||||
->where('plant_id', $plant->id)
|
return response()->json([
|
||||||
->where('process_order', $processOrder)
|
'status_code' => 'ERROR',
|
||||||
->where('rework_status', 0)
|
'status_description' => 'Machine name not found in process order!',
|
||||||
->orderBy('id', 'desc')
|
], 404);
|
||||||
->first();
|
}
|
||||||
|
|
||||||
$totalReceivedQty = $processOrderRecords->sum('received_quantity');
|
$item = $proOrdAgPlant->item;
|
||||||
// $lastRecord = $processOrderRecords->first();
|
|
||||||
$item = $lastRecord->item;
|
$processOrderRecords = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('machine_name', $machineName)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$lastRecord = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('machine_name', $machineName)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$lastRecord1 = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('machine_name', $machineName)
|
||||||
|
->where('rework_status', 0)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$totalReceivedQty = $processOrderRecords->sum('received_quantity');
|
||||||
|
// $lastRecord = $processOrderRecords->first();
|
||||||
|
$item = $lastRecord->item;
|
||||||
|
|
||||||
|
if ($totalReceivedQty == $proOrdAgPlant->order_quantity) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' has already reached its order quantity.",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemId = $lastRecord->item_id;
|
||||||
|
|
||||||
|
$line = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->where('item_id',$itemId)->first();
|
||||||
|
|
||||||
|
$lineId = $line->line_id;
|
||||||
|
|
||||||
|
$lineName = Line::where('plant_id', $plantId)->where('id', $lineId)->value('name');
|
||||||
|
|
||||||
|
|
||||||
|
// $workCenter = Machine::where('plant_id', $plantId)->where('work_center', $machineName)->first();
|
||||||
|
|
||||||
|
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
|
||||||
|
|
||||||
|
$machine = Machine::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_center', $machineName)->first();
|
||||||
|
$machineId = $machine->id;
|
||||||
|
|
||||||
|
if(!$machine){
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Machine not found in machine table.",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ($totalReceivedQty > $proOrdAgPlant->order_quantity) {
|
||||||
|
// return responses()->json([
|
||||||
|
// 'status_code' => 'ERROR',
|
||||||
|
// 'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' received quantity is more than its order quantity."
|
||||||
|
// ], 404);
|
||||||
|
// }
|
||||||
|
|
||||||
|
$okQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('machine_id', $machineId)->where('status', 'Ok')->get()->count();
|
||||||
|
|
||||||
|
$notOkQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('machine_id', $machineId)->where('status', 'NotOk')->get()->count();
|
||||||
|
|
||||||
|
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
|
||||||
|
|
||||||
if ($totalReceivedQty == $proOrdAgPlant->order_quantity) {
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'item_code' => $item?->code ?? '',
|
||||||
'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' has already reached its order quantity.",
|
'description' => $item?->description ?? '',
|
||||||
], 404);
|
'line_name' => $lineName ?? '',
|
||||||
|
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
||||||
|
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
||||||
|
'coil_number' => $currentCoil,
|
||||||
|
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
||||||
|
'ok_quantity' => (string) $okQty ?? '0',
|
||||||
|
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
||||||
|
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$proOrdAgPlant = ProcessOrder::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$proOrdAgPlant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'process order not found!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = $proOrdAgPlant->item;
|
||||||
|
|
||||||
|
$processOrderRecords = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$lastRecord = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$lastRecord1 = ProcessOrder::with('item')
|
||||||
|
->where('plant_id', $plant->id)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('rework_status', 0)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$totalReceivedQty = $processOrderRecords->sum('received_quantity');
|
||||||
|
// $lastRecord = $processOrderRecords->first();
|
||||||
|
$item = $lastRecord->item;
|
||||||
|
|
||||||
|
if ($totalReceivedQty == $proOrdAgPlant->order_quantity) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' has already reached its order quantity.",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemId = $lastRecord->item_id;
|
||||||
|
|
||||||
|
$line = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->where('item_id',$itemId)->first();
|
||||||
|
|
||||||
|
$lineId = $line->line_id;
|
||||||
|
|
||||||
|
$lineName = Line::where('plant_id', $plantId)->where('id', $lineId)->value('name');
|
||||||
|
|
||||||
|
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
|
||||||
|
|
||||||
|
// if ($totalReceivedQty > $proOrdAgPlant->order_quantity) {
|
||||||
|
// return responses()->json([
|
||||||
|
// 'status_code' => 'ERROR',
|
||||||
|
// 'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' received quantity is more than its order quantity."
|
||||||
|
// ], 404);
|
||||||
|
// }
|
||||||
|
|
||||||
|
$okQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('status', 'Ok')->get()->count();
|
||||||
|
|
||||||
|
$notOkQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('status', 'NotOk')->get()->count();
|
||||||
|
|
||||||
|
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'item_code' => $item?->code ?? '',
|
||||||
|
'description' => $item?->description ?? '',
|
||||||
|
'line_name' => $lineName ?? '',
|
||||||
|
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
||||||
|
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
||||||
|
'coil_number' => $currentCoil,
|
||||||
|
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
||||||
|
'ok_quantity' => (string) $okQty ?? '0',
|
||||||
|
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
||||||
|
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($totalReceivedQty > $proOrdAgPlant->order_quantity) {
|
|
||||||
// return response()->json([
|
|
||||||
// 'status_code' => 'ERROR',
|
|
||||||
// 'status_description' => "Process order '{$processOrder}' for plant '{$plantCode}' received quantity is more than its order quantity."
|
|
||||||
// ], 404);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$okQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('status', 'Ok')->get()->count();
|
|
||||||
|
|
||||||
$notOkQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('status', 'NotOk')->get()->count();
|
|
||||||
|
|
||||||
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'item_code' => $item?->code ?? '',
|
|
||||||
'description' => $item?->description ?? '',
|
|
||||||
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
|
||||||
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
|
||||||
'coil_number' => $currentCoil,
|
|
||||||
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
|
||||||
'ok_quantity' => (string) $okQty ?? '0',
|
|
||||||
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
|
||||||
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeProcessOrderData(Request $request)
|
public function storeProcessOrderData(Request $request)
|
||||||
@@ -691,7 +817,7 @@ class PdfController extends Controller
|
|||||||
$plantId = $plant->id;
|
$plantId = $plant->id;
|
||||||
|
|
||||||
$itemCode = $data['item_code'] ?? '';
|
$itemCode = $data['item_code'] ?? '';
|
||||||
$lineName = $data['line_name'] ?? '';
|
// $lineName = $data['line_name'] ?? '';
|
||||||
$coilNo = $data['coil_number'] ?? '';
|
$coilNo = $data['coil_number'] ?? '';
|
||||||
$updatedOrderQty = $data['order_quantity'] ?? 0;
|
$updatedOrderQty = $data['order_quantity'] ?? 0;
|
||||||
$receivedQty = $data['received_quantity'] ?? 0;
|
$receivedQty = $data['received_quantity'] ?? 0;
|
||||||
@@ -699,18 +825,9 @@ class PdfController extends Controller
|
|||||||
$sfgNo = $data['sfg_number'] ?? '';
|
$sfgNo = $data['sfg_number'] ?? '';
|
||||||
$machineId = $data['machine_id'] ?? '';
|
$machineId = $data['machine_id'] ?? '';
|
||||||
$rework = $data['rework'] ?? '';
|
$rework = $data['rework'] ?? '';
|
||||||
|
$operationNo = $data['operation_number'] ?? '';
|
||||||
$createdBy = $data['created_by'] ?? '';
|
$createdBy = $data['created_by'] ?? '';
|
||||||
|
|
||||||
// $validated = $request->validate([
|
|
||||||
// 'item_code' => 'nullable|integer',
|
|
||||||
// 'coil_number' => 'nullable|string',
|
|
||||||
// 'order_quantity' => 'nullable|integer',
|
|
||||||
// 'received_quantity' => 'nullable|numeric',
|
|
||||||
// 'sfg_number' => 'nullable|string',
|
|
||||||
// 'machine_id' => 'nullable|string',
|
|
||||||
// 'created_by' => 'nullable|string',
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
if ($itemCode == null || $itemCode == '' || ! $itemCode) {
|
if ($itemCode == null || $itemCode == '' || ! $itemCode) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
@@ -728,13 +845,39 @@ class PdfController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($lineName == null || $lineName == '' || ! $lineName) {
|
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||||
|
|
||||||
|
if(!$item){
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Line name can't be empty!",
|
'status_description' => "Item Code not found!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($item){
|
||||||
|
$lineIdExist = $item->line_id ?? '';
|
||||||
|
|
||||||
|
if ($lineIdExist) {
|
||||||
|
|
||||||
|
$line = Line::where('id', $lineIdExist)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
if ($line) {
|
||||||
|
$lineId = $line->id;
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Line not found!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Line not mapped for item code '$itemCode'!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($scrapQty == null || $scrapQty == '') {
|
if ($scrapQty == null || $scrapQty == '') {
|
||||||
$scrapQty = 0;
|
$scrapQty = 0;
|
||||||
}
|
}
|
||||||
@@ -746,28 +889,6 @@ class PdfController extends Controller
|
|||||||
], 404);
|
], 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 == '') {
|
if ($coilNo == null || $coilNo == '') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
@@ -781,19 +902,12 @@ class PdfController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($sfgNo == null || $sfgNo == '' || ! $sfgNo) {
|
if ($operationNo == null || $operationNo == '' || ! $operationNo) {
|
||||||
// return response()->json([
|
return response()->json([
|
||||||
// 'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
// 'status_description' => "SFG number can't be empty!",
|
'status_description' => "Operation Number can't be empty!",
|
||||||
// ], 404);
|
], 404);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if ($machineId == null || $machineId == '' || ! $machineId) {
|
|
||||||
// return response()->json([
|
|
||||||
// 'status_code' => 'ERROR',
|
|
||||||
// 'status_description' => "Machine ID can't be empty!",
|
|
||||||
// ], 404);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
|
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -942,9 +1056,8 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineNamePlantId)
|
->where('line_id', $lineId)
|
||||||
->where('coil_number', $coilMain)
|
->where('coil_number', $coilMain)
|
||||||
// ->where('machine_name', $machineId)
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $existingCoil) {
|
if (! $existingCoil) {
|
||||||
@@ -968,16 +1081,15 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineNamePlantId)
|
->where('line_id', $lineId)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
// ->where('machine_name', $machineId)
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $existingCoil) {
|
if (! $existingCoil) {
|
||||||
ProcessOrder::Create(
|
ProcessOrder::Create(
|
||||||
[
|
[
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'line_id' => $lineNamePlantId,
|
'line_id' => $lineId,
|
||||||
'process_order' => $processOrder,
|
'process_order' => $processOrder,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'coil_number' => $coilNo,
|
'coil_number' => $coilNo,
|
||||||
@@ -987,6 +1099,7 @@ class PdfController extends Controller
|
|||||||
'scrap_quantity' => $scrapQty,
|
'scrap_quantity' => $scrapQty,
|
||||||
'sfg_number' => $sfgNo,
|
'sfg_number' => $sfgNo,
|
||||||
'machine_name' => $machineId,
|
'machine_name' => $machineId,
|
||||||
|
'operation_number' => $operationNo,
|
||||||
'rework_status' => 1,
|
'rework_status' => 1,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
]
|
]
|
||||||
@@ -999,12 +1112,13 @@ class PdfController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineNamePlantId)
|
->where('line_id', $lineId)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
->update([
|
->update([
|
||||||
// 'order_quantity' => $orderQty,
|
// 'order_quantity' => $orderQty,
|
||||||
'received_quantity' => $receivedQty,
|
'received_quantity' => $receivedQty,
|
||||||
'scrap_quantity' => $scrapQty,
|
'scrap_quantity' => $scrapQty,
|
||||||
|
'operation_number' => $operationNo,
|
||||||
// 'sfg_number' => $sfgNo,
|
// 'sfg_number' => $sfgNo,
|
||||||
// 'machine_name' => $machineId,
|
// 'machine_name' => $machineId,
|
||||||
'rework_status' => 1,
|
'rework_status' => 1,
|
||||||
@@ -1030,7 +1144,7 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineNamePlantId)
|
->where('line_id', $lineId)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@@ -1056,13 +1170,13 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('line_id', $lineNamePlantId)
|
->where('line_id', $lineId)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
->where('machine_name', $machineId)
|
|
||||||
->update([
|
->update([
|
||||||
// 'order_quantity' => $orderQty,
|
// 'order_quantity' => $orderQty,
|
||||||
'received_quantity' => $receivedQty,
|
'received_quantity' => $receivedQty,
|
||||||
'scrap_quantity' => $scrapQty,
|
'scrap_quantity' => $scrapQty,
|
||||||
|
'operation_number' => $operationNo,
|
||||||
// 'sfg_number' => $sfgNo,
|
// 'sfg_number' => $sfgNo,
|
||||||
// 'machine_name' => $machineId,
|
// 'machine_name' => $machineId,
|
||||||
'rework_status' => 1,
|
'rework_status' => 1,
|
||||||
@@ -1093,14 +1207,12 @@ class PdfController extends Controller
|
|||||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
->where('machine_name', $machineId)
|
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($existing) {
|
if ($existing) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Coil number '{$coilNo}' already exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
'status_description' => "Coil number '{$coilNo}' already exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||||
// "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
|
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1129,7 +1241,7 @@ class PdfController extends Controller
|
|||||||
ProcessOrder::Create(
|
ProcessOrder::Create(
|
||||||
[
|
[
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'line_id' => $lineNamePlantId,
|
'line_id' => $lineId,
|
||||||
'process_order' => $processOrder,
|
'process_order' => $processOrder,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'coil_number' => $coilNo,
|
'coil_number' => $coilNo,
|
||||||
@@ -1139,6 +1251,7 @@ class PdfController extends Controller
|
|||||||
'scrap_quantity' => $scrapQty,
|
'scrap_quantity' => $scrapQty,
|
||||||
'sfg_number' => $sfgNo,
|
'sfg_number' => $sfgNo,
|
||||||
'machine_name' => $machineId,
|
'machine_name' => $machineId,
|
||||||
|
'operation_number' => $operationNo,
|
||||||
'rework_status' => 0,
|
'rework_status' => 0,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user