【类 型】:feat

【原  因】:保存飞行数据接口
【过  程】:
【影  响】:

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
air 2025-06-14 15:21:25 +08:00
parent 56d848d0cc
commit 046cd39166

View File

@ -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' => '参数不完整'));
}
}
}