12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.Options;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using TEAMModelOS.Models;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Models;
- using Azure.Cosmos;
- using System.Text.Json;
- using HTEXLib.COMM.Helpers;
- using TEAMModelOS.SDK.Models.Cosmos.Common;
- using TEAMModelOS.SDK.Models.Cosmos.BI;
- using Azure.Messaging.ServiceBus;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models.Service;
- using TEAMModelBI.Filter;
- using TEAMModelBI.Tool.Extension;
- using TEAMModelBI.Tool;
- using Azure.Storage.Blobs.Models;
- using Azure;
- using Azure.Storage.Blobs.Specialized;
- using System.Net.Http;
- using System.Net.Http.Json;
- using System.Net;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.Context.BI;
- namespace TEAMModelBI.Controllers.BISchool
- {
- [Route("batcharea")]
- [ApiController]
- public class BatchAreaController : ControllerBase
- {
- private readonly AzureCosmosFactory _azureCosmos;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly AzureStorageFactory _azureStorage;
- private readonly IConfiguration _configuration;
- private readonly NotificationService _notificationService;
- private readonly AzureServiceBusFactory _serviceBus;
- private readonly IHttpClientFactory _http;
- private readonly CoreAPIHttpService _coreAPIHttpService;
- public BatchAreaController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IConfiguration configuration, NotificationService notificationService, AzureServiceBusFactory serviceBus, IHttpClientFactory http, CoreAPIHttpService coreAPIHttpService)
- {
- _azureCosmos = azureCosmos;
- _dingDing = dingDing;
- _azureStorage = azureStorage;
- _option = option?.Value;
- _configuration = configuration;
- _notificationService = notificationService;
- _serviceBus = serviceBus;
- _http = http;
- _coreAPIHttpService = coreAPIHttpService;
- }
- /// <summary>
- /// 查询所有的区域标准 //已对接
- /// </summary>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("get-areas")]
- public async Task<IActionResult> GetArea(JsonElement jsonElement)
- {
- try
- {
- jsonElement.TryGetProperty("site", out JsonElement site);
- int? pageSize = null; //默认不指定返回大小
- string continuationToken = string.Empty; //返给前端分页token
- string pageToken = default;//接受前端的分页Tolen
- bool iscontinuation = false;//是否需要进行分页查询,默认不分页
- if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
- {
- if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
- {
- pageSize = tempPageSize;
- }
- }
- if (pageSize != null && pageSize.Value > 0)
- {
- iscontinuation = true;
- }
- if (jsonElement.TryGetProperty("contToken", out JsonElement ContToken))
- {
- pageToken = ContToken.GetString();
- }
- List<RecArea> areas = new();
- var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
- var cosmosClient = _azureCosmos.GetCosmosClient();
- if ($"{site}".Equals(BIConst.Global))
- {
- cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
- table = _azureStorage.GetCloudTableClient(BIConst.Global).GetTableReference("IESLogin");
- }
- string areaSql = $"select c.id,c.code,c.pk,c.name,c.provCode,c.provName,c.cityCode,c.cityName,c.standard,c.standardName,c.institution from c";
- await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: areaSql, continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base-Area") }))
- {
- using var json = await JsonDocument.ParseAsync(itemArea.ContentStream);
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetInt16() > 0)
- {
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
- {
- areas.Add(obj.ToObject<RecArea>());
- }
- if (iscontinuation)
- {
- continuationToken = itemArea.GetContinuationToken();
- break;
- }
- }
- }
- areas.ForEach(async area =>
- {
- 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");
- area.aquoteRec = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
- //List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{area.id}'");
- //aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
- 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") }))
- {
- if (string.IsNullOrEmpty(item))
- area.cutArea = false;
- else
- area.cutArea = true;
- };
- });
- //await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<RecArea>(queryText: areaSql,requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
- //{
- // areas.Add(item);
- //}
- //foreach (var recArea in areas)
- //{
- // recArea.schoolCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.areaId='{recArea.id}' and c.standard='{recArea.standard}'", "Base");
- // List<AreaQuoteRecord> aqr = await table.QueryWhereString<AreaQuoteRecord>($"PartitionKey eq 'QuoteRecord' and areaId eq '{recArea.id}'");
- // aqr.Sort((x, y) => y.RowKey.CompareTo(x.RowKey));
- // recArea.aquoteRec = aqr;
- // await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.accessConfig) from c where c.id='{recArea.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("AreaSetting") }))
- // {
- // if (string.IsNullOrEmpty(item))
- // recArea.cutArea = false;
- // else
- // recArea.cutArea = true;
- // };
- //}
- return Ok(new { state = 200, areas, continuationToken });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"BI,{_option.Location} batcharea/get-areas \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 批量创区 新接口 //已对接
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [AuthToken(Roles = "admin,rdc")]
- [HttpPost("batch-area")]
- public async Task<IActionResult> batchArea(JsonElement jsonElement)
- {
- try
- {
- if (!jsonElement.TryGetProperty("name", out JsonElement name)) return BadRequest();
- jsonElement.TryGetProperty("provCode", out JsonElement provCode);
- jsonElement.TryGetProperty("provName", out JsonElement provName);
- jsonElement.TryGetProperty("cityCode", out JsonElement cityCode);
- jsonElement.TryGetProperty("cityName", out JsonElement cityName);
- jsonElement.TryGetProperty("areaAdmin", out JsonElement areadAdmin);
- if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
- if (!jsonElement.TryGetProperty("standardName", out JsonElement standardName)) return BadRequest();
- jsonElement.TryGetProperty("institution", out JsonElement institution);
- jsonElement.TryGetProperty("oldId", out JsonElement _oldId);
- jsonElement.TryGetProperty("oldStandard", out JsonElement oldStandard);
- jsonElement.TryGetProperty("oldName", out JsonElement oldName);
- jsonElement.TryGetProperty("site", out JsonElement site);
- var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
- //操作记录实体
- var tempStandard = !string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}") ? $"{oldStandard}" : "standard2";
- //var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
- var cosmosClient = _azureCosmos.GetCosmosClient();//数据库连接
- var tableClient = _azureStorage.GetCloudTableClient();
- var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
- ServiceBusClient serBusClient;
- try
- {
- serBusClient = _serviceBus.GetServiceBusClient();
- }
- catch
- {
- return Ok(new { state = 403, msg = "Functionn未启动,请联系管理员" });
- }
- var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
- if ($"{site}".Equals(BIConst.Global))
- {
- cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
- tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
- blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", name: BIConst.Global);
- //serBusClient = _serviceBus.GetServiceBusClient(BIConst.Global); //暂未确定使用默认
- //activeTask = _configuration.GetValue<string>("GlobalAzure:ServiceBus:ActiveTask"); //暂未确定使用默认
- }
- var table = tableClient.GetTableReference("IESLogin");
- //查询新的是否存在
- 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") }))
- {
- if (item.standard.Equals($"{standard}"))
- return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
- }
- //区级的ID
- string areaId = Guid.NewGuid().ToString();
- Area addArea = new Area()
- {
- id = areaId,
- code = $"Base-Area",
- name = $"{name}",
- provCode = $"{provCode}",
- provName = $"{provName}",
- cityCode = $"{cityCode}",
- cityName = $"{cityName}",
- standard = $"{standard}",
- standardName = $"{standardName}",
- institution = $"{institution}"
- };
- #region 区级管理员
- var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{areadAdmin}" } }, _option.Location, _configuration);
- if (coreUser == null || coreUser.id == null)
- return Ok(new { state = 404, msg = "未找到改账户的管理员" });
- //string tmdId = !string.IsNullOrEmpty(tempTmdId) ? tempTmdId : $"{areadAdmin}";
- Teacher teacher = null;
- try
- {
- //查询该教师是否存在
- teacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{coreUser.id}", new PartitionKey("Base"));
- }
- catch
- {
- }
- if (teacher != null)
- {
- //教师存在,在该教师信息中添加要管理的学校信息
- teacher.areas.Add(new Teacher.TeacherArea { areaId = addArea.id, status = "join", name = addArea.name });
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey("Base"));
- }
- else
- {
- teacher.id = coreUser.id;
- teacher.name = coreUser.name;
- teacher.picture = coreUser.picture;
- teacher.pk = "Base";
- teacher.code = "Base";
- teacher.size = 1;
- teacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- //教师存在,在该教师信息中添加要管理的学校信息
- teacher.areas.Add(new Teacher.TeacherArea { areaId = addArea.id, status = "join", name = addArea.name });
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
- }
- #endregion
- //创建区域
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync<Area>(addArea, new PartitionKey("Base-Area"));
- //保存引用记录
- await table.SaveOrUpdate<AreaQuoteRecord>(new AreaQuoteRecord() { PartitionKey = "QuoteRecord", RowKey = $"{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}", areaId = $"{areaId}", quoteId = $"{_oldId}", quoteName = $"{oldName}", standard = tempStandard });
- //消息分区键
- string partitionCode = "copyAbility-mark";
- #region 使用Function创区
- //string areaCode = "copyArea-mark";
- //BatchCopyAreaRelevant bCopyArea = new BatchCopyAreaRelevant()
- //{
- // tmdid = $"{_tmdId}",
- // tmdName = $"{_tmdName}",
- // codeKey = areaCode,
- // tmdIds = new List<string> { $"{_tmdId}"},
- // oldStandard = $"{oldStandard}",
- // oldId = $"{_oldId}",
- // standard = $"{standard}",
- // areaId = areaId,
- // cut="",
- //};
- //var messageBatchCopyArea = new ServiceBusMessage(bCopyArea.ToJsonString());
- //messageBatchCopyArea.ApplicationProperties.Add("name", "CopyAreaRelevant");
- //var activeTaskArea = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTaskArea, messageBatchCopyArea);
- #endregion
- #region 旧的批量创区
- List<Task<ItemResponse<Ability>>> abilities = new List<Task<ItemResponse<Ability>>>(); //存储区域数据
- List<Task<ItemResponse<AbilityTask>>> abilityTasks = new List<Task<ItemResponse<AbilityTask>>>(); //存储章节
- if (!string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}"))
- {
- //查询要复制区域的能力标准点
- 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}") }))
- {
- if (!string.IsNullOrEmpty(item.blob))
- {
- item.blob = item.blob.Replace($"/{oldStandard}/", $"/{standard}/");
- };
- item.standard = $"{standard}";
- item.code = $"Ability-{standard}";
- item.school = $"{standard}";
- //添加区能力标准点
- abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
- }
- try
- {
- if (abilities.Count < 256)
- {
- await Task.WhenAll(abilities);
- }
- else
- {
- int pages = (abilities.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempAbility);
- }
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
- }
- try
- {
- //微能力点
- 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}") }))
- {
- List<Tnode> tnodes = new List<Tnode>();
- foreach (Tnode tnode in atask.children)
- {
- if (tnode.rnodes != null)
- {
- List<Rnode> rnodes = new List<Rnode>();
- foreach (Rnode rnode in tnode.rnodes)
- {
- if (!string.IsNullOrEmpty($"{rnode.link}"))
- {
- rnode.link = rnode.link.Replace($"/{oldStandard}/", $"/{standard}/");
- }
- rnodes.Add(rnode);
- }
- tnode.rnodes = rnodes;
- }
- tnodes.Add(tnode);
- }
- atask.children = tnodes;
- atask.code = $"AbilityTask-{standard}";
- atask.standard = $"{standard}";
- atask.codeval = $"{standard}";
- //添加区能力标准点中的节点
- //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
- }
- //if (abilityTasks.Count > 0)
- //{
- // for (int i = 0; i < abilityTasks.Count; i++)
- // {
- // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip((i)).Take(1).ToList();
- // await Task.WhenAll(tempAbilityTasks);
- // }
- //}
- //新政策文件
- 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") }))
- {
- if (standardFile != null)
- {
- standardFile.standard = $"{standard}";
- standardFile.id = areaId;
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
- }
- }
- //新的区域设置
- 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") }))
- {
- if (areaSetting != null)
- {
- areaSetting.accessConfig = null;
- areaSetting.id = areaId;
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
- }
- }
- }
- else
- {
- Area area = null;
- 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") }))
- {
- area = tempArea;
- }
- if (area != null)
- {
- //查询要复制区域的能力标准点
- 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}") }))
- {
- if (!string.IsNullOrEmpty(item.blob))
- {
- item.blob = item.blob.Replace($"/{area.standard}/", $"/{standard}/");
- };
- item.standard = $"{standard}";
- item.code = $"Ability-{standard}";
- item.school = $"{standard}";
- //添加区能力标准点
- abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
- }
- try
- {
- if (abilities.Count < 256)
- {
- await Task.WhenAll(abilities);
- }
- else
- {
- int pages = (abilities.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempAbility);
- }
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
- }
- try
- {
- //微能力点
- 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}") }))
- {
- List<Tnode> tnodes = new List<Tnode>();
- foreach (Tnode tnode in atask.children)
- {
- if (tnode.rnodes != null)
- {
- List<Rnode> rnodes = new List<Rnode>();
- foreach (Rnode rnode in tnode.rnodes)
- {
- if (!string.IsNullOrEmpty($"{rnode.link}"))
- {
- rnode.link = rnode.link.Replace($"/{area.standard}/", $"/{standard}/");
- }
- rnodes.Add(rnode);
- }
- tnode.rnodes = rnodes;
- }
- tnodes.Add(tnode);
- }
- atask.children = tnodes;
- atask.code = $"AbilityTask-{standard}";
- atask.standard = $"{standard}";
- atask.codeval = $"{standard}";
- //添加区能力标准点中的节点
- //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
- }
- //if (abilityTasks.Count > 0)
- //{
- // for (int i = 0; i < abilityTasks.Count; i++)
- // {
- // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip(i).Take(1).ToList();
- // await Task.WhenAll(tempAbilityTasks);
- // }
- //}
- //新政策文件
- 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") }))
- {
- if (standardFile != null)
- {
- standardFile.standard = $"{standard}";
- standardFile.id = areaId;
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
- }
- }
- //新的区域设置
- 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") }))
- {
- if (areaSetting != null)
- {
- areaSetting.accessConfig = null;
- areaSetting.id = areaId;
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
- }
- }
- }
- else return Ok(new { state = 201, message = "未找到默认能力点!" });
- }
- #endregion
- //执行复制操作
- BatchCopyFile batchCopyFile = new BatchCopyFile();
- batchCopyFile.blobCntr = "teammodelos";
- batchCopyFile.oldFileName = $"{oldStandard}";
- batchCopyFile.newFileName = $"{standard}";
- batchCopyFile.tmdid = $"{_tmdId}";
- batchCopyFile.tmdIds = new List<string> { $"{ _tmdId}" };
- batchCopyFile.codeKey = partitionCode;
- batchCopyFile.tmdName = $"{_tmdName}";
- var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
- messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
- //var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
- try
- {
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
- await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile);
- }
- catch (Exception)
- {
- return Ok(new { state = 201, msg = "能力点复制成功,复制能力点的文件失败," });
- }
- //发送消息实体
- Notification notification = new Notification
- {
- hubName = "hita",
- type = "msg",
- from = $"BI:{_option.Location}:private",
- to = new List<string> { $"{ _tmdId}" },
- label = $"{partitionCode}_start",
- body = new { location = _option.Location, biz = partitionCode, tmdid = $"{_tmdId}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
- expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
- };
- var notiUrl = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
- var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
- var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
- var location = _option.Location;
- await _notificationService.SendNotification(clientID, clientSecret, location, notiUrl, notification); //站内发送消息
- //保存操作记录
- //await _azureStorage.SaveBILog("area-add", $"{_tmdName}【{_tmdId}】已操作创区功能模块:{name},当前标准【{standard}】,复制的微能力点:{tempStandard}", _dingDing, httpContext: HttpContext);
- await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "area-add", $"{_tmdName}【{_tmdId}】已操作创区功能模块:{name},当前标准【{standard}】,复制的微能力点:{tempStandard}", _dingDing, httpContext: HttpContext);
- return Ok(new { state = 200, area = addArea });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"BI,{_option.Location} /batcharea/batch-area \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 创区后切换能力点, 先删除原来的能力点,后复制新的能力点 //已对接
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [AuthToken(Roles = "admin,rdc")]
- [HttpPost("cut-standard")]
- public async Task<IActionResult> CutStandard(JsonElement jsonElement)
- {
- try
- {
- if (!jsonElement.TryGetProperty("oldId", out JsonElement _oldId)) return BadRequest();
- if (!jsonElement.TryGetProperty("oldStandard", out JsonElement _oldStandard)) return BadRequest();
- if (!jsonElement.TryGetProperty("newId", out JsonElement _newId)) return BadRequest();
- if (!jsonElement.TryGetProperty("newStandard", out JsonElement _newStandard)) return BadRequest();
- jsonElement.TryGetProperty("newName", out JsonElement newName);
- jsonElement.TryGetProperty("site", out JsonElement site);
- var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
- //操作记录实体
- string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
- var tableClient = _azureStorage.GetCloudTableClient();
- var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
- var cosmosClient = _azureCosmos.GetCosmosClient();
- var serBusClient = _serviceBus.GetServiceBusClient();
- var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
- if ($"{site}".Equals(BIConst.Global))
- {
- cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
- tableClient = _azureStorage.GetCloudTableClient(BIConst.Global);
- blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public", BIConst.Global);
- serBusClient = _serviceBus.GetServiceBusClient(BIConst.Global); //暂未确定使用默认
- //activeTask = _configuration.GetValue<string>("GlobalAzure:ServiceBus:ActiveTask"); //暂未确定使用默认
- }
- var table = tableClient.GetTableReference("IESLogin");
- var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{_oldId}", new PartitionKey("AreaSetting"));
- if (responseSet.Status == 200)
- {
- using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
- AreaSetting delSet = fileJson.ToObject<AreaSetting>();
- if (!string.IsNullOrEmpty(delSet.accessConfig))
- return Ok(new { state = 401, msg = "区域已经规定了,不能切换能能力" });
- }
- //保存引用记录
- //await table.SaveOrUpdate<AreaQuoteRecord>(new AreaQuoteRecord() { PartitionKey = "QuoteRecord", RowKey = $"{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}", areaId = $"{_oldId}", quoteId = $"{_newId}", quoteName = $"{newName}", standard = $"{_newStandard}" });
- List<string> abilityIds = new List<string>(); //册别的ID集合
- //查询册别信息
- 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}") }))
- {
- abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
- }
- //删除册别
- if (abilityIds.IsNotEmpty())
- {
- var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{_oldStandard}");
- }
- List<string> abilityTaskIds = new List<string>(); //章节ID集合
- 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}") }))
- {
- abilityTaskIds.Add(item.id); //查询出来的章节信息ID添加到战绩集合
- }
- //删除章节
- if (abilityTaskIds.IsNotEmpty())
- {
- var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{_oldStandard}");
- }
- List<Task<ItemResponse<Ability>>> abilities = new List<Task<ItemResponse<Ability>>>(); //存储册别数据
- List<Task<ItemResponse<AbilityTask>>> abilityTasks = new List<Task<ItemResponse<AbilityTask>>>(); //存储章节
- //查询要复制区域的能力标准点
- 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}") }))
- {
- if (!string.IsNullOrEmpty(item.blob))
- {
- item.blob = item.blob.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
- };
- item.standard = $"{_oldStandard}";
- item.code = $"Ability-{_oldStandard}";
- item.school = $"{_oldStandard}";
- //添加区能力标准点
- abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
- }
- try
- {
- if (abilities.Count < 256)
- {
- await Task.WhenAll(abilities);
- }
- else
- {
- int pages = (abilities.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(tempAbility);
- }
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
- }
- try
- {
- //微能力点
- 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}") }))
- {
- List<Tnode> tnodes = new();
- foreach (Tnode tnode in atask.children)
- {
- if (tnode.rnodes != null)
- {
- List<Rnode> rnodes = new();
- foreach (Rnode rnode in tnode.rnodes)
- {
- if (!string.IsNullOrEmpty($"{rnode.link}"))
- {
- rnode.link = rnode.link.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
- }
- rnodes.Add(rnode);
- }
- tnode.rnodes = rnodes;
- }
- tnodes.Add(tnode);
- }
- atask.children = tnodes;
- atask.code = $"AbilityTask-{_oldStandard}";
- atask.standard = $"{_oldStandard}";
- atask.codeval = $"{_oldStandard}";
- ////添加区能力标准点中的节点
- //abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}"));
- }
- }
- catch
- {
- return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
- }
- StandardFile saveFile = new();
- //新政策文件
- 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") }))
- {
- if (standardFile != null)
- {
- standardFile.standard = $"{_oldStandard}";
- standardFile.id = $"{_oldId}";
- saveFile = standardFile;
- }
- }
- StandardFile tempFile = new();
- try
- {
- tempFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>(saveFile.id, new PartitionKey("StandardFile"));
- }
- catch
- {
- }
- if (tempFile.id != null)
- {
- if (tempFile.id.Equals(saveFile.id))
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<StandardFile>(saveFile, saveFile.id, new PartitionKey("StandardFile")); //直接替换以前的数据
- else
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
- }
- //新的区域设置
- AreaSetting saveSetting = new AreaSetting();
- 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") }))
- {
- if (areaSetting != null)
- {
- areaSetting.accessConfig = null;
- areaSetting.id = $"{_oldId}";
- saveSetting = areaSetting;
- }
- }
- AreaSetting tempSetting = new();
- try
- {
- tempSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(saveSetting.id, new PartitionKey("StandardFile"));
- }
- catch
- {
- }
- if (tempSetting.id != null)
- {
- if (tempSetting.id.Equals(saveSetting.id))
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReplaceItemAsync<AreaSetting>(saveSetting, saveSetting.id, new PartitionKey($"AreaSetting")); //直接替换以前的数据
- else
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting")); //需要删除原来的区域设置数据在进行添加
- }
- //发送消息分区键
- string partitionCode = "DelBeforeCopyAbility-mark";
- //执行复制操作
- BatchCopyFile batchCopyFile = new BatchCopyFile();
- batchCopyFile.blobCntr = "teammodelos";
- batchCopyFile.oldFileName = $"{_newStandard}";
- batchCopyFile.newFileName = $"{_oldStandard}";
- batchCopyFile.tmdid = $"{_tmdId}";
- batchCopyFile.tmdIds = new List<string> { $"{ _tmdId}" };
- batchCopyFile.codeKey = partitionCode;
- batchCopyFile.tmdName = $"{_tmdName}";
- var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
- messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
- try
- {
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制 单一
- await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile); //先执行删除操作,在执行复制
- }
- catch (Exception)
- {
- return Ok(new { state = 201 ,msg = "能力点复制成功,复制能力点的文件失败," });
- }
- //发送消息实体
- Notification notification = new Notification
- {
- hubName = "hita",
- type = "msg",
- from = $"BI:{_option.Location}:private",
- to = new List<string> { $"{ _tmdId}" },
- label = $"{partitionCode}_start",
- body = new { location = _option.Location, biz = partitionCode, tmdid = $"{_tmdId}", tmdname = $"{_tmdName}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
- expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
- };
- var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
- var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
- var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
- var location = _option.Location;
- await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //发送站内发送消息
- //保存操作记录
- //await _azureStorage.SaveBILog("area-cut", $"{_tmdName}【{_tmdId}】已操作【{_oldStandard}】切换至{_newStandard}微能力点,复制标准:{_newStandard}", _dingDing, httpContext: HttpContext);
- await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "area-cut", $"{_tmdName}【{_tmdId}】已操作【{_oldStandard}】切换至{_newStandard}微能力点,复制标准:{_newStandard}", _dingDing, httpContext: HttpContext);
- return Ok(new { state = 200 });
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"BI,{_option.Location} batcharea/cut-standard \n {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- return BadRequest();
- }
- }
- /// <summary>
- /// 删除区域和区域的册别、能力点、区域文件、区域设置
- /// </summary>
- /// <param name="jsonElement"></param>
- /// <returns></returns>
- [HttpPost("del-area")]
- public async Task<IActionResult> DelArea(JsonElement jsonElement)
- {
- if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
- if (!jsonElement.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
- jsonElement.TryGetProperty("site", out JsonElement site);
- var blobClient = _azureStorage.GetBlobContainerClient(containerName: "teammodelos");
- var cosmosClient = _azureCosmos.GetCosmosClient();
- if ($"{site}".Equals(BIConst.Global))
- {
- cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
- blobClient = _azureStorage.GetBlobContainerClient(containerName: "teammodelos", BIConst.Global);
- }
- var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{areaId}", new PartitionKey("Base-Area"));
- if (response.Status == 200)
- {
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
- Area area = json.ToObject<Area>();
- if (area.standard == $"{standard}")
- {
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<Area>(area.id, new PartitionKey("Base-Area")); //删除区
- List<string> scIds = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c where c.areaId='{area.id}' and c.standard ='{area.standard}'", "Base");
- foreach (var item in scIds)
- {
- School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(item, new PartitionKey("Base"));
- school.areaId = "";
- school.standard = "";
- school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey("Base"));
- }
- List<string> abilityIds = new(); //册别的ID集合
- List<string> abilityTaskIds = new(); //章节ID集合
- //查询册别信息
- 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}") }))
- {
- abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
- }
- //删除册别
- if (abilityIds.IsNotEmpty())
- {
- var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityIds, $"Ability-{area.standard}");
- }
- 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}") }))
- {
- abilityTaskIds.Add(item.id); //查询出来的章节信息ID添加到战绩集合
- }
- //删除章节
- if (abilityTaskIds.IsNotEmpty())
- {
- var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{standard}");
- }
- //区域政策文件
- StandardFile delFile = new();
- var responseFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("StandardFile"));
- if(responseFile.Status == 200)
- {
- using var fileJson = await JsonDocument.ParseAsync(responseFile.ContentStream);
- delFile = fileJson.ToObject<StandardFile>();
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(delFile.id, new PartitionKey("StandardFile"));
- }
- //区域设置
- AreaSetting delSet = new();
- var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("AreaSetting"));
- if (responseSet.Status == 200)
- {
- using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
- delSet = fileJson.ToObject<AreaSetting>();
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(delSet.id, new PartitionKey("AreaSetting"));
- }
- List<object> fileobj = new();
- //先删除原有的文件
- List<Task<Response<bool>>> DelList = new List<Task<Response<bool>>>();
- await foreach (BlobItem blobItem in blobClient.GetBlobsAsync(BlobTraits.None, BlobStates.None, $"yxpt/{area.standard}/"))
- {
- fileobj.Add(blobItem.Name);
- DelList.Add(blobClient.GetBlobBaseClient(blobItem.Name).DeleteIfExistsAsync());
- }
- if (DelList.Count <= 256)
- {
- await Task.WhenAll(DelList);
- }
- else
- {
- int pages = (DelList.Count + 255) / 256;
- for (int i = 0; i < pages; i++)
- {
- List<Task<Response<bool>>> delList = DelList.Skip((i) * 256).Take(256).ToList();
- await Task.WhenAll(delList);
- }
- }
- return Ok(new { state = 200,area, scIds, abilityIds, abilityTaskIds, delFile, delSet, fileobj });
- }
- else return Ok(new { state = 400, msg = "id和standard不匹配!" });
- }
- else return Ok(new { state = 404,msg="依据Id未找到该区!" });
- }
- /// <summary>
- /// 区域列表
- /// </summary>
- public record RecArea
- {
- public string id { get; set; }
- public string code { get; set; }
- public string pk { get; set; }
- public string name { get; set; }
- public string provCode { get; set; }
- public string provName { get; set; }
- public string cityCode { get; set; }
- public string cityName { get; set; }
- public string standard { get; set; }
- public string standardName { get; set; }
- public string institution { get; set; }
- public int schoolCount { get; set; }
- public bool cutArea { get; set; } = false;
- public List<AreaQuoteRecord> aquoteRec { get; set; } = new List<AreaQuoteRecord>();
- }
- }
- }
|