]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
правки по обмену
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 12 Apr 2024 07:46:56 +0000 (10:46 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 12 Apr 2024 07:46:56 +0000 (10:46 +0300)
docker-compose.yml
erp24/api2/controllers/DataController.php
erp24/inc/db.php
erp24/views/cron/1c.php

index 092315d46fa14def3dddfe77bacdd99fb5b714c7..51b6753357963e8858bd751b92053021367751a0 100644 (file)
@@ -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:
index 2a727756171d3c19b99cbde070ad967b97d478f8..101eab35238b4a321c7a8c29072b3891d11d6466 100644 (file)
@@ -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)) {
index 1ffb6e02805437124788af6e424bb8dd5f9c1f24..8bca3bc877142d6360193d7b86867911d47345f5 100644 (file)
@@ -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);
   }
   
index aae6e9db29a0a94b49ad3df168260c3204624e92..9348327ac9196fd5f08775602fb871fd00ec5c0f 100644 (file)
@@ -48,6 +48,7 @@ foreach($items as $name => $ar) {
     echo '</table>';
 }
 echo'<br><button name=save value=1 type=submit class="btn btn-success">Сохранить</button></form>';
+echo'<p><button class="btn"><a href="/cron/1c">Обновить</a></button></p>';
 $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"<h3>Здания для 1с</h3><table class=\"table table-hover table-sm\"><tbody>";
 foreach($data as $row) {
     echo"<tr"; if($row["status"]==0) echo" class=\"bg-warning\" ";