Browse Source

IOT添加服务

denny 1 year ago
parent
commit
447032162c

+ 4 - 0
Tools/Flyinsono.DBCopy.Tool/Config/AppSetting.json

@@ -21,5 +21,9 @@
   "TerminalRecordSync": {
     "StartTime": "2023-10-21 19:00:00",
     "EndTime": "2023-10-23 08:30:00"
+  },
+  "SignStudentRecordSync": {
+    "StartTime": "2023-06-27 00:00:00",
+    "EndTime": "2024-02-02 00:00:00"
   }
 }

+ 5 - 0
Tools/Flyinsono.DBCopy.Tool/Entities/Config/AppSetting.cs

@@ -31,6 +31,11 @@ namespace Flyinsono.DBCopy.Tool.Entities.Config
         /// </summary>
         public TerminalRecordSyncSetting TerminalRecordSync { get; set; }
 
+        /// <summary>
+        /// 报名同步
+        /// </summary>
+        public TerminalRecordSyncSetting SignStudentRecordSync { get; set; }
+
         /// <summary>
         /// 第三方服务
         /// </summary>

+ 52 - 0
Tools/Flyinsono.DBCopy.Tool/Service/MigrateService.BasicInfo.cs

@@ -3008,6 +3008,58 @@ namespace Flyinsono.DBCopy.Tool.Service
             }
         }
 
+        public async Task SignStudentCourse()
+        {
+            var startTime = CommonConfigManager.SignStudentRecordSync.StartTime;
+            var endTime = CommonConfigManager.SignStudentRecordSync.EndTime;
+            //报名数据
+            var signCourseFilter = Builders<CourseStudents>.Filter.Where(x => x.IsDeleted == false && ((x.CreateTime > startTime && x.CreateTime <= endTime) || (x.UpdateTime > startTime && x.UpdateTime <= endTime)));
+            var signCourseStudentRecords = _coursesDBRepository.GetCourseStudents(signCourseFilter).ToList();
+            if (signCourseStudentRecords?.Count > 0)
+            {
+                var courseCodes = signCourseStudentRecords.Select(c => c.Id).Distinct().ToList();
+                if (courseCodes?.Count > 0)
+                {
+                    var filter = Builders<Courses>.Filter.Where(x => courseCodes.Contains(x.Id));
+                    var coursesRecords = new List<Courses>();
+                    var tempCoursesRecords = _coursesDBRepository.GetCourses(filter).OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
+
+                    coursesRecords = await FilterData<Courses>(tempCoursesRecords, "CoursesData");
+                    Logger.WriteLineInfo($"Courses totalCount:{coursesRecords.Count}");
+
+                    var courseAvailabilityExtensionsFilter = Builders<CourseAvailabilityExtensions>.Filter.Where(x => !string.IsNullOrEmpty(x.Id));
+                    var courseAvailabilityExtensionsRecords = _coursesDBRepository.GetCourseAvailabilityExtensions(courseAvailabilityExtensionsFilter).ToList();
+
+                    var courseStudentFilter = Builders<CourseStudents>.Filter.Where(x => x.IsDeleted == false);
+                    var courseStudentRecords = _coursesDBRepository.GetCourseStudents(courseStudentFilter).ToList();
+
+                    var pageIndex = 0;
+                    var pageSize = 10;
+                    var coursesCount = coursesRecords.Count;
+                    while (true)
+                    {
+                        var pendingRecords = coursesRecords.Skip(pageIndex * pageSize).Take(pageSize)?.ToList() ?? new List<Courses>();
+                        var pendingCount = pendingRecords.Count;
+                        if (pendingCount > 0)
+                        {
+                            await SendCoursesInfos(pendingRecords, courseStudentRecords, courseAvailabilityExtensionsRecords, SyncDBEnum.Synchronize);
+                            pageIndex++;
+                        }
+                        if (pageIndex * pageSize >= coursesCount)
+                        {
+                            Logger.WriteLineInfo($"Courses record processing: 100%");
+                            break;
+                        }
+                        else
+                        {
+                            var tempValue = coursesCount == 0 ? 1 : coursesCount;
+                            Logger.WriteLineInfo($"Courses record processing: {(pageIndex * pageSize * 100 / tempValue)}%");
+                        }
+                    }
+                }
+            }
+        }
+
         public async Task FindUserAccountInfo()
         {
             var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Config", "账号.txt");

+ 49 - 2
Tools/Flyinsono.DBCopy.Tool/Service/MigrateService.Course.cs

@@ -245,6 +245,53 @@ namespace Flyinsono.DBCopy.Tool.Service
                     Logger.WriteLineInfo($"Courses record processing: {(pageIndex * pageSize * 100 / tempValue)}%");
                 }
             }
