Changed production quantity importer logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 4m4s
Laravel Larastan / larastan (pull_request) Failing after 6m39s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 4m4s
Laravel Larastan / larastan (pull_request) Failing after 6m39s
This commit is contained in:
@@ -57,19 +57,19 @@ class ProductionQuantityImporter extends Importer
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example(['Day', 'Night'])
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('block_reference')
|
||||
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||
// ->exampleHeader('Block Name')
|
||||
// ->example(['Block A', 'Block A'])
|
||||
// ->label('Block Name')
|
||||
// ->rules(['required']), // Or remove if not required
|
||||
// ImportColumn::make('shift')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Shift Name')
|
||||
// ->example(['Day', 'Night'])
|
||||
// ->label('Shift Name')
|
||||
// ->relationship(resolveUsing: 'name')
|
||||
// ->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
@@ -98,8 +98,8 @@ class ProductionQuantityImporter extends Importer
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$line = null;
|
||||
$block = null;
|
||||
$shift = null;
|
||||
// $block = null;
|
||||
// $shift = null;
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
@@ -110,23 +110,11 @@ class ProductionQuantityImporter extends Importer
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
// block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (! $line) {
|
||||
$warnMsg[] = 'Line not found';
|
||||
}
|
||||
if (! $block) {
|
||||
$warnMsg[] = 'Block not found';
|
||||
} elseif ($plant) {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
|
||||
// $shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (! $shift) {
|
||||
$warnMsg[] = 'Shift not found';
|
||||
}
|
||||
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
@@ -199,6 +187,31 @@ class ProductionQuantityImporter extends Importer
|
||||
$warnMsg[] = 'Operator ID not found';
|
||||
}
|
||||
|
||||
$shift = null;
|
||||
|
||||
if (isset($fdateTime) && $plant) {
|
||||
|
||||
$createdTime = $fdateTime->format('H:i:s');
|
||||
|
||||
if ($createdTime >= '08:00:00' && $createdTime < '19:30:00') {
|
||||
|
||||
$shiftName = 'Day';
|
||||
|
||||
} else {
|
||||
|
||||
$shiftName = 'Night';
|
||||
|
||||
}
|
||||
|
||||
$shift = Shift::where('plant_id', $plant->id)
|
||||
->where('name', $shiftName)
|
||||
->first();
|
||||
|
||||
if (! $shift) {
|
||||
$warnMsg[] = "{$shiftName} shift not found";
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else { // if (empty($warnMsg))
|
||||
@@ -212,6 +225,8 @@ class ProductionQuantityImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ProductionQuantity::updateOrCreate([
|
||||
'serial_number' => $this->data['serial_number'],
|
||||
'plant_id' => $plant->id,
|
||||
|
||||
Reference in New Issue
Block a user