CrazyIter_Bin 1 ano atrás
pai
commit
9ba09d313f

+ 1 - 1
TEAMModelOS.FunctionV4/CosmosDB/CommonTrigger.cs

@@ -85,7 +85,7 @@ namespace TEAMModelOS.FunctionV4
                                 switch (data.pk)
                                 {
                                     case "Exam":
-                                        await TriggerExam.Trigger(_coreAPIHttpService, _azureCosmos, _serviceBus, _azureStorage, _dingDing, client, element, data, _httpClient, _configuration,_httpTrigger);
+                                        await TriggerExam.Trigger(_coreAPIHttpService, _azureCosmos, _serviceBus, _azureStorage, _dingDing, client, element, data, _httpClient, _configuration,_httpTrigger,_azureRedis);
                                         break;
                                     case "Vote":
                                         await TriggerVote.Trigger(_coreAPIHttpService, _serviceBus, _azureStorage, _dingDing, client, element, data, _azureRedis, _configuration);

+ 6 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -43,7 +43,7 @@ namespace TEAMModelOS.FunctionV4
     public class TriggerExam
     {
         public static async Task Trigger(CoreAPIHttpService _coreAPIHttpService, AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
-            CosmosClient client, JsonElement input, TriggerData data, IHttpClientFactory _httpClient, IConfiguration _configuration, HttpTrigger _httpTrigger)
+            CosmosClient client, JsonElement input, TriggerData data, IHttpClientFactory _httpClient, IConfiguration _configuration, HttpTrigger _httpTrigger,AzureRedisFactory _azureRedis)
         {
 
             List<ExamClassResult> examClassResults = new();
@@ -183,6 +183,11 @@ namespace TEAMModelOS.FunctionV4
                                 //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageBlob);
                                 #endregion
                                 //List<string> classes = new List<string>();
+                                if (info!=null && info.scope.Equals("private"))
+                                {
+                                    await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=info.id, key="exam-going", name=info.name, scope="teacher", target=info.creatorId });
+                                }
+
                                 //处理活动中间件
                                 List<RGroupList> members = await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
                                 if (examClassResults.Count == 0)

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

@@ -132,6 +132,10 @@ namespace TEAMModelOS.FunctionV4
                                     };
                                     await table.Save<ChangeRecord>(changeRecord);
                                 }
