CrazyIter_Bin 3 tahun lalu
induk
melakukan
b46c47dca2

+ 12 - 5
TEAMModelOS.SDK/Models/Cosmos/Common/StudentScoreRecord.cs

@@ -14,14 +14,16 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         // id  雪花id
         // id  雪花id
         //code  LessonStudentRecord[-学校编码],  LessonStudentRecord
         //code  LessonStudentRecord[-学校编码],  LessonStudentRecord
         //其他基础信息
         //其他基础信息
-        public StudentScoreRecord() {
+        public StudentScoreRecord()
+        {
             pk = "StudentScoreRecord";
             pk = "StudentScoreRecord";
         }
         }
         public string stuid { get; set; }
         public string stuid { get; set; }
         public string tmdid { get; set; }
         public string tmdid { get; set; }
+        public string userType { get; set; }
         public string school { get; set; }
         public string school { get; set; }
         public int year { get; set; }
         public int year { get; set; }
-        
+
         public List<StudentLessonRecord> lessonRecords { get; set; } = new List<StudentLessonRecord>();
         public List<StudentLessonRecord> lessonRecords { get; set; } = new List<StudentLessonRecord>();
         //单独记录 组计分,个人积分,互动分,
         //单独记录 组计分,个人积分,互动分,
         public double gscore { get; set; } //组计分
         public double gscore { get; set; } //组计分
@@ -30,12 +32,13 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
     }
     }
 
 
 
 
-    public class StudentLessonRecord {
+    public class StudentLessonRecord
+    {
         /// <summary>
         /// <summary>
         ///必填 教师醍摩豆id
         ///必填 教师醍摩豆id
         /// </summary>
         /// </summary>
         public string tmdid { get; set; }
         public string tmdid { get; set; }
-       // public string tmdname { get; set; }
+        // public string tmdname { get; set; }
         /// <summary>
         /// <summary>
         ///必填 课堂名称
         ///必填 课堂名称
         /// </summary>
         /// </summary>
@@ -69,10 +72,14 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         public double pscore { get; set; }  //个人计分
         public double pscore { get; set; }  //个人计分
         public double tscore { get; set; } //互动计分
         public double tscore { get; set; } //互动计分
         /// <summary>
         /// <summary>
+        /// 课例时间
+        /// </summary>
+        public long time { get; set; }
+        /// <summary>
         /// 名单信息
         /// 名单信息
         /// </summary>
         /// </summary>
         //public List<string> groupIds { get; set; } = new List<string>();
         //public List<string> groupIds { get; set; } = new List<string>();
     }
     }
-   
+
 
 
 }
 }

+ 41 - 24
TEAMModelOS.SDK/Models/Service/LessonService.cs

