|
|
@@ -46,6 +46,30 @@ public class ReportStatsController {
|
|
|
Child child = childMapper.selectById(childId);
|
|
|
result.put("totalPoints", child != null ? child.getTotalPoints() : 0);
|
|
|
|
|
|
+ // 月活跃天数(当月有积分变动的天数)
|
|
|
+ Calendar monthCal = Calendar.getInstance();
|
|
|
+ monthCal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ monthCal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ monthCal.set(Calendar.MINUTE, 0);
|
|
|
+ monthCal.set(Calendar.SECOND, 0);
|
|
|
+ monthCal.set(Calendar.MILLISECOND, 0);
|
|
|
+ Date monthStart = monthCal.getTime();
|
|
|
+
|
|
|
+ List<PointsLog> monthLogs = pointsLogMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<PointsLog>()
|
|
|
+ .eq(PointsLog::getChildId, childId)
|
|
|
+ .ge(PointsLog::getCreatedAt, monthStart)
|
|
|
+ .orderByAsc(PointsLog::getCreatedAt));
|
|
|
+
|
|
|
+ Set<String> activeDays = new HashSet<>();
|
|
|
+ SimpleDateFormat daySdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ for (PointsLog log : monthLogs) {
|
|
|
+ if (log.getCreatedAt() != null) {
|
|
|
+ activeDays.add(daySdf.format(log.getCreatedAt()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("monthActiveDays", activeDays.size());
|
|
|
+
|
|
|
// 任务统计
|
|
|
List<Task> tasks = taskService.getAllTasksByChild(childId);
|
|
|
long taskTotal = tasks.size();
|