Merge pull request 'Changed production quantity importer logic' (#1413) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #1413
This commit was merged in pull request #1413.
This commit is contained in:
@@ -57,19 +57,19 @@ class ProductionQuantityImporter extends Importer
|
|||||||
->label('Line Name')
|
->label('Line Name')
|
||||||
->relationship(resolveUsing: 'name')
|
->relationship(resolveUsing: 'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('block_reference')
|
// ImportColumn::make('block_reference')
|
||||||
->requiredMapping() // Or optionalMapping() if not always present
|
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||||
->exampleHeader('Block Name')
|
// ->exampleHeader('Block Name')
|
||||||
->example(['Block A', 'Block A'])
|
// ->example(['Block A', 'Block A'])
|
||||||
->label('Block Name')
|
// ->label('Block Name')
|
||||||
->rules(['required']), // Or remove if not required
|
// ->rules(['required']), // Or remove if not required
|
||||||
ImportColumn::make('shift')
|
// ImportColumn::make('shift')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Shift Name')
|
// ->exampleHeader('Shift Name')
|
||||||
->example(['Day', 'Night'])
|
// ->example(['Day', 'Night'])
|
||||||
->label('Shift Name')
|
// ->label('Shift Name')
|
||||||
->relationship(resolveUsing: 'name')
|
// ->relationship(resolveUsing: 'name')
|
||||||
->rules(['required']),
|
// ->rules(['required']),
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Code')
|
->exampleHeader('Plant Code')
|
||||||
@@ -98,8 +98,8 @@ class ProductionQuantityImporter extends Importer
|
|||||||
$plantCod = $this->data['plant'];
|
$plantCod = $this->data['plant'];
|
||||||
$plant = null;
|
$plant = null;
|
||||||
$line = null;
|
$line = null;
|
||||||
$block = null;
|
// $block = null;
|
||||||
$shift = null;
|
// $shift = null;
|
||||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
$warnMsg[] = 'Invalid plant code found';
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
} else {
|
} else {
|
||||||
@@ -110,23 +110,11 @@ class ProductionQuantityImporter extends Importer
|
|||||||
$warnMsg[] = 'Plant not found';
|
$warnMsg[] = 'Plant not found';
|
||||||
} else {
|
} else {
|
||||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
$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) {
|
if (! $line) {
|
||||||
$warnMsg[] = 'Line not found';
|
$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;
|
$item = null;
|
||||||
if ($plant) {
|
if ($plant) {
|
||||||
@@ -199,6 +187,31 @@ class ProductionQuantityImporter extends Importer
|
|||||||
$warnMsg[] = 'Operator ID not found';
|
$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)) {
|
if (! empty($warnMsg)) {
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
} else { // if (empty($warnMsg))
|
} else { // if (empty($warnMsg))
|
||||||
@@ -212,6 +225,8 @@ class ProductionQuantityImporter extends Importer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProductionQuantity::updateOrCreate([
|
ProductionQuantity::updateOrCreate([
|
||||||
'serial_number' => $this->data['serial_number'],
|
'serial_number' => $this->data['serial_number'],
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
|
|||||||
Reference in New Issue
Block a user