|
@@ -1,12 +1,15 @@
|
|
|
package com.fs.statis.service.impl;
|
|
package com.fs.statis.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
+import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.cache.ICompanyUserCacheService;
|
|
import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
import com.fs.company.domain.CompanyDept;
|
|
import com.fs.company.domain.CompanyDept;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyDeptMapper;
|
|
import com.fs.company.mapper.CompanyDeptMapper;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
|
|
+import com.fs.course.domain.FsUserCourse;
|
|
|
|
|
+import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
import com.fs.qw.cache.QwSopCacheService;
|
|
import com.fs.qw.cache.QwSopCacheService;
|
|
|
import com.fs.qw.cache.QwUserCacheService;
|
|
import com.fs.qw.cache.QwUserCacheService;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
import com.fs.qw.domain.QwUser;
|
|
@@ -65,6 +68,9 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private QwSopCacheService qwSopCacheService;
|
|
private QwSopCacheService qwSopCacheService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsUserCourseMapper fsUserCourseMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
public FsStatisSalerWatchServiceImpl(FsStatisSalerWatchMapper fsStatisSalerWatchMapper,
|
|
public FsStatisSalerWatchServiceImpl(FsStatisSalerWatchMapper fsStatisSalerWatchMapper,
|
|
|
CompanyUserMapper companyUserMapper,
|
|
CompanyUserMapper companyUserMapper,
|
|
@@ -146,22 +152,16 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
|
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
- List<FsStatisSalerWatch> fsStatisSalerWatches = fsStatisSalerWatchMapper.queryList(param);
|
|
|
|
|
- for (FsStatisSalerWatch item : fsStatisSalerWatches) {
|
|
|
|
|
- if(item.getDeptId() != null) {
|
|
|
|
|
- CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(item.getDeptId());
|
|
|
|
|
- if(ObjectUtils.isNotNull(companyDept)) {
|
|
|
|
|
- item.setDeptName(companyDept.getDeptName());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<FsStatisSalerWatch> fsStatisSalerWatches;
|
|
|
|
|
+ if (needWatchLogQuery(param)) {
|
|
|
|
|
+ if (!prepareCourseIds(param)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
- if(item.getCompanyUserId() != null) {
|
|
|
|
|
- String companyUserName = companyUserCacheService.selectCompanyUserNameUserById(item.getCompanyUserId());
|
|
|
|
|
- if(StringUtils.isNotEmpty(companyUserName)){
|
|
|
|
|
- item.setCompanyUserName(companyUserName);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ fsStatisSalerWatches = fsStatisSalerWatchMapper.queryListByWatchLog(param);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fsStatisSalerWatches = fsStatisSalerWatchMapper.queryList(param);
|
|
|
}
|
|
}
|
|
|
|
|
+ fillUserAndDeptName(fsStatisSalerWatches);
|
|
|
return fsStatisSalerWatches;
|
|
return fsStatisSalerWatches;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -238,9 +238,106 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
|
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
|
}
|
|
}
|
|
|
|
|
+ if (needWatchLogQuery(param)) {
|
|
|
|
|
+ if (!prepareCourseIds(param)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return fsStatisSalerWatchMapper.queryListExportByWatchLog(param);
|
|
|
|
|
+ }
|
|
|
return fsStatisSalerWatchMapper.queryListExport(param);
|
|
return fsStatisSalerWatchMapper.queryListExport(param);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否走看课日志实时聚合(项目或课程区间)
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean needWatchLogQuery(StatsWatchLogPageListDTO param) {
|
|
|
|
|
+ if (param == null) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (param.getProject() != null) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return param.getCourseStart() != null || param.getCourseEnd() != null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解析项目下课程 ID:按 sort 升序,空 sort 靠后;有区间则按下标切片(1-based)
|
|
|
|
|
+ * @return false 表示应返回空列表(无匹配课程)
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean prepareCourseIds(StatsWatchLogPageListDTO param) {
|
|
|
|
|
+ if (param.getCourseStart() != null || param.getCourseEnd() != null) {
|
|
|
|
|
+ if (param.getProject() == null) {
|
|
|
|
|
+ throw new ServiceException("请先选择项目后再按课程区间筛选");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (param.getProject() == null) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ FsUserCourse query = new FsUserCourse();
|
|
|
|
|
+ query.setProject(param.getProject());
|
|
|
|
|
+ query.setIsDel(0);
|
|
|
|
|
+ List<FsUserCourse> courses = fsUserCourseMapper.selectFsUserCourseList(query);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(courses)) {
|
|
|
|
|
+ param.setCourseIds(Collections.emptyList());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ courses.sort(Comparator
|
|
|
|
|
+ .comparing((FsUserCourse c) -> c.getSort() == null)
|
|
|
|
|
+ .thenComparing(c -> c.getSort() == null ? 0L : c.getSort())
|
|
|
|
|
+ .thenComparing(c -> c.getCourseId() == null ? 0L : c.getCourseId()));
|
|
|
|
|
+ int from = param.getCourseStart() == null ? 1 : param.getCourseStart();
|
|
|
|
|
+ int to = param.getCourseEnd() == null ? courses.size() : param.getCourseEnd();
|
|
|
|
|
+ if (from < 1) {
|
|
|
|
|
+ from = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (to < from) {
|
|
|
|
|
+ throw new ServiceException("课程区间起始不能大于结束");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (from > courses.size()) {
|
|
|
|
|
+ param.setCourseIds(Collections.emptyList());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (to > courses.size()) {
|
|
|
|
|
+ to = courses.size();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> courseIds = new ArrayList<>();
|
|
|
|
|
+ for (int i = from - 1; i < to; i++) {
|
|
|
|
|
+ Long courseId = courses.get(i).getCourseId();
|
|
|
|
|
+ if (courseId != null) {
|
|
|
|
|
+ courseIds.add(courseId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (courseIds.isEmpty()) {
|
|
|
|
|
+ param.setCourseIds(Collections.emptyList());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setCourseIds(courseIds);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 补齐部门名、销售昵称
|
|
|
|
|
+ */
|
|
|
|
|
+ private void fillUserAndDeptName(List<FsStatisSalerWatch> list) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (FsStatisSalerWatch item : list) {
|
|
|
|
|
+ if (item.getDeptId() != null) {
|
|
|
|
|
+ CompanyDept companyDept = companyDeptMapper.selectCompanyDeptById(item.getDeptId());
|
|
|
|
|
+ if (ObjectUtils.isNotNull(companyDept)) {
|
|
|
|
|
+ item.setDeptName(companyDept.getDeptName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.getCompanyUserId() != null) {
|
|
|
|
|
+ String companyUserName = companyUserCacheService.selectCompanyUserNameUserById(item.getCompanyUserId());
|
|
|
|
|
+ if (StringUtils.isNotEmpty(companyUserName)) {
|
|
|
|
|
+ item.setCompanyUserName(companyUserName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<FsStatisSopWatch> exportQueryPeriodList(StatsWatchLogPageListDTO param) {
|
|
public List<FsStatisSopWatch> exportQueryPeriodList(StatsWatchLogPageListDTO param) {
|
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|
|
if(StringUtils.isNull(param.getStartDate()) && StringUtils.isNull(param.getEndDate())) {
|