BatchSchoolController.cs 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440
  1. using Azure.Cosmos;
  2. using HTEXLib.COMM.Helpers;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.Extensions.Options;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Dynamic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Text.Json;
  12. using System.Threading.Tasks;
  13. using TEAMModelOS.Models;
  14. using TEAMModelOS.SDK.DI;
  15. using TEAMModelOS.SDK.Extension;
  16. using TEAMModelOS.SDK.Models;
  17. using TEAMModelOS.SDK.Models.Cosmos.BI;
  18. using Microsoft.AspNetCore.Hosting; //引用读取文件
  19. using TEAMModelOS.SDK.Models.Service;
  20. using System.IO;
  21. using System.Net.Http;
  22. using Microsoft.Extensions.Configuration;
  23. using System.Net.Http.Json;
  24. using System.Net;
  25. using TEAMModelBI.Filter;
  26. using TEAMModelBI.Tool.Extension;
  27. using TEAMModelBI.Tool;
  28. using TEAMModelBI.Models;
  29. using TEAMModelOS.SDK;
  30. using TEAMModelOS.SDK.Context.BI;
  31. using TEAMModelOS.SDK.Context.Constant;
  32. using Pipelines.Sockets.Unofficial.Arenas;
  33. using Microsoft.Identity.Client;
  34. using TEAMModelOS.SDK.Models.Dtos;
  35. using static TEAMModelBI.Controllers.BITest.TestController;
  36. using static TEAMModelBI.Controllers.BISchool.BatchSchoolController;
  37. using DocumentFormat.OpenXml.Spreadsheet;
  38. namespace TEAMModelBI.Controllers.BISchool
  39. {
  40. [Route("batchschool")]
  41. [ApiController]
  42. public class BatchSchoolController : ControllerBase
  43. {
  44. private readonly AzureCosmosFactory _azureCosmos;
  45. private readonly DingDing _dingDing;
  46. private readonly Option _option;
  47. private readonly AzureStorageFactory _azureStorage;
  48. private readonly IWebHostEnvironment _environment; //读取文件
  49. private readonly IHttpClientFactory _http;
  50. //读取配置信息
  51. private readonly IConfiguration _configuration;
  52. private readonly CoreAPIHttpService _coreAPIHttpService;
  53. public BatchSchoolController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, IHttpClientFactory http, CoreAPIHttpService coreAPIHttpService)
  54. {
  55. _azureCosmos = azureCosmos;
  56. _dingDing = dingDing;
  57. _azureStorage = azureStorage;
  58. _option = option?.Value;
  59. _environment = hostingEnvironment;
  60. _configuration = configuration;
  61. _http = http;
  62. _coreAPIHttpService = coreAPIHttpService;
  63. }
  64. /// <summary>
  65. /// 获取BI权限列表 //已对接
  66. /// </summary>
  67. /// <returns></returns>
  68. [ProducesDefaultResponseType]
  69. [HttpPost("get-teacher-authoritybilist")]
  70. public async Task<IActionResult> GetAuthorityBIList(JsonElement jsonElement)
  71. {
  72. //jsonElement.TryGetProperty("site", out JsonElement site);
  73. Dictionary<string, object> dic = new() { { "PartitionKey", "authority-bi" } };
  74. var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
  75. ////分开部署,就不需要,一站多用时,取消注释
  76. //if ($"{site}".Equals(BIConst.Global))
  77. // table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("SchoolSetting");
  78. List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
  79. return Ok(new { authorityBIList });
  80. }
  81. /// <summary>
  82. /// 批量创校 //已对接
  83. /// </summary>
  84. /// <param name="school"></param>
  85. /// <returns></returns>
  86. [ProducesDefaultResponseType]
  87. [AuthToken(Roles = "admin,rdc")]
  88. [HttpPost("batch-school")]
  89. public async Task<IActionResult> BatchCreateSchool(FoundSchools foundSchools)
  90. {
  91. try
  92. {
  93. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  94. List<BISchool> schools = new();
  95. List<BISchool> userScs = new();
  96. List<BISchool> cutArea = new();
  97. List<string> upSc = new();
  98. StringBuilder stringBuilder = new($"{_tmdName}【{_tmdId}】使用批量创校功能:");
  99. StringBuilder noticeDD = new(); //创校信息通知
  100. var cosmosClient = _azureCosmos.GetCosmosClient();
  101. var tableClient = _azureStorage.GetCloudTableClient();
  102. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
  103. //if (BIConst.Global.Equals($"{foundSchools.site}"))
  104. //{
  105. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  106. // tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
  107. // blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
  108. //}
  109. if (foundSchools.biSchools.Count > 0)
  110. {
  111. #region 新版直接创建
  112. foreach (BISchool bischool in foundSchools.biSchools)
  113. {
  114. Area area = null;
  115. //查询区是否存在
  116. var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
  117. if (respAreaId.Status == 200)
  118. {
  119. using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
  120. area = areaBase.ToObject<Area>();
  121. }
  122. CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
  123. {
  124. province = bischool.province,
  125. id = "",
  126. name = bischool.name,
  127. city = bischool.city,
  128. aname = "",
  129. createCount = 0,
  130. };
  131. //生成学校ID
  132. bool tempStaus = true;
  133. do
  134. {
  135. createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
  136. var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
  137. if (schoolStatu.Status != 200) tempStaus = false;
  138. else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
  139. } while (tempStaus);
  140. if (createSchoolInfo.id != null)
  141. {
  142. string campusId = Guid.NewGuid().ToString();
  143. School upSchool = new()
  144. {
  145. id = createSchoolInfo.id,
  146. name = bischool.name,
  147. size = bischool.size == 0 ? 100 : bischool.size,
  148. code = "Base",
  149. campuses = new List<Campus> { new Campus { name = bischool.name, id = campusId } },
  150. region = bischool.region,
  151. province = bischool.province,
  152. city = bischool.city,
  153. dist = bischool.dist,
  154. address = bischool.address,
  155. picture = "https://teammodelstorage.blob.core.chinacloudapi.cn/0-public/school/bbf54fb3-3fc8-43ae-a358-107281c174cc.png",
  156. timeZone = new TEAMModelOS.SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
  157. type = string.IsNullOrEmpty(bischool.type.ToString()) ? 1 : bischool.type,
  158. pk = "School",
  159. ttl = -1,
  160. areaId = area == null ? "" : area.id,
  161. standard = area == null ? "" : area.standard,
  162. schoolCode = createSchoolInfo.id,
  163. period = PresetSchoolPeriod(bischool.period, foundSchools.lang, campusId),
  164. scale = bischool.size >= 300 ? 500 : 0,
  165. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  166. };
  167. stringBuilder.Append($"创建学校:{upSchool.name}【{upSchool.id}】");
  168. noticeDD.Append($"{upSchool.name}【{upSchool.id}】 \r 学校管理员信息:");
  169. upSc.Add(upSchool.id);
  170. //创建学校
  171. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(upSchool, new PartitionKey(upSchool.code));
  172. var content = new StringContent(bischool.admin.ToArray().ToJsonString(), Encoding.UTF8, "application/json");
  173. string json = await _coreAPIHttpService.GetUserInfos(content);
  174. List<TmdUserinfo> tmdInfos = json.ToObject<List<TmdUserinfo>>();
  175. foreach (var tmdIndo in tmdInfos)
  176. {
  177. Teacher teacher = new();
  178. var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{tmdIndo.id}", new PartitionKey("Base"));
  179. if (resTeache.Status == 200)
  180. {
  181. using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
  182. teacher = tchJson.ToObject<Teacher>();
  183. //教师存在,在该教师信息中添加要管理的学校信息
  184. teacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId, schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
  185. //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, coreUser.id, new PartitionKey("Base"));
  186. SchoolTeacher schoolTeacher = new()
  187. {
  188. id = tmdIndo.id,
  189. code = $"Teacher-{createSchoolInfo.id}",
  190. roles = new List<string> { "admin" },
  191. job = "管理员",
  192. name = teacher.name,
  193. picture = teacher.picture,
  194. status = "join",
  195. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  196. pk = "Teacher",
  197. ttl = -1
  198. };
  199. stringBuilder.Append($"【基础:{schoolTeacher.name}【{schoolTeacher.id}】,权限:{string.Join(",", schoolTeacher.roles)}】");
  200. noticeDD.Append($"{schoolTeacher.name}【{schoolTeacher.id}】");
  201. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  202. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  203. }
  204. else
  205. {
  206. //不存在 新建教师和新建要管理的学校信息
  207. Teacher addteacher = new()
  208. {
  209. id = tmdIndo.id,
  210. pk = "Base",
  211. code = "Base",
  212. name = $"{tmdIndo.name}",
  213. picture = $"{tmdIndo.picture}",
  214. //创建账号并第一次登录IES5则默认赠送1G
  215. size = 1,
  216. defaultSchool = createSchoolInfo.id,
  217. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  218. schools = new List<Teacher.TeacherSchool>() { new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
  219. };
  220. stringBuilder.Append($"【没有该教师基础信息,创建的教师基本信息:{addteacher.name}【{addteacher.id}】");
  221. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(addteacher, new PartitionKey("Base"));
  222. SchoolTeacher schoolTeacher = new()
  223. {
  224. id = tmdIndo.id,
  225. code = $"Teacher-{createSchoolInfo.id}",
  226. roles = new List<string> { "admin" },
  227. job = "管理员",
  228. name = $"{tmdIndo.name}",
  229. picture = "",
  230. status = "join",
  231. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  232. pk = "Teacher",
  233. ttl = -1
  234. };
  235. stringBuilder.Append($"权限:{string.Join(",", schoolTeacher.roles)}】");
  236. noticeDD.Append($"{schoolTeacher.name}【{schoolTeacher.id}】");
  237. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  238. }
  239. }
  240. }
  241. }
  242. #endregion
  243. #region 旧版先检测 在创建
  244. //foreach (BISchool bischool in foundSchools.biSchools)
  245. //{
  246. // List<string> scName = new();
  247. // //查询学校名称是否全字段匹配
  248. // await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bischool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  249. // {
  250. // scName.Add(item);
  251. // }
  252. // Area area = null;
  253. // //查询区是否存在
  254. // var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("Base-Area"));
  255. // if (respAreaId.Status == 200)
  256. // {
  257. // using var areaBase = await JsonDocument.ParseAsync(respAreaId.ContentStream);
  258. // area = areaBase.ToObject<Area>();
  259. // }
  260. // bool isSYNCArea = false;
  261. // //查询去是否同步省平台
  262. // var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bischool.areaId}", new PartitionKey("AreaSetting"));
  263. // if (responseSet.Status == 200)
  264. // {
  265. // using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  266. // AreaSetting delSet = fileJson.ToObject<AreaSetting>();
  267. // if (!string.IsNullOrEmpty(delSet.accessConfig))
  268. // isSYNCArea = true;
  269. // }
  270. // if (scName.Count <= 0)
  271. // {
  272. // if (isSYNCArea == false)
  273. // {
  274. // var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{bischool.admin}" } }, _option.Location, _configuration);
  275. // if (coreUser != null && coreUser.id != null)
  276. // {
  277. // CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
  278. // {
  279. // province = bischool.province,
  280. // id = "",
  281. // name = bischool.name,
  282. // city = bischool.city,
  283. // aname = "",
  284. // createCount = 0,
  285. // };
  286. // //生成学校ID
  287. // bool tempStaus = true;
  288. // do
  289. // {
  290. // createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
  291. // var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
  292. // if (schoolStatu.Status != 200) tempStaus = false;
  293. // else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
  294. // } while (tempStaus);
  295. // if (createSchoolInfo.id != null)
  296. // {
  297. // string campusId = Guid.NewGuid().ToString();
  298. // School upSchool = new()
  299. // {
  300. // id = createSchoolInfo.id,
  301. // name = bischool.name,
  302. // size = bischool.size == 0 ? 100 : bischool.size,
  303. // code = "Base",
  304. // campuses = new List<Campus> { new Campus { name = bischool.name, id = campusId } },
  305. // region = bischool.region,
  306. // province = bischool.province,
  307. // city = bischool.city,
  308. // dist = bischool.dist,
  309. // address = bischool.address,
  310. // picture = "https://teammodelstorage.blob.core.chinacloudapi.cn/0-public/school/bbf54fb3-3fc8-43ae-a358-107281c174cc.png",
  311. // timeZone = new TEAMModelOS.SDK.Models.TimeZone { label = "(UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐", value = "+08:00" },
  312. // type = string.IsNullOrEmpty(bischool.type.ToString()) ? 1 : bischool.type,
  313. // pk = "School",
  314. // ttl = -1,
  315. // areaId = area == null ? "" : area.id,
  316. // standard = area == null ? "" : area.standard,
  317. // schoolCode = createSchoolInfo.id,
  318. // period = PresetSchoolPeriod(bischool.period, foundSchools.lang, campusId),
  319. // scale = bischool.size >= 300 ? 500 : 0,
  320. // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  321. // };
  322. // stringBuilder.Append($"创建学校:{upSchool.name}【{upSchool.id}】");
  323. // noticeDD.Append($"【ID:{upSchool.id}|名称:{upSchool.name}】 ");
  324. // upSc.Add(upSchool.id);
  325. // //创建学校
  326. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<School>(upSchool, new PartitionKey(upSchool.code));
  327. // //创建学校管理员
  328. // Teacher teacher = null;
  329. // var resTeache = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync($"{coreUser.id}", new PartitionKey("Base"));
  330. // if (resTeache.Status == 200)
  331. // {
  332. // using var tchJson = await JsonDocument.ParseAsync(resTeache.ContentStream);
  333. // teacher = tchJson.ToObject<Teacher>();
  334. // //教师存在,在该教师信息中添加要管理的学校信息
  335. // teacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(bischool.areaId) ? "" : bischool.areaId, schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
  336. // //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, coreUser.id, new PartitionKey("Base"));
  337. // SchoolTeacher schoolTeacher = new()
  338. // {
  339. // id = coreUser.id,
  340. // code = $"Teacher-{createSchoolInfo.id}",
  341. // roles = new List<string> { "admin", "teacher" },
  342. // job = "管理员",
  343. // name = teacher.name,
  344. // picture = teacher.picture,
  345. // status = "join",
  346. // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  347. // pk = "Teacher",
  348. // ttl = -1
  349. // };
  350. // stringBuilder.Append($"教师信息:{schoolTeacher.name}【{schoolTeacher.id}】,教师权限:{string.Join(",", schoolTeacher.roles)}");
  351. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  352. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  353. // }
  354. // else
  355. // {
  356. // //不存在 新建教师和新建要管理的学校信息
  357. // Teacher addteacher = new()
  358. // {
  359. // id = coreUser.id,
  360. // pk = "Base",
  361. // code = "Base",
  362. // name = $"{coreUser.name}",
  363. // picture = $"{coreUser.picture}",
  364. // //创建账号并第一次登录IES5则默认赠送1G
  365. // size = 1,
  366. // defaultSchool = createSchoolInfo.id,
  367. // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  368. // schools = new List<Teacher.TeacherSchool>() { new Teacher.TeacherSchool { schoolId = createSchoolInfo.id, name = bischool.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }
  369. // };
  370. // stringBuilder.Append($"没有该教师信息创建的教师信息:{addteacher.name}【{addteacher.id}】");
  371. // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(addteacher, new PartitionKey("Base"));
  372. // SchoolTeacher schoolTeacher = new()
  373. // {
  374. // id = coreUser.id,
  375. // code = $"Teacher-{createSchoolInfo.id}",
  376. // roles = new List<string> { "admin", "teacher" },
  377. // job = "管理员",
  378. // name = $"{coreUser.name}",
  379. // picture = "",
  380. // status = "join",
  381. // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  382. // pk = "Teacher",
  383. // ttl = -1
  384. // };
  385. // stringBuilder.Append($"教师权限:{string.Join(",", schoolTeacher.roles)}");
  386. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
  387. // }
  388. // }
  389. // }
  390. // else userScs.Add(bischool);
  391. // }
  392. // else cutArea.Add(bischool);
  393. // }
  394. // else schools.Add(bischool);
  395. //}
  396. #endregion
  397. }
  398. else return Ok(new { state = 1, message = "创校信息为空" });
  399. if (upSc.Count > 1)
  400. await _dingDing.SendBotMsg($"BI,{_option.Location} \n 批量建校信息:{noticeDD}", GroupNames.成都开发測試群組);
  401. else if(upSc.Count == 1)
  402. await _dingDing.SendBotMsg($"BI,{_option.Location} \n 单个建校信息:{noticeDD}", GroupNames.成都开发測試群組);
  403. //保存操作记录
  404. await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "school-batchAdd", stringBuilder?.ToString(), _dingDing, httpContext: HttpContext);
  405. if (schools.Count == foundSchools.biSchools.Count || userScs.Count == foundSchools.biSchools.Count)
  406. return Ok(new { state = RespondCode.CreateFailed, message = "已有部分学校批量创建成功;学校已经重复/学校信息有误!请检查学校信息!", schools, userScs });
  407. else
  408. {
  409. if (schools.Count > 0 || userScs.Count > 0 || cutArea.Count > 0)
  410. return Ok(new { state = RespondCode.Created, message = "已有部分学校批量创建成功;学校已经重复/学校信息有误/区域已在研修不能加区!请检查学校信息!", schools, userScs, cutArea });
  411. else
  412. return Ok(new { state = RespondCode.Ok, message = "批量创校已全部完成" });
  413. }
  414. }
  415. catch (Exception ex)
  416. {
  417. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/batch-school \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  418. return BadRequest();
  419. }
  420. }
  421. /// <summary>
  422. /// 依据学校编号查询学校信息;若是没有传学校编号,则查询所有学校信息 //已对接
  423. /// </summary>
  424. /// <param name="jsonElement"></param>
  425. /// <returns></returns>
  426. [ProducesDefaultResponseType]
  427. [HttpPost("get-schoolsinfo")]
  428. public async Task<IActionResult> GetSchoolsInfo(JsonElement jsonElement)
  429. {
  430. try
  431. {
  432. jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
  433. jsonElement.TryGetProperty("scId", out JsonElement scId);
  434. jsonElement.TryGetProperty("name", out JsonElement name);
  435. jsonElement.TryGetProperty("order", out JsonElement order);
  436. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  437. var cosmosClient = _azureCosmos.GetCosmosClient();
  438. ////分开部署,就不需要,一站多用时,取消注释
  439. //if ($"{site}".Equals(BIConst.Global))
  440. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  441. int scCnt = 0;
  442. int? pageSize = 100; //默认不指定返回大小
  443. string continuationToken = string.Empty; //返给前端分页token
  444. string pageToken = default;//接受前端的分页Tolen
  445. bool iscontinuation = false;//是否需要进行分页查询,默认不分页
  446. List<AssistSchool> schoolAssists = new(); //返回学校列表集合
  447. List<string> schoolIds = new();
  448. StringBuilder stringBuilder = new("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c ");
  449. scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c", "Base");
  450. if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
  451. {
  452. if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
  453. {
  454. pageSize = tempPageSize;
  455. }
  456. }
  457. if (pageSize != null && pageSize.Value > 0)
  458. {
  459. iscontinuation = true;
  460. }
  461. if (jsonElement.TryGetProperty("contToken", out JsonElement ContToken))
  462. {
  463. pageToken = ContToken.GetString();
  464. }
  465. if (!string.IsNullOrEmpty($"{tmdId}"))
  466. {
  467. schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
  468. }
  469. if (schoolIds.Count > 0)
  470. {
  471. foreach (var id in schoolIds)
  472. {
  473. StringBuilder sqlTxt = new($"select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c where c.id='{id}'");
  474. if ($"{order}".Equals("desc"))
  475. {
  476. sqlTxt.Append(" order by c.createTime desc");
  477. }
  478. await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<AssistSchool>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  479. {
  480. schoolAssists.Add(itemSchool);
  481. }
  482. }
  483. }
  484. else
  485. {
  486. if (!string.IsNullOrEmpty($"{scId}") && string.IsNullOrEmpty($"{name}"))
  487. {
  488. stringBuilder.Append($" where c.id='{scId}'");
  489. }
  490. if (string.IsNullOrEmpty($"{scId}") && !string.IsNullOrEmpty($"{name}"))
  491. {
  492. stringBuilder.Append($" where Contains(c.name,'{name}')");
  493. }
  494. if ($"{order}".Equals("desc"))
  495. {
  496. stringBuilder.Append(" order by c.createTime desc");
  497. }
  498. await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
  499. {
  500. using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);
  501. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
  502. {
  503. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  504. {
  505. schoolAssists.Add(obj.ToObject<AssistSchool>());
  506. }
  507. if (iscontinuation)
  508. {
  509. continuationToken = itemSchool.GetContinuationToken();
  510. break;
  511. }
  512. }
  513. }
  514. }
  515. foreach (var item in schoolAssists)
  516. {
  517. var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(item.id, new PartitionKey("ProductSum"));
  518. if (response.Status == 200)
  519. {
  520. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  521. if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
  522. {
  523. item.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  524. }
  525. if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
  526. {
  527. item.service = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  528. }
  529. if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
  530. {
  531. item.hard = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
  532. }
  533. }
  534. item.assists = await CommonFind.FindSchoolRoles(cosmosClient, item.id, "assist");
  535. item.lessonCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c ", $"LessonRecord-{item.id}");
  536. }
  537. //schoolAssists.ForEach(async school =>
  538. //{
  539. // var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
  540. // if (response.Status == 200)
  541. // {
  542. // using var json = await JsonDocument.ParseAsync(response.ContentStream);
  543. // if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
  544. // {
  545. // school.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  546. // }
  547. // if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
  548. // {
  549. // school.service = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  550. // }
  551. // if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
  552. // {
  553. // school.hard = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
  554. // }
  555. // }
  556. // school.assists = await CommonFind.FindSchoolRoles(cosmosClient, school.id, "assist");
  557. // school.lessonCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c ", $"LessonRecord-{school.id}");
  558. //});
  559. return Ok(new { state = 200, scCnt, continuationToken, schoolAssists });
  560. }
  561. catch (Exception ex)
  562. {
  563. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schoolsinfo \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  564. return BadRequest();
  565. }
  566. }
  567. /// <summary>
  568. /// 使用yieId 关键字 本地效率未测出
  569. /// </summary>
  570. /// <param name="cosmosClient"></param>
  571. /// <param name="schoolAssists"></param>
  572. /// <returns></returns>
  573. private async IAsyncEnumerable<List<AssistSchool>> GetSchools(CosmosClient cosmosClient, List<AssistSchool> schoolAssists)
  574. {
  575. List<AssistSchool> tempSchoolAssists = new();
  576. foreach (var temp in schoolAssists)
  577. {
  578. var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
  579. if (response.Status == 200)
  580. {
  581. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  582. if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
  583. {
  584. temp.serial = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  585. }
  586. if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
  587. {
  588. temp.service = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
  589. }
  590. if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
  591. {
  592. temp.hard = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
  593. }
  594. }
  595. temp.assists = await CommonFind.FindSchoolRoles(cosmosClient, temp.id, "assist");
  596. tempSchoolAssists.Add(temp);
  597. }
  598. yield return tempSchoolAssists;
  599. }
  600. /// <summary>
  601. /// 取得学校所有顾问列表
  602. /// </summary>
  603. /// <returns></returns>
  604. [ProducesDefaultResponseType]
  605. [HttpPost("get-schoolassist")]
  606. public async Task<IActionResult> GetSchoolAssist(JsonElement jsonElement)
  607. {
  608. try
  609. {
  610. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  611. string schoolId = (jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) ? _schoolId.GetString() : string.Empty;
  612. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new();
  613. string managerWhereOption = (!string.IsNullOrWhiteSpace(schoolId)) ? $" AND c.code = 'Teacher-{schoolId}'" : string.Empty;
  614. //查询学校的顾问
  615. string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join'{managerWhereOption}";
  616. var cosmosClient = _azureCosmos.GetCosmosClient();
  617. //if ($"{site}".Equals(BIConst.Global))
  618. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  619. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
  620. {
  621. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  622. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  623. {
  624. string id = obj.GetProperty("id").GetString(); //管理员ID
  625. string name = obj.GetProperty("name").GetString(); //管理员姓名
  626. string tempSchoolId = obj.GetProperty("schoolId").GetString(); //学校ID
  627. Dictionary<string, string> managerDic = new();
  628. managerDic.Add("id", id);
  629. managerDic.Add("name", name);
  630. if (haveSchoolManger.ContainsKey(tempSchoolId))
  631. {
  632. haveSchoolManger[tempSchoolId].Add(managerDic);
  633. }
  634. else
  635. {
  636. List<Dictionary<string, string>> managerList = new List<Dictionary<string, string>>();
  637. managerList.Add(managerDic);
  638. haveSchoolManger.Add(tempSchoolId, managerList);
  639. }
  640. }
  641. }
  642. //管理模组学校
  643. List<string> baseModuleSchoos = new List<string>();
  644. string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
  645. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
  646. {
  647. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  648. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  649. {
  650. string tempSchoolId = obj.GetProperty("id").GetString(); //学校ID
  651. baseModuleSchoos.Add(tempSchoolId);
  652. }
  653. }
  654. //学校信息
  655. List<object> schools = new List<object>();
  656. string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
  657. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  658. {
  659. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  660. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  661. {
  662. dynamic schoolExpando = new ExpandoObject();
  663. schoolExpando.id = obj.GetProperty("id").GetString();
  664. schoolExpando.name = obj.GetProperty("name").GetString();
  665. //schoolExpando.period = obj.GetProperty("period");
  666. schoolExpando.schoolCode = obj.GetProperty("schoolCode").GetString();
  667. schoolExpando.region = obj.GetProperty("region").GetString();
  668. schoolExpando.province = obj.GetProperty("province").GetString();
  669. schoolExpando.city = obj.GetProperty("city").GetString();
  670. schoolExpando.picture = obj.GetProperty("picture").GetString();
  671. if (haveSchoolManger.ContainsKey(schoolExpando.id))
  672. {
  673. schoolExpando.hasMarger = true;
  674. schoolExpando.managers = haveSchoolManger[schoolExpando.id];
  675. }
  676. else
  677. {
  678. schoolExpando.hasMarger = false;
  679. schoolExpando.managers = new List<object>();
  680. }
  681. schoolExpando.hasBaseModule = (baseModuleSchoos.Contains(schoolExpando.id)) ? true : false;
  682. schools.Add(schoolExpando);
  683. }
  684. }
  685. return Ok(new { state = 200, schools });
  686. }
  687. catch (Exception ex)
  688. {
  689. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schools \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  690. return BadRequest();
  691. }
  692. }
  693. /// <summary>
  694. /// 修改学校信息和顾问信息 //已经对接
  695. /// </summary>
  696. /// <param name="jsonElement"></param>
  697. /// <returns></returns>
  698. [ProducesDefaultResponseType]
  699. [AuthToken(Roles = "admin,rdc")]
  700. [HttpPost("upd-schoolassist")]
  701. public async Task<IActionResult> UpdSchoolAssist(JsonElement jsonElement)
  702. {
  703. try
  704. {
  705. if (!jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
  706. if (!jsonElement.TryGetProperty("name", out JsonElement schoolName)) return BadRequest();
  707. if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
  708. if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
  709. //if (!jsonElement.TryGetProperty("period", out JsonElement period)) return BadRequest();
  710. if (!jsonElement.TryGetProperty("picture", out JsonElement picture)) return BadRequest();
  711. if (!jsonElement.TryGetProperty("size", out JsonElement size)) return BadRequest();
  712. if (!jsonElement.TryGetProperty("scale", out JsonElement scale)) return BadRequest();
  713. if (!jsonElement.TryGetProperty("assistId", out JsonElement _assistId)) return BadRequest();
  714. if (!jsonElement.TryGetProperty("type", out JsonElement _type)) return BadRequest();
  715. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  716. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  717. List<string> assistId = _assistId.ToObject<List<string>>();
  718. //List<string> periodS = period.ToObject<List<string>>();
  719. Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new();
  720. var cosmosClient = _azureCosmos.GetCosmosClient();
  721. var tableClient = _azureStorage.GetCloudTableClient();
  722. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
  723. //if ($"{site}".Equals(BIConst.Global))
  724. //{
  725. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  726. // tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
  727. // blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
  728. //}
  729. School tempShool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
  730. if (tempShool != null)
  731. {
  732. List<Period> periods = new();
  733. string campusId = Guid.NewGuid().ToString();
  734. //periodS.ForEach(x =>
  735. //{
  736. // periods.Add(new Period { id = Guid.NewGuid().ToString(), name = x.ToString(), campusId = campusId });
  737. //});
  738. //tempShool.period = periods;
  739. tempShool.size = !string.IsNullOrEmpty($"{size}") ? int.Parse($"{size}") : tempShool.size;
  740. tempShool.scale = !string.IsNullOrEmpty($"{scale}") ? int.Parse($"{scale}") : tempShool.scale;
  741. tempShool.picture = $"{picture}";
  742. tempShool.type = int.Parse($"{_type}");
  743. tempShool.name = $"{schoolName}";
  744. tempShool.areaId = $"{areaId}";
  745. tempShool.standard = $"{standard}";
  746. //修改学校
  747. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempShool, tempShool.id, new PartitionKey("Base"));
  748. //修改学校教师关联的信息
  749. string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
  750. List<Teacher> teachers = new();
  751. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
  752. {
  753. teachers.Add(item);
  754. }
  755. foreach (var item in teachers)
  756. {
  757. Teacher.TeacherSchool teacherSchool = item.schools.Find(x => x.schoolId.Equals(tempShool.id));
  758. if (teacherSchool != null)
  759. {
  760. teacherSchool.name = tempShool.name;
  761. teacherSchool.picture = tempShool.picture;
  762. teacherSchool.areaId = tempShool.areaId;
  763. }
  764. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey($"Base"));
  765. }
  766. if (assistId.Count > 0)
  767. {
  768. //修改学校顾问
  769. string sqlTxt = $"SELECT value(c) From c WHERE ARRAY_CONTAINS(c.roles,'assist',true)";
  770. List<SchoolTeacher> schoolTeachers = new();
  771. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempShool.id}") }))
  772. {
  773. if (!assistId.Contains(item.id))
  774. {
  775. if (item.roles.Contains("assist"))
  776. {
  777. item.roles.Remove("assist");
  778. if (item.roles.Count > 0)
  779. {
  780. await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(item, item.id, new PartitionKey(item.code));
  781. }
  782. else
  783. {
  784. await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
  785. }
  786. }
  787. }
  788. }
  789. foreach (var itemTeacher in assistId)
  790. {
  791. Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{itemTeacher}", new PartitionKey("Base"));
  792. if (tempTeacher != null)
  793. {
  794. var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{_schoolId}"));
  795. if (haveTeacher != null)
  796. {
  797. //查询该教师是否存在该校
  798. SchoolTeacher schoolTeacher = null;
  799. try
  800. {
  801. schoolTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
  802. }
  803. catch
  804. {
  805. }
  806. if (schoolTeacher != null)
  807. {
  808. if (!schoolTeacher.roles.Contains("assist"))
  809. {
  810. schoolTeacher.roles.Add("assist");
  811. //添加顾问权限
  812. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{tempShool.id}"));
  813. }
  814. }
  815. else
  816. {
  817. SchoolTeacher addSchoolTeacher = new()
  818. {
  819. id = itemTeacher,
  820. code = $"Teacher-{tempShool.id}",
  821. pk = "Teacher",
  822. status = "join",
  823. roles = new List<string>() { "assist" },
  824. name = tempTeacher.name,
  825. job = $"{tempShool.name}-顾问",
  826. size = 0,
  827. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  828. };
  829. //添加学校顾问
  830. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  831. }
  832. }
  833. else
  834. {
  835. Teacher.TeacherSchool teacherSchool = new()
  836. {
  837. schoolId = tempShool.id,
  838. name = tempShool.name,
  839. status = "join",
  840. time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  841. picture = tempShool.picture,
  842. areaId = tempShool.areaId
  843. };
  844. tempTeacher.schools.Add(teacherSchool);
  845. //给醍摩豆顾问添加学校
  846. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, tempTeacher.id, new PartitionKey($"Base"));
  847. //不存在则在原来的基础上添加顾问角色
  848. SchoolTeacher addSchoolTeacher = new()
  849. {
  850. id = itemTeacher,
  851. code = $"Teacher-{tempShool.id}",
  852. pk = "Teacher",
  853. status = "join",
  854. roles = new List<string>() { "assist" },
  855. name = tempTeacher.name,
  856. job = $"{tempShool.name}-顾问",
  857. size = 0,
  858. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  859. };
  860. //添加学校学校顾问
  861. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
  862. }
  863. }
  864. }
  865. }
  866. }
  867. //保存操作记录
  868. await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "school-update", $"{_tmdName}【{_tmdId}】修改学校功能,修改的学校:{_schoolId},{_type},{picture},{size},{string.Join("|", assistId.ToArray())}", _dingDing, httpContext: HttpContext);
  869. return Ok(new { state = 200 });
  870. }
  871. catch (Exception ex)
  872. {
  873. await _dingDing.SendBotMsg($"BI, {_option.Location} /batchschool/upd-schoolassist \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  874. return BadRequest();
  875. }
  876. }
  877. /// <summary>
  878. /// 查询区域的学校
  879. /// </summary>
  880. /// <param name="jsonElement"></param>
  881. /// <returns></returns>
  882. [ProducesDefaultResponseType]
  883. [HttpPost("get-schooldist")]
  884. public async Task<IActionResult> GetSchoolDist(JsonElement jsonElement)
  885. {
  886. try
  887. {
  888. if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
  889. //jsonElement.TryGetProperty("site", out JsonElement site); //分开部署,就不需要,一站多用时,取消注释
  890. var cosmosClient = _azureCosmos.GetCosmosClient();
  891. //if ($"{site}".Equals(BIConst.Global))
  892. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  893. string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
  894. List<School> schools = new List<School>();
  895. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  896. {
  897. schools.Add(item);
  898. }
  899. return Ok(new { state = 200, schools });
  900. }
  901. catch (Exception ex)
  902. {
  903. await _dingDing.SendBotMsg($"BI,{_option.Location} /batchschool/get-schooldist \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  904. return BadRequest();
  905. }
  906. }
  907. /// <summary>
  908. /// 分页学校和顾问信息
  909. /// </summary>
  910. /// <param name="jsonElement"></param>
  911. /// <returns></returns>
  912. [ProducesDefaultResponseType]
  913. [HttpPost("get-schools")]
  914. public async Task<IActionResult> GetSchools(JsonElement jsonElement)
  915. {
  916. //List<School> schools = new List<School>();
  917. List<AssistSchool> schoolAssists = new List<AssistSchool>();
  918. if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
  919. if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
  920. //jsonElement.TryGetProperty("site", out JsonElement site); //分开部署,就不需要,一站多用时,取消注释
  921. var cosmosClient = _azureCosmos.GetCosmosClient();
  922. //if ($"{site}".Equals(BIConst.Global))
  923. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  924. string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
  925. await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  926. {
  927. AssistSchool schoolAssist = new()
  928. {
  929. id = itemSchool.id,
  930. code = itemSchool.code,
  931. schoolCode = itemSchool.schoolCode,
  932. name = itemSchool.name,
  933. region = itemSchool.region,
  934. province = itemSchool.province,
  935. city = itemSchool.city,
  936. dist = itemSchool.dist,
  937. size = itemSchool.size,
  938. address = itemSchool.address,
  939. picture = itemSchool.picture,
  940. type = itemSchool.type,
  941. scale = itemSchool.scale,
  942. areaId = itemSchool.areaId,
  943. standard = itemSchool.standard
  944. };
  945. schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, itemSchool.id, "assist");
  946. schoolAssists.Add(schoolAssist);
  947. }
  948. return Ok(new { state = 200, schoolAssists });
  949. }
  950. /// <summary>
  951. /// 创校前检查数据
  952. /// </summary>
  953. /// <param name="jsonElement"></param>
  954. /// <returns></returns>
  955. [ProducesDefaultResponseType]
  956. [HttpPost("get-checlkexist")]
  957. public async Task<IActionResult> GetCheckExist(JsonElement jsonElement)
  958. {
  959. if (!jsonElement.TryGetProperty("scNames", out JsonElement _scNames)) return BadRequest();
  960. if (!jsonElement.TryGetProperty("accounts", out JsonElement _accounts)) return BadRequest();
  961. if (!jsonElement.TryGetProperty("areaIds", out JsonElement _areaIds)) return BadRequest();
  962. var cosmosClient = _azureCosmos.GetCosmosClient();
  963. List<string> scNames = _scNames.ToObject<List<string>>();
  964. List<string> accounts = _accounts.ToObject<List<string>>();
  965. List<string> areaIds = _areaIds.ToObject<List<string>>();
  966. List<string> existScNames = new(); //存在的学校
  967. List<string> noAccounts = new(); // 不存在的账户
  968. List<string> noAreaIds = new(); //不存在的学区
  969. List<string> synPro = new(); //已同步省平台
  970. if (scNames.Count > 0)
  971. {
  972. foreach (var item in scNames)
  973. {
  974. //查询学校名称是否全字段匹配
  975. await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{item}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  976. {
  977. existScNames.Add(item);
  978. }
  979. }
  980. }
  981. if (accounts.Count > 0)
  982. {
  983. var content = new StringContent(_accounts.ToString(), Encoding.UTF8, "application/json");
  984. string json = await _coreAPIHttpService.GetUserInfos(content);
  985. List<TmdUserinfo> tmdInfos = json.ToObject<List<TmdUserinfo>>();
  986. accounts.ForEach(ac =>
  987. {
  988. var noTmdInfo = tmdInfos.Find(f => f.id.Equals($"{ac}") || f.mail.Equals($"{ac}") || f.mobile.Equals($"{ac}"));
  989. if (noTmdInfo == null)
  990. noAccounts.Add(ac);
  991. });
  992. }
  993. if (areaIds.Count > 0)
  994. {
  995. foreach (var item in areaIds)
  996. {
  997. //查询区是否存在
  998. var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("Base-Area"));
  999. if (respAreaId.Status != 200)
  1000. {
  1001. noAreaIds.Add(item);
  1002. }
  1003. //查询去是否同步省平台
  1004. var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("AreaSetting"));
  1005. if (responseSet.Status == 200)
  1006. {
  1007. using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  1008. AreaSetting delSet = fileJson.ToObject<AreaSetting>();
  1009. if (!string.IsNullOrEmpty(delSet.accessConfig))
  1010. synPro.Add(item);
  1011. }
  1012. }
  1013. }
  1014. if (existScNames.Count > 0 || noAccounts.Count > 0 || noAreaIds.Count > 0 || synPro.Count > 0)
  1015. return Ok(new { state = RespondCode.Created, existScNames, noAccounts, noAreaIds, synPro });
  1016. else
  1017. return Ok(new { state = RespondCode.Ok });
  1018. }
  1019. /// <summary>
  1020. /// 添加多个学校添加多个管理员
  1021. /// </summary>
  1022. /// <param name="jsonElement"></param>
  1023. /// <returns></returns>
  1024. [HttpPost("set-batchmanage")]
  1025. public async Task<IActionResult> SetBatchManage(JsonElement jsonElement)
  1026. {
  1027. if (!jsonElement.TryGetProperty("scIds", out JsonElement _scIds)) return BadRequest();
  1028. if (!jsonElement.TryGetProperty("manages", out JsonElement _manages)) return BadRequest();
  1029. var cosmosClient = _azureCosmos.GetCosmosClient();
  1030. List<string> scIds= _scIds.ToObject<List<string>>();
  1031. List<string> manages = _manages.ToObject<List<string>>();
  1032. List<ExistScManage> existScManages = new();
  1033. if (scIds.Count > 0 && manages.Count > 0)
  1034. {
  1035. foreach (var scId in scIds)
  1036. {
  1037. foreach (var msId in manages)
  1038. {
  1039. //不存在则在原来的基础上添加顾问角色
  1040. Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{msId}", new PartitionKey("Base"));
  1041. if (tempTeacher != null)
  1042. {
  1043. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{msId}", new PartitionKey($"Teacher-{scId}"));
  1044. if (response.Status == 200)
  1045. {
  1046. using var tchJson = await JsonDocument.ParseAsync(response.ContentStream);
  1047. SchoolTeacher tchSc = tchJson.ToObject<SchoolTeacher>();
  1048. if (tchSc.roles.Contains("admin"))
  1049. {
  1050. tchSc.roles.Add("admin");
  1051. //添加顾问权限
  1052. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(tchSc, tchSc.id, new PartitionKey($"Teacher-{scId}"));
  1053. }
  1054. else
  1055. existScManages.Add(new ExistScManage() { scId = scId, tmdId = msId });
  1056. }
  1057. else
  1058. {
  1059. SchoolTeacher addSchoolTeacher = new()
  1060. {
  1061. id = tempTeacher.id,
  1062. code = $"Teacher-{scId}",
  1063. pk = "Teacher",
  1064. status = "join",
  1065. roles = new List<string>() { "admin" },
  1066. name = tempTeacher.name,
  1067. job = $"管理员",
  1068. size = 0,
  1069. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1070. };
  1071. var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{scId}"));
  1072. if (haveTeacher == null)
  1073. {
  1074. School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(scId, new PartitionKey("Base"));
  1075. //教师存在,在该教师信息中添加要管理的学校信息
  1076. tempTeacher.schools.Add(new Teacher.TeacherSchool { areaId = string.IsNullOrEmpty(school.areaId) ? "" : school.areaId, schoolId = school.id, name = school.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() });
  1077. tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, msId, new PartitionKey("Base"));
  1078. }
  1079. //添加学校学校顾问
  1080. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{scId}"));
  1081. }
  1082. }
  1083. else
  1084. {
  1085. CoreUser coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{msId}" } }, _option.Location, _configuration);
  1086. Teacher teacher = new() { id = coreUser.id, name = coreUser.name, picture = coreUser.picture, pk = "Base", code = "Base", size = 1, createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() };
  1087. var responseSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
  1088. if (responseSc.Status == 200)
  1089. {
  1090. using var tchJson = await JsonDocument.ParseAsync(responseSc.ContentStream);
  1091. School scInfo = tchJson.ToObject<School>();
  1092. teacher.schools.Add(new() { schoolId = scInfo.id, name = scInfo.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = scInfo.picture, areaId = scInfo.areaId });
  1093. }
  1094. teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
  1095. SchoolTeacher addSchoolTeacher = new()
  1096. {
  1097. id = coreUser.id,
  1098. code = $"Teacher-{scId}",
  1099. pk = "Teacher",
  1100. status = "join",
  1101. roles = new List<string>() { "admin" },
  1102. name = coreUser.name,
  1103. job = $"管理员",
  1104. size = 0,
  1105. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1106. };
  1107. //添加学校学校顾问
  1108. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{scId}"));
  1109. }
  1110. }
  1111. }
  1112. }
  1113. if (existScManages.Count > 0)
  1114. return Ok(new { state = RespondCode.Created, existScManages });
  1115. else
  1116. return Ok(new { state = RespondCode.Ok });
  1117. }
  1118. #region 预设学校基础信息 多语言
  1119. /// <summary>
  1120. /// 预设学校基础信息 多语言
  1121. /// </summary>
  1122. /// <param name="period"></param>
  1123. /// <param name="Language"></param>
  1124. /// <param name="campusId"></param>
  1125. /// <returns></returns>
  1126. public List<Period> PresetSchoolPeriod(List<string> period, string Language, string campusId)
  1127. {
  1128. var builder = $"{_environment.ContentRootPath}/JsonFile/Preset/LangSchoolConfig.json";
  1129. StreamReader streamReader = new(new FileStream(builder, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
  1130. StringBuilder stringBuilder = new();
  1131. string text;
  1132. while ((text = streamReader.ReadLine()) != null)
  1133. {
  1134. stringBuilder.Append(text.ToString());
  1135. }
  1136. streamReader.Close();
  1137. string input = stringBuilder.ToString();
  1138. List<SchoolConfig> schoolConfigs = input.ToObject<List<SchoolConfig>>();
  1139. SchoolConfig schoolConfig = schoolConfigs.Find(x => x.Lang.Contains($"{Language}"));
  1140. if (schoolConfig == null)
  1141. {
  1142. if (Language.Contains("en"))
  1143. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("en-US"));
  1144. else
  1145. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("zh-CN"));
  1146. }
  1147. List<Period> periods = new();
  1148. period.ForEach(x =>
  1149. {
  1150. periods.Add(new Period
  1151. {
  1152. id = Guid.NewGuid().ToString(),
  1153. name = x,
  1154. campusId = campusId,
  1155. semesters = new List<Semester>() { new Semester { name = schoolConfig.semester[0].term, start = schoolConfig.semester[0].start, month = schoolConfig.semester[0].month, day = schoolConfig.semester[0].day, id = Guid.NewGuid().ToString() },
  1156. new Semester { name = schoolConfig.semester[1].term, start = schoolConfig.semester[1].start, month = schoolConfig.semester[1].month, day = schoolConfig.semester[1].day, id = Guid.NewGuid().ToString() } },
  1157. subjects = new List<Subject>() {
  1158. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[0].name,type=schoolConfig.PresetSubject[0].type },
  1159. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[1].name,type=schoolConfig.PresetSubject[1].type },
  1160. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[2].name,type=schoolConfig.PresetSubject[2].type }
  1161. },
  1162. grades = schoolConfig.grades,
  1163. analysis = new Analysis()
  1164. {
  1165. type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
  1166. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[1].name },
  1167. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[2].name },
  1168. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[3].name } },
  1169. income = schoolConfig.PresetExam[0].income,
  1170. eugenics = schoolConfig.PresetExam[0].eugenics,
  1171. touch = schoolConfig.PresetExam[0].touch
  1172. }
  1173. });
  1174. });
  1175. return periods;
  1176. }
  1177. public record SchoolConfig
  1178. {
  1179. public string Lang { get; set; }
  1180. public List<semester> semester { get; set; }
  1181. public List<string> grades { get; set; }
  1182. public List<PresetSubject> PresetSubject { get; set; }
  1183. public List<PresetExam> PresetExam { get; set; }
  1184. }
  1185. public record semester
  1186. {
  1187. public string id { get; set; } = Guid.NewGuid().ToString();
  1188. public string term { get; set; }
  1189. public int start { get; set; }
  1190. public int month { get; set; }
  1191. public int day { get; set; }
  1192. }
  1193. public record PresetSubject
  1194. {
  1195. public string id { get; set; } = Guid.NewGuid().ToString();
  1196. public string name { get; set; }
  1197. public int type { get; set; }
  1198. }
  1199. public record PresetExam
  1200. {
  1201. public List<StudyType> type { get; set; }
  1202. public int income { get; set; }
  1203. public int eugenics { get; set; }
  1204. public int touch { get; set; }
  1205. }
  1206. public record StudyType
  1207. {
  1208. public string id { get; set; } = Guid.NewGuid().ToString();
  1209. public string name { get; set; }
  1210. }
  1211. #endregion
  1212. //public class SchoolAssist
  1213. //{
  1214. // public string id { get; set; }
  1215. // public string code { get; set; }
  1216. // public string schoolCode { get; set; }
  1217. // public string name { get; set; }
  1218. // public string region { get; set; }
  1219. // public string province { get; set; }
  1220. // public string city { get; set; }
  1221. // public string dist { get; set; }
  1222. // public int size { get; set; }
  1223. // public string address { get; set; }
  1224. // public string picture { get; set; }
  1225. // public int type { get; set; }
  1226. // public int scale { get; set; }
  1227. // public string standard { get; set; }
  1228. // public string areaId { get; set; }
  1229. // public List<SchoolTeacherRoles> assists { get; set; }
  1230. // public int serial { get; set; } //软体
  1231. // public int service { get; set; } //服务
  1232. // public int hard { get; set; } //硬体
  1233. // //public List<SchoolProductSumData> serial { get; set; } //软体
  1234. // //public List<SchoolProductSumData> service { get; set; } //服务
  1235. // //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
  1236. //}
  1237. /// <summary>
  1238. /// 创建多个学校实体
  1239. /// </summary>
  1240. public record FoundSchools()
  1241. {
  1242. /// <summary>
  1243. /// 语系
  1244. /// </summary>
  1245. public string lang { get; set; }
  1246. /// <summary>
  1247. /// 站点
  1248. /// </summary>
  1249. public string site { get; set; }
  1250. /// <summary>
  1251. /// 批量创校的数据结构
  1252. /// </summary>
  1253. public List<BISchool> biSchools { get; set; } = new List<BISchool>();
  1254. }
  1255. /// <summary>
  1256. /// 批量创校的数据结构
  1257. /// </summary>
  1258. public record BISchool()
  1259. {
  1260. /// <summary>
  1261. /// 学校名称
  1262. /// </summary>
  1263. public string name { get; set; }
  1264. /// <summary>
  1265. /// 学校管理员
  1266. /// </summary>
  1267. public List<string> admin { get; set; }
  1268. /// <summary>
  1269. /// 学校的学段
  1270. /// </summary>
  1271. public List<string> period { get; set; }
  1272. /// <summary>
  1273. /// 学校空间大小
  1274. /// </summary>
  1275. public int size { get; set; }
  1276. /// <summary>
  1277. /// 地区
  1278. /// </summary>
  1279. public string region { get; set; }
  1280. /// <summary>
  1281. /// 省份
  1282. /// </summary>
  1283. public string province { get; set; }
  1284. /// <summary>
  1285. /// 城市
  1286. /// </summary>
  1287. public string city { get; set; }
  1288. /// <summary>
  1289. /// 县,区,郡
  1290. /// </summary>
  1291. public string dist { get; set; }
  1292. /// <summary>
  1293. /// 学校详细地址
  1294. /// </summary>
  1295. public string address { get; set; }
  1296. /// <summary>
  1297. /// 学校类型
  1298. /// </summary>
  1299. public int type { get; set; }
  1300. /// <summary>
  1301. /// 区域ID
  1302. /// </summary>
  1303. public string areaId { get; set; }
  1304. /// <summary>
  1305. /// 区域标准
  1306. /// </summary>
  1307. public string standard { get; set; }
  1308. }
  1309. public record ExistScManage
  1310. {
  1311. public string scId{ get; set; }
  1312. public string tmdId { get; set; }
  1313. }
  1314. }
  1315. }