瀏覽代碼

Merge branch 'PL/develop-BI' into develop

Li 3 年之前
父節點
當前提交
1c74b4f55f
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      TEAMModelBI/Controllers/BISchool/BatchAreaController.cs

+ 13 - 3
TEAMModelBI/Controllers/BISchool/BatchAreaController.cs

@@ -771,6 +771,16 @@ namespace TEAMModelBI.Controllers.BISchool
                 {
                     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集合
 
@@ -806,10 +816,10 @@ namespace TEAMModelBI.Controllers.BISchool
 
                     //区域设置
                     AreaSetting delSet = new();
-                    var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("StandardFile"));
+                    var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync(area.id, new PartitionKey("AreaSetting"));
                     if (responseFile.Status == 200)
                     {
-                        using var fileJson = await JsonDocument.ParseAsync(responseFile.ContentStream);
+                        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"));
                     }
@@ -837,7 +847,7 @@ namespace TEAMModelBI.Controllers.BISchool
                         }
                     }
 
-                    return Ok(new { state = 200,area, abilityIds, abilityTaskIds, delFile, delSet, fileobj });
+                    return Ok(new { state = 200,area, scIds, abilityIds, abilityTaskIds, delFile, delSet, fileobj });
                 }
                 else return Ok(new { state = 400, msg = "id和standard不匹配!" });
             }