Sfoglia il codice sorgente

1、优化区级统计接口返回类型
2、添加埋点方式

Li 2 anni fa
parent
commit
375c934611

+ 1 - 1
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -1054,7 +1054,7 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-            return Ok(new { state = RespondCode.Ok, areaScStats, schoolInfos, weekLess, assists = assits.Where((w, i) => assits.FindIndex(s => s.id.Equals(w.id)) == i).ToList(), saless = saless.Where((w, i) => saless.FindIndex(f => f.id.Equals(w.id)) == i).ToList(), useSize, typeStics });
+            return Ok(new { state = RespondCode.Ok, areaScStats, schoolInfos, weekLess, assists = assits.Where((w, i) => assits.FindIndex(s => s.id.Equals(w.id)) == i).ToList(), saless = saless.Where((w, i) => saless.FindIndex(f => f.id.Equals(w.id)) == i).ToList(), useSize, typeStics = typeStics.ToList() });
         }
 
         /// <summary>

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -12,6 +12,7 @@ using System.Collections.Generic;
 using System.Threading.Tasks;
 using System;
 using System.Linq;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -122,6 +123,7 @@ namespace TEAMModelOS.FunctionV4
                                 await table.Save<ChangeRecord>(changeRecord);
                                 //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
                             }
+                            await BIStats.SetTypeAddStats(client, info.school, "Exam", 1);//BI统计增/减量
                             break;
                         case "going":
 

+ 3 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerHomework.cs

@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -97,6 +98,8 @@ namespace TEAMModelOS.FunctionV4
                                 };
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
+
+                            await BIStats.SetTypeAddStats(client, work.school, "Homework", 1);//BI统计增/减量
                             break;
                         case "going":
 

+ 4 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerStudy.cs

@@ -1,5 +1,7 @@
 using Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
+using DocumentFormat.OpenXml.Office2013.Excel;
+using DocumentFormat.OpenXml.Vml;
 using HTEXLib.COMM.Helpers;
 using Microsoft.Azure.Documents;
 using Microsoft.Extensions.Configuration;
