From 56d848d0cc23f19dfd2521aa4d8b2882825d27ef Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:36:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2=E9=A3=9E=E6=9C=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=87=BD=E6=95=B0?= =?UTF-8?q?=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20?= =?UTF-8?q?=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlaneController.class.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 7fd695e..0bf206b 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -723,4 +723,67 @@ class PlaneController extends PublicController echo json_encode(array('status' => 0, 'msg' => '登录异常')); } } + /** + * @description 获取指定飞机组的飞行数据(按时间戳) + */ + public function getFlyDataByIdArr() + { + $idArrStr = I('post.idArr'); + $startTime = I('post.startTime', 0, 'intval'); + $endTime = I('post.endTime', 0, 'intval'); + + if (!$idArrStr || !$startTime || !$endTime) { + echo json_encode(array( + 'status' => 0, + 'msg' => '缺少必要参数' + )); + exit; + } + + $idArr = explode(',', $idArrStr); + + // 别名 + $flightLogDb = M('flight_log')->alias('f'); + + // 关联 airplane_register 表 + $flightLogDb->join('__AIRPLANE_REGISTER__ a ON f.plane_id = a.id'); + + // 查询条件 + $where = array( + 'f.plane_id' => array('in', $idArr), + 'f.start_time' => array('between', array($startTime, $endTime)), + ); + + // 非总管理员需加店铺限制 + if ($this->tokenShop_id != C('powerId')) { + $where['a.shop_id'] = $this->tokenShop_id; + } + + // 查询字段 + $fields = array( + 'f.plane_id', + 'a.name as plane_name', + 'f.start_time', + 'f.end_time', + 'f.distance', + 'f.power_used', + 'f.gps_path' + ); + + // 查询 + $dataList = $flightLogDb->where($where)->field($fields)->order('f.start_time DESC')->select(); + + if ($dataList !== false) { + echo json_encode(array( + 'status' => 1, + 'msg' => '获取成功', + 'dataList' => $dataList + )); + } else { + echo json_encode(array( + 'status' => 0, + 'msg' => '获取失败' + )); + } + } }