Browse Source

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

tongshanglei 1 year ago
parent
commit
d335bd0745
2 changed files with 51 additions and 9 deletions
  1. 37 1
      catch/api/controller/Api.php
  2. 14 8
      task_script/MN_RL4RSSI_MQTT_CLIENT.php

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

@@ -188,6 +188,24 @@ class Api extends CatchController
             $received_state=$redis->hget('api_receiver_asset_state', 'accessClassReport');
             $mac=$list['mac'];
             foreach($list['data'] as $val){
+                if ($received_state == '1') {
+                    # code...
+                    $antData = json_decode( $redis->hGet('lab_ant_tmp',$val['label']) );
+                    if (!$antData) {
+                        # code...
+                        $antData = [
+                            $val['ant'] => 1 
+                        ];
+                    }elseif(!$antData[$val['ant']]){
+                        $antData[$val['ant']] = 1;
+                    }else {
+                        # code...
+                        $antData[$val['ant']] += 1;
+                    }
+                    $redis->hset('lab_ant_tmp',$val['label'], json_encode($antData) );
+                }else{
+                    $redis->del('lab_ant_tmp');
+                }
                 //1 3外 2 4内
                 if($val['ant']=='3'){
                     $val['ant']='1';
@@ -1080,7 +1098,8 @@ class Api extends CatchController
         $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"];
 
-        if($flagIn && $status == 2){
+
+        if($flagIn && ($status == 2 || $status == 3) ){
         // if($flagIn){
             $inoutIntFilter = $ues_redis->hget("anbang_four_wire", "anbang_4rssi_intFilter");
             $inoutIntFilter = $inoutIntFilter ? $inoutIntFilter : 20;
@@ -1090,6 +1109,23 @@ class Api extends CatchController
             }
             //推送进
             $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;
+                }
+                
+            }
             
             $url_data = [
                 "mac" => $info["mac"],

+ 14 - 8
task_script/MN_RL4RSSI_MQTT_CLIENT.php

@@ -6,8 +6,8 @@ use think\facade\Cache;
 date_default_timezone_set("PRC");
 define('HOST', '127.0.0.1');
 define('PORT', '6379');
-define('PASSWORD', '123456');
-define('DATABASE', 4);
+define('PASSWORD', 'R!478gH*%23nPn');
+define('DATABASE', 2);
 
 
 function app_redis()
@@ -59,7 +59,7 @@ function rlog(...$args)
         return;
     }
     static $LOG_CONSOLE = false; //是否输出到控制台
-    static $LOG_NAME = "school_mqtt.log"; //值为空时 不写入文件
+    static $LOG_NAME = "school_mqtt_nb_serv.log"; //值为空时 不写入文件
     static $LOG_SIZE = 64 * 1024 * 1024; //文件最大尺寸
 
     static $LOG_CACHE = false; //是否缓存日志内容 用于批量写入文件
@@ -300,11 +300,17 @@ function rcInfoMsg($topic, $msg)
 }
 function loop()
 {
-    $server   = 'develop.rltest.cn';
+    // $server   = 'develop.rltest.cn';
+    // $port     = 1883;
+    // $clientId = 'mqttx_test1312412412';
+    // $username = 'rl517';
+    // $password = "rlian2022";
+    // $clean_session = true;
+    $server   = '127.0.0.1';
     $port     = 1883;
-    $clientId = 'mqttx_test1312412412';
-    $username = 'rl517';
-    $password = "rlian2022";
+    $clientId = 'mqttx_resiarea'.rand(1234, 99999);
+    $username = 'rl0606';
+    $password = "rlian2023";
     $clean_session = true;
 
     $connectionSettings  = new ConnectionSettings();
@@ -344,7 +350,7 @@ function loop()
     //     getDevSysMsg($topic, $message);
     // }, 0);
     //终端上报系统信息数据
-    $mqtt->subscribe('RL4RSSI/rfidinfos4444', function ($topic, $message) {
+    $mqtt->subscribe('RL4RSSI/rfidinfos', function ($topic, $message) {
         rlog("INFO", 'recv', $topic, $message);
         $data=json_decode($message,true);