|
@@ -89,44 +89,56 @@ public class FsUserCourseCompanyStatisticsController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('course:statistics:export')")
|
|
@PreAuthorize("@ss.hasPermi('course:statistics:export')")
|
|
|
@Log(title = "会员每日看课统计", businessType = BusinessType.EXPORT)
|
|
@Log(title = "会员每日看课统计", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(FsUserCourseCompanyStatistics fsUserCourseCompanyStatistics)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult export(FsUserCourseCompanyStatistics fsUserCourseCompanyStatistics) {
|
|
|
|
|
+
|
|
|
List<FsUserCourseCompanyStatistics> list =
|
|
List<FsUserCourseCompanyStatistics> list =
|
|
|
fsUserCourseCompanyStatisticsService.selectFsUserCourseCompanyStatisticsTotal(fsUserCourseCompanyStatistics);
|
|
fsUserCourseCompanyStatisticsService.selectFsUserCourseCompanyStatisticsTotal(fsUserCourseCompanyStatistics);
|
|
|
|
|
|
|
|
- Optional.ofNullable(list).orElse(Collections.emptyList())
|
|
|
|
|
- .forEach(item -> {
|
|
|
|
|
- // 计算完播率 (完播次数 / 观看次数 * 100)
|
|
|
|
|
- item.setCompleteRate(
|
|
|
|
|
- Optional.ofNullable(item.getWatchCount())
|
|
|
|
|
- .filter(watchCount -> watchCount > 0)
|
|
|
|
|
- .map(watchCount -> BigDecimal.valueOf(
|
|
|
|
|
- Optional.ofNullable(item.getCompleteWatchCount()).orElse(0L))
|
|
|
|
|
- .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
- .divide(BigDecimal.valueOf(watchCount), 2, RoundingMode.HALF_UP)
|
|
|
|
|
- .longValue()
|
|
|
|
|
- )
|
|
|
|
|
- .orElse(0L)
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 计算正确率 (正确人次 / 答题人次 * 100)
|
|
|
|
|
- item.setCorrectRate(
|
|
|
|
|
- Optional.ofNullable(item.getAnswerCount())
|
|
|
|
|
- .filter(answerCount -> answerCount > 0)
|
|
|
|
|
- .map(answerCount -> BigDecimal.valueOf(
|
|
|
|
|
- Optional.ofNullable(item.getCorrectCount()).orElse(0L))
|
|
|
|
|
- .multiply(BigDecimal.valueOf(100))
|
|
|
|
|
- .divide(BigDecimal.valueOf(answerCount), 2, RoundingMode.HALF_UP)
|
|
|
|
|
- .longValue()
|
|
|
|
|
- )
|
|
|
|
|
- .orElse(0L)
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (list == null) {
|
|
|
|
|
+ list = Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (FsUserCourseCompanyStatistics item : list) {
|
|
|
|
|
|
|
|
- ExcelUtil<FsUserCourseCompanyStatistics> util = new ExcelUtil<FsUserCourseCompanyStatistics>(FsUserCourseCompanyStatistics.class);
|
|
|
|
|
|
|
+ Long watchCount = item.getWatchCount();
|
|
|
|
|
+ Long completeWatchCount = Optional.ofNullable(item.getCompleteWatchCount()).orElse(0L);
|
|
|
|
|
+
|
|
|
|
|
+ // 完播率 = 完播次数 / 观看次数 * 100 (放大100倍存入long,再格式化两位小数)
|
|
|
|
|
+ if (watchCount != null && watchCount > 0) {
|
|
|
|
|
+ Long rateValue = BigDecimal.valueOf(completeWatchCount)
|
|
|
|
|
+ .multiply(BigDecimal.valueOf(10000)) // 100*100
|
|
|
|
|
+ .divide(BigDecimal.valueOf(watchCount), 0, RoundingMode.HALF_UP)
|
|
|
|
|
+ .longValue();
|
|
|
|
|
+ item.setCompleteRate(rateValue);
|
|
|
|
|
+ item.setCompleteRateStr(String.format("%.2f%%", rateValue / 100.0)); // Excel 格式化
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.setCompleteRate(0L);
|
|
|
|
|
+ item.setCompleteRateStr("0.00%");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long answerCount = item.getAnswerCount();
|
|
|
|
|
+ Long correctCount = Optional.ofNullable(item.getCorrectCount()).orElse(0L);
|
|
|
|
|
+
|
|
|
|
|
+ // 正确率 = 正确人次 / 答题人次 * 100
|
|
|
|
|
+ if (answerCount != null && answerCount > 0) {
|
|
|
|
|
+ Long rateValue = BigDecimal.valueOf(correctCount)
|
|
|
|
|
+ .multiply(BigDecimal.valueOf(10000))
|
|
|
|
|
+ .divide(BigDecimal.valueOf(answerCount), 0, RoundingMode.HALF_UP)
|
|
|
|
|
+ .longValue();
|
|
|
|
|
+ item.setCorrectRate(rateValue);
|
|
|
|
|
+ item.setCorrectRateStr(String.format("%.2f%%", rateValue / 100.0));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.setCorrectRate(0L);
|
|
|
|
|
+ item.setCorrectRateStr("0.00%");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ExcelUtil<FsUserCourseCompanyStatistics> util = new ExcelUtil<>(FsUserCourseCompanyStatistics.class);
|
|
|
return util.exportExcel(list, "会员每日看课统计数据");
|
|
return util.exportExcel(list, "会员每日看课统计数据");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取会员每日看课统计详细信息
|
|
* 获取会员每日看课统计详细信息
|
|
|
*/
|
|
*/
|