likang 2 anni fa
parent
commit
a82f1b5486
2 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. 2 2
      catch/api/controller/Api.php
  2. 10 6
      catch/api/service/dispose.php

+ 2 - 2
catch/api/controller/Api.php

@@ -211,7 +211,7 @@ class Api extends CatchController
                         $a=$json_data['a'];
                         $status=$json_data['status'];
                         $count= count($a);
-                        if((time()-$json_data["time"])<10){
+                        if((time()-$json_data["time"])<8){
                             debug_log("clear_label", $item.':'. "标签上报间隔没有超过20秒进行跳过");
                             continue;
                         }
@@ -399,7 +399,7 @@ class Api extends CatchController
         debug_log($key,"没有上报的的标签总数".$f);
         // $redis->del($key);
         $dis= new dispose($redis);
-      //  $dis->analysisLog();
+       $dis->analysisLog();
         
     }
 

+ 10 - 6
catch/api/service/dispose.php

@@ -372,7 +372,9 @@ class dispose
      * 解析日志
      */
     public function analysisLog(){
-        $path="D:\公司项目\测试基站\station-test-api\runtime\log\2023-05-15\label_log.log";
+        $path=app()->getRootPath()."runtime/log/2023-05-15/label_log.log";
+        var_dump($path);
+        var_dump(is_file($path));
         $file = fopen($path, "rb");
         debug_log("in_label","开始解析标签");
         $array=[];
@@ -386,12 +388,14 @@ class dispose
         };  
         debug_log("in_label","解析运行中");
 
-    foreach ($readCvs($file) as $key=>$data) {
-        debug_log("in_label",$data);
+    foreach ($readCvs($file) as $data) {
+        
         if(strstr($data,"xsj")){
-            $arr=  explode("xsj:",$data);
-            $data= json_decode(trim($arr[1]),true);
-            debug_log("in_label",trim($arr[1]));
+           
+            $arr=  explode("{",$data);
+                
+            $data= json_decode("{".trim($arr[1]),true);
+            debug_log("in_label",$data);
             if(!in_array($data['label'],$array)&&$data["rssi1"]>$data["rssi2"]){
                 array_push($array,$data['label']);
             }