Vehicle.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace catchAdmin\yunying\controller;
  3. use catcher\base\CatchRequest as Request;
  4. use catcher\CatchResponse;
  5. use catcher\base\CatchController;
  6. use catchAdmin\yunying\model\Vehicle as vehicleModel;
  7. use catcher\library\excel\Excel;
  8. use catchAdmin\yunying\excel\VehiclesExport;
  9. use catcher\Utils;
  10. class Vehicle extends CatchController
  11. {
  12. protected $vehicleModel;
  13. public function __construct(VehicleModel $vehicleModel)
  14. {
  15. $this->vehicleModel = $vehicleModel;
  16. }
  17. /**
  18. * 列表
  19. * @time 2022年01月20日 10:42
  20. * @param Request $request
  21. */
  22. public function index(Request $request) : \think\Response
  23. {
  24. $field = $request->get('field')?:'id';
  25. $order = $request->get('order')?:'desc';
  26. return CatchResponse::paginate($this->vehicleModel->getVehicleList($field,$order));
  27. }
  28. public function getVehicleListOracle(Request $request)
  29. {
  30. $param=$request->param();
  31. //联表条件o.rfid_id = s.id and o.owner_id = r.id
  32. $cond=[
  33. '_string'=>'o.rfid_id = s.id and o.owner_id = r.id ',
  34. ];
  35. if($param['PLATE_NO']){
  36. $cond['o.PLATE_NO']=['like',$param['PLATE_NO']];
  37. }
  38. if($param['ID_CARD_NUMBER']){
  39. $cond['r.ID_CARD_NUMBER']=['like',$param['ID_CARD_NUMBER']];
  40. }
  41. if($param['MOBILE_NUMBER']){
  42. $cond['r.MOBILE_NUMBER']=['like',$param['MOBILE_NUMBER']];
  43. }
  44. if($param['RFID_SN']){
  45. $cond['s.RFID_SN']=['like',$param['RFID_SN']];
  46. }
  47. $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond);
  48. $cond['page']=isset($param['page'])?$param['page']:1;
  49. $cond['limit']=isset($param['limit'])?$param['limit']:10;
  50. $rows=queryOracleSelect('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond,'o.PLATE_NO,s.RFID_SN,r. NAME,r.ID_CARD_NUMBER,r.MOBILE_NUMBER,r.HOME_ADDRESS');
  51. // foreach($rows as &$val){
  52. // // $val['DEVICE_NAME'] = mb_convert_encoding($val['DEVICE_NAME'], 'UTF-8', 'GBK');
  53. // $val['IS_ONLINE_TEXT']=$val['IS_ONLINE']?'在线':'离线';
  54. // // $val['UPDATE_DATE'] = mb_convert_encoding($val['UPDATE_DATE'], 'UTF-8', 'GBK');
  55. // // $val['CREATE_DATE'] = mb_convert_encoding($val['CREATE_DATE'], 'UTF-8', 'GBK');
  56. // $findCond=[
  57. // 'DEVICE_CODE'=>['=',$val['DEVICE_CODE']]
  58. // ];
  59. // $info=queryOracleFind('DSSC2.ADM_DEV_RFID_CHN',$findCond);
  60. // $val['longitude']=$info['GPS_X'];
  61. // $val['latitude']=$info['GPS_Y'];
  62. // }
  63. $response=[
  64. 'code'=>10000,
  65. 'message'=>'查询成功',
  66. 'count'=>$count,
  67. 'data'=>$rows,
  68. 'current'=>isset($param['page'])?(int)$param['page']:1,
  69. 'limit'=>isset($param['limit'])?(int)$param['limit']:10,
  70. ];
  71. return $response;
  72. }
  73. /**
  74. * 保存信息
  75. * @time 2022年01月20日 10:42
  76. * @param Request $request
  77. */
  78. public function save(Request $request) : \think\Response
  79. {
  80. return CatchResponse::success($this->vehicleModel->storeBy($request->post()));
  81. }
  82. /**
  83. * 读取
  84. * @time 2022年01月20日 10:42
  85. * @param $id
  86. */
  87. public function read($id) : \think\Response
  88. {
  89. return CatchResponse::success($this->vehicleModel->findBy($id));
  90. }
  91. /**
  92. * 更新
  93. * @time 2022年01月20日 10:42
  94. * @param Request $request
  95. * @param $id
  96. */
  97. public function update(Request $request, $id) : \think\Response
  98. {
  99. return CatchResponse::success($this->vehicleModel->updateBy($id, $request->post()));
  100. }
  101. /**
  102. * 删除
  103. * @time 2022年01月20日 10:42
  104. * @param $id
  105. */
  106. public function delete($id) : \think\Response
  107. {
  108. return CatchResponse::success($this->vehicleModel->deleteBy($id));
  109. }
  110. /**
  111. * 导出
  112. *
  113. * @time 2022年01月22日
  114. * @param Excel $excel
  115. * @param VehicleExport $vehicleExport
  116. * @throws \PhpOffice\PhpSpreadsheet\Exception
  117. * @return \think\response\Json
  118. */
  119. public function export_vehicle(Excel $excel, VehiclesExport $VehicleExport)
  120. {
  121. // var_dump(Utils::publicPath('export/users'));//导出路径
  122. return CatchResponse::success($excel->save($VehicleExport, Utils::publicPath('export/vehicles'), 'local', '车辆列表'));
  123. }
  124. }