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' => '获取失败' + )); + } + } }