Station.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace catchAdmin\device\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. // use catchAdmin\device\model\RfRecord as rfRecordModel;
  7. // use catchAdmin\device\model\StationPhoto;
  8. // use catcher\Utils;
  9. // use catcher\library\excel\Excel;
  10. // use PhpOffice\PhpSpreadsheet\IOFactory;
  11. use think\facade\Db;
  12. use PDO;
  13. class Station extends CatchController
  14. {
  15. // protected $stationModel;
  16. // protected $rfRecordModel;
  17. // public function __construct(rfRecordModel $rfRecordModel)
  18. // {
  19. // $this->rfRecordModel = $rfRecordModel;
  20. // }
  21. /**
  22. * 列表
  23. * @time 2022年01月20日 10:09
  24. * @param Request $request
  25. */
  26. public function index(Request $request)
  27. {
  28. // $field = $request->get('field')?:'id';
  29. // $order = $request->get('order')?:'desc';
  30. // $where=[];
  31. // $param=$request->param();
  32. // if($param['shortcode']){
  33. // $where[]=['a.DEVICE_CODE','like','%'.$param['shortcode'].'%'];
  34. // }
  35. // if($param['name']){
  36. // $where[]=['a.DEVICE_NAME','like','%'.$param['name'].'%'];
  37. // }
  38. // return CatchResponse::paginate($this->stationModel->getStationList($field,$order,$where));
  39. $param=$request->param();
  40. // var_dump($param);
  41. $cond=[];
  42. if($param['shortcode']){
  43. $cond['DEVICE_CODE']=['like',$param['shortcode']];
  44. }
  45. if($param['name']){
  46. // $param['name'] = mb_convert_encoding($param['name'], 'GBK','UTF-8');
  47. $cond['DEVICE_NAME']=['like',$param['name']];
  48. }
  49. $count=queryOracleCount('DSSC2.ADM_DEV',$cond);
  50. $cond['page']=isset($param['page'])?$param['page']:1;
  51. $cond['limit']=isset($param['limit'])?$param['limit']:10;
  52. $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');
  53. foreach($rows as &$val){
  54. // $val['DEVICE_NAME'] = mb_convert_encoding($val['DEVICE_NAME'], 'UTF-8', 'GBK');
  55. $val['IS_ONLINE_TEXT']=$val['IS_ONLINE']?'在线':'离线';
  56. // $val['UPDATE_DATE'] = mb_convert_encoding($val['UPDATE_DATE'], 'UTF-8', 'GBK');
  57. // $val['CREATE_DATE'] = mb_convert_encoding($val['CREATE_DATE'], 'UTF-8', 'GBK');
  58. $findCond=[
  59. 'DEVICE_CODE'=>['=',$val['DEVICE_CODE']]
  60. ];
  61. $info=queryOracleFind('DSSC2.ADM_DEV_RFID_CHN',$findCond);
  62. $val['longitude']=$info['GPS_X'];
  63. $val['latitude']=$info['GPS_Y'];
  64. }
  65. $response=[
  66. 'code'=>10000,
  67. 'message'=>'查询成功',
  68. 'count'=>$count,
  69. 'data'=>$rows,
  70. 'current'=>isset($param['page'])?(int)$param['page']:1,
  71. 'limit'=>isset($param['limit'])?(int)$param['limit']:10,
  72. ];
  73. return $response;
  74. }
  75. public function getdeviceListByStation(Request $request){
  76. $params=$request->param();
  77. if(!$params['station_code']){
  78. return CatchResponse::success('');
  79. }
  80. $cond=[];
  81. if($params['station_code']){
  82. $cond['RF_ID']=['=',$params['station_code']];
  83. }
  84. $start_time = date('Y-m-d 00:00:00',time());
  85. $end_time = date('Y-m-d 23:59:59',time());
  86. if(isset($params['timeRange']) && $params['timeRange'] != ''){
  87. $start_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][0]));
  88. $end_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][1]));
  89. $cond['RF_DATE']=['timeRange',$start_time,$end_time];
  90. }
  91. $count=queryOracleCount('DSSC2.W_DW_RF_RECORD',$cond);
  92. $cond['page']=isset($param['page'])?$param['page']:1;
  93. $cond['limit']=isset($param['limit'])?$param['limit']:10;
  94. $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');
  95. foreach($rows as &$val){
  96. //状态: 0- 未知,1 - 进入,2 - 离开
  97. if($val['RF_STAT']==1){
  98. $val['RF_STAT_TEXT']='进入';
  99. }elseif($val['RF_STAT']==2){
  100. $val['RF_STAT_TEXT']='离开';
  101. }else{
  102. $val['RF_STAT_TEXT']='未知';
  103. }
  104. }
  105. $response=[
  106. 'code'=>10000,
  107. 'message'=>'查询成功',
  108. 'count'=>$count,
  109. 'data'=>$rows,
  110. 'current'=>isset($params['page'])?(int)$params['page']:1,
  111. 'limit'=>isset($params['limit'])?(int)$params['limit']:10,
  112. ];
  113. return $response;
  114. // $cond=[];
  115. // $params=$request->param();
  116. // if(!$params['station_code']){
  117. // return CatchResponse::success('');
  118. // }
  119. // if($params['station_code']){
  120. // $cond[]=['RF_ID','=',$params['station_code']];
  121. // }
  122. // $start_time = date('Y-m-d 00:00:00',time());
  123. // $end_time = date('Y-m-d 23:59:59',time());
  124. // if(isset($params['timeRange']) && $params['timeRange'] != ''){
  125. // $start_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][0]));
  126. // $end_time=date('Y-m-d H:i:s',strtotime($params['timeRange'][1]));
  127. // $cond[]=['RF_DATE','between',[$start_time,$end_time]];
  128. // }
  129. // $list=$this->rfRecordModel->getList($cond);
  130. // return CatchResponse::paginate($list);
  131. }
  132. }