+
+            //报名数据
+            var signCourseFilter = Builders<CourseStudents>.Filter.Where(x => x.IsDeleted == false && ((x.CreateTime > startTime && x.CreateTime <= endTime) || (x.UpdateTime > startTime && x.UpdateTime <= endTime)));
+            var signCourseStudentRecords = _coursesDBRepository.GetCourseStudents(signCourseFilter).ToList();
+            if (signCourseStudentRecords?.Count > 0)
+            {
+                var courseCodes = signCourseStudentRecords.Select(c => c.Id).Distinct().ToList();
+                if (courseCodes?.Count > 0)
+                {
+                    filter = builder.Where(x => courseCodes.Contains(x.Id));
+                    coursesRecords = new List<Courses>();
+                    tempCoursesRecords = _coursesDBRepository.GetCourses(filter).OrderByDescending(x => x.CreateTime).ThenBy(x => x.Id).ToList();
+
+                    coursesRecords = await FilterData<Courses>(tempCoursesRecords, "CoursesData");
+                    Logger.WriteLineInfo($"Courses totalCount:{coursesRecords.Count}");
+
+                    courseAvailabilityExtensionsFilter = Builders<CourseAvailabilityExtensions>.Filter.Where(x => !string.IsNullOrEmpty(x.Id));
+                    courseAvailabilityExtensionsRecords = _coursesDBRepository.GetCourseAvailabilityExtensions(courseAvailabilityExtensionsFilter).ToList();
+
+                    courseStudentFilter = Builders<CourseStudents>.Filter.Where(x => x.IsDeleted == false);
+                    courseStudentRecords = _coursesDBRepository.GetCourseStudents(courseStudentFilter).ToList();
+
+                    pageIndex = 0;
+                    pageSize = 10;
+                    coursesCount = coursesRecords.Count;
+                    while (true)
+                    {
+                        var pendingRecords = coursesRecords.Skip(pageIndex * pageSize).Take(pageSize)?.ToList() ?? new List<Courses>();
+                        var pendingCount = pendingRecords.Count;
+                        if (pendingCount > 0)
+                        {
+                            await SendCoursesInfos(pendingRecords, courseStudentRecords, courseAvailabilityExtensionsRecords, syncType);
+                            pageIndex++;
+                        }
+                        if (pageIndex * pageSize >= coursesCount)
+                        {
+                            Logger.WriteLineInfo($"Courses record processing: 100%");
+                            break;
+                        }
+                        else
+                        {
+                            var tempValue = coursesCount == 0 ? 1 : coursesCount;
+                            Logger.WriteLineInfo($"Courses record processing: {(pageIndex * pageSize * 100 / tempValue)}%");
+                        }
+                    }
+                }
+            }
         }
 
         /// <summary>
