Bläddra i källkod

Merge branch 'master' of http://gogs.renlianiot.com:4000/zmcoding/station-test-api

likang 1 år sedan
förälder
incheckning
3701deef19
2 ändrade filer med 17 tillägg och 2 borttagningar
  1. 11 1
      catch/api/controller/Api.php
  2. 6 1
      task_script/PAREA_STATUS_UPDATE.php

+ 11 - 1
catch/api/controller/Api.php

@@ -591,8 +591,13 @@ class Api extends CatchController
 
         $url="http://47.114.185.186:8115/api/areaReport";
         if($flagIn && $status == 2){
+            if ($info["pushTime"] &&  (time()-$info['pushTime']) < 5 ) {
+                # code...
+                return $info;
+            }
             //推送进
             $info['status'] = 1;
+            
             $url_data = [
                 "mac" => $info["mac"],
                 "data" => [
@@ -605,13 +610,17 @@ class Api extends CatchController
             ];
             debug_log("pushPareaRes","进推送依赖:".json_encode($info));
             $url_res= curl_http_post(json_encode($url_data),$url,false);
-            
+            $info['pushTime'] = time();
             debug_log("pushPareaRes","远程返回结果".$url_res);
         }
         // if($info['id'] == "E2B15AD5"){
         //     var_dump($flagIn, $flagOut, $status, $avg["front"],$avg["behind"],$avg["left"], $avg["right"]);
         // }
         if($flagOut && $status == 1){
+            if ($info["pushTime"] &&  (time()-$info['pushTime']) < 5 ) {
+                # code...
+                return $info;
+            }
             //推送出
             $info['status'] = 2;
             $url_data = [
@@ -626,6 +635,7 @@ class Api extends CatchController
             ];
             debug_log("pushPareaRes","出推送依赖:".json_encode($info));
             $url_res= curl_http_post(json_encode($url_data),$url,false);
+            $info['pushTime'] = time();
             
             debug_log("pushPareaRes","远程返回结果".$url_res);
         }

+ 6 - 1
task_script/PAREA_STATUS_UPDATE.php

@@ -252,6 +252,11 @@ while (true) {
     } catch (\Exception $ex) {
         rlog("INFO", 'pushhttp',"推送 异常".$ex->getMessage());
     }
-    sleep(floor($offlineInt/2)); //1分钟遍历一次
+    $sleepTime = floor($offlineInt/10);
+    if ($sleepTime < 3) {
+        # code...
+        $sleepTime = 3;
+    }
+    sleep($sleepTime); //1分钟遍历一次
 }