Ver código fonte

创建完整版学区的初始化信息,和同步两个区的信息到完整版学区中

Li 2 anos atrás
pai
commit
269a30e484

+ 281 - 0
TEAMModelBI/Controllers/BINormal/BatchAreaController.cs

@@ -32,6 +32,8 @@ using System.Text;
 using DocumentFormat.OpenXml.Bibliography;
 using Microsoft.Extensions.Hosting;
 using Microsoft.AspNetCore.Hosting;
+using static TEAMModelBI.Controllers.RepairApi.InitialAreaController;
+using TEAMModelOS.SDK.Context.Constant;
 
 namespace TEAMModelBI.Controllers.BINormal
 {
@@ -1005,6 +1007,285 @@ namespace TEAMModelBI.Controllers.BINormal
             else return Ok(new { state = 404,msg="依据Id未找到该区!" });
         }
 
+
+        /// <summary>
+        /// 同步两个区到新的区中
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "admin")]
+        [HttpPost("cut-full-statndard")]
+        public async Task<IActionResult> CutFullStandard(JsonElement jsonElement)
+        {
+            string _oldId = "bde5c011-2ae4-461a-b46c-5483ba72ae45";
+            string _oldStandard = "standard27";
+            string standardFileId = "02944f32-f534-3397-ea56-e6f1fc6c3714";
+            string standard = "standard2";
+
+            List<CopyStandard> copyStand = new()
+            {
+                new CopyStandard() { id = standardFileId, standard = standard },
+                new CopyStandard() { id = "99a4a33b-e21b-44ac-80a1-b31dc40496e0", standard = "standard3" }
+            };
+
+            var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+            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");//秘钥地址
+
+            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 = "区域已经规定了,不能切换能能力" });
+            }
+
+            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<AbilityTask>>> abilityTasks = new();  //存储章节
+
+            List<string> repeatAbilityId = new();
+            List<string> repeatAbilityTaskId = new();
+
+            foreach (var newstand in copyStand)
+            {
+                try
+                {
+                    //查询要复制区域的能力标准点 
+                    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}") }))
+                    {
+                        if (!string.IsNullOrEmpty(item.blob))
+                            item.blob = item.blob.Replace($"/{newstand.standard}/", $"/{_oldStandard}/");
+
+                        item.standard = $"{_oldStandard}";
+                        item.code = $"Ability-{_oldStandard}";
+                        item.school = $"{_oldStandard}";
+
+                        //添加区能力标准点
+                        //abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
+                        //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}"));
+
+                        var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(item.id, new PartitionKey(item.code));
+                        if (respond.Status != 200)
+                            abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
+                        else
+                            repeatAbilityId.Add(item.id);
+                    }
+                }
+                catch
+                {
+                    return Ok(new { state = 200, msg = "创区成功,能力标准点复制失败,遗留数据影响!" });
+                }
+
+                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-{newstand.standard}") }))
+                    {
+                        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($"/{newstand.standard}/", $"/{_oldStandard}/");
+                                    }
+                                    rnodes.Add(rnode);
+                                }
+                                tnode.rnodes = rnodes;
+                            }
+                            tnodes.Add(tnode);
+                        }
+
+                        atask.children = tnodes;
+                        atask.code = $"AbilityTask-{_oldStandard}";
+                        atask.standard = $"{_oldStandard}";
+                        atask.codeval = $"{_oldStandard}";
+
+                        var respond = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(atask.id, new PartitionKey(atask.code));
+                        if (respond.Status != 200)
+                            ////添加区能力标准点中的节点 
+                            //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}"));
+                        else
+                            repeatAbilityTaskId.Add(atask.id);
+                    }
+                }
+                catch
+                {
+                    return Ok(new { state = 200, msg = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
+                }
+
+                //发送消息分区键
+                string partitionCode = "DelBeforeCopyAbility-mark";
+
+                //执行复制操作
+                BatchCopyFile batchCopyFile = new();
+                batchCopyFile.blobCntr = "teammodelos";
+                batchCopyFile.oldFileName = $"{newstand.standard}";
+                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()
+                {
+                    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); //发送站内发送消息
+            }
+
+            StandardFile saveFile = new();
+            //新政策文件
+            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") }))
+            {
+                if (standardFile != null)
+                {
+                    standardFile.standard = $"{_oldStandard}";
+                    standardFile.id = $"{_oldId}";
+
+                    saveFile = standardFile;
+                }
+            }
+
+            StandardFile tempFile = new();
+            if (saveFile.id != null)
+            {
+                var respFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveFile.id, new PartitionKey("StandardFile"));
+                if (respFile.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(respFile.ContentStream);
+                    tempFile = json.ToObject<StandardFile>();
+                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<StandardFile>(tempFile.id, new PartitionKey("StandardFile"));
+                }
+
+                tempFile = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveFile, new PartitionKey($"StandardFile")); // 需要删除原来的政策文件数据在进行添加
+            }
+
+            //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();
+            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") }))
+            {
+                if (areaSetting != null)
+                {
+                    areaSetting.accessConfig = null;
+                    areaSetting.id = $"{_oldId}";
+
+                    saveSetting = areaSetting;
+                }
+            }
+
+            AreaSetting tempSetting = new();
+            if (saveSetting.id != null)
+            {
+                var respSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(saveSetting.id, new PartitionKey("AreaSetting"));
+                if (respSetting.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(respSetting.ContentStream);
+                    tempSetting = json.ToObject<AreaSetting>();
+                    await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemAsync<AreaSetting>(tempFile.id, new PartitionKey("AreaSetting"));
+                }
+
+                tempSetting = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(saveSetting, new PartitionKey($"AreaSetting"));  //需要删除原来的区域设置数据在进行添加
+            }
+
+            //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"));  //需要删除原来的区域设置数据在进行添加
+            //}
+
+            return Ok(new { state = RespondCode.Ok, repeatAbilityId, repeatAbilityTaskId });
+        }
+
         /// <summary>
         /// 区域列表
         /// </summary>

+ 189 - 9
TEAMModelBI/Controllers/RepairApi/InitialAreaController.cs

@@ -18,6 +18,12 @@ using TEAMModelOS.SDK.Models;
 using Azure.Cosmos;
 using System;
 using System.Collections.Generic;
+using TEAMModelOS.SDK.Models.Cosmos.Common;
+using System.Linq;
+using Pipelines.Sockets.Unofficial.Arenas;
+using TEAMModelOS.SDK.Models.Cosmos.BI;
+using TEAMModelBI.Filter;
+using HTEXLib.COMM.Helpers;
 
 namespace TEAMModelBI.Controllers.RepairApi
 {
@@ -55,8 +61,9 @@ namespace TEAMModelBI.Controllers.RepairApi
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
+        [ProducesDefaultResponseType]
         [HttpPost("create-full-version")]
-        public async Task<IActionResult> CreateFullVersion(JsonElement jsonElement) 
+        public async Task<IActionResult> CreateFullVersion(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("name", out JsonElement name)) return BadRequest();
             jsonElement.TryGetProperty("provCode", out JsonElement provCode);
@@ -67,15 +74,12 @@ namespace TEAMModelBI.Controllers.RepairApi
             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";
+            List<CopyStandard> copyStand = new();
+            if (!string.IsNullOrEmpty($"{oldStandard}"))
+                copyStand = oldStandard.ToObject<List<CopyStandard>>();
 
             var cosmosClient = _azureCosmos.GetCosmosClient();  //数据库连接
             var tableClient = _azureStorage.GetCloudTableClient();
@@ -117,7 +121,6 @@ namespace TEAMModelBI.Controllers.RepairApi
                 institution = $"{institution}"
             };
 
-
             #region  区级管理员
 
             var coreUser = await _coreAPIHttpService.GetUserInfo(new Dictionary<string, string> { { "key", $"{areadAdmin}" } }, _option.Location, _configuration);
@@ -157,12 +160,189 @@ namespace TEAMModelBI.Controllers.RepairApi
 
             #endregion
 
+            //创建区域
+            await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync<Area>(addArea, new PartitionKey("Base-Area"));
+
+            //消息分区键
+            string partitionCode = "copyAbility-mark";
+
+            #region 复制微能力点到新区
+
+            List<Task<ItemResponse<Ability>>> abilities = new();      //存储区域数据
+            List<Task<ItemResponse<AbilityTask>>> abilityTasks = new();  //存储章节
+
+            Area AreaS2 = null;
+            List<Area> areas = new();
+
+            await foreach (var itemArea 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") }))
+            {
+                areas.Add(itemArea);
+                AreaS2 = itemArea;
+            }
+
+            await foreach (var itemArea in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='standard3'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+            {
+                areas.Add(itemArea);
+            }
+
+            foreach (var area in areas)
+            {
+                //查询要复制区域的能力标准点 
+                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();
+                        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 = "创区成功,能力标准创建成功,微能力点复制失败,遗留数据影响!" });
+                }
+
+                //执行复制操作
+                BatchCopyFile batchCopyFile = new();
+                batchCopyFile.blobCntr = "teammodelos";
+                batchCopyFile.oldFileName = $"{area.standard}";
+                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()
+                {
+                    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); //站内发送消息
+            }
+
+            if (AreaS2 != null)
+            {
+                //新政策文件
+                await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where  c.id='{AreaS2.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='{AreaS2.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
 
             return Ok(new { sate = RespondCode.Ok });
         }
 
 
-
+        public record CopyStandard
+        {
+            public string id { get; set; }
+            public string standard { get; set; }
+            public string name { get; set; }
+        }
 
 
     }