Browse Source

Merge branch 'master' of http://git.ius.plus/Project-Vital/VitalApp

guanxinyi 1 year ago
parent
commit
bb8b37531e

+ 4 - 2
lib/managers/device.dart

@@ -24,8 +24,10 @@ class DeviceManager extends IDeviceManager {
 
   @override
   Future<List<String>> getAccessTypes() async {
-    final settings = await Get.find<ISystemSettingManager>().getSettings();
-    final settingTypes = settings.peripheralDevice!.split(',');
+    // final settings = await Get.find<ISystemSettingManager>().getSettings();
+    // final settingTypes = settings.peripheralDevice!.split(',');
+    final settingTypes =
+        await Get.find<ISystemSettingManager>().getEnableDeviceKeysAsync();
     final types = settingTypes
         .map((e) => _typeConvertMap[e])
         .where((e) => e != null)

+ 3 - 0
lib/managers/interfaces/system_setting.dart

@@ -5,4 +5,7 @@ import 'base.dart';
 abstract class ISystemSettingManager implements IManager {
   /// 获取系统设置
   Future<SyncSettingsDTO> getSettings([bool isRefresh = false]);
+
+  ///获取当前组织外设详情
+  Future<List<String>> getEnableDeviceKeysAsync();
 }

+ 14 - 0
lib/managers/system_setting.dart

@@ -79,4 +79,18 @@ class SystemSettingManager implements ISystemSettingManager {
       return null;
     }
   }
+
+  @override
+  Future<List<String>> getEnableDeviceKeysAsync() async {
+    try {
+      final request = GetEnableDeviceKeysRequest(
+          token: Store.user.token,
+          organizationCode: Store.user.organizationCode);
+      final result = await rpc.organization.getEnableDeviceKeysAsync(request);
+      return result;
+    } catch (e) {
+      logger.e("SystemSettingManager getEnableDeviceKeysAsync error.", e);
+      return [];
+    }
+  }
 }

+ 22 - 5
lib/pages/medical/widgets/ecg_view/controller.dart

@@ -1,6 +1,7 @@
 import 'dart:async';
 
 import 'package:get/get.dart';
+import 'package:vitalapp/architecture/utils/prompt_box.dart';
 
 import 'index.dart';
 