@@ -17,11 +17,12 @@ namespace TEAMModelOS.SDK.Models.Service
 {
 {
     public class LessonService
     public class LessonService
     {
     {
-        public static async void DoLessonStudentRecord(DingDing _dingding , SnowflakeId snowflakeId, LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
+        public static async void DoLessonStudentRecord(DingDing _dingding, SnowflakeId snowflakeId, LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
             Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
             Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
         {
         {
 
 
-            try {
+            try
+            {
                 int year = DateTimeOffset.UtcNow.Year;
                 int year = DateTimeOffset.UtcNow.Year;
                 var clientSummaryList = lessonBase.report.clientSummaryList.Where(x => x.groupTaskCompleteCount != 0 || x.groupScore != 0 || x.score != 0 || x.tnteractScore != 0 || x.taskCompleteCount != 0);
                 var clientSummaryList = lessonBase.report.clientSummaryList.Where(x => x.groupTaskCompleteCount != 0 || x.groupScore != 0 || x.score != 0 || x.tnteractScore != 0 || x.taskCompleteCount != 0);
                 IEnumerable<LessonStudent> students = new List<LessonStudent>();
                 IEnumerable<LessonStudent> students = new List<LessonStudent>();
@@ -59,7 +60,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 }
                 }
                 List<Task<ItemResponse<StudentScoreRecord>>> records = new List<Task<ItemResponse<StudentScoreRecord>>>();
                 List<Task<ItemResponse<StudentScoreRecord>>> records = new List<Task<ItemResponse<StudentScoreRecord>>>();
                 stuids.ToList().ForEach(x => {
                 stuids.ToList().ForEach(x => {
-                    var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"StudentScoreRecord") && l.school.Equals(x.school) );
+                    var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"StudentScoreRecord") && l.school.Equals(x.school));
                     ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
                     ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
                     if (record != null)
                     if (record != null)
                     {
                     {
@@ -78,6 +79,7 @@ namespace TEAMModelOS.SDK.Models.Service
                                      courseId = lessonRecord.courseId,
                                      courseId = lessonRecord.courseId,
                                      periodId = lessonRecord.periodId,
                                      periodId = lessonRecord.periodId,
                                      subjectId = lessonRecord.subjectId,
                                      subjectId = lessonRecord.subjectId,
+                                     time = lessonRecord.startTime
                                  }
                                  }
                              );
                              );
                         }
                         }
@@ -87,6 +89,7 @@ namespace TEAMModelOS.SDK.Models.Service
 
 
                         record = new StudentScoreRecord
                         record = new StudentScoreRecord
                         {
                         {
+                            userType = Constant.ScopeStudent,
                             id = $"{snowflakeId.NextId()}",
                             id = $"{snowflakeId.NextId()}",
                             year = year,
                             year = year,
                             stuid = x.id,
                             stuid = x.id,
@@ -110,6 +113,10 @@ namespace TEAMModelOS.SDK.Models.Service
                         };
                         };
 
 
                     }
                     }
+                    record.userType = Constant.ScopeStudent;
+                    record.gscore = record.lessonRecords.Select(x => x.gscore).Sum();
+                    record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
+                    record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
                     records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
                     records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
                 });
                 });
                 tmdids.ToList().ForEach(x => {
                 tmdids.ToList().ForEach(x => {
@@ -139,6 +146,7 @@ namespace TEAMModelOS.SDK.Models.Service
                     {
                     {
                         record = new StudentScoreRecord
                         record = new StudentScoreRecord
                         {
                         {
+                            userType = Constant.ScopeTmdUser,
                             id = $"{snowflakeId.NextId()}",
                             id = $"{snowflakeId.NextId()}",
                             code = $"StudentScoreRecord",
                             code = $"StudentScoreRecord",
                             pk = "StudentScoreRecord",
                             pk = "StudentScoreRecord",
@@ -162,6 +170,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         }
                         }
                         };
                         };
                     }
                     }
+                    record.userType = Constant.ScopeStudent;
                     record.gscore = record.lessonRecords.Select(x => x.gscore).Sum();
                     record.gscore = record.lessonRecords.Select(x => x.gscore).Sum();
                     record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
                     record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
                     record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
                     record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
@@ -171,13 +180,16 @@ namespace TEAMModelOS.SDK.Models.Service
                 {
                 {
                     await Task.WhenAll(records);
                     await Task.WhenAll(records);
                 }
                 }
-            } catch (Exception ex ) {
-                await  _dingding.SendBotMsg($"学生个人课例统计信息异常,{ex.Message}\n{ex.StackTrace}",GroupNames.醍摩豆服務運維群組);
+            }
+            catch (Exception ex)
+            {
+                await _dingding.SendBotMsg($"学生个人课例统计信息异常,{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
             }
             }
         }
         }
 
 
-        public static async void DoAutoDeleteSchoolLessonRecord(LessonRecord lessonRecord,string  scope ,CosmosClient client,string school,string tmdid,
-            Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration) {
+        public static async void DoAutoDeleteSchoolLessonRecord(LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
+            Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration)
+        {
             if (lessonRecord.scope.Equals("school"))
             if (lessonRecord.scope.Equals("school"))
             {
             {
                 SchoolSetting setting = null;
                 SchoolSetting setting = null;
@@ -203,7 +215,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 {
                 {
                     setting = new SchoolSetting() { lessonSetting = new LessonSetting { openAutoClean = 0, expireDays = Constant.school_lesson_expire } };
                     setting = new SchoolSetting() { lessonSetting = new LessonSetting { openAutoClean = 0, expireDays = Constant.school_lesson_expire } };
                 }
                 }
-                int school_lesson_expire =0;
+                int school_lesson_expire = 0;
                 bool save = true;
                 bool save = true;
                 List<string> msg = new List<string>();
                 List<string> msg = new List<string>();
                 if (setting.lessonSetting.openAutoClean == 1)
                 if (setting.lessonSetting.openAutoClean == 1)
@@ -212,7 +224,8 @@ namespace TEAMModelOS.SDK.Models.Service
                     {
                     {
                         save = false;
                         save = false;
                     }
                     }
-                    else {
+                    else
+                    {
                         school_lesson_expire = setting.lessonSetting.expireDays;
                         school_lesson_expire = setting.lessonSetting.expireDays;
                         foreach (var item in setting.lessonSetting.conds)
                         foreach (var item in setting.lessonSetting.conds)
                         {
                         {
@@ -386,7 +399,8 @@ namespace TEAMModelOS.SDK.Models.Service
                         }
                         }
                     }
                     }
                 }
                 }
-                else {
+                else
+                {
                     save = false;
                     save = false;
                     school_lesson_expire = Constant.school_lesson_expire;
                     school_lesson_expire = Constant.school_lesson_expire;
                 }
                 }
@@ -401,14 +415,14 @@ namespace TEAMModelOS.SDK.Models.Service
                     //result.Add(3, day3);
                     //result.Add(3, day3);
                     //剩余1天的通知
                     //剩余1天的通知
                     var day1 = now.AddDays(school_lesson_expire - (school_lesson_expire - 1)).ToUnixTimeMilliseconds();
                     var day1 = now.AddDays(school_lesson_expire - (school_lesson_expire - 1)).ToUnixTimeMilliseconds();
-                    result.Add(1, new ExpireTag { expire= day1 ,tag= "notification" });
+                    result.Add(1, new ExpireTag { expire = day1, tag = "notification" });
                     //到期通知
                     //到期通知
                     //不到五点上传的课例,七天之后直接删除。
                     //不到五点上传的课例,七天之后直接删除。
                     int addSecond = 0;
                     int addSecond = 0;
                     if (now.Hour > 5)
                     if (now.Hour > 5)
                     {
                     {
                         // 到凌晨00点还差 (24 - now.Hour) *60 * 60 分钟,再加天数;
                         // 到凌晨00点还差 (24 - now.Hour) *60 * 60 分钟,再加天数;
-                        addSecond = school_lesson_expire * 86400 + (24 - now.Hour) * 3600-(now.Hour* 3600);
+                        addSecond = school_lesson_expire * 86400 + (24 - now.Hour) * 3600 - (now.Hour * 3600);
                         //再加 00到05小时内的 随机秒数
                         //再加 00到05小时内的 随机秒数
                         Random rand = new Random();
                         Random rand = new Random();
                         int randInt = rand.Next(0, 18000);
                         int randInt = rand.Next(0, 18000);
@@ -420,13 +434,13 @@ namespace TEAMModelOS.SDK.Models.Service
                     }
                     }
                     lessonRecord.expire = now.AddSeconds(addSecond).ToUnixTimeMilliseconds();
                     lessonRecord.expire = now.AddSeconds(addSecond).ToUnixTimeMilliseconds();
                     result.Add(school_lesson_expire, new ExpireTag { expire = lessonRecord.expire, tag = "delete" });
                     result.Add(school_lesson_expire, new ExpireTag { expire = lessonRecord.expire, tag = "delete" });
-                   // result.Add(school_lesson_expire, lessonRecord.expire);
+                    // result.Add(school_lesson_expire, lessonRecord.expire);
                     string biz = "expire";
                     string biz = "expire";
                     Notification notification = new Notification
                     Notification notification = new Notification
                     {
                     {
                         hubName = "hita",
                         hubName = "hita",
                         type = "msg",
                         type = "msg",
-                        from = $"ies5:{ Environment.GetEnvironmentVariable("Option:Location")}:private",
+                        from = $"ies5:{Environment.GetEnvironmentVariable("Option:Location")}:private",
                         to = new List<string> { tmdid },
                         to = new List<string> { tmdid },
                         label = $"{biz}_lessonRecord",
                         label = $"{biz}_lessonRecord",
                         body = new
                         body = new
@@ -491,7 +505,8 @@ namespace TEAMModelOS.SDK.Models.Service
                         }
                         }
                     }
                     }
                 }
                 }
