Browse Source

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

nana_sen 1 year ago
parent
commit
f2f493fc0f
2 changed files with 53 additions and 4 deletions
  1. 6 2
      catch/api/controller/Api.php
  2. 47 2
      catch/api/service/dispose.php

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

@@ -113,7 +113,7 @@ class Api extends CatchController
                      $vs=false;
                      $DA['num']=$num;
                      $DA['other_time']=date("Y-m-d H:i:s",$time);
-                    if($DA['rssi1']<=75||$DA['rssi2']<=75||$DA['rssi3']<=75||$DA['rssi4']<=75){
+                    if($DA['rssi1']<=72||$DA['rssi2']<=72||$DA['rssi3']<=72||$DA['rssi4']<=72){
                         $vs=true;
 
                     }else{
@@ -211,7 +211,7 @@ class Api extends CatchController
                         $a=$json_data['a'];
                         $status=$json_data['status'];
                         $count= count($a);
-                        if((time()-$json_data["time"])<20){
+                        if((time()-$json_data["time"])<10){
                             debug_log("clear_label", $item.':'. "标签上报间隔没有超过20秒进行跳过");
                             continue;
                         }
@@ -398,6 +398,9 @@ class Api extends CatchController
         }
         debug_log($key,"没有上报的的标签总数".$f);
         // $redis->del($key);
+        $dis= new dispose($redis);
+      //  $dis->analysisLog();
+        
     }
 
 
@@ -408,6 +411,7 @@ class Api extends CatchController
 
 
 
+
   public function temporary_label($redis,$label,$type){
         $key="temporary_label";
         if($type==1){

+ 47 - 2
catch/api/service/dispose.php

@@ -256,7 +256,7 @@ class dispose
                             $url_res= curl_http_post(json_encode($url_data),$url,false);
                            debug_log("InAndOUT","远程返回结果".$url_res);
                            debug_log("result","正常计算返回的结果".json_encode($url_data));
-                            
+
                            $this->temporary_label($this->redis,$data['label'],2);
                           $status['dirt']=$res;
                           $status['time']=$time;
@@ -367,11 +367,56 @@ class dispose
             $redis->hSet($key,$label,2);
         }
 
-  }
+    }
+    /**
+     * 解析日志
+     */
+    public function analysisLog(){
+        $path="D:\公司项目\测试基站\station-test-api\runtime\log\2023-05-15\label_log.log";
+        $file = fopen($path, "rb");
+        debug_log("in_label","开始解析标签");
+        $array=[];
+        $readCvs=function($file){
+            while (feof($file)===false) {
+                # code...
+                yield fgets($file);
+            }
+            fclose($file);
+
+        };  
+        debug_log("in_label","解析运行中");
+
+    foreach ($readCvs($file) as $key=>$data) {
+        debug_log("in_label",$data);
+        if(strstr($data,"xsj")){
+            $arr=  explode("xsj:",$data);
+            $data= json_decode(trim($arr[1]),true);
+            debug_log("in_label",trim($arr[1]));
+            if(!in_array($data['label'],$array)&&$data["rssi1"]>$data["rssi2"]){
+                array_push($array,$data['label']);
+            }
+         }
+
+    }
+
+
+
+        foreach($array as $item){
+            debug_log("in_label",$item);
+        }
+        debug_log("in_label","标签总数".count($array));
+          
+       
+
+
 
 
 
 
+    }
+
+
+