diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 0bf206b..02103ad 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -786,4 +786,28 @@ class PlaneController extends PublicController )); } } + /** + * @description: 上传保存飞机飞行数据(从解锁到加锁) + */ + public function saveFlyData() + { + // 参数校验 + if ($_REQUEST['plane_id'] && $_REQUEST['start_time'] && $_REQUEST['end_time'] && $_REQUEST['gps_path']) { + $data['plane_id'] = $_REQUEST['plane_id']; + $data['start_time'] = $_REQUEST['start_time']; // 秒级时间戳 + $data['end_time'] = $_REQUEST['end_time']; // 秒级时间戳 + $data['gps_path'] = $_REQUEST['gps_path']; // JSON 字符串,经纬度数组 + $data['distance'] = $_REQUEST['distance'] ?? 0; // 累计距离,单位米 + $data['power_used'] = $_REQUEST['power_used'] ?? 0; // 耗电量,单位 mAh + + $flightLogDb = D('flight_log'); // 假设数据表为 airplane_flight,可按实际修改 + if ($flightLogDb->data($data)->add()) { + echo json_encode(array('status' => 1, 'msg' => '飞行数据保存成功')); + } else { + echo json_encode(array('status' => 0, 'msg' => '保存失败')); + } + } else { + echo json_encode(array('status' => 0, 'msg' => '参数不完整')); + } + } }