Explorar o código

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

tongshanglei hai 1 ano
pai
achega
0eb97aa91e
Modificáronse 1 ficheiros con 92 adicións e 65 borrados
  1. 92 65
      catch/api/controller/Api.php

+ 92 - 65
catch/api/controller/Api.php

@@ -111,12 +111,32 @@ class Api extends CatchController
                      //打印原始的数据日志
                      debug_log("label_log","cssh: ".json_encode($DA));
 
-                     if($DA['rssi1']<=85||$DA['rssi2']<=85||$DA['rssi3']<=85||$DA['rssi4']<=85){
+                     $rssiHi = 85;
+                     if ($mac == '638007') {
+                        # code...
+                        $rssiHi = 60;
+                    }
+                     if($DA['rssi1']<=$rssiHi||$DA['rssi2']<=$rssiHi||$DA['rssi3']<=$rssiHi||$DA['rssi4']<=$rssiHi){
                         //原始数据只要其中有一条信号小于85 都存入redis 历史数据
                         $history_status=true;
                      }
-                   
-                    if($DA['rssi1']<=72||$DA['rssi2']<=72||$DA['rssi3']<=72||$DA['rssi4']<=72){
+                     $rssiIn = 72;
+
+                    //安装调测代码
+                    $de_macs = ['638006','638007', '631176'];
+                    $de_rfids = ['E2B6A925', '0200C1D2', '0200C1D1'];
+                    if (in_array($mac, $de_macs) && in_array($label, $de_rfids)){
+                        $deDa = $DA;
+                        $deDa['time'] = date("Y-m-d H:i:s",$time);
+                        $deLkey = 'debug_'.$mac.'_'. hexdec($label);
+                        $ues_redis->lpush($deLkey,json_encode($deDa));
+                    }
+                    if ($mac == '638007') {
+                        # code...
+                        $rssiIn = 60;
+                    }
+
+                    if($DA['rssi1']<=$rssiIn||$DA['rssi2']<=$rssiIn||$DA['rssi3']<=$rssiIn||$DA['rssi4']<=$rssiIn){
                          //原始数据只要其中有一条信号小于72 都参与计算
                         $vs=true;
                     }
@@ -755,7 +775,7 @@ class Api extends CatchController
                         $info = [
                             "mac" => $mac,
                             "id" => $rfid,
-                            "firs_time" => $time,
+                            "first_time" => $time,
                             "time" => $time,
                             "status" => 2,//2出状态,1进状态
                             "rssi" => [
@@ -1082,7 +1102,6 @@ class Api extends CatchController
             // debug_log("push_indoor_res","出推送依赖:".json_encode($info));
             // $url_res= curl_http_post(json_encode($url_data),$url,false);
             $info['pushTime'] = time();
-            
             // debug_log("push_indoor_res","远程返回结果".$url_res);
         }
         return $info;
@@ -1099,7 +1118,8 @@ class Api extends CatchController
         $flagOut = $avg["front"] > $config["front_out"] && $avg["behind"] > $config["behind_out"] && $avg["left"] > $config["left_out"] && $avg["right"] > $config["right_out"];
 
 
-        if($flagIn && ($status == 2 || $status == 3) ){
+        if($flagIn){
+        // if($flagIn && ($status == 2 || $status == 3) ){
         // if($flagIn){
             $inoutIntFilter = $ues_redis->hget("anbang_four_wire", "anbang_4rssi_intFilter");
             $inoutIntFilter = $inoutIntFilter ? $inoutIntFilter : 20;
@@ -1107,50 +1127,58 @@ class Api extends CatchController
                 # code...
                 return $info;
             }
-            //推送进
-            $info['status'] = 1;
 
-            // 临时功能代码
-            $labels = ['0200C1D1', '0200C1D2']; //测试设备
-            if (in_array(strtoupper($info['id']), $labels)) {
-                # code...
-                //card_black
-                $where = [];
-                $where[] = ['type', '=','basic_config'];
-                $where[] = ['field', '=','card_black'];
-                $bkList = Db::name('sys_config')->where($where)->find();
-                $bkList = explode(',', $bkList['fieldValue']);
-                if (in_array(strtoupper($info['id']), $bkList)) {
-                    # code...
-                    $info['status'] = 3;
-                }
+
+            // // 临时功能代码
+            // var_dump($info["id"]);
+            // $labels = ['0200C1D1', '0200C1D2']; //测试设备
+            // if (in_array(strtoupper($info['id']), $labels)) {
+            //     # code...
+            //     //card_black
+            //     $where = [];
+            //     $where[] = ['type', '=','basic_config'];
+            //     $where[] = ['field', '=','card_black'];
+            //     $bkList = Db::name('sys_config')->where($where)->find();
+            //     $bkList = explode(',', $bkList['fieldValue']);
+            //     // var_dump($info['id'],in_array(strtoupper($info['id']), $bkList),$bkList);
+            //     if (in_array(strtoupper($info['id']), $bkList)) {
+            //         # code...
+            //         $info['status'] = 3;
+            //     }
                 
-            }
+            // }
+            $expInt =$info["time"]-$info["first_time"];
             
-            $url_data = [
-                "mac" => $info["mac"],
-                "data" => [
-                    [
-                        "label" => $info["id"],
-                        "time" => $info["time"],
-                        "first_time" => $info["first_time"],
-                        "dirt" => 1,
-                        "rssi" => $info["rssi"],//数组 [{"front":72,"behind":255,"left":255,"right":255,"time":1685067709},{"front":76,"behind":255,"left":255,"right":255,"time":1685067710}]
-                        "avg" => $info["avg"] //{"front":"77.17","behind":"90.00","left":"90.00","right":"90.00"}
+            if ($expInt >= 120 && !key_exists('pushTime', $info)) {
+                //推送进
+                $info['status'] = 1;
+                # code...
+                // var_dump('-------------expint------',$info["id"],$expInt);
+                $url_data = [
+                    "mac" => $info["mac"],
+                    "data" => [
+                        [
+                            "label" => $info["id"],
+                            "time" => $info["time"],
+                            "first_time" => $info["first_time"],
+                            "dirt" => $info['status'],
+                            "rssi" => $info["rssi"],//数组 [{"front":72,"behind":255,"left":255,"right":255,"time":1685067709},{"front":76,"behind":255,"left":255,"right":255,"time":1685067710}]
+                            "avg" => $info["avg"] //{"front":"77.17","behind":"90.00","left":"90.00","right":"90.00"}
+                        ]
                     ]
-                ]
-            ];
-            // debug_log("pushPareaRes","进推送依赖:".json_encode($info));
-            // $url_res= curl_http_post(json_encode($url_data),$url,false);
-            $ues_redis->lpush("parea_inoutres_push", json_encode($url_data));
-            $info['pushTime'] = time();
+                ];
+                // debug_log("pushPareaRes","进推送依赖:".json_encode($info));
+                $ues_redis->lpush("parea_inoutres_push", json_encode($url_data));
+                $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 ) {
+            if ($info["pushTime"] &&  (time()-$info['pushTime']) < 2 ) {
                 # code...
                 return $info;
             }
@@ -1175,30 +1203,30 @@ class Api extends CatchController
             
             // debug_log("pushPareaRes","远程返回结果".$url_res);
         }
-        if($flagIn && $info['status'] == 1){
-            $inoutIntFilter = $ues_redis->hget("anbang_four_wire", "anbang_4rssi_intFilter");
-            $inoutIntFilter = $inoutIntFilter ? $inoutIntFilter : 20;
-            if ($info["camPushTime"] &&  (time()-$info['camPushTime']) < $inoutIntFilter ) { 
-                # code...
-                return $info;
-            }
-            //推送进
-            $url_data = [
-                "mac" => $info["mac"],
-                "first_time" => $info["first_time"],
-                "data" => [
-                    [
-                        "label" => $info["id"],
-                        "time" => $info["time"],
-                        "dirt" => 1,
-                        "rssi" => $info["rssi"],//数组 [{"front":72,"behind":255,"left":255,"right":255,"time":1685067709},{"front":76,"behind":255,"left":255,"right":255,"time":1685067710}]
-                        "avg" => $info["avg"] //{"front":"77.17","behind":"90.00","left":"90.00","right":"90.00"}
-                    ]
-                ]
-            ];
-            $ues_redis->lpush("parea_inoutres_push", json_encode($url_data));
-            $info["camPushTime"] = time();
-        }
+        // if($flagIn && $info['status'] == 1){
+        //     $inoutIntFilter = $ues_redis->hget("anbang_four_wire", "anbang_4rssi_intFilter");
+        //     $inoutIntFilter = $inoutIntFilter ? $inoutIntFilter : 20;
+        //     if ($info["camPushTime"] &&  (time()-$info['camPushTime']) < $inoutIntFilter ) { 
+        //         # code...
+        //         return $info;
+        //     }
+        //     //推送进
+        //     $url_data = [
+        //         "mac" => $info["mac"],
+        //         "first_time" => $info["first_time"],
+        //         "data" => [
+        //             [
+        //                 "label" => $info["id"],
+        //                 "time" => $info["time"],
+        //                 "dirt" => 1,
+        //                 "rssi" => $info["rssi"],//数组 [{"front":72,"behind":255,"left":255,"right":255,"time":1685067709},{"front":76,"behind":255,"left":255,"right":255,"time":1685067710}]
+        //                 "avg" => $info["avg"] //{"front":"77.17","behind":"90.00","left":"90.00","right":"90.00"}
+        //             ]
+        //         ]
+        //     ];
+        //     $ues_redis->lpush("parea_inoutres_push", json_encode($url_data));
+        //     $info["camPushTime"] = time();
+        // }
 
         return $info;
     }
@@ -1235,7 +1263,6 @@ class Api extends CatchController
     
     }
 
-    
 
     /**
      * 检测小程序版本版本 function