Browse Source

版本号标记5.2210.19

CrazyIter_Bin 2 năm trước cách đây
mục cha
commit
d34f86a35d

+ 52 - 3
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -1,10 +1,10 @@
 using Azure.Cosmos;
 using Azure.Storage.Blobs.Models;
 using HTEXLib.COMM.Helpers;
+using HTEXLib.Models;
 using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Azure.Functions.Worker.Http;
-using OpenXmlPowerTools;
 using StackExchange.Redis;
 using System;
 using System.Collections.Generic;
@@ -12,15 +12,18 @@ using System.Dynamic;
 using System.IO;
 using System.Linq;
 using System.Net;
+using System.Net.Http;
+using System.Net.Http.Json;
 using System.Reflection;
+using System.Security.Policy;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
+using System.Web;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
-using TEAMModelOS.SDK.Models.Cosmos.Teacher;
 using TEAMModelOS.SDK.Models.Table;
 using static TEAMModelOS.SDK.Models.Teacher;
 
@@ -32,13 +35,15 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
         private readonly DingDing _dingDing;
         private readonly AzureStorageFactory _azureStorage;
         private readonly AzureRedisFactory _azureRedis;
+        private readonly HttpClient _httpClient;
         public IESHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage
-      , AzureRedisFactory azureRedis)
+      , AzureRedisFactory azureRedis, HttpClient httpClient)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _azureStorage = azureStorage;
             _azureRedis = azureRedis;
+            _httpClient = httpClient;
         }
         /// <summary>
         /// </summary>
@@ -846,5 +851,49 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
                 return response;
             }
         }
+        /// <summary>
+        /// 艺术评测报告生成
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Function("online-record")]
+        public async Task<HttpResponseData> GenArtPDF([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req) {
+            var response = req.CreateResponse(HttpStatusCode.OK);
+            string data = await new StreamReader(req.Body).ReadToEndAsync();
+            var json = JsonDocument.Parse(data).RootElement;
+            json.TryGetProperty("studentPdfs", out JsonElement _studentPdfs);
+            json.TryGetProperty("schoolCode", out JsonElement _schoolCode);
+            List<ArtStudentPdf> studentPdfs = _studentPdfs.Deserialize<List<ArtStudentPdf>>();
+            List<Task<string>> uploads = new List<Task<string>>();
+            studentPdfs.ForEach(x => {
+                uploads.Add(_azureStorage.GetBlobContainerClient(x.schoolCode).UploadFileByContainer(x.ToJsonString(), "art", $"{x.artId}/report/{x.studentId}.json", true));
+            });
+            var uploadJsonUrls= await Task.WhenAll(uploads);
+            var list =uploadJsonUrls.ToList();
+            List<string> urls = new List<string>();
+            (string uri, string sas) =  _azureStorage.GetBlobContainerSAS($"{_schoolCode}",Azure.Storage.Sas.BlobContainerSasPermissions.Read);
+            studentPdfs.ForEach(x => {
+                string atrUrl = "https://teammodelos.blob.core.chinacloudapi.cn/0-public/art-report-template/report.html";
+                var a = list.Find(l => l.Contains(x.studentId));
+                if (a != null) {
+                    a = $"{HttpUtility.UrlEncode($"{a}?{sas}", Encoding.UTF8)}";
+                    string url = $"{atrUrl}?url={a}&pdfpath={x.artId}/report/{x.studentId}";
+                    urls.Add(url);
+                }
+            });
+            await _httpClient.PostAsJsonAsync("http://cdhabook.teammodel.cn:8805/screen/screenshot-pdf",
+                new 
+                {
+                    width = 1080,
+                    height=1920,
+                    urls= urls,
+                    fileNameKey= "pdfpath",
+                    cnt=$"{_schoolCode}",
+                    root="art",
+                    pagesize=5
+                }
+            );
+            return response;
+        }
     }
 }

+ 72 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/StudentArtResult.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -65,4 +66,75 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public List<Attachment> files { get; set; }
     }