-                else {
+                else
+                {
 
 
                     if (lessonRecord.expire > 0)
                     if (lessonRecord.expire > 0)
                     {
                     {
@@ -517,7 +532,8 @@ namespace TEAMModelOS.SDK.Models.Service
         }
         }
 
 
 
 
-        public record ExpireTag {
+        public record ExpireTag
+        {
             public long expire { get; set; }
             public long expire { get; set; }
             public string tag { get; set; }
             public string tag { get; set; }
         }
         }
@@ -536,7 +552,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 lessonDis.record = 1;
                 lessonDis.record = 1;
             }
             }
             //删除数据的情况
             //删除数据的情况
-           //不再对LessonCount进行减
+            //不再对LessonCount进行减
             else if (oldRecord != null && newRecord == null)
             else if (oldRecord != null && newRecord == null)
             {
             {
                 /*lessonDis.record = -1;
                 /*lessonDis.record = -1;
@@ -679,11 +695,12 @@ namespace TEAMModelOS.SDK.Models.Service
                         code = $"LessonCount-{data.school}-{year}";
                         code = $"LessonCount-{data.school}-{year}";
                         tbname = "School";
                         tbname = "School";
                     }
                     }
-                    else {
+                    else
+                    {
                         code = $"LessonCount-{data.school}-{year}-{data.periodId}";
                         code = $"LessonCount-{data.school}-{year}-{data.periodId}";
                         tbname = "School";
                         tbname = "School";
                     }
                     }
-                    
+
                 }
                 }
                 else
                 else
                 {
                 {
@@ -705,17 +722,17 @@ namespace TEAMModelOS.SDK.Models.Service
                 }
                 }
                 else
                 else
                 {
                 {
-                    LessonCount count = new LessonCount
+                    LessonCount count = new()
                     {
                     {
                         id = data.tmdid,
                         id = data.tmdid,
                         code = code,
                         code = code,
                         ttl = -1
                         ttl = -1
                     };
                     };
                     double[] da = new double[days];
                     double[] da = new double[days];
-                    List<double> list = new (da);
-                    List<double> listT = new (da);
-                    List<double> listP = new (da);
-                    List<double> listPT = new (da);
+                    List<double> list = new(da);
+                    List<double> listT = new(da);
+                    List<double> listP = new(da);
+                    List<double> listPT = new(da);
 
 
                     list[day - 1] += lessonDis.record;
                     list[day - 1] += lessonDis.record;
                     listT[day - 1] += lessonDis.disTCount;
                     listT[day - 1] += lessonDis.disTCount;