From a2b39bce2615d5ace56fdf294876465656029e79 Mon Sep 17 00:00:00 2001 From: JoySystem_v Date: Mon, 19 Aug 2024 20:43:34 +0300 Subject: [PATCH] =?utf8?q?=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20=D0=BA?= =?utf8?q?=D0=BE=D0=B4=D0=B0=20=D0=BE=D1=82=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?utf8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index b0490a57..7f943c89 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -808,7 +808,7 @@ class DataController extends BaseController { $matrixProductsIds = SalaryHelper::getMatrixProductsIds(); } - if (!empty($result['checks']) && count($result['checks']) < 300) { + if (!empty($result['checks']) && count($result['checks']) < 1000) { foreach ($result["checks"] as $arr) { $check_id = $arr["id"]; @@ -1591,9 +1591,6 @@ class DataController extends BaseController { private function insertDataSales($values, $tableName, $columns) { $chunkValues = array_chunk($values, 1000); - // Логирование общего количества значений и количества фрагментов - file_put_contents(self::OUT_DIR . '/error_upload.txt', PHP_EOL . "Total values: " . count($values), FILE_APPEND); - file_put_contents(self::OUT_DIR . '/error_upload.txt', PHP_EOL . "Total chunks: " . count($chunkValues), FILE_APPEND); foreach ($chunkValues as $key => $rows) { // Преобразование значений в $rows перед вставкой @@ -1604,23 +1601,17 @@ class DataController extends BaseController { } } - - // Логирование текущего фрагмента перед попыткой вставки - $jsonRows = json_encode($rows, JSON_UNESCAPED_UNICODE); - file_put_contents(self::OUT_DIR . '/sales_upload.json', PHP_EOL . "Chunk $key: " . $jsonRows, FILE_APPEND); try { - file_put_contents(self::OUT_DIR . '/sales_upload2.json', PHP_EOL . "Inserting chunk $key", FILE_APPEND); $transaction = \Yii::$app->db->beginTransaction(); Yii::$app->db->createCommand()->batchInsert($tableName, $columns, $rows)->execute(); $transaction->commit(); } catch (Exception $e) { - // $transaction->rollBack(); + $transaction->rollBack(); $errorString = substr($e->getMessage(), 0, 2000); - // InfoLogService::setInfoLog(__FILE__, __LINE__, $tableName , 'error_id_25'); - // InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString , 'error_id_25_22'); - // LogService::apiErrorLog(json_encode(["error_id" => 25, "error" => $errorString], JSON_UNESCAPED_UNICODE)); - file_put_contents(self::OUT_DIR . '/sales_upload3.json', PHP_EOL . "Error in chunk $key: " . $errorString, FILE_APPEND); - file_put_contents(self::OUT_DIR . '/sales_upload3.json', PHP_EOL . "Failed chunk data: " . $jsonRows, FILE_APPEND); + InfoLogService::setInfoLog(__FILE__, __LINE__, $tableName , 'error_id_25'); + InfoLogService::setInfoLog(__FILE__, __LINE__, $errorString , 'error_id_25_22'); + LogService::apiErrorLog(json_encode(["error_id" => 25, "error" => $errorString], JSON_UNESCAPED_UNICODE)); + } } } -- 2.39.5