CrazyIter_Bin 3 سال پیش
والد
کامیت
e42c8c23b1

+ 10 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/CodeValue.cs

@@ -9,4 +9,14 @@ namespace TEAMModelOS.SDK.Models
         public string code { get; set; }
         public string value { get; set; }
     }
+    public class IdSchool
+    {
+        public string id { get; set; }
+        public string school { get; set; }
+    }
+    public class IdCode
+    {
+        public string id { get; set; }
+        public string code { get; set; }
+    }
 }

+ 6 - 4
TEAMModelOS.SDK/Models/Cosmos/Common/LessonStudentRecord.cs

@@ -17,11 +17,13 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         public LessonStudentRecord() {
             pk = "LessonStudentRecord";
         }
-        public List<StudentRecord> records { get; set; } = new List<StudentRecord>();
+       // public List<StudentRecord> records { get; set; } = new List<StudentRecord>();
         //单独记录 组计分,个人积分,互动分,
-        public double groupScore { get; set; }
-        public double personScore { get; set; }
-        public double tnteractScore { get; set; }
+        public List<double> groupScore { get; set; }= new List<double>();
+        public List<double> personScore { get; set; } = new List<double>();
+        public List<double> tnteractScore { get; set; } = new List<double>();
+        public List<IdSchool> schoolRecord { get; set; } = new List<IdSchool>();
+        public HashSet<string> privateRecord { get; set; } = new HashSet<string>();
     }
 
 

+ 52 - 18
TEAMModelOS.SDK/Models/Service/LessonService.cs

