CrazyIter_Bin 3 anos atrás
pai
commit
ac35524cdd

+ 4 - 0
TEAMModelFunction/MonitorServicesBus.cs

@@ -812,6 +812,8 @@ namespace TEAMModelFunction
             try
             {
                 LessonRecord lessonRecord = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<LessonRecord>($"{_lessonId}", new PartitionKey(code));
+                LessonRecord oldlessonRecord= lessonRecord;
+               
                 if (_grant_types.ValueKind.Equals(JsonValueKind.Array))
                 {
                     List<LessonUpdate> updates = _grant_types.ToObject<List<LessonUpdate>>();
@@ -866,6 +868,8 @@ namespace TEAMModelFunction
                                 break;
                         }
                     }
+                    //计算课堂更新前后的差值
+                    LessonService.DisLessonCount(oldlessonRecord, lessonRecord);
                     await LessonService.FixLessonCount(client, _dingDing, lessonRecord);
                     await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(lessonRecord,$"{_lessonId}", new PartitionKey(code));
                 }

+ 18 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/LessonRecord.cs

@@ -145,4 +145,22 @@ namespace TEAMModelOS.SDK.Models
         public string grant_type { get; set; }
         public object data { get; set; }
     }
+    /// <summary>
+    /// 课堂记录更新前后差值
+    /// </summary>
+    public class LessonDis
+    {
+        /// <summary>
+        /// T分数量差
+        /// </summary>
+        public int disTCount { get; set; }
+        /// <summary>
+        /// P分数量差
+        /// </summary>
+        public int disPCount { get; set; }
+        /// <summary>
+        /// 双绿灯数量差
+        /// </summary>
+        public int disDCount { get; set; }
+    }
 }

+ 60 - 0
TEAMModelOS.SDK/Models/Service/LessonService.cs

@@ -13,6 +13,66 @@ namespace TEAMModelOS.SDK.Models.Service
 {
     public class LessonService
     {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="client"></param>
+        /// <param name="_dingDing"></param>
+        /// <param name="data"></param>
+        /// <returns></returns>
+        public static LessonDis DisLessonCount( LessonRecord oldRecord, LessonRecord newRecord ) {
+            //P分数量加减
+
+            LessonDis lessonDis = new LessonDis();
+            if (oldRecord.pScore >= 70)
+            {
+                if (newRecord.pScore < 70)
+                {
+                    lessonDis. disPCount = -1;
+                }
+            }
+            else
+            {
+                if (newRecord.pScore >= 70)
+                {
+                    lessonDis.disPCount = 1;
+                }
+            }
+            //T分数量加减
+           
+            if (oldRecord.tScore >= 70)
+            {
+                if (newRecord.tScore < 70)
+                {
+                    lessonDis.disTCount = -1;
+                }
+            }
+            else
+            {
+                if (newRecord.tScore >= 70)
+                {
+                    lessonDis.disTCount = 1;
+                }
+            }
+            //双绿灯数量
+            
+            if (oldRecord.tScore >= 70 && oldRecord.pScore >= 70)
+            {
+                if (newRecord.tScore < 70 || newRecord.pScore < 70)
+                {
+                    lessonDis.disDCount = -1;
+                }
+            }
+            else
+            {
+                if (newRecord.tScore >= 70 && newRecord.pScore >= 70)
+                {
+                    lessonDis.disDCount = 1;
+                }
+            }
+            return lessonDis;
+        }
+
         public static async Task FixLessonCount(CosmosClient client, DingDing _dingDing, LessonRecord data)
         {
             try