CrazyIter_Bin 5 ay önce
ebeveyn
işleme
414f653cfe

+ 3 - 1
TEAMModelOS.Extension/IES.ExamLib/Models/EvaluationCommon.cs

@@ -78,11 +78,13 @@ namespace IES.ExamServer.Models
         /// </summary>
         /// </summary>
         public string? password {  get; set; }
         public string? password {  get; set; }
     }
     }
-    public class ExamSubject
+    public class SubjectExam
     {
     {
         public string? examId { get; set; }
         public string? examId { get; set; }
         public string? id { get; set; }
         public string? id { get; set; }
         public string? name { get; set; }
         public string? name { get; set; }
+        public  int paperCount {  get; set; }
+        public List<string> paperIds { get; set; } = new List<string>();
     }
     }
     public class EvaluationExam 
     public class EvaluationExam 
     {
     {

+ 2 - 1
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -2575,8 +2575,9 @@ namespace TEAMModelOS.Function
                                     imei.lessonId=null;
                                     imei.lessonId=null;
                                     await db.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync<Imei>(imei, imei.id, new PartitionKey(imei.code));
                                     await db.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync<Imei>(imei, imei.id, new PartitionKey(imei.code));
                                 }
                                 }
+                                //await _dingDing.SendBotMsg($"{_option.Location},清理占用频道号的电子学生证,清理成功,频道号{channel},清理人数{rs.list.Count()}", GroupNames.成都开发測試群組);
                             }
                             }