@@ -20,7 +20,12 @@ namespace TEAMModelOS.SDK.Models.Service
         public static async void DoLessonStudentRecord(LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
             Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
         {
-            var stuids = lessonBase.student.Where(x => x.type == 2);
+            var clientSummaryList =lessonBase.report.clientSummaryList.Where(x => x.groupTaskCompleteCount!=0 ||  x.groupScore != 0 || x.score != 0 || x.tnteractScore != 0 || x.taskCompleteCount!=0);
+            IEnumerable<LessonStudent> students = new List<LessonStudent>();
+            if (clientSummaryList.Any()) {
+                students= lessonBase.student.Where(x => clientSummaryList.Select(x => x.seatID).Contains(x.seatID));
+            }
+            var stuids = students.Where(x => x.type == 2);
             if (stuids.Any()) {
                 stuids.ToList().ForEach(x => {
                     x.school = string.IsNullOrWhiteSpace(x.school) ? school : x.school;
@@ -36,7 +41,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 }
 
             }
-            var tmdids = lessonBase.student.Where(x => x.type == 1);
+            var tmdids = students.Where(x => x.type == 1);
             if (tmdids.Any()) {
                 string tmdsql = $"select value(c) from c where c.id in({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<LessonStudentRecord>(queryText: tmdsql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"LessonStudentRecord") }))
@@ -47,31 +52,60 @@ namespace TEAMModelOS.SDK.Models.Service
             List<Task<ItemResponse<LessonStudentRecord>>> records = new List<Task<ItemResponse<LessonStudentRecord>>>();
             stuids.ToList().ForEach(x => {
                 var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"LessonStudentRecord-{x.school}"));
+                ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
                 if (record != null)
                 {
-                    ClientSummaryList?  clientSummaryList= lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
-                    record.records.Add(new StudentRecord
-                    {
-                        tmdid = teacher.id,
-                        tmdname = teacher.name,
-                        name = lessonRecord.name,
-                        school = lessonRecord.school,
-                        scope = lessonRecord.scope,
-                        lessonId = lessonRecord.id,
-                        courseId = lessonRecord.courseId,
-                        periodId = lessonRecord.periodId,
-                        subjectId = lessonRecord.subjectId,
-                        report = clientSummaryList
-
-                    }) ;
+                    if (clientSummaryList != null) {
+                        if (clientSummaryList.groupScore > 0) 
+                        { record.groupScore.Add(clientSummaryList.groupScore); }
+                        if (clientSummaryList.score > 0)
+                        { record.personScore.Add(clientSummaryList.score); }
+                        if (clientSummaryList.tnteractScore > 0)
+                        { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
+                    }
                 }
-                else { 
+                else {
                     
+                    record = new LessonStudentRecord {id=x.id,code=$"LessonStudentRecord-{x.school}",pk= "LessonStudentRecord",ttl=-1 };
+                    if (clientSummaryList.groupScore > 0)
+                    { record.groupScore.Add(clientSummaryList.groupScore); }
+                    if (clientSummaryList.score > 0)
+                    { record.personScore.Add(clientSummaryList.score); }
+                    if (clientSummaryList.tnteractScore > 0)
+                    { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
                 }
+                records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
             });
             tmdids.ToList().ForEach(x => {
                 var record = lessonStudentRecords.Find(l => l.id.Equals(x.id) && l.code.Equals($"LessonStudentRecord"));
+                ClientSummaryList clientSummaryList = lessonBase.report.clientSummaryList.Find(c => c.seatID == x.seatID);
+                if (record != null)
+                {
+                    if (clientSummaryList != null)
+                    {
+                        if (clientSummaryList.groupScore > 0)
+                        { record.groupScore.Add(clientSummaryList.groupScore); }
+                        if (clientSummaryList.score > 0)
+                        { record.personScore.Add(clientSummaryList.score); }
+                        if (clientSummaryList.tnteractScore > 0)
+                        { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
+                    }
+                }
+                else
+                {
+                    record = new LessonStudentRecord { id = x.id, code = $"LessonStudentRecord", pk = "LessonStudentRecord", ttl = -1 };
+                    if (clientSummaryList.groupScore > 0)
+                    { record.groupScore.Add(clientSummaryList.groupScore); }
+                    if (clientSummaryList.score > 0)
+                    { record.personScore.Add(clientSummaryList.score); }
+                    if (clientSummaryList.tnteractScore > 0)
+                    { record.tnteractScore.Add(clientSummaryList.tnteractScore); }
+                }
+                records.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(record, partitionKey: new PartitionKey(record.code)));
             });
+            if (records.Any()) { 
+                await  Task.WhenAll(records);
+            }
         }
 
         public static async void DoAutoDeleteSchoolLessonRecord(LessonRecord lessonRecord,string  scope ,CosmosClient client,string school,string tmdid,

+ 5 - 6
TEAMModelOS/Controllers/System/CoreController.cs

@@ -55,7 +55,7 @@ namespace TEAMModelOS.Controllers
                 $"申请学校:{request.name}\n" +
                 $"学制:{string.Join(",", request.period)}\n" +
                 $"机构代码:{request.orgCode}\n" +
-                $"所在国家\\地区:{request.area}\n" +
+                $"所在国家/地区:{request.area}\n" +
                 $"申请人:{request.tmdname}({request.tmdid})\n" +
                 $"联系电话:{request.cellphone}\n" +
                 $"备注:{request.content}";
@@ -69,11 +69,10 @@ namespace TEAMModelOS.Controllers
         {
             string devmsg = _option.Location.Contains("Test") || _option.Location.Contains("Dep") ? "(测试消息)" : "";
             string msg = $"有新的模组购买申请。{devmsg}\n" +
-                $"申请站点:{_option.Location}\n" +
-                $"所在国家\\地区:{request.area}\n" +
-                $"申请学校:{request.name}\n" +
-                $"申请人:{request.tmdname}({request.tmdid})\n" +
-                $"性别:{request.gender}" +
+                $"站点:{_option.Location}\n" +
+                $"所在国家/地区:{request.area}\n" +
+                $"咨询学校:{request.name}\n" +
+                $"联系人:{request.tmdname} - {request.gender}({request.tmdid})\n " +
                 $"联系电话:{request.cellphone}\n" +
                 $"咨询内容:{request.content}";
             await _dingDing.SendBotMsg(msg, GroupNames.AI智慧學校申請通知群);