Browse Source

处理数据问题。

CrazyIter_Bin 3 years ago
parent
commit
ce407e9669

+ 97 - 62
TEAMModelFunction/MonitorServicesBus.cs

@@ -22,6 +22,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
 using Microsoft.Extensions.Configuration;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelFunction
 {
@@ -369,87 +370,121 @@ namespace TEAMModelFunction
         /// <returns></returns>
         [FunctionName("TeacherTrainChange")]
         public async Task TeacherTrainChange([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "teacher-train-change", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
-            TeacherTrainChange change = msg.ToObject<TeacherTrainChange>();
-            await _dingDing.SendBotMsg($"TeacherTrainChange:\n{msg}", GroupNames.醍摩豆服務運維群組);
-            if (change.update == null || change.update.Count <= 0)
-            {
-                return;
-            }
-            TeacherTrain teacherTrain = null;
-            var client = _azureCosmos.GetCosmosClient();
-            if (change.statistics != 1)
-            {
-                teacherTrain = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherTrain>(change.tmdid, new PartitionKey($"TeacherTrain-{change.school}"));
-                foreach (string up in change.update) {
-                    teacherTrain.updateProperty.Add(up);
+            try {
+                TeacherTrainChange change = msg.ToObject<TeacherTrainChange>();
+                if (change.update == null || change.update.Count <= 0 || change.tmdids.IsEmpty())
+                {
+                    return;
                 }
-                await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<TeacherTrain>(teacherTrain, change.tmdid, new PartitionKey($"TeacherTrain-{change.school}"));
-            }
-            else {
-                Area area = null;
-                string sql = $"select value(c) from c where c.standard='{change.standard}'";
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
-                      requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                var client = _azureCosmos.GetCosmosClient();
+                string insql = $"where c.id in ({string.Join(",", change.tmdids.Select(x => "'{x}'"))})";
+                string selsql = $"select value(c) from c {insql} ";
+                List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: selsql,
+                      requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{change.school}") }))
                 {
-                    area = item;
+                    teacherTrains.Add(item);
                 }
-                AreaSetting setting = null;
-                if (area != null)
+
+                if (change.statistics != 1)
                 {
-                    try
+
+                    List<Task<ItemResponse<TeacherTrain>>> task = new List<Task<ItemResponse<TeacherTrain>>>();
+                    teacherTrains.ForEach(x => {
+                        x.update.UnionWith(change.update);
+                        task.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<TeacherTrain>(x, x.id, new PartitionKey($"TeacherTrain-{change.school}")));
+                    });
+                    await task.TaskPage(5);
+                    var unchange = change.tmdids.Except(teacherTrains.Select(x => x.id));
+                    if (unchange != null)
                     {
-                        //优先找校级
-                        setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(change.school, new PartitionKey("AreaSetting"));
+                        task.Clear();
+                        unchange.ToList().ForEach(x => {
+                            TeacherTrain teacherTrain = new TeacherTrain
+                            {
+                                pk = "TeacherTrain",
+                                id = x,
+                                code = $"TeacherTrain-{change.school}",
+                                tmdid = x,
+                                school = change.school,
+                                update = new HashSet<string> {  StatisticsService.TeacherAility,
+                        StatisticsService.TeacherClass, StatisticsService.OfflineRecord }
+                            };
+                            teacherTrain.update.UnionWith(change.update);
+                            task.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherTrain>(teacherTrain, new PartitionKey($"TeacherTrain-{change.school}")));
+                        });
+                        await task.TaskPage(5);
                     }
-                    catch (CosmosException)
+                }
+                else
+                {
+                    Area area = null;
+                    string sql = $"select value(c) from c where c.standard='{change.standard}'";
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
+                          requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                    {
+                        area = item;
+                    }
+                    AreaSetting setting = null;
+                    if (area != null)
                     {
                         try
                         {
-                            setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
+                            //优先找校级
+                            setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(change.school, new PartitionKey("AreaSetting"));
                         }
                         catch (CosmosException)
                         {
-                            setting = null;
+                            try
+                            {
+                                setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
+                            }
+                            catch (CosmosException)
+                            {
+                                setting = null;
+                            }
                         }
                     }
-                }
-                if (setting == null)
-                {
-                    setting = new AreaSetting
-                    {
-                        allTime = 50,
-                        classTime = 5,
-                        submitTime = 15,
-                        onlineTime = 20,
-                        offlineTime = 10,
-                        lessonMinutes = 45,
-                    };
-                }
-
-                try
-                {
-                    teacherTrain = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherTrain>(change.tmdid, new PartitionKey($"TeacherTrain-{change.school}"));
-                    foreach (string up in change.update)
+                    if (setting == null)
                     {
-                        teacherTrain.updateProperty.Add(up);
+                        setting = new AreaSetting
+                        {
+                            allTime = 50,
+                            classTime = 5,
+                            submitTime = 15,
+                            onlineTime = 20,
+                            offlineTime = 10,
+                            lessonMinutes = 45,
+                        };
                     }
-                    teacherTrain = await StatisticsService.StatisticsTeacher(teacherTrain, setting, area, client,null);
-                }
-                catch (CosmosException)
-                {
-                    teacherTrain = await StatisticsService.StatisticsTeacher(new TeacherTrain
+                    List<Task<TeacherTrain>> task = new List<Task<TeacherTrain>>();
+                    teacherTrains.ForEach(x => {
+                        x.update.UnionWith(change.update);
+                        task.Add(StatisticsService.StatisticsTeacher(x, setting, area, client, null));
+                    });
+                    await task.TaskPage(1);
+                    var unchange = change.tmdids.Except(teacherTrains.Select(x => x.id));
+                    if (unchange != null)
                     {
-                        pk = "TeacherTrain",
-                        id = change.tmdid,
-                        code = $"TeacherTrain-{change.school}",
-                        tmdid = change.tmdid,
-                        school = change.school,
-                        updateProperty = new HashSet<string> {  StatisticsService.TeacherAility,
-                        StatisticsService.TeacherClass, StatisticsService.OfflineRecord }
-                    }, setting, area, client, null);
+                        task.Clear();
+                        unchange.ToList().ForEach(x => {
+                            task.Add(StatisticsService.StatisticsTeacher(new TeacherTrain
+                            {
+                                pk = "TeacherTrain",
+                                id = x,
+                                code = $"TeacherTrain-{change.school}",
+                                tmdid = x,
+                                school = change.school,
+                                update = new HashSet<string> {  StatisticsService.TeacherAility,
+                                StatisticsService.TeacherClass, StatisticsService.OfflineRecord }
+                            }, setting, area, client, null));
+                        });
+                        await task.TaskPage(1);
+                    }
                 }
+            } catch (Exception ex) {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-研修数据变更,重新统计-TeacherTrainChange\n{msg}", GroupNames.成都开发測試群組);
             }
-            
         }
 
         /// <summary>

+ 5 - 10
TEAMModelFunction/TriggerExamLite.cs

@@ -86,17 +86,17 @@ namespace TEAMModelFunction
                                 }
                             }
                             (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, lite.tchLists, lite.school, ps);
-                            // (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{school}");
-                            //(List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, lite.tchLists, lite.school);
                             List<StuActivity> tchActivities = new List<StuActivity>();
-                            List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
+                            (string standard, List<string> tmdids, string school, List<string> update, int statistics)  list =    (null,null, null, new List<string> { StatisticsService.TeacherExamLite }, 0)  ;
                             if (tchList.IsNotEmpty())
                             {
-                               
+                                list.tmdids = tchList.Select(x => x.id).ToList();
                                 School school = null;
                                 if (string.IsNullOrEmpty(lite.school))
                                 {
                                     school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(lite.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    list.school = school.id;
+                                    list.standard = school.standard;
                                 }
                                 tchList.ForEach(x =>
                                 {
@@ -120,15 +120,10 @@ namespace TEAMModelFunction
                                         taskStatus = -1,
                                         classIds = lite.tchLists
                                     });
-                                    if (school != null)
-                                    {   
-                                        //TeacherExamLite
-                                        list.Add((school.standard,x.id,school.id,new List<string> { StatisticsService.TeacherExamLite },0));
-                                    }
+                                   
                                 });
                               
                             }
-
                             await ActivityService.SaveStuActivity(client, _dingDing, null, null, tchActivities);
                             await StatisticsService.SendServiceBus(list, _configuration, _serviceBus);
                             var messageWorkEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = tdata.code }.ToJsonString());

+ 6 - 10
TEAMModelFunction/TriggerHomework.cs

@@ -5,6 +5,7 @@ using Microsoft.Azure.Documents;
 using Microsoft.Extensions.Configuration;
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK;
@@ -145,18 +146,16 @@ namespace TEAMModelFunction
                                 });
                             }
                             (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, work.tchLists, work.school,ps);
-                            // (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{school}");
-                            // (List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, work.tchLists, work.school);
-                            //List<Task> bustasks = new List<Task>();
-                            List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
+                            (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.OfflineRecord }, 0);
                             if (tchList.IsNotEmpty())
                             {
-                               
-
+                                list.tmdids = tchList.Select(x => x.id).ToList();
                                 School school = null;
                                 if (string.IsNullOrEmpty(work.school))
                                 {
                                     school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(work.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    list.school = school.id;
+                                    list.standard = school.standard;
                                 }
                                 tchList.ForEach(x =>
                                 {
@@ -180,10 +179,7 @@ namespace TEAMModelFunction
                                         taskStatus = -1,
                                         classIds = work.tchLists
                                     });
-                                    if (school != null)
-                                    {
-                                        list.Add((school.standard, x.id, school.id, new List<string> { StatisticsService.OfflineRecord }, 0));
-                                    }
+                                     
                                 });
                             }
                             await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, tchActivities);

+ 5 - 10
TEAMModelFunction/TriggerStudy.cs

@@ -85,18 +85,18 @@ namespace TEAMModelFunction
                             }
                             (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, study.tchLists, study.school,ps);
                             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}研修活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作、list??{tchList.ToJsonString()}=={ps[0].gid.ToJsonString()}", GroupNames.成都开发測試群組);
-
-                            List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
                             List<StuActivity> tchActivities = new List<StuActivity>();
+                            (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.OfflineRecord }, 0);
                             if (tchList.IsNotEmpty())
                             {
-                                
+                                list.tmdids = tchList.Select(x => x.id).ToList();
                                 School school = null;
                                 if (string.IsNullOrEmpty(study.school))
                                 {
-                                    school=await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(study.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(study.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    list.school = school.id;
+                                    list.standard = school.standard;
                                 }
-                                
                                 tchList.ForEach(x =>
                                 {
                                     tchActivities.Add(new StuActivity
@@ -119,11 +119,6 @@ namespace TEAMModelFunction
                                         taskStatus = -1,
                                         classIds = study.tchLists
                                     });
-                                    if (school != null)
-                                    {
-                                        //TeacherExamLite
-                                        list.Add((school.standard, x.id, school.id, new List<string> { StatisticsService.OfflineRecord }, 0));
-                                    }
                                 });
                               
                             }

+ 5 - 10
TEAMModelFunction/TriggerSurvey.cs

@@ -153,18 +153,17 @@ namespace TEAMModelFunction
                                 });
                             }
                             (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, survey.tchLists, survey.school,ps);
-                            // (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{school}");
-                            //(List<TmdInfo> tchList, _) = await TriggerStuActivity.GetTchList(client, _dingDing, survey.tchLists, survey.school);
-                            List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
+                            (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherSurvey }, 0);
                             if (tchList.IsNotEmpty())
                             {
-                                
+                                list.tmdids = tchList.Select(x => x.id).ToList();
                                 School school = null;
                                 if (string.IsNullOrEmpty(survey.school))
                                 {
                                     school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(survey.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    list.school = school.id;
+                                    list.standard = school.standard;
                                 }
-
                                 tchList.ForEach(x => {
                                     tchActivities.Add(new StuActivity
                                     {
@@ -185,11 +184,7 @@ namespace TEAMModelFunction
                                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                                         taskStatus = -1,
                                         classIds = survey.tchLists
-                                    }); if (school != null)
-                                    {
-                                        //TeacherExamLite
-                                        list.Add((school.standard, x.id, school.id, new List<string> { StatisticsService.TeacherSurvey }, 0));
-                                    }
+                                    });
                                 });
                                 
                             }

+ 4 - 7
TEAMModelFunction/TriggerVote.cs

@@ -160,15 +160,16 @@ namespace TEAMModelFunction
                                 });
                             }
                             (List<RMember> tchList, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, vote.tchLists, vote.school,ps);
-                            List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
-
+                            (string standard, List<string> tmdids, string school, List<string> update, int statistics) list = (null, null, null, new List<string> { StatisticsService.TeacherVote }, 0);
                             if (tchList.IsNotEmpty())
                             {
-                               
+                                list.tmdids = tchList.Select(x => x.id).ToList();
                                 School school = null;
                                 if (string.IsNullOrEmpty(vote.school))
                                 {
                                     school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(vote.school, new Azure.Cosmos.PartitionKey("Base"));
+                                    list.school = school.id;
+                                    list.standard = school.standard;
                                 }
                                 tchList.ForEach(x => {
                                     tchActivities.Add(new StuActivity
@@ -191,10 +192,6 @@ namespace TEAMModelFunction
                                         taskStatus = -1,
                                         classIds = classes
                                     });
-                                    if (school != null)
-                                    {
-                                        list.Add((school.standard, x.id, school.id, new List<string> { StatisticsService.TeacherVote }, 0));
-                                    }
                                 });
                               
                             }

+ 2 - 2
TEAMModelOS.SDK/Models/Cosmos/Research/TeacherTrain.cs

@@ -121,7 +121,7 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 待更新的属性
         /// </summary>
-        public HashSet<string>updateProperty{get;set;}
+        public HashSet<string> update { get; set; } = new HashSet<string>();
     }
     public class TeacherTrainChange {
         /// <summary>
@@ -131,7 +131,7 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 醍摩豆id
         /// </summary>
-        public string tmdid { get; set; }
+        public List<string> tmdids { get; set; } = new List<string>();
         /// <summary>
         /// 学校编码
         /// </summary>

+ 35 - 56
TEAMModelOS.SDK/Models/Service/StatisticsService.cs

@@ -45,47 +45,21 @@ namespace TEAMModelOS.SDK
         /// </summary>
         public const string TeacherExamLite = "TeacherExamLite";
 
-        public static async Task SendServiceBus(List<(string standard, string tmdid, string school, List<string> update, int statistics)> list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus) {
-            //List<ServiceBusMessage> serviceBusMessages = new List<ServiceBusMessage>();
-            //list.ForEach(x => {
-            //    if (x.update.IsNotEmpty()) {
-            //        TeacherTrainChange change = new TeacherTrainChange
-            //        {
-            //            standard = x.standard,
-            //            tmdid = x.tmdid,
-            //            school = x.school,
-            //            update = new HashSet<string>(x.update),
-            //            statistics = x.statistics
-            //        };
-            //        var messageChange = new ServiceBusMessage(change.ToJsonString());
-            //        messageChange.ApplicationProperties.Add("name", "TeacherTrainChange");
-            //        serviceBusMessages.Add(messageChange);
-            //    }
-            //});
-
-            //if (serviceBusMessages.IsNotEmpty()) {
-            //    var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-            //    await _serviceBus.GetServiceBusClient().SendBatchMessageAsync(ActiveTask, serviceBusMessages);
-            //}
+        public static async Task SendServiceBus((string standard, List<string> tmdids, string school, List<string> update, int statistics)list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus) {
             var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-            foreach (var x in list)
-            {
-                if (x.update.IsNotEmpty())
+            if (list.tmdids.IsNotEmpty() && list.update.IsNotEmpty()) {
+                TeacherTrainChange change = new TeacherTrainChange
                 {
-                    TeacherTrainChange change = new TeacherTrainChange
-                    {
-                        standard = x.standard,
-                        tmdid = x.tmdid,
-                        school = x.school,
-                        update = new HashSet<string>(x.update),
-                        statistics = x.statistics
-                    };
-                    var messageChange = new ServiceBusMessage(change.ToJsonString());
-                    messageChange.ApplicationProperties.Add("name", "TeacherTrainChange");
-                    await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
-                }
+                    standard = list.standard,
+                    tmdids = list.tmdids,
+                    school = list.school,
+                    update = new HashSet<string>(list.update),
+                    statistics = list.statistics
+                };
+                var messageChange = new ServiceBusMessage(change.ToJsonString());
+                messageChange.ApplicationProperties.Add("name", "TeacherTrainChange");
+                await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
             }
-
         }
 
         public static async Task GetAreaAndAreaSetting(  string schoolId, string _standard, CosmosClient client, HttpContext httpContext)
@@ -103,7 +77,6 @@ namespace TEAMModelOS.SDK
                 //优先找校级
                 school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(schoolId, new PartitionKey("Base"));
             }
-
         }
         public static async Task<List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>> StatisticsArea(AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing,  HashSet<string> updates)
         {
@@ -144,11 +117,11 @@ namespace TEAMModelOS.SDK
             if (updates != null) {
                 foreach (var up in updates)
                 {
-                    trains.ForEach(x => x.updateProperty.Add(up));
+                    trains.ForEach(x => x.update.Add(up));
                 }
             }
-            var update = trains.FindAll(x => x.updateProperty.Count() > 0);
-            var noupdate = trains.FindAll(x => x.updateProperty.Count() <=0);
+            var update = trains.FindAll(x => x.update.Count() > 0);
+            var noupdate = trains.FindAll(x => x.update.Count() <=0);
             
             var unStatistics = members.Select(x => x.id).Except(trains.Select(x => x.id));
             List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
@@ -168,7 +141,7 @@ namespace TEAMModelOS.SDK
                         name = member.name,
                         picture=member.picture,
                         school = school,
-                        updateProperty = new HashSet<string> { TeacherAility,TeacherClass,OfflineRecord }
+                        update = new HashSet<string> { TeacherAility,TeacherClass,OfflineRecord }
                     });
                 }
             }
@@ -187,12 +160,18 @@ namespace TEAMModelOS.SDK
             {
                 returnTrains.AddRange(noupdate);
             }
+            //移除不在研修名单的人员
+            returnTrains.RemoveAll(x => !members.Select(y => y.id).Contains(x.id));
             returnTrains.ForEach(x => {
                 var mbm= members.Find(y => y.id.Equals(x.id));
-                x.groupName = mbm?.groupName;
-                x.name = mbm?.name;
-                x.picture = mbm?.picture;
+                if (mbm != null)
+                {
+                    x.groupName = mbm?.groupName;
+                    x.name = mbm?.name;
+                    x.picture = mbm?.picture;
+                }
             });
+
             return (returnTrains, yxtrain); 
         }
         private static async Task<List<TeacherTrain>> GetStatisticsTeacher(List<TeacherTrain> trains, AreaSetting setting, Area area, CosmosClient client, List<Study> studies)
@@ -224,9 +203,9 @@ namespace TEAMModelOS.SDK
             string _tmdid = train.tmdid;
            // TeacherTrain teacher_train = null;
             List<Task<TeacherTrain>> teachers = new List<Task<TeacherTrain>>();
-            if (train.updateProperty.Count > 0) {
-                foreach (string property in train.updateProperty) {
-                    teachers.Add(DoProperty(train.updateProperty, property, setting, area, client, train,studies));
+            if (train.update.Count > 0) {
+                foreach (string property in train.update) {
+                    teachers.Add(DoProperty(train.update, property, setting, area, client, train,studies));
                 }
                 int pagesize = 50;
                 if (teachers.Count <= pagesize)
@@ -275,27 +254,27 @@ namespace TEAMModelOS.SDK
             switch (property) {
                 case TeacherAility:
                     train = await DoTeacherAility(train, setting, area, client, _school, _tmdid);
-                    train.updateProperty.Remove(TeacherAility);
+                    train.update.Remove(TeacherAility);
                     break;
                 //课堂实录更新
                 case TeacherClass:
                     train = await DoTeacherClass(train, setting, area, client, _school, _tmdid);
-                    train.updateProperty.Remove(TeacherClass);
+                    train.update.Remove(TeacherClass);
                     break;
                 //线下研修
                 case OfflineRecord:
                     train = await DoOfflineRecord(train, setting, area, client, _school, _tmdid,studies);
-                    train.updateProperty.Remove(OfflineRecord);
+                    train.update.Remove(OfflineRecord);
                     break;
                 //投票
                 case TeacherVote:
                     train = await DoTeacherVote(train, setting, area, client, _school, _tmdid);
-                    train.updateProperty.Remove(TeacherVote);
+                    train.update.Remove(TeacherVote);
                     break;
                 //问卷
                 case TeacherSurvey:
                     train = await DoTeacherSurvey(train, setting, area, client, _school, _tmdid);
-                    train.updateProperty.Remove(TeacherSurvey);
+                    train.update.Remove(TeacherSurvey);
                     break;
                 //作业
                 //case TeacherHomework:
@@ -305,10 +284,10 @@ namespace TEAMModelOS.SDK
                 //评测
                 case TeacherExamLite:
                     train = await DoTeacherExamLite(train, setting, area, client, _school, _tmdid);
-                    train.updateProperty.Remove(TeacherExamLite);
+                    train.update.Remove(TeacherExamLite);
                     break;
                 default:
-                    train.updateProperty.Remove(property);
+                    train.update.Remove(property);
                     break;
             }
             return train;

+ 1 - 1
TEAMModelOS/Controllers/Common/ExamLiteController.cs

@@ -142,7 +142,7 @@ namespace TEAMModelOS.Controllers.Common
                     await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(trExam, trExam.id, new PartitionKey($"{trExam.code}"));
                     if (!string.IsNullOrEmpty(standard) && !string.IsNullOrEmpty(school))
                     {
-                        await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)>() { ($"{standard}", $"{userid}", $"{school}", new List<string>() { StatisticsService.TeacherExamLite }, 1) }, _configuration, _serviceBus);
+                        await StatisticsService.SendServiceBus(  ($"{standard}", new List<string> { $"{userid}" }, $"{school}", new List<string>() { StatisticsService.TeacherExamLite }, 1) , _configuration, _serviceBus);
                     }
                 }
                 else

+ 2 - 2
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -668,7 +668,7 @@ namespace TEAMModelOS.Controllers.Learn
                                         {
                                            
                                         }
-                                        await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)>() { ($"{standard}", $"{one.id}", $"{school}", new List<string>() { StatisticsService.TeacherClass }, 1) }, _configuration, _serviceBus);
+                                        await StatisticsService.SendServiceBus( ($"{standard}", new List<string> { $"{one.id}" }, $"{school}", new List<string>() { StatisticsService.OfflineRecord },0)  , _configuration, _serviceBus);
                                         
                                     }
                                 }
@@ -739,7 +739,7 @@ namespace TEAMModelOS.Controllers.Learn
                                 }
                                 if (content.Exists(x => x.prime == true))
                                 {
-                                    await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)>() { ($"{standard}", $"{userid}", $"{school}", new List<string>() { StatisticsService.TeacherClass }, 1) }, _configuration, _serviceBus);
+                                    await StatisticsService.SendServiceBus(   ($"{standard}", new List<string> { $"{userid}" }, $"{school}", new List<string>() { StatisticsService.OfflineRecord }, 0 ), _configuration, _serviceBus);
                                 }
                             }
                             return Ok(new { msgid, taskStatus });

+ 6 - 4
TEAMModelOS/Controllers/Common/StudyController.cs

@@ -476,7 +476,8 @@ namespace TEAMModelOS.Controllers.Common
                 List<Task<ItemResponse<StudyRecord>>> tasky = new();
                 List<(string op, string tId)> opp = new List<(string op, string tId)>();
                 int statu = type.GetInt32();
-                List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
+               (string standard, List<string> tmdid, string school, List<string> update, int statistics)  list = (  $"{standard}", null,   school, new List<string> { StatisticsService.OfflineRecord }  , 1);
+                HashSet<string> tch= new HashSet<string>();
                 foreach (var aId in acId)
                 {
                     foreach (KeyValuePair<string, List<string>> pair in aId)
@@ -514,14 +515,15 @@ namespace TEAMModelOS.Controllers.Common
                                 };
                                 tasky.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(setting, new PartitionKey($"{setting.code}")));
                             }
-                            list.Add((($"{standard}", $"{teacId}", $"{school}", new List<string>() { StatisticsService.OfflineRecord },0)));
+                            tch.Add($"{teacId}");
+                             
                         }
 
                     }
                 }
-                await Task.WhenAll(tasky);
+                list.tmdid = new List<string>(tch);
+                await tasky.TaskPage(10);
                 await StatisticsService.SendServiceBus(list, _configuration, _serviceBus);
-                //await foreach (var s in AuditTask(acId, client, type.GetInt32(), now, standard, school)) ;
                 return Ok(new { code = HttpStatusCode.OK });
             }
             catch (Exception ex)

+ 2 - 2
TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

@@ -431,7 +431,7 @@ namespace TEAMModelOS.Controllers
                     teacherTrain.picture=picture;
                     if (update!=null && update.Count > 0) {
                         foreach (var up in update) {
-                            teacherTrain.updateProperty.Add(up);
+                            teacherTrain.update.Add(up);
                         }
                         await StatisticsService.StatisticsTeacher(teacherTrain, setting, area, client, null);
                     }
@@ -446,7 +446,7 @@ namespace TEAMModelOS.Controllers
                         school = school,
                         name= name,
                         picture= picture,
-                        updateProperty = new HashSet<string> {  StatisticsService.TeacherAility,
+                        update = new HashSet<string> {  StatisticsService.TeacherAility,
                         StatisticsService.TeacherClass, StatisticsService.OfflineRecord }
                     }, setting, area, client,null);
                 }

+ 7 - 24
TEAMModelOS/Controllers/Research/AbilitySubController.cs

@@ -111,7 +111,7 @@ namespace TEAMModelOS.Controllers
                     }
                 }
                 if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
-                await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}",new List<string> { StatisticsService.TeacherAility }, 0) }, _configuration, _serviceBus);
+                await StatisticsService.SendServiceBus(  ($"{standard}", new List<string> { $"{_tmdid}" }, $"{school}",new List<string> { StatisticsService.TeacherAility }, 0), _configuration, _serviceBus);
                 return Ok(new { abilityIds });
             }
             catch (Exception ex)
@@ -397,25 +397,8 @@ namespace TEAMModelOS.Controllers
                         }
                         abilitySubTasks.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(sub, sub.id, new PartitionKey(sub.code)));
                     });
-                    List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
-                    tmdids.ForEach(x => {
-                        list.Add(($"{standard}", $"{x}", $"{school}", new List<string> { StatisticsService.TeacherAility }, 1));
-                        
-                    });
-                    int pagesize = 10;
-                    if (abilitySubTasks.Count <= pagesize)
-                    {
-                        await Task.WhenAll(abilitySubTasks);
-                    }
-                    else
-                    {
-                        int pages = (abilitySubTasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
-                        for (int i = 0; i < pages; i++)
-                        {
-                            var lists = abilitySubTasks.Skip((i) * pagesize).Take(pagesize).ToList();
-                            await Task.WhenAll(lists);
-                        }
-                    }
+                    (string standard, List<string> tmdid, string school, List<string> update, int statistics) list = ($"{standard}", tmdids, school, new List<string> { StatisticsService.TeacherAility },0);
+                    await  abilitySubTasks.TaskPage(10);
                     await StatisticsService.SendServiceBus(list, _configuration, _serviceBus);
                     return Ok(new { status = 200 });
                 }
@@ -508,7 +491,7 @@ namespace TEAMModelOS.Controllers
                             abilitySub.exerciseScore = int.Parse($"{_exercise}");
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
                             status = 1;
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}",new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus( ($"{standard}", new List<string> { $"{_tmdid}" }, $"{_school}",new List<string> { StatisticsService.TeacherAility }, 0) , _configuration, _serviceBus);
                             return Ok(new { status });
                         }
                         else
@@ -556,7 +539,7 @@ namespace TEAMModelOS.Controllers
                             abilitySub.selfTime = now;
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
                             status = 1;
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 0) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus(  ($"{standard}", new List<string> { $"{_tmdid}" }, $"{_school}", new List<string> { StatisticsService.TeacherAility }, 0)  , _configuration, _serviceBus);
                         }
                         else
                         {
@@ -738,7 +721,7 @@ namespace TEAMModelOS.Controllers
                                 }
                             }
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<AbilitySub>(abilitySub, $"{_abilityId}", new PartitionKey(code));
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus(  ($"{standard}",new List<string> { $"{_tmdid}" }, $"{_school}", new List<string> { StatisticsService.TeacherAility }, 0) , _configuration, _serviceBus);
                             status = 1;
                         }
                         return Ok(new { status, abilitySub });
@@ -894,7 +877,7 @@ namespace TEAMModelOS.Controllers
                             await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey($"TeacherFile-{_school}"));
                         }
                         if (fileRcds.Exists(x => x.type.Equals("video"))) {
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{_school}", new List<string> { StatisticsService.TeacherAility }, 1) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus( ($"{standard}",new List<string> { $"{_tmdid}" }, $"{_school}", new List<string> { StatisticsService.TeacherAility },0) , _configuration, _serviceBus);
                         }
                         //获取视文件学习记录
                         List<dynamic> _files = new List<dynamic>();

+ 1 - 1
TEAMModelOS/Controllers/Research/AppraiseController.cs

@@ -130,7 +130,7 @@ namespace TEAMModelOS.Controllers.Research
                         else {
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Appraise>(appraise, appraise.id, new PartitionKey(code));
                         }
-                        await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}", new List<string> { StatisticsService.TeacherClass }, 1) }, _configuration, _serviceBus);
+                        await StatisticsService.SendServiceBus(  ($"{standard}", new List<string> { $"{_tmdid}" }, $"{school}", new List<string> { StatisticsService.TeacherClass }, 0) , _configuration, _serviceBus);
                         return Ok(new { dimensions, score });
                     case bool when $"{_opt}".Equals("Comment", StringComparison.OrdinalIgnoreCase):
                         if (!request.TryGetProperty("comment", out JsonElement _comment)) return BadRequest();

+ 5 - 19
TEAMModelOS/Controllers/Research/ClassVideoController.cs

@@ -222,7 +222,7 @@ namespace TEAMModelOS.Controllers.Research
                 List<Task<ItemResponse<ClassVideo>>> teacherTrains = new List<Task<ItemResponse<ClassVideo>>>();
                 List<Task> tasks = new List<Task>();
 
-                List<(string standard, string tmdid, string school, List<string> update, int statistics)> list = new List<(string standard, string tmdid, string school, List<string> update, int statistics)>();
+                (string standard, List<string> tmdid, string school, List<string> update, int statistics)  list =  (  $"{standard}", tmdids,   school, new List<string> { StatisticsService.TeacherClass }, 0);
                 tmdids.ForEach(x => {
                     
 
@@ -230,23 +230,9 @@ namespace TEAMModelOS.Controllers.Research
                 trains.ForEach(x => {
                     x.files.ForEach(y => { y.score = score; });
                     teacherTrains.Add(client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(x, x.id, new PartitionKey(x.code)));
-                    list.Add(($"{standard}", $"{x.id}", $"{school}", new List<string> { StatisticsService.TeacherClass },0));
                      
                 });
-                int pagesize = 50;
-                if (teacherTrains.Count <= pagesize)
-                {
-                    await Task.WhenAll(teacherTrains);
-                }
-                else
-                {
-                    int pages = (teacherTrains.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
-                    for (int i = 0; i < pages; i++)
-                    {
-                        var lists = teacherTrains.Skip((i) * pagesize).Take(pagesize).ToList();
-                        await Task.WhenAll(lists);
-                    }
-                }
+                await  teacherTrains.TaskPage(10);
                 await StatisticsService.SendServiceBus(list, _configuration, _serviceBus);
                 return Ok(new { status = 200 });
             }
@@ -295,7 +281,7 @@ namespace TEAMModelOS.Controllers.Research
                             var fid= videoRd.files.Find(x => x.id.Equals($"{_videoId}"));
                             fid.score = int.Parse($"{_score}");
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ClassVideo>(videoRd,videoRd.id, new PartitionKey(code));
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}",new List<string> { StatisticsService.TeacherClass }, 1) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus( ($"{standard}", new List<string> { $"{_tmdid}" }, $"{school}",new List<string> { StatisticsService.TeacherClass }, 0) , _configuration, _serviceBus);
                             return Ok(new { status = 1 });
                         }
                         catch (CosmosException ex)
@@ -345,7 +331,7 @@ namespace TEAMModelOS.Controllers.Research
                                     await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<ClassVideo>(classVideo, new PartitionKey(code));
                                 }
                             }
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}", new List<string> { StatisticsService.TeacherClass }, 0) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus( ($"{standard}", new List<string> { $"{_tmdid}" }, $"{school}", new List<string> { StatisticsService.TeacherClass }, 0)  , _configuration, _serviceBus);
                             return Ok(new { classVideo });
                         }
                         else {
@@ -368,7 +354,7 @@ namespace TEAMModelOS.Controllers.Research
                                 });
                             }
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ClassVideo>(delvideo, $"{_tmdid}", new PartitionKey(code));
-                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{_tmdid}", $"{school}", new List<string> { StatisticsService.TeacherClass }, 0) }, _configuration, _serviceBus);
+                            await StatisticsService.SendServiceBus( ($"{standard}", new List<string> { $"{_tmdid}" }, $"{school}", new List<string> { StatisticsService.TeacherClass }, 0)  , _configuration, _serviceBus);
                             //TODO同时删除话题和点评记录
                             return Ok(new { classVideo = delvideo });
                         }

+ 2 - 2
TEAMModelOS/Services/Common/ActivityStudentService.cs

@@ -179,7 +179,7 @@ namespace TEAMModelOS.Services.Common
                                     activity.taskStatus = taskStatus;
                                     await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuActivity>(activity, vote.id, new PartitionKey($"Activity-{userid}"));
                                     if (!string.IsNullOrEmpty(standard) && !string.IsNullOrEmpty(school)) {
-                                      await  StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{userid}", $"{school}", new List<string> { StatisticsService.TeacherVote }, 0) }, _configuration, _serviceBus);
+                                      await  StatisticsService.SendServiceBus(  ($"{standard}",new List<string> { $"{userid}" }, $"{school}", new List<string> { StatisticsService.TeacherVote }, 0)  , _configuration, _serviceBus);
                                     }
                                 }
                                 catch(CosmosException cosex) {
@@ -719,7 +719,7 @@ namespace TEAMModelOS.Services.Common
                                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuActivity>(activity, survey.id, new PartitionKey($"Activity-{userid}"));
                                         if (!string.IsNullOrEmpty(standard) && !string.IsNullOrEmpty(school))
                                         {
-                                            await StatisticsService.SendServiceBus(new List<(string standard, string tmdid, string school, List<string> update, int statistics)> { ($"{standard}", $"{userid}", $"{school}", new List<string> { StatisticsService.TeacherSurvey }, 0) }, _configuration, _serviceBus);
+                                            await StatisticsService.SendServiceBus( ($"{standard}",new List<string> { $"{userid}" }, $"{school}", new List<string> { StatisticsService.TeacherSurvey }, 0)  , _configuration, _serviceBus);
                                         }
                                     } catch (CosmosException cosex) {
                                         if (cosex.Status == 404) {