From: Aleksey Filippov Date: Fri, 12 Apr 2024 07:46:56 +0000 (+0300) Subject: правки по обмену X-Git-Tag: 1.1~148^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=4af6420e79bc4444bb97c54c8503fe66913982e0;p=erp24_rep%2Fyii-erp24%2F.git правки по обмену --- diff --git a/docker-compose.yml b/docker-compose.yml index 092315d4..51b67533 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -75,7 +75,7 @@ services: ports: - "5432:5432" volumes: - - pgsqldata:/var/lib/postgresql + - pgsqldata:/var/lib/postgresql/data env_file: ./docker/db/dev.db-pgsql.env pgadmin-yii_erp24: diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 2a727756..101eab35 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -338,6 +338,8 @@ class DataController extends BaseController { public function actionUpload() { set_time_limit(600); + file_put_contents(self::OUT_DIR . '/a2_upload_in.json', PHP_EOL . date('Y-m-d H:i:s') . ' ', FILE_APPEND | LOCK_EX); + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $request = Yii::$app->request->getRawBody(); @@ -347,6 +349,11 @@ class DataController extends BaseController { } catch (Exception $ex) { return $this->asJson(['error' => ['code' => 400, 'message' => 'Json body invalid']]); } + if (empty($result)) { + file_put_contents(self::OUT_DIR . '/error_upload.txt', + PHP_EOL . 'result empty', FILE_APPEND); + return $this->asJson(['error' => ['code' => 400, 'message' => 'result empty']]); + } $requestId = ''; if (!empty($result["request_id"])) { @@ -367,7 +374,10 @@ class DataController extends BaseController { } $mess["result"] = true; $checks_dell = ""; - $request_id = $result["request_id"]; + $request_id = time(); + if (array_key_exists("request_id", $result) && !empty($result["request_id"])) { + $request_id = $result["request_id"]; + } $type_price = "Розничная цена"; if (!empty($request_id)) { diff --git a/erp24/inc/db.php b/erp24/inc/db.php index 1ffb6e02..8bca3bc8 100644 --- a/erp24/inc/db.php +++ b/erp24/inc/db.php @@ -105,6 +105,9 @@ protected $config = ''; * @return mixed */ public static function getRow($query, $args = []) { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } @$GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetch(); } @@ -115,6 +118,9 @@ protected $config = ''; * @return array */ public static function getRows($query, $args = []) { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } @$GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetchAll(); } @@ -125,6 +131,9 @@ protected $config = ''; * @return mixed */ public static function getValue($query, $args = []) { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } @$GLOBALS["sql_cnt"]++; $result = self::getRow($query, $args); if (!empty($result)) { @@ -139,11 +148,17 @@ protected $config = ''; * @return array */ public static function getColumn($query, $args = []) { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } @$GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN); } public static function getCol($query, $args = []) { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } $GLOBALS["sql_cnt"]++; return self::run($query, $args)->fetch(PDO::FETCH_NAMED); } @@ -151,7 +166,11 @@ protected $config = ''; public static function sql($query, $args = []) - { $GLOBALS["sql_cnt"]++; + { + if(!isset($GLOBALS["sql_cnt"])) { + $GLOBALS["sql_cnt"] = 0; + } + $GLOBALS["sql_cnt"]++; self::run($query, $args); } diff --git a/erp24/views/cron/1c.php b/erp24/views/cron/1c.php index aae6e9db..9348327a 100644 --- a/erp24/views/cron/1c.php +++ b/erp24/views/cron/1c.php @@ -48,6 +48,7 @@ foreach($items as $name => $ar) { echo ''; } echo'
'; +echo'

'; $m=array(); $request_id=time(); $m["request_id"]=$request_id; @@ -66,12 +67,12 @@ if(!empty($_POST["in"]) and $json2!="[]") { - $db::sql("INSERT INTO api_cron (id, date, date_up, json_post,request_id) VALUES (0, NOW(), NOW(),?,?)",[$json2,$request_id]); + $db::sql("INSERT INTO api_cron (date, date_up, status,json_post,request_id) VALUES (NOW(), NOW(), 0, ?, ?)",[$json2,$request_id]); } $status_arr=[0=>"ожидает выполнения",1=>"выполнено"]; -$data = $db::getRows("SELECT * FROM api_cron WHERE 1 order by date DESC LIMIT 30 "); +$data = $db::getRows("SELECT * FROM api_cron WHERE 1=1 order by date DESC LIMIT 30 "); echo"

Здания для 1с

"; foreach($data as $row) { echo"