BatchSchoolController.cs 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  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. TmdUserinfo noTmdInfo = null;
  989. tmdInfos.ForEach(tmd =>
  990. {
  991. if (!string.IsNullOrEmpty(tmd.id))
  992. if (tmd.id.Equals($"{ac}"))
  993. noTmdInfo = tmd;
  994. if (!string.IsNullOrEmpty(tmd.mobile))
  995. if (tmd.mobile.Equals($"{ac}"))
  996. noTmdInfo = tmd;
  997. if (!string.IsNullOrEmpty(tmd.mail))
  998. if (tmd.mail.Equals($"{ac}"))
  999. noTmdInfo = tmd;
  1000. });
  1001. //noTmdInfo = tmdInfos.Find(f => f.id.Equals($"{ac}") || f.mail.Equals($"{ac}") || f.mobile.Equals($"{ac}"));
  1002. if (noTmdInfo == null)
  1003. noAccounts.Add(ac);
  1004. });
  1005. }
  1006. if (areaIds.Count > 0)
  1007. {
  1008. foreach (var item in areaIds)
  1009. {
  1010. //查询区是否存在
  1011. var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("Base-Area"));
  1012. if (respAreaId.Status != 200)
  1013. {
  1014. noAreaIds.Add(item);
  1015. }
  1016. //查询去是否同步省平台
  1017. var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{item}", new PartitionKey("AreaSetting"));
  1018. if (responseSet.Status == 200)
  1019. {
  1020. using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  1021. AreaSetting delSet = fileJson.ToObject<AreaSetting>();
  1022. if (!string.IsNullOrEmpty(delSet.accessConfig))
  1023. synPro.Add(item);
  1024. }
  1025. }
  1026. }
  1027. if (existScNames.Count > 0 || noAccounts.Count > 0 || noAreaIds.Count > 0 || synPro.Count > 0)
  1028. return Ok(new { state = RespondCode.Created, existScNames, noAccounts, noAreaIds, synPro });
  1029. else
  1030. return Ok(new { state = RespondCode.Ok });
  1031. }
  1032. /// <summary>
  1033. /// 添加多个学校添加多个管理员
  1034. /// </summary>
  1035. /// <param name="jsonElement"></param>
  1036. /// <returns></returns>
  1037. [HttpPost("set-batchmanage")]
  1038. public async Task<IActionResult> SetBatchManage(JsonElement jsonElement)
  1039. {
  1040. if (!jsonElement.TryGetProperty("scIds", out JsonElement _scIds)) return BadRequest();
  1041. if (!jsonElement.TryGetProperty("manages", out JsonElement _manages)) return BadRequest();
  1042. var cosmosClient = _azureCosmos.GetCosmosClient();
  1043. List<string> scIds= _scIds.ToObject<List<string>>();
  1044. List<string> manages = _manages.ToObject<List<string>>();
  1045. List<ExistScManage> existScManages = new();
  1046. if (scIds.Count > 0 && manages.Count > 0)
  1047. {
  1048. foreach (var scId in scIds)
  1049. {
  1050. foreach (var msId in manages)
  1051. {
  1052. //不存在则在原来的基础上添加顾问角色
  1053. Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{msId}", new PartitionKey("Base"));
  1054. if (tempTeacher != null)
  1055. {
  1056. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{msId}", new PartitionKey($"Teacher-{scId}"));
  1057. if (response.Status == 200)
  1058. {
  1059. using var tchJson = await JsonDocument.ParseAsync(response.ContentStream);
  1060. SchoolTeacher tchSc = tchJson.ToObject<SchoolTeacher>();
  1061. if (tchSc.roles.Contains("admin"))
  1062. {
  1063. tchSc.roles.Add("admin");
  1064. //添加顾问权限
  1065. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(tchSc, tchSc.id, new PartitionKey($"Teacher-{scId}"));
  1066. }
  1067. else
  1068. existScManages.Add(new ExistScManage() { scId = scId, tmdId = msId });
  1069. }
  1070. else
  1071. {
  1072. SchoolTeacher addSchoolTeacher = new()
  1073. {
  1074. id = tempTeacher.id,
  1075. code = $"Teacher-{scId}",
  1076. pk = "Teacher",
  1077. status = "join",
  1078. roles = new List<string>() { "admin" },
  1079. name = tempTeacher.name,
  1080. job = $"管理员",
  1081. size = 0,
  1082. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1083. };
  1084. var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{scId}"));
  1085. if (haveTeacher == null)
  1086. {
  1087. School school = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(scId, new PartitionKey("Base"));
  1088. //教师存在,在该教师信息中添加要管理的学校信息
  1089. 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() });
  1090. tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, msId, new PartitionKey("Base"));
  1091. }
  1092. //添加学校学校顾问
  1093. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{scId}"));
  1094. }
  1095. }
  1096. else
  1097. {
  1098. CoreUser coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{msId}" } }, _option.Location, _configuration);
  1099. Teacher teacher = new() { id = coreUser.id, name = coreUser.name, picture = coreUser.picture, pk = "Base", code = "Base", size = 1, createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() };
  1100. var responseSc = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scId, new PartitionKey("Base"));
  1101. if (responseSc.Status == 200)
  1102. {
  1103. using var tchJson = await JsonDocument.ParseAsync(responseSc.ContentStream);
  1104. School scInfo = tchJson.ToObject<School>();
  1105. teacher.schools.Add(new() { schoolId = scInfo.id, name = scInfo.name, status = "join", time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), picture = scInfo.picture, areaId = scInfo.areaId });
  1106. }
  1107. teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
  1108. SchoolTeacher addSchoolTeacher = new()
  1109. {
  1110. id = coreUser.id,
  1111. code = $"Teacher-{scId}",
  1112. pk = "Teacher",
  1113. status = "join",
  1114. roles = new List<string>() { "admin" },
  1115. name = coreUser.name,
  1116. job = $"管理员",
  1117. size = 0,
  1118. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1119. };
  1120. //添加学校学校顾问
  1121. await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{scId}"));
  1122. }
  1123. }
  1124. }
  1125. }
  1126. if (existScManages.Count > 0)
  1127. return Ok(new { state = RespondCode.Created, existScManages });
  1128. else
  1129. return Ok(new { state = RespondCode.Ok });
  1130. }
  1131. #region 预设学校基础信息 多语言
  1132. /// <summary>
  1133. /// 预设学校基础信息 多语言
  1134. /// </summary>
  1135. /// <param name="period"></param>
  1136. /// <param name="Language"></param>
  1137. /// <param name="campusId"></param>
  1138. /// <returns></returns>
  1139. public List<Period> PresetSchoolPeriod(List<string> period, string Language, string campusId)
  1140. {
  1141. var builder = $"{_environment.ContentRootPath}/JsonFile/Preset/LangSchoolConfig.json";
  1142. StreamReader streamReader = new(new FileStream(builder, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
  1143. StringBuilder stringBuilder = new();
  1144. string text;
  1145. while ((text = streamReader.ReadLine()) != null)
  1146. {
  1147. stringBuilder.Append(text.ToString());
  1148. }
  1149. streamReader.Close();
  1150. string input = stringBuilder.ToString();
  1151. List<SchoolConfig> schoolConfigs = input.ToObject<List<SchoolConfig>>();
  1152. SchoolConfig schoolConfig = schoolConfigs.Find(x => x.Lang.Contains($"{Language}"));
  1153. if (schoolConfig == null)
  1154. {
  1155. if (Language.Contains("en"))
  1156. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("en-US"));
  1157. else
  1158. schoolConfig = schoolConfigs.Find(x => x.Lang.Contains("zh-CN"));
  1159. }
  1160. List<Period> periods = new();
  1161. period.ForEach(x =>
  1162. {
  1163. periods.Add(new Period
  1164. {
  1165. id = Guid.NewGuid().ToString(),
  1166. name = x,
  1167. campusId = campusId,
  1168. 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() },
  1169. 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() } },
  1170. subjects = new List<Subject>() {
  1171. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[0].name,type=schoolConfig.PresetSubject[0].type },
  1172. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[1].name,type=schoolConfig.PresetSubject[1].type },
  1173. new Subject { id=Guid.NewGuid().ToString(),name=schoolConfig.PresetSubject[2].name,type=schoolConfig.PresetSubject[2].type }
  1174. },
  1175. grades = schoolConfig.grades,
  1176. analysis = new Analysis()
  1177. {
  1178. type = new List<ExamSimple>() { new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[0].name },
  1179. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[1].name },
  1180. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[2].name },
  1181. new ExamSimple { id = Guid.NewGuid().ToString(), name = schoolConfig.PresetExam[0].type[3].name } },
  1182. income = schoolConfig.PresetExam[0].income,
  1183. eugenics = schoolConfig.PresetExam[0].eugenics,
  1184. touch = schoolConfig.PresetExam[0].touch
  1185. }
  1186. });
  1187. });
  1188. return periods;
  1189. }
  1190. public record SchoolConfig
  1191. {
  1192. public string Lang { get; set; }
  1193. public List<semester> semester { get; set; }
  1194. public List<string> grades { get; set; }
  1195. public List<PresetSubject> PresetSubject { get; set; }
  1196. public List<PresetExam> PresetExam { get; set; }
  1197. }
  1198. public record semester
  1199. {
  1200. public string id { get; set; } = Guid.NewGuid().ToString();
  1201. public string term { get; set; }
  1202. public int start { get; set; }
  1203. public int month { get; set; }
  1204. public int day { get; set; }
  1205. }
  1206. public record PresetSubject
  1207. {
  1208. public string id { get; set; } = Guid.NewGuid().ToString();
  1209. public string name { get; set; }
  1210. public int type { get; set; }
  1211. }
  1212. public record PresetExam
  1213. {
  1214. public List<StudyType> type { get; set; }
  1215. public int income { get; set; }
  1216. public int eugenics { get; set; }
  1217. public int touch { get; set; }
  1218. }
  1219. public record StudyType
  1220. {
  1221. public string id { get; set; } = Guid.NewGuid().ToString();
  1222. public string name { get; set; }
  1223. }
  1224. #endregion
  1225. //public class SchoolAssist
  1226. //{
  1227. // public string id { get; set; }
  1228. // public string code { get; set; }
  1229. // public string schoolCode { get; set; }
  1230. // public string name { get; set; }
  1231. // public string region { get; set; }
  1232. // public string province { get; set; }
  1233. // public string city { get; set; }
  1234. // public string dist { get; set; }
  1235. // public int size { get; set; }
  1236. // public string address { get; set; }
  1237. // public string picture { get; set; }
  1238. // public int type { get; set; }
  1239. // public int scale { get; set; }
  1240. // public string standard { get; set; }
  1241. // public string areaId { get; set; }
  1242. // public List<SchoolTeacherRoles> assists { get; set; }
  1243. // public int serial { get; set; } //软体
  1244. // public int service { get; set; } //服务
  1245. // public int hard { get; set; } //硬体
  1246. // //public List<SchoolProductSumData> serial { get; set; } //软体
  1247. // //public List<SchoolProductSumData> service { get; set; } //服务
  1248. // //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
  1249. //}
  1250. /// <summary>
  1251. /// 创建多个学校实体
  1252. /// </summary>
  1253. public record FoundSchools()
  1254. {
  1255. /// <summary>
  1256. /// 语系
  1257. /// </summary>
  1258. public string lang { get; set; }
  1259. /// <summary>
  1260. /// 站点
  1261. /// </summary>
  1262. public string site { get; set; }
  1263. /// <summary>
  1264. /// 批量创校的数据结构
  1265. /// </summary>
  1266. public List<BISchool> biSchools { get; set; } = new List<BISchool>();
  1267. }
  1268. /// <summary>
  1269. /// 批量创校的数据结构
  1270. /// </summary>
  1271. public record BISchool()
  1272. {
  1273. /// <summary>
  1274. /// 学校名称
  1275. /// </summary>
  1276. public string name { get; set; }
  1277. /// <summary>
  1278. /// 学校管理员
  1279. /// </summary>
  1280. public List<string> admin { get; set; }
  1281. /// <summary>
  1282. /// 学校的学段
  1283. /// </summary>
  1284. public List<string> period { get; set; }
  1285. /// <summary>
  1286. /// 学校空间大小
  1287. /// </summary>
  1288. public int size { get; set; }
  1289. /// <summary>
  1290. /// 地区
  1291. /// </summary>
  1292. public string region { get; set; }
  1293. /// <summary>
  1294. /// 省份
  1295. /// </summary>
  1296. public string province { get; set; }
  1297. /// <summary>
  1298. /// 城市
  1299. /// </summary>
  1300. public string city { get; set; }
  1301. /// <summary>
  1302. /// 县,区,郡
  1303. /// </summary>
  1304. public string dist { get; set; }
  1305. /// <summary>
  1306. /// 学校详细地址
  1307. /// </summary>
  1308. public string address { get; set; }
  1309. /// <summary>
  1310. /// 学校类型
  1311. /// </summary>
  1312. public int type { get; set; }
  1313. /// <summary>
  1314. /// 区域ID
  1315. /// </summary>
  1316. public string areaId { get; set; }
  1317. /// <summary>
  1318. /// 区域标准
  1319. /// </summary>
  1320. public string standard { get; set; }
  1321. }
  1322. public record ExistScManage
  1323. {
  1324. public string scId{ get; set; }
  1325. public string tmdId { get; set; }
  1326. }
  1327. }
  1328. }