Przeglądaj źródła

basic logic test success

nana_sen 2 lat temu
rodzic
commit
3d1f853345
2 zmienionych plików z 36 dodań i 23 usunięć
  1. 33 21
      catch/api/controller/Api.php
  2. 3 2
      task_script/PAREA_STATUS_UPDATE.php

+ 33 - 21
catch/api/controller/Api.php

@@ -280,7 +280,7 @@ class Api extends CatchController
                         ]
                     ];
                     $ues_redis->hset("parea_rfidinfos",$field, json_encode($info,true));
-                    debug_log("parea_rfidinfos_redis_set_record","redis更新记录".$url_res);
+                    debug_log("parea_rfidinfos_redis_set_record","redis更新记录".json_encode($info,true));
                 }else{
                     $info = json_decode($info,true);
 
@@ -293,21 +293,28 @@ class Api extends CatchController
                         "time" => $time
                     ];
                     $rssisArr = $info["rssi"];
-
-                    foreach ($rssisArr as $k => $v) {
-                        # code...
-                        if( ($time - $v["time"] ) > $EXP_TIME ){
-                            unset($rssisArr[$k]);
-                        }
-                    }
+                    
+                    // var_dump("+++++++++++++++++", $time, $newRssi["time"]);
+
+                    // foreach ($rssisArr as $k => $v) {
+                    //     # code...
+                    //     if( ($time - $v["time"] ) > $EXP_TIME ){
+                    //         unset($rssisArr[$k]);
+                    //         // var_dump("+++++++++++++++++", $time, $v["time"]);
+                    //     }
+                    // }
                     if(count($rssisArr) == $EFF_SIG_NUM){
                         array_shift($rssisArr);
                         array_push($rssisArr, $newRssi);
                     }else{
                         array_push($rssisArr, $newRssi);
                     }
+                    
+                    // var_dump("+++++++++++++++++",$rssisArr);
                     $info["rssi"] = $rssisArr;
 
+                    // var_dump("------------",$info["rssi"]);
+
                     $cacCount = count($rssisArr);
                     // if($cacCount > $EFF_SIG_NUM){
                     $sum1 = 0;
@@ -332,9 +339,9 @@ class Api extends CatchController
                         # code...
                        $info = $this->compAndPush($info ,$ues_redis);
                     }
-
                     $ues_redis->hset("parea_rfidinfos",$field, json_encode($info,true));
-                    debug_log("parea_rfidinfos_redis_set_record","redis更新记录".$url_res);
+                    
+                    debug_log("parea_rfidinfos_redis_set_record","redis更新记录".json_encode($info,true));
                 }
                 $text=substr($text,24);
             }else{
@@ -357,21 +364,21 @@ class Api extends CatchController
             # code...
             $config = [
                 "front_in" => 65,
-                "behind_in" => 65,
-                "left_in" => 65,
-                "right_in" => 65,
-                "front_out" => 78,
-                "behind_out" => 78,
-                "left_out" => 78,
-                "right_out" => 78,
+                "behind_in" => 70,
+                "left_in" => 80,
+                "right_in" => 70,
+                "front_out" => 70,
+                "behind_out" => 75,
+                "left_out" => 82,
+                "right_out" => 70,
             ];     
         }
 
         $avg = $info['avg'];
         $status = $info['status'];
 
-        $flagIn = $data["front"] < $config["front_in"] || $data["behind"] < $config["behind_in"] || $data["left"] < $config["left_in"] || $data["right"] < $config["right_in"];
-        $flagOut = $data["front"] > $config["front_out"] && $data["behind"] < $config["behind_out"] && $data["left"] < $config["left_out"] && $data["right"] < $config["right_out"];
+        $flagIn = $avg["front"] < $config["front_in"] || $avg["behind"] < $config["behind_in"] || $avg["left"] < $config["left_in"] || $avg["right"] < $config["right_in"];
+        $flagOut = $avg["front"] > $config["front_out"] && $avg["behind"] > $config["behind_out"] && $avg["left"] > $config["left_out"] && $avg["right"] > $config["right_out"];
 
         $url="http://47.114.185.186:8115/api/areaReport";
         if($flagIn && $status == 2){
@@ -387,10 +394,14 @@ class Api extends CatchController
                     ]
                 ]
             ];
-            debug_log("pushPareaRes","推送内容:".json_encode($url_data));
+            debug_log("pushPareaRes","进推送依赖:".json_encode($info));
             $url_res= curl_http_post(json_encode($url_data),$url,false);
+            
             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){
             //推送出
             $info['status'] = 2;
@@ -404,8 +415,9 @@ class Api extends CatchController
                     ]
                 ]
             ];
-            debug_log("pushPareaRes","推送内容:".json_encode($url_data));
+            debug_log("pushPareaRes","出推送依赖:".json_encode($info));
             $url_res= curl_http_post(json_encode($url_data),$url,false);
+            
             debug_log("pushPareaRes","远程返回结果".$url_res);
         }
         return $info;

+ 3 - 2
task_script/PAREA_STATUS_UPDATE.php

@@ -8,7 +8,7 @@ define('HOST', '127.0.0.1');
 define('PORT', '6379');
 define('PASSWORD', '123456');
 define('DATABASE', 3);
-define('OFFLINETIMEINT', 120);
+define('OFFLINETIMEINT', 30);
 
 
 function app_redis()
@@ -240,6 +240,7 @@ while (true) {
                         ]
                     ];
                     http($url, $url_data, [], 'POST');
+                    rlog("PUSH INFO","离线推送依赖数据", $v);
                 }
                 app_redis()->hdel('parea_rfidinfos',$k);;
             }
@@ -248,6 +249,6 @@ while (true) {
     } catch (\Exception $ex) {
         rlog("INFO", 'pushhttp',"推送 异常".$ex->getMessage());
     }
-    sleep(60); //1分钟遍历一次
+    sleep(10); //1分钟遍历一次
 }