123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace catchAdmin\yunying\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\yunying\model\Vehicle as vehicleModel;
- use catcher\library\excel\Excel;
- use catchAdmin\yunying\excel\VehiclesExport;
- use catcher\Utils;
- class Vehicle extends CatchController
- {
- protected $vehicleModel;
-
- public function __construct(VehicleModel $vehicleModel)
- {
- $this->vehicleModel = $vehicleModel;
- }
-
- /**
- * 列表
- * @time 2022年01月20日 10:42
- * @param Request $request
- */
- public function index(Request $request) : \think\Response
- {
- $field = $request->get('field')?:'id';
- $order = $request->get('order')?:'desc';
- return CatchResponse::paginate($this->vehicleModel->getVehicleList($field,$order));
- }
-
- public function getVehicleListOracle(Request $request)
- {
- $param=$request->param();
- //联表条件o.rfid_id = s.id and o.owner_id = r.id
- $cond=[
- '_string'=>'o.rfid_id = s.id and o.owner_id = r.id ',
- ];
- if($param['PLATE_NO']){
- $cond['o.PLATE_NO']=['like',$param['PLATE_NO']];
- }
- if($param['ID_CARD_NUMBER']){
- $cond['r.ID_CARD_NUMBER']=['like',$param['ID_CARD_NUMBER']];
- }
- if($param['MOBILE_NUMBER']){
- $cond['r.MOBILE_NUMBER']=['like',$param['MOBILE_NUMBER']];
- }
- if($param['RFID_SN']){
- $cond['s.RFID_SN']=['like',$param['RFID_SN']];
- }
- $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond);
- $cond['page']=isset($param['page'])?$param['page']:1;
- $cond['limit']=isset($param['limit'])?$param['limit']:10;
- $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');
-
- // 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;
- }
- /**
- * 保存信息
- * @time 2022年01月20日 10:42
- * @param Request $request
- */
- public function save(Request $request) : \think\Response
- {
- return CatchResponse::success($this->vehicleModel->storeBy($request->post()));
- }
-
- /**
- * 读取
- * @time 2022年01月20日 10:42
- * @param $id
- */
- public function read($id) : \think\Response
- {
- return CatchResponse::success($this->vehicleModel->findBy($id));
- }
-
- /**
- * 更新
- * @time 2022年01月20日 10:42
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id) : \think\Response
- {
- return CatchResponse::success($this->vehicleModel->updateBy($id, $request->post()));
- }
-
- /**
- * 删除
- * @time 2022年01月20日 10:42
- * @param $id
- */
- public function delete($id) : \think\Response
- {
- return CatchResponse::success($this->vehicleModel->deleteBy($id));
- }
- /**
- * 导出
- *
- * @time 2022年01月22日
- * @param Excel $excel
- * @param VehicleExport $vehicleExport
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @return \think\response\Json
- */
- public function export_vehicle(Excel $excel, VehiclesExport $VehicleExport)
- {
- // var_dump(Utils::publicPath('export/users'));//导出路径
- return CatchResponse::success($excel->save($VehicleExport, Utils::publicPath('export/vehicles'), 'local', '车辆列表'));
- }
- }
|