tongshanglei 2 years ago
parent
commit
d25865b90d

+ 76 - 44
catch/device/controller/Station.php

@@ -6,6 +6,7 @@ use catcher\base\CatchRequest as Request;
 use catcher\CatchResponse;
 use catcher\base\CatchController;
 use catchAdmin\device\model\Station as stationModel;
+use catchAdmin\device\model\RfRecord as rfRecordModel;
 use catchAdmin\device\model\StationPhoto;
 use catcher\Utils;
 use catcher\library\excel\Excel;
@@ -16,10 +17,12 @@ use PDO;
 class Station extends CatchController
 {
     protected $stationModel;
+    protected $rfRecordModel;
     
-    public function __construct(StationModel $stationModel)
+    public function __construct(StationModel $stationModel,rfRecordModel $rfRecordModel)
     {
         $this->stationModel = $stationModel;
+        $this->rfRecordModel = $rfRecordModel;
     }
     
     /**
@@ -29,54 +32,65 @@ class Station extends CatchController
      */
     public function index(Request $request) 
     {
-        // header('Content-Type: text/html; charset=utf-8');
-        // header('Content-Type: text/html; charset=gb2312');
-            $param=$request->param();
-            // var_dump($param);
-            $cond=[];
-            if($param['shortcode']){
-                $cond['DEVICE_CODE']=['like',$param['shortcode']];
-            }
-            if($param['name']){
-                $param['name'] = mb_convert_encoding($param['name'],  'GBK','UTF-8');
-                $cond['DEVICE_NAME']=['like',$param['name']];
-            }
-            $count=queryOracleCount('DSSC2.ADM_DEV',$cond);
+        $field = $request->get('field')?:'id';
+        $order = $request->get('order')?:'desc';
+        $where=[];
+        $param=$request->param();
+        if($param['shortcode']){
+            $where[]=['a.DEVICE_CODE','like','%'.$param['shortcode'].'%'];
+        }
+        if($param['name']){
+            $where[]=['a.DEVICE_NAME','like','%'.$param['name'].'%'];
+        }
+
+        return CatchResponse::paginate($this->stationModel->getStationList($field,$order,$where));
+            // $param=$request->param();
+            // // var_dump($param);
+            // $cond=[];
+            // if($param['shortcode']){
+            //     $cond['DEVICE_CODE']=['like',$param['shortcode']];
+            // }
+            // if($param['name']){
+            //     $param['name'] = mb_convert_encoding($param['name'],  'GBK','UTF-8');
+            //     $cond['DEVICE_NAME']=['like',$param['name']];
+            // }
+            // $count=queryOracleCount('DSSC2.ADM_DEV',$cond);
 
-            $cond['page']=isset($param['page'])?$param['page']:1;
-            $cond['limit']=isset($param['limit'])?$param['limit']:10;
-            $rows=queryOracleSelect('DSSC2.ADM_DEV',$cond,'a.ID,a.IS_ONLINE,a.LOGIN_NAME,a.DEVICE_CODE,a.DEVICE_NAME,a.OWNER_CODE,a.DEVICE_IP,a.DEVICE_PORT,to_char(a.UPDATE_DATE,\'yyyy-mm-dd hh24:mi:ss\') UPDATE_DATE');
+            // $cond['page']=isset($param['page'])?$param['page']:1;
+            // $cond['limit']=isset($param['limit'])?$param['limit']:10;
+            // $rows=queryOracleSelect('DSSC2.ADM_DEV',$cond,'a.ID,a.IS_ONLINE,a.LOGIN_NAME,a.DEVICE_CODE,a.DEVICE_NAME,a.OWNER_CODE,a.DEVICE_IP,a.DEVICE_PORT,to_char(a.UPDATE_DATE,\'yyyy-mm-dd hh24:mi:ss\') UPDATE_DATE');
             
             
-            foreach($rows as &$val){
-                $val['DEVICE_NAME'] = mb_convert_encoding($val['DEVICE_NAME'], 'UTF-8', 'GBK');
-                $val['IS_ONLINE_TEXT']=$val['IS_ONLINE']?'在线':'离线';
-                // $val['UPDATE_DATE'] = mb_convert_encoding($val['UPDATE_DATE'], 'UTF-8', 'GBK');
-                // $val['CREATE_DATE'] = mb_convert_encoding($val['CREATE_DATE'], 'UTF-8', 'GBK');
-                $findCond=[
-                    'DEVICE_CODE'=>['=',$val['DEVICE_CODE']]
-                ];
-                $info=queryOracleFind('DSSC2.ADM_DEV_RFID_CHN',$findCond);
-                $val['longitude']=$info['GPS_X'];
-                $val['latitude']=$info['GPS_Y'];
+            // foreach($rows as &$val){
+            //     $val['DEVICE_NAME'] = mb_convert_encoding($val['DEVICE_NAME'], 'UTF-8', 'GBK');
+            //     $val['IS_ONLINE_TEXT']=$val['IS_ONLINE']?'在线':'离线';
+            //     // $val['UPDATE_DATE'] = mb_convert_encoding($val['UPDATE_DATE'], 'UTF-8', 'GBK');
+            //     // $val['CREATE_DATE'] = mb_convert_encoding($val['CREATE_DATE'], 'UTF-8', 'GBK');
+            //     $findCond=[
+            //         'DEVICE_CODE'=>['=',$val['DEVICE_CODE']]
+            //     ];
+            //     $info=queryOracleFind('DSSC2.ADM_DEV_RFID_CHN',$findCond);
+            //     $val['longitude']=$info['GPS_X'];
+            //     $val['latitude']=$info['GPS_Y'];
                
-            }
+            // }
             
-            $response=[
-                'code'=>10000,
-                'message'=>'查询成功',
-                'count'=>$count,
-                'data'=>$rows,
-                'current'=>isset($param['page'])?(int)$param['page']:1,
-                'limit'=>isset($param['limit'])?(int)$param['limit']:10,
-            ];
-            return $response;
-        // $field = $request->get('field')?:'id';
-        // $order = $request->get('order')?:'desc';
-        // return CatchResponse::paginate($this->stationModel->getStationList($field,$order));
+            // $response=[
+            //     'code'=>10000,
+            //     'message'=>'查询成功',
+            //     'count'=>$count,
+            //     'data'=>$rows,
+            //     'current'=>isset($param['page'])?(int)$param['page']:1,
+            //     'limit'=>isset($param['limit'])?(int)$param['limit']:10,
+            // ];
+            // return $response;
+       
     }
     
     public function getdeviceListByStation(Request $request){
+       
+      
+
         $params=$request->param();
         if(!$params['station_code']){
             return CatchResponse::success('');
@@ -98,9 +112,6 @@ class Station extends CatchController
         $cond['page']=isset($param['page'])?$param['page']:1;
         $cond['limit']=isset($param['limit'])?$param['limit']:10;
         $rows=queryOracleSelect('DSSC2.W_DW_RF_RECORD',$cond,'a.RF_FLAGID,a.RF_STAT,to_char(a.RF_DATE,\'yyyy-mm-dd hh24:mi:ss\') RF_DATE');
-        foreach($rows as &$val){
-            $val['RF_DATE'] = mb_convert_encoding($val['RF_DATE'], 'UTF-8', 'GBK');
-        }
         $response=[
             'code'=>10000,
             'message'=>'查询成功',
@@ -110,6 +121,27 @@ class Station extends CatchController
             'limit'=>isset($params['limit'])?(int)$params['limit']:10,
         ];
         return $response;
+
+
+        // $cond=[];
+        // $params=$request->param();
+        //   if(!$params['station_code']){
+        //     return CatchResponse::success('');
+        // }
+        // if($params['station_code']){
+        //     $cond[]=['RF_ID','=',$params['station_code']];
+        // }
+        // $start_time = date('Y-m-d 00:00:00',time());
+        // $end_time = date('Y-m-d 23:59:59',time());
+
+        // if(isset($params['timeRange']) && $params['timeRange'] != ''){
+        //     $start_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][0]));
+        //     $end_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][1]));
+        //     $cond[]=['RF_DATE','between',[$start_time,$end_time]];
+        // }
+        // $list=$this->rfRecordModel->getList($cond);
+        
+        // return CatchResponse::paginate($list);
    
     }
     /**

+ 34 - 0
catch/device/model/RfRecord.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace catchAdmin\device\model;
+
+use \think\Model as Model;
+
+// use catchAdmin\permissions\model\DataRangScopeTrait;
+
+use think\facade\Db;
+class RfRecord extends Model
+{
+    // use DataRangScopeTrait;
+
+    protected $connection = 'oracle';
+    // 表名
+    public $name = 'dssc2.w_dw_rf_record';
+    // 数据库字段映射
+    public $field = array( );
+     /**
+     * 获取基站列表
+     */
+    public function getList()
+    {
+        $res =  $this
+   
+        ->field('a.RF_FLAGID,a.RF_STAT,to_char(a.RF_DATE,\'yyyy-mm-dd hh24:mi:ss\') RF_DATE')
+        ->paginate();
+           
+        // var_dump($this->getLastSql());
+        return $res;
+    }
+   
+    
+}

+ 19 - 61
catch/device/model/Station.php

@@ -2,82 +2,40 @@
 
 namespace catchAdmin\device\model;
 
-use catcher\base\CatchModel as Model;
+use \think\Model as Model;
+
 use catchAdmin\permissions\model\DataRangScopeTrait;
 use catchAdmin\device\model\get\StationGet;
+use think\facade\Db;
 class Station extends Model
 {
     use DataRangScopeTrait;
     use StationGet;
-    // protected $connection = 'oracle';
+    protected $connection = 'oracle';
     // 表名
-    public $name = 'stations';
+    public $name = 'dssc2.adm_dev';
     // 数据库字段映射
     public $field = array(
-        'id',
-        // 基站Mac
-        'mac',
-        // 基站简码
-        'shortcode',
-        // 基站名称
-        'name',
-        // 基站型号
-        'model',
-        // 基站序列号
-        'serial_number',
-        // 所属部门
-        'department_id',
-        // 版本号
-        'version',
-        // 开局状态
-        'open_status',
-        // SIM卡号
-        'sim_no',
-        // 经度
-        'longitude',
-        // 纬度
-        'latitude',
-        // 在线时间
-        'online_time',
-        // 安装地址
-        'address',
-        // 备注
-        'remark',
-        // 开局时间
-        'open_time',
-        // 开局用户
-        'open_user_id',
-        // 创建人ID
-        'creator_id',
-        // 创建时间
-        'created_at',
-        // 更新时间
-        'updated_at',
-        // 软删除
-        'deleted_at',
+        
     );
      /**
      * 获取基站列表
      */
-    public function getStationList($field, $order)
+    public function getStationList($field, $order,$where=[])
     {
-        $res =  $this->dataRange()
-           
-            ->append(['depart_name', 'net_state', 'open_user_name', 'creator_name', 'model_text'])
-            ->order($this->aliasField($field), $order)
+        $res =  $this
+            // ->dataRange()
+            // ->catchSearch()
+            ->where($where)
+            ->alias('a')
+            ->join('dssc2.adm_dev_rfid_chn n','a.DEVICE_CODE=n.DEVICE_CODE')
+            ->field('a.ID,a.IS_ONLINE,a.LOGIN_NAME,a.DEVICE_CODE,a.DEVICE_NAME,a.OWNER_CODE,a.DEVICE_IP,a.DEVICE_PORT,to_char(a.UPDATE_DATE,\'yyyy-mm-dd hh24:mi:ss\') UPDATE_DATE,n.GPS_X as longitude,n.GPS_Y as latitude')
+            // ->append(['depart_name', 'net_state', 'open_user_name', 'creator_name', 'model_text'])
+            // ->order($this->aliasField($field), $order)
             ->paginate();
+            // var_dump($this->getLastSql());
         return $res;
     }
-    /**
-     * 获取基站导出列表
-     */
-    public function getStationExportList()
-    {
-        $res =  $this->dataRange()
-            ->catchSearch()
-            ->append(['depart_name', 'net_state','open_user_name', 'creator_name', 'model_text'])
-            ->order($this->aliasField('id'), 'desc')
-            ->select();
-        return $res;
-    }
+  
+    
 }

+ 5 - 47
catch/device/model/search/DeviceSearch.php

@@ -11,59 +11,17 @@ trait DeviceSearch
       /**
      * 根据部门搜索
      */
-    public function searchDepartmentIdAttr($query, $value, $data)
+    public function searchNameAttr($query, $value, $data)
     {
-        if ($value) {
-            $id = end($value);
-            return $query->where('department_id', '=', $id);
-        }
+        return $query->where('DEVICE_NAME', 'like', '%'.$value.'%');
     }
      /**
      * 根据imei搜索
      */
-    public function searchImeiAttr($query, $value, $data)
+    public function searchShortCodeAttr($query, $value, $data)
     {
-            return $query->where('imei', 'like', '%'.$value.'%');
-    }
-    /**
-     * iccid
-     */
-    public function searchIccidAttr($query, $value, $data)
-    {
-            return $query->where('iccid', 'like', '%'.$value.'%');
-    }
-     /**
-     * 根据rfid搜索
-     */
-    public function searchRfidAttr($query, $value, $data)
-    {
-            return $query->where('rfid', 'like', '%'.$value.'%');
-    }
-     /**
-     * 根据设备状态搜索
-     */
-    public function searchDeviceStateAttr($query, $value, $data)
-    {
-            if($value){
-                return $query->where('bind_id', '<>', 0);
-            }else{
-                return $query->where('bind_id', '=', 0); 
-            }
-            
-    }
-     /**
-     * 根据用户搜索
-     */
-    public function searchUserIdAttr($query, $value, $data)
-    {
-            return $query->where('user_id', '=', $value);
-    }
-    /**
-     * 设备号
-     */
-    public function searchDeviceNumberAttr($query, $value, $data)
-    {
-        return $query->where('imei|rfid', 'like', '%'. $value . '%');
+            return $query->where('DEVICE_CODE', 'like', '%'.$value.'%');
     }
+
     
 }

+ 2 - 1
catch/report/controller/Report.php

@@ -24,7 +24,8 @@ class Report extends CatchController
     public function homePageCountData(Request $request)
     {
         // 基站数据
-        $station_data = $this->reportModel->getStationCountData() ?: [];
+        // $station_data = $this->reportModel->getStationCountData() ?: [];
+        $station_data =[];
         // 部门数据
         // $department_data = $this->reportModel->getDepartmentCountData() ?: [];
         // 用户数据