|
@@ -111,7 +111,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
[HttpPost("get-areastics")]
|
|
|
public async Task<IActionResult> GetAreaStics(JsonElement jsonElement)
|
|
|
{
|
|
|
- if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ jsonElement.TryGetProperty("areaId", out JsonElement areaId);
|
|
|
//jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
|
|
|
var (dayS, dayE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
|
|
|
var (weekS, weekE) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
|
|
@@ -161,14 +161,25 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
List<AreaStudy> trains = new();
|
|
|
|
|
|
AreaSetting setting = null;
|
|
|
- try
|
|
|
- {
|
|
|
- setting = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemAsync<AreaSetting>($"{areaId}", new PartitionKey("AreaSetting"));
|
|
|
- }
|
|
|
- catch (CosmosException)
|
|
|
+
|
|
|
+
|
|
|
+ string oftenSql = "select value(count(c.id)) from c";
|
|
|
+ string scSql = "";
|
|
|
+ if (!string.IsNullOrEmpty($"{areaId}"))
|
|
|
{
|
|
|
- setting = null;
|
|
|
+ scSql = $"select value(c.id) from c where c.areaId='{areaId}'";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ setting = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemAsync<AreaSetting>($"{areaId}", new PartitionKey("AreaSetting"));
|
|
|
+ }
|
|
|
+ catch (CosmosException)
|
|
|
+ {
|
|
|
+ setting = null;
|
|
|
+ }
|
|
|
}
|
|
|
+ else
|
|
|
+ scSql = "select value(c.id) from c where c.areaId = null or c.areaId = ''";
|
|
|
+
|
|
|
if (setting == null)
|
|
|
{
|
|
|
setting = new AreaSetting
|
|
@@ -181,10 +192,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
lessonMinutes = 45,
|
|
|
};
|
|
|
}
|
|
|
-
|
|
|
- string oftenSql = "select value(count(c.id)) from c";
|
|
|
- string scSql = $"{oftenSql} where c.areaId='{areaId}'";
|
|
|
- List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", $"select value(c.id) from c where c.areaId='{areaId}'", "Base");
|
|
|
+ List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql, "Base");
|
|
|
if (scIds.Count > 0)
|
|
|
{
|
|
|
string weekWhereSql = $"c.createTime >= {weekS} and c.createTime <= {weekE}";
|