Quellcode durchsuchen

Merge branch 'PL/develop-BI' into develop

Li vor 2 Jahren
Ursprung
Commit
996878f10e

+ 10 - 4
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -301,13 +301,14 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
-                jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
+                jsonElement.TryGetProperty("scId", out JsonElement scId);
+                jsonElement.TryGetProperty("name", out JsonElement name);
                 jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 if ($"{site}".Equals(BIConst.Global))
                     cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
-                int? pageSize = null;      //默认不指定返回大小        
+                int? pageSize = 10;      //默认不指定返回大小        
                 string continuationToken = string.Empty;     //返给前端分页token           
                 string pageToken = default;//接受前端的分页Tolen
                 bool iscontinuation = false;//是否需要进行分页查询,默认不分页
@@ -349,9 +350,14 @@ namespace TEAMModelBI.Controllers.BISchool
                 }
                 else
                 {
-                    if (!string.IsNullOrEmpty($"{_schoolCode}"))
+                    if (!string.IsNullOrEmpty($"{scId}") && string.IsNullOrEmpty($"{name}"))
                     {
-                        stringBuilder.Append($" where c.id='{_schoolCode}'");
+                        stringBuilder.Append($" where c.id='{scId}'");
+                    }
+
+                    if (string.IsNullOrEmpty($"{scId}") && !string.IsNullOrEmpty($"{name}"))
+                    {
+                        stringBuilder.Append($" where Contains(c.name,'{name}')");
                     }
 
                     await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))

+ 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);

+ 23 - 22
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -552,27 +552,28 @@ namespace TEAMModelBI.Controllers.Census
 
             foreach (var area in areaInfos)
             {
-                string scSql = $"select value(c.id) from c where c.areaId='{area.id}'";
-                List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql,"Base");
+                //string scSql = $"select value(c.id) from c where c.areaId='{area.id}'";
+                //List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql,"Base");
                 //allSize += recSchools.Select(s => s.size).Sum();
-                area.scCnt = scIds.Count;
-                int tTchCnt = 0;
-                int tStuCnt = 0;
-                if (scIds.Count > 0)
-                {
-                    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
-
-                    //查教师
-                    string tchSql = $"select value(count(c.id)) from c where c.pk='Teacher' and {scSql}";
-                    tTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
-
-                    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
-                    //查学生
-                    string stuSql = $"select value(count(c.id)) from c where c.pk='Base' and {scSql}";
-                    tStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", stuSql);
-                }
-                area.tchCnt = tTchCnt;
-                area.stuCnt = tStuCnt;
+                area.scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.areaId='{area.id}'", "Base");
+                //area.scCnt = scIds.Count;
+                //int tTchCnt = 0;
+                //int tStuCnt = 0;
+                //if (scIds.Count > 0)
+                //{
+                //    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
+
+                //    //查教师
+                //    string tchSql = $"select value(count(c.id)) from c where c.pk='Teacher' and {scSql}";
+                //    tTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
+
+                //    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
+                //    //查学生
+                //    string stuSql = $"select value(count(c.id)) from c where c.pk='Base' and {scSql}";
+                //    tStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", stuSql);
+                ////}
+                //area.tchCnt = tTchCnt;
+                //area.stuCnt = tStuCnt;
             }
 
             return Ok(new { state = RespondCode.Ok, areaInfos });
@@ -927,8 +928,8 @@ namespace TEAMModelBI.Controllers.Census
             public string standard { get; set; }
             public string standardName { get; set; }
             public int scCnt { get; set; } = 0;
-            public int tchCnt { get; set; } = 0;
-            public int stuCnt { get; set; } = 0;
+            //public int tchCnt { get; set; } = 0;
+            //public int stuCnt { get; set; } = 0;
         }
 
 

+ 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>

+ 19 - 0
TEAMModelBI/appsettings.Development.json

@@ -38,6 +38,25 @@
       "ActiveTask": "dep-active-task",
       "ItemCondQueue": "dep-itemcond"
     }
+
+    ////正式站
+    //"Storage": {
+    //  "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
+    //},
+    //"LogStorage": {
+    //  "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn"
+    //},
+    //"Cosmos": {
+    //  "ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
+    //},
+    //"Redis": {
+    //  "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
+    //},
+    //"ServiceBus": {
+    //  "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+    //  "ActiveTask": "dep-active-task",
+    //  "ItemCondQueue": "dep-itemcond"
+    //}
   },
   //国际站连接字符串  暂时是本地
   "GlobalAzure": {

+ 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; }
     }