CrazyIter_Bin 3 년 전
부모
커밋
d8401c656c

+ 1 - 1
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -1030,7 +1030,7 @@ namespace TEAMModelOS.SDK
                     }
                     }
                     catch (Exception ex)
                     catch (Exception ex)
                     {
                     {
-                        await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location}用户转换失败:{_coreAPIHttpService.options.Get("Default").url}{json}\n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
+                        await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location}用户转换失败:{_coreAPIHttpService.options.Get("Default").url}{json}\n {ex.Message}{ex.StackTrace}{tmdids.Select(x => x.id).ToJsonString()}", GroupNames.成都开发測試群組);
                     }
                     }
                 }
                 }
                
                

+ 1 - 1
TEAMModelOS/Controllers/Third/Sc/ScDataInitController.cs

@@ -614,7 +614,7 @@ namespace TEAMModelOS.Controllers.Third
                     name = sch.schoolname,
                     name = sch.schoolname,
                     // admin = "1530606136",
                     // admin = "1530606136",
                     period = new List<string>() { sch.schooltypename },
                     period = new List<string>() { sch.schooltypename },
-                    size = 100,
+                    size = 1024,
                 });
                 });
             }
             }
             var client = _azureCosmos.GetCosmosClient();
             var client = _azureCosmos.GetCosmosClient();

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

@@ -1727,6 +1727,104 @@ namespace TEAMModelOS.Controllers
                 return Ok(new { state = 401 });
                 return Ok(new { state = 401 });
             }
             }
         }
         }
+
+
+
+        /// <summary>
+        /// 所有学校添加国家智慧教育公共服务平台  https://www.smartedu.cn/ 
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("set-school-smartedu")]
+        public async Task<IActionResult> SetSchoolSmartedu(JsonElement json)
+        {
+            string sql = "select value(c.id) from c  join a in c.third join b in a.links where b.url='https://basic.smartedu.cn/'";
+            List<string> schoolIdsAdded = new List<string>();
+            //已经添加的
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("SchoolSetting") }))
+            {
+                schoolIdsAdded.Add(item);
+            }
+            string sqlSchool = "select value(c.id) from c ";
+            List<string> schoolIdsAddHas= new List<string>();
+            //未添加的=有SchoolSetting的-已经添加的
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sqlSchool, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("SchoolSetting") }))
+            {
+                schoolIdsAddHas.Add(item);
+            }
+            string linkName = "国家智慧教育公共服务平台";
+            string linkUrl = "https://www.smartedu.cn/";
+            //没有添加的
+            var schoolIdsAddNo = schoolIdsAddHas.Except(schoolIdsAdded);
+            //新添加的
+            List<string> schoolIdsAddNew = new List<string>();
+            if (schoolIdsAddHas.IsNotEmpty()) {
+               
+                string sqlAdd = $"select value(c.id) from c  where c.id not in ({string.Join(",",schoolIdsAddHas.Select(x=>$"'{x}'"))})";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<string>(queryText: sqlAdd, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                {
+                    schoolIdsAddNew.Add(item);
+                }
+                foreach (var item in schoolIdsAddNew) {
+                    SchoolSetting setting = new SchoolSetting
+                    {
+                        id= item,
+                        code= "SchoolSetting",
+                        pk= "SchoolSetting",
+                        third= new List<Policy> { new Policy { tag= "default", links= new List<Link> { new Link { name=linkName,url=linkUrl} } } }
+                    };
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).CreateItemAsync(setting, new PartitionKey("SchoolSetting"));
+                }
+
+            }
+            foreach (var item in schoolIdsAddNo) {
+                SchoolSetting setting = await  _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<SchoolSetting>(item, new PartitionKey("SchoolSetting"));
+                if (setting.third.IsNotEmpty())
+                {
+                    var defaultTag = setting.third.Find(x => x.tag.Equals("default"));
+                    if (defaultTag != null)
+                    {
+                        if (defaultTag.links.IsNotEmpty())
+                        {
+                            defaultTag.links.Add(new Link { name = linkName, url = linkUrl });
+                        }
+                        else {
+                            defaultTag.links=new List<Link> { new Link { name = linkName, url = linkUrl } };
+
+                        }
+                    }
+                    else {
+                        setting.third.Add(new Policy { tag = "default", links = new List<Link> { new Link { name = linkName, url = linkUrl } } });
+                    }
+                }
+                else {
+                    setting.third= new List<Policy> { new Policy { tag = "default", links = new List<Link> { new Link { name = linkName, url = linkUrl } } } };
+                }
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(setting, setting.id, new PartitionKey("SchoolSetting"));
+            }
+            return Ok(new { schoolIdsAddNo , schoolIdsAddNew });
+        }
+        /// <summary>
+        /// 给学校空间设置1024T,按区域。
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("fix-school-blobsize")]
+        public async Task<IActionResult> FixSchoolBlobSize(JsonElement json) {
+            string sql = "select value(c) from c where c.areaId in " +
+                "('99a4a33b-e21b-44ac-80a1-b31dc40496e0','f35e0031-a53f-45e5-b307-1cd39446a2cf'," +
+                "'2c1b01fe-3641-464f-8499-7be95a489b7c','9ae614ba-0771-4502-a56e-0537bc5207c3'," +
+                "'870a5a6b-1ab3-461a-bdeb-baec19780ddb','dd15017a-f361-4346-852e-8eee71d027ad')";
+            List<School> schools = new List<School>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
+                schools.Add(item);
+            }
+            schools.ForEach(x => { x.size = 1024; });
+            foreach (var item in schools) {
+                await   _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+            }
+            return Ok(schools);
+        }
         public record CorrectStu
         public record CorrectStu
         {
         {
             public string id { get; set; }
             public string id { get; set; }