Преглед на файлове

益寿缘-销售端-增加通过短信发送课程链接的功能

cgp преди 2 дни
родител
ревизия
aa167cac93

+ 5 - 1
fs-admin/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -70,7 +70,11 @@ public class FsCourseTrafficLogController extends BaseController
             param.setYear(Integer.parseInt(parts[0]));
             param.setMonth(Integer.parseInt(parts[1]));
         }
-        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficByCompany(param);
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
+        //格式化每个记录的流量为 GB 字符串
+        for (FsCourseTrafficLogListVO vo : list) {
+            vo.formatTraffic();
+        }
         ExcelUtil<FsCourseTrafficLogListVO> util = new ExcelUtil<FsCourseTrafficLogListVO>(FsCourseTrafficLogListVO.class);
         return util.exportExcel(list, "短链课程流量记录数据");
     }

+ 18 - 1
fs-service/src/main/java/com/fs/course/vo/FsCourseTrafficLogListVO.java

@@ -15,15 +15,32 @@ import java.io.Serializable;
 @Data
 public class FsCourseTrafficLogListVO implements Serializable
 {
+    @Excel(name = "公司名称")
     private String companyName;
     private Long companyId;
+    @Excel(name = "课程名称")
     private String courseName;
     private Long courseId;
+    //@Excel(name = "项目名称")
     private String projectName;
     private Long project;
-
+    // 原始字节数(不用于导出)
     private Long totalInternetTraffic;
 
+    @Excel(name = "总流量 (GB)")
+    private String formattedTotalTraffic;
+
+    @Excel(name = "统计月份")
     private String month;
 
+    // 工具方法:根据 totalInternetTraffic 自动计算 formattedTotalTraffic
+    public void formatTraffic() {
+        if (this.totalInternetTraffic == null) {
+            this.formattedTotalTraffic = "0.0000 GB";
+        } else {
+            double gb = this.totalInternetTraffic.doubleValue() / (1024 * 1024 * 1024);
+            this.formattedTotalTraffic = String.format("%.4f GB", gb);
+        }
+    }
+
 }

+ 7 - 13
fs-service/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -266,7 +266,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectTrafficNew" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
-        select company_id,project,course_id,SUM(internet_traffic) AS total_internet_traffic
+        select company_id,course_id,SUM(internet_traffic) AS total_internet_traffic
         ,DATE_FORMAT(create_time, '%Y-%m-%d') AS `month`  from fs_course_traffic_log
         <where>
             <if test="startDate != null and endDate != null">
@@ -276,24 +276,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and company_id = #{companyId}
             </if>
             <if test="courseId != null">
-                and course_id = ${courseId}
+                and course_id = #{courseId}
             </if>
-            <if test="project != null">
-                and project = ${project}
-            </if>
-            <if test="common == null">
-                AND company_id IS not NULL
-            </if>
-            <if test="common != null ">
+            <if test='common != null and common == "common"'>
                 AND company_id IS NULL
             </if>
+            <if test='!(common != null and common == "common")'>
+                AND company_id IS NOT NULL
+            </if>
         </where>
 
         <if test="tabType==null or tabType==''">
-            group by company_id,`month`,course_id,project
-        </if>
-        <if test="tabType!=null and tabType=='project'">
-            group by project,`month`
+            group by company_id,`month`,course_id
         </if>
         <if test="tabType!=null and tabType=='course'">
             group by course_id,`month`