CrazyIter_Bin пре 1 година
родитељ
комит
8bd65ee6bc

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

@@ -302,7 +302,6 @@ namespace TEAMModelOS.SDK.Models.Service
                     record.gscore = record.lessonRecords.Select(x => x.gscore).Sum();
                     record.pscore = record.lessonRecords.Select(x => x.pscore).Sum();
                     record.tscore = record.lessonRecords.Select(x => x.tscore).Sum();
-                   
                     if (dataSemester.currSemester != null  && (clientSummaryList.groupScore>0  || clientSummaryList.score > 0 || clientSummaryList.tnteractScore > 0)) {
                         string oid = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{record.stuid}"; 
                         string ocode = $"OverallEducation-{school}";

+ 12 - 1
TEAMModelOS.SDK/Models/Service/SchoolService.cs

@@ -283,9 +283,20 @@ namespace TEAMModelOS.SDK
         /// </summary>
         /// <param name="semesterList"></param>
         /// <returns></returns>
-        public static (Semester currSemester,  int studyYear, DateTimeOffset date, DateTimeOffset nextSemester) GetSemester(  Period period, string time =null) {
+        public static (Semester currSemester,  int studyYear, DateTimeOffset date, DateTimeOffset nextSemester) GetSemester(  Period period, long timestamp = 0,  string time =null) {
             //string time = "2023/05-11";
             DateTimeOffset date = default;
+            if (timestamp > 1000000000) {
+                //毫秒级
+                if (timestamp > 1000000000000)
+                {
+                    date = DateTimeOffset.FromUnixTimeMilliseconds(timestamp);
+                }
+                //秒级
+                else {
+                    date = DateTimeOffset.FromUnixTimeSeconds(timestamp);
+                }
+            }
             if (!(!string.IsNullOrWhiteSpace(time) && DateTimeOffset.TryParse(time, out date)))
             {
                 //date = DateTimeOffset.FromUnixTimeSeconds(1672506061);

+ 1 - 1
TEAMModelOS/Controllers/Both/CourseBaseController.cs

@@ -708,7 +708,7 @@ namespace TEAMModelOS.Controllers.Both
                                     continue;
                                 }
                                 //获取当前学年,当前学期,当前导入时间的日期,以及下学期开学时间
-                                (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester) info = SchoolService.GetSemester(period, item.stime);
+                                (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester) info = SchoolService.GetSemester(period,time: item.stime);
                                 if (info.currSemester != null)
                                 {
                                     //5.2检查课程结束日期格式是否正确

+ 156 - 6
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -49,6 +49,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
+using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Services;
@@ -96,12 +97,161 @@ namespace TEAMModelOS.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("transform-lessonrecord-overalleducation")]
         public async Task<IActionResult> TransformLessonrecordOveralleducation(JsonElement json) {
-            string msg = json.ToString();
-            var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-            var messageChange = new ServiceBusMessage(msg);
-            messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
-            //await _dingDing.SendBotMsg($"{_option.Location},课堂id:{_lessonId} 更新事件,{msg}", GroupNames.醍摩豆服務運維群組);
-            await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+            //string msg = json.ToString();
+            //var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+            //var messageChange = new ServiceBusMessage(msg);
+            //messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
+            //await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+            string sql = "select value c from  c  where  c.pk='StudentScoreRecord' and c.userType='student' and c.school<>null  and c.school<>'' ";
+            List<StudentScoreRecord> studentScores = new List<StudentScoreRecord>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<StudentScoreRecord>(sql)) {
+                studentScores.Add(item);
+            }
+            var group = studentScores.GroupBy(z => z.school);
+            string schoolSql = $"select value c from c where c.id in ({string.Join(",",group.Select(x=>$"'{x.Key}'"))})";
+            var resultScool= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(schoolSql,"Base");
+            foreach(var item in group)
+            {
+                var list = item.ToList();
+                var stuids = list.Select(z => z.stuid);
+                string studentSql = $"select value c from c where c.id in ({string.Join(",", stuids.Select(x => $"'{x}'"))})";
+                var resultStuden = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>(studentSql, $"Base-{item.Key}");
+               
+                foreach (var sturecord in list) {
+                    HashSet<OverallEducation> overallEducations = new HashSet<OverallEducation>();
+                    var studentBase = resultStuden.list.Find(x => x.id.Equals(sturecord.stuid, StringComparison.OrdinalIgnoreCase));
+                    var schoolBase = resultScool.list.Find(x => x.id.Equals(sturecord.school, StringComparison.OrdinalIgnoreCase));
+                    if (studentBase == null) {
+                        continue;
+                    }
+                    var  period = schoolBase.period.Find(x => x.id.Equals($"{studentBase.periodId}"));
+                    foreach (var record in sturecord.lessonRecords) {
+                        if (record.time > 1000000000000) {
+                            (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester) dataSemester = SchoolService.GetSemester(period, record.time);
+                            string oid = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{sturecord.stuid}";
+                            string ocode = $"OverallEducation-{sturecord.school}";
+                            OverallEducation overallEducation =  overallEducations.Where(o => o.id.Equals(oid, StringComparison.OrdinalIgnoreCase) && o.code.Equals(ocode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+                            if (overallEducation != null)
+                            {
+                                var hasrecord = overallEducation.lessonScore.Find(x => x.lessonId.Equals(record.lessonId));
+                                if (hasrecord != null)
+                                {
+                                    hasrecord.gscore = record.gscore;
+                                    hasrecord.pscore = record.pscore;
+                                    hasrecord.tscore = record.tscore;
+                                    hasrecord.tmdid = record.tmdid;
+                                    hasrecord.school = record.school;
+                                    hasrecord.scope = record.scope;
+                                    hasrecord.lessonId = record.lessonId;
+                                    hasrecord.courseId = record.courseId;
+                                    hasrecord.periodId = record.periodId;
+                                    hasrecord.subjectId = record.subjectId;
+                                    hasrecord.time = record.time;
+                                }
+                                else
+                                {
+                                    overallEducation.lessonScore.Add(
+                                         new StudentLessonRecord
+                                         {
+                                             gscore = record.gscore,
+                                             pscore = record.pscore,
+                                             tscore = record.tscore,
+                                             tmdid = record.tmdid,
+                                             school = record.school,
+                                             scope = record.scope,
+                                             lessonId = record.lessonId,
+                                             courseId = record.courseId,
+                                             periodId = record.periodId,
+                                             subjectId = record.subjectId,
+                                             time = record.time
+                                         }
+                                     );
+                                }
+                            }
+                            else {
+                                Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemStreamAsync(oid, new PartitionKey(ocode));
+                                if (response.Status != 200)
+                                {
+                                    overallEducation = new OverallEducation
+                                    {
+                                        id = oid,
+                                        code = $"OverallEducation-{sturecord.school}",
+                                        pk = "OverallEducation",
+                                        ttl = -1,
+                                        name = studentBase.name,
+                                        classId = studentBase?.classId,
+                                        schoolCode = $"{sturecord.school}",
+                                        semesterId = dataSemester.currSemester.id,
+                                        year = dataSemester.studyYear,
+                                        periodId = $"{period.id}",
+                                        stuYear = studentBase.year,
+                                        studentId = studentBase.id,
+                                        lessonScore = new List<StudentLessonRecord>
+                                    {
+                                        new StudentLessonRecord
+                                        {
+                                            gscore = record.gscore,
+                                            pscore = record.pscore,
+                                            tscore = record.tscore,
+                                            tmdid = record.tmdid,
+                                            school = record.school,
+                                            scope = record.scope,
+                                            lessonId = record.lessonId,
+                                            courseId = record.courseId,
+                                            periodId = record.periodId,
+                                            subjectId = record.subjectId,
+                                            time= record.time
+                                         }
+                                    }
+                                    };
+                                }
+                                else
+                                {
+                                    overallEducation = JsonDocument.Parse(response.Content).RootElement.ToObject<OverallEducation>();
+                                    var hasrecord = overallEducation.lessonScore.Find(x => x.lessonId.Equals(record.lessonId));
+                                    if (hasrecord != null)
+                                    {
+                                        hasrecord.gscore = record.gscore;
+                                        hasrecord.pscore = record.pscore;
+                                        hasrecord.tscore = record.tscore;
+                                        hasrecord.tmdid = record.tmdid;
+                                        hasrecord.school = record.school;
+                                        hasrecord.scope = record.scope;
+                                        hasrecord.lessonId = record.lessonId;
+                                        hasrecord.courseId = record.courseId;
+                                        hasrecord.periodId = record.periodId;
+                                        hasrecord.subjectId = record.subjectId;
+                                        hasrecord.time = record.time;
+                                    }
+                                    else
+                                    {
+                                        overallEducation.lessonScore.Add(
+                                             new StudentLessonRecord
+                                             {
+                                                 gscore = record.gscore,
+                                                 pscore = record.pscore,
+                                                 tscore = record.tscore,
+                                                 tmdid = record.tmdid,
+                                                 school = record.school,
+                                                 scope = record.scope,
+                                                 lessonId = record.lessonId,
+                                                 courseId = record.courseId,
+                                                 periodId = record.periodId,
+                                                 subjectId = record.subjectId,
+                                                 time = record.time
+                                             }
+                                         );
+                                    }
+                                }
+                                overallEducations.Add(overallEducation);
+                            }
+                        }
+                    }
+                    foreach (var overallEducation in overallEducations) {
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(overallEducation, partitionKey: new PartitionKey(overallEducation.code));
+                    }
+                }
+            }
             return Ok();
         }
 

+ 3 - 3
TEAMModelOS/TEAMModelOS.csproj

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

+ 3 - 3
TEAMModelOS/appsettings.Development.json

@@ -18,10 +18,10 @@
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
     //"HttpTrigger": "http://localhost:7071/api/"
-    "Version": "5.2306.21.1"
+    "Version": "5.2306.20.1"
   },
   "Azure": {
-    // 测试站数据库
+     //测试站数据库
     "Storage": {
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
     },
@@ -39,7 +39,7 @@
     },
     "SignalR": {
       "ConnectionString": "Endpoint=https://channel.service.signalr.net;AccessKey=KrblW06tuA4a/GyqRPDU0ynFFmAWxbAvyJihHclSXbQ=;Version=1.0;"
-    },
+    }
     // 正式站数据库
     //"Storage": {
     //  "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"

+ 1 - 1
TEAMModelOS/appsettings.json

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