后台-sud小游戏时长统计-导出
This commit is contained in:
@@ -49,8 +49,8 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
|||||||
|
|
||||||
// 计算查询时间范围
|
// 计算查询时间范围
|
||||||
Date monthDateTime = DateTimeUtil.convertStrToDate(month, DateTimeUtil.DEFAULT_DATE_PATTERN_YEAR_MONTH);
|
Date monthDateTime = DateTimeUtil.convertStrToDate(month, DateTimeUtil.DEFAULT_DATE_PATTERN_YEAR_MONTH);
|
||||||
long startTime = DateTimeUtil.getBeginTimeOfMonth(monthDateTime).getTime();
|
long startTime = DateTimeUtil.getBeginTimeOfMonth(monthDateTime).getTime() / 1000;
|
||||||
long endTime = DateTimeUtil.getEndTimeOfMonth(monthDateTime).getTime();
|
long endTime = DateTimeUtil.getEndTimeOfMonth(monthDateTime).getTime() / 1000;
|
||||||
|
|
||||||
// 查询统计数据
|
// 查询统计数据
|
||||||
List<MiniGameForSudAdminStatsVo> statList = miniGameForSudAdminMapper.statGameDurationByMonth(gameId, startTime, endTime);
|
List<MiniGameForSudAdminStatsVo> statList = miniGameForSudAdminMapper.statGameDurationByMonth(gameId, startTime, endTime);
|
||||||
@@ -66,7 +66,6 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
|||||||
vo = new MiniGameForSudAdminStatsVo();
|
vo = new MiniGameForSudAdminStatsVo();
|
||||||
vo.setGameId(game.getMgId());
|
vo.setGameId(game.getMgId());
|
||||||
vo.setGameName(game.getName());
|
vo.setGameName(game.getName());
|
||||||
vo.setStatMonth(month);
|
|
||||||
vo.setTotalDuration(0L);
|
vo.setTotalDuration(0L);
|
||||||
vo.setEnDuration(0L);
|
vo.setEnDuration(0L);
|
||||||
vo.setArDuration(0L);
|
vo.setArDuration(0L);
|
||||||
@@ -75,6 +74,7 @@ public class MiniGameForSudAdminService extends ServiceImpl<MiniGameForSudAdminM
|
|||||||
vo.setEn2Duration(0L);
|
vo.setEn2Duration(0L);
|
||||||
}
|
}
|
||||||
vo.setGameName(game.getName());
|
vo.setGameName(game.getName());
|
||||||
|
vo.setStatMonth(month);
|
||||||
return vo;
|
return vo;
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,29 @@ public class MiniGameForSudAdminController {
|
|||||||
List<MiniGameForSudAdminStatsVo> result = miniGameForSudAdminService.listStat(gameId, month);
|
List<MiniGameForSudAdminStatsVo> result = miniGameForSudAdminService.listStat(gameId, month);
|
||||||
return BusiResult.success(result);
|
return BusiResult.success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@ApiOperation("导出休闲游戏时长统计")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "gameId", value = "游戏ID", required = false, dataType = "Long", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "month", value = "月份(格式: yyyy-MM)", required = true, dataType = "String", paramType = "query")
|
||||||
|
})
|
||||||
|
@GetMapping("/exportStat")
|
||||||
|
public void exportStat(
|
||||||
|
Long gameId,
|
||||||
|
String month,
|
||||||
|
HttpServletResponse response) {
|
||||||
|
if (!StringUtils.hasText(month)){
|
||||||
|
throw new AdminServiceException(BusiStatus.PARAMERROR);
|
||||||
|
}
|
||||||
|
List<MiniGameForSudAdminStatsVo> dataList = miniGameForSudAdminService.listStat(gameId, month);
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||||
|
String fileName = URLEncoder.encode("休闲游戏时长统计", "UTF-8").replaceAll("\\+", "%20");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||||
|
EasyExcel.write(response.getOutputStream(), MiniGameForSudAdminStatsVo.class).sheet("休闲游戏时长统计").doWrite(dataList);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("获取休闲游戏时长明细列表")
|
@ApiOperation("获取休闲游戏时长明细列表")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
|
Reference in New Issue
Block a user