123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace catchAdmin\device\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- // use catchAdmin\device\model\RfRecord as rfRecordModel;
- // use catchAdmin\device\model\StationPhoto;
- // use catcher\Utils;
- // use catcher\library\excel\Excel;
- // use PhpOffice\PhpSpreadsheet\IOFactory;
- use think\facade\Db;
- use PDO;
- class Station extends CatchController
- {
- // protected $stationModel;
- // protected $rfRecordModel;
-
- // public function __construct(rfRecordModel $rfRecordModel)
- // {
- // $this->rfRecordModel = $rfRecordModel;
- // }
-
- /**
- * 列表
- * @time 2022年01月20日 10:09
- * @param Request $request
- */
- public function index(Request $request)
- {
- // $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');
-
-
- 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;
-
- }
-
- public function getdeviceListByStation(Request $request){
-
-
- $params=$request->param();
- if(!$params['station_code']){
- return CatchResponse::success('');
- }
- $cond=[];
- 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']=['timeRange',$start_time,$end_time];
- }
- $count=queryOracleCount('DSSC2.W_DW_RF_RECORD',$cond);
- $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){
- //状态: 0- 未知,1 - 进入,2 - 离开
- if($val['RF_STAT']==1){
- $val['RF_STAT_TEXT']='进入';
- }elseif($val['RF_STAT']==2){
- $val['RF_STAT_TEXT']='离开';
- }else{
- $val['RF_STAT_TEXT']='未知';
- }
- }
- $response=[
- 'code'=>10000,
- 'message'=>'查询成功',
- 'count'=>$count,
- 'data'=>$rows,
- 'current'=>isset($params['page'])?(int)$params['page']:1,
- '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);
-
- }
-
- }
|