+                                if (work!=null && work.scope.Equals("private"))
+                                {
+                                    await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new SDK.Models.Dtos.Accumulate { client="web", count=1, id=work.id, key="homework-going", name=work.name, scope="teacher", target=work.creatorId });
+                                }
                             } catch (Exception e) {
                                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修作业活动going{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
                             }

+ 126 - 7
TEAMModelOS.SDK/Models/Service/SystemService.cs

@@ -31,14 +31,59 @@ namespace TEAMModelOS.SDK.Models.Service
     public static class SystemService
     {
 
-
-        public static async Task AccumulateDaily(AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos)
+        static string cn_wb = @"
+IES晚报:
+    尊敬的{tmdname}您好,以下是您的今日个人IES教学汇总报告,截至{sendTime},您已发布{examCount}次评测任务,{homeworkCount}次作业任务,并使用HiTeach教师端开设了{lessonCount}节课堂教学活动。
+    以下是报告的具体详细信息。
+    评测任务提交详情:
+        {examList}
+    课堂教学出席详情:
+        {lessonList}
+    个人课程名单变化详情:
+        {cn_grouplistJoin}
+        {cn_grouplistLeave}
+    如有布置作业任务,将于次日8点通过早报方式发送。
+";
+        static string cn_examList = "{examName}已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。";
+        static string cn_lessonList = "{lessonName}课例应出席人数{memberCount},实际出席人数{attendCount},出席率{attendRate}。";
+        static string cn_grouplistJoin = "{grouplistName}已有总人数{memberCount},有{joinCount}加入。";
+        static string cn_grouplistLeave = "{grouplistName}已有总人数{memberCount},有{joinCount}离开。";
+
+        static string cn_zb = @"
+IES早报:
+    尊敬的{tmdname}您好,以下是您发布过的作业任务汇总报告。
+     以下是报告的具体详细信息。
+     作业任务提交详情:
+        {cn_homeworkList}
+";
+        static string cn_homeworkList = "{homeworkName}已经有{submitCount}位学生提交,仍有{unsubmitCount}位学生未提交。";
+
+        public static async Task AccumulateDaily(AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos,CoreAPIHttpService coreAPIHttpService, DingDing dingDing)
         {
             DateTimeOffset now = DateTimeOffset.UtcNow;
             string day = now.ToString("yyyyMMdd");
+            string homeworkYesterday = now.AddDays(-1).ToString("yyyyMMdd");
+            List<string> keys = new List<string>();
+            //当天评测发布的。
             //当天的个人评测提交数
             Dictionary<string, double?> exam_submit = new();
-            List<string> keys = new List<string>();
+            SortedSetEntry[] exam_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:private:exam-going:{day}");
+          //  Dictionary<string, double?> exam_going = new();
+            if (exam_goingScores != null)
+            {
+                foreach (var score in exam_goingScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                   // exam_going.Add(key, val);
+                    exam_submit.Add(key, val);
+                    keys.Add(key);
+                }
+            }
+
+           
+           
+            ///需要再次获取 没有任何人提交的作业和评测任务。
             SortedSetEntry[] exam_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:private:exam-submit:{day}");
             if (exam_submitScores != null)
             {
@@ -50,10 +95,27 @@ namespace TEAMModelOS.SDK.Models.Service
                     keys.Add(key);
                 }
             }
-            List<string> homeworkIds = new List<string>();
-            //当天的个人作业提交数
-            SortedSetEntry[] homework_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-submit:{day}");
+           
+            //昨天发布的作业
+            SortedSetEntry[] homework_goingScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-going:{homeworkYesterday}");
             Dictionary<string, double?> homework_submit = new();
+            //Dictionary<string, double?> homework_going = new();
+            if (homework_goingScores != null)
+            {
+                foreach (var score in homework_goingScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                    //homework_going.Add(key, val);
+                    homework_submit.Add(key, val);
+                    keys.Add(key);
+                    
+                }
+            }
+
+            //昨天的个人作业提交数
+            SortedSetEntry[] homework_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-submit:{homeworkYesterday}");
+           
             if (homework_submitScores != null)
             {
                 foreach (var score in homework_submitScores)
@@ -62,7 +124,6 @@ namespace TEAMModelOS.SDK.Models.Service
                     string key = score.Element.ToString();
                     homework_submit.Add(key, val);
                     keys.Add(key);
-                    homeworkIds.Add(key.Split("::")[1]);
                 }
             }
             //当天的个人名单加入人数
@@ -78,6 +139,19 @@ namespace TEAMModelOS.SDK.Models.Service
                     keys.Add(key);
                 }
             }
+            //当天教师的开课数量Accumulate:Daily:teacher:lesson-create:20240527
+            Dictionary<string, double?> lessoncreate = new();
+            SortedSetEntry[] llessoncreateScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:lesson-create:{day}");
+            if (llessoncreateScores != null)
+            {
+                foreach (var score in llessoncreateScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                    lessoncreate.Add(key, val);
+                    keys.Add(key);
+                }
+            }
             List<string> ids = new List<string>();
             keys.ForEach(x => {
                 ids.Add(x.Split("::")[0]);
@@ -92,6 +166,51 @@ namespace TEAMModelOS.SDK.Models.Service
                     teachers.AddRange(result.list);
                 }
             }
+
+            foreach (var teacher in teachers) 
+            {
+                int examCount = 0,homeworkCount=0,lessonCount=0;
+                StringBuilder examSB= new StringBuilder();
+                foreach (var exam in exam_submit)
+                {
+                    int sendTime = 20;
+                    string[] ks = exam.Key.Split("::");
+                    string tid = ks[0];
+                    string examId = ks[1];
+                    string examName = ks[3];
+                    if (tid.Equals(teacher.id)) {
+                        var tzt = now.GetGMTTime((int)teacher.timezone);
+                        if (tzt.Hour==sendTime)
+                        {
+                            string sql = $"select c.status  from c where c.examId='{examId}' and c.pk='ExamClassResult'";
+                            var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<ExamClassResult>("", $"ExamClassResult-{tid}");
+                            if (result.list.IsNotEmpty()) {
+                                var unsubmit = result.list.SelectMany(x => x.status).Where(x => x==1);
+                                var submit = result.list.SelectMany(x => x.status).Where(x => x==0);
+                                examCount++;
+                                examSB.Append(cn_examList.Replace("{examName}",examName).Replace("{submitCount}",$"{submit}").Replace("{unsubmitCount}",$"{unsubmit}"));
+                            }
+
+                        }
+                    }
+                }
+                foreach (var homework in homework_submit) 
+                {
+                    int sendTime = 8;
+                    string[] ks = homework.Key.Split("::");
+                    string tid = ks[0];
+                    string examId = ks[1];
+                    string examName = ks[3];
+                    if (tid.Equals(teacher.id))
+                    {
+                        var tzt = now.GetGMTTime((int)teacher.timezone);
+                        if (tzt.Hour==sendTime)
+                        {
+                            string sql = $"select c.status  from c where c.examId='{examId}' and c.pk='ExamClassResult'";
+                        }
+                    }
+                }
+            }
         }
         public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, DingDing dingDing, Accumulate accumulate)
         {

+ 2 - 0
TEAMModelOS/Controllers/Third/Moofen/MoofenController.cs

@@ -199,7 +199,9 @@ namespace TEAMModelOS.Controllers.Third.Moofen
 
         [HttpPost("moofen/question")]
         [AuthToken(Roles = "teacher,admin")]
+#if !DEBUG
         [Authorize(Roles = "IES")]
+#endif
         public async Task<IActionResult> Question(JsonElement json) 
         {
             var tokenData= HttpContext.GetAuthTokenInfo();

+ 5 - 0
TEAMModelOS/Lang/zh-cn.json

@@ -35,6 +35,10 @@
   "blob-space-school-notify": [ "剩余空间不足", "亲爱的{schoolName}管理员{tmdname}您好,提醒您贵校剩余空间不足{percent}%,请联系官方客服购买空间,详情请登入IES(www.teammodel.cn)查看,如果已经扩容请忽略此通知。" ],
   "blob-space-private-notify": [ "剩余空间不足", "亲爱的{tmdname}您好,提醒您的帐号{tmdid}授权的剩余空间不足{percent}%,请联系学校管理员配置或是购买个人空间,如果已经扩容请忽略此通知。" ],
   "school-scale-notify": [ "学生登录数已达学校规模数上限", "亲爱的{schoolName}管理员{tmdname}您好,提醒您贵校学生登录数已达规模数上限:({scale}),请联系官方客服购买规模数,详情请登入IES(www.teammodel.cn)查看,如果已经购买请忽略此通知。" ],
+  "exam-submit-private-notify": [ "评测作答提交汇总通知", "{tmdname}您好,你发布的评测:{examName},截至{sendTime},已经有{submitCount}位学生提交,仍有{unsubmitCont}位学生未提交,请查收。" ],
+  "homework-submit-private-notify": [ "作业提交汇总通知", "{tmdname}您好,你发布的作业:{homeworkName},截至{sendTime},已经有{submitCount}位学生提交,仍有{unsubmitCont}位学生未提交,请查收。" ],
+  "grouplist-join-private-notify": [ "名单人员变化通知", "{tmdname}您好,你的个人课程名单:{grouplistName}已有总人数{memberCount},{sendTime}有{joinCount}加入/离开。" ],
+  "lesson-create-private-notify": [ "名单人员变化通知", "{tmdname}您好,截至当天{sendTime},您使用HiTeach开课数量为{lessonCount}," ],
   "notify-status": {
     "code0": "凭据失效",
     "code1": "参数异常",
@@ -100,4 +104,5 @@
     "art-read": "艺术评测查看权限",
     "art-upd": "艺术评测管理权限"
   }
+  "": ""
 }