Преглед на файлове

处理查询学校列表总数问题

Li преди 2 години
родител
ревизия
ab28f056b1
променени са 2 файла, в които са добавени 40 реда и са изтрити 2 реда
  1. 23 2
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs
  2. 17 0
      TEAMModelBI/Controllers/BISchool/SchoolController.cs

+ 23 - 2
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -36,6 +36,7 @@ using DocumentFormat.OpenXml.Spreadsheet;
 using DocumentFormat.OpenXml.Wordprocessing;
 using DocumentFormat.OpenXml.Bibliography;
 using HTEXLib;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelBI.Controllers.BISchool
 {
@@ -528,7 +529,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 List<AssistSchool> schoolAssists = new(); //返回学校列表集合
                 List<string> schoolIds = new();
                 StringBuilder stringBuilder = new("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c ");
-                scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", "select value(count(c.id)) from c", "Base");
+                StringBuilder scCntSql = new($"select value(count(c.id)) from c");
                 if (jsonElement.TryGetProperty("pageSize", out JsonElement jsonPageSize))
                 {
                     if (!jsonPageSize.ValueKind.Equals(JsonValueKind.Undefined) && !jsonPageSize.ValueKind.Equals(JsonValueKind.Null) && jsonPageSize.TryGetInt32(out int tempPageSize))
@@ -548,10 +549,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!string.IsNullOrEmpty($"{tmdId}"))
                 {
                     schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
+                    string scsSql = BICommonWay.ManyScSql("c.school", schoolIds);
+                    scCntSql.Append(scsSql);
                 }
 
                 if (schoolIds.Count > 0)
                 {
+                    scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
                     foreach (var id in schoolIds)
                     {
                         StringBuilder sqlTxt = new($"select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c where c.id='{id}'");
@@ -570,21 +574,38 @@ namespace TEAMModelBI.Controllers.BISchool
                 else
                 {
                     if (!string.IsNullOrEmpty($"{scId}") && string.IsNullOrEmpty($"{name}"))
+                    {
                         stringBuilder.Append($" where c.id='{scId}'");
+                        scCntSql.Append($" where c.id='{scId}'");
+                    }
                     if (string.IsNullOrEmpty($"{scId}") && !string.IsNullOrEmpty($"{name}"))
+                    {
                         stringBuilder.Append($" where Contains(c.name,'{name}')");
+                        scCntSql.Append($" where Contains(c.name,'{name}')");
+                    }
                     if (!string.IsNullOrEmpty($"{province}") && string.IsNullOrEmpty($"{city}") && string.IsNullOrEmpty($"{dist}"))
+                    {
                         stringBuilder.Append($" where Contains(c.province,'{province}')");
-                    if (!string.IsNullOrEmpty($"{city}") && !string.IsNullOrEmpty($"{city}") && string.IsNullOrEmpty($"{dist}"))
+                        scCntSql.Append($" where  Contains(c.province,'{province}')");
+                    }
+                    if (!string.IsNullOrEmpty($"{city}") && !string.IsNullOrEmpty($"{city}") && string.IsNullOrEmpty($"{dist}")) 
+                    {
                         stringBuilder.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}')");
+                        scCntSql.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}')");
+                    }
                     if (!string.IsNullOrEmpty($"{dist}") && !string.IsNullOrEmpty($"{city}") && !string.IsNullOrEmpty($"{dist}"))
+                    {
                         stringBuilder.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}') and Contains(c.dist,'{dist}')");
+                        scCntSql.Append($" where Contains(c.province,'{province}') and Contains(c.city,'{city}') and Contains(c.dist,'{dist}')");
+                    }
 
                     if ($"{order}".Equals("desc"))
                     {
                         stringBuilder.Append(" order by c.createTime desc");
                     }
 
+                    scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", scCntSql.ToString(), "Base");
+
                     await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: pageToken, requestOptions: new QueryRequestOptions() { MaxItemCount = pageSize, PartitionKey = new PartitionKey("Base") }))
                     {
                         using var json = await JsonDocument.ParseAsync(itemSchool.ContentStream);

+ 17 - 0
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -2196,6 +2196,22 @@ namespace TEAMModelBI.Controllers.BISchool
             return Ok(new { state = RespondCode.Ok, scSimple });
         }
 
+        /// <summary>
+        /// 设置学校学段
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("set-scperiod")]
+        public async Task<IActionResult> SetScPeriod(JsonElement jsonElement) 
+        {
+
+
+
+
+            return Ok(new { state = RespondCode.Ok });
+        }
+
         #region 购买记录
 
         /// <summary>
@@ -2307,6 +2323,7 @@ namespace TEAMModelBI.Controllers.BISchool
             public Space space { get; set; }
 
         }
+        
         /// <summary>
         /// 空间
         /// </summary>