@@ -47,28 +48,28 @@ class EcgViewController extends GetxController {
   void addData(List<int> data) {
     if (allPoints.isEmpty) {
       startTime = DateTime.now().millisecondsSinceEpoch;
-      startTimer();
+      _startTimer();
     }
     allPoints.addAll(data);
     if (isPaused) {
       isPaused = false;
-      startTimer();
+      _startTimer();
     }
   }
 
   /// 开启定时器,每隔一定时间添加一次数据,并且更新UI
-  void startTimer() {
+  void _startTimer() {
     timer = Timer.periodic(
       Duration(milliseconds: updatePeriod),
       (timer) {
         // print("timer: ${timer.tick}");
-        updateData();
+        _updateData();
       },
     );
   }
 
   /// 每帧更新数据
-  void updateData() {
+  void _updateData() {
     // 计算当前数据位
     currentDataIndex = (DateTime.now().millisecondsSinceEpoch - startTime) ~/
         (1000 ~/ dataPerSecond);
@@ -101,11 +102,27 @@ class EcgViewController extends GetxController {
   }
 
   void openFullScreenDialog() {
+    print("当前点总数为:${allPoints.length}");
+    if (allPoints.length < dataPerSecond * 30) {
+      PromptBox.toast("未完成检测,数据量不足");
+      return;
+    }
     Get.dialog(
       const FullScreenEcgDataDialog(),
     );
   }
 
+  void reset() {
+    allPoints.clear();
+    newPointsToDraw.clear();
+    oldPointsToDraw.clear();
+    startTime = DateTime.now().millisecondsSinceEpoch;
+    currentDataIndex = 0;
+    timer.cancel();
+    isPaused = false;
+    update(['ecg_view']);
+  }
+
   // @override
   // void onInit() {
   //   super.onInit();

+ 10 - 8
lib/pages/medical/widgets/ecg_view/view.dart

@@ -12,15 +12,17 @@ class EcgView extends GetView<EcgViewController> {
   // 主视图
   Widget _buildView() {
     return Center(
-      child: CustomPaint(
-        foregroundPainter: EcgPainter(
-          newPoints: controller.newPointsToDraw,
-          oldPoints: controller.oldPointsToDraw,
-          xDataCount: controller.xDataCount,
-          yMax: 200,
+      child: ClipRect(
+        child: CustomPaint(
+          foregroundPainter: EcgPainter(
+            newPoints: controller.newPointsToDraw,
+            oldPoints: controller.oldPointsToDraw,
+            xDataCount: controller.xDataCount,
+            yMax: 200,
+          ),
+          painter: GridBackgroundPainter(40, 20),
+          size: Size(width, height),
         ),
-        painter: GridBackgroundPainter(40, 20),
-        size: Size(width, height),
       ),
     );
   }

+ 2 - 3
lib/pages/medical/widgets/ecg_view/widgets/ecg_painter_for_all.dart

@@ -4,15 +4,14 @@ class EcgPainterForAll extends CustomPainter {
   /// 分为新数据和历史数据
   final List<int> allPoints;
 
-  /// 横坐标数据量(横轴一共多少个点)
-  final int xDataCount;
+  /// 横坐标数据量(横轴一共多少个点) 30s * 125 = 3750
+  final int xDataCount = 3750;
 
   /// 纵坐标最大值
   final double yMax;
 
   EcgPainterForAll({
     required this.allPoints,
-    required this.xDataCount,
     required this.yMax,
   });
 

+ 3 - 1
lib/pages/medical/widgets/ecg_view/widgets/full_screen_ecg_data_dialog.dart

@@ -11,6 +11,7 @@ class FullScreenEcgDataDialog extends GetView<EcgViewController> {
     const designWidth = 1280.0; // 设计尺寸宽度:1280
     final width = Get.width;
     final scale = width / designWidth; // 计算缩放比例
+    final ScrollController scrollController = ScrollController();
     return Container(
       width: Get.width * 0.9 / scale,
       height: Get.height * 0.9 / scale,
@@ -27,7 +28,9 @@ class FullScreenEcgDataDialog extends GetView<EcgViewController> {
               thumbVisibility: true,
               thickness: 10,
               radius: const Radius.circular(10),
+              controller: scrollController,
               child: SingleChildScrollView(
+                controller: scrollController,
                 padding: const EdgeInsets.only(left: 10, right: 10, bottom: 20),
                 physics: const BouncingScrollPhysics(),
                 scrollDirection: Axis.horizontal,
@@ -42,7 +45,6 @@ class FullScreenEcgDataDialog extends GetView<EcgViewController> {
                   child: CustomPaint(
                     foregroundPainter: EcgPainterForAll(
                       allPoints: controller.allPoints,
-                      xDataCount: controller.xDataCount,
                       yMax: 600,
                     ),
                     painter: GridBackgroundPainterForAll(),

+ 4 - 1
lib/pages/settings/devices/widgets/search_dialog.dart

@@ -31,6 +31,7 @@ class _DialogState extends State<DeviceSearchDialog> {
   DeviceSearcher? searcher;
   DeviceInfo? deviceInfo;
   String? errorMsg;
+  bool showDialogCancel = true;
 
   @override
   void initState() {
@@ -68,11 +69,13 @@ class _DialogState extends State<DeviceSearchDialog> {
     return VAlertDialog(
       title: "搜索设备",
       content: child,
+      showCancel: showDialogCancel,
     );
   }
 
   void _onSuccess(_, DeviceInfo e) {
     setState(() {
+      showDialogCancel = false; // 此时不可手动取消Dialog,否则结果无法回传
       deviceInfo = e;
       Future.delayed(const Duration(seconds: 2), () {
         Get.back(result: e);
@@ -131,7 +134,7 @@ class _ResultWidget extends StatelessWidget {
         ? const Icon(Icons.check_circle, color: Colors.green, size: 32)
         : const Icon(Icons.cancel, color: Colors.red, size: 32);
     return Container(
-      height: 80,
+      height: 120,
       alignment: Alignment.center,
       child: Row(
         mainAxisSize: MainAxisSize.min,

+ 3 - 0
lib/store/modules/user.dart

@@ -59,6 +59,9 @@ class UserState extends StateModuleBase {
   /// 医生电话
   String get principalPhone => _userInfo?.principalPhone ?? "";
 
+  /// 机构code
+  String get organizationCode => _userInfo?.organizationCode ?? "";
+
   /// 机构名称
   String get organizationName => _userInfo?.organizationName ?? "";
 

+ 2 - 2
pubspec.lock

@@ -852,8 +852,8 @@ packages:
     dependency: "direct main"
     description:
       path: "."
-      ref: f806223cf7
-      resolved-ref: f806223cf715204f3c5496658f191dac556d14e4
+      ref: "05786f1c82"
+      resolved-ref: "05786f1c827c45dc994793cdff329a8fdc347c8e"
       url: "http://git.ius.plus/Project-Vital/FlutterDevicePlugin.git"
     source: git
     version: "0.0.1"

+ 1 - 1
pubspec.yaml

@@ -49,7 +49,7 @@ dependencies:
   vnote_device_plugin:
     git:
       url: http://git.ius.plus/Project-Vital/FlutterDevicePlugin.git
-      ref: f806223cf7
+      ref: 05786f1c82
     # path: ..\FlutterDevicePlugin
   vital_local_database:
     git: