CrazyIter_Bin 1 年之前
父节点
当前提交
6316f98cc5

+ 3 - 3
TEAMModelBI/TEAMModelBI.csproj

@@ -65,9 +65,9 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2405.22</Version>
-		<AssemblyVersion>5.2405.22.1</AssemblyVersion>
-		<FileVersion>5.2405.22.1</FileVersion>
+		<Version>5.2405.29</Version>
+		<AssemblyVersion>5.2405.29.1</AssemblyVersion>
+		<FileVersion>5.2405.29.1</FileVersion>
 		<Description>TEAMModelBI(BI)</Description>
 		<PackageReleaseNotes>BI版本说明版本切换标记2022000908</PackageReleaseNotes>
 		<PackageId>TEAMModelBI</PackageId>

+ 1 - 1
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -2496,7 +2496,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                     foreach (var stu in stus.EnumerateArray())
                     {
                         await foreach (Response item in db.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator(
-                        queryText: $"SELECT TOP 1 * FROM c WHERE c.stuid = '{stu.GetString()}'",
+                        queryText: $"SELECT TOP 1 * FROM c WHERE c.stuid = '{stu.GetString()}' and c.school='{school}'  ",
                         requestOptions: new() { PartitionKey = new($"Imei") }))
                         {
                             using var root = await JsonDocument.ParseAsync(item.ContentStream);

+ 3 - 3
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -5,9 +5,9 @@
 		<OutputType>Exe</OutputType>
 		<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
 		<SignAssembly>true</SignAssembly>
-		<Version>5.2405.22</Version>
-		<AssemblyVersion>5.2405.22.1</AssemblyVersion>
-		<FileVersion>5.2405.22.1</FileVersion>
+		<Version>5.2405.29</Version>
+		<AssemblyVersion>5.2405.29.1</AssemblyVersion>
+		<FileVersion>5.2405.29.1</FileVersion>
 		<PackageId>TEAMModelOS.FunctionV4</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 16 - 0
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -3,6 +3,7 @@ using Azure.Storage.Blobs.Models;
 using Azure.Storage.Blobs.Specialized;
 using DinkToPdf;
 using DinkToPdf.Contracts;
+using DocumentFormat.OpenXml.Spreadsheet;
 using HTEXLib.COMM.Helpers;
 using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Azure.Functions.Worker;
@@ -26,6 +27,7 @@ using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
+using TEAMModelOS.SDK.Models.Cosmos.School;
 using TEAMModelOS.SDK.Models.Cosmos.Teacher;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.SDK.Models.Service.BI;
@@ -62,7 +64,21 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
             _ipSearcher = ipSearcher;
             _longitudeLatitudeTranslator = longitudeLatitudeTranslator;
         }
+        /// <summary>
+        /// 防火墙日志记录文件
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [Function("DailyReport")]
+        //https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp
+        //0 1 * * * * 一天中每小时的第 1 分钟
+        //0 */10 * * * *  每五分钟一次
+        public async Task DailyReport([TimerTrigger("0 1 * * * *")] TimerInfo myTimer, ILogger log)
+        {
+            
 
+        }
         /// <summary>
         /// 防火墙日志记录文件
         /// </summary>

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Teacher/Teacher.cs

@@ -27,6 +27,7 @@ namespace TEAMModelOS.SDK.Models
         public List<LoginInfo> loginInfos { get; set; } = new List<LoginInfo>();
 
         public string lang { get; set; }
+        public double timezone { get; set; } = 8;
 
         public class LoginInfo
         {

+ 6 - 2
TEAMModelOS.SDK/Models/Service/Common/TeacherService.cs

@@ -144,6 +144,7 @@ namespace TEAMModelOS.Services
                         teacher.defaultSchool = null;
                     }
                 }
+                teacher.timezone=timezone;
                 await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                 //預設學校ID
                 defaultschool = teacher.defaultSchool;
@@ -165,7 +166,8 @@ namespace TEAMModelOS.Services
                         size = 1,
                         defaultSchool = null,
                         schools = new List<Teacher.TeacherSchool>(),
-                        lang=lang
+                        lang=lang,
+                        timezone=timezone,
                     };
                     var container = _azureStorage.GetBlobContainerClient(id);
                     await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
@@ -431,6 +433,7 @@ namespace TEAMModelOS.Services
                         teacher.defaultSchool = null;
                     }
                 }
+                teacher.timezone=timezone;
                 await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, id, new PartitionKey("Base"));
                 //預設學校ID
                 defaultschool = teacher.defaultSchool;
@@ -452,7 +455,8 @@ namespace TEAMModelOS.Services
                         size = 1,
                         defaultSchool = null,
                         schools = new List<Teacher.TeacherSchool>(),
-                        lang=lang
+                        lang=lang,
+                        timezone=timezone,
                     };
                     var container = _azureStorage.GetBlobContainerClient(id);
                     await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在

+ 64 - 0
TEAMModelOS.SDK/Models/Service/SystemService.cs

@@ -7,6 +7,7 @@ using HTEXLib.COMM.Helpers;
 using Microsoft.Azure.Amqp.Framing;
 using Newtonsoft.Json.Linq;
 using OpenXmlPowerTools;
+using StackExchange.Redis;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -29,6 +30,69 @@ namespace TEAMModelOS.SDK.Models.Service
 {
     public static class SystemService
     {
+
+
+        public static async Task AccumulateDaily(AzureRedisFactory _azureRedis,AzureCosmosFactory _azureCosmos)
+        {
+            DateTimeOffset now = DateTimeOffset.UtcNow;
+            string day = now.ToString("yyyyMMdd");
+            //当天的个人评测提交数
+            Dictionary<string, double?> exam_submit = new();
+            List<string> keys = new List<string>();
+            SortedSetEntry[] exam_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:private:exam-submit:{day}");
+            if (exam_submitScores != null)
+            {
+                foreach (var score in exam_submitScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                    exam_submit.Add(key, val);
+                    keys.Add(key);
+                }
+            }
+            List<string> homeworkIds = new List<string>();
+            //当天的个人作业提交数
+            SortedSetEntry[] homework_submitScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:homework-submit:{day}");
+            Dictionary<string, double?> homework_submit = new();
+            if (homework_submitScores != null)
+            {
+                foreach (var score in homework_submitScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                    homework_submit.Add(key, val);
+                    keys.Add(key);
+                    homeworkIds.Add(key.Split("::")[1]);
+                }
+            }
+            //当天的个人名单加入人数
+            Dictionary<string, double?> grouplist = new();
+            SortedSetEntry[] grouplistScores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Accumulate:Daily:teacher:grouplist:{day}");
+            if (grouplistScores != null)
+            {
+                foreach (var score in grouplistScores)
+                {
+                    double val = score.Score;
+                    string key = score.Element.ToString();
+                    grouplist.Add(key, val);
+                    keys.Add(key);
+                }
+            }
+            List<string> ids = new List<string>();
+            keys.ForEach(x => {
+                ids.Add(x.Split("::")[0]);
+            });
+            List<Teacher> teachers= new List<Teacher>();
+            if (ids.IsNotEmpty()) 
+            {
+                string sql = $"select value c from c where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))})";
+                var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetList<Teacher>(sql, "Base");
+                if (result.list.IsNotEmpty()) 
+                {
+                    teachers.AddRange(result.list);
+                }
+            }
+        }
         public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, DingDing dingDing, Accumulate accumulate)
         {
             if (!string.IsNullOrWhiteSpace(accumulate.key)  && !string.IsNullOrWhiteSpace(accumulate.target) &&

+ 3 - 3
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -2,9 +2,9 @@
 
 	<PropertyGroup>
 		<TargetFramework>net6.0</TargetFramework>
-		<Version>5.2405.22</Version>
-		<AssemblyVersion>5.2405.22.1</AssemblyVersion>
-		<FileVersion>5.2405.22.1</FileVersion>
+		<Version>5.2405.29</Version>
+		<AssemblyVersion>5.2405.29.1</AssemblyVersion>
+		<FileVersion>5.2405.29.1</FileVersion>
 		<PackageReleaseNotes>发版</PackageReleaseNotes>
 	</PropertyGroup>
 

+ 17 - 4
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -1773,7 +1773,9 @@ namespace TEAMModelOS.Controllers.Client
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        [Authorize(Roles = "HiTeach")]
+#if !DEBUG
+ [Authorize(Roles = "HiTeach")]
+#endif
         [ProducesDefaultResponseType]
         [HttpPost("create-lesson")]
         public async Task<IActionResult> CreateLesson(CreateLessondRequest request)
@@ -1873,9 +1875,20 @@ namespace TEAMModelOS.Controllers.Client
                         }
                     }
                     var stus = students.Select(x => x.id).ToList();
-                    var imeimsg = new ServiceBusMessage(new { request.channel, userid = request.did, request.school, stus, imeiType }.ToJsonString());
-                    imeimsg.ApplicationProperties.Add("name", "Imei");
-                    sbm.Add(imeimsg);
+                    if (stus.IsNotEmpty()  && !string.IsNullOrWhiteSpace(request.school)) 
+                    {
+                        string sql = $"select value  count(1) from c   where c.stuid in({string.Join (",",stus.Select(x=>$"'{x}'"))}) and c.school='{request.school}' ";
+                        var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<int>(sql, "Imei");
+                        if (result.list.IsNotEmpty() && result.list[0]>0)
+                        {
+                            var imeimsg = new ServiceBusMessage(new { request.channel, userid = request.did, request.school, stus, imeiType }.ToJsonString());
+                            imeimsg.ApplicationProperties.Add("name", "Imei");
+                            sbm.Add(imeimsg);
+                        }
+                        else {
+                            imeiType=string.Empty;
+                        }
+                    }
                 }
                 //開課記錄保存
                 LessonRecord lr = new()

+ 13 - 7
TEAMModelOS/Controllers/Third/IRS/ThirdIRSController.cs

@@ -48,7 +48,9 @@ namespace TEAMModelOS.Controllers
         //};
         public readonly static Dictionary<string, (string scope, string imeiType)> areaSchools =  new Dictionary<string, (string scope, string imeiType)>
         {
-            {"2ffbd7f9-2445-4139-90a7-59e27c0d097e",("grouplist","ThirdIRS_139zhxy") }
+            {"2ffbd7f9-2445-4139-90a7-59e27c0d097e",("grouplist","ThirdIRS_139zhxy") },
+            {"hbcn",("school","ThirdIRS_139zhxy") },
+            {"habook",("school","ThirdIRS_139zhxy") }
         };
         
         public AzureCosmosFactory _azureCosmos;
@@ -110,8 +112,8 @@ namespace TEAMModelOS.Controllers
                                 httpClient.DefaultRequestHeaders.Remove("timestamp");
                             }
                             httpClient.DefaultRequestHeaders.Add("timestamp", $"{now}");
-                            var phones = result.list.Where(y => y.id.Length==11).Select(x => x.id);
-                            if (phones!=null  && phones.Count()>0)
+                            var imeis = result.list.Select(x => x.id);
+                            if (imeis!=null  && imeis.Count()>0)
                             {
                                 switch (lessonTask.type)
                                 {
@@ -136,7 +138,7 @@ namespace TEAMModelOS.Controllers
                                                 items.Add(new { type = type, id = order, topicList = item.question });
                                                 order++;
                                             }
-                                            var data = new { phones, workId = lessonTask.id, title = lessonTask.examTask.title, works = items, callbackUrl };
+                                            var data = new { /*phones,*/ imeis= imeis, workId = lessonTask.id, title = lessonTask.examTask.title, works = items, callbackUrl };
                                             HttpResponseMessage httpResponse = await httpClient.PostAsJsonAsync($"{URL139zhxy}/apiBaseData/studentCard/work/push", data);
                                             if (httpResponse.StatusCode.Equals(HttpStatusCode.OK))
                                             {
@@ -204,9 +206,12 @@ namespace TEAMModelOS.Controllers
                         if (!data.IsNullOrEmpty)
                         {
                             LessonTask lessonTask = data.ToString().ToObject<LessonTask>();
-
-
-                            Imei stu = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemAsync<Imei>(result.phone, new PartitionKey("Imei"));
+                            string kid = result.imei;
+                            if (string.IsNullOrWhiteSpace(result.imei)) 
+                            {
+                                kid=result.phone;
+                            }
+                            Imei stu = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemAsync<Imei>(kid, new PartitionKey("Imei"));
                             if (!string.IsNullOrWhiteSpace(stu?.channel) && !string.IsNullOrWhiteSpace(stu?.userid)  && lessonTask.channel.Equals(stu?.channel))
                             {
                                 // 處理單例復用,提高請求效率,避免ServiceTransportType.Persistent websocket斷線在Azure偶發的消息遺失
@@ -449,6 +454,7 @@ namespace TEAMModelOS.Controllers
     public class ZHXY139IRSResult
     {
         public string phone { get; set; }
+        public string imei {  get; set; }
         public string workId { get; set; }
         public List<ZHXY139IRSAnswer> answers { get; set; }
     }

+ 4 - 4
TEAMModelOS/TEAMModelOS.csproj

@@ -79,11 +79,11 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2405.22</Version>
-		<AssemblyVersion>5.2405.22.1</AssemblyVersion>
-		<FileVersion>5.2405.22.1</FileVersion>
+		<Version>5.2405.29</Version>
+		<AssemblyVersion>5.2405.29.1</AssemblyVersion>
+		<FileVersion>5.2405.29.1</FileVersion>
 		<Description>TEAMModelOS(IES5)</Description>
-		<PackageReleaseNotes>IES版本说明版本切换标记5.2405.22.1</PackageReleaseNotes>
+		<PackageReleaseNotes>IES版本说明版本切换标记5.2405.29.1</PackageReleaseNotes>
 		<PackageId>TEAMModelOS</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 1 - 1
TEAMModelOS/appsettings.Development.json

@@ -18,7 +18,7 @@
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
     //"HttpTrigger": "http://localhost:7071/api/"
-    "Version": "5.2405.22.1"
+    "Version": "5.2405.29.1"
   },
   "Azure": {
 

+ 1 - 1
TEAMModelOS/appsettings.json

@@ -18,7 +18,7 @@
     "Exp": 86400,
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction.chinacloudsites.cn/api/",
-    "Version": "5.2405.22.1"
+    "Version": "5.2405.29.1"
   },
   "Azure": {
     "Storage": {