Browse Source

优化统计接口误差问题

Li 2 years ago
parent
commit
44a54b6f59

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

@@ -995,9 +995,6 @@ namespace TEAMModelBI.Controllers.BISchool
             int yearACTCnt = 0;  //今年活动
             int lastYearACTCnt = 0;  //去年活动
 
-            int yearCnt = 0;
-            int lastCnt = 0;
-
             SchoolInfo schoolInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolInfo>($"{schoolId}", new PartitionKey("Base"));
             if (schoolInfo != null)
             {

+ 4 - 4
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -487,11 +487,11 @@ namespace TEAMModelBI.Controllers.Census
             allSize = await CommonFind.GetSqlValueCount(cosmosClient, "School", commSql,  "Base");
 
 
-            weekScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {termStart} and c.createTime >= {termEnd}", "Base");
-            monthScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {monthS} and c.createTime >= {monthE}", "Base");
+            weekScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {weekStart} and c.createTime <= {weekEnd}", "Base");
+            monthScCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.createTime >= {monthS} and c.createTime <= {monthE}", "Base");
 
-            weekTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {termStart} and c.createTime >= {termEnd}", "Base");
-            monthTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {monthS} and c.createTime >= {monthE}", "Base");
+            weekTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {weekStart} and c.createTime <= {weekEnd}", "Base");
+            monthTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Teacher", $"{commSql} where c.createTime >= {monthS} and c.createTime <= {monthE}", "Base");
 
             heCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.type = 1", "Base");
             geCount = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"{commSql} where c.type = 2", "Base");

+ 3 - 3
TEAMModelBI/Controllers/Census/LessonSticsController.cs

@@ -47,7 +47,7 @@ namespace TEAMModelBI.Controllers.Census
         }
 
         /// <summary>
-        /// 依据区级ID分析该去所有学校课例   //后端有
+        /// 依据区级ID分析该去所有学校课例   //已对接
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
@@ -57,7 +57,7 @@ namespace TEAMModelBI.Controllers.Census
         {
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
             jsonElement.TryGetProperty("site", out JsonElement site);
-            var (lWeekS, lWeekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm");
+            var (lWeekS, lWeekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
             var (monthS, monthE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
@@ -77,7 +77,7 @@ namespace TEAMModelBI.Controllers.Census
                     item.weekCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.startTime >= {lWeekS} and c.startTime <= {lWeekE}", $"LessonRecord-{item.id}");
                     item.monthCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where  c.startTime >= {monthS} and c.startTime <= {monthE}", $"LessonRecord-{item.id}");
                 }
-                areaSchools = areaSchools.Where(w => w.allCnt != 0 && w.weekCnt != 0 && w.monthCnt != 0).ToList();
+                areaSchools = areaSchools.Where(w => (w.allCnt != 0 || w.weekCnt != 0 || w.monthCnt != 0)).ToList();
             }
 
             return Ok(new { state = RespondCode.Ok, areaSchools });