Przeglądaj źródła

处理活动结束后的代码逻辑

Li 2 lat temu
rodzic
commit
cb1624a5d1

+ 77 - 3
TEAMModelBI/Controllers/BITest/Ies5TestController.cs

@@ -22,7 +22,7 @@ using static TEAMModelOS.SDK.Models.Teacher;
 
 namespace TEAMModelBI.Controllers.BITest
 {
-    [Route("iesapitest")]
+    [Route("ies5test")]
     [ApiController]
     public class Ies5TestController : ControllerBase
     {
@@ -78,9 +78,83 @@ namespace TEAMModelBI.Controllers.BITest
             return Ok(new { state = 200, dateHours, dateHours1, dateHours2, dateDay, dateDays, dateMonth, });
         }
 
-        public async Task<IActionResult> GetRedisToTable(JsonElement jsonElement)
+        [HttpPost("get-fmember")]
+        public async Task<IActionResult> GetFMember(JsonElement jsonElement)
         {
-            return Ok(new { state = 200 });
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+
+            if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            if (!jsonElement.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            if (!jsonElement.TryGetProperty("actType", out JsonElement actType)) return BadRequest();
+
+            List<string> classes = new();
+            List<string> stuLists = new();
+            List<string> tchLists = new();
+            List<(string pId, List<string> gid)> ps = new();
+            string school = null;
+
+            if ($"{actType}".Equals("Study"))
+            {
+                Study study = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Study>($"{id}", new Azure.Cosmos.PartitionKey($"Study-{code}"));
+                if (study.groupLists.Count > 0)
+                {
+                    var group = study.groupLists;
+                    foreach (var gp in group)
+                    {
+                        foreach (KeyValuePair<string, List<string>> pp in gp)
+                        {
+                            ps.Add((pp.Key, pp.Value));
+                        }
+                    }
+                }
+                classes = study.classes;
+                stuLists = study.stuLists;
+                tchLists = study.tchLists;
+                school = study.school;
+            }
+            else if ($"{actType}".Equals("Vote"))
+            {
+                Vote vote = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>($"{id}", new Azure.Cosmos.PartitionKey($"Vote-{code}"));
+                classes = vote.classes;
+                stuLists = vote.stuLists;
+                tchLists = vote.tchLists;
+                school = vote.school;
+            }
+            else if ($"{actType}".Equals("Homework"))
+            {
+                Homework work = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Homework>($"{id}", new Azure.Cosmos.PartitionKey($"Homework-{code}"));
+                classes = work.classes;
+                stuLists = work.stuLists;
+                tchLists = work.tchLists;
+                school = work.school;
+            }
+            else if ($"{actType}".Equals("Survey")) 
+            {
+                Survey survey = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>($"{id}", new Azure.Cosmos.PartitionKey($"Survey-{code}"));
+                classes = survey.classes;
+                stuLists = survey.stuLists;
+                tchLists = survey.tchLists;
+                school = survey.school;
+            }
+            else if ($"{actType}".Equals("ExamLite")) 
+            {
+                ExamLite examLite = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamLite>($"{id}", new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                classes = examLite.classes;
+                stuLists = examLite.stuLists;
+                tchLists = examLite.tchLists;
+                school = examLite.school;
+            }
+            else if ($"{actType}".Equals("Exam"))
+            {
+                ExamInfo examInfo = await cosmosClient.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>($"{id}", new Azure.Cosmos.PartitionKey($"ExamLite-{code}"));
+                classes = examInfo.classes;
+                stuLists = examInfo.stuLists;
+                school = examInfo.school;
+            }
+
+            List<FMember> idsList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, cosmosClient, _dingDing, school, classes, stuLists, tchLists, ps);
+
+            return Ok(new { state = 200, idsList });
         }
 
     }

+ 5 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -413,6 +413,11 @@ namespace TEAMModelOS.FunctionV4
                                     info.lostStu = settlement.stus;
                                     info.stuCount = settlement.total;
                                     info.qRate = settlement.qrate;
+
+                                    //处理试卷活动结束统计账户信息
+                                    List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, info.school, info.classes, info.stuLists, null);
+                                    info.staffIds = idList;
+
                                     await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
                                 }
                             }

