|
@@ -255,6 +255,9 @@ class dispose
|
|
"mac"=>$data['mac'],
|
|
"mac"=>$data['mac'],
|
|
"data"=>$data_array
|
|
"data"=>$data_array
|
|
];
|
|
];
|
|
|
|
+ //设定最后结果
|
|
|
|
+ $this->set_time_results($data['mac'],$data['label'],$resArray['time'],$inAndOut);
|
|
|
|
+ //推送远程数据
|
|
$this->getRemoteData($url_data);
|
|
$this->getRemoteData($url_data);
|
|
//清除缓存数据
|
|
//清除缓存数据
|
|
$this->get_label_history(3,$data['mac'],$data['label']);
|
|
$this->get_label_history(3,$data['mac'],$data['label']);
|
|
@@ -301,45 +304,45 @@ class dispose
|
|
|
|
|
|
|
|
|
|
//排序
|
|
//排序
|
|
- public function sortlist($list){
|
|
|
|
- $list01=[];
|
|
|
|
- $list02=[];
|
|
|
|
- $list03=[];
|
|
|
|
- $list04=[];
|
|
|
|
- debug_log("InAndOUT","排序的数据:".json_encode($list));
|
|
|
|
- foreach($list as $item){
|
|
|
|
- array_push($list01,$item['rssi1']);
|
|
|
|
- array_push($list02,$item['rssi2']);
|
|
|
|
- array_push($list03,$item['rssi3']);
|
|
|
|
- array_push($list04,$item['rssi4']);
|
|
|
|
- }
|
|
|
|
|
|
+ // public function sortlist($list){
|
|
|
|
+ // $list01=[];
|
|
|
|
+ // $list02=[];
|
|
|
|
+ // $list03=[];
|
|
|
|
+ // $list04=[];
|
|
|
|
+ // debug_log("InAndOUT","排序的数据:".json_encode($list));
|
|
|
|
+ // foreach($list as $item){
|
|
|
|
+ // array_push($list01,$item['rssi1']);
|
|
|
|
+ // array_push($list02,$item['rssi2']);
|
|
|
|
+ // array_push($list03,$item['rssi3']);
|
|
|
|
+ // array_push($list04,$item['rssi4']);
|
|
|
|
+ // }
|
|
|
|
|
|
- if(count($list)>=3){
|
|
|
|
- sort($list01);
|
|
|
|
- sort($list02);
|
|
|
|
- sort($list03);
|
|
|
|
- sort($list04);
|
|
|
|
- array_pop($list01);
|
|
|
|
- array_pop($list02);
|
|
|
|
- array_pop($list03);
|
|
|
|
- array_pop($list04);
|
|
|
|
- array_shift($list01);
|
|
|
|
- array_shift($list02);
|
|
|
|
- array_shift($list03);
|
|
|
|
- array_shift($list04);
|
|
|
|
- }
|
|
|
|
- debug_log("InAndOUT","排序后的队列:".json_encode($list01));
|
|
|
|
- debug_log("InAndOUT","排序后的队列:".json_encode($list02));
|
|
|
|
- debug_log("InAndOUT","排序后的队列:".json_encode($list03));
|
|
|
|
- debug_log("InAndOUT","排序后的队列:".json_encode($list04));
|
|
|
|
- $rssi1= array_sum($list01)/count($list01);
|
|
|
|
- $rssi2= array_sum($list02)/count($list02);
|
|
|
|
- $rssi3= array_sum($list03)/count($list03);
|
|
|
|
- $rssi4= array_sum($list04)/count($list04);
|
|
|
|
- $res=[$rssi1,$rssi2,$rssi3,$rssi4];
|
|
|
|
- debug_log("InAndOUT","结算后的结果:".json_encode($res));
|
|
|
|
- return $res;
|
|
|
|
- }
|
|
|
|
|
|
+ // if(count($list)>=3){
|
|
|
|
+ // sort($list01);
|
|
|
|
+ // sort($list02);
|
|
|
|
+ // sort($list03);
|
|
|
|
+ // sort($list04);
|
|
|
|
+ // array_pop($list01);
|
|
|
|
+ // array_pop($list02);
|
|
|
|
+ // array_pop($list03);
|
|
|
|
+ // array_pop($list04);
|
|
|
|
+ // array_shift($list01);
|
|
|
|
+ // array_shift($list02);
|
|
|
|
+ // array_shift($list03);
|
|
|
|
+ // array_shift($list04);
|
|
|
|
+ // }
|
|
|
|
+ // debug_log("InAndOUT","排序后的队列:".json_encode($list01));
|
|
|
|
+ // debug_log("InAndOUT","排序后的队列:".json_encode($list02));
|
|
|
|
+ // debug_log("InAndOUT","排序后的队列:".json_encode($list03));
|
|
|
|
+ // debug_log("InAndOUT","排序后的队列:".json_encode($list04));
|
|
|
|
+ // $rssi1= array_sum($list01)/count($list01);
|
|
|
|
+ // $rssi2= array_sum($list02)/count($list02);
|
|
|
|
+ // $rssi3= array_sum($list03)/count($list03);
|
|
|
|
+ // $rssi4= array_sum($list04)/count($list04);
|
|
|
|
+ // $res=[$rssi1,$rssi2,$rssi3,$rssi4];
|
|
|
|
+ // debug_log("InAndOUT","结算后的结果:".json_encode($res));
|
|
|
|
+ // return $res;
|
|
|
|
+ // }
|
|
/**
|
|
/**
|
|
* 获取远程推送的数据
|
|
* 获取远程推送的数据
|
|
*
|
|
*
|
|
@@ -349,6 +352,7 @@ class dispose
|
|
*/
|
|
*/
|
|
|
|
|
|
public function getRemoteData($data){
|
|
public function getRemoteData($data){
|
|
|
|
+
|
|
$key="push_data";
|
|
$key="push_data";
|
|
$redis=$this->redis;
|
|
$redis=$this->redis;
|
|
$redis->Rpush($key,json_encode($data));
|
|
$redis->Rpush($key,json_encode($data));
|
|
@@ -364,13 +368,31 @@ public function set_label_history($data){
|
|
$key=$MAC."_label_history";
|
|
$key=$MAC."_label_history";
|
|
$head=$data['label']."_head";
|
|
$head=$data['label']."_head";
|
|
$tail=$data["label"]."_tail";
|
|
$tail=$data["label"]."_tail";
|
|
|
|
+ $frontMaxKey=$data['label'].'_frontMax';
|
|
|
|
+ $backMaxKey=$data['label'].'_backMax';
|
|
|
|
+ $frontMax=null;
|
|
|
|
+ $backMax=null;
|
|
|
|
+
|
|
//保存头部
|
|
//保存头部
|
|
$head_data= $this->selectHash($key,$head);
|
|
$head_data= $this->selectHash($key,$head);
|
|
$tail_data=$this->selectHash($key,$tail);
|
|
$tail_data=$this->selectHash($key,$tail);
|
|
- debug_log("InAndOUT","最旧信号间隔-".($data["report_time"]-$tail_data[count($tail_data)-1]["report_time"]));
|
|
|
|
- debug_log("InAndOUT","最旧信号间隔--".json_encode($tail_data));
|
|
|
|
- debug_log("InAndOUT","最旧信号间隔---".json_encode($tail_data[count($tail_data)-1]));
|
|
|
|
- debug_log("InAndOUT","最旧信号间隔----".$data["report_time"]);
|
|
|
|
|
|
+ //保存朝外的信号最大值
|
|
|
|
+ $frontMax=$this->selectHash($key,$frontMaxKey);
|
|
|
|
+ //保存朝内的信号最大值
|
|
|
|
+ $backMax=$this->selectHash($key,$backMaxKey);
|
|
|
|
+ if(empty($frontMax)){
|
|
|
|
+ $frontMax=$data["rssi1"];
|
|
|
|
+ }else{
|
|
|
|
+ $frontMax=$data["rssi1"]<$frontMax?$data["rssi1"]:$frontMax;
|
|
|
|
+ }
|
|
|
|
+ if(empty($backMax)){
|
|
|
|
+ $backMax=$data["rssi2"];
|
|
|
|
+ }else{
|
|
|
|
+ $backMax=$data["rssi2"]<$backMax?$data["rssi2"]:$backMax;
|
|
|
|
+ }
|
|
|
|
+ $this->setHash($key,$frontMaxKey,$frontMax);
|
|
|
|
+ $this->setHash($key,$backMaxKey,$backMax);
|
|
|
|
+
|
|
if(!empty($tail_data)){
|
|
if(!empty($tail_data)){
|
|
if(($data["report_time"]-$tail_data[count($tail_data)-1]["report_time"])>6){
|
|
if(($data["report_time"]-$tail_data[count($tail_data)-1]["report_time"])>6){
|
|
$head_data=[];
|
|
$head_data=[];
|
|
@@ -387,7 +409,6 @@ public function set_label_history($data){
|
|
}
|
|
}
|
|
//保存尾部标签数据
|
|
//保存尾部标签数据
|
|
|
|
|
|
-
|
|
|
|
$tail_data=empty($tail_data)?[]: $tail_data;
|
|
$tail_data=empty($tail_data)?[]: $tail_data;
|
|
array_push($tail_data,$data);
|
|
array_push($tail_data,$data);
|
|
while(count($tail_data)>3){
|
|
while(count($tail_data)>3){
|
|
@@ -408,6 +429,8 @@ public function get_label_history($type,$mac,$label){
|
|
$key=$mac."_label_history";
|
|
$key=$mac."_label_history";
|
|
$head=$label."_head";
|
|
$head=$label."_head";
|
|
$tail=$label."_tail";
|
|
$tail=$label."_tail";
|
|
|
|
+ $frontMaxKey=$label.'_frontMax';
|
|
|
|
+ $backMaxKey=$label.'_backMax';
|
|
if($type==1){
|
|
if($type==1){
|
|
$head_data= $this->selectHash($key,$head);
|
|
$head_data= $this->selectHash($key,$head);
|
|
return $head_data;
|
|
return $head_data;
|
|
@@ -418,9 +441,23 @@ public function get_label_history($type,$mac,$label){
|
|
}
|
|
}
|
|
if($type==3){
|
|
if($type==3){
|
|
debug_log("InAndOUT","清空头部和尾部历史:".$mac." ".$label);
|
|
debug_log("InAndOUT","清空头部和尾部历史:".$mac." ".$label);
|
|
- $tail_data= $this->delHash($key,$head);
|
|
|
|
- $tail_data= $this->delHash($key,$tail);
|
|
|
|
|
|
+ $this->delHash($key,$head);
|
|
|
|
+ $this->delHash($key,$tail);
|
|
|
|
+ $this->delHash($key,$frontMaxKey);
|
|
|
|
+ $this->delHash($key, $backMaxKey);
|
|
|
|
+ }
|
|
|
|
+ if($type==4){
|
|
|
|
+ $frontMax= $this->selectHash($key,$frontMaxKey);
|
|
|
|
+ return $frontMax;
|
|
}
|
|
}
|
|
|
|
+ if($type==5){
|
|
|
|
+ $backMax= $this->selectHash($key,$backMaxKey);
|
|
|
|
+ return $backMax;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 二次生成进出
|
|
* 二次生成进出
|
|
@@ -471,8 +508,7 @@ public function second_create_direction($mac,$label){
|
|
$front+=1;
|
|
$front+=1;
|
|
}else{
|
|
}else{
|
|
$behind+=1;
|
|
$behind+=1;
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
$time=$item['report_time'];
|
|
$time=$item['report_time'];
|
|
}
|
|
}
|
|
$tail_dir=$front>$behind?1:2;
|
|
$tail_dir=$front>$behind?1:2;
|
|
@@ -484,11 +520,77 @@ public function second_create_direction($mac,$label){
|
|
}else{
|
|
}else{
|
|
$res=2;
|
|
$res=2;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ $frontMax= $this->get_label_history(4,$mac,$label);
|
|
|
|
+ debug_log("second_dirt","标签.$label.的最朝外的最大值".$frontMax);
|
|
|
|
+ if($frontMax>65){
|
|
|
|
+ debug_log("second_dirt","标签.$label.的最朝外的最小值大于65不参与计算");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //早上对"进寝室不做二次计算
|
|
|
|
+
|
|
|
|
+ $start_time=strtotime(date("Y-m-d",time()));
|
|
|
|
+ $end_time=$start_time+60*60*8;
|
|
|
|
+ debug_log("second_dirt","判断的时间".date("Y-m-d H:i:s",$end_time));
|
|
|
|
+ debug_log("second_dirt","判断的时间".date("Y-m-d H:i:s",$time));
|
|
|
|
+ //当天结束之间 当天早上7点之前进寝室,不做二次计算
|
|
|
|
+ if($time<$end_time&&$res==1){
|
|
|
|
+ debug_log("second_dirt","当天早上7点之前进寝室,不做二次计算");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ $befor_res= $this->get_time_results($mac,$label,2);
|
|
|
|
+
|
|
|
|
+ if(!empty($befor_res)){
|
|
|
|
+ debug_log("second_dirt","间隔时间".json_encode($befor_res));
|
|
|
|
+ if($befor_res['dir']==$res){
|
|
|
|
+ $interval_time=$time-$befor_res["time"];
|
|
|
|
+ debug_log("second_dirt","间隔时间".$interval_time);
|
|
|
|
+ debug_log("second_dirt","间隔时间第一个小时,且方向相同 不做二次计算".$interval_time);
|
|
|
|
+ if($interval_time<1*60*60){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ debug_log("second_dirt","数据为空,进行生成");
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
debug_log("second_dirt","最终结果".json_encode(["dirt"=>$res,"time"=>$time]));
|
|
debug_log("second_dirt","最终结果".json_encode(["dirt"=>$res,"time"=>$time]));
|
|
return ["dirt"=>$res,"time"=>$time];
|
|
return ["dirt"=>$res,"time"=>$time];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+/**
|
|
|
|
+ * Undocumented function 基站配置
|
|
|
|
+ *
|
|
|
|
+ * @param [type] $mac
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+public function get_station_config($mac){
|
|
|
|
+
|
|
|
|
+ $Key="station_config";
|
|
|
|
+ $mackey=$mac;
|
|
|
|
+ $data=[
|
|
|
|
+ "filter_signal"=>72,//过滤信号强度
|
|
|
|
+ "history_filter_signal"=>82,//历史记录过滤的信号强度
|
|
|
|
+ "init_data"=>3, //需要三条数据确定初始方向
|
|
|
|
+ "change_data"=>5, //需要5条数据确定变换的方向
|
|
|
|
+ "timeout"=>6,
|
|
|
|
+ "second_create_res"=>[]//二次根据历史记录生成配置 数组中的参数配置 start_time,end_time,dir 1 前 2后;
|
|
|
|
+ ];
|
|
|
|
+ $config_data=$this->selectHash($Key,$mackey);
|
|
|
|
+ if(!empty($config_data)){
|
|
|
|
+ foreach($data as $key=>$value){
|
|
|
|
+ $data[$key]=empty($config_data[$key])?$data[$key]:$config_data[$key];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $data;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -496,6 +598,45 @@ public function second_create_direction($mac,$label){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * function 设置存储结果的时间
|
|
|
|
+ *
|
|
|
|
+ * @param [type] $mac
|
|
|
|
+ * @param [type] $label
|
|
|
|
+ * @param [type] $time
|
|
|
|
+ * @param [type] $dir 进出结果
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function set_time_results($mac,$label,$time,$dir){
|
|
|
|
+ $mac_key=$mac."res_time";
|
|
|
|
+ $array=["time"=>$time,"dir"=>$dir];
|
|
|
|
+ $this->setHash($mac_key,$label,$array);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * function 获取存储结果的时间
|
|
|
|
+ *
|
|
|
|
+ * @param [type] $mac
|
|
|
|
+ * @param [type] $label
|
|
|
|
+ * @param [type] $type 类型
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function get_time_results($mac,$label,$type=1){
|
|
|
|
+ $mac_key=$mac."res_time";
|
|
|
|
+ $data=$this->selectHash($mac_key,$label);
|
|
|
|
+ if(empty($data)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if($type==1){
|
|
|
|
+ return $data["time"];
|
|
|
|
+ }else{
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//查询key hash
|
|
//查询key hash
|
|
public function selectHash($hashKey,$key){
|
|
public function selectHash($hashKey,$key){
|
|
$res= $this->redis->hGet($hashKey,$key);
|
|
$res= $this->redis->hGet($hashKey,$key);
|
|
@@ -511,11 +652,13 @@ public function second_create_direction($mac,$label){
|
|
|
|
|
|
}
|
|
}
|
|
public function delHash($hashKey,$key){
|
|
public function delHash($hashKey,$key){
|
|
- $this->redis->Hdel($hashKey,$key);
|
|
|
|
|
|
+ $this->redis->hDel($hashKey,$key);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
public function temporary_label($redis,$label,$type){
|
|
public function temporary_label($redis,$label,$type){
|
|
-
|
|
|
|
|
|
+
|
|
return;
|
|
return;
|
|
$key="temporary_label";
|
|
$key="temporary_label";
|
|
if($type==1){
|
|
if($type==1){
|
|
@@ -532,7 +675,7 @@ public function second_create_direction($mac,$label){
|
|
* 解析日志
|
|
* 解析日志
|
|
*/
|
|
*/
|
|
public function analysisLog(){
|
|
public function analysisLog(){
|
|
- $path=app()->getRootPath()."runtime/log/2023-05-15/label_log.log";
|
|
|
|
|
|
+ $path=app()->getRootPath()."runtime/log/2023-05-28/label_log.log";
|
|
var_dump($path);
|
|
var_dump($path);
|
|
var_dump(is_file($path));
|
|
var_dump(is_file($path));
|
|
$file = fopen($path, "rb");
|
|
$file = fopen($path, "rb");
|
|
@@ -563,8 +706,6 @@ public function second_create_direction($mac,$label){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
foreach($array as $item){
|
|
foreach($array as $item){
|
|
debug_log("in_label",$item);
|
|
debug_log("in_label",$item);
|
|
}
|
|
}
|
|
@@ -574,7 +715,7 @@ public function second_create_direction($mac,$label){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|