-                            await _dingDing.SendBotMsg($"{_option.Location},清理占用频道号的电子学生证,清理成功,频道号{channel},清理人数{rs.list.Count()}", GroupNames.成都开发測試群組);
+                           
                         }
                         }
                     } catch (Exception ex)
                     } catch (Exception ex)
                     {
                     {

+ 8 - 5
TEAMModelOS.SDK/Models/Cosmos/Normal/EvaluationSyncInfo.cs

@@ -1,4 +1,5 @@
-using System;
+using IES.ExamServer.Models;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Linq;
@@ -26,8 +27,10 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Normal
         /// 活动名称
         /// 活动名称
         /// </summary>
         /// </summary>
         public string name { get; set; }
         public string name { get; set; }
-        public string subject { get; set; }
-
+        /// <summary>
+        /// 科目
+        /// </summary>
+        public List<SubjectExam> subjects { get; set; } = new List<SubjectExam>();
         /// <summary>
         /// <summary>
         /// 数据源拥有者,学校id或者个人id
         /// 数据源拥有者,学校id或者个人id
         /// </summary>
         /// </summary>
@@ -70,9 +73,9 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Normal
         public long webviewSize { get; set; }
         public long webviewSize { get; set; }
         public string webviewPath { get; set; }
         public string webviewPath { get; set; }
         /// <summary>
         /// <summary>
-        /// 名单数量
+        /// 名单集合
         /// </summary>
         /// </summary>
-        public int grouplistCount { get; set; }
+        public List<string> grouplist { get; set; }= new List<string>();
         /// <summary>
         /// <summary>
         /// 学生数量
         /// 学生数量
         /// </summary>
         /// </summary>

+ 80 - 3
TEAMModelOS.SDK/Models/Service/EvaluationSyncInfoService.cs

@@ -6,6 +6,7 @@ using System.Text;
 using System.Text.Json;
 using System.Text.Json;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.Normal;
 using TEAMModelOS.SDK.Models.Cosmos.Normal;
 
 
 
 
@@ -23,9 +24,14 @@ namespace TEAMModelOS.SDK.Models.Service
         /// <param name="type"></param>
         /// <param name="type"></param>
         /// <param name="azureCosmos"></param>
         /// <param name="azureCosmos"></param>
         /// <param name="azureStorage"></param>
         /// <param name="azureStorage"></param>
-        public static async Task PackageEvaluation( string id,string scope, string owner, string type, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage)
+        public static async Task PackageEvaluation( string id,string scope, string owner, string type, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage,CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing)
         {
         {
             EvaluationSyncInfo evaluationSyncInfo= null;
             EvaluationSyncInfo evaluationSyncInfo= null;
+            string schoolCode = null;
+            if (scope.Equals("school"))
+            {
+                schoolCode= owner;
+            }
             var responseEvaluationSyncInfo = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(id, new PartitionKey("EvaluationSyncInfo"));
             var responseEvaluationSyncInfo = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(id, new PartitionKey("EvaluationSyncInfo"));
             if (responseEvaluationSyncInfo.IsSuccessStatusCode)
             if (responseEvaluationSyncInfo.IsSuccessStatusCode)
             {
             {
@@ -39,18 +45,89 @@ namespace TEAMModelOS.SDK.Models.Service
                     type = type,
                     type = type,
                     pk="EvaluationSyncInfo",
                     pk="EvaluationSyncInfo",
                     code="ActivitySyncInfo",
                     code="ActivitySyncInfo",
-
                 };
                 };
             }
             }
             switch (true) 
             switch (true) 
             {
             {
                 case bool when (type == "Exam"):
                 case bool when (type == "Exam"):
-                    break;
+                    {
+                        string code = $"Exam-{owner}";
+                        var response = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(id, new PartitionKey(code));
+                        if (response.IsSuccessStatusCode)
+                        {
+                            ExamInfo exam= JsonDocument.Parse(response.Content).RootElement.Deserialize<ExamInfo>();
+                            if (!string.IsNullOrWhiteSpace(evaluationSyncInfo.shortCode)) 
+                            {
+                                evaluationSyncInfo.shortCode = $"{MurmurHash3.Hash32(exam.id)}";
+                            }
+                            evaluationSyncInfo.name=exam.name;
+                            evaluationSyncInfo.subjects = exam.subjects?.Select(x=>new IES.ExamServer.Models.SubjectExam { id=x.id,name=x.name,examId=id}).ToList();
+                            evaluationSyncInfo.dataTime= DateTimeOffset.Now.ToUnixTimeMilliseconds();
+
+                            HashSet<string> grouplist = new HashSet<string>();
+                            if (exam.classes.IsNotEmpty()) {
+                                exam.classes.ForEach(x => { grouplist.Add(x); });
+                            }
+                            if (exam.stuLists.IsNotEmpty())
+                            {
+                                exam.stuLists.ForEach(x => { grouplist.Add(x); });
+                            }
+                            evaluationSyncInfo.grouplist=grouplist.ToList() ;
+                            evaluationSyncInfo.paperCount=exam.papers.IsNotEmpty()? exam.papers.Count():0;
+                            foreach (var group in exam.papers.GroupBy(x=>x.subjectId).Select(x=>new { key = x.Key,list= x.ToList()}))
+                            {
+                                var subject= exam.subjects.Find(x => x.id.Equals(group.key));
+                                if (subject!=null) 
+                                {
+                                    evaluationSyncInfo.subjects.Add(new IES.ExamServer.Models.SubjectExam {
+                                        id=subject.id,
+                                        name=subject.name,
+                                        examId=id,
+                                        paperCount= group.list.Count,
+                                        paperIds= group.list.Select(x => x.id).ToList()
+                                    } );
+                                }
+                            }
+                        }
+                        break;
+                    }
                 case bool when (type == "Art"):
                 case bool when (type == "Art"):
+                    {
+                        string code = $"Art-{owner}";
+                        var response = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).ReadItemStreamAsync(id, new PartitionKey(code));
+                        if (response.IsSuccessStatusCode) 
+                        {
+                            ArtEvaluation art = JsonDocument.Parse(response.Content).RootElement.Deserialize<ArtEvaluation>();
+                            evaluationSyncInfo.subjects = art.subjects?.Select(x => new IES.ExamServer.Models.SubjectExam { id=x.id, name=x.name, examId=id }).ToList();
+                            evaluationSyncInfo.name = art.name;
+                            evaluationSyncInfo.dataTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                            HashSet<string> grouplist = new HashSet<string>();
+                            if (art.classes.IsNotEmpty())
+                            {
+                                art.classes.ForEach(x => { grouplist.Add(x); });
+                            }
+                            if (art.stuLists.IsNotEmpty())
+                            {
+                                art.stuLists.ForEach(x => { grouplist.Add(x); });
+                            }
+                            if (art.tchLists.IsNotEmpty())
+                            {
+                                art.tchLists.ForEach(x => { grouplist.Add(x); });
+                            }
+                            evaluationSyncInfo.grouplist=grouplist.ToList();
+                            var quota_22 = art.settings.Find(x => x.id.Equals("quota_22"));
+                            foreach (var item in quota_22.task) 
+                            {
+                               
+                            }
+                        }
+                    }
                     break;
                     break;
                 default:
                 default:
                     break;
                     break;
             }
             }
+            var listInfo=  await  GroupListService.GetMemberByListids(_coreAPIHttpService, azureCosmos.GetCosmosClient(), _dingDing, evaluationSyncInfo.grouplist, schoolCode);
+            evaluationSyncInfo.studentCount =  listInfo.rmembers.Count();
         }
         }
     }
     }
 }
 }

+ 2 - 0
TEAMModelOS/Controllers/Both/EvaluationSyncInfoController.cs

@@ -12,6 +12,7 @@ using TEAMModelOS.Filter;
 using System.Text.Json.Nodes;
 using System.Text.Json.Nodes;
 using TEAMModelOS.SDK.Models.Cosmos.Normal;
 using TEAMModelOS.SDK.Models.Cosmos.Normal;
 using Microsoft.Azure.Cosmos;
 using Microsoft.Azure.Cosmos;
+using TEAMModelOS.SDK.Models.Service;
 
 
 
 
 namespace TEAMModelOS.Controllers.Both
 namespace TEAMModelOS.Controllers.Both
@@ -70,6 +71,7 @@ namespace TEAMModelOS.Controllers.Both
                 ValidResult validResult = activity.Valid();
                 ValidResult validResult = activity.Valid();
                 if (!validResult.isVaild) 
                 if (!validResult.isVaild) 
                 {
                 {
+                    await EvaluationSyncInfoService.PackageEvaluation(activity.id, activity.scope, activity.owner, activity.type, _azureCosmos, _azureStorage, _coreAPIHttpService,_dingDing);
                     return BadRequest(validResult);
                     return BadRequest(validResult);
                 }
                 }