@@ -259,8 +306,8 @@ namespace Flyinsono.DBCopy.Tool.Service
                 {
                     var teacherCodes = coursesRecords.Where(c => !string.IsNullOrEmpty(c.Teacher?.Id)).Select(c => c.Teacher?.Id).Distinct().ToList();
                     var teacherList = _usersDBRepository.GetUserByCodes(teacherCodes);
-                    var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
-                    var endTime = _migrateRecord.EndTime;
+                    //var startTime = GetFactBeginTime(_migrateRecord.StartTime, _migrateRecord.EndTime);
+                    //var endTime = _migrateRecord.EndTime;
                     Logger.WriteLineInfo($"Courses Infos Migrate Starting");
                     var courseInfoList = new List<CourseMigratoryInfo>();
                     foreach (var courseItem in coursesRecords)

+ 9 - 0
Tools/Flyinsono.DBCopy.Tool/Utilities/CommonConfigManager.cs

@@ -137,6 +137,10 @@ namespace Flyinsono.DBCopy.Tool.Utilities
                 {
                     TerminalRecordSync = appConfig.TerminalRecordSync;
                 }
+                if (appConfig.SignStudentRecordSync != null)
+                {
+                    SignStudentRecordSync = appConfig.SignStudentRecordSync;
+                }
                 if (appConfig.ThirdPartyServer != null)
                 {
                     ThirdPartyServer = appConfig.ThirdPartyServer;
@@ -446,6 +450,11 @@ namespace Flyinsono.DBCopy.Tool.Utilities
         /// </summary>
         public static TerminalRecordSyncSetting TerminalRecordSync { get; set; }
 
+        /// <summary>
+        /// 病例同步配置
+        /// </summary>
+        public static TerminalRecordSyncSetting SignStudentRecordSync { get; set; }
+
         /// <summary>
         /// 过滤指定的代理商
         /// </summary>

+ 28 - 0
Tools/Flyinsono.DBCopy.Tool/ViewModels/MainWindowViewModel.cs

@@ -12,6 +12,8 @@ using Flyinsono.DBCopy.Tool.Service;
 using Flyinsono.DBCopy.Tool.Utilities;
 using WingInterfaceLibrary.Enum;
 using Flyinsono.DBCopy.Tool.RpcService;
+using MongoDB.Bson.IO;
+using Newtonsoft.Json.Linq;
 
 namespace Flyinsono.DBCopy.Tool
 {
@@ -1546,9 +1548,35 @@ namespace Flyinsono.DBCopy.Tool
                 {
                     try
                     {
+                        //List<Dictionary<string, object>> keyValuePairs = new List<Dictionary<string, object>>();
+                        //Dictionary<string, object> temp = new Dictionary<string, object>();
+                        //temp.Add("Name", "武松");
+                        //temp["Age"] = 28;
+                        //temp["Birthday"] = DateTime.Now;
+                        //keyValuePairs.Add(temp);
+                        //Dictionary<string, object> temp1 = new Dictionary<string, object>();
+                        //temp1.Add("Name", "睿智深");
+                        //temp1["Age"] = 31;
+                        //temp1["Birthday"] = DateTime.Now;
+                        //keyValuePairs.Add(temp1);
+
+                        //List<dynamic> dynamicsList = new List<dynamic>();
+                        //foreach (Dictionary<string, object> keyValues in keyValuePairs)
+                        //{
+                        //    dynamic obj = new System.Dynamic.ExpandoObject();
+                        //    foreach (KeyValuePair<string, object> keyValuePair in keyValues)
+                        //    {
+                        //        ((IDictionary<string, object>)obj).Add(keyValuePair.Key, keyValuePair.Value);
+                        //    }
+                        //    dynamicsList.Add(obj);
+                        //}
+
+                        //string paramsText = Newtonsoft.Json.JsonConvert.SerializeObject(dynamicsList);
+
                         //await MigrateServiceReal.MigrateCertifiedInstructorUserInfos(SyncDBEnum.Synchronize);
                         //await MigrateServiceReal.GetTrainingBrowsedRecordsDatas(SyncDBEnum.Synchronize);
                         await MigrateServiceReal.FindUserAccountInfo();
+                        //await MigrateServiceReal.SignStudentCourse();
                     }
                     catch (Exception ex)
                     {

+ 167 - 0
src/Resource/IOT/DeviceAttribute.json

@@ -0,0 +1,167 @@
+{
+    "General": {
+        "Version": "1.0"
+    },
+    "BreathAttributeInfo": {
+        "pip_life": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "pip_lifeDesc"
+        },
+        "mask_life": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "mask_lifeDesc"
+        },
+        "cartridge_life": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "cartridge_lifeDesc"
+        },
+        "treat_pwr": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "treat_pwrDesc"
+        },
+        "treat_mode": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "treat_modeDesc"
+        },
+        "auto_start":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "auto_startDesc"
+        },
+        "auto_stop": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "auto_stopDesc"
+        },
+        "pip_heat": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "pip_heatDesc"
+        },
+        "delay_boost": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "delay_boostDesc"
+        },
+        "start_pressure": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "start_pressureDesc"
+        },
+        "ipap": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "ipapDesc"
+        },
+        "epap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "epapDesc"
+        },
+        "inspiratory_sens":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "inspiratory_sensDesc"
+        },
+        "expiratory_sens":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "expiratory_sensDesc"
+        },
+        "max_intime":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "max_intimeDesc"
+        },
+        "min_intime":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "min_intimeDesc"
+        },
+        "pressure_up":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "pressure_upDesc"
+        },
+        "backup_ventilation":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "backup_ventilationDesc"
+        },
+        "exp_dec":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "exp_decDesc"
+        },
+        "cpap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "cpapDesc"
+        },
+        "min_cpap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "min_cpapDesc"
+        },
+        "max_cpap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "max_cpapDesc"
+        },
+        "pressure_sens":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "pressure_sensDesc"
+        },
+        "minepap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "minepapDesc"
+        },
+        "maxipap":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "maxipapDesc"
+        },
+        "pressure_support":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "pressure_supportDesc"
+        },
+        "rr":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "rrDesc"
+        },
+        "intime":
+        {
+            "Type":"int",
+            "DefaultValue": 0,
+            "Desc": "intimeDesc"
+        }
+    },
+    "OxygenAttributeInfo": {
+    }
+}

+ 194 - 0
src/Resource/IOT/DeviceReport.json

@@ -0,0 +1,194 @@
+{
+    "General": {
+        "Version": "1.0"
+    },
+    "BreathReportInfo": {
+        "UseDay": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "使用天数 Unit:天"
+        },
+        "UseDay4h": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "UseHour": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "UseAHourM": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "UseAhour": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "TPressAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "TPress95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "TPress90": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "IPressAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "IPress95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "IPress90": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "EPressAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "EPress95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "EPress90": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "TidalAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Tidal95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "MveAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Mve95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "InstAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "SpinPer": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "SpexPer": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "RrAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Spo2Ave": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Spo2Min": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "PrAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "LeakAve": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Leak95": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Leak90": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "LeakAthr": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "AhiM": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Ahi": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Hi": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Ai": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Oai": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "CaiM": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "Cai": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        },
+        "SnoreE": {
+            "Type": "int",
+            "DefaultValue": 0,
+            "Desc": "≥4小时的使用天数 Unit:天"
+        }
+    },
+    "OxygenReportInfo": {
+    }
+}