+ 7 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerExamLite.cs

@@ -181,6 +181,13 @@ namespace TEAMModelOS.FunctionV4
                             }
                             break;
                         case "finish":
+
+                            //处理试卷练习活动结束统计账户信息
+                            List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, lite.school, lite.classes, lite.stuLists, lite.tchLists);
+                            lite.staffIds = idList;
+
+                            await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<ExamLite>(lite, lite.id, new Azure.Cosmos.PartitionKey(lite.code));
+
                             break;
                     }
 

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

@@ -135,6 +135,11 @@ namespace TEAMModelOS.FunctionV4
                             break;
                         case "finish":
                             await Activity(_coreAPIHttpService, _serviceBus, _dingDing, client, _configuration, work);
+                            //处理家庭作业活动结束统计账户信息
+                            List<FMember> idsList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, work.school, work.classes, work.stuLists, work.stuLists);
+                            work.staffIds = idsList;
+
+                            await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Homework>(work, work.id, new Azure.Cosmos.PartitionKey(work.code));
                             break;
                     }
 

+ 18 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerStudy.cs

@@ -193,6 +193,24 @@ namespace TEAMModelOS.FunctionV4
                            
                             break;
                         case "finish":
+
+                            List<(string pId, List<string> gid)> gls = new List<(string pId, List<string> gid)>();
+                            if (study.groupLists.Count > 0)
+                            {
+                                var group = study.groupLists;
+                                foreach (var gp in group)
+                                {
+                                    foreach (KeyValuePair<string, List<string>> pp in gp)
+                                    {
+                                        gls.Add((pp.Key, pp.Value));
+                                    }
+                                }
+                            }
+                            //处理教研活动结束统计账户信息
+                            List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, study.school, study.classes, study.stuLists, study.stuLists, gls);
+                            study.staffIds = idList;
+                            await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync<Study>(study, study.id, new Azure.Cosmos.PartitionKey(study.code));
+
                             break;
                     }
                 }

+ 5 - 0
TEAMModelOS.FunctionV4/CosmosDB/TriggerSurvey.cs

@@ -407,6 +407,11 @@ namespace TEAMModelOS.FunctionV4
                             var cods = new { records = recs, userids, question = questionRecords, urecord = surveyRecords };
                             //问卷整体情况
                             await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "survey", $"{survey.id}/record.json");
+
+                            //处理问卷调查活动结束统计账户信息
+                            List<FMember> idsList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, survey.school, survey.classes, survey.stuLists, survey.tchLists);
+                            survey.staffIds = idsList;
+
                             if (string.IsNullOrEmpty(survey.recordUrl))
                             {
                                 survey.recordUrl = $"/survey/{survey.id}/record.json";

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

@@ -352,6 +352,10 @@ namespace TEAMModelOS.FunctionV4
                             tasks.Add(_azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(new { options = countcds, records = recordsBlob }.ToJsonString(), "vote", $"{vote.id}/record.json"));
                             //处理投票者的记录
 
+                            //处理投票活动结束统计账户信息
+                            List<FMember> idsList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, vote.school, vote.classes, vote.stuLists, vote.tchLists);
+                            vote.staffIds = idsList;
+
                             if (string.IsNullOrEmpty(vote.recordUrl))
                             {
                                 vote.recordUrl = url;

+ 3 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/ExamLite.cs

@@ -79,6 +79,9 @@ namespace TEAMModelOS.SDK.Models
         public string progress { get; set; }
         //发布层级 0校级,1区级
         public int? publish { get; set; } = 0;
+
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
     public class Record
     {

+ 29 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/GroupList.cs

@@ -120,7 +120,35 @@ namespace TEAMModelOS.SDK.Models
         //0在校,1毕业 
         public int graduate { get; set; } = 0;
     }
-    
+
+    /// <summary>
+    /// 活动结束后的结算接结构
+    /// </summary>
+    public class FMember 
+    {
+        /// <summary>
+        /// 账号id
+        /// </summary>
+        public string id { get; set; }
+        /// <summary>
+        /// 所在学校的学校id
+        /// </summary>
+        public string code { get; set; }
+        /// <summary>
+        /// 账户类型
+        /// </summary>
+        public int type { get; set; }
+        /// <summary>
+        /// 分组id
+        /// </summary>
+        public string groupId { get; set; }
+        /// <summary>
+        /// 分组名称
+        /// </summary>
+        public string groupName { get; set; }
+    }
+
+
     public class RMember
     {
         /// <summary>

+ 3 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Homework.cs

@@ -117,6 +117,9 @@ namespace TEAMModelOS.SDK.Models
         public int? publish { get; set; } = 0;
 
         public bool mustSubmit { get; set; } = false;
+
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
 
     public class Submits

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Study.cs

@@ -70,6 +70,8 @@ namespace TEAMModelOS.SDK.Models
         public string examId { get; set; }
         //发布层级 0校级,1区级
         public int? publish { get; set; } = 0;
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
     /*public class Setting
     {

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Survey.cs

@@ -115,6 +115,8 @@ namespace TEAMModelOS.SDK.Models
         public string pId { get; set; }
         //发布层级 0校级,1区级
         public int? publish { get; set; } = 0;
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
 
     /// <summary>

+ 3 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Vote.cs

@@ -127,6 +127,9 @@ namespace TEAMModelOS.SDK.Models
         public string areaId { get; set; }
         public string pId { get; set; }
         public int? publish { get; set; } = 0;
+
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
     /// <summary>
     /// 投票选项

+ 3 - 0
TEAMModelOS.SDK/Models/Cosmos/School/ExamInfo.cs

@@ -123,6 +123,9 @@ namespace TEAMModelOS.SDK.Models
         public int sStatus { get; set; } = 0;
         //容器名称 container name
         //public string cn { get; set; }
+
+        //结束后账户统计
+        public List<FMember> staffIds { get; set; } = new List<FMember>();
     }
     public class Custom {
         public string id { get; set; }

+ 35 - 0
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -1295,6 +1295,41 @@ namespace TEAMModelOS.SDK
             }
             return (null, null);
         }
+
+        public static async Task<List<FMember>> GetFinishMemberInfo(CoreAPIHttpService _coreAPIHttpService, CosmosClient cosmosClient, DingDing _dingDing, string school, List<string> classes, List<string> stuLists, List<string> tchLists, List<(string, List<string>)> _groupLists = null, int graduate = -1)
+        {
+            List<RGroupList> groupLists = new List<RGroupList>();
+            List<FMember> fMembers = new();
+
+            List<(string pId, List<string> gid)> ps = new();
+
+            if (classes != null && classes.Count > 0)
+            {
+                (List<RMember> staffList, List<RGroupList> classInfos) = await GetMemberByListids(_coreAPIHttpService, cosmosClient, _dingDing, classes, school);
+                staffList.ForEach(x => fMembers.Add(new FMember() { id = x.id, code = x.schoolId, type = 1 }));
+            }
+
+            if (stuLists != null && stuLists.Count > 0)
+            {
+                (List<RMember> staffList, List<RGroupList> classInfos) = await GetMemberByListids(_coreAPIHttpService, cosmosClient, _dingDing, stuLists, school);
+                staffList.ForEach(x => fMembers.Add(new FMember() { id = x.id, code = x.schoolId, type = 2 }));
+            }
+
+            if (tchLists != null && tchLists.Count > 0)
+            {
+                (List<RMember> staffList, List<RGroupList> classInfos) = await GetMemberByListids(_coreAPIHttpService, cosmosClient, _dingDing, tchLists, school);
+                staffList.ForEach(x => fMembers.Add(new FMember() { id = x.id, code = x.schoolId, type = 3 }));
+            }
+            if (_groupLists != null && _groupLists.Count > 0) 
+            {
+                (List<RMember> staffList, List<RGroupList> groupLists1) = await GetMemberByListids(_coreAPIHttpService, cosmosClient, _dingDing, classes, school, _groupLists);
+                staffList.ForEach(x => fMembers.Add(new FMember() { id = x.id, code = x.schoolId, type = 4 }));
+            }
+
+
+            return (fMembers);
+        
+        }
     }