|
@@ -293,36 +293,36 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
|
|
|
var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year"); //计算今年开始/结束时间
|
|
|
|
|
|
- tecCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "SELECT value(count(c.id)) FROM c WHERE ARRAY_CONTAINS(c.roles, 'teacher', true) AND c.status = 'join'", code: $"Teacher-{schoolId}");
|
|
|
- stuCount = await JointlySingleQuery.GetValueInt(cosmosClient, "Student", code: $"Base-{schoolId}");
|
|
|
- classCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Class-{schoolId}");
|
|
|
- roomCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Room-{schoolId}");
|
|
|
+ tecCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Teacher-{schoolId}", "SELECT value(count(c.id)) FROM c WHERE ARRAY_CONTAINS(c.roles, 'teacher', true) AND c.status = 'join'");
|
|
|
+ stuCount = await JointlySingleQuery.GetValueInt(cosmosClient, "Student", $"Base-{schoolId}");
|
|
|
+ classCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Class-{schoolId}");
|
|
|
+ roomCount = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Room-{schoolId}");
|
|
|
|
|
|
string unifyTimeSql = "select value(count(c.id)) from c where c.startTime>={0} and c.startTime<={1}";
|
|
|
allLessCount = await LessonStatisWay.GetSchoolIdLessonCount(cosmosClient, $"{schoolId}");
|
|
|
- lastWeekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastWeekStart, lastWeekEnd), $"LessonRecord-{schoolId}");
|
|
|
- weekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, weekStart, lastWeekEnd), $"LessonRecord-{schoolId}");
|
|
|
- lastTermLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastTermStart, lastTermEnd), $"LessonRecord-{schoolId}");
|
|
|
- termLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, termStart, termEnd), $"LessonRecord-{schoolId}");
|
|
|
- lessYearLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, lastYearStart, lastYearEnd), $"LessonRecord-{schoolId}");
|
|
|
+ lastWeekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{schoolId}", string.Format(unifyTimeSql, lastWeekStart, lastWeekEnd));
|
|
|
+ weekLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{schoolId}", string.Format(unifyTimeSql, weekStart, lastWeekEnd));
|
|
|
+ lastTermLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{schoolId}", string.Format(unifyTimeSql, lastTermStart, lastTermEnd));
|
|
|
+ termLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{schoolId}", string.Format(unifyTimeSql, termStart, termEnd));
|
|
|
+ lessYearLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{schoolId}", string.Format(unifyTimeSql, lastYearStart, lastYearEnd));
|
|
|
yearLess = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(unifyTimeSql, yearStart, yearEnd), $"LessonRecord-{schoolId}");
|
|
|
|
|
|
//统计活动
|
|
|
foreach (var type in StaticValue.activityTypes)
|
|
|
{
|
|
|
string sqlTime = "select value(count(c.id)) from c where c.pk = '{0}' and c.school = '{1}' and c.createTime>={2} and c.createTime<={3}";
|
|
|
- allActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"select value(count(c.id)) from c where c.pk = '{type}' and c.school = '{schoolId}'");
|
|
|
- lastYearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, lastYearStart, lastYearEnd));
|
|
|
- yearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, yearStart, yearEnd));
|
|
|
- lastWeekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, lastWeekStart, lastWeekEnd));
|
|
|
- weekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", string.Format(sqlTime, type, schoolId, weekStart, weekEnd));
|
|
|
+ allActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common",$"{type}-{schoolId}", $"select value(count(c.id)) from c where c.pk = '{type}' and c.school = '{schoolId}'");
|
|
|
+ lastYearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"{type}-{schoolId}", string.Format(sqlTime, type, schoolId, lastYearStart, lastYearEnd));
|
|
|
+ yearActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"{type}-{schoolId}", string.Format(sqlTime, type, schoolId, yearStart, yearEnd));
|
|
|
+ lastWeekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"{type}-{schoolId}", string.Format(sqlTime, type, schoolId, lastWeekStart, lastWeekEnd));
|
|
|
+ weekActivity += await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"{type}-{schoolId}", string.Format(sqlTime, type, schoolId, weekStart, weekEnd));
|
|
|
}
|
|
|
|
|
|
//学校资源
|
|
|
string blobTimeSql = "select value(count(c.id)) from c where c.time>={0} and c.time<={1}";
|
|
|
- allBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", code: $"Bloblog-{schoolId}");
|
|
|
- lastYearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(blobTimeSql, lastYearStart, lastYearEnd), $"Bloblog-{schoolId}");
|
|
|
- yearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", string.Format(blobTimeSql, yearStart, yearEnd), $"Bloblog-{schoolId}");
|
|
|
+ allBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Bloblog-{schoolId}");
|
|
|
+ lastYearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Bloblog-{schoolId}", string.Format(blobTimeSql, lastYearStart, lastYearEnd));
|
|
|
+ yearBlob = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"Bloblog-{schoolId}", string.Format(blobTimeSql, yearStart, yearEnd));
|
|
|
|
|
|
//获取所有的课程记录
|
|
|
List<LessonRecord> records = new();
|
|
@@ -571,10 +571,12 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
scStats.lessStats.week = statsInfo.lesson.week;
|
|
|
scStats.lessStats.lastTerm = statsInfo.lesson.lastTerm;
|
|
|
scStats.lessStats.term = statsInfo.lesson.term;
|
|
|
+ scStats.lessStats.month = statsInfo.lesson.month;
|
|
|
+ scStats.lessStats.lastMonth = statsInfo.lesson.lastMonth;
|
|
|
scStats.lessStats.lastDayInter = statsInfo.lesson.lastDayInter;
|
|
|
scStats.lessStats.dayInter = statsInfo.lesson.dayInter;
|
|
|
- //scStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
- //scStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
+ scStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
+ scStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
scStats.lessStats.lastYear = ((int)BICommonWay.ManyDoubleMerge(lastYear.Select(s => s.lesson.year).Where(w => w.Count > 0).ToList()).Sum());
|
|
|
scStats.lessStats.lastYearInter = statsInfo.lesson.lastYearInter;
|
|
|
scStats.lessStats.yearInter = statsInfo.lesson.yearInter;
|
|
@@ -654,8 +656,8 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
|
jsonElement.TryGetProperty("role", out JsonElement role);
|
|
|
|
|
|
- if (string.IsNullOrEmpty($"{areaId}") && string.IsNullOrEmpty($"{tmdId}"))
|
|
|
- return Ok(new { stats = RespondCode.ParamsError, msg = "areaId/tmdId两者参数不能都为空!" });
|
|
|
+ //if (string.IsNullOrEmpty($"{areaId}") && string.IsNullOrEmpty($"{tmdId}"))
|
|
|
+ // return Ok(new { stats = RespondCode.ParamsError, msg = "areaId/tmdId两者参数不能都为空!" });
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
Area area = null;
|
|
@@ -755,8 +757,8 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
areaScStats.lessStats.term = statsInfo.lesson.term;
|
|
|
areaScStats.lessStats.lastDayInter = statsInfo.lesson.lastDayInter;
|
|
|
areaScStats.lessStats.dayInter = statsInfo.lesson.dayInter;
|
|
|
- //areaScStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
- //areaScStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
+ areaScStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
+ areaScStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
areaScStats.lessStats.lastYearInter = statsInfo.lesson.lastYearInter;
|
|
|
areaScStats.lessStats.yearInter = statsInfo.lesson.yearInter;
|
|
|
areaScStats.lessStats.yearInters = TimeHelper.GetYearMonth(statsInfo.lesson.yearInters, dateTime.Year, dateTime.Month);
|
|
@@ -846,12 +848,32 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
AllScStats allScStats = new();
|
|
|
List<StatsInfo> statsInfos = new();
|
|
|
DateTimeOffset dateTime = DateTimeOffset.UtcNow;
|
|
|
+ var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(dateTime.AddDays(-1)); //昨天开始时间
|
|
|
+ var (dayS, dayE) = TimeHelper.GetStartOrEnd(dateTime); //今天开始时间
|
|
|
+
|
|
|
+ var (lastWeekS, lastWeekE) = TimeHelper.GetStartOrEnd(dateTime, "lastweek"); //计算上周开始/结束时间
|
|
|
+ var (weekS, weekE) = TimeHelper.GetStartOrEnd(dateTime, "week"); //计算本周开始/结束时间
|
|
|
+
|
|
|
+ var (lastTermS, lastTermE) = TimeHelper.GetStartOrEnd(dateTime, "lastterm"); //计算上学期开始/结束时间
|
|
|
+ var (termS, termE) = TimeHelper.GetStartOrEnd(dateTime, "term"); //计算本学期开始/结束时间
|
|
|
+
|
|
|
+ var (lastMthS, LastmthE) = TimeHelper.GetStartOrEnd(dateTime, "lastMonth"); //上月开始/结束时间
|
|
|
+ var (mthS, mthE) = TimeHelper.GetStartOrEnd(dateTime, "month"); //本月开始/结束时间
|
|
|
+
|
|
|
+ var (lastYearS, lastYearE) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{dateTime.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
|
|
|
+ var (yearS, yearE) = TimeHelper.GetStartOrEnd(dateTime, "year"); //计算今年开始/结束时间
|
|
|
+
|
|
|
+ string sql = "select value(count(c.id)) from c ";
|
|
|
+ int areaCnt = await JointlySingleQuery.GetValueInt(cosmosClient,"Normal", "Base-Area" , sql);
|
|
|
+ int scCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", sql);
|
|
|
+ int scWeekCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {weekS} and c.createTime <= {weekE}");
|
|
|
+ int scMonthCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {mthS} and c.createTime <= {mthE}");
|
|
|
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StatsInfo>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Statistics") }))
|
|
|
{
|
|
|
statsInfos.Add(item);
|
|
|
}
|
|
|
- var areaCnt = statsInfos.GroupBy(g => g.areaId).ToList().Select(s=>s.Where(w=>w.areaId.Equals(s.Key)));
|
|
|
+ var areaGrup = statsInfos.GroupBy(g => g.areaId).ToList().Select(s=>s.Where(w=>w.areaId.Equals(s.Key)));
|
|
|
|
|
|
StatsInfo statsInfo = null;
|
|
|
statsInfo = SchoolStatsWay.GetAreaStats(cosmosClient, _httpTrigger, _option, statsInfos);
|
|
@@ -881,8 +903,8 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
allScStats.lessStats.term = statsInfo.lesson.term;
|
|
|
allScStats.lessStats.lastDayInter = statsInfo.lesson.lastDayInter;
|
|
|
allScStats.lessStats.dayInter = statsInfo.lesson.dayInter;
|
|
|
- //allScStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
- //allScStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
+ allScStats.lessStats.lastMonthInter = statsInfo.lesson.lastMonthInter;
|
|
|
+ allScStats.lessStats.monthInter = statsInfo.lesson.monthInter;
|
|
|
allScStats.lessStats.lastYearInter = statsInfo.lesson.lastYearInter;
|
|
|
allScStats.lessStats.yearInter = statsInfo.lesson.yearInter;
|
|
|
allScStats.actStats.all = statsInfo.activity.all;
|
|
@@ -1019,10 +1041,12 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public int week { get; set; }
|
|
|
public int lastTerm { get; set; }
|
|
|
public int term { get; set; }
|
|
|
+ public int month { get; set; }
|
|
|
+ public int lastMonth { get; set; }
|
|
|
public int lastDayInter { get; set; }
|
|
|
public int dayInter { get; set; }
|
|
|
- //public int lastMonthInter { get; set; }
|
|
|
- //public int monthInter { get; set; }
|
|
|
+ public int lastMonthInter { get; set; }
|
|
|
+ public int monthInter { get; set; }
|
|
|
public int lastYearInter { get; set; }
|
|
|
public int yearInter { get; set; }
|
|
|
}
|