BatchAreaController.cs 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.Options;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using TEAMModelOS.Models;
  10. using TEAMModelOS.SDK.DI;
  11. using TEAMModelOS.SDK.Models;
  12. using Azure.Cosmos;
  13. using System.Text.Json;
  14. using HTEXLib.COMM.Helpers;
  15. using TEAMModelOS.SDK.Models.Cosmos.Common;
  16. using TEAMModelOS.SDK.Models.Cosmos.BI;
  17. using Azure.Messaging.ServiceBus;
  18. using TEAMModelOS.SDK.Extension;
  19. using TEAMModelBI.Filter;
  20. using TEAMModelBI.Tool.Extension;
  21. using TEAMModelBI.Tool;
  22. using Azure.Storage.Blobs.Models;
  23. using Azure;
  24. using Azure.Storage.Blobs.Specialized;
  25. using System.Net.Http;
  26. using System.Net.Http.Json;
  27. using System.Net;
  28. using TEAMModelOS.SDK;
  29. using TEAMModelOS.SDK.Context.BI;
  30. using TEAMModelOS.SDK.DI.CoreAPI;
  31. using System.Text;
  32. using DocumentFormat.OpenXml.Bibliography;
  33. using Microsoft.Extensions.Hosting;
  34. using Microsoft.AspNetCore.Hosting;
  35. using static TEAMModelBI.Controllers.RepairApi.InitialAreaController;
  36. using TEAMModelOS.SDK.Context.Constant;
  37. namespace TEAMModelBI.Controllers.BINormal
  38. {
  39. [Route("batcharea")]
  40. [ApiController]
  41. public class BatchAreaController : ControllerBase
  42. {
  43. private readonly AzureCosmosFactory _azureCosmos;
  44. private readonly DingDing _dingDing;
  45. private readonly Option _option;
  46. private readonly AzureStorageFactory _azureStorage;
  47. private readonly IConfiguration _configuration;
  48. private readonly NotificationService _notificationService;
  49. private readonly AzureServiceBusFactory _serviceBus;
  50. private readonly IHttpClientFactory _http;
  51. private readonly CoreAPIHttpService _coreAPIHttpService;
  52. private readonly IWebHostEnvironment _environment; //读取文件
  53. public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IConfiguration configuration, NotificationService notificationService, AzureServiceBusFactory serviceBus, IHttpClientFactory http, CoreAPIHttpService coreAPIHttpService, IWebHostEnvironment hostingEnvironment)
  54. {
  55. _azureCosmos = azureCosmos;
  56. _dingDing = dingDing;
  57. _azureStorage = azureStorage;
  58. _option = option?.Value;
  59. _configuration = configuration;
  60. _notificationService = notificationService;
  61. _serviceBus = serviceBus;
  62. _http = http;
  63. _coreAPIHttpService = coreAPIHttpService;
  64. _environment = hostingEnvironment;
  65. }
  66. /// <summary>
  67. /// 查询所有的区域标准 //已对接
  68. /// </summary>
  69. /// <returns></returns>
  70. [ProducesDefaultResponseType]
  71. [HttpPost("get-areas")]
  72. public async Task<IActionResult> GetArea(JsonElement jsonElement)
  73. {
  74. try
  75. {
  76. jsonElement.TryGetProperty("id", out JsonElement id);
  77. jsonElement.TryGetProperty("name", out JsonElement name);
  78. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  79. int? pageSize = 100; //默认不指定返回大小
  80. string continuationToken = string.Empty; //返给前端分页token
  81. string pageToken = default;//接受前端的分页Tolen
  82. bool iscontinuation = false;//是否需要进行分页查询,默认不分页
  83. if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
  84. {
  85. if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
  86. {
  87. pageSize = tempPageSize;
  88. }
  89. }
  90. if (pageSize != null && pageSize.Value > 0)
  91. {
  92. iscontinuation = true;
  93. }
  94. if (jsonElement.TryGetProperty("contToken", out JsonElement ContToken))
  95. {
  96. pageToken = ContToken.GetString();
  97. }
  98. List<RecArea> areas = new();
  99. var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
  100. var cosmosClient = _azureCosmos.GetCosmosClient();
  101. ////分开部署,就不需要,一站多用时,取消注释
  102. //if ($"{site}".Equals(BIConst.Global))
  103. //{
  104. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  105. // table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("IESLogin");
  106. //}
  107. StringBuilder areaSql = new($"select c.id,c.code,c.pk,c.name,c.provCode,c.provName,c.cityCode,c.cityName,c.standard,c.standardName,c.institution,c.updateTime,c.quoteId from c");
  108. if (!string.IsNullOrEmpty($"{id}") && string.IsNullOrEmpty($"{name}"))
  109. areaSql.Append($" where c.id='{id}'");
  110. if (string.IsNullOrEmpty($"{id}") && !string.IsNullOrEmpty($"{name}"))
  111. areaSql.Append($" where Contains(c.name,'{name}')");
  112. await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: areaSql.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") }))
  113. {
  114. using var json = await JsonDocument.ParseAsync(itemArea.ContentStream);
  115. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
  116. {
  117. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  118. {
  119. areas.Add(obj.ToObject<RecArea>());
  120. }
  121. if (iscontinuation)
  122. {
  123. continuationToken = itemArea.GetContinuationToken();
  124. break;
  125. }
  126. }
  127. }
  128. //areas.ForEach(async area =>
  129. //{
  130. // area.schoolCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.areaId='{area.id}' and c.standard='{area.standard}'", "Base");
  131. // area.aquoteRec = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
  132. // //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
  133. // //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
  134. // await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  135. // {
  136. // if (string.IsNullOrEmpty(item))
  137. // area.cutArea = false;
  138. // else
  139. // area.cutArea = true;
  140. // };
  141. //});
  142. foreach (var area in areas)
  143. {
  144. //select value(count(c.id)) from c where c.areaId='{area.id}' and c.standard='{area.standard}'
  145. area.schoolCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.areaId='{area.id}'", "Base");
  146. area.aquoteRec = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
  147. //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
  148. //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
  149. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  150. {
  151. if (string.IsNullOrEmpty(item))
  152. area.cutArea = false;
  153. else
  154. area.cutArea = true;
  155. };
  156. }
  157. return Ok(new { state = 200, areas, continuationToken });
  158. }
  159. catch (Exception ex)
  160. {
  161. await _dingDing.SendBotMsg($"BI,{_option.Location} batcharea/get-areas \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  162. return BadRequest();
  163. }
  164. }
  165. /// <summary>
  166. /// 批量创区 新接口 //已对接
  167. /// </summary>
  168. /// <param name="jsonElement"></param>
  169. /// <returns></returns>
  170. [ProducesDefaultResponseType]
  171. [AuthToken(Roles = "admin,rdc")]
  172. [HttpPost("batch-area")]
  173. public async Task<IActionResult> batchArea(JsonElement jsonElement)
  174. {
  175. try
  176. {
  177. if (!jsonElement.TryGetProperty("name", out JsonElement name)) return BadRequest();
  178. jsonElement.TryGetProperty("provCode", out JsonElement provCode);
  179. jsonElement.TryGetProperty("provName", out JsonElement provName);
  180. jsonElement.TryGetProperty("cityCode", out JsonElement cityCode);
  181. jsonElement.TryGetProperty("cityName", out JsonElement cityName);
  182. jsonElement.TryGetProperty("areaAdmin", out JsonElement areadAdmin);
  183. if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
  184. if (!jsonElement.TryGetProperty("standardName", out JsonElement standardName)) return BadRequest();
  185. jsonElement.TryGetProperty("institution", out JsonElement institution);
  186. jsonElement.TryGetProperty("oldId", out JsonElement _oldId);
  187. jsonElement.TryGetProperty("oldStandard", out JsonElement oldStandard);
  188. jsonElement.TryGetProperty("oldName", out JsonElement oldName);
  189. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  190. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  191. //操作记录实体
  192. var tempStandard = !string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}") ? $"{oldStandard}" : "standard2";
  193. var cosmosClient = _azureCosmos.GetCosmosClient();//数据库连接
  194. var tableClient = _azureStorage.GetCloudTableClient();
  195. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
  196. ServiceBusClient serBusClient;
  197. try
  198. {
  199. serBusClient = _serviceBus.GetServiceBusClient();
  200. }
  201. catch
  202. {
  203. return Ok(new { state = 403, msg = "Functionn未启动,请联系管理员" });
  204. }
  205. var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
  206. //分开部署,就不需要,一站多用时,取消注释
  207. //if ($"{site}".Equals(BIConst.Global))
  208. //{
  209. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  210. // tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
  211. // blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", name: BIConst.Global);
  212. //}
  213. var table = tableClient.GetTableReference("IESLogin");
  214. //查询新的是否存在
  215. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  216. {
  217. if (item.standard.Equals($"{standard}"))
  218. return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
  219. }
  220. //区级的ID
  221. string areaId = Guid.NewGuid().ToString();
  222. Area addArea = new()
  223. {
  224. id = areaId,
  225. code = $"Base-Area",
  226. name = $"{name}",
  227. provCode = $"{provCode}",
  228. provName = $"{provName}",
  229. cityCode = $"{cityCode}",
  230. cityName = $"{cityName}",
  231. standard = $"{standard}",
  232. standardName = $"{standardName}",
  233. institution = $"{institution}",
  234. quoteId = $"{_oldId}"
  235. };
  236. #region 区级管理员
  237. var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{areadAdmin}" } }, _option.Location, _configuration);
  238. if (coreUser == null || coreUser.id == null)
  239. return Ok(new { state = 404, msg = "未找到改账户的管理员" });
  240. //string tmdId = !string.IsNullOrEmpty(tempTmdId) ? tempTmdId : $"{areadAdmin}";
  241. Teacher teacher = null;
  242. try
  243. {
  244. //查询该教师是否存在
  245. teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{coreUser.id}", new PartitionKey("Base"));
  246. }
  247. catch
  248. {
  249. }
  250. if (teacher != null)
  251. {
  252. //教师存在,在该教师信息中添加要管理的学校信息
  253. teacher.areas.Add(new Teacher.TeacherArea { areaId = addArea.id, status = "join", name = addArea.name });
  254. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
  255. }
  256. else
  257. {
  258. teacher.id = coreUser.id;
  259. teacher.name = coreUser.name;
  260. teacher.picture = coreUser.picture;
  261. teacher.pk = "Base";
  262. teacher.code = "Base";
  263. teacher.size = 1;
  264. teacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
  265. //教师存在,在该教师信息中添加要管理的学校信息
  266. teacher.areas.Add(new Teacher.TeacherArea { areaId = addArea.id, status = "join", name = addArea.name });
  267. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
  268. }
  269. #endregion
  270. //创建区域
  271. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync<Area>(addArea, new PartitionKey("Base-Area"));
  272. //保存引用记录
  273. await table.SaveOrUpdate<AreaQuoteRecord>(new AreaQuoteRecord() { PartitionKey = "QuoteRecord", RowKey = $"{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}", areaId = $"{areaId}", quoteId = $"{_oldId}", quoteName = $"{oldName}", standard = tempStandard });
  274. //消息分区键
  275. string partitionCode = "copyAbility-mark";
  276. #region 使用Function创区
  277. //string areaCode = "copyArea-mark";
  278. //BatchCopyAreaRelevant bCopyArea = new BatchCopyAreaRelevant()
  279. //{
  280. // tmdid = $"{_tmdId}",
  281. // tmdName = $"{_tmdName}",
  282. // codeKey = areaCode,
  283. // tmdIds = new List<string> { $"{_tmdId}"},
  284. // oldStandard = $"{oldStandard}",
  285. // oldId = $"{_oldId}",
  286. // standard = $"{standard}",
  287. // areaId = areaId,
  288. // cut="",
  289. //};
  290. //var messageBatchCopyArea = new ServiceBusMessage(bCopyArea.ToJsonString());
  291. //messageBatchCopyArea.ApplicationProperties.Add("name", "CopyAreaRelevant");
  292. //var activeTaskArea = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
  293. //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTaskArea, messageBatchCopyArea);
  294. #endregion
  295. #region 旧的批量创区
  296. List<Task<ItemResponse<Ability>>> abilities = new List<Task<ItemResponse<Ability>>>(); //存储区域数据
  297. List<Task<ItemResponse<AbilityTask>>> abilityTasks = new List<Task<ItemResponse<AbilityTask>>>(); //存储章节
  298. if (!string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}"))
  299. {
  300. //查询要复制区域的能力标准点
  301. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{oldStandard}") }))
  302. {
  303. if (!string.IsNullOrEmpty(item.blob))
  304. {
  305. item.blob = item.blob.Replace($"/{oldStandard}/", $"/{standard}/");
  306. };
  307. item.standard = $"{standard}";
  308. item.code = $"Ability-{standard}";
  309. item.school = $"{standard}";
  310. //添加区能力标准点
  311. abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
  312. }
  313. try
  314. {
  315. if (abilities.Count < 256)
  316. {
  317. await Task.WhenAll(abilities);
  318. }
  319. else
  320. {
  321. int pages = (abilities.Count + 255) / 256;
  322. for (int i = 0; i < pages; i++)
  323. {
  324. List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
  325. await Task.WhenAll(tempAbility);
  326. }
  327. }
  328. }
  329. catch
  330. {
  331. return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
  332. }
  333. try
  334. {
  335. //微能力点
  336. await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
  337. {
  338. List<Tnode> tnodes = new List<Tnode>();
  339. foreach (Tnode tnode in atask.children)
  340. {
  341. if (tnode.rnodes != null)
  342. {
  343. List<Rnode> rnodes = new List<Rnode>();
  344. foreach (Rnode rnode in tnode.rnodes)
  345. {
  346. if (!string.IsNullOrEmpty($"{rnode.link}"))
  347. {
  348. rnode.link = rnode.link.Replace($"/{oldStandard}/", $"/{standard}/");
  349. }
  350. rnodes.Add(rnode);
  351. }
  352. tnode.rnodes = rnodes;
  353. }
  354. tnodes.Add(tnode);
  355. }
  356. atask.children = tnodes;
  357. atask.code = $"AbilityTask-{standard}";
  358. atask.standard = $"{standard}";
  359. atask.codeval = $"{standard}";
  360. //添加区能力标准点中的节点
  361. //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
  362. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
  363. }
  364. }
  365. catch
  366. {
  367. return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
  368. }
  369. //if (abilityTasks.Count > 0)
  370. //{
  371. // for (int i = 0; i < abilityTasks.Count; i++)
  372. // {
  373. // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip((i)).Take(1).ToList();
  374. // await Task.WhenAll(tempAbilityTasks);
  375. // }
  376. //}
  377. //新政策文件
  378. await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
  379. {
  380. if (standardFile != null)
  381. {
  382. standardFile.standard = $"{standard}";
  383. standardFile.id = areaId;
  384. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
  385. }
  386. }
  387. //新的区域设置
  388. await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_oldId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  389. {
  390. if (areaSetting != null)
  391. {
  392. areaSetting.accessConfig = null;
  393. areaSetting.id = areaId;
  394. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
  395. }
  396. }
  397. }
  398. else
  399. {
  400. Area area = null;
  401. await foreach (var tempArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard2'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
  402. {
  403. area = tempArea;
  404. }
  405. if (area != null)
  406. {
  407. //查询要复制区域的能力标准点
  408. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
  409. {
  410. if (!string.IsNullOrEmpty(item.blob))
  411. {
  412. item.blob = item.blob.Replace($"/{area.standard}/", $"/{standard}/");
  413. };
  414. item.standard = $"{standard}";
  415. item.code = $"Ability-{standard}";
  416. item.school = $"{standard}";
  417. //添加区能力标准点
  418. abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
  419. }
  420. try
  421. {
  422. if (abilities.Count < 256)
  423. {
  424. await Task.WhenAll(abilities);
  425. }
  426. else
  427. {
  428. int pages = (abilities.Count + 255) / 256;
  429. for (int i = 0; i < pages; i++)
  430. {
  431. List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
  432. await Task.WhenAll(tempAbility);
  433. }
  434. }
  435. }
  436. catch
  437. {
  438. return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
  439. }
  440. try
  441. {
  442. //微能力点
  443. await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
  444. {
  445. List<Tnode> tnodes = new List<Tnode>();
  446. foreach (Tnode tnode in atask.children)
  447. {
  448. if (tnode.rnodes != null)
  449. {
  450. List<Rnode> rnodes = new List<Rnode>();
  451. foreach (Rnode rnode in tnode.rnodes)
  452. {
  453. if (!string.IsNullOrEmpty($"{rnode.link}"))
  454. {
  455. rnode.link = rnode.link.Replace($"/{area.standard}/", $"/{standard}/");
  456. }
  457. rnodes.Add(rnode);
  458. }
  459. tnode.rnodes = rnodes;
  460. }
  461. tnodes.Add(tnode);
  462. }
  463. atask.children = tnodes;
  464. atask.code = $"AbilityTask-{standard}";
  465. atask.standard = $"{standard}";
  466. atask.codeval = $"{standard}";
  467. //添加区能力标准点中的节点
  468. //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
  469. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
  470. }
  471. }
  472. catch
  473. {
  474. return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
  475. }
  476. //if (abilityTasks.Count > 0)
  477. //{
  478. // for (int i = 0; i < abilityTasks.Count; i++)
  479. // {
  480. // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip(i).Take(1).ToList();
  481. // await Task.WhenAll(tempAbilityTasks);
  482. // }
  483. //}
  484. //新政策文件
  485. await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
  486. {
  487. if (standardFile != null)
  488. {
  489. standardFile.standard = $"{standard}";
  490. standardFile.id = areaId;
  491. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
  492. }
  493. }
  494. //新的区域设置
  495. await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  496. {
  497. if (areaSetting != null)
  498. {
  499. areaSetting.accessConfig = null;
  500. areaSetting.id = areaId;
  501. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
  502. }
  503. }
  504. }
  505. else return Ok(new { state = 201, message = "未找到默认能力点!" });
  506. }
  507. #endregion
  508. //执行复制操作
  509. BatchCopyFile batchCopyFile = new BatchCopyFile();
  510. batchCopyFile.blobCntr = "teammodelos";
  511. batchCopyFile.oldFileName = $"{oldStandard}";
  512. batchCopyFile.newFileName = $"{standard}";
  513. batchCopyFile.tmdid = $"{_tmdId}";
  514. batchCopyFile.tmdIds = new List<string> { $"{ _tmdId}" };
  515. batchCopyFile.codeKey = partitionCode;
  516. batchCopyFile.tmdName = $"{_tmdName}";
  517. var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
  518. messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
  519. //var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
  520. try
  521. {
  522. //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
  523. await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile);
  524. }
  525. catch (Exception)
  526. {
  527. return Ok(new { state = 201, msg = "能力点复制成功,复制能力点的文件失败," });
  528. }
  529. //发送消息实体
  530. Notification notification = new Notification
  531. {
  532. hubName = "hita",
  533. type = "msg",
  534. from = $"BI:{_option.Location}:private",
  535. to = new List<string> { $"{ _tmdId}" },
  536. label = $"{partitionCode}_start",
  537. body = new { location = _option.Location, biz = partitionCode, tmdid = $"{_tmdId}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
  538. expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
  539. };
  540. var notiUrl = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
  541. var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
  542. var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
  543. var location = _option.Location;
  544. await _notificationService.SendNotification(clientID, clientSecret, location, notiUrl, notification); //站内发送消息
  545. //保存操作记录
  546. //await _azureStorage.SaveBILog("area-add", $"{_tmdName}【{_tmdId}】已操作创区功能模块:{name},当前标准【{standard}】,复制的微能力点:{tempStandard}", _dingDing, httpContext: HttpContext);
  547. await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "area-add", $"{_tmdName}【{_tmdId}】已操作创区功能模块:{name},当前标准【{standard}】,复制的微能力点:{tempStandard}", _dingDing, httpContext: HttpContext);
  548. return Ok(new { state = 200, area = addArea });
  549. }
  550. catch (Exception ex)
  551. {
  552. await _dingDing.SendBotMsg($"BI,{_option.Location} /batcharea/batch-area \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  553. return BadRequest();
  554. }
  555. }
  556. /// <summary>
  557. /// 创区后切换能力点, 先删除原来的能力点,后复制新的能力点 //已对接
  558. /// </summary>
  559. /// <param name="jsonElement"></param>
  560. /// <returns></returns>
  561. [ProducesDefaultResponseType]
  562. [AuthToken(Roles = "admin,rdc")]
  563. [HttpPost("cut-standard")]
  564. public async Task<IActionResult> CutStandard(JsonElement jsonElement)
  565. {
  566. try
  567. {
  568. if (!jsonElement.TryGetProperty("oldId", out JsonElement _oldId)) return BadRequest();
  569. if (!jsonElement.TryGetProperty("oldStandard", out JsonElement _oldStandard)) return BadRequest();
  570. if (!jsonElement.TryGetProperty("newId", out JsonElement _newId)) return BadRequest();
  571. if (!jsonElement.TryGetProperty("newStandard", out JsonElement _newStandard)) return BadRequest();
  572. jsonElement.TryGetProperty("newName", out JsonElement newName);
  573. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  574. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  575. //操作记录实体
  576. string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
  577. var tableClient = _azureStorage.GetCloudTableClient();
  578. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
  579. var cosmosClient = _azureCosmos.GetCosmosClient();
  580. var serBusClient = _serviceBus.GetServiceBusClient();
  581. var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
  582. ////分开部署,就不需要,一站多用时,取消注释
  583. //if ($"{site}".Equals(BIConst.Global))
  584. //{
  585. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  586. // tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
  587. // blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
  588. // serBusClient = _serviceBus.GetServiceBusClient(BIConst.Global); //暂未确定使用默认
  589. // //activeTask = _configuration.GetValue<string>("GlobalAzure:ServiceBus:ActiveTask"); //暂未确定使用默认
  590. //}
  591. var table = tableClient.GetTableReference("IESLogin");
  592. var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
  593. if (responseSet.Status == 200)
  594. {
  595. using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  596. AreaSetting delSet = fileJson.ToObject<AreaSetting>();
  597. if (!string.IsNullOrEmpty(delSet.accessConfig))
  598. return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
  599. }
  600. //保存引用记录
  601. await table.SaveOrUpdate<AreaQuoteRecord>(new AreaQuoteRecord() { PartitionKey = "QuoteRecord", RowKey = $"{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}", areaId = $"{_oldId}", quoteId = $"{_newId}", quoteName = $"{newName}", standard = $"{_newStandard}" });
  602. List<string> abilityIds = new(); //册别的ID集合
  603. //查询册别信息
  604. await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
  605. {
  606. abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
  607. }
  608. //删除册别
  609. if (abilityIds.IsNotEmpty())
  610. {
  611. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{_oldStandard}");
  612. }
  613. List<string> abilityTaskIds = new(); //章节ID集合
  614. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
  615. {
  616. abilityTaskIds.Add(item.id); //查询出来的章节信息ID添加到战绩集合
  617. }
  618. //删除章节
  619. if (abilityTaskIds.IsNotEmpty())
  620. {
  621. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{_oldStandard}");
  622. }
  623. List<Task<ItemResponse<Ability>>> abilities = new(); //存储册别数据
  624. List<Task<ItemResponse<AbilityTask>>> abilityTasks = new(); //存储章节
  625. //查询要复制区域的能力标准点
  626. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_newStandard}") }))
  627. {
  628. if (!string.IsNullOrEmpty(item.blob))
  629. {
  630. item.blob = item.blob.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
  631. };
  632. item.standard = $"{_oldStandard}";
  633. item.code = $"Ability-{_oldStandard}";
  634. item.school = $"{_oldStandard}";
  635. //添加区能力标准点
  636. abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
  637. }
  638. try
  639. {
  640. if (abilities.Count < 256)
  641. {
  642. await Task.WhenAll(abilities);
  643. }
  644. else
  645. {
  646. int pages = (abilities.Count + 255) / 256;
  647. for (int i = 0; i < pages; i++)
  648. {
  649. List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
  650. await Task.WhenAll(tempAbility);
  651. }
  652. }
  653. }
  654. catch
  655. {
  656. return Ok(new { state = 200, msg = "能力标准点复制失败,遗留数据影响!" });
  657. }
  658. try
  659. {
  660. //微能力点
  661. await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
  662. {
  663. List<Tnode> tnodes = new();
  664. foreach (Tnode tnode in atask.children)
  665. {
  666. if (tnode.rnodes != null)
  667. {
  668. List<Rnode> rnodes = new();
  669. foreach (Rnode rnode in tnode.rnodes)
  670. {
  671. if (!string.IsNullOrEmpty($"{rnode.link}"))
  672. {
  673. rnode.link = rnode.link.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
  674. }
  675. rnodes.Add(rnode);
  676. }
  677. tnode.rnodes = rnodes;
  678. }
  679. tnodes.Add(tnode);
  680. }
  681. atask.children = tnodes;
  682. atask.code = $"AbilityTask-{_oldStandard}";
  683. atask.standard = $"{_oldStandard}";
  684. atask.codeval = $"{_oldStandard}";
  685. ////添加区能力标准点中的节点
  686. //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
  687. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}"));
  688. }
  689. }
  690. catch
  691. {
  692. return Ok(new { state = 200, msg = "能力标准创建成功,微能力点复制失败,遗留数据影响!" });
  693. }
  694. StandardFile saveFile = new();
  695. //新政策文件
  696. await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
  697. {
  698. if (standardFile != null)
  699. {
  700. standardFile.standard = $"{_oldStandard}";
  701. standardFile.id = $"{_oldId}";
  702. saveFile = standardFile;
  703. }
  704. }
  705. StandardFile tempFile = new();
  706. if (saveFile.id != null)
  707. {
  708. var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
  709. if (respFile.Status == 200)
  710. {
  711. using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
  712. tempFile = json.ToObject<StandardFile>();
  713. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
  714. }
  715. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
  716. }
  717. //新的区域设置
  718. AreaSetting saveSetting = new AreaSetting();
  719. await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  720. {
  721. if (areaSetting != null)
  722. {
  723. areaSetting.accessConfig = null;
  724. areaSetting.id = $"{_oldId}";
  725. saveSetting = areaSetting;
  726. }
  727. }
  728. AreaSetting tempSetting = new();
  729. if (saveSetting.id != null)
  730. {
  731. var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
  732. if (respSetting.Status == 200)
  733. {
  734. using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
  735. tempSetting = json.ToObject<AreaSetting>();
  736. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(tempFile.id, new PartitionKey("AreaSetting"));
  737. }
  738. tempSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting")); //需要删除原来的区域设置数据在进行添加
  739. }
  740. //修改切换区级能力引用id
  741. Area area = new();
  742. area = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<Area>($"{_oldId}", new PartitionKey("Base-Area"));
  743. area.quoteId = $"{_newId}";
  744. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<Area>(area, area.id, new PartitionKey(area.code));
  745. //发送消息分区键
  746. string partitionCode = "DelBeforeCopyAbility-mark";
  747. //v2通知
  748. Teacher targetTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<Teacher>($"{_tmdId}", new PartitionKey($"Base"));
  749. _coreAPIHttpService.PushNotify(new List<IdNameCode> { new IdNameCode { id = targetTeacher.id, name = targetTeacher.name, code = targetTeacher.lang } }, "copy-file_area", Constant.NotifyType_IES5_Management, new Dictionary<string, object> { { "tmdname", $"{_tmdName}" } }, _option.Location, _configuration, _dingDing, _environment.ContentRootPath);
  750. //执行复制操作
  751. BatchCopyFile batchCopyFile = new();
  752. batchCopyFile.blobCntr = "teammodelos";
  753. batchCopyFile.oldFileName = $"{_newStandard}";
  754. batchCopyFile.newFileName = $"{_oldStandard}";
  755. batchCopyFile.tmdid = $"{_tmdId}";
  756. batchCopyFile.tmdIds = new List<string> { $"{ _tmdId}" };
  757. batchCopyFile.codeKey = partitionCode;
  758. batchCopyFile.tmdName = $"{_tmdName}";
  759. var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
  760. messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
  761. try
  762. {
  763. //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制 单一
  764. await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制
  765. }
  766. catch (Exception)
  767. {
  768. return Ok(new { state = 201 ,msg = "能力点复制成功,复制能力点的文件失败," });
  769. }
  770. //发送消息实体
  771. Notification notification = new()
  772. {
  773. hubName = "hita",
  774. type = "msg",
  775. from = $"BI:{_option.Location}:private",
  776. to = new List<string> { $"{ _tmdId}" },
  777. label = $"{partitionCode}_start",
  778. body = new { location = _option.Location, biz = partitionCode, tmdid = $"{_tmdId}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
  779. expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
  780. };
  781. var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
  782. var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
  783. var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
  784. var location = _option.Location;
  785. await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //发送站内发送消息
  786. //保存操作记录
  787. await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "area-cut", $"{_tmdName}【{_tmdId}】已操作【{_oldStandard}】切换至{_newStandard}微能力点,复制标准:{_newStandard}", _dingDing, httpContext: HttpContext);
  788. return Ok(new { state = 200 });
  789. }
  790. catch (Exception ex)
  791. {
  792. await _dingDing.SendBotMsg($"BI,{_option.Location} batcharea/cut-standard \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  793. return BadRequest();
  794. }
  795. }
  796. /// <summary>
  797. /// 删除区域和区域的册别、能力点、区域文件、区域设置
  798. /// </summary>
  799. /// <param name="jsonElement"></param>
  800. /// <returns></returns>
  801. [ProducesDefaultResponseType]
  802. [HttpPost("del-area")]
  803. public async Task<IActionResult> DelArea(JsonElement jsonElement)
  804. {
  805. if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
  806. if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
  807. //jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
  808. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "teammodelos");
  809. var cosmosClient = _azureCosmos.GetCosmosClient();
  810. ////分开部署,就不需要,一站多用时,取消注释
  811. //if ($"{site}".Equals(BIConst.Global))
  812. //{
  813. // cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
  814. // blobClient = _azureStorage.GetBlobContainerClient(containerName: "teammodelos", BIConst.Global);
  815. //}
  816. var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("Base-Area"));
  817. if (response.Status == 200)
  818. {
  819. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  820. Area area = json.ToObject<Area>();
  821. if (area.standard == $"{standard}")
  822. {
  823. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<Area>(area.id, new PartitionKey("Base-Area")); //删除区
  824. List<Teacher> teachers = new();
  825. await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Teacher>(queryText: $"SELECT distinct value(c) FROM c join a in c.areas join s in c.schools where a.areaId='{area.id}' or s.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
  826. {
  827. teachers.Add(item);
  828. }
  829. foreach (var item in teachers)
  830. {
  831. var tempArea = item.areas.Find(f => f.areaId.Equals(area.id));
  832. if (tempArea != null)
  833. {
  834. item.areas.Remove(tempArea);
  835. }
  836. item.schools.ForEach(fe => { if (fe.areaId.Equals(area.id)) fe.areaId = ""; });
  837. await cosmosClient.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Teacher>(item, item.id, new PartitionKey("Base"));
  838. }
  839. List<string> scIds = await CommonFind.FindScIds(cosmosClient, $"select c.id from c where c.areaId='{area.id}' and c.standard ='{area.standard}'", "Base");
  840. foreach (var item in scIds)
  841. {
  842. School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(item, new PartitionKey("Base"));
  843. school.areaId = "";
  844. school.standard = "";
  845. school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
  846. }
  847. List<string> abilityIds = new(); //册别的ID集合
  848. List<string> abilityTaskIds = new(); //章节ID集合
  849. //查询册别信息
  850. await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
  851. {
  852. abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
  853. }
  854. //删除册别
  855. if (abilityIds.IsNotEmpty())
  856. {
  857. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{area.standard}");
  858. }
  859. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
  860. {
  861. abilityTaskIds.Add(item.id); //查询出来的章节信息ID添加到战绩集合
  862. }
  863. //删除章节
  864. if (abilityTaskIds.IsNotEmpty())
  865. {
  866. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{standard}");
  867. }
  868. //区域政策文件
  869. StandardFile delFile = new();
  870. var responseFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("StandardFile"));
  871. if(responseFile.Status == 200)
  872. {
  873. using var fileJson = await JsonDocument.ParseAsync(responseFile.ContentStream);
  874. delFile = fileJson.ToObject<StandardFile>();
  875. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(delFile.id, new PartitionKey("StandardFile"));
  876. }
  877. //区域设置
  878. AreaSetting delSet = new();
  879. var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("AreaSetting"));
  880. if (responseSet.Status == 200)
  881. {
  882. using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  883. delSet = fileJson.ToObject<AreaSetting>();
  884. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(delSet.id, new PartitionKey("AreaSetting"));
  885. }
  886. List<object> fileobj = new();
  887. //先删除原有的文件
  888. List<Task<Response<bool>>> DelList = new();
  889. await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{area.standard}/"))
  890. {
  891. fileobj.Add(blobItem.Name);
  892. DelList.Add(blobClient.GetBlobBaseClient(blobItem.Name).DeleteIfExistsAsync());
  893. }
  894. if (DelList.Count <= 256)
  895. {
  896. await Task.WhenAll(DelList);
  897. }
  898. else
  899. {
  900. int pages = (DelList.Count + 255) / 256;
  901. for (int i = 0; i < pages; i++)
  902. {
  903. List<Task<Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
  904. await Task.WhenAll(delList);
  905. }
  906. }
  907. return Ok(new { state = 200,area, scIds, abilityIds, abilityTaskIds, delFile, delSet, fileobj });
  908. }
  909. else return Ok(new { state = 400, msg = "id和standard不匹配!" });
  910. }
  911. else return Ok(new { state = 404,msg="依据Id未找到该区!" });
  912. }
  913. /// <summary>
  914. /// 同步两个区到新的区中
  915. /// </summary>
  916. /// <param name="jsonElement"></param>
  917. /// <returns></returns>
  918. [ProducesDefaultResponseType]
  919. [AuthToken(Roles = "admin")]
  920. [HttpPost("cut-full-statndard")]
  921. public async Task<IActionResult> CutFullStandard(JsonElement jsonElement)
  922. {
  923. try
  924. {
  925. string _oldId = "bde5c011-2ae4-461a-b46c-5483ba72ae45";
  926. string _oldStandard = "standard27";
  927. string standardFileId = "02944f32-f534-3397-ea56-e6f1fc6c3714";
  928. string standard = "standard2";
  929. List<CopyStandard> copyStand = new()
  930. {
  931. new CopyStandard() { id = standardFileId, standard = standard },
  932. new CopyStandard() { id = "99a4a33b-e21b-44ac-80a1-b31dc40496e0", standard = "standard3" }
  933. };
  934. var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
  935. var tableClient = _azureStorage.GetCloudTableClient();
  936. var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
  937. var cosmosClient = _azureCosmos.GetCosmosClient();
  938. var serBusClient = _serviceBus.GetServiceBusClient();
  939. var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
  940. var table = tableClient.GetTableReference("IESLogin");
  941. var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
  942. if (responseSet.Status == 200)
  943. {
  944. using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
  945. AreaSetting delSet = fileJson.ToObject<AreaSetting>();
  946. if (!string.IsNullOrEmpty(delSet.accessConfig))
  947. return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
  948. }
  949. List<string> abilityIds = new List<string>(); //册别的ID集合
  950. //查询册别信息
  951. await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
  952. {
  953. abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
  954. }
  955. //删除册别
  956. if (abilityIds.IsNotEmpty())
  957. {
  958. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{_oldStandard}");
  959. }
  960. List<string> abilityTaskIds = new List<string>(); //章节ID集合
  961. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
  962. {
  963. abilityTaskIds.Add(item.id); //查询出来的章节信息ID添加到战绩集合
  964. }
  965. //删除章节
  966. if (abilityTaskIds.IsNotEmpty())
  967. {
  968. var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{_oldStandard}");
  969. }
  970. List<Task<ItemResponse<Ability>>> abilities = new(); //存储册别数据
  971. List<Task<ItemResponse<AbilityTask>>> abilityTasks = new(); //存储章节
  972. List<string> repeatAbilityId = new();
  973. List<string> repeatAbilityTaskId = new();
  974. foreach (var newstand in copyStand)
  975. {
  976. try
  977. {
  978. //查询要复制区域的能力标准点
  979. await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{newstand.standard}") }))
  980. {
  981. if (!string.IsNullOrEmpty(item.blob))
  982. item.blob = item.blob.Replace($"/{newstand.standard}/", $"/{_oldStandard}/");
  983. item.standard = $"{_oldStandard}";
  984. item.code = $"Ability-{_oldStandard}";
  985. item.school = $"{_oldStandard}";
  986. //添加区能力标准点
  987. //abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
  988. //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}"));
  989. var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(item.id, new PartitionKey(item.code));
  990. if (respond.Status != 200)
  991. abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
  992. else
  993. repeatAbilityId.Add(item.id);
  994. }
  995. }
  996. catch
  997. {
  998. return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
  999. }
  1000. try
  1001. {
  1002. if (abilities.Count < 256)
  1003. {
  1004. await Task.WhenAll(abilities);
  1005. }
  1006. else
  1007. {
  1008. int pages = (abilities.Count + 255) / 256;
  1009. for (int i = 0; i < pages; i++)
  1010. {
  1011. List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
  1012. await Task.WhenAll(tempAbility);
  1013. }
  1014. }
  1015. }
  1016. catch
  1017. {
  1018. return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
  1019. }
  1020. try
  1021. {
  1022. //微能力点
  1023. await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{newstand.standard}") }))
  1024. {
  1025. List<Tnode> tnodes = new();
  1026. foreach (Tnode tnode in atask.children)
  1027. {
  1028. if (tnode.rnodes != null)
  1029. {
  1030. List<Rnode> rnodes = new();
  1031. foreach (Rnode rnode in tnode.rnodes)
  1032. {
  1033. if (!string.IsNullOrEmpty($"{rnode.link}"))
  1034. {
  1035. rnode.link = rnode.link.Replace($"/{newstand.standard}/", $"/{_oldStandard}/");
  1036. }
  1037. rnodes.Add(rnode);
  1038. }
  1039. tnode.rnodes = rnodes;
  1040. }
  1041. tnodes.Add(tnode);
  1042. }
  1043. atask.children = tnodes;
  1044. atask.code = $"AbilityTask-{_oldStandard}";
  1045. atask.standard = $"{_oldStandard}";
  1046. atask.codeval = $"{_oldStandard}";
  1047. var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(atask.id, new PartitionKey(atask.code));
  1048. if (respond.Status != 200)
  1049. ////添加区能力标准点中的节点
  1050. //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
  1051. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}"));
  1052. else
  1053. repeatAbilityTaskId.Add(atask.id);
  1054. }
  1055. }
  1056. catch
  1057. {
  1058. return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
  1059. }
  1060. //发送消息分区键
  1061. string partitionCode = "DelBeforeCopyAbility-mark";
  1062. //执行复制操作
  1063. BatchCopyFile batchCopyFile = new();
  1064. batchCopyFile.blobCntr = "teammodelos";
  1065. batchCopyFile.oldFileName = $"{newstand.standard}";
  1066. batchCopyFile.newFileName = $"{_oldStandard}";
  1067. batchCopyFile.tmdid = $"{_tmdId}";
  1068. batchCopyFile.tmdIds = new List<string> { $"{_tmdId}" };
  1069. batchCopyFile.codeKey = partitionCode;
  1070. batchCopyFile.tmdName = $"{_tmdName}";
  1071. var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
  1072. messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
  1073. try
  1074. {
  1075. //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制 单一
  1076. await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制
  1077. }
  1078. catch (Exception)
  1079. {
  1080. return Ok(new { state = 201, msg = "能力点复制成功,复制能力点的文件失败," });
  1081. }
  1082. //发送消息实体
  1083. Notification notification = new()
  1084. {
  1085. hubName = "hita",
  1086. type = "msg",
  1087. from = $"BI:{_option.Location}:private",
  1088. to = new List<string> { $"{_tmdId}" },
  1089. label = $"{partitionCode}_start",
  1090. body = new { location = _option.Location, biz = partitionCode, tmdid = $"{_tmdId}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
  1091. expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
  1092. };
  1093. var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
  1094. var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
  1095. var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
  1096. var location = _option.Location;
  1097. await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //发送站内发送消息
  1098. }
  1099. StandardFile saveFile = new();
  1100. //新政策文件
  1101. await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
  1102. {
  1103. if (standardFile != null)
  1104. {
  1105. standardFile.standard = $"{_oldStandard}";
  1106. standardFile.id = $"{_oldId}";
  1107. saveFile = standardFile;
  1108. }
  1109. }
  1110. StandardFile tempFile = new();
  1111. if (saveFile.id != null)
  1112. {
  1113. var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
  1114. if (respFile.Status == 200)
  1115. {
  1116. using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
  1117. tempFile = json.ToObject<StandardFile>();
  1118. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
  1119. }
  1120. tempFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
  1121. }
  1122. //if (tempFile.id != null)
  1123. //{
  1124. // if (tempFile.id.Equals(saveFile.id))
  1125. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<StandardFile>(saveFile, saveFile.id, new PartitionKey("StandardFile")); //直接替换以前的数据
  1126. // else
  1127. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
  1128. //}
  1129. //新的区域设置
  1130. AreaSetting saveSetting = new();
  1131. await foreach (AreaSetting areaSetting in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: $"select value(c) from c where c.id='{standardFileId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
  1132. {
  1133. if (areaSetting != null)
  1134. {
  1135. areaSetting.accessConfig = null;
  1136. areaSetting.id = $"{_oldId}";
  1137. saveSetting = areaSetting;
  1138. }
  1139. }
  1140. AreaSetting tempSetting = new();
  1141. if (saveSetting.id != null)
  1142. {
  1143. var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
  1144. if (respSetting.Status == 200)
  1145. {
  1146. using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
  1147. tempSetting = json.ToObject<AreaSetting>();
  1148. await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(saveSetting.id, new PartitionKey("AreaSetting"));
  1149. }
  1150. tempSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting")); //需要删除原来的区域设置数据在进行添加
  1151. }
  1152. //if (tempSetting.id != null)
  1153. //{
  1154. // if (tempSetting.id.Equals(saveSetting.id))
  1155. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<AreaSetting>(saveSetting, saveSetting.id, new PartitionKey($"AreaSetting")); //直接替换以前的数据
  1156. // else
  1157. // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting")); //需要删除原来的区域设置数据在进行添加
  1158. //}
  1159. return Ok(new { state = RespondCode.Ok, repeatAbilityId, repeatAbilityTaskId });
  1160. }
  1161. catch (Exception ex)
  1162. {
  1163. await _dingDing.SendBotMsg($"BI,{_option.Location} batcharea/cut-full-statndard \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  1164. return BadRequest();
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// 区域列表
  1169. /// </summary>
  1170. public record RecArea
  1171. {
  1172. public string id { get; set; }
  1173. public string code { get; set; }
  1174. public string pk { get; set; }
  1175. public string name { get; set; }
  1176. public string provCode { get; set; }
  1177. public string provName { get; set; }
  1178. public string cityCode { get; set; }
  1179. public string cityName { get; set; }
  1180. public string standard { get; set; }
  1181. public string standardName { get; set; }
  1182. public string institution { get; set; }
  1183. public int schoolCount { get; set; }
  1184. public long updateTime { get; set; }
  1185. public string quoteId { get; set; } = null;
  1186. public bool cutArea { get; set; } = false;
  1187. public List<AreaQuoteRecord> aquoteRec { get; set; } = new List<AreaQuoteRecord>();
  1188. }
  1189. }
  1190. }