BatchSchoolController.cs 103 KB

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