Melon 1 rok temu
rodzic
commit
9674291ba2

+ 7 - 2
lib/database/db.dart

@@ -40,11 +40,16 @@ class VitalDatabaseAccessor
       await _debugBatch();
     }
 
+    try {
+      await checkAndUpgradeDatabaseVersion();
+    } catch (e) {
+      logger.e(
+          "VitalDatabaseAccessor checkAndUpgradeDatabaseVersion error.", e);
+    }
+
     _store.regRepository<IPatientRepository>(PatientRepository(database));
     _store.regRepository<IDiagnosisRepository>(DiagnosisRepository(database));
     _store.regRepository<IFollowUpRepository>(FollowUpRepository(database));
-
-    await checkAndUpgradeDatabaseVersion();
   }
 
   Future<void> _debugBatch() async {

+ 1 - 1
lib/database/db_patch/v2.dart

@@ -27,7 +27,7 @@ class DatabasePatchV2 extends BaseDatabasePatch {
     await db.database.execute(
         'ALTER TABLE patients ADD COLUMN diagnosisCount INTEGER NOT NULL DEFAULT 0;');
     await db.database.execute(
-        'ALTER TABLE patients ADD COLUMN orgCode VARCHAR(100) NOT NULL DEFAULT;');
+        "ALTER TABLE patients ADD COLUMN orgCode VARCHAR(100) NOT NULL DEFAULT '';");
 
     await _cleanDuplicatePatients();
 

+ 1 - 1
lib/managers/record_data_cache_manager.dart

@@ -51,7 +51,7 @@ class RecordDataCacheManager implements IRecordDataCacheManager {
         final id = await db.repositories.diagnosis.insert(entity);
         if (id > 0) {
           // 统计数量+1
-          await db.repositories.patient.increaseDiagnoissCount(entity.code);
+          await db.repositories.patient.increaseDiagnoissCount(patientCode);
         }
       }
 

+ 6 - 4
lib/mock/services/followup.dart

@@ -12,13 +12,14 @@ class FollowUpServiceMock extends VitalFollowUpService {
   @override
   Future<String> createFollowUpAsync(CreateFollowUpRequest request) async {
     final entity = FollowUpEntity();
+    final patientCode = Store.user.currentSelectPatientInfo!.code!;
     // 本地先生成一个Code,上传后更新
     final uuid = const Uuid().v4().replaceAll('-', '');
     entity.code = "mock_$uuid";
     entity.isValid = true;
     entity.syncType = OfflineDataSyncType.create;
     entity.userCode = Store.user.userCode!;
-    entity.patientCode = Store.user.currentSelectPatientInfo!.code!;
+    entity.patientCode = patientCode;
     entity.contractDoctor = Store.user.principalName;
     entity.typeKey = request.key!;
     entity.templateCode = request.templateCode!;
@@ -36,7 +37,7 @@ class FollowUpServiceMock extends VitalFollowUpService {
     final success = id > 0;
     if (success) {
       // 统计数量+1
-      await db.repositories.patient.increaseFollowUpCount(entity.code);
+      await db.repositories.patient.increaseFollowUpCount(patientCode);
     }
     final result = success ? entity.code : "";
     return result;
@@ -51,9 +52,10 @@ class FollowUpServiceMock extends VitalFollowUpService {
       entity.isValid = true;
       entity.syncType = OfflineDataSyncType.update;
     }
+    final patientCode = Store.user.currentSelectPatientInfo!.code!;
     entity.code = request.code!;
     entity.userCode = Store.user.userCode!;
-    entity.patientCode = Store.user.currentSelectPatientInfo!.code!;
+    entity.patientCode = patientCode;
     entity.contractDoctor = Store.user.principalName;
     entity.typeKey = request.key!;
     entity.mode = request.followUpMode!;
@@ -67,7 +69,7 @@ class FollowUpServiceMock extends VitalFollowUpService {
       result = await db.repositories.followUp.insert(entity);
       if (result > 0) {
         // 统计数量+1
-        await db.repositories.patient.increaseFollowUpCount(entity.code);
+        await db.repositories.patient.increaseFollowUpCount(patientCode);
       }
     } else {
       result = await db.repositories.followUp.update(entity);

+ 3 - 2
lib/pages/data_sync/center/view.dart

@@ -58,8 +58,9 @@ class _Header extends GetView<SyncCenterController> {
             Text("全部上传", style: TextStyle(fontSize: 18)),
           ],
         ),
-        onTap: () {
-          SyncUploadDialog.show();
+        onTap: () async {
+          final result = await SyncUploadDialog.show();
+          controller.reloadPageList();
         },
       ),
     );

+ 21 - 17
lib/pages/data_sync/center/widgets/upload_dialog.dart

@@ -36,6 +36,7 @@ class _SyncUploadDialogController extends GetxController {
     if (!loaded) {
       return;
     }
+    await Future.delayed(const Duration(seconds: 1)); // 等待页面显示一会
     for (var i = 0; i < totalCount; i++) {
       final success = await _handleSingle();
       if (success) {
@@ -68,12 +69,13 @@ class _SyncUploadDialogController extends GetxController {
 class SyncUploadDialog extends GetView<_SyncUploadDialogController> {
   const SyncUploadDialog({super.key});
 
-  static Future<void> show() async {
+  static Future<bool> show() async {
     final result = await Get.dialog(
       const SyncUploadDialog(),
       barrierDismissible: false,
     );
     print("SyncUploadDialog result:$result.");
+    return result;
   }
 
   @override
@@ -90,22 +92,24 @@ class SyncUploadDialog extends GetView<_SyncUploadDialogController> {
     return GetBuilder<_SyncUploadDialogController>(
       init: _SyncUploadDialogController(),
       builder: (context) {
-        final data = controller.handleData;
-        return Container(
-          height: 280,
-          alignment: Alignment.center,
-          child: data != null
-              ? _SyncProgress(
-                  uploadedCount: controller.uploadedCount.value,
-                  totalCount: controller.totalCount,
-                  patientName: data.name,
-                )
-              : const SizedBox(
-                  width: 28,
-                  height: 28,
-                  child: CircularProgressIndicator(),
-                ),
-        );
+        return Obx(() {
+          final data = controller.handleData;
+          return Container(
+            height: 280,
+            alignment: Alignment.center,
+            child: data != null
+                ? _SyncProgress(
+                    uploadedCount: controller.uploadedCount.value,
+                    totalCount: controller.totalCount,
+                    patientName: data.name,
+                  )
+                : const SizedBox(
+                    width: 28,
+                    height: 28,
+                    child: CircularProgressIndicator(),
+                  ),
+          );
+        });
       },
     );
   }