|
@@ -2,8 +2,13 @@ package com.fs.qw.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fs.common.constant.HttpStatus;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.DictUtils;
|
|
|
+import com.fs.company.cache.ICompanyCacheService;
|
|
|
+import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
+import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.course.domain.FsUserCourse;
|
|
@@ -18,11 +23,13 @@ import com.fs.qw.service.IQwWatchLogService;
|
|
|
import com.fs.qw.vo.QwWatchLogAllStatisticsListVO;
|
|
|
import com.fs.qw.vo.QwWatchLogStatisticsListVO;
|
|
|
import com.fs.store.service.cache.IFsUserCourseCacheService;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.hc.openapi.tool.util.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 企微看课Service业务层处理
|
|
@@ -44,6 +51,12 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
|
|
|
|
|
|
@Autowired
|
|
|
private IFsUserCourseVideoCacheService fsUserCourseVideoCacheService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICompanyCacheService companyCacheService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICompanyUserCacheService companyUserCacheService;
|
|
|
/**
|
|
|
* 查询企微看课
|
|
|
*
|
|
@@ -118,13 +131,18 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<QwWatchLogStatisticsListVO> selectQwWatchLogStatisticsListVO(QwWatchLogStatisticsListParam param) {
|
|
|
+ public TableDataInfo selectQwWatchLogStatisticsListVO(QwWatchLogStatisticsListParam param) {
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(new ArrayList<>());
|
|
|
+ rspData.setTotal(0L);
|
|
|
|
|
|
Date sTime = param.getSTime();
|
|
|
Date eTime = param.getETime();
|
|
|
List<Date> datesBetween = getDatesBetween(sTime, eTime);
|
|
|
if (datesBetween.size() > 7) {
|
|
|
- return new ArrayList<>();
|
|
|
+ return rspData;
|
|
|
}
|
|
|
if (param.getCompanyUserId()!=null){
|
|
|
param.setIds(companyUserMapper.selectQwUserIdsByCompany(param.getCompanyUserId()));
|
|
@@ -140,46 +158,73 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
|
|
|
vo.setFirstOver(stat.getFirstOver());
|
|
|
}
|
|
|
|
|
|
- return vos;
|
|
|
+ Long total = qwWatchLogMapper.selectQwExtCountByDayAndCount(param);
|
|
|
+ rspData.setRows(vos);
|
|
|
+ rspData.setTotal(total);
|
|
|
+ return rspData;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<QwWatchLogStatisticsListVO> selectQwWatchLogStatisticsListVONew(QwWatchLogStatisticsListParam param) {
|
|
|
+ public TableDataInfo selectQwWatchLogStatisticsListVONew(QwWatchLogStatisticsListParam param) {
|
|
|
// 获取当前公司下的所有销售
|
|
|
List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
|
|
|
|
|
|
+ List<Long> userIds = companyUsers.stream()
|
|
|
+ .map(CompanyUser::getUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
List<QwWatchLogStatisticsListVO> list = new ArrayList<>();
|
|
|
- for (CompanyUser companyUser : companyUsers) {
|
|
|
- // 统计销售下面的所有记录
|
|
|
- List<QwWatchLogStatisticsListVO> vos = qwWatchLogMapper.selectQwWatchLogByCompanyUserId(companyUser.getCompanyId(),companyUser.getUserId()
|
|
|
- , param.getSTime(),param.getETime(),param.getProject(),param.getCourseId(),param.getVideoId());
|
|
|
- for (QwWatchLogStatisticsListVO item : vos) {
|
|
|
- item.setCompanyUserName(String.format("%s_%d",companyUser.getUserName(),companyUser.getUserId()));
|
|
|
- item.setCreateTime(companyUser.getCreateTime());
|
|
|
- if(ObjectUtils.isNotNull(item.getProject())){
|
|
|
- String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
- if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
- item.setProjectName(sysCourseProject);
|
|
|
- }
|
|
|
+
|
|
|
+ // 统计销售下面的所有记录
|
|
|
+ List<QwWatchLogStatisticsListVO> vos = qwWatchLogMapper
|
|
|
+ .selectQwWatchLogByCompanyUserId(userIds
|
|
|
+ , param.getSTime(),param.getETime(),param.getProject(),param.getCourseId(),param.getVideoId(),param.getPageNum(),param.getPageSize());
|
|
|
+
|
|
|
+ for (QwWatchLogStatisticsListVO item : vos) {
|
|
|
+ Company company = companyCacheService.selectCompanyById(item.getCompanyId());
|
|
|
+ if(ObjectUtils.isNotNull(company)){
|
|
|
+ item.setCompanyUserName(company.getCompanyName());
|
|
|
+ item.setCreateTime(company.getCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtils.isNotNull(item.getProject())){
|
|
|
+ String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
+ if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
+ item.setProjectName(sysCourseProject);
|
|
|
}
|
|
|
- // 课程名
|
|
|
- if(ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
- FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(item.getCourseId());
|
|
|
- if(ObjectUtils.isNotNull(course)){
|
|
|
- item.setCourseName(course.getCourseName());
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 课程名
|
|
|
+ if(ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
+ FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(item.getCourseId());
|
|
|
+ if(ObjectUtils.isNotNull(course)){
|
|
|
+ item.setCourseName(course.getCourseName());
|
|
|
}
|
|
|
- // 小节名
|
|
|
- if(ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
- FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
- if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
- item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 小节名
|
|
|
+ if(ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
+ if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
+ item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
}
|
|
|
- list.add(item);
|
|
|
}
|
|
|
+ list.add(item);
|
|
|
}
|
|
|
- return list;
|
|
|
+
|
|
|
+ // 获取总记录数
|
|
|
+ Long total = qwWatchLogMapper
|
|
|
+ .selectQwWatchLogByCompanyUserIdCount(userIds
|
|
|
+ , param.getSTime(), param.getETime(), param.getProject(), param.getCourseId(), param.getVideoId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ rspData.setTotal(total);
|
|
|
+
|
|
|
+ return rspData;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -209,45 +254,67 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<QwWatchLogAllStatisticsListVO> selectQwWatchLogAllStatisticsListVONew(QwWatchLogStatisticsListParam param) {
|
|
|
+ public TableDataInfo selectQwWatchLogAllStatisticsListVONew(QwWatchLogStatisticsListParam param) {
|
|
|
// 获取当前公司下的所有销售
|
|
|
List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
|
|
|
|
|
|
List<QwWatchLogAllStatisticsListVO> list = new ArrayList<>();
|
|
|
|
|
|
- for (CompanyUser companyUser : companyUsers) {
|
|
|
- List<QwWatchLogAllStatisticsListVO> vos = qwWatchLogMapper
|
|
|
- .selectQwWatchLogAllStatisticsListVONew(companyUser.getUserId(),companyUser.getCompanyId(), param.getSTime(), param.getETime(),
|
|
|
- param.getProject(),param.getCourseId(),param.getVideoId()
|
|
|
- );
|
|
|
- for (QwWatchLogAllStatisticsListVO item : vos) {
|
|
|
- if(ObjectUtils.isNotNull(item.getProject())){
|
|
|
- String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
- if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
- item.setProjectName(sysCourseProject);
|
|
|
- }
|
|
|
+ List<Long> userIds = companyUsers.stream().filter(e -> e.getUserId() != null)
|
|
|
+ .map(e -> e.getUserId())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<QwWatchLogAllStatisticsListVO> vos = qwWatchLogMapper
|
|
|
+ .selectQwWatchLogAllStatisticsListVONew(userIds, param.getSTime(), param.getETime(),
|
|
|
+ param.getProject(),param.getCourseId(),param.getVideoId()
|
|
|
+ );
|
|
|
+ for (QwWatchLogAllStatisticsListVO item : vos) {
|
|
|
+ if(ObjectUtils.isNotNull(item.getProject())){
|
|
|
+ String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
+ if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
+ item.setProjectName(sysCourseProject);
|
|
|
}
|
|
|
- // 课程名
|
|
|
- if(ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
- FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(item.getCourseId());
|
|
|
- if(ObjectUtils.isNotNull(course)){
|
|
|
- item.setCourseName(course.getCourseName());
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 课程名
|
|
|
+ if(ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
+ FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(item.getCourseId());
|
|
|
+ if(ObjectUtils.isNotNull(course)){
|
|
|
+ item.setCourseName(course.getCourseName());
|
|
|
}
|
|
|
- // 小节名
|
|
|
- if(ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
- FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
- if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
- item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 小节名
|
|
|
+ if(ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
+ if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
+ item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
}
|
|
|
- item.setQwUserName(companyUser.getUserName());
|
|
|
- item.setCreateTime(companyUser.getCreateTime());
|
|
|
- list.add(item);
|
|
|
}
|
|
|
+ // 销售名称
|
|
|
+ CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(item.getCompanyUserId());
|
|
|
|
|
|
+ item.setQwUserName(companyUser.getUserName());
|
|
|
+ item.setCreateTime(companyUser.getCreateTime());
|
|
|
+ list.add(item);
|
|
|
}
|
|
|
- return list;
|
|
|
+
|
|
|
+ Long total = qwWatchLogMapper
|
|
|
+ .selectQwWatchLogAllStatisticsListVONewCount(userIds, param.getSTime(), param.getETime(),
|
|
|
+ param.getProject(),param.getCourseId(),param.getVideoId()
|
|
|
+ );
|
|
|
+
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ rspData.setTotal(total);
|
|
|
+
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long selectQwWatchLogStatisticsListVONewCount(QwWatchLogStatisticsListParam param) {
|
|
|
+
|
|
|
+ return companyUserMapper.selectQwWatchLogStatisticsListVONewCount(param);
|
|
|
}
|
|
|
|
|
|
public List<Date> getDatesBetween(Date sTime, Date eTime) {
|