Ver código fonte

看客统计定时任务- 看客人数-完课人数

xgb 1 semana atrás
pai
commit
a3fa5d1965

+ 19 - 3
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -7,19 +7,17 @@ import com.fs.common.core.redis.RedisCache;
 import com.fs.company.constant.CompanyTrafficConstants;
 import com.fs.company.domain.Company;
 import com.fs.company.service.ICompanyService;
-import com.fs.company.service.ICompanyTrafficRecordService;
-import com.fs.company.service.impl.CompanyTrafficRecordServiceImpl;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
 import com.fs.statis.param.StatisticsDeptCompanyParam;
+import com.fs.statis.service.IStatisticsService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import com.fs.system.service.ISysDeptService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -55,6 +53,9 @@ public class IndexStatisticsController {
 
     @Autowired
     private MedicalMallConfig medicalMallConfig;
+
+    @Autowired
+    private IStatisticsService statisticsService;
     /**
      * 分析概览
      */
@@ -857,4 +858,19 @@ public class IndexStatisticsController {
             }
         }
     }
+
+    /**
+     * @Description: 看课统计按公司
+     * @Param:
+     * @Return:
+     * @Author xgb
+     * @Date 2025/10/27 16:29
+     */
+    @PostMapping("/getWatchCourseStatisticsData")
+    public R getWatchCourseStatisticsData(@RequestBody AnalysisPreviewQueryDTO param){
+        // 从缓存获取看客统计数据
+        List<WatchCourseStatisticsResultDTO> data=statisticsService.getWatchCourseStatisticsData( param);
+
+        return R.ok().put("data", data);
+    }
 }

+ 26 - 2
fs-company/src/main/java/com/fs/company/controller/company/IndexStatisticsController.java

@@ -7,8 +7,7 @@ import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
-import com.fs.system.domain.SysConfig;
-import com.fs.system.service.ISysConfigService;
+import com.fs.statis.service.IStatisticsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -28,6 +27,10 @@ public class IndexStatisticsController {
 
     @Autowired
     private TokenService tokenService;
+
+    @Autowired
+    private IStatisticsService statisticsService;
+
     /**
      * 分析概览
      */
@@ -239,4 +242,25 @@ public class IndexStatisticsController {
         R result = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.THIS_MONTH_RECV_COUNT,companyId));
         return result;
     }
+
+    /**
+     * @Description: 看课统计按公司
+     * @Param:
+     * @Return:
+     * @Author xgb
+     * @Date 2025/10/27 16:29
+     */
+    @PostMapping("/getWatchCourseStatisticsData")
+    public R getWatchCourseStatisticsData(@RequestBody AnalysisPreviewQueryDTO param){
+        // 获取公司ID
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        if(param.getCompanyId()==null){
+            param.setCompanyId(companyId);
+        }
+        // 从缓存获取看客统计数据
+        List<WatchCourseStatisticsResultDTO> data=statisticsService.getWatchCourseStatisticsData(param);
+
+        return R.ok().put("data", data);
+    }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/statis/dto/AnalysisPreviewQueryDTO.java

@@ -39,6 +39,7 @@ public class AnalysisPreviewQueryDTO implements Serializable {
 
     /**
      * 0 用户 1 企微
+     * 1 会员 2 企微
      */
     private Integer userType;
 

+ 2 - 0
fs-service/src/main/java/com/fs/statis/service/IStatisticsService.java

@@ -120,4 +120,6 @@ public interface IStatisticsService {
      * 统计今日看课
      */
     void watchCourseStatisticsGroupByCompany();
+
+    List<WatchCourseStatisticsResultDTO> getWatchCourseStatisticsData(AnalysisPreviewQueryDTO param);
 }

+ 25 - 0
fs-service/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -1029,5 +1029,30 @@ public class StatisticsServiceImpl implements IStatisticsService {
         }
     }
 
+    @Override
+    public List<WatchCourseStatisticsResultDTO> getWatchCourseStatisticsData(AnalysisPreviewQueryDTO param) {
+
+        String redisData = redisCache.getCacheObject(FsConstants.WATCH_COURSE_STATISTICS_GROUP_COMPANY + param.getType());
+        List<WatchCourseStatisticsResultDTO> watchCourseStatisticsDTOS = new ArrayList<>();
+        if (StringUtils.isNotBlank(redisData)) {
+            watchCourseStatisticsDTOS = JSONObject.parseArray(redisData, WatchCourseStatisticsResultDTO.class);
+        }
+        String sendType;
+        if (param.getUserType() == 1) {
+            sendType = "1";
+        } else if (param.getUserType() == 2) {
+            sendType = "2";
+        } else {
+            return new ArrayList<>();
+        }
+
+        watchCourseStatisticsDTOS = watchCourseStatisticsDTOS.stream()
+                .filter(dto -> StringUtils.equals(sendType, dto.getSendType()))
+                .filter(dto -> param.getCompanyId() == null ||
+                        StringUtils.equals(dto.getCompanyId(), String.valueOf(param.getCompanyId())))
+                .collect(Collectors.toList());
 
+
+        return watchCourseStatisticsDTOS;
+    }
 }