tongshanglei 2 years ago
parent
commit
9d654513ed
1 changed files with 28 additions and 1 deletions
  1. 28 1
      catch/device/model/get/StationGet.php

+ 28 - 1
catch/device/model/get/StationGet.php

@@ -5,7 +5,7 @@ namespace catchAdmin\device\model\get;
 use catchAdmin\permissions\model\SysConfig;
 use catchAdmin\system\model\SysDictData;
 use think\facade\Db;
-
+use think\facade\Env;
 trait StationGet
 {
     /**
@@ -21,7 +21,15 @@ 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';
         }
@@ -35,6 +43,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,6 +62,16 @@ 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 '在线';
         }