Bladeren bron

完善学校列表结构

Li 2 jaren geleden
bovenliggende
commit
48c4d1a353
1 gewijzigde bestanden met toevoegingen van 24 en 3 verwijderingen
  1. 24 3
      TEAMModelBI/Controllers/Census/SchoolController.cs

+ 24 - 3
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -694,7 +694,7 @@ namespace TEAMModelBI.Controllers.Census
         {
             var cosmosClient = _azureCosmos.GetCosmosClient();
             List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
-
+            List<BIRelation> scInfos = new();
             foreach (var itemId in scId)
             {
                 BIRelation bIRelation = null;
@@ -733,12 +733,33 @@ namespace TEAMModelBI.Controllers.Census
                         upDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                     };
 
+                    var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("ProductSum"));
+                    if (response.Status == 200)
+                    {
+                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
+                        {
+                            List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
+                            bIRelation.serial = serials;
+                        }
+                        if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
+                        {
+                            List<string> services = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
+                            bIRelation.service = services;
+                        }
+                        if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
+                        {
+                            List<string> hards = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
+                            bIRelation.hard = hards;
+                        }
+                    }
+                    bIRelation = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<BIRelation>(bIRelation, new PartitionKey("BIRel"));
                 }
 
+                scInfos.Add(bIRelation);
             }
 
-
-            return Ok(new { state = 200 });
+            return Ok(new { state = RespondCode.Ok, cnt = scId.Count, scInfos });
         }