소스 검색

直播数据导出

15376779826 18 시간 전
부모
커밋
6dc211c537

+ 6 - 5
fs-company/src/main/java/com/fs/company/controller/live/LiveDataController.java

@@ -15,6 +15,7 @@ import com.fs.live.domain.LiveData;
 import com.fs.live.param.LiveDataParam;
 import com.fs.live.service.ILiveDataService;
 import com.fs.live.vo.ColumnsConfigVo;
+import com.fs.live.vo.LiveDataListVo;
 import com.fs.live.vo.LiveUserDetailExportVO;
 import com.github.pagehelper.PageHelper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,7 +62,7 @@ public class LiveDataController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('liveData:liveData:query')")
     @GetMapping("/getLiveUserDetailListBySql")
-    public R getLiveUserDetailListBySql(@RequestParam Long liveId, 
+    public R getLiveUserDetailListBySql(@RequestParam Long liveId,
                                         @RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "100") Integer pageSize,
                                         HttpServletRequest request) {
@@ -163,11 +164,11 @@ public class LiveDataController extends BaseController
     @PreAuthorize("@ss.hasPermi('liveData:liveData:export')")
     @Log(title = "直播数据", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(LiveData liveData)
+    public AjaxResult export(LiveDataParam param)
     {
-        List<LiveData> list = liveDataService.selectLiveDataList(liveData);
-        ExcelUtil<LiveData> util = new ExcelUtil<LiveData>(LiveData.class);
-        return util.exportExcel(list, "直播数据数据");
+        List<LiveDataListVo> liveDataListVos = liveDataService.exportLiveData(param);
+        ExcelUtil<LiveDataListVo> util = new ExcelUtil<LiveDataListVo>(LiveDataListVo.class);
+        return util.exportExcel(liveDataListVos, "直播数据数据");
     }
 
     /**

+ 2 - 0
fs-service/src/main/java/com/fs/live/service/ILiveDataService.java

@@ -167,4 +167,6 @@ public interface ILiveDataService {
      * @return 导出VO列表
      */
     List<LiveUserDetailExportVO> exportLiveUserDetail(Long liveId, Long companyId, Long companyUserId);
+
+    List<LiveDataListVo> exportLiveData(LiveDataParam param);
 }

+ 30 - 0
fs-service/src/main/java/com/fs/live/service/impl/LiveDataServiceImpl.java

@@ -192,6 +192,36 @@ public class LiveDataServiceImpl implements ILiveDataService {
         return R.ok().put("list", liveDataList).put("data", statistics).put("total", total);
     }
 
+    @Override
+    public List<LiveDataListVo> exportLiveData(LiveDataParam param){
+        List<Live> lives = liveMapper.listLiveData(param);
+        int total = liveMapper.listLiveDataCount(param);
+
+        if (lives == null || lives.isEmpty()) {
+            LiveDataStatisticsVo statistics = new LiveDataStatisticsVo();
+            return Collections.emptyList();
+        }
+
+        // 获取直播间ID列表
+        List<Long> liveIds = lives.stream()
+                .map(Live::getLiveId)
+                .collect(Collectors.toList());
+
+        // 查询统计数据(根据live_watch_user表查询用户的在线时长,计算平均时长
+        // 根据live_video的文件时长,判断用户的完课情况
+        // 根据live_order查询直播间的销量额和订单数)
+        LiveDataStatisticsVo statistics = baseMapper.selectLiveDataStatistics(liveIds);
+        if (statistics == null) {
+            statistics = new LiveDataStatisticsVo();
+        }
+
+        // 查询列表数据(每个直播间的详细统计数据)
+        List<LiveDataListVo> liveDataList = baseMapper.selectLiveDataListByLiveIds(liveIds);
+        if (liveDataList == null) {
+            liveDataList = Collections.emptyList();
+        }
+        return liveDataList;
+    }
     /**
      * 查询直播数据
      *

+ 19 - 0
fs-service/src/main/java/com/fs/live/vo/LiveDataListVo.java

@@ -1,6 +1,7 @@
 package com.fs.live.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
 import lombok.Data;
 
 import java.math.BigDecimal;
@@ -15,59 +16,77 @@ import java.util.Date;
 @Data
 public class LiveDataListVo {
     /** 直播ID */
+    @Excel(name = "直播ID")
     private Long liveId;
 
     /** 直播名称 */
+    @Excel(name = "直播名称")
     private String liveName;
 
     /** 直播类型 1直播,2录播,3直播回放 */
+    @Excel(name = "直播类型 1直播,2录播,3直播回放")
     private Integer liveType;
 
     /** 直播状态 1未开播 2直播中 3已结束 4直播回放中 */
+    @Excel(name = "直播状态 1未开播 2直播中 3已结束 4直播回放中")
     private Integer status;
 
     /** 开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date startTime;
 
     /** 结束时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date finishTime;
 
     /** 累计观看人数 */
+    @Excel(name = "累计观看人数")
     private Long totalViewers = 0L;
 
     /** 直播观看人数 */
+    @Excel(name = "直播观看人数")
     private Long liveViewers = 0L;
 
     /** 回放观看人数 */
+    @Excel(name = "回放观看人数")
     private Long playbackViewers = 0L;
 
     /** 直播平均时长(秒) */
+    @Excel(name = "直播平均时长")
     private Long liveAvgDuration = 0L;
 
     /** 回放平均时长(秒) */
+    @Excel(name = "回放平均时长")
     private Long playbackAvgDuration = 0L;
 
     /** 累计完课人数 */
+    @Excel(name = "累计完课人数")
     private Long totalCompletedCourses = 0L;
 
     /** 直播完课人数 */
+    @Excel(name = "直播完课人数")
     private Long liveCompletedCourses = 0L;
 
     /** 回放完课人数 */
+    @Excel(name = "回放完课人数")
     private Long playbackCompletedCourses = 0L;
 
     /** GMV(总销售额) */
+    @Excel(name = "总销售额")
     private BigDecimal gmv = BigDecimal.ZERO;
 
     /** 付费人数 */
+    @Excel(name = "付费人数")
     private Long paidUsers = 0L;
 
     /** 付费单数 */
+    @Excel(name = "付费单数")
     private Long paidOrders = 0L;
 
     /** 销量统计 */
+    @Excel(name = "销量统计")
     private Long salesCount = 0L;
 }