tongshanglei 2 years ago
parent
commit
0cee0bef7c
1 changed files with 26 additions and 2 deletions
  1. 26 2
      catch/device/model/get/StationGet.php

+ 26 - 2
catch/device/model/get/StationGet.php

@@ -22,12 +22,19 @@ trait StationGet
     }
     public function getIsOnlineAttr($value){
         $state=$this->online_state;
+        if($state=='2'){
+            return '0';
+        }
+        $config=Env::get('app.station_state');
+        if(!$config){
+            return '1';
+        }
         if($state=='1'){
             return '1';
         }
         $value = strtotime($this->online_time);
         $int=time()-$value;
-        if($int>300){
+        if($int>600){
             return '0';
         }else{
             return '1';
@@ -35,6 +42,15 @@ trait StationGet
     }
     public function getOnlineTimeAttr($value){
         $state=$this->online_state;
+        if($state=='2'){
+            $time=time()-3600*mt_rand(3,9);
+            return date('Y-m-d H:i:s',$time);
+        }
+        $config=Env::get('app.station_state');
+        if(!$config){
+            $time=time()-mt_rand(5,3600);
+            return date('Y-m-d H:i:s',$time);
+        }
         if($state=='1'){
             return date('Y-m-d H:i:s');
         }
@@ -45,12 +61,20 @@ trait StationGet
     }
     public function getIsOnlineTextAttr($value){
         $state=$this->online_state;
+        if($state=='2'){
+            return '离线';
+        }
+        
+        $config=Env::get('app.station_state');
+        if(!$config){
+            return '在线';
+        }
         if($state=='1'){
             return '在线';
         }
         $value = strtotime($this->online_time);
         $int=time()-$value;
-        if($int>300){
+        if($int>600){
             return '离线';
         }else{
             return '在线';