فهرست منبع

优化查询未加区的学校

Li 2 سال پیش
والد
کامیت
5c7557632f

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

@@ -241,6 +241,13 @@ namespace TEAMModelBI.Controllers.BINormal
                         return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
                 }
 
+                //查询新的区级名称是否存在
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.name='{name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
+                {
+                    if (item.name.Equals($"{standard}"))
+                        return Ok(new { state = 1, message = "区级名称相同,请检测区级名称!" });
+                }
+
                 //区级的ID
                 string areaId = Guid.NewGuid().ToString();
                 Area addArea = new()

+ 1 - 1
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -114,7 +114,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 }
                 else
                 {
-                    sqltxt.Append($" WHERE c.areaId ='' and c.standard = ''");
+                    sqltxt.Append($" WHERE c.areaId ='' or c.areaId = null");
                 }
 
                 List<NotAreaSchool> tempNotAreaSchools = new();

+ 23 - 0
TEAMModelBI/Controllers/Census/PaperController.cs

@@ -113,9 +113,17 @@ namespace TEAMModelBI.Controllers.Census
         [HttpPost("copy-infos")]
         public async Task<IActionResult> CopyInfos(JsonElement jsonElement) 
         {
+            if (!jsonElement.TryGetProperty("papers", out JsonElement jsPapers)) return BadRequest();
 
+            List<CopyPaper> papers = jsPapers.ToObject<List<CopyPaper>>();
 
+            var cosmosClinet = _azureCosmos.GetCosmosClient();
+            foreach (var cItem in papers)
+            {
+                Paper paper = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Paper>(cItem.oldId, new PartitionKey($"Paper-{cItem.oldSc}"));
+                
 
+            }
 
             return Ok(new { state = RespondCode.Ok});
         }
@@ -455,5 +463,20 @@ namespace TEAMModelBI.Controllers.Census
             public Dictionary<string, long> yearPaper { get; set; }
         }
 
+
+        public record CopyPaper 
+        {
+            public string oldId { get; set; }
+            public string oldSc { get; set; }
+            public string newId { get; set; }
+            public string newSc { get; set; }
+            public string newPrdId { get; set; }
+            public string newSubId { get; set; }
+            public string newGrId { get; set; }
+            public string isKlogger { get; set; }
+
+
+        }
+
     }
 }