Эх сурвалжийг харах

tracker log roster fixed nodelete

fares 9 сар өмнө
parent
commit
99334004f9

+ 16 - 5
lib/handlers/file_upload_api.dart

@@ -478,17 +478,22 @@ class FileProcess {
       final dataToInsert = comparisonResult.insertData;
 
       //special export prgpn
+      List<int> indexRemovedToMaintain = [];
       if (filename == "exportPGRGPN.txt" ||
           filename == "ExportPGRGPNmois.txt") {
         //if there is line insert with tlc and date
         for (final data in mapsToInsert) {
           tlcs..add(data["tlc"] ?? "");
         }
-        final indexRemovedToMaintain = indexToRemove
+        indexRemovedToMaintain = indexToRemove
             .where((e) => !tlcs.contains(oldComparable[e]["tlc"]))
             .toList();
-        indexToMaintain.addAll(indexRemovedToMaintain);
-        indexToRemove.removeWhere((e) => indexRemovedToMaintain.contains(e));
+        // indexToMaintain.addAll(indexRemovedToMaintain);
+        // indexToRemove.removeWhere((e) => indexRemovedToMaintain.contains(e));
+        for (var e in indexRemovedToMaintain) {
+          indexToMaintain.add(e);
+          indexToRemove.remove(e);
+        }
       }
 
       try {
@@ -535,6 +540,9 @@ class FileProcess {
       }
 
 //logging tracking data
+      final List<Map<String, dynamic>> mapsToInsertNoDelete =
+          List.from(mapsToInsert)
+            ..addAll(indexRemovedToMaintain.map((e) => oldComparable[e]));
       for (var tracker in trackers[filename] ?? []) {
         final String table = tracker["table"];
         final List<String> groupby = tracker["groupby"] ?? [];
@@ -543,7 +551,7 @@ class FileProcess {
             (e) => groupby.map((f) => e[f]).join("|"),
             dataFunction: (e) =>
                 e.filterKeys(track).values.map((j) => j ?? "").join("|"));
-        final stateNew = mapsToInsert.groupBy(
+        final stateNew = mapsToInsertNoDelete.groupBy(
             (e) => groupby.map((f) => e[f]).join("|"),
             dataFunction: (e) =>
                 e.filterKeys(track).values.map((j) => j ?? "").join("|"));
@@ -567,7 +575,10 @@ class FileProcess {
                   : [],
             };
             logs.add(row);
-            print("   Tracker:$tracker row: $row ");
+            // if (key.contains("7506")) {
+            //   print(
+            //       "   table:$table key: $key \n\n ---old:${stateOld[key]} \n\n +++new:${stateNew[key]}");
+            // }
           }
         }