Quellcode durchsuchen

Merge branch 'refs/heads/master_feat_20250407'

xdd vor 2 Wochen
Ursprung
Commit
89e91902e0

+ 136 - 0
fs-admin/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -0,0 +1,136 @@
+package com.fs.course.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.course.domain.FsCourseTrafficLog;
+import com.fs.course.param.FsCourseTrafficLogParam;
+import com.fs.course.service.IFsCourseTrafficLogService;
+import com.fs.course.service.IFsUserCourseService;
+import com.fs.course.vo.FsCourseTrafficLogListVO;
+import com.fs.his.vo.OptionsVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+
+/**
+ * 短链课程流量记录Controller
+ *
+ * @author fs
+ * @date 2024-10-31
+ */
+@RestController
+@RequestMapping("/course/courseTrafficLog")
+public class FsCourseTrafficLogController extends BaseController
+{
+    @Autowired
+    private IFsCourseTrafficLogService fsCourseTrafficLogService;
+
+    @Autowired
+    private IFsUserCourseService fsUserCourseMapper;
+    /**
+     * 查询短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(FsCourseTrafficLogParam param)
+    {
+        startPage();
+        if(ObjectUtils.isNotNull(param.getTime())){
+
+            YearMonth yearMonth = param.getTime();
+            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
+
+            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
+                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            param.setStartDate(startOfMonth.format(formatter));
+            param.setEndDate(startOfNextMonth.format(formatter));
+        }
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:export')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.EXPORT)
+    @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);
+        return util.exportExcel(list, "短链课程流量记录数据");
+    }
+
+    /**
+     * 获取短链课程流量记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:query')")
+    @GetMapping(value = "/{logId}")
+    public AjaxResult getInfo(@PathVariable("logId") Long logId)
+    {
+        return AjaxResult.success(fsCourseTrafficLogService.selectFsCourseTrafficLogByLogId(logId));
+    }
+
+    /**
+     * 新增短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:add')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.insertFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 修改短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:edit')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.updateFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 删除短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:remove')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{logIds}")
+    public AjaxResult remove(@PathVariable Long[] logIds)
+    {
+        return toAjax(fsCourseTrafficLogService.deleteFsCourseTrafficLogByLogIds(logIds));
+    }
+
+    @GetMapping("/courseList")
+    public R courseList()
+    {
+        List<OptionsVO> optionsVOS = fsUserCourseMapper.selectFsUserCourseAllList();
+        return R.ok().put("list", optionsVOS);
+    }
+}

+ 140 - 0
fs-company/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -0,0 +1,140 @@
+package com.fs.course.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.course.domain.FsCourseTrafficLog;
+import com.fs.course.param.FsCourseTrafficLogParam;
+import com.fs.course.service.IFsCourseTrafficLogService;
+import com.fs.course.service.IFsUserCourseService;
+import com.fs.course.vo.FsCourseTrafficLogListVO;
+import com.fs.his.vo.OptionsVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+
+/**
+ * 短链课程流量记录Controller
+ *
+ * @author fs
+ * @date 2024-10-31
+ */
+@RestController
+@RequestMapping("/course/courseTrafficLog")
+public class FsCourseTrafficLogController extends BaseController
+{
+    @Autowired
+    private IFsCourseTrafficLogService fsCourseTrafficLogService;
+
+    @Autowired
+    private IFsUserCourseService fsUserCourseMapper;
+    /**
+     * 查询短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(FsCourseTrafficLogParam param)
+    {
+        startPage();
+        if(ObjectUtils.isNotNull(param.getTime())){
+
+            YearMonth yearMonth = param.getTime();
+            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
+
+            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
+                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            param.setStartDate(startOfMonth.format(formatter));
+            param.setEndDate(startOfNextMonth.format(formatter));
+        }
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficNew(param);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出短链课程流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:export')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(FsCourseTrafficLogParam param)
+    {
+        if (param.getTime() != null) {
+            YearMonth yearMonth = param.getTime();
+            LocalDateTime startOfMonth = yearMonth.atDay(1).atStartOfDay();
+
+            LocalDateTime startOfNextMonth = yearMonth.plusMonths(1).atDay(1).atStartOfDay()
+                    .minusDays(1).withHour(23).withMinute(59).withSecond(59);
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+            param.setStartDate(startOfMonth.format(formatter));
+            param.setEndDate(startOfNextMonth.format(formatter));
+        }
+        List<FsCourseTrafficLogListVO> list = fsCourseTrafficLogService.selectTrafficByCompany(param);
+        ExcelUtil<FsCourseTrafficLogListVO> util = new ExcelUtil<FsCourseTrafficLogListVO>(FsCourseTrafficLogListVO.class);
+        return util.exportExcel(list, "短链课程流量记录数据");
+    }
+
+    /**
+     * 获取短链课程流量记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:query')")
+    @GetMapping(value = "/{logId}")
+    public AjaxResult getInfo(@PathVariable("logId") Long logId)
+    {
+        return AjaxResult.success(fsCourseTrafficLogService.selectFsCourseTrafficLogByLogId(logId));
+    }
+
+    /**
+     * 新增短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:add')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.insertFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 修改短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:edit')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody FsCourseTrafficLog fsCourseTrafficLog)
+    {
+        return toAjax(fsCourseTrafficLogService.updateFsCourseTrafficLog(fsCourseTrafficLog));
+    }
+
+    /**
+     * 删除短链课程流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('course:courseTrafficLog:remove')")
+    @Log(title = "短链课程流量记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{logIds}")
+    public AjaxResult remove(@PathVariable Long[] logIds)
+    {
+        return toAjax(fsCourseTrafficLogService.deleteFsCourseTrafficLogByLogIds(logIds));
+    }
+
+    @GetMapping("/courseList")
+    public R courseList()
+    {
+        List<OptionsVO> optionsVOS = fsUserCourseMapper.selectFsUserCourseAllList();
+        return R.ok().put("list", optionsVOS);
+    }
+}

+ 7 - 0
fs-service-system/src/main/java/com/fs/company/cache/ICompanyCacheService.java

@@ -14,4 +14,11 @@ public interface ICompanyCacheService {
      */
     public Company selectCompanyById(Long companyId);
 
+    /**
+     * 查询企业名称
+     *
+     * @param companyId 企业ID
+     * @return 企业名称
+     */
+    String selectCompanyNameById(Long companyId);
 }

+ 15 - 0
fs-service-system/src/main/java/com/fs/company/cache/impl/ICompanyCacheServiceImpl.java

@@ -21,8 +21,23 @@ public class ICompanyCacheServiceImpl implements ICompanyCacheService {
             .maximumSize(1000)
             .expireAfterWrite(3, TimeUnit.MINUTES)
             .build();
+    private static final Cache<Long, String> COMPANY_NAME_CACHE = Caffeine.newBuilder()
+            .maximumSize(1000)
+            .expireAfterWrite(3, TimeUnit.MINUTES)
+            .build();
     @Override
     public Company selectCompanyById(Long companyId) {
         return COMPANY_CACHE.get(companyId,e-> companyService.selectCompanyById(companyId));
     }
+
+    @Override
+    public String selectCompanyNameById(Long companyId) {
+        return COMPANY_NAME_CACHE.get(companyId, e-> {
+            Company company = companyService.selectCompanyById(companyId);
+            if(company == null){
+                return "";
+            }
+            return String.format("%s_%s",company.getCompanyName(),company.getCompanyId());
+        });
+    }
 }

+ 8 - 0
fs-service-system/src/main/java/com/fs/course/domain/FsCourseTrafficLog.java

@@ -47,10 +47,18 @@ public class FsCourseTrafficLog extends BaseEntity
     /** 公司id */
     @Excel(name = "公司id")
     private Long companyId;
+    private String companyName;
 
     /** 课程id */
     @Excel(name = "课程id")
     private Long courseId;
+    private String courseName;
+
+    /**
+     * 项目id
+     */
+    private Long project;
+    private String projectName;
 
 //    @JsonFormat(pattern = "yyyy-MM-dd")
 //    private Date time;

+ 3 - 16
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java

@@ -63,26 +63,13 @@ public interface FsCourseTrafficLogMapper
      */
     public int deleteFsCourseTrafficLogByLogIds(Long[] logIds);
 
-    @Select({"<script> " +
-            "select c.company_name, SUM(l.internet_traffic) AS total_internet_traffic" +
-            ",DATE_FORMAT(l.create_time, '%Y-%m') AS `month`  from fs_course_traffic_log l " +
-            "left join company c on c.company_id = l.company_id " +
-            "where 1 = 1 " +
-            "<if test= 'maps.year != null '>" +
-            "and YEAR(l.create_time) = #{maps.year} " +
-            "</if>" +
-            "<if test= 'maps.month != null '>"+
-            "and MONTH(l.create_time) = #{maps.month} " +
-            "</if>" +
-            "<if test = ' maps.companyId !=null '> " +
-            "and l.company_id = #{maps.companyId} " +
-            "</if>" +
-            "group by l.company_id,`month` "+
-            "</script>"})
+
     List<FsCourseTrafficLogListVO> selectTrafficByCompany(@Param("maps") FsCourseTrafficLogParam param);
 
     @Select("select * from fs_course_traffic_log where uu_id = #{uuId}")
     FsCourseTrafficLog selectFsCourseTrafficLogByuuId(@Param("uuId") String uuId);
 
     void insertOrUpdateTrafficLog(FsCourseTrafficLog trafficLog);
+
+    List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param);
 }

+ 18 - 4
fs-service-system/src/main/java/com/fs/course/param/FsCourseTrafficLogParam.java

@@ -1,16 +1,30 @@
 package com.fs.course.param;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
-import java.util.Date;
+import java.time.YearMonth;
 
 @Data
 public class FsCourseTrafficLogParam {
 
-    @JsonFormat(pattern = "yyyy-MM")
-    private Date time;
+    @DateTimeFormat(pattern = "yyyy-MM")
+    private YearMonth time;
+    /**
+     * 公司id
+     */
     private Long companyId;
     private Integer year;
     private Integer month;
+    /**
+     * 项目id
+     */
+    private Long project;
+    /**
+     * 课程id
+     */
+    private Long courseId;
+
+    private String startDate;
+    private String endDate;
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/course/service/IFsCourseTrafficLogService.java

@@ -63,4 +63,5 @@ public interface IFsCourseTrafficLogService
 
 
     List<FsCourseTrafficLogListVO> selectTrafficByCompany(FsCourseTrafficLogParam param);
+    List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param);
 }

+ 65 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java

@@ -1,9 +1,16 @@
 package com.fs.course.service.impl;
 
+import java.util.Collections;
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.DictUtils;
+import com.fs.company.cache.ICompanyCacheService;
 import com.fs.course.param.FsCourseTrafficLogParam;
 import com.fs.course.vo.FsCourseTrafficLogListVO;
+import com.fs.store.service.cache.IFsUserCourseCacheService;
+import com.hc.openapi.tool.util.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.course.mapper.FsCourseTrafficLogMapper;
@@ -21,6 +28,10 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
 {
     @Autowired
     private FsCourseTrafficLogMapper fsCourseTrafficLogMapper;
+    @Autowired
+    private ICompanyCacheService companyCacheService;
+    @Autowired
+    private IFsUserCourseCacheService fsUserCourseCacheService;
 
     /**
      * 查询短链课程流量记录
@@ -43,7 +54,32 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
     @Override
     public List<FsCourseTrafficLog> selectFsCourseTrafficLogList(FsCourseTrafficLog fsCourseTrafficLog)
     {
-        return fsCourseTrafficLogMapper.selectFsCourseTrafficLogList(fsCourseTrafficLog);
+        List<FsCourseTrafficLog> fsCourseTrafficLogs = fsCourseTrafficLogMapper.selectFsCourseTrafficLogList(fsCourseTrafficLog);
+
+        for (FsCourseTrafficLog log : fsCourseTrafficLogs) {
+            if(ObjectUtils.isNotNull(log.getProject())){
+                String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(log.getProject()));
+                if(StringUtils.isNotBlank(sysCourseProject)){
+                    log.setProjectName(sysCourseProject);
+                }
+            }
+
+            if(ObjectUtils.isNotNull(log.getCompanyId())){
+                String companyName = companyCacheService.selectCompanyNameById(log.getCompanyId());
+                if(StringUtils.isNotBlank(companyName)){
+                    log.setCompanyName(companyName);
+                }
+            }
+
+            if(ObjectUtils.isNotNull(log.getCourseId())){
+                String courseName = fsUserCourseCacheService.selectCourseNameByCourseId(log.getCourseId());
+                if(StringUtils.isNotBlank(courseName)){
+                    log.setCourseName(courseName);
+                }
+            }
+        }
+
+        return fsCourseTrafficLogs;
     }
 
     /**
@@ -99,4 +135,32 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
     public List<FsCourseTrafficLogListVO> selectTrafficByCompany(FsCourseTrafficLogParam param) {
         return fsCourseTrafficLogMapper.selectTrafficByCompany(param);
     }
+
+    @Override
+    public List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param) {
+        List<FsCourseTrafficLogListVO> fsCourseTrafficLogListVOS = fsCourseTrafficLogMapper.selectTrafficNew(param);
+        for (FsCourseTrafficLogListVO log : fsCourseTrafficLogListVOS) {
+            if (ObjectUtils.isNotNull(log.getProject())) {
+                String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(log.getProject()));
+                if (StringUtils.isNotBlank(sysCourseProject)) {
+                    log.setProjectName(sysCourseProject);
+                }
+            }
+
+            if (ObjectUtils.isNotNull(log.getCompanyId())) {
+                String companyName = companyCacheService.selectCompanyNameById(log.getCompanyId());
+                if (StringUtils.isNotBlank(companyName)) {
+                    log.setCompanyName(companyName);
+                }
+            }
+
+            if (ObjectUtils.isNotNull(log.getCourseId())) {
+                String courseName = fsUserCourseCacheService.selectCourseNameByCourseId(log.getCourseId());
+                if (StringUtils.isNotBlank(courseName)) {
+                    log.setCourseName(courseName);
+                }
+            }
+        }
+        return fsCourseTrafficLogListVOS;
+    }
 }

+ 10 - 0
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.course.service.impl;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
@@ -39,6 +40,7 @@ import com.fs.qwApi.Result.QwAddContactWayResult;
 import com.fs.qwApi.param.QwAddContactWayParam;
 import com.fs.qwApi.service.QwApiService;
 import com.fs.sop.mapper.QwSopLogsMapper;
+import com.fs.store.service.cache.IFsUserCourseCacheService;
 import com.fs.system.service.ISysConfigService;
 import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
 import org.slf4j.Logger;
@@ -501,6 +503,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
     }
 
 
+    @Autowired
+    private IFsUserCourseCacheService fsUserCourseCacheService;
     @Transactional
     @Override
     public R getInternetTraffic(FsUserCourseVideoFinishUParam param) {
@@ -526,6 +530,12 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
                 // 直接插入或更新
 //                logger.error("zyp \n【插入或更新流量】:{}",trafficLog);
+                if(ObjectUtils.isNotNull(trafficLog.getCourseId())) {
+                    FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(trafficLog.getCourseId());
+                    if(ObjectUtils.isNotNull(course)){
+                        trafficLog.setProject(course.getProject());
+                    }
+                }
                 fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
             }
         } catch (Exception e) {

+ 5 - 0
fs-service-system/src/main/java/com/fs/course/vo/FsCourseTrafficLogListVO.java

@@ -14,6 +14,11 @@ import java.io.Serializable;
 public class FsCourseTrafficLogListVO implements Serializable
 {
     private String companyName;
+    private Long companyId;
+    private String courseName;
+    private Long courseId;
+    private String projectName;
+    private Long project;
 
     private Long totalInternetTraffic;
 

+ 8 - 0
fs-service-system/src/main/java/com/fs/store/service/cache/IFsUserCourseCacheService.java

@@ -10,4 +10,12 @@ public interface IFsUserCourseCacheService {
      * @return 课程
      */
     public FsUserCourse selectFsUserCourseByCourseId(Long courseId);
+
+    /**
+     * 查询课程名称
+     *
+     * @param courseId 课程主键
+     * @return 课程名称
+     */
+    public String selectCourseNameByCourseId(Long courseId);
 }

+ 9 - 0
fs-service-system/src/main/java/com/fs/store/service/cache/impl/FsUserCourseCacheServiceImpl.java

@@ -21,8 +21,17 @@ public class FsUserCourseCacheServiceImpl implements IFsUserCourseCacheService {
             .maximumSize(1000)
             .expireAfterWrite(1, TimeUnit.MINUTES)
             .build();
+    private static final Cache<Long, String> COURSE_ID_AND_NAME = Caffeine.newBuilder()
+            .maximumSize(1000)
+            .expireAfterWrite(1, TimeUnit.MINUTES)
+            .build();
     @Override
     public FsUserCourse selectFsUserCourseByCourseId(Long courseId) {
         return FS_USER_COURSE_CACHE.get(courseId,e-> fsUserCourseService.selectFsUserCourseByCourseId(courseId));
     }
+
+    @Override
+    public String selectCourseNameByCourseId(Long courseId) {
+        return COURSE_ID_AND_NAME.get(courseId, e-> fsUserCourseService.selectFsUserCourseByCourseId(courseId).getCourseName());
+    }
 }

+ 42 - 1
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -19,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectFsCourseTrafficLogVo">
-        select log_id, uu_id,user_id, video_id, create_time, qw_external_contact_id, internet_traffic, qw_user_id, company_user_id, company_id, course_id from fs_course_traffic_log
+        select log_id, uu_id,user_id, video_id, create_time, qw_external_contact_id, internet_traffic, qw_user_id, company_user_id, company_id, course_id, project from fs_course_traffic_log
     </sql>
 
     <select id="selectFsCourseTrafficLogList" parameterType="FsCourseTrafficLog" resultMap="FsCourseTrafficLogResult">
@@ -40,6 +40,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsCourseTrafficLogVo"/>
         where log_id = #{logId}
     </select>
+    <select id="selectTrafficByCompany" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
+        select c.company_name, SUM(l.internet_traffic) AS total_internet_traffic
+        ,DATE_FORMAT(l.create_time, '%Y-%m') AS `month`  from fs_course_traffic_log l
+        left join company c on c.company_id = l.company_id
+        where 1 = 1
+        <if test= 'maps.year != null '>
+            and YEAR(l.create_time) = #{maps.year}
+            </if>
+        <if test= 'maps.month != null '>
+            and MONTH(l.create_time) = #{maps.month}
+            </if>
+        <if test = ' maps.companyId !=null '>
+            and l.company_id = #{maps.companyId}
+            </if>
+        group by l.company_id,`month`
+
+    </select>
+    <select id="selectTrafficNew" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
+        select company_id,project,course_id,SUM(internet_traffic) AS total_internet_traffic
+        ,DATE_FORMAT(create_time, '%Y-%m') AS `month`  from fs_course_traffic_log
+        <where>
+            <if test="startDate != null and endDate != null">
+                and create_time between #{startDate} AND #{endDate}
+            </if>
+            <if test='companyId !=null'>
+                and company_id = #{companyId}
+            </if>
+            <if test="courseId != null">
+                and course_id = ${courseId}
+            </if>
+            <if test="project">
+                and project = ${project}
+            </if>
+        </where>
+        group by company_id,`month`,project,course_id
+    </select>
 
     <insert id="insertFsCourseTrafficLog" parameterType="FsCourseTrafficLog" useGeneratedKeys="true" keyProperty="logId">
         insert into fs_course_traffic_log
@@ -54,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">company_id,</if>
             <if test="courseId != null">course_id,</if>
             <if test="uuId != null">uu_id,</if>
+            <if test="project != null">project,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
@@ -66,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">#{companyId},</if>
             <if test="courseId != null">#{courseId},</if>
             <if test="uuId != null">#{uuId},</if>
+            <if test="project != null">#{project},</if>
          </trim>
     </insert>
 
@@ -82,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">company_id,</if>
             <if test="courseId != null">course_id,</if>
             <if test="uuId != null">uu_id,</if>
+            <if test="project != null">project,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
@@ -94,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">#{companyId},</if>
             <if test="courseId != null">#{courseId},</if>
             <if test="uuId != null">#{uuId},</if>
+            <if test="project != null">#{project},</if>
         </trim>
         on duplicate key update
         <trim suffixOverrides=",">
@@ -114,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">company_id = #{companyId},</if>
             <if test="courseId != null">course_id = #{courseId},</if>
             <if test="uuId != null">uu_id = #{uuId},</if>
+            <if test="project != null">project = #{project},</if>
         </trim>
         where log_id = #{logId}
     </update>