|
@@ -8,6 +8,7 @@ use catcher\base\CatchModel as Model;
|
|
|
use catchAdmin\permissions\model\DataRangScopeTrait;
|
|
|
use catchAdmin\device\model\get\StationGet;
|
|
|
use think\facade\Db;
|
|
|
+use think\facade\Env;
|
|
|
class Station extends Model
|
|
|
{
|
|
|
use DataRangScopeTrait;
|
|
@@ -130,9 +131,17 @@ class Station extends Model
|
|
|
public function searchOnlineStateAttr($query, $value, $data)
|
|
|
{
|
|
|
$time=date('Y-m-d H:i:s',time()-300);
|
|
|
+ $config=Env::get('app.station_state');
|
|
|
+
|
|
|
if($value=='1'){
|
|
|
+ if(!$config){
|
|
|
+ return $query->where('online_state', 1)->whereOr('online_state','null');
|
|
|
+ }
|
|
|
return $query->where('online_time', '>=', $time)->whereOr('online_state','=', 1);
|
|
|
}elseif($value=='2'){
|
|
|
+ if(!$config){
|
|
|
+ return $query->where('online_state',2);
|
|
|
+ }
|
|
|
return $query->where(function ($query) use( $time) {
|
|
|
$query->whereOr('online_time','<', $time)->whereOr('online_time','=', null);
|
|
|
});
|