生成路径 对接

This commit is contained in:
mmc
2026-02-28 14:58:25 +08:00
parent 34478cbf4e
commit cd2f94347a
2 changed files with 175 additions and 13 deletions

View File

@@ -28,6 +28,7 @@ class PathRepositoryImpl implements PathRepository {
'holes': holes.map((hole) => hole.toJson()).toList(),
'workType': workType,
});
print('请求体: $body'); // 调试输出请求体
try {
final response = await http.post(url, headers: headers, body: body);
@@ -134,14 +135,12 @@ class PathRepositoryImpl implements PathRepository {
required String workName,
}) async {
final timestamp = DateTime.now().millisecondsSinceEpoch;
final url = Uri.parse(
'https://serviceri.satabot.com/iot/workRecord/selectByWorkName',
).replace(
queryParameters: {
'workName': workName,
'_t': timestamp.toString(),
},
);
final url =
Uri.parse(
'https://serviceri.satabot.com/iot/workRecord/selectByWorkName',
).replace(
queryParameters: {'workName': workName, '_t': timestamp.toString()},
);
print('请求URL: $url');
try {
@@ -167,20 +166,22 @@ class PathRepositoryImpl implements PathRepository {
} else if (rawData is Map) {
records = [Map<String, dynamic>.from(rawData)];
} else {
throw Exception('Unexpected data type for "data": ${rawData.runtimeType}');
throw Exception(
'Unexpected data type for "data": ${rawData.runtimeType}',
);
}
return records;
} else {
throw Exception('API error: ${data['msg'] ?? 'Unknown'}');
}
} else {
throw Exception('HTTP ${response.statusCode}: ${response.reasonPhrase}');
throw Exception(
'HTTP ${response.statusCode}: ${response.reasonPhrase}',
);
}
} catch (e) {
throw Exception('Network error in selectWorkRecordByName: $e');
}
}
}