@@ -15,6 +17,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -97,6 +100,7 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
+                            await BIStats.SetTypeAddStats(client, study.school, "Study", 1);//BI统计增/减量
                             break;
                         case "going":
                             try {

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerSurvey.cs

@@ -21,6 +21,7 @@ using TEAMModelOS.SDK.Models.Service;
 using HTEXLib.COMM.Helpers;
 using Microsoft.Extensions.Configuration;
 using System.Linq;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -105,6 +106,7 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
+                            await BIStats.SetTypeAddStats(client, survey.school, "Survey", 1);//BI统计增/减量
                             break;
                         case "going":
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();

+ 2 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -19,6 +19,7 @@ using HTEXLib.COMM.Helpers;
 using Microsoft.Extensions.Configuration;
 using DocumentFormat.OpenXml.Office2013.Excel;
 using DocumentFormat.OpenXml.Vml;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4
 {
@@ -101,6 +102,7 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
+                            await BIStats.SetTypeAddStats(client, vote.school, "Vote", 1);//BI统计增/减量
                             break;
                         case "going":
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();

+ 12 - 0
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -43,6 +43,7 @@ using System.Threading;
 using System.Collections.Concurrent;
 using Microsoft.Azure.Amqp.Framing;
 using System.Security.Policy;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.FunctionV4.ServiceBus
 {
@@ -510,6 +511,13 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                 await ActivityService.FixActivity(client, _dingDing, groupChange, "Art");
                 //TODO学习活动
                 //await FixActivity(client, stuListChange, "Learn");
+                if (groupChange.type.Equals("class") || groupChange.type.Equals("student"))
+                {
+                    if (groupChange.stujoin.Count > 0)
+                        await BIStats.SetTypeAddStats(client, groupChange.school, "Student", groupChange.stujoin.Count);//BI统计增/减量
+                    if (groupChange.stuleave.Count > 0)
+                        await BIStats.SetTypeAddStats(client, groupChange.school, "Student", -groupChange.stuleave.Count);//BI统计增/减量
+                }
 
                 if (groupChange.type == null || !groupChange.type.Equals("research") || !groupChange.type.Equals("yxtrain") || !groupChange.type.Equals("activity"))
                 {
@@ -1450,6 +1458,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                     msgs.Add(update);
 
                                     DoLessonStudentRecord(_dingDing, _snowflakeId, lessonRecord, scope, client, school, tmdid, teacher,   _serviceBus, _azureStorage, _configuration, lessonBase);
+
                                 }
                                 catch (Exception ex)
                                 {
@@ -1458,6 +1467,8 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                     }
                                     
                                 }
+
+                                await BIStats.SetTypeAddStats(client, lessonRecord.school, "Less", 0, 1, lessonRecord.clientInteractionCount);//BI统计增/减量
                                 break;
                             //更新 时间线
                             case "up-TimeLine":
@@ -1763,6 +1774,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                 }
 
                                 msgs.Add(update);
+                                await BIStats.SetTypeAddStats(client, lessonRecord.school, "Less", 1, 0);//BI统计增/减量
                                 break;
                             default:
                                 break;

+ 4 - 4
TEAMModelOS.SDK/Models/Service/BI/BIStats.cs

@@ -23,10 +23,10 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         /// <param name="scId">学校id</param>
         /// <param name="type">类型:Exam(测验) Survey(问卷调查) Vote(投票) Homework(作业)  Less(课例) Student(学生)  Tchaer(教师) </param>
         /// <param name="count">增减数量 </param>
-        /// <param name="careDate">时间</param>
         /// <param name="interaction">互动</param>
+        /// <param name="careDate">时间</param>
         /// <returns></returns>
-        public static async Task SetTypeAddStats(CosmosClient cosmosClient, string scId, string type, int count, int lessType = 0, long careDate = 0, int interaction = 0)
+        public static async Task SetTypeAddStats(CosmosClient cosmosClient, string scId, string type, int count, int lessType = 0, int interaction = 0, long careDate = 0)
         {
             DateTimeOffset dateOff = DateTimeOffset.UtcNow;
             if (careDate > 1000000000000)
@@ -185,7 +185,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                     statsInfo.lesson.upTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                     break;
-                case "stu":
+                case "Student":
                     statsInfo.stuYear[dateOff.DayOfYear] += count;
                     statsInfo.stu += count;
 
@@ -196,7 +196,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
 
                     statsInfo.stuUpTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                     break;
-                case "tch":
+                case "Teacher":
 
                     statsInfo.tchYear[dateOff.DayOfYear] += count;
                     statsInfo.tch += count;

+ 1 - 0
TEAMModelOS.SDK/Models/Service/SurveyService.cs

@@ -38,6 +38,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         }
                     }
                     await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(survey, new PartitionKey($"{survey.code}"));
+
                 }
                 else
                 {

+ 4 - 0
TEAMModelOS/Controllers/System/CoreController.cs

@@ -37,6 +37,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.PngQuant;
 using Top.Api;
 using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
@@ -250,6 +251,8 @@ namespace TEAMModelOS.Controllers
                                                 code = 2;
                                                 msg = "操作成功";
                                                 msg = status.TryGetProperty($"code{code}", out JsonElement text) ? $"{text}" : msg;
+
+                                                await BIStats.SetTypeAddStats(_azureCosmos.GetCosmosClient(), $"{_schoolId}", "Teacher", 1);//BI统计增/减量
                                             }
                                             //拒绝
                                             int count = 0;
@@ -331,6 +334,7 @@ namespace TEAMModelOS.Controllers
                                         code = 2;
                                         msg = "操作成功";
                                         msg = status.TryGetProperty($"code{code}", out JsonElement text) ? $"{text}" : msg;
+                                        await BIStats.SetTypeAddStats(_azureCosmos.GetCosmosClient(), $"{_schoolId}", "Teacher", 1);//BI统计增/减量
                                     }
                                     //拒绝
                                     int count = 0;