Ver código fonte

优化版本报错的问题。

Li 2 anos atrás
pai
commit
cbbcfb5f33

+ 2 - 2
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -1721,8 +1721,8 @@ namespace TEAMModelBI.Controllers.BITest
             var cosmosClient = _azureCosmos.GetCosmosClient();
             var cosmosClient = _azureCosmos.GetCosmosClient();
             if (!jsonElement.TryGetProperty("scId", out JsonElement scId)) return BadRequest();
             if (!jsonElement.TryGetProperty("scId", out JsonElement scId)) return BadRequest();
 
 
-            List<string> server = new();
-            _ = BISchoolService.UpSchoolEdition(cosmosClient, _dingDing, server, "hbcn");
+            List<string> server = new() { "YMPCVCIM" };
+            _ = BISchoolService.UpSchoolEdition(cosmosClient, _dingDing, server, "habook");
 
 
             return Ok(new { state = 200 });
             return Ok(new { state = 200 });
         }
         }

+ 22 - 4
TEAMModelOS.SDK/Models/Service/BI/BISchoolService.cs

@@ -5,6 +5,7 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Models.Cosmos;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 
 
 namespace TEAMModelOS.SDK.Models.Service.BI
 namespace TEAMModelOS.SDK.Models.Service.BI
@@ -25,22 +26,39 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(id, new PartitionKey("Base"));
                 School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(id, new PartitionKey("Base"));
                 int edition = 0;
                 int edition = 0;
                 if (school.size <= 100 && school.scale == 0)
                 if (school.size <= 100 && school.scale == 0)
-                    edition = 1;
+                {
+                    edition = 1; 
+                }
                 else if (school.size >= 300 && school.scale >= 500 && server.Contains("YMPCVCIM"))
                 else if (school.size >= 300 && school.scale >= 500 && server.Contains("YMPCVCIM"))
+                { 
                     edition = 2;
                     edition = 2;
+                }
                 else if (school.size >= 300 && school.scale >= 1000 && server.Contains("YMPCVCIM") && server.Count > 2)
                 else if (school.size >= 300 && school.scale >= 1000 && server.Contains("YMPCVCIM") && server.Count > 2)
-                    edition = 3;
+                { 
+                    edition = 3; 
+                }
 
 
+                if (edition == 0)
+                {
+                    edition = 1;
+                }
                 if (school.edition != null)
                 if (school.edition != null)
                 {
                 {
                     school.edition.current = edition;
                     school.edition.current = edition;
                     if (school.edition.record < edition)
                     if (school.edition.record < edition)
+                    {
                         school.edition.record = edition;
                         school.edition.record = edition;
+                    }
                 }
                 }
                 else
                 else
                 {
                 {
-                    school.edition.current = edition;
-                    school.edition.record = edition;
+                    Edition tempEdition = new()
+                    {
+                        current = edition,
+                        record = edition
+                    };
+
+                    school.edition = tempEdition;
                 }
                 }
                 await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, id, new PartitionKey("Base"));
                 await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, id, new PartitionKey("Base"));
                 BIRelation biRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<BIRelation>(id, new PartitionKey("BIRel"));
                 BIRelation biRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<BIRelation>(id, new PartitionKey("BIRel"));