+    public class ArtStudentPdf
+    {
+        public string schoolName { get; set; }
+        public string periodId { get; set; }
+        public string periodName { get; set; }
+        public string schoolCode { get; set; }
+        public string studentId { get; set; }
+        public string studentName { get; set; }
+        public string picture { get; set; }
+        public List<string> classNames { get; set; } = new List<string>();
+        public string artName { get; set; }
+        public string artId { get; set; }
+        public string level { get; set; }
+        public double score { get; set; }
+        /// <summary>
+        /// 评语
+        /// </summary>
+        public string comment { get; set; }
+        public List<ArtQuotaPdf> allSubjectQuotas { get; set; }
+    }
+    /// <summary>
+    /// 艺术评测指标维度PDF输出。
+    /// </summary>
+    public class ArtQuotaPdf
+    {
+        public string quota1 { get; set; }
+        public string quota2 { get; set; }
+        public string quota3 { get; set; }
+        public string quotaN1 { get; set; }
+        public string quotaN2 { get; set; }
+        public string quotaN3 { get; set; }
+        public double quotaP1 { get; set; }
+        public double quotaP2 { get; set; }
+        public double quotaP3 { get; set; }
+        public string quotaId { get; set; }
+        public string quotaName { get; set; }
+        public string scoreData { get; set; }
+        public double score { get; set; }
+        public string percent { get; set; }
+        public string level { get; set; }
+    }
+    public class StudentArt
+    {
+        [Required(ErrorMessage = "studentId 必须设置")]
+        public string studentId { get; set; }
+        public double totalScore { get; set; } = -1;
+        public List<ArtResult> results { get; set; } = new List<ArtResult>();
+        public List<ArtSubjectScore> subjectScores { get; set; } = new List<ArtSubjectScore>();
+    }
+    public class ArtResult
+    {
+        /// <summary>
+        /// 任务id
+        /// </summary>
+        [Required(ErrorMessage = "taskId 必须设置")]
+        public string taskId { get; set; }
+        /// <summary>
+        /// 科目id
+        /// </summary>
+        [Required(ErrorMessage = "subjectId 必须设置")]
+        public string subjectId { get; set; }
+        /// <summary>
+        /// 指标id
+        /// </summary>
+        [Required(ErrorMessage = "quotaId 必须设置")]
+        public string quotaId { get; set; }
+        /// <summary>
+        /// 分数
+        /// </summary>
+        public double score { get; set; }
+    }
 }

+ 2 - 64
TEAMModelOS/Controllers/School/ArtReviewController.cs

@@ -357,41 +357,7 @@ namespace TEAMModelOS.Controllers
 
         }
 
-        public class ArtStudentPdf { 
-            public string studentId { get; set; }
-            public string studentName { get; set; }
-            public string picture { get; set; }
-            public List<string> classNames { get; set; } = new List<string>();
-            public  string artName { get; set;}
-            public string level { get; set; }
-            public double score { get; set; }
-            /// <summary>
-            /// 评语
-            /// </summary>
-            public string comment { get; set; }
-            public List<ArtQuotaPdf> allSubjectQuotas { get; set; }
-        }
-        /// <summary>
-        /// 艺术评测指标维度PDF输出。
-        /// </summary>
-        public class ArtQuotaPdf
-        {
-            public string quota1 { get; set; }
-            public string quota2 { get; set; }
-            public string quota3 { get; set; }
-            public string quotaN1 { get; set; }
-            public string quotaN2 { get; set; }
-            public string quotaN3 { get; set; }
-            public double quotaP1 { get; set; }
-            public double quotaP2 { get; set; }
-            public double quotaP3 { get; set; }
-            public string quotaId { get; set; }
-            public string quotaName { get; set; }
-            public string scoreData { get; set; }
-            public double score { get; set; }
-            public string percent { get; set; }
-            public string level { get; set; }
-        }
+      
         /// <summary>
         /// 
         /// </summary>
@@ -640,33 +606,5 @@ namespace TEAMModelOS.Controllers
             return Ok();
         }
     }
-    public class StudentArt {
-        [Required(ErrorMessage = "studentId 必须设置")]
-        public string studentId { get; set; }
-        public double totalScore { get; set; } = -1;
-        public List<ArtResult> results { get; set; } = new List<ArtResult>();
-        public List<ArtSubjectScore> subjectScores { get; set; } = new List<ArtSubjectScore>();
-    }
-    public class ArtResult
-    {
-        /// <summary>
-        /// 任务id
-        /// </summary>
-        [Required(ErrorMessage = "taskId 必须设置")]
-        public string taskId { get; set; }
-        /// <summary>
-        /// 科目id
-        /// </summary>
-        [Required(ErrorMessage = "subjectId 必须设置")]
-        public string subjectId { get; set; }
-        /// <summary>
-        /// 指标id
-        /// </summary>
-        [Required(ErrorMessage = "quotaId 必须设置")] 
-        public string quotaId { get; set; }
-        /// <summary>
-        /// 分数
-        /// </summary>
-        public double score { get; set; }
-    }
+    
 }

+ 0 - 4
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -27,11 +27,7 @@ using System.Net.Http.Json;
 using HTEXLib.COMM.Helpers;
 using System.IdentityModel.Tokens.Jwt;
 using TEAMModelOS.SDK.DI.CoreAPI;
-using Azure.Storage.Blobs.Models;
-using Microsoft.Extensions.Hosting;
 using Microsoft.AspNetCore.Hosting;
-using DocumentFormat.OpenXml.Office2010.Excel;
-using TEAMModelOS.SDK.Models.Service;
 
 namespace TEAMModelOS.Controllers
 {

+ 38 - 1
TEAMModelOS/Controllers/Third/Sc/ScApiController.cs

@@ -27,6 +27,8 @@ using Azure.Storage.Blobs.Models;
 using static TEAMModelOS.SDK.Models.Teacher;
 using System.Web;
 using static TEAMModelOS.Controllers.FixDataController;
+using System.Collections;
+using FastJSON;
 
 namespace TEAMModelOS.Controllers
 {
@@ -73,7 +75,42 @@ namespace TEAMModelOS.Controllers
            
             _httpTrigger = httpTrigger;
         }
-         
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("sc/get-school-list")]
+        [AllowAnonymous]
+        public async Task<IActionResult> GetSchoolList(List<Unbind> unbinds) {
+            // 5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表
+            string  Code = "GetSchoolList";
+            Dictionary<string,object> parameterMap = new Dictionary<string, object>
+            {
+                { "TrainComID", "3072" },
+                { "ProjectID", "180" },
+                { "ProjectItemID", "1249" }
+            };
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            ScsResult GetSchoolList1 = await _scsApisService.Post("https://scts.scedu.com.cn/webservice/EduService.asmx/RequestService", Code, "MSmZQnjvySxwB8KZ", "CA00580BB7BFA3817334CFA38257AC9A", parameterMap);
+            GetSchoolList1.bizcode = Code;
+            GetSchoolList1.title = "5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表";
+            List<ScSchool>  schools = GetSchoolList1.content.ToObject<List<ScSchool>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+            List<ScSchool> tbschools = new List<ScSchool>();
+            var zhishu = await table.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"f35e0031-a53f-45e5-b307-1cd39446a2cf" } });
+            var fzhishu = await table.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"870a5a6b-1ab3-461a-bdeb-baec19780ddb" } });
+            if (zhishu.Any()) {
+                tbschools.AddRange(zhishu);
+            }
+            if (fzhishu.Any())
+            {
+                tbschools.AddRange(fzhishu);
+            }
+            var ids= schools.Select(x => x.schoolid).Except(tbschools.Select(x => x.schoolid));
+            var newschools= schools.Where(x => ids.Contains(x.schoolid));
+            return Ok(new { schools= schools.ToJsonString(), newschools = newschools .ToJsonString()});
+        }
         /// <summary>
         ///
         /// </summary>

+ 123 - 8
TEAMModelOS/Controllers/Third/Sc/ScDataInitController.cs

@@ -196,6 +196,117 @@ namespace TEAMModelOS.Controllers.Third
             var unbind = ScTeachers.Where(x => string.IsNullOrWhiteSpace(x.tmdid));
             return Ok(unbind);
         }
+
+        /// <summary>
+        /// 4. 同步增加批次的
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-scs-teacher-add")]
+        [AllowAnonymous]
+        public async Task<IActionResult> getScsTeacherAdd(JsonElement request) {
+            if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
+            if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
+            if (!request.TryGetProperty("dist", out JsonElement dist)) return BadRequest();
+            if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            var ScTeachers1249 = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "ProjectItemID", 1249 } });
+            //数据校验
+            var jsondata = ScTeachers1249.Select(x => new { x.schoolCode, x.tmdid, x.PXID, x.TID, x.TeacherName, x.SchoolName, x.SchoolID, x.Account, x.areaId }).ToJsonString();
+            //当前区已有的教师
+            var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
+            //当前区的学校
+            var ScSchools = await table.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"{areaId}" } });
+            Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
+            //获取当前期,所有区所有学校的教师
+            (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            //序列化
+            List<ScTeacher> teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+            // 处理省平台后补的教师,教师的学校不在当前区的学校列表中。
+            teachers.RemoveAll(x => !ScSchools.Select(z => z.schoolid).Contains(x.SchoolID));
+            string json_teachers = teachers.ToJsonString();
+            //拿到当前期的所有且是再当前区内的学校的培训id
+            var a = teachers.Select(x => $"{x.PXID}").ToList();
+            var s = ScTeachers.Select(z=>z.RowKey).ToList();
+            //新增的pxid
+            var addPxid = a.Except(s).ToList();
+            //原来已经有的pdxid可能需要更新的,如果需要更新,则需要判断两次的TID是否相同,不相同则需要换绑tmdid,则需要把tmdid置空
+            var updatePxid = a.Where(x=>s.Contains(x)).ToList();
+            if (addPxid.Any())
+            {
+                List<ScTeacher> newTeachers = new List<ScTeacher>();
+                var allScteacher = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+                addPxid.ForEach(add =>
+                {
+                    var newTeacher = allScteacher.Find(x => $"{x.PXID}".Equals(add));
+                    if (newTeacher != null)
+                    {
+                        var schoolInfo = ScSchools.Find(x => x.schoolid == newTeacher.SchoolID);
+                        if (schoolInfo != null)
+                        {
+                            newTeacher.status = 1;
+                            newTeacher.areaId = $"{areaId}";
+                            newTeacher.PartitionKey = "ScTeacher";
+                            newTeacher.tmdid = null;
+                            newTeacher.schoolCode = schoolInfo?.schoolCode;
+                            newTeacher.RowKey = $"{newTeacher.PXID}";
+                            newTeachers.Add(newTeacher);
+                        }
+                    }
+                });
+                await table.SaveOrUpdateAll(newTeachers);
+            }
+            if (updatePxid.Any()) {
+                List<ScTeacher> updateTeachers = new List<ScTeacher>();
+                var allScteacher = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+                updatePxid.ForEach(update => {
+                    //数据库的教师
+                    var updateTeacherDB = ScTeachers.Find(x => $"{x.RowKey}".Equals(update));
+                    //省平台的教师
+                    var schoolInfo = ScSchools.Find(x => x.schoolid == updateTeacherDB.SchoolID);
+                    var scTeacher = allScteacher.Find(x => $"{x.PXID}".Equals(update));
+                    if (updateTeacherDB != null && scTeacher!=null) {
+                        if (updateTeacherDB.TID == scTeacher.TID)
+                        {
+                            //保持tmdid不变
+                            updateTeacherDB.TID = scTeacher.TID;
+                        }
+                        else {
+                            updateTeacherDB.tmdid = null;
+                        }
+                        updateTeacherDB.PXID = scTeacher.PXID;
+                        updateTeacherDB.TID = scTeacher.TID;
+                        updateTeacherDB.TeacherName = scTeacher.TeacherName;
+                        updateTeacherDB.status = 1;
+                        updateTeacherDB.SchoolID = scTeacher.SchoolID;
+                        updateTeacherDB.SchoolName = scTeacher.SchoolName;
+                        updateTeacherDB.ProjectID = scTeacher.ProjectID;
+                        updateTeacherDB.ProjectItemID = scTeacher.ProjectItemID;
+                        updateTeacherDB.ProjectItemTitle = scTeacher.ProjectItemTitle;
+                        updateTeacherDB.ProjectTitle = scTeacher.ProjectTitle;
+                        updateTeacherDB.CityID = scTeacher.CityID;
+                        updateTeacherDB.DistrictID = scTeacher.DistrictID;
+                        updateTeacherDB.CityName = scTeacher.CityName;
+                        updateTeacherDB.DisName = scTeacher.DisName;
+                        updateTeacherDB.Account = scTeacher.Account;
+                        updateTeacherDB.TeacherXK = scTeacher.TeacherXK;
+                        updateTeacherDB.TeacherXD = scTeacher.TeacherXD;
+                        updateTeacherDB.Mobile = scTeacher.Mobile;
+                        updateTeacherDB.Email = scTeacher.Email;
+                        updateTeacherDB.areaId = $"{areaId}";
+                        updateTeacherDB.PartitionKey = "ScTeacher";
+                        updateTeacherDB.schoolCode = schoolInfo?.schoolCode;
+                        updateTeachers.Add(updateTeacherDB);
+                    }
+                   
+                });
+                await table.SaveOrUpdateAll(updateTeachers);
+            }
+            return Ok();
+        }
+
         /// <summary>
         /// 3. 处理 省平台最新的教师以及 反向更新没有绑定醍摩豆id 的账号。
         /// </summary>
@@ -228,16 +339,20 @@ namespace TEAMModelOS.Controllers.Third
             //未保存在数据库的。
             var asin = a.Except(s).ToList();
             string json_asin = asin.ToJsonString();
-            //var aa =a.Except(asin);
-            //if (aa.Any()) {
+            var aa = a.Except(asin);
+            //if (aa.Any())
+            //{
             //    List<ScTeacher> newTeachers = new List<ScTeacher>();
             //    var allScteacher = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
-            //    aa.ToList().ForEach(a => {
+            //    aa.ToList().ForEach(a =>
+            //    {
             //        var newTeacher = allScteacher.Find(x => $"{x.TID}".Equals(a));
-            //        if (newTeacher != null) {
-            //           var schoolInfo = ScSchools.Find(x => x.schoolid == newTeacher.SchoolID);
-            //            if (schoolInfo != null) {
-            //                newTeacher.status = 1; 
+            //        if (newTeacher != null)
+            //        {
+            //            var schoolInfo = ScSchools.Find(x => x.schoolid == newTeacher.SchoolID);
+            //            if (schoolInfo != null)
+            //            {
+            //                newTeacher.status = 1;
             //                newTeacher.areaId = $"{areaId}";
             //                newTeacher.PartitionKey = "ScTeacher";
             //                newTeacher.tmdid = null;
@@ -247,7 +362,7 @@ namespace TEAMModelOS.Controllers.Third
             //            }
             //        }
             //    });
-            //     await table.SaveOrUpdateAll(newTeachers);
+            //    await table.SaveOrUpdateAll(newTeachers);
             //}
             #region 省平台获取到最新的教师,并添加到Table中。
             var adds = teachers.FindAll(x => asin.Contains($"{x.TID}"));

+ 15 - 8
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -3015,7 +3015,9 @@ namespace TEAMModelOS.Controllers
 
                         teacher.id = $"{item.newId}";
                         //教师基础信息
-                        teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey(teacher.code));
+                        try {
+                            teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey(teacher.code));
+                        } catch { }
                     }
 
                     //教师研修文件
@@ -3027,7 +3029,9 @@ namespace TEAMModelOS.Controllers
                         teacherFile = json.ToObject<TeacherFile>();
                         teacherFile.id = $"{item.newId}";
                         //创建新的教师研修文件
-                        teacherFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey(teacherFile.code));
+                        try {
+                            teacherFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey(teacherFile.code));
+                        } catch { }
                     }
 
                     //研修统计
@@ -3124,7 +3128,7 @@ namespace TEAMModelOS.Controllers
                         }
                         teacherTrain.id = item.newId;
                         //创建新的教师研修统计
-                        teacherTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherTrain>(teacherTrain, new PartitionKey(teacherTrain.code));
+                        try { teacherTrain = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherTrain>(teacherTrain, new PartitionKey(teacherTrain.code)); } catch { }
                     }
 
                     //课堂实录
@@ -3153,7 +3157,7 @@ namespace TEAMModelOS.Controllers
 
                         classVideo.id = $"{item.newId}";
                         //创建新的教师课堂实录
-                        classVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<ClassVideo>(classVideo, new PartitionKey(classVideo.code));
+                        try { classVideo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<ClassVideo>(classVideo, new PartitionKey(classVideo.code)); } catch { }
                     }
 
                     //订阅记录和学习记录
@@ -3193,7 +3197,7 @@ namespace TEAMModelOS.Controllers
                         }
 
                         abilitySub.code = abilitySub.code.Replace($"-{item.oldId}", $"-{item.newId}");
-                        abilitySubs.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<AbilitySub>(abilitySub, new PartitionKey($"AbilitySub-{defaultSc}-{item.newId}")));
+                        try { abilitySubs.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<AbilitySub>(abilitySub, new PartitionKey($"AbilitySub-{defaultSc}-{item.newId}"))); } catch { }
                     }
 
                     if (abilitySubs.Count < 256)
@@ -3218,7 +3222,10 @@ namespace TEAMModelOS.Controllers
                         schoolTeacher.id = item.newId;
 
                         //创建新的教师在学校的基础信息
-                        schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
+                        try { 
+                            schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code)); 
+                        } catch { 
+                        }
                     }
 
                     //名单信息
@@ -3348,7 +3355,7 @@ namespace TEAMModelOS.Controllers
                         if (isReplace == true)
                         {
                             homerec.code = homerec.code.Replace($"-{item.oldId}", $"-{item.newId}");
-                            homeworkRecord.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<HomeworkRecord>(homerec, new PartitionKey(homerec.code)));
+                            try { homeworkRecord.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<HomeworkRecord>(homerec, new PartitionKey(homerec.code))); } catch { }
                         }
                     }
 
@@ -3388,7 +3395,7 @@ namespace TEAMModelOS.Controllers
                         }
 
                         if ((isRepCode == true && isReplace == true) || (isRepCode == true && isReplace == false))
-                            appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Appraise>(appra, new PartitionKey(appra.code)));
+                            try { appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Appraise>(appra, new PartitionKey(appra.code))); } catch { }
                         if (isReplace == true && isRepCode == false)
                             appraises.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Appraise>(appra, appra.id, new PartitionKey(appra.code)));
                     }