From 0f8e6a7a6a161bf500c8fb8be4e0503c12802eda Mon Sep 17 00:00:00 2001 From: RedHood Date: Sun, 31 Jan 2021 20:39:02 +1000 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D1=81=D0=BB=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=B2=D1=88=D0=B8=D1=85=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mirzaev/skillparts/system/models/Account.php | 1 + .../system/models/AccountEdgePurchase.php | 4 +- .../system/models/AccountEdgeSupply.php | 4 +- mirzaev/skillparts/system/models/Document.php | 1 + mirzaev/skillparts/system/models/Edge.php | 1 + mirzaev/skillparts/system/models/Product.php | 5 +-- .../system/models/ProductEdgeProduct.php | 4 +- .../system/models/ProductEdgeProductGroup.php | 4 +- .../skillparts/system/models/ProductGroup.php | 38 ++++++++++--------- .../models/ProductGroupEdgeProductGroup.php | 4 +- mirzaev/skillparts/system/models/Purchase.php | 4 +- .../system/models/PurchaseEdgeSupply.php | 4 +- .../skillparts/system/models/Requisite.php | 10 +++-- mirzaev/skillparts/system/models/Supply.php | 27 +++++++++++-- .../system/models/SupplyEdgeProduct.php | 2 + .../system/models/SupplyEdgeRequisite.php | 4 +- .../system/models/SupplyEdgeSupply.php | 4 +- .../system/models/SupplyEdgeSupplyGroup.php | 4 +- .../skillparts/system/models/SupplyGroup.php | 1 + .../models/SupplyGroupEdgeSupplyGroup.php | 4 +- 20 files changed, 91 insertions(+), 39 deletions(-) diff --git a/mirzaev/skillparts/system/models/Account.php b/mirzaev/skillparts/system/models/Account.php index 08f3193..9042bbd 100644 --- a/mirzaev/skillparts/system/models/Account.php +++ b/mirzaev/skillparts/system/models/Account.php @@ -1,4 +1,5 @@ id)) { - // Группа не найдена + // if (!$model = static::readByOnecId($group->id)) { + // // Группа не найдена - // Инициализация - $model = new static; + // // Инициализация + // $model = new static; - $model->onec_id = $group->id; - } + // $model->onec_id = $group->id; + // } - $model->name = $group->name; + // $model->name = $group->name; - if ($parent = $group->getParent()) { - // Найден родитель + // if ($parent = $group->getParent()) { + // // Найден родитель - // Инициализация (рекурсия) - $parentModel = static::createByML($parent); + // // Инициализация (рекурсия) + // $parentModel = static::createByML($parent); - $model->onec_prnt_id = $parentModel->id; + // $model->onec_prnt_id = $parentModel->id; - unset($parentModel); - } else { - $model->onec_prnt_id = null; - } + // unset($parentModel); + // } else { + // $model->onec_prnt_id = null; + // } - $model->save(); + // $model->save(); - return $model; + // return $model; + + return null; } private static function writeEdgeBetweenGroup(string $from, string $to): bool diff --git a/mirzaev/skillparts/system/models/ProductGroupEdgeProductGroup.php b/mirzaev/skillparts/system/models/ProductGroupEdgeProductGroup.php index 2492cf8..15c7f6b 100644 --- a/mirzaev/skillparts/system/models/ProductGroupEdgeProductGroup.php +++ b/mirzaev/skillparts/system/models/ProductGroupEdgeProductGroup.php @@ -1,10 +1,12 @@ andWhere(['status_id' => 2])->all(); } diff --git a/mirzaev/skillparts/system/models/PurchaseEdgeSupply.php b/mirzaev/skillparts/system/models/PurchaseEdgeSupply.php index 3d19e6f..487a1c8 100644 --- a/mirzaev/skillparts/system/models/PurchaseEdgeSupply.php +++ b/mirzaev/skillparts/system/models/PurchaseEdgeSupply.php @@ -1,10 +1,12 @@ user->id, true); $properties = self::xml2array($properties->xml); + $fp = fopen('1.txt', 'a'); + fwrite($fp, print_r(count($models), true) . PHP_EOL); + fclose($fp); + + // for ($i = 0; $i <= count($models); $i++) foreach ($models as $model) { // Перебор записей + $fp = fopen('2.txt', 'a'); + fwrite($fp, $model->ocid . PHP_EOL); + fclose($fp); + // Инициализация $changes = false; + $transit = $model->onec; - foreach ($model->onec['ЗначенияСвойств'] as &$attribute) { + foreach ($model->onec['ЗначенияСвойств'] as $attribute_name => $attribute_value) { // Перебор аттрибутов foreach ($properties as $property) { // Перебор свойств - if ($attribute['ЗначенияСвойства']['Ид'] === $property['Свойство']['Ид']) { + if (is_array($attribute_value) && is_array($property) && $attribute_value['Ид'] === $property['Ид']) { // Совпадение идентификаторов // Объединение данных - array_merge($attribute, $property); + $transit['ЗначенияСвойств'][$attribute_name] = array_merge($attribute_value, $property, $transit['ЗначенияСвойств'][$attribute_name]); // Запись индикатора наличия изменений $changes = true; + + // break; + } else { + // Объединение данных + $transit['ЗначенияСвойств'][$attribute_name] = $property; } } } if ($changes) { + // Если указано, что записаны изменения + + // Настройка ($transit нужен из-за ограничений __set()) + $model->onec = $transit; + + // Запись $model->save(); } } diff --git a/mirzaev/skillparts/system/models/SupplyEdgeProduct.php b/mirzaev/skillparts/system/models/SupplyEdgeProduct.php index 7f51d4d..f93801f 100644 --- a/mirzaev/skillparts/system/models/SupplyEdgeProduct.php +++ b/mirzaev/skillparts/system/models/SupplyEdgeProduct.php @@ -1,5 +1,7 @@