CrazyIter_Bin 1 год назад
Родитель
Сommit
6689d6455b

+ 11 - 0
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -43,6 +43,8 @@ using System.Collections.Concurrent;
 using Microsoft.Azure.Amqp.Framing;
 using System.Security.Policy;
 using TEAMModelOS.SDK.Models.Service.BI;
+using TEAMModelOS.SDK.Models.Dtos;
+using System.ServiceModel.Channels;
 
 namespace TEAMModelOS.FunctionV4.ServiceBus
 {
@@ -494,6 +496,15 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                 //await _dingDing.SendBotMsg($"名单变化{msg}", GroupNames.成都开发測試群組);
                 var jsonMsg = JsonDocument.Parse(msg);
                 GroupChange groupChange = msg.ToObject<GroupChange>();
+                int add = groupChange.tmdjoin.Count-groupChange.tmdleave.Count+groupChange.stujoin.Count-groupChange.stuleave.Count;
+                if (groupChange.scope.Equals("private") && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
+                {
+                    await SystemService.RecordAccumulateData(_azureRedis, _dingDing, new Accumulate { client=groupChange.client, count=add, id= groupChange.listid, scope="teacher", key= "grouplist", name=groupChange.name, target= groupChange.creatorId });
+                }
+                if (groupChange.scope.Equals("school")  && (groupChange.type.Equals("student") || groupChange.type.Equals("class") || groupChange.type.Equals("teach")))
+                {
+                    await SystemService.RecordAccumulateData(_azureRedis,_dingDing, new Accumulate { client=groupChange.client, count=add, id= groupChange.listid, scope="school", key= "grouplist", name=groupChange.name, target=groupChange.school });
+                }
                 //名单变动修改学生课程关联信息
                 //await StuListService.FixStuCourse(client, stuListChange);
                 //Vote投票 Survey问卷 Exam评测 Learn学习活动 Homework作业活动

+ 3 - 0
TEAMModelOS.SDK/DI/HttpTrigger/WebHookHttpTrigger.cs

@@ -100,6 +100,7 @@ namespace TEAMModelOS.SDK.DI
             GroupChange data = null;
             if (json.TryGetProperty("data", out JsonElement _data)){
                 data= _data.ToObject<GroupChange>();
+                data.client="web";
             }
             (List<BizConfig> businessConfigs, List<(List<string> urls, string head, string token, BizConfig config)> webhooks ) = await WebHookService.GetRequestData(_data, _azureCosmos,_azureRedis,_azureStorage);
             if (webhooks.IsNotEmpty() && !string.IsNullOrWhiteSpace(data.school))
@@ -110,6 +111,8 @@ namespace TEAMModelOS.SDK.DI
                     {
                         await WebHookService.Send(new
                         {
+                            data.name,
+                            data.client,
                             data.status,
                             data.type,
                             data.listid,

+ 5 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/GroupChange.cs

@@ -56,5 +56,10 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public string status { get; set; } = "upsert";
         public string periodId { get; set; }
+        /// <summary>
+        /// web  hiteach hita
+        /// </summary>
+        public string client { get; set; }
+        public string name { get; set; }
     }
 }

+ 11 - 7
TEAMModelOS.SDK/Models/Dtos/Accumulate.cs

@@ -32,22 +32,26 @@ namespace TEAMModelOS.SDK.Models.Dtos
         /// </summary>
         public string name { get; set; }
         /// <summary>
-        /// teacher  school  system
+        /// teacher发送给教师的  school 发送给学校管理员的   system发送给系统管理员的
         /// </summary>
         public string scope { get; set; }
-        public int count { get; set; }
+        public int count { get; set; } = 1;
+        /// <summary>
+        /// web,hiteach,hita
+        /// </summary>
+        public string client {  get; set; }
 
         //Accumulate:Keys:Day
 
         //Accumulate:Keys:Week
 
-        /*课程加入的人数
-         * Accumulate:Daily:teacher:course:yyyyddMM:==>1595321354-courseId=>count
-        key:course
+        /*加入的人数
+         * Accumulate:Daily:teacher:grouplist:yyyyddMM:==>1595321354-grouplistId=>count
+        key:grouplist
         target:1595321354
-        id:courseId
+        id:grouplistId
         scope:teacher
-        name:课程名称
+        name:名单名称
         count:8
          */
         /*作业提交人数

+ 12 - 7
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -16,6 +16,7 @@ using TEAMModelOS.SDK.Models;
 using System.Net.Http;
 using DocumentFormat.OpenXml.Drawing.Charts;
 using System.Reflection;
+using TEAMModelOS.SDK.Models.Service;
 
 
 namespace TEAMModelOS.SDK
@@ -230,10 +231,11 @@ namespace TEAMModelOS.SDK
             }
         }
 
-        public static async Task DeleteGrouplistEvent(string  id , string code,string  tbname ,CosmosClient client, IConfiguration _configuration, AzureServiceBusFactory _serviceBus)
+        public static async Task DeleteGrouplistEvent(string  id , string code,string  tbname ,CosmosClient client, IConfiguration _configuration, AzureServiceBusFactory _serviceBus,string _client)
         {
-            GroupChange change = new GroupChange();
+            
             GroupList groupList = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<GroupList>(id.ToString(), new PartitionKey(code));
+            GroupChange change = new GroupChange() { client=_client,name=groupList.name};
             var tleave = groupList.members.FindAll(x => x.type == 1);
             if (tleave.IsNotEmpty())
             {
@@ -446,7 +448,7 @@ namespace TEAMModelOS.SDK
         /// <param name="type"></param>
         /// <param name="school"></param>
         /// <returns></returns>
-        public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client,AzureRedisFactory _azureRedis, string _stuListNo, string userid, int type, string school,int year,string name ,string picture,string lang,int seatNo, string courseId= null)
+        public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client,AzureRedisFactory _azureRedis, string _stuListNo, string userid, int type, string school,int year,string name ,string picture,string lang,int seatNo, string courseId= null,string _client="web")
         {
             var queryNo = $"SELECT  value(c)  FROM c where  c.no ='{_stuListNo}'";
             (int status, GroupList stuList,Member member) data = (-1, null,null);
@@ -455,7 +457,7 @@ namespace TEAMModelOS.SDK
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryNo,
                 requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
                 {
-                    data = JoinList(item, userid, type, school,year,seatNo);
+                     data = await JoinList(_azureRedis, item, userid, type, school,year,seatNo,_client:_client);
                     break;
                 }
             }
@@ -519,7 +521,7 @@ namespace TEAMModelOS.SDK
                     //状态=5 ,人数已满
                     return (5, item, null);
                 }
-                data = JoinList(item, userid, type, school,year,seatNo);
+                data =await JoinList(_azureRedis, item, userid, type, school,year,seatNo, _client: _client);
                 //TODO 需要考虑已经通过别的途径加入名单,但是缓存数据仍记录数据的问题。 还要考虑手动加入过的。或者在获取名未加入名单成员的临时缓存数据的时候过滤已经加入的。
                 break;
             }
@@ -555,7 +557,7 @@ namespace TEAMModelOS.SDK
             public int seatNo { get; set; }
            public List<IdName> courses  { get; set; }= new List<IdName>();
         }
-        public static (int status, GroupList stuList, Member member) JoinList(GroupList stuList, string userid, int type, string school, int year, int seatNo = 0)
+        public static async Task<(int status, GroupList stuList, Member member)> JoinList(AzureRedisFactory azureRedis, GroupList stuList, string userid, int type, string school, int year, int seatNo = 0,string _client="web")
         {
             
             Member member = null;
@@ -586,6 +588,7 @@ namespace TEAMModelOS.SDK
                             status = 0;
                             member = new Member { id = userid, type = type, irs = $"{seatNo}", no =  $"{seatNo}", year=year,manual=1 };
                             stuList.members.Add(member);
+                           
                         }
                     }
                     else if (type == 2)
@@ -675,7 +678,7 @@ namespace TEAMModelOS.SDK
             return (status, stuList, member);
         }
 
-        public static async Task<GroupList> UpsertList(GroupList list, AzureCosmosFactory _azureCosmos, IConfiguration _configuration, AzureServiceBusFactory _serviceBus)
+        public static async Task<GroupList> UpsertList(GroupList list, AzureCosmosFactory _azureCosmos, IConfiguration _configuration, AzureServiceBusFactory _serviceBus,string _client )
         {
             bool isnew = false;
             var client = _azureCosmos.GetCosmosClient();
@@ -721,6 +724,8 @@ namespace TEAMModelOS.SDK
             {
                 GroupChange change = new GroupChange()
                 {
+                    name=list.name,
+                    client=_client,
                     type = list.type,
                     listid = list.id,
                     scope = list.scope,

+ 32 - 5
TEAMModelOS.SDK/Models/Service/StudentService.cs

@@ -2,6 +2,7 @@
 using Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using DocumentFormat.OpenXml.Drawing;
+using DocumentFormat.OpenXml.Drawing.Charts;
 using DocumentFormat.OpenXml.Office2010.Excel;
 using DocumentFormat.OpenXml.Spreadsheet;
 using DocumentFormat.OpenXml.VariantTypes;
@@ -407,6 +408,8 @@ namespace TEAMModelOS.SDK
                             {
                                 GroupChange change = new GroupChange
                                 {
+
+                                    client="web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -442,6 +445,7 @@ namespace TEAMModelOS.SDK
                             {
                                 GroupChange change = new GroupChange
                                 {
+                                    client="web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -480,6 +484,7 @@ namespace TEAMModelOS.SDK
                                 {
                                     GroupChange change = new GroupChange
                                     {
+                                        client="web",
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
@@ -511,6 +516,7 @@ namespace TEAMModelOS.SDK
                                 {
                                     GroupChange change = new GroupChange
                                     {
+                                        client="web",
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
@@ -558,6 +564,7 @@ namespace TEAMModelOS.SDK
                             {
                                 GroupChange change = new GroupChange
                                 {
+                                    client="web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -602,7 +609,8 @@ namespace TEAMModelOS.SDK
                             else
                             {
                                 GroupChange change = new GroupChange
-                                {
+                                {   
+                                    client = "web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -638,6 +646,7 @@ namespace TEAMModelOS.SDK
                             {
                                 GroupChange change = new GroupChange
                                 {
+                                    client="web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -676,6 +685,7 @@ namespace TEAMModelOS.SDK
                                 {
                                     GroupChange change = new GroupChange
                                     {
+                                        client="web",
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
@@ -707,6 +717,7 @@ namespace TEAMModelOS.SDK
                                 {
                                     GroupChange change = new GroupChange
                                     {
+                                        client="web",
                                         scope = "school",
                                         school = schoolId,
                                         type = "student",
@@ -754,6 +765,7 @@ namespace TEAMModelOS.SDK
                             {
                                 GroupChange change = new GroupChange
                                 {
+                                    client="web",
                                     scope = "school",
                                     school = schoolId,
                                     type = "student",
@@ -775,15 +787,30 @@ namespace TEAMModelOS.SDK
                     }
                 }
             }
+            List<Class> classes = new List<Class>();
+            if (dictChange.Keys.Count>0)
+            {
+                string insql = string.Join(",", dictChange.Keys.Select(x => $"'{x}'"));
+                var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetList<Class>($"select     c.id,c.name   from c where c.id in ({insql})", $"Class-{schoolId}");
+                if (result.list.IsNotEmpty())
+                {
+                    classes.AddRange(result.list);
+                }
+            }
             foreach (var changed in dictChange.Keys)
             {
                 var change = dictChange[changed];
                 if (change.stujoin.Count != 0 || change.stuleave.Count != 0)
                 {
-                    var messageChange = new ServiceBusMessage(change.ToJsonString());
-                    messageChange.ApplicationProperties.Add("name", "GroupChange");
-                    var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-                    await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+                   var clazz=  classes.Find(x => x.id.Equals(changed));
+                    if (clazz!=null) {
+                        change.name=clazz.name;
+                        var messageChange = new ServiceBusMessage(change.ToJsonString());
+                        messageChange.ApplicationProperties.Add("name", "GroupChange");
+                        var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                        await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+                    }
+                    
                 }
             }
 

+ 33 - 16
TEAMModelOS.SDK/Models/Service/SystemService.cs

@@ -4,18 +4,35 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models.Dtos;
 using static OpenXmlPowerTools.RevisionProcessor;
 
 namespace TEAMModelOS.SDK.Models.Service
 {
     public static class SystemService
     {
+        public static async Task RecordAccumulateData(AzureRedisFactory azureRedis,DingDing dingDing, Accumulate accumulate)
+        {
+            if (!string.IsNullOrWhiteSpace(accumulate.key)  && !string.IsNullOrWhiteSpace(accumulate.target) &&
+                !string.IsNullOrWhiteSpace(accumulate.id) && !string.IsNullOrWhiteSpace(accumulate.name) &&
+                !string.IsNullOrWhiteSpace(accumulate.scope) &&  !string.IsNullOrWhiteSpace(accumulate.client))
+            {
+                await RecordAccumulateData(azureRedis, accumulate.key, accumulate.target, accumulate.id, accumulate.name, accumulate.scope, accumulate.client, accumulate.count);
+            }
+            else {
+                await dingDing.SendBotMsg($"IES累计数据变更统计参数异常,{accumulate.ToJsonString()}", GroupNames.成都开发測試群組);
+            }
+        }
+
         /// <summary>
         /// 记录累计数据
         /// </summary>
-        public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, string key, string target, string id, string name, string scope) 
+        public static async Task RecordAccumulateData(AzureRedisFactory azureRedis, string key, string target, string id, string name, string scope, string client,int count) 
         {
-            if (!string.IsNullOrWhiteSpace(key)  && !string.IsNullOrWhiteSpace(target) && !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(scope)) {
+            if (!string.IsNullOrWhiteSpace(key)  && !string.IsNullOrWhiteSpace(target) && 
+                !string.IsNullOrWhiteSpace(id) && !string.IsNullOrWhiteSpace(name) && 
+                !string.IsNullOrWhiteSpace(scope)&& !string.IsNullOrWhiteSpace(client)) {
                 //处理UTC时差
                  var nowTime = DateTimeOffset.UtcNow.GetGMTTime();
                 var day = nowTime.ToString("yyyyMMdd");
@@ -24,20 +41,20 @@ namespace TEAMModelOS.SDK.Models.Service
                 {
                 }
                 string redisKey = $"Accumulate:Daily:{scope}:{key}:{day}";
-                string member = $"{target}::{id}::{name}";
-                await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, 1);
-                if (key.Equals("lesson")  || key.StartsWith("login_"))
-                {
-                    redisKey = $"Accumulate:Daily:ies:{key}:{day}";
-                    if (scope.Equals("school"))
-                    {
-                        member = $"ies::{id}::{name}";
-                    }
-                    else {
-                        member = $"ies::ies::{name}";
-                    }
-                    await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, 1);
-                }
+                string member = $"{target}::{id}::{client}::{name}";
+                await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, count);
+                //if (key.Equals("lesson")  || key.StartsWith("login_"))
+                //{
+                //    redisKey = $"Accumulate:Daily:ies:{key}:{day}";
+                //    if (scope.Equals("school"))
+                //    {
+                //        member = $"ies::{id}::{name}";
+                //    }
+                //    else {
+                //        member = $"ies::ies::{name}";
+                //    }
+                //    await azureRedis.GetRedisClient(8).SortedSetIncrementAsync(redisKey, member, 1);
+                //}
             }
         }
     }

+ 3 - 3
TEAMModelOS.SDK/Models/Service/Third/ThirdService.cs

@@ -151,14 +151,14 @@ namespace TEAMModelOS.SDK.Models
                                 if (meber == null || !meber.Any())
                                 {
                                     yxtrain[0].members.Add(new Member { id = teacher.id, type = 1, groupId = groupId, groupName = groupName,nickname= nickname });
-                                    await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus);
+                                    await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus,"web");
                                 }
                                 else
                                 {
                                     if (string.IsNullOrEmpty(meber.First().groupId) || string.IsNullOrEmpty(meber.First().groupName))
                                     {
                                         meber.ToList().ForEach(x => { x.groupId = groupId; x.groupName = groupName;x.nickname = string.IsNullOrWhiteSpace(x.nickname)? nickname:x.nickname; });
-                                        await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus);
+                                        await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, "web");
                                     }
                                 }
                             }
@@ -191,7 +191,7 @@ namespace TEAMModelOS.SDK.Models
                                     pk = "GroupList",
                                     ttl = -1
                                 };
-                                await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
+                                await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, "web");
                             }
                         }
                     }

+ 3 - 3
TEAMModelOS/Controllers/Both/CourseController.cs

@@ -703,7 +703,7 @@ namespace TEAMModelOS.Controllers
 
                 try
                 {
-                    await GroupListService.DeleteGrouplistEvent($"{stulist}", "GroupList", Constant.Teacher, client, _configuration, _serviceBus);
+                    await GroupListService.DeleteGrouplistEvent($"{stulist}", "GroupList", Constant.Teacher, client, _configuration, _serviceBus,"web");
                 }
                 catch (Exception ex) {  }
                
@@ -910,7 +910,7 @@ namespace TEAMModelOS.Controllers
                         foreach (var listid in courseChange.delList) {
                             try
                             {
-                                await GroupListService.DeleteGrouplistEvent(listid, "GroupList", Constant.Teacher, client, _configuration, _serviceBus);
+                                await GroupListService.DeleteGrouplistEvent(listid, "GroupList", Constant.Teacher, client, _configuration, _serviceBus, "web");
                             }
                             catch (Exception ex) { continue; }
                         }
@@ -921,7 +921,7 @@ namespace TEAMModelOS.Controllers
                         if (exlists.Any()) {
                             foreach (var listid in exlists) {
                                 try {
-                                    await  GroupListService.DeleteGrouplistEvent(listid, "GroupList", Constant.Teacher, client, _configuration, _serviceBus);
+                                    await  GroupListService.DeleteGrouplistEvent(listid, "GroupList", Constant.Teacher, client, _configuration, _serviceBus, "web");
                                 } catch (Exception ex) { continue; }
                             }
                         }

+ 13 - 13
TEAMModelOS/Controllers/Both/GroupListController.cs

@@ -179,11 +179,11 @@ namespace TEAMModelOS.Controllers
                 }
             }
             int year = DateTimeOffset.UtcNow.Year;
-            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", id, type: 1, $"{school}", year, $"{name}", $"{picture}", $"{lang}", seatNo, $"{_courseId}");
+            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", id, type: 1, $"{school}", year, $"{name}", $"{picture}", $"{lang}", seatNo, $"{_courseId}","hita");
             //没有TmdUser时
             if (data.status == 0)
             {
-                await GroupListService.UpsertList(data.stuList, _azureCosmos, _configuration, _serviceBus);
+                await GroupListService.UpsertList(data.stuList, _azureCosmos, _configuration, _serviceBus,_client: "hita");
 
                 List<string> ids = new List<string>();
                 if (data.stuList.scope.Equals("private") && !string.IsNullOrEmpty(data.stuList.creatorId))
@@ -263,11 +263,11 @@ namespace TEAMModelOS.Controllers
                 type = 1;
             }
             int seatNo =0;
-            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", userid, type, school, year, _name, _picture, head_lang,seatNo);
+            (int status, GroupList stuList, Member member) data = await GroupListService.CodeJoinList(client, _azureRedis, $"{_stuListNo}", userid, type, school, year, _name, _picture, head_lang,seatNo,_client:"web");
             if (data.status == 0)
             {
 
-                await GroupListService.UpsertList(data.stuList, _azureCosmos, _configuration, _serviceBus);
+                await GroupListService.UpsertList(data.stuList, _azureCosmos, _configuration, _serviceBus, "web");
 
                 List<string> ids = new List<string>();
                 if (data.stuList.scope.Equals("private") && !string.IsNullOrEmpty(data.stuList.creatorId))
@@ -1393,7 +1393,7 @@ namespace TEAMModelOS.Controllers
                                     {
                                         foreach (var t in takes)
                                         {
-                                            GroupListService.JoinList(list, t.userid, t.type, t.school, t.year,t.seatNo);
+                                           await GroupListService.JoinList(_azureRedis, list, t.userid, t.type, t.school, t.year,t.seatNo, _client: "web");
                                             string stuKey = !string.IsNullOrWhiteSpace(school) ? $"GroupList:StudentWaitinglist:{school}_{t.userid}" : $"GroupList:StudentWaitinglist:{t.userid}";
                                             string stuFiled = $"{list.scope}:{list.id}";
                                             var data = await _azureRedis.GetRedisClient(8).HashGetAsync(stuKey, stuFiled);
@@ -1455,31 +1455,31 @@ namespace TEAMModelOS.Controllers
                     case bool when $"{list.type}".Equals("teach", StringComparison.OrdinalIgnoreCase):
                         list.type = "teach";
                         list = await GroupListService.CheckListNo(list, _azureCosmos, _dingDing, _option);
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, "web");
                         break;
                     //教研组名单,只有加入学校的老师名单 成员账号类型是醍摩豆ID,保存在学校表,分区键为GroupList-hbcn
                     case bool when $"{list.type}".Equals("research", StringComparison.OrdinalIgnoreCase):
                         list.type = "research";
                         list.scope = "school";
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, "web");
                         break;
                     //个人好友名单,成员账号类型可以是学校学生账号和醍摩豆ID,分区键为GroupList
                     case bool when $"{list.type}".Equals("friend", StringComparison.OrdinalIgnoreCase):
                         list.type = "friend";
                         list.scope = "private";
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, "web");
                         break;
                     //社交群组类型(包含学校交流群组,个人交流群组),成员账号类型可以是学校学生账号和醍摩豆ID,,分区键为GroupList-hbcn 
                     case bool when $"{list.type}".Equals("group", StringComparison.OrdinalIgnoreCase):
                         list.type = "group";
                         list = await GroupListService.CheckListNo(list, _azureCosmos, _dingDing, _option);
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus , "web");
                         break;
                     //研修类型成员账号类型可以是学校学生账号和醍摩豆ID,,分区键为GroupList-hbcn 
                     case bool when $"{list.type}".Equals("yxtrain", StringComparison.OrdinalIgnoreCase):
                         list.type = "yxtrain";
                         list.scope = "school";
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, "web");
                         break;
                     default:
                         return Ok(new { error = 400, msg = "参数错误!" });
@@ -1521,7 +1521,7 @@ namespace TEAMModelOS.Controllers
                 }
                 try
                 {
-                    await GroupListService.DeleteGrouplistEvent($"{id}", datacode, tbname, client, _configuration, _serviceBus);
+                    await GroupListService.DeleteGrouplistEvent($"{id}", datacode, tbname, client, _configuration, _serviceBus, "web");
                 }
                 catch (Exception ex) { }
                 return Ok(new { id });
@@ -1686,7 +1686,7 @@ namespace TEAMModelOS.Controllers
                                                     var mb = groupList.members.Find(x => x.type==value.type  && x.id.Equals(value.userid));
                                                     if (mb== null)
                                                     {
-                                                        var joindata = GroupListService.JoinList(groupList, value.userid, value.type, value.school, value.year);
+                                                        var joindata =await GroupListService.JoinList( _azureRedis,groupList, value.userid, value.type, value.school, value.year, _client: "hita");
                                                         if (joindata.status==0) {
                                                             add=true;
                                                         }
@@ -1715,7 +1715,7 @@ namespace TEAMModelOS.Controllers
                                 }
                                 if (add)
                                 {
-                                    await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
+                                    await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, _client: "hita");
                                 }
                             }
                         }

+ 1 - 1
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -724,7 +724,7 @@ namespace TEAMModelOS.Controllers.Client
 
 
                 list = await GroupListService.CheckListNo(list, _azureCosmos, _dingDing, _option);
-                list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, _client: "hita");
 
                 #region === 更新DB課程名單 ===
                 //if (!request.TryGetProperty("datas", out JsonElement _datas))

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

@@ -286,7 +286,7 @@ namespace TEAMModelOS.Controllers
                 list.name = areaStudy.name;
                 list.school = null;
                 list = await GroupListService.CheckListNo(list, _azureCosmos, _dingDing, _option);
-                list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, _client: "web");
                 areaStudy.tchLists.Add(list.id);
                 foreach (string scId in baseIds)
                 {

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

@@ -114,7 +114,7 @@ namespace TEAMModelOS.Controllers.Common
                                     member.code = study.school;
                                     group.members.Add(member);
                                 }
-                                await GroupListService.UpsertList(group, _azureCosmos, _configuration, _serviceBus);
+                                await GroupListService.UpsertList(group, _azureCosmos, _configuration, _serviceBus, _client: "web");
                                 // await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(group, group.id, new PartitionKey($"{group.code}"));
                             }
                         }

+ 6 - 6
TEAMModelOS/Controllers/OpenApi/OpenSchool/ScGroupListController.cs

@@ -336,7 +336,7 @@ namespace TEAMModelOS.Controllers
                         if (infos.Any())
                         {
                             int year = DateTimeOffset.UtcNow.Year;
-                            infos.ToList().ForEach(x =>
+                            infos.ToList().ForEach(async x =>
                             {
                                 var mebJoined = list.members.Find(m => m.id.Equals(x.id) && m.type == 1);
                                 var mb = tmds.Where(m => m.id.Equals(x.id) && m.type == 1).First();
@@ -365,7 +365,7 @@ namespace TEAMModelOS.Controllers
                                 }
                                 else
                                 {
-                                    (int status, GroupList stuList, Member member) = GroupListService.JoinList(list, x.id, 1, school,year);
+                                    (int status, GroupList stuList, Member member) =await GroupListService.JoinList(_azureRedis, list, x.id, 1, school,year, _client: "web");
                                     member.nickname = mb.nickname == null ? mebJoined.nickname : mb.nickname;
                                     member.groupName = groupName == null ? member.groupName : groupName;
                                     member.groupId = groupId == null ? member.groupId : groupId;
@@ -374,7 +374,7 @@ namespace TEAMModelOS.Controllers
                         }
                         if (stus.Any())
                         {
-                            stus.ToList().ForEach(x =>
+                            stus.ToList().ForEach(async x =>
                             {
                                 var mebJoined = list.members.Find(m => m.id.Equals(x.id) && m.type == 2);
                                 var mb = stus.Where(m => m.id.Equals(x.id) && m.type == 2).First();
@@ -402,7 +402,7 @@ namespace TEAMModelOS.Controllers
                                 }
                                 else
                                 {
-                                    (int status, GroupList stuList, Member member) = GroupListService.JoinList(list, x.id, 2, school,x.year);
+                                    (int status, GroupList stuList, Member member) =await GroupListService.JoinList( _azureRedis,list, x.id, 2, school,x.year, _client:"web");
                                     member.nickname = mb.nickname == null ? mebJoined.nickname : mb.nickname;
                                     member.groupName = groupName == null ? member.groupName : groupName;
                                     member.groupId = groupId == null ? member.groupId : groupId;
@@ -411,7 +411,7 @@ namespace TEAMModelOS.Controllers
                         }
 
                         list = await GroupListService.CheckListNo(list, _azureCosmos, _dingDing, _option);
-                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                        list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, _client: "web");
                         return Ok(new
                         {
                             unexist_student,
@@ -503,7 +503,7 @@ namespace TEAMModelOS.Controllers
                             }
                         });
                     }
-                    list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus);
+                    list = await GroupListService.UpsertList(list, _azureCosmos, _configuration, _serviceBus, _client: "web");
                     return Ok(new
                     {
                         remove_stuids,

+ 1 - 1
TEAMModelOS/Controllers/School/ClassController.cs

@@ -270,7 +270,7 @@ namespace TEAMModelOS.Controllers
                 {
                     tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stu, stu.id, new PartitionKey(($"Base-{code}"))));
                 }
-                GroupChange change = new GroupChange();
+                GroupChange change = new GroupChange() { client="web",name =clssz .name};
                 if (students.IsNotEmpty()) {
                     change.stuleave.AddRange(students.Select(x=> new Member {
                         id = x.id,

+ 1 - 1
TEAMModelOS/Controllers/School/SchoolTeacherController.cs

@@ -1085,7 +1085,7 @@ namespace TEAMModelOS.Controllers
                         if (exists)
                         {
                             item.members.RemoveAll(x => x.id.Equals(id.ToString()));
-                            await GroupListService.UpsertList(item, _azureCosmos, _configuration, _azureServiceBus);
+                            await GroupListService.UpsertList(item, _azureCosmos, _configuration, _azureServiceBus, _client: "web");
                             //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(item,item.id,new PartitionKey(item.code));
                         }
                     }

+ 3 - 0
TEAMModelOS/Controllers/Student/StudentController.cs

@@ -142,8 +142,11 @@ namespace TEAMModelOS.Controllers
                                 }
                                 else
                                 {
+                                    Class clazz =await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<Class>(classId, new PartitionKey($"Class-{schoolId}"));
                                     GroupChange change = new GroupChange
                                     {
+                                        client="web",
+                                        name=clazz.name,
                                         scope = "school",
                                         school = schoolId.GetString(),
                                         type = "student",

+ 2 - 2
TEAMModelOS/Controllers/Third/Sc/ScController.cs

@@ -194,7 +194,7 @@ namespace TEAMModelOS.Controllers
                                     if (meber == null || meber.Count() <= 0)
                                     {
                                         yxtrain[0].members.Add(new Member { id = teacher.id, type = 1 });
-                                        await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus);
+                                        await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, _client: "web");
                                     }
                                 }
                                 else
@@ -214,7 +214,7 @@ namespace TEAMModelOS.Controllers
                                         ttl = -1,
                                         expire=0,
                                     };
-                                    await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
+                                    await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, _client: "web");
                                 }
                             }
                             Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));

+ 2 - 2
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -1154,7 +1154,7 @@ namespace TEAMModelOS.Controllers
                             {
                                 groupList.members.Add(new Member { id = schjoin.tmdid, type = 1 });
                             }
-                            await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
+                            await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, _client: "web");
                         }
                     }
                     else
@@ -1183,7 +1183,7 @@ namespace TEAMModelOS.Controllers
                                 pk = "GroupList",
                                 ttl = -1
                             };
-                            await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
+                            await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, _client: "web");
                         }
                     }
                     var schtch = joins.FindAll(x => x.schoolId.Equals(sch.id));

+ 4 - 36
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -59,6 +59,7 @@ using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.School;
+using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Service;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Services;
@@ -114,46 +115,13 @@ namespace TEAMModelOS.Controllers
         /// <param name="file"></param>
         /// <param name="periodId"></param>
         /// <returns></returns>
-        [HttpPost("remove-stucourse")]
+        [HttpPost("test-accumulate")]
         [RequestSizeLimit(102_400_000_00)] //最大10000m左右
         public async Task<IActionResult> RemoveStuCourse(JsonElement json)
         {
 
-            JsonNode jsonNode = JsonObject.Parse(json.ToString());
-            var path= JsonPath.Parse("$.groupLists[*].groupList.members[*]");
-            var d = path.Evaluate(jsonNode);
-            JsonPathContext context = new JsonPathContext
-            { ValueSystem = new JsonApiValueSystem() };
-            //解析试卷作答详情
-            var datas = context.SelectNodes(json,
-            "$.groupLists[*].groupList.members[*]").Select(node => node.Value).ToList();
-        
-
-            return Ok(datas);
-
-
-            //            var schoolResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<string>("select value c.id from c ", "Base");
-            //            if (schoolResult.list.IsNotEmpty()) 
-            //            {
-            //                foreach (var item in schoolResult.list) {
-            //                    var courseResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<IdCode>($"select  c.id,c.code from c where contains(c.code,'StuCourse-{item}-') ");
-            //                    if(courseResult.list.IsNotEmpty()) {
-            //                        foreach (var course in courseResult.list) 
-            //                        {
-            //                           await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).DeleteItemStreamAsync(course.id, new PartitionKey(course.code));
-            //;                        }
-            //                    }
-            //                }
-            //            }
-            //string sql = "select value c from c where contains(c.code,'StuCourse-')";
-            //var courseResult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<IdCode>(sql);
-            //if (courseResult.list.IsNotEmpty())
-            //{
-            //    foreach (var course in courseResult.list)
-            //    {
-            //        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).DeleteItemStreamAsync(course.id, new PartitionKey(course.code));
-            //    }
-            //}
+            Accumulate accumulate= json.ToObject<Accumulate>();
+            await SystemService.RecordAccumulateData(_azureRedis,_dingDing, accumulate);
             return Ok();
         }