Browse Source

修改统计返回类型的问题
添加新的查询统计方法

Li 2 năm trước cách đây
mục cha
commit
6d92c2d278

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

@@ -1390,7 +1390,7 @@ namespace TEAMModelBI.Controllers.BISchool
                     yearCnt.lessCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", selessSql);
 
                     string interactSql = $"select value(sum(c.clientInteractionAverge)) from c where c.pk='LessonRecord' and {scSql} and c.startTime >= { item.start} and c.startTime <= {item.end}";
-                    yearCnt.interCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", interactSql);
+                    yearCnt.interCnt = await CommonFind.GetSqlValueDoubleCounnt(cosmosClient, "School", interactSql);
 
                     string mthActSql = $"and {scSql} and c.createTime >= {item.start} and c.createTime <= {item.end}";
                     yearCnt.actCnt = await ActivityWay.GetCnt(cosmosClient, condSql: mthActSql);

+ 41 - 0
TEAMModelBI/Tool/CommonFind.cs

@@ -219,6 +219,47 @@ namespace TEAMModelBI.Tool
             return totals;
         }
 
+        /// <summary>
+        /// 单个容器数据统计  double
+        /// </summary>
+        /// <param name="cosmosClient"></param>
+        /// <param name="container"></param>
+        /// <param name="SqlTxt"></param>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public static async Task<double> GetSqlValueDoubleCounnt(CosmosClient cosmosClient, string container, string SqlTxt, string code = null)
+        {
+            double totals = 0;
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+            {
+                totals = item;
+            }
+
+            return totals;
+        }
+
+        /// <summary>
+        /// 多个容器数据统计  double
+        /// </summary>
+        /// <param name="cosmosClient"></param>
+        /// <param name="container"></param>
+        /// <param name="SqlTxt"></param>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public static async Task<double> GetSqlValueDoubleCounnt(CosmosClient cosmosClient, List<string> containers, string SqlTxt, string code = null)
+        {
+            double totals = 0;
+            foreach (var container in containers)
+            {
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", container).GetItemQueryIterator<double>(queryText: SqlTxt, requestOptions: string.IsNullOrEmpty(code) ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
+                {
+                    totals += item;
+                }
+            }
+
+            return totals;
+        }
+
         /// <summary>
         /// 通过SQL 语句返回实体信息
         /// </summary>

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/BI/BICommon/MonthStartEnd.cs

@@ -70,7 +70,7 @@ namespace TEAMModelOS.SDK.Models
     {
         public string name { get; set; }
         public int lessCnt { get; set; }
-        public int interCnt { get; set; }
+        public double interCnt { get; set; }
         public int actCnt { get; set; }
     }