浏览代码

研修平台中多人使用一个账户的接口。和相关测试接口

Li 2 年之前
父节点
当前提交
cdf28cabb9

+ 64 - 20
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -53,6 +53,7 @@ using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Specialized;
 using System.Web;
 using Azure.Storage.Sas;
+using DocumentFormat.OpenXml.Drawing.Diagrams;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -1478,36 +1479,79 @@ namespace TEAMModelBI.Controllers.BITest
         {
 
             List<Task<CopyFromUriOperation>> filelist = new List<Task<CopyFromUriOperation>>();
-            var azureClient = _azureStorage.GetBlobContainerClient($"0-public");//获取容器连接地址
+            //var azureClient = _azureStorage.GetBlobContainerClient($"0-public");//获取容器连接地址
+
+            ////查询目录下所有容器路径
+            //await foreach (BlobItem blobItem in azureClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"TestMP4Max/"))
+            //{
+            //    string newurl = $"{blobItem.Name}".Replace($"/SourceFile/", $"/SourceFiles/");//替换成新的容器路径
+            //    var urlSas = _azureStorage.GetBlobSAS($"0-public", blobItem.Name, BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+            //    //await azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas));
+            //    filelist.Add(azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas)));
+            //    //await azureClient.GetBlobClient(newurl).SyncCopyFromUriAsync(new Uri(urlSas));  //添加复制文件到集合执行复制操作
+            //}
+            //if (filelist.Count <= 256)
+            //{
+            //    await Task.WhenAll(filelist);
+            //}
+            //else
+            //{
+            //    int pages = (filelist.Count + 255) / 256;
+            //    for (int i = 0; i < pages; i++)
+            //    {
+            //        List<Task<CopyFromUriOperation>> rspBlobCopyInfos = filelist.Skip((i) * 256).Take(256).ToList();
+            //        await Task.WhenAll(rspBlobCopyInfos);
+            //    }
+            //}
+
+            var azureClient = _azureStorage.GetBlobContainerClient($"1636016499");//获取容器连接地址
 
             //查询目录下所有容器路径
-            await foreach (BlobItem blobItem in azureClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"TestMP4Max/"))
+            await foreach (BlobItem blobItem in azureClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"doc"))
             {
-                string newurl = $"{blobItem.Name}".Replace($"/SourceFile/", $"/SourceFiles/");//替换成新的容器路径
-                var urlSas = _azureStorage.GetBlobSAS($"0-public", blobItem.Name, BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+                string newurl = $"{blobItem.Name}".Replace($"doc/", $"/SourceFiles/");//替换成新的容器路径
+                var urlSas = _azureStorage.GetBlobSAS($"1636016499", blobItem.Name, BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
                 //await azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas));
-                filelist.Add(azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas)));
+                await azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas));
                 //await azureClient.GetBlobClient(newurl).SyncCopyFromUriAsync(new Uri(urlSas));  //添加复制文件到集合执行复制操作
-
-            }
-            if (filelist.Count <= 256)
-            {
-                await Task.WhenAll(filelist);
-            }
-            else
-            {
-                int pages = (filelist.Count + 255) / 256;
-                for (int i = 0; i < pages; i++)
-                {
-                    List<Task<CopyFromUriOperation>> rspBlobCopyInfos = filelist.Skip((i) * 256).Take(256).ToList();
-                    await Task.WhenAll(rspBlobCopyInfos);
-                }
             }
 
-
             return Ok(new { state = 200 , filelist });
         }
 
+        [HttpPost("test-copy-file")]
+        public async Task<IActionResult> TestCaopyFile()
+        {
+            string blobName = "cswznb";
+            string oldFile = "https://teammodeltest.blob.core.chinacloudapi.cn/cswznb/survey%2Fd011c05b-c009-0a53-428f-b871a58092c7%2Findex.json";//"https://teammodeltest.blob.core.chinacloudapi.cn/1636016499/yxpt%2Fstandard2%2FTEAMModelOS%E6%95%B0%E6%8D%AE%E5%BA%93.doc";
+            string oldId = "survey";
+            string newId = "survey1";
+
+            List<Task<CopyFromUriOperation>> filelist = new();   //可复制256M以上文件
+            //var set = await BatchCopyFileService.SingleCopyFile(_azureStorage, blobName, oldFile, oldId, newId);
+
+            var set = await SingleCopyFile(_azureStorage, blobName, oldFile, oldId, newId);
+
+            //var azureClient = _azureStorage.GetBlobContainerClient($"{blobName}");//获取容器连接地址
+            //string newurl = $"{oldFile}".Replace($"/{oldId}/", $"/{newId}/");//替换成新的容器路径
+            //var urlSas = _azureStorage.GetBlobSAS($"{blobName}", $"{newurl}", BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+            //var setr = azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas));    //可复制256M以上文件
+
+            return Ok(new { state = 200 });
+        }
+
+
+        public static Task<int> SingleCopyFile(AzureStorageFactory _azureStorage, string blobName, string oldFile, string oldId, string newId)
+        {
+            var azureClient = _azureStorage.GetBlobContainerClient($"{blobName}");//获取容器连接地址
+            string newurl = oldFile.Substring(oldFile.IndexOf($"{blobName}/") + $"{blobName}/".Length).Replace($"{oldId}", $"{newId}");//替换成新的容器路径
+            string oldFileName = oldFile.Substring(oldFile.IndexOf($"{blobName}/") + $"{blobName}/".Length);
+            var urlSas = _azureStorage.GetBlobSAS($"{blobName}", "", BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+            //var respCopy =  azureClient.GetBlobClient(HttpUtility.UrlDecode(newurl)).SyncCopyFromUri(new Uri(urlSas));    //可复制256M以下文件
+            var respCopy1 = azureClient.GetBlobClient(HttpUtility.UrlDecode(newurl)).StartCopyFromUriAsync(new Uri(urlSas));    //可复制256M以上文件
+            return  null;
+        }
+
         public class linqTest
         {
             public string id { get; set; }

+ 10 - 0
TEAMModelOS.SDK/Models/Service/BatchCopyFileService.cs

@@ -81,8 +81,18 @@ namespace TEAMModelOS.SDK.Models.Service
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-Batch-CopyFile \n {ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return -1;
             }
+        }
 
 
+        public static async Task<CopyFromUriOperation> SingleCopyFile(AzureStorageFactory _azureStorage, string blobName, string oldFile, string oldId, string newId)
+        {
+            var azureClient = _azureStorage.GetBlobContainerClient($"{blobName}");//获取容器连接地址
+            //string name = oldFile.Substring(oldFile.IndexOf($"{blobName}/"));
+            string newurl = oldFile.Substring(oldFile.IndexOf($"{blobName}/")).Replace($"{oldId}/", $"{newId}/");//替换成新的容器路径
+            string oldFileName = oldFile.Substring(oldFile.IndexOf($"{oldId}/") + $"{oldId}/".Length);
+            var urlSas = _azureStorage.GetBlobSAS($"{blobName}", $"{oldFileName}", BlobSasPermissions.Read | BlobSasPermissions.List);   //获取容器sas和有效期
+            var setr = await azureClient.GetBlobClient(newurl).StartCopyFromUriAsync(new Uri(urlSas));    //可复制256M以上文件
+            return setr;
         }
 
     }

+ 381 - 0
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -31,6 +31,12 @@ using TEAMModelOS.Models;
 using System.Text.RegularExpressions;
 using TEAMModelOS.SDK.Services;
 using Azure.Messaging.ServiceBus;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using static ICSharpCode.SharpZipLib.Zip.ZipEntryFactory;
+using Azure.Storage.Sas;
+using DocumentFormat.OpenXml.Drawing.Diagrams;
+using TEAMModelOS.SDK.Models.Dtos;
+using DocumentFormat.OpenXml.Bibliography;
 
 namespace TEAMModelOS.Controllers
 {
@@ -2966,5 +2972,380 @@ namespace TEAMModelOS.Controllers
                 return BadRequest(ex.StackTrace);
             }
         }
+
+        /// <summary>
+        /// 修复研修平台账号重复的问题
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("fix-training")]
+        public async Task<IActionResult> RepairTraining(JsonElement jsonElement) 
+        {
+            if (!jsonElement.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
+            List<TrainingId> trainingIds = ids.ToObject<List<TrainingId>>();
+
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+
+            foreach (var item in trainingIds)
+            {
+                List<ScTeacher> scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "tmdid", $"{item.oldId}" } });
+                if (scTeachers.Count > 0) 
+                {
+                    scTeachers.ForEach(sct => sct.tmdid = item.newId);
+                    ////保存和更新研修信息  最后统一解除注释
+                    //await table.SaveOrUpdateAll(scTeachers);
+                }
+                string defaultSc = null;
+
+                //教师基础信息
+                Teacher teacher = new();
+                var resTchBase = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey("Base"));
+                if (resTchBase.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(resTchBase.ContentStream);
+                    teacher = json.ToObject<Teacher>();
+                    defaultSc = teacher.defaultSchool;
+                    if (string.IsNullOrEmpty(teacher.defaultSchool))
+                        defaultSc = teacher.schools[0].schoolId;
+
+                    teacher.id = $"{item.newId}";
+                    ////教师基础信息
+                    //teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey(teacher.code));
+                }
+
+                //教师研修文件
+                TeacherFile teacherFile = new();
+                var resTchFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"TeacherFile-{defaultSc}"));
+                if (resTchFile.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(resTchFile.ContentStream);
+                    teacherFile = json.ToObject<TeacherFile>();
+                    teacherFile.id = $"{item.newId}";
+                    ////创建新的教师研修文件
+                    //teacherFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey(teacherFile.code));
+                }
+
+                //研修统计
+                TeacherTrain teacherTrain = new();
+                var resTchTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"TeacherTrain-{defaultSc}"));
+                if (resTchTrain.Status == 200) 
+                {
+                    using var json = await JsonDocument.ParseAsync(resTchTrain.ContentStream);
+                    teacherTrain = json.ToObject<TeacherTrain>();
+                    teacherTrain.tmdid = $"{item.newId}";
+                    teacherTrain.id = $"{item.newId}";
+                    //研修报告路径
+                    if (!string.IsNullOrEmpty($"{teacherTrain.offlineUrl}")) 
+                    {
+                        teacherTrain.offlineUrl = teacherTrain.offlineUrl.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                        /**
+                         * 复制操作没写 写完逻辑后补充
+                         */
+
+                        await BatchCopyFileService.SingleCopyFile(_azureStorage, "teammodelos", teacherTrain.offlineUrl, item.oldId, item.newId);
+                    }
+
+                    if (teacherTrain.offlineRecords.Count > 0) 
+                    {
+                        foreach (var off in teacherTrain.offlineRecords)
+                        {
+                            off.url = off.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                            /**
+                             * 复制操作没写 写完逻辑后补充
+                             * 
+                             */
+                            foreach (var offOther in off.other) 
+                            {
+                                /**
+                                 * 复制操作没写 写完逻辑后补充
+                                 */
+                                offOther.url = offOther.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                                offOther.blob = offOther.blob.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                            }
+                        }
+                        //课堂实录
+                        foreach (var tchClass in teacherTrain.teacherClasses)
+                        {
+                            /**
+                             * 复制操作没写 写完逻辑后补充
+                             */
+                            tchClass.url = tchClass.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                        }
+
+                        teacherTrain.id = item.newId;
+                        ////创建新的教师研修统计
+                        //teacherTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherTrain>(teacherTrain, new PartitionKey(teacherTrain.code));
+                    }
+                }
+
+                ClassVideo classVideo = new();
+                var respCalsVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"ClassVideo-{defaultSc}"));
+                if (respCalsVideo.Status == 200) 
+                {
+                    using var json = await JsonDocument.ParseAsync(respCalsVideo.ContentStream);
+                    classVideo = json.ToObject<ClassVideo>();
+                    classVideo.creatorId = $"{item.newId}";
+                    if (classVideo.files.Count > 0) 
+                    {
+                        foreach (var cv in classVideo.files)
+                        {
+                            cv.url = cv.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                            /**
+                             * 复制操作没写 写完逻辑后补充
+                             */
+                        }
+                    }
+
+                    classVideo.id = $"{item.newId}";
+                    ////创建新的教师课堂实录
+                    //classVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<ClassVideo>(classVideo, new PartitionKey(classVideo.code));
+                }
+
+                //订阅记录和学习记录
+                List<Task<ItemResponse<AbilitySub>>> abilitySubs =new();
+                await foreach (var abilitySub in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<AbilitySub>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{defaultSc}-{item.oldId}") }))
+                {
+                    abilitySub.creatorId = item.newId;
+                    if (abilitySub.uploads.Count > 0) 
+                    {
+                        foreach (var asup in abilitySub.uploads)
+                        {
+                            if (asup.urls.Count > 0) 
+                            {
+                                foreach (var asupurl in asup.urls)
+                                {
+                                    asupurl.url = asupurl.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                                    /**
+                                     * 复制操作没写 写完逻辑后补充
+                                     */
+
+                                }
+                            }
+                        }
+                    }
+                    abilitySub.code = abilitySub.code.Replace($"-{item.oldId}", $"-{item.oldId}");
+                    abilitySubs.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<AbilitySub>(abilitySub, new PartitionKey($"AbilitySub-{defaultSc}-{item.newId}")));
+                }
+                
+                //if (abilitySubs.Count < 256)
+                //    await Task.WhenAll(abilitySubs);
+                //else 
+                //{
+                //    int pages = (abilitySubs.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<AbilitySub>>> exAbilitySub = abilitySubs.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(exAbilitySub);
+                //    }
+                //}
+
+                //教师所在学校的基础信息
+                SchoolTeacher schoolTeacher = new();
+                var resScTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{item.oldId}", new PartitionKey($"Teacher-{defaultSc}"));
+                if (resScTeacher.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(resScTeacher.ContentStream);
+                    schoolTeacher = json.ToObject<SchoolTeacher>();
+                    schoolTeacher.id = item.newId;
+
+                    ////创建新的教师在学校的基础信息
+                    //schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
+                }
+
+                //名单信息
+                List<Task<ItemResponse<GroupList>>> groupLists = new();
+                await foreach (var grups in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"GroupList-{defaultSc}") }))
+                {
+                    bool isReplace = false;
+                    if (grups.members.Count > 0) 
+                    {
+                        foreach (var griupm in grups.members)
+                        {
+                            if (griupm.id.Equals(item.oldId)) 
+                            {
+                                griupm.id = item.newId;
+                                isReplace = true;
+                            }
+                        }
+                    }
+                    if (grups.creatorId.Equals(item.oldId)) 
+                    {
+                        grups.creatorId = item.newId;
+                        isReplace = true;
+                    }
+                    if (isReplace == true)
+                    {
+                        //groupLists.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<GroupList>(grups, new PartitionKey(grups.code)));
+                    }
+                }
+
+                //if (groupLists.Count < 256)
+                //    await Task.WhenAll(groupLists);
+                //else 
+                //{
+                //    int pages = (groupLists.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<GroupList>>> tempGroups = groupLists.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempGroups);
+                //    }
+                //}
+
+                //教研活动
+                List<Task<ItemResponse<Study>>> studys = new();
+                await foreach (var study in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<Study>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Study-{defaultSc}") })) 
+                {
+                    if (study.teacIds.Contains(item.oldId) == true)
+                    {
+                        study.teacIds = study.teacIds.Select(x => x.Replace($"{item.oldId}", $"{item.oldId}")).ToList();
+                        studys.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<Study>(study, study.id, new PartitionKey($"Study-{defaultSc}")));
+                    }
+                }
+
+                //if (studys.Count < 256)
+                //    await Task.WhenAll(studys);
+                //else
+                //{
+                //    int pages = (studys.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<Study>>> tempStudys = studys.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempStudys);
+                //    }
+                //}
+
+                //教研测验活动
+                List<Task<ItemResponse<ExamLite>>> examLites = new();
+                await foreach (var examl in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamLite>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamLite-{defaultSc}") })) 
+                {
+                    bool isReplace = false;
+                    if (examl.teachers.Count > 0) 
+                    {
+                        foreach (var examTch in examl.teachers)
+                        {
+                            if (examTch.id.Equals(item.oldId))
+                            {
+                                examTch.id = item.newId;
+                                isReplace =true;
+                            }
+                        }
+                    }
+                    if (isReplace == true) 
+                    {
+                        examLites.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamLite>(examl, examl.id, new PartitionKey($"ExamLite-{defaultSc}")));
+                    }
+                }
+
+                //if (examLites.Count < 256)
+                //    await Task.WhenAll(examLites);
+                //else
+                //{
+                //    int pages = (examLites.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<ExamLite>>> tempExam = examLites.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempExam);
+                //    }
+                //}
+
+                List<Task<ItemResponse<HomeworkRecord>>> homeworkRecord = new();
+                await foreach (var homerec in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{item.oldId}") }))
+                {
+                    bool isReplace = false;
+                    if (homerec.content.Count > 0) 
+                    {
+                        foreach (var hrCon in homerec.content)
+                        {
+                            if (hrCon.url.Contains($"/{item.oldId}/")) 
+                            {
+                                hrCon.url = hrCon.url.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                                hrCon.blob = hrCon.blob.Replace($"/{item.oldId}/", $"/{item.newId}/");
+                                isReplace = true;
+                            }
+                        }
+                    }
+
+                    if (isReplace == true)
+                    {
+                        homerec.code = homerec.code.Replace($"-{item.oldId}", $"-{item.oldId}");
+                        homeworkRecord.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<HomeworkRecord>(homerec, homerec.id, new PartitionKey()));
+                    }
+                }
+
+                //if (homeworkRecord.Count < 256)
+                //    await Task.WhenAll(homeworkRecord);
+                //else
+                //{
+                //    int pages = (homeworkRecord.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<HomeworkRecord>>> tempHomeR = homeworkRecord.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempHomeR);
+                //    }
+                //}
+
+                //视频点评
+                List<Task<ItemResponse<Appraise>>> appraises = new();
+                await foreach (var appra in cosmosClient.GetContainer(Constant.TEAMModelOS,"Teacher").GetItemQueryIterator<Appraise>(queryText:"select value(c) from c", requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Appraise-{item.oldId}") }))
+                {
+                    appra.code = appra.code.Replace($"-{item.oldId}", $"-{item.newId}");
+                    appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Appraise>(appra, new PartitionKey(appra.code)));
+                }
+
+                //if (appraises.Count < 256)
+                //    await Task.WhenAll(appraises);
+                //else
+                //{
+                //    int pages = (appraises.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<Appraise>>> tempAppra = appraises.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempAppra);
+                //    }
+                //}
+
+                List<Task<ItemResponse<Debate>>> debates = new();
+                await foreach (var debate in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Debate>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{defaultSc}") }))
+                {
+                    bool isReplace = false;
+                    if (debate.replies.Count > 0) 
+                    {
+                        foreach (var deRep in debate.replies)
+                        {
+                            if (deRep.tmdid.Equals(item.oldId)) 
+                            {
+                                deRep.tmdid = item.newId;
+                            }
+                        }
+                    }
+                    if (isReplace == true)
+                    {
+                        debates.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<Debate>(debate, debate.id, new PartitionKey(debate.code)));
+                    }
+                }
+
+                //if (debates.Count < 256)
+                //    await Task.WhenAll(debates);
+                //else
+                //{
+                //    int pages = (debates.Count + 255) / 256;
+                //    for (int i = 0; i < pages; i++)
+                //    {
+                //        List<Task<ItemResponse<Debate>>> tempDebates = debates.Skip((i) * 256).Take(256).ToList();
+                //        await Task.WhenAll(tempDebates);
+                //    }
+                //}
+            }
+
+            return Ok(new { state = 200 });
+        }
+
+        public record TrainingId 
+        {
+            public string oldId { get; set; }
+
+            public string newId { get; set; }
+        }
     }
 }