Browse Source

测试数据合并

CrazyIter_Bin 4 years ago
parent
commit
b085fe234f

+ 5 - 5
TEAMModelFunction/ActivityHttpTrigger.cs

@@ -403,17 +403,17 @@ namespace TEAMModelFunction
             try {
                 var client = _azureCosmos.GetCosmosClient();
                 List<ItemInfo> items = new List<ItemInfo>();
-                var queryslt = $"SELECT  value(c) FROM c ";
-
+                var queryslt = $"SELECT  value(c) FROM c where  c.pid = null ";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
                 {
 
                     items.Add(item);
                 }
                 List<ItemCond> itemConds = new List<ItemCond>();
-                items.GroupBy(x => x.periodId).ToList().ForEach(x => {
-                    ItemCond cond = new ItemCond() { id = x.Key, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
-                    x.ToList().ForEach(y => {
+                items.GroupBy(x => x.periodId).Select(y=>new {key= y.Key,list=y.ToList() }).ToList().ForEach(z => {
+                    ItemCond cond = new ItemCond() { id = z.key, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
+                    z.list.ForEach(y => {
+                        
                         ItemService.CountItemCond(y, null, cond);
                     });
 

+ 2 - 1
TEAMModelOS.SDK/Models/Service/ItemService.cs

@@ -84,7 +84,7 @@ namespace TEAMModelOS.Services.Common
                     cond.grades.Add(new GradeCount { id = x, count = count });
                 }
             });
-            cond.count = cond.grades.Select(x=>x.count).Sum();
+         
             SubjectCount subject = cond.subjects.Where(x => x.id == key).FirstOrDefault();
             if (subject == null)
             {
@@ -118,6 +118,7 @@ namespace TEAMModelOS.Services.Common
                     y.types[type]["field"][$"{level}"] = y.types[type]["field"][$"{field}"] + count;
                 }
             });
+        //var aaa = cond.subjects.Select(x=>x.types.Values).ToList();
         }
     }
 }

+ 4 - 5
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -87,17 +87,16 @@ namespace TEAMModelOS.Controllers.XTest
             {
                 var client = _azureCosmos.GetCosmosClient();
                 List<ItemInfo> items = new List<ItemInfo>();
-                var queryslt = $"SELECT  value(c) FROM c ";
-
+                var queryslt = $"SELECT  value(c) FROM c where  c.pid = null ";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-hbcn") }))
                 {
 
                     items.Add(item);
                 }
                 List<ItemCond> itemConds = new List<ItemCond>();
-                items.GroupBy(x => x.periodId).ToList().ForEach(x => {
-                    ItemCond cond = new ItemCond() { id = x.Key, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
-                    x.ToList().ForEach(y => {
+                items.GroupBy(x => x.periodId).Select(y => new { key = y.Key, list = y.ToList() }).ToList().ForEach(z => {
+                    ItemCond cond = new ItemCond() { id = z.key, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = z.list.Count, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
+                    z.list.ForEach(y => {
                         ItemService.CountItemCond(y, null, cond);
                     });