2023-08-16 09:01:26 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | author: likeadminTeam
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
2023-08-16 14:10:41 +08:00
|
|
|
|
use app\api\logic\GpsLogic;
|
2023-08-16 09:01:26 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 文章管理
|
|
|
|
|
* Class ArticleController
|
|
|
|
|
* @package app\api\controller
|
|
|
|
|
*/
|
|
|
|
|
class GpsController extends BaseApiController
|
|
|
|
|
{
|
2023-08-16 14:10:41 +08:00
|
|
|
|
public array $notNeedLogin = ['getCarInfo','getCarStatus','getCarHistory','test'];
|
2023-08-16 09:01:26 +08:00
|
|
|
|
|
|
|
|
|
public function getCarInfo() {
|
2023-08-17 11:30:23 +08:00
|
|
|
|
//获取参数
|
|
|
|
|
$params = $this -> request -> get('imei');
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($params)) return $this->fail('参数错误');
|
|
|
|
|
//获取数据
|
|
|
|
|
$result = (new GpsLogic()) -> info($params);
|
2023-08-16 14:10:41 +08:00
|
|
|
|
return $result['code'] == 1 ? $this->success($result['msg'],$result['data']) : $this->fail($result['msg']);
|
2023-08-16 09:01:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCarStatus() {
|
2023-08-16 14:10:41 +08:00
|
|
|
|
$result = (new GpsLogic()) -> status();
|
|
|
|
|
return $result['code'] == 1 ? $this->success($result['msg'],$result['data']) : $this->fail($result['msg']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCarHistory() {
|
|
|
|
|
//获取参数
|
|
|
|
|
$params = $this->request->get(['car_id','start_time','end_time']);
|
|
|
|
|
//验证参数
|
|
|
|
|
if(empty($params['car_id']) || empty($params['start_time']) || empty($params['end_time'])){
|
|
|
|
|
return $this->fail('参数错误');
|
|
|
|
|
}
|
|
|
|
|
//获取车辆行驶历史信息
|
|
|
|
|
$result = (new GpsLogic()) -> history($params);
|
|
|
|
|
if($result['code'] == 1){
|
|
|
|
|
$data = [];
|
|
|
|
|
foreach ($result['data'] as $k => $v) {
|
|
|
|
|
$data[$k]['lat'] = $v['latc'];
|
|
|
|
|
$data[$k]['lon'] = $v['lonc'];
|
|
|
|
|
}
|
|
|
|
|
return $this->success($result['msg'],$data);
|
|
|
|
|
}else{
|
|
|
|
|
return $this->fail($result['msg']);
|
|
|
|
|
}
|
2023-08-16 09:01:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-16 14:10:41 +08:00
|
|
|
|
public function test() {
|
2023-08-17 11:30:23 +08:00
|
|
|
|
$res = push_message('170976fa8b98aae6535','这是条测试信息');
|
2023-08-16 15:00:35 +08:00
|
|
|
|
dump($res);
|
2023-08-16 14:10:41 +08:00
|
|
|
|
return !($res['code'] == 0);
|
2023-08-16 09:01:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|