import 'dart:convert'; import 'package:fis_jsonrpc/rpc.dart'; import 'package:get/get.dart'; import 'interfaces/data_convert.dart'; import 'interfaces/dictionary.dart'; class DataConvertManager implements IDataConvertManager { @override String heartRateConversion(int heartRate) { if (heartRate < 60) { return "心率过低"; } else if (heartRate > 100) { return "心率过快"; } return "心率值未见异常"; } @override Future>> getTableData(String data) async { var currentDiagnosis = >[]; if (data.isEmpty) { return currentDiagnosis; } var jsonData = json.decode(data); List keys = jsonData.keys.toList(); List? dtos = []; dtos = await Get.find() .getDictionaryNameAndUnitByKeysAsync(keys) ?? []; for (var key in keys) { if (key == "ECG_POINT" || key == "ECG_POINT12" || key == "HealthGuidance") { continue; } var dto = dtos.firstWhereOrNull((item) => item.key == key); if (dto == null) { continue; } final value = jsonData[key].toString(); if (value.isEmpty) { // 不展示空值 continue; } currentDiagnosis.add([ dto.name ?? '', value, dto.unit ?? '', ]); } return currentDiagnosis; } }