Browse Source

优化课例和活动统计信息

Li 2 năm trước cách đây
mục cha
commit
0ba711f58c

+ 6 - 5
TEAMModelOS.SDK/Models/Service/BI/BIActivity.cs

@@ -9,7 +9,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI.BITable;
 
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
-    public class BIActivity
+    public class BIActivityService
     {
         /// <summary>
         /// 通过时间戳保存活动统计记录统计
@@ -19,11 +19,12 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         /// <param name="_azureRedis">redis连接池</param>
         /// <param name="_dingDing">错误消息发送</param>
         /// <param name="unix">时间戳</param>
-        /// <param name="num">数量:1 -1</param>
+        /// <param name="num">数量:1 -1</param>
         /// <param name="type">活动类型:0 Exam评测  1 Survey问卷  2 Vote投票 3 Homework作业活动  </param>
+        /// <param name="scope">范围(默认学校范围):学校 school  个人 private</param>
         /// <param name="schoolId">学校编码</param>
         /// <returns></returns>
-        public static async Task SetTableStats(AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0, string schoolId = null)
+        public static async Task SetTableStats(AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0, string scope = "private", string schoolId = null)
         {
             try
             {
@@ -169,7 +170,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 }
                 catch { }
 
-                if (!string.IsNullOrEmpty(schoolId))
+                if (!string.IsNullOrEmpty(schoolId) && scope.Equals("school"))
                 {
                     try
                     {
@@ -276,7 +277,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBITableStats  活动统计异常参数:{unix}|{num}|{type}|{schoolId} ;错误信息:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBITableStats  BI记录活动统计数据异常参数:{unix}|{num}|{type}|{schoolId} ;错误信息:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
         }
 

+ 9 - 73
TEAMModelOS.SDK/Models/Service/BI/BILeeson.cs

@@ -14,7 +14,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI.BITable;
 
 namespace TEAMModelOS.SDK.Models.Service.BI
 {
-    public class BILeeson
+    public class BILeesonService
     {
         /// <summary>
         /// 通过时间戳保存开课记录和课例记录统计
@@ -239,6 +239,8 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             }
         }
 
+
+
         /// <summary>
         /// 通过时间戳保存开课记录和课例记录统计
         /// 统计数据存储在table表中
@@ -249,9 +251,10 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         /// <param name="unix">13位时间戳</param>
         /// <param name="num">数量</param>
         /// <param name="type">类型:0 开课记录  1 课例记录</param>
+        /// <param name="scope">范围(默认学校范围):学校 school  个人 private</param>
         /// <param name="schoolId">学校编码</param>
         /// <returns></returns>
-        public static async Task SetTableStats(AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0, string schoolId = null)
+        public static async Task SetTableStats(AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0,string scope = "private", string schoolId = null)
         {
             try
             {
@@ -354,7 +357,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                         if (lessYear.lesson != null)
                         {
                             double[] tempLess = Array.ConvertAll<string, double>(lessYear.lesson.Split(','), s => double.Parse(s));
-                            tempLess[hour] = tempLess[hour] + num;
+                            tempLess[days] = tempLess[days] + num;
                             string sLess = string.Join(',', tempLess);
                             lessYear.lesson = sLess;
                         }
@@ -388,75 +391,8 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 }
                 catch { }
 
-                //if (dayCnt != null && dayCnt.Length > 0)
-                //{
-                //    double[] daHour = new double[23];
-                //    foreach (var item in dayCnt)
-                //    {
-                //        double val = ((double)item.Score);
-                //        int key = ((int)item.Element);
-                //        daHour[key] = val;
-                //    }
-
-                //    string hoursStats = string.Join(",", daHour);
-                //    LessStats lessStats = table.Get<LessStats>("LessonHour", $"{dateDay}");
-                //    if (lessStats != null)
-                //    {
-                //        if (type == 1)
-                //            lessStats.lesson = hoursStats;
-                //        else
-                //            lessStats.open = hoursStats;
-                //    }
-                //    else
-                //    {
-                //        lessStats = new() { PartitionKey = "LessonHour", RowKey = $"{dateDay}" };
-                //        if (type == 1)
-                //            lessStats.lesson = hoursStats;
-                //        else
-                //            lessStats.open = hoursStats;
-                //    }
-                //    try
-                //    {
-                //        await table.SaveOrUpdate<LessStats>(lessStats);
-                //    }
-                //    catch {}
-                //}
-
-                //if (yearCnt != null && yearCnt.Length > 0)
-                //{
-                //    double[] daYear = new double[yearDays];
-                //    foreach (var item in yearCnt)
-                //    {
-                //        double val = ((double)item.Score);
-                //        int key = ((int)item.Element);
-                //        daYear[key] = val;
-                //    }
-                //    string tempStats = string.Join(",", daYear);
-                //    LessStats lessStats = table.Get<LessStats>("LessonYear", $"{year}");
-                //    if (lessStats != null)
-                //    {
-                //        if (type == 1)
-                //            lessStats.lesson = tempStats;
-                //        else
-                //            lessStats.open = tempStats;
-                //    }
-                //    else
-                //    {
-                //        lessStats = new() { PartitionKey = "LessonYear", RowKey = $"{year}" };
-                //        if (type == 1)
-                //            lessStats.lesson = tempStats;
-                //        else
-                //            lessStats.open = tempStats;
-                //    }
-                //    try
-                //    {
-                //        await table.SaveOrUpdate<LessStats>(lessStats);
-                //    }
-                //    catch { }
-                //}
-
                 //保存学校课例数据
-                if (!string.IsNullOrEmpty(schoolId))
+                if (!string.IsNullOrEmpty(schoolId) && scope.Equals("school"))
                 {
                     ////保存学校当天的统计  小时
                     //SortedSetEntry[] dayScCnt = null;
@@ -539,7 +475,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             if (lessScYear.lesson != null)
                             {
                                 double[] tempLess = Array.ConvertAll<string, double>(lessScYear.lesson.Split(','), s => double.Parse(s));
-                                tempLess[hour] = tempLess[hour] + num;
+                                tempLess[days] = tempLess[days] + num;
                                 string sLess = string.Join(',', tempLess);
                                 lessScYear.lesson = sLess;
                             }
@@ -653,7 +589,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBITableStats  BI课例统计异常参数:{unix}|{num}|{type}|{schoolId} ;错误信息:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBITableStats  BI记录课例统计数据异常参数:{unix}|{num}|{type}|{scope}|{schoolId} ;错误信息:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
         }
     }

+ 0 - 6
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -46,10 +46,4 @@
 	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.1.0" />
 	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
   </ItemGroup>
-
-
-
-  <ItemGroup>
-    <Folder Include="Models\Cosmos\BI\BICommon\" />
-  </ItemGroup>
 </Project>