|
|
@@ -1,16 +1,14 @@
|
|
|
package com.fs.course.controller;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.fs.common.core.domain.R;
|
|
|
-import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.common.utils.bean.BeanUtils;
|
|
|
import com.fs.course.param.FsCourseTrafficLogParam;
|
|
|
import com.fs.course.param.InternetTrafficParam;
|
|
|
import com.fs.course.vo.FsCourseTrafficLogListVO;
|
|
|
-import com.fs.qw.param.QwWatchLogStatisticsListParam;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -63,18 +61,28 @@ public class FsCourseTrafficLogController extends BaseController
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(FsCourseTrafficLogParam param)
|
|
|
{
|
|
|
- if (param.getTime() != null) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
- String formattedDate = sdf.format(param.getTime());
|
|
|
- String[] parts = formattedDate.split("-");
|
|
|
- param.setYear(Integer.parseInt(parts[0]));
|
|
|
- param.setMonth(Integer.parseInt(parts[1]));
|
|
|
- }
|
|
|
- List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficByCompany(param);
|
|
|
- ExcelUtil<FsCourseTrafficLogListVO> util = new ExcelUtil<FsCourseTrafficLogListVO>(FsCourseTrafficLogListVO.class);
|
|
|
+ List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
|
|
|
+ list.forEach(vo -> {
|
|
|
+ // 流量转换
|
|
|
+ vo.setTotalInternetTrafficFormat(formatTraffic(vo.getTotalInternetTraffic()));
|
|
|
+ });
|
|
|
+ ExcelUtil<FsCourseTrafficLogListVO> util = new ExcelUtil<>(FsCourseTrafficLogListVO.class);
|
|
|
return util.exportExcel(list, "短链课程流量记录数据");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 流量转换
|
|
|
+ */
|
|
|
+ private static String formatTraffic(long bytes) {
|
|
|
+ if (bytes < 1024) return bytes + " B";
|
|
|
+ double kb = bytes / 1024.0;
|
|
|
+ if (kb < 1024) return String.format("%.2f KB", kb);
|
|
|
+ double mb = kb / 1024.0;
|
|
|
+ if (mb < 1024) return String.format("%.2f MB", mb);
|
|
|
+ double gb = mb / 1024.0;
|
|
|
+ return String.format("%.2f GB", gb);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取短链课程流量记录详细信息
|
|
|
*/
|