|
|
@@ -72,16 +72,16 @@ class ImportReclamationsService extends ImportBaseService
|
|
|
$year = (int)$r['orders.year'];
|
|
|
|
|
|
// округ
|
|
|
- if (!($districtId = $this->findId('districts.shortname', $r['districts.name'] ?? ''))) {
|
|
|
- $errors['district_not_found'][] = $strNumber;
|
|
|
- continue;
|
|
|
- }
|
|
|
+// if (!($districtId = $this->findId('districts.shortname', $r['districts.name'] ?? ''))) {
|
|
|
+// $errors['district_not_found'][] = $strNumber;
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
// район
|
|
|
- if (!($areaId = $this->findId('areas.name', $r['areas.name']))) {
|
|
|
- $errors['area_not_found'][] = $strNumber;
|
|
|
- continue;
|
|
|
- }
|
|
|
+// if (!($areaId = $this->findId('areas.name', $r['areas.name']))) {
|
|
|
+// $errors['area_not_found'][] = $strNumber;
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
// manager
|
|
|
$userId = config('app.default_maf_order_user_id');
|
|
|
@@ -93,54 +93,50 @@ class ImportReclamationsService extends ImportBaseService
|
|
|
}
|
|
|
|
|
|
// order
|
|
|
- $order = Order::query()
|
|
|
- ->withoutGlobalScopes()
|
|
|
- ->where('year', $year)
|
|
|
- ->where('object_address', $r['orders.object_address'])
|
|
|
- ->first();
|
|
|
- if (!$order) {
|
|
|
- echo $this->import->log('Order NOT FOUND: ' . $r['orders.object_address'], 'WARNING');
|
|
|
- $errors['order_not_found'][] = $strNumber;
|
|
|
- continue;
|
|
|
- } else {
|
|
|
- $logMessage .= 'Found order: ' . $order->object_address . ". ";
|
|
|
- }
|
|
|
+// $order = Order::query()
|
|
|
+// ->withoutGlobalScopes()
|
|
|
+// ->where('year', $year)
|
|
|
+// ->where('object_address', $r['orders.object_address'])
|
|
|
+// ->first();
|
|
|
+// if (!$order) {
|
|
|
+// echo $this->import->log('Order NOT FOUND: ' . $r['orders.object_address'], 'WARNING');
|
|
|
+// $errors['order_not_found'][] = $strNumber;
|
|
|
+// continue;
|
|
|
+// } else {
|
|
|
+// $logMessage .= 'Found order: ' . $order->object_address . ". ";
|
|
|
+// }
|
|
|
|
|
|
// product
|
|
|
- $product = Product::query()
|
|
|
- ->withoutGlobalScopes()
|
|
|
- ->where('year', $year)
|
|
|
- ->where('nomenclature_number', $r['products.nomenclature_number'])
|
|
|
- ->first();
|
|
|
- if (!$product) {
|
|
|
- echo $this->import->log('Product not found: ' . $r['products.nomenclature_number'], 'WARNING');
|
|
|
- $errors['product_not_found'][] = $strNumber;
|
|
|
- continue;
|
|
|
- }
|
|
|
+// $product = Product::query()
|
|
|
+// ->withoutGlobalScopes()
|
|
|
+// ->where('year', $year)
|
|
|
+// ->where('nomenclature_number', $r['products.nomenclature_number'])
|
|
|
+// ->first();
|
|
|
+// if (!$product) {
|
|
|
+// echo $this->import->log('Product not found: ' . $r['products.nomenclature_number'], 'WARNING');
|
|
|
+// $errors['product_not_found'][] = $strNumber;
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
$rfid = Str::replace(' ', '', $r['products_sku.rfid']);
|
|
|
|
|
|
// check maf with this nomenclature number in order
|
|
|
$productSKU = ProductSKU::query()
|
|
|
->withoutGlobalScopes()
|
|
|
- ->where('year', $year)
|
|
|
- ->where('product_id', $product->id)
|
|
|
- ->where('order_id', $order->id)
|
|
|
+// ->where('year', $year)
|
|
|
+// ->where('product_id', $product->id)
|
|
|
+// ->where('order_id', $order->id)
|
|
|
->where('rfid', $rfid)
|
|
|
->first();
|
|
|
+
|
|
|
if (!$productSKU) {
|
|
|
- $productSKU = ProductSKU::query()
|
|
|
- ->where('year', $year)
|
|
|
- ->where('product_id', $product->id)
|
|
|
- ->where('order_id', $order->id)
|
|
|
- ->first();
|
|
|
- }
|
|
|
- if (!$productSKU) {
|
|
|
- echo $this->import->log('SKU not found: ' . $r['products.nomenclature_number'], 'WARNING');
|
|
|
+ echo $this->import->log('SKU not found: ' . $r['products.nomenclature_number'] . '(RFID: ' . $r['products_sku.rfid'] . ')', 'WARNING');
|
|
|
$errors['sku_not_found'][] = $strNumber;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ $order = Order::query()->withoutGlobalScopes()->where('id', $productSKU->order_id)->first();
|
|
|
+
|
|
|
$createDate = ($r['reclamations.create_date']) ? DateHelper::excelDateToISODate($r['reclamations.create_date']) : null;
|
|
|
$finishDate = ($r['reclamations.finish_date']) ? DateHelper::excelDateToISODate($r['reclamations.finish_date']) : null;
|
|
|
$startWorkDate = ($r['reclamations.start_work_date']) ? DateHelper::excelDateToISODate($r['reclamations.start_work_date']) : null;
|