|
|
@@ -27,6 +27,7 @@ import com.fs.course.service.cache.IFsUserCourseVideoCacheService;
|
|
|
import com.fs.course.vo.*;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
+import com.fs.his.dto.UserConditionDTO;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
@@ -63,6 +64,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -70,6 +73,7 @@ import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -79,8 +83,7 @@ import java.util.stream.Collectors;
|
|
|
* @date 2024-09-18
|
|
|
*/
|
|
|
@Service
|
|
|
-public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMapper, FsCourseWatchLog> implements IFsCourseWatchLogService
|
|
|
-{
|
|
|
+public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMapper, FsCourseWatchLog> implements IFsCourseWatchLogService {
|
|
|
private static final Logger log = LoggerFactory.getLogger(FsCourseWatchLogServiceImpl.class);
|
|
|
@Autowired
|
|
|
private FsCourseWatchLogMapper fsCourseWatchLogMapper;
|
|
|
@@ -147,8 +150,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 短链课程看课记录
|
|
|
*/
|
|
|
@Override
|
|
|
- public FsCourseWatchLog selectFsCourseWatchLogByLogId(Long logId)
|
|
|
- {
|
|
|
+ public FsCourseWatchLog selectFsCourseWatchLogByLogId(Long logId) {
|
|
|
return fsCourseWatchLogMapper.selectFsCourseWatchLogByLogId(logId);
|
|
|
}
|
|
|
|
|
|
@@ -159,8 +161,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 短链课程看课记录
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<FsCourseWatchLog> selectFsCourseWatchLogList(FsCourseWatchLog fsCourseWatchLog)
|
|
|
- {
|
|
|
+ public List<FsCourseWatchLog> selectFsCourseWatchLogList(FsCourseWatchLog fsCourseWatchLog) {
|
|
|
return fsCourseWatchLogMapper.selectFsCourseWatchLogList(fsCourseWatchLog);
|
|
|
}
|
|
|
|
|
|
@@ -182,8 +183,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertFsCourseWatchLog(FsCourseWatchLog fsCourseWatchLog)
|
|
|
- {
|
|
|
+ public int insertFsCourseWatchLog(FsCourseWatchLog fsCourseWatchLog) {
|
|
|
fsCourseWatchLog.setCreateTime(DateUtils.getNowDate());
|
|
|
return fsCourseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
|
|
|
}
|
|
|
@@ -195,8 +195,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateFsCourseWatchLog(FsCourseWatchLog fsCourseWatchLog)
|
|
|
- {
|
|
|
+ public int updateFsCourseWatchLog(FsCourseWatchLog fsCourseWatchLog) {
|
|
|
fsCourseWatchLog.setUpdateTime(DateUtils.getNowDate());
|
|
|
return fsCourseWatchLogMapper.updateFsCourseWatchLog(fsCourseWatchLog);
|
|
|
}
|
|
|
@@ -208,8 +207,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsCourseWatchLogByLogIds(Long[] logIds)
|
|
|
- {
|
|
|
+ public int deleteFsCourseWatchLogByLogIds(Long[] logIds) {
|
|
|
return fsCourseWatchLogMapper.deleteFsCourseWatchLogByLogIds(logIds);
|
|
|
}
|
|
|
|
|
|
@@ -220,19 +218,18 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsCourseWatchLogByLogId(Long logId)
|
|
|
- {
|
|
|
+ public int deleteFsCourseWatchLogByLogId(Long logId) {
|
|
|
return fsCourseWatchLogMapper.deleteFsCourseWatchLogByLogId(logId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FsCourseWatchLog getWatchCourseVideo(Long userId, Long videoId, String qwUserId,Long externalId) {
|
|
|
- return fsCourseWatchLogMapper.getWatchCourseVideo(userId,videoId,qwUserId,externalId);
|
|
|
+ public FsCourseWatchLog getWatchCourseVideo(Long userId, Long videoId, String qwUserId, Long externalId) {
|
|
|
+ return fsCourseWatchLogMapper.getWatchCourseVideo(userId, videoId, qwUserId, externalId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public FsCourseWatchLog getWatchCourseVideoH5(Long videoId, String qwUserId, Long externalId) {
|
|
|
- return fsCourseWatchLogMapper.getWatchCourseLogVideoBySop(videoId,qwUserId,externalId);
|
|
|
+ return fsCourseWatchLogMapper.getWatchCourseLogVideoBySop(videoId, qwUserId, externalId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -240,37 +237,37 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsCourseWatchLogStatisticsListVO> list = fsCourseWatchLogMapper.selectFsCourseWatchLogStatisticsListVONew(param);
|
|
|
for (FsCourseWatchLogStatisticsListVO item : list) {
|
|
|
// 项目名
|
|
|
- if(ObjectUtils.isNotNull(item.getProject())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getProject())) {
|
|
|
String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
- if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
+ if (StringUtils.isNotBlank(sysCourseProject)) {
|
|
|
item.setProjectName(sysCourseProject);
|
|
|
}
|
|
|
}
|
|
|
// 课程名
|
|
|
- if(ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
String courseName = fsUserCourseCacheService.selectCourseNameByCourseId(item.getCourseId());
|
|
|
- if(ObjectUtils.isNotNull(courseName)){
|
|
|
+ if (ObjectUtils.isNotNull(courseName)) {
|
|
|
item.setCourseName(courseName);
|
|
|
}
|
|
|
}
|
|
|
// 小节名
|
|
|
- if(ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
- if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
+ if (ObjectUtils.isNotNull(fsUserCourseVideo)) {
|
|
|
item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
}
|
|
|
}
|
|
|
// 用户名
|
|
|
- if(ObjectUtils.isNotNull(item.getUserId())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getUserId())) {
|
|
|
FsUser fsUser = fsUserCacheService.selectFsUserById(item.getUserId());
|
|
|
- if(ObjectUtils.isNotNull(fsUser)){
|
|
|
- item.setUserName(String.format("%s_%d",fsUser.getNickName(),fsUser.getUserId()));
|
|
|
+ if (ObjectUtils.isNotNull(fsUser)) {
|
|
|
+ item.setUserName(String.format("%s_%d", fsUser.getNickName(), fsUser.getUserId()));
|
|
|
}
|
|
|
}
|
|
|
// 销售名
|
|
|
- if(ObjectUtils.isNotNull(item.getCompanyUserId())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getCompanyUserId())) {
|
|
|
CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(item.getCompanyUserId());
|
|
|
- if(ObjectUtils.isNotNull(companyUser)){
|
|
|
+ if (ObjectUtils.isNotNull(companyUser)) {
|
|
|
item.setCompanyUserName(String.format("%s_%d", companyUser.getUserName(), companyUser.getUserId()));
|
|
|
}
|
|
|
}
|
|
|
@@ -284,7 +281,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public void addCourseWatchLogDayNew() {
|
|
|
|
|
|
List<FsUserCourse> courses = fsUserCourseMapper.selectFsUserCourseAllCourse();
|
|
|
@@ -300,45 +297,45 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
// 获取进线时间
|
|
|
FsUser fsUser = fsUserService.selectFsUserById(fsCourseWatchLog.getUserId());
|
|
|
- if (fsUser!=null){
|
|
|
+ if (fsUser != null) {
|
|
|
fsCourseWatchLog.setLineTime(fsUser.getCreateTime());
|
|
|
}
|
|
|
// 查询首次观看时间
|
|
|
Date date = fsCourseWatchLogMapper.queryFirstWatchDateLogByVideoId(fsCourseWatchLog.getUserId());
|
|
|
- if (date!=null){
|
|
|
+ if (date != null) {
|
|
|
fsCourseWatchLog.setFirstTime(date);
|
|
|
}
|
|
|
|
|
|
Date firstTime = fsCourseWatchLog.getFirstTime();
|
|
|
- Long day=1L;
|
|
|
- if (fsCourseWatchLog.getLineTime()==null){
|
|
|
+ Long day = 1L;
|
|
|
+ if (fsCourseWatchLog.getLineTime() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
//不是第一次 看课程
|
|
|
- if (firstTime!=null){
|
|
|
+ if (firstTime != null) {
|
|
|
LocalDate firstLocalDate = firstTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
day = ChronoUnit.DAYS.between(firstLocalDate, currentDate);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//是先导课
|
|
|
- if (fsUserCourseVideo.getIsFirst()!=null&&fsUserCourseVideo.getIsFirst()==1){
|
|
|
+ if (fsUserCourseVideo.getIsFirst() != null && fsUserCourseVideo.getIsFirst() == 1) {
|
|
|
// 如果存在第一次记录就跳过
|
|
|
int count = qwWatchLogMapper.selectQwWatchLogIsFirstByUserId(fsCourseWatchLog.getUserId());
|
|
|
- if (count>0){
|
|
|
+ if (count > 0) {
|
|
|
continue;
|
|
|
}
|
|
|
- day=0L;
|
|
|
+ day = 0L;
|
|
|
//不是先导课
|
|
|
}
|
|
|
}
|
|
|
HyWatchLog qwWatchLog = new HyWatchLog();
|
|
|
qwWatchLog.setExtId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
|
|
|
- if(fsCourseWatchLog.getQwUserId() != null) {
|
|
|
+ if (fsCourseWatchLog.getQwUserId() != null) {
|
|
|
qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
|
|
|
}
|
|
|
qwWatchLog.setDay(day);
|
|
|
- qwWatchLog.setStatus(fsCourseWatchLog.getLogType()==3?0:fsCourseWatchLog.getLogType()==2?2:1);
|
|
|
+ qwWatchLog.setStatus(fsCourseWatchLog.getLogType() == 3 ? 0 : fsCourseWatchLog.getLogType() == 2 ? 2 : 1);
|
|
|
qwWatchLog.setProject(project);
|
|
|
qwWatchLog.setCreateTime(fsCourseWatchLog.getCreateTime());
|
|
|
qwWatchLog.setCompanyId(fsCourseWatchLog.getCompanyId());
|
|
|
@@ -348,11 +345,11 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
qwWatchLog.setVideoId(fsCourseWatchLog.getVideoId());
|
|
|
QwWatchLogs.add(qwWatchLog);
|
|
|
}
|
|
|
- if (!QwWatchLogs.isEmpty()){
|
|
|
+ if (!QwWatchLogs.isEmpty()) {
|
|
|
hyWatchLogMapper.insertHyWatchLogBatch(QwWatchLogs);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
- log.error("看课记录add异常:{}",course.getCourseId(),e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("看课记录add异常:{}", course.getCourseId(), e);
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
@@ -385,8 +382,8 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Long videoId = Long.parseLong(parts[4]);
|
|
|
Long companyUserId = Long.parseLong(parts[5]);
|
|
|
String durationStr = redisCache.getCacheObject(key);
|
|
|
- if(durationStr==null){
|
|
|
- log.error("key中数据为null:{}",key);
|
|
|
+ if (durationStr == null) {
|
|
|
+ log.error("key中数据为null:{}", key);
|
|
|
continue; // 如果 Redis 中没有记录,跳过
|
|
|
}
|
|
|
Long duration = Long.valueOf(durationStr);
|
|
|
@@ -401,7 +398,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Long videoDuration = 0L;
|
|
|
try {
|
|
|
videoDuration = getFsUserVideoDuration(videoId);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("视频时长识别错误:{}", key);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -411,7 +408,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
if (percentage >= config.getAnswerRate()) {
|
|
|
watchLog.setLogType(2); // 设置状态为“已完成”checkFsUserWatchStatus
|
|
|
watchLog.setFinishTime(new Date());
|
|
|
- String heartbeatKey ="h5wxuser:watch:heartbeat:" + userId+ ":" + videoId + ":" + companyUserId;
|
|
|
+ String heartbeatKey = "h5wxuser:watch:heartbeat:" + userId + ":" + videoId + ":" + companyUserId;
|
|
|
// 完课删除心跳记录
|
|
|
redisCache.deleteObject(heartbeatKey);
|
|
|
// 完课删除看课时长记录
|
|
|
@@ -422,32 +419,34 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
//集合中增加
|
|
|
logs.add(watchLog);
|
|
|
}
|
|
|
- batchUpdateFsUserCourseWatchLog(logs,100);
|
|
|
+ batchUpdateFsUserCourseWatchLog(logs, 100);
|
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(finishedLogs)){
|
|
|
+ if (CollectionUtils.isNotEmpty(finishedLogs)) {
|
|
|
fsTagUpdateService.onCourseWatchFinishedBatch(finishedLogs);
|
|
|
}
|
|
|
}
|
|
|
- public Long getFsUserVideoDuration(Long videoId){
|
|
|
+
|
|
|
+ public Long getFsUserVideoDuration(Long videoId) {
|
|
|
//将视频时长也存到redis
|
|
|
String videoRedisKey = "h5wxuser:video:duration:" + videoId;
|
|
|
- Long videoDuration=0L;
|
|
|
+ Long videoDuration = 0L;
|
|
|
try {
|
|
|
videoDuration = redisCache.getCacheObject(videoRedisKey);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
String string = redisCache.getCacheObject(videoRedisKey);
|
|
|
- videoDuration=Long.parseLong(string);
|
|
|
+ videoDuration = Long.parseLong(string);
|
|
|
log.error("key中id为S:{}", videoDuration);
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (videoDuration==null){
|
|
|
+ if (videoDuration == null) {
|
|
|
FsUserCourseVideo video = courseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
- videoDuration=video.getDuration();
|
|
|
- redisCache.setCacheObject(videoRedisKey,video.getDuration());
|
|
|
+ videoDuration = video.getDuration();
|
|
|
+ redisCache.setCacheObject(videoRedisKey, video.getDuration());
|
|
|
}
|
|
|
return videoDuration;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void checkFsUserWatchStatus() {
|
|
|
log.info("WXH5-开始更新会员看课中断记录>>>>>");
|
|
|
@@ -478,14 +477,14 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
watchLog.setLogType(4);
|
|
|
// 从 Redis 中删除该记录
|
|
|
redisCache.deleteObject(key);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
watchLog.setLogType(1);
|
|
|
watchingLogs.add(watchLog);
|
|
|
}
|
|
|
logs.add(watchLog);
|
|
|
}
|
|
|
- batchUpdateFsUserCourseWatchLog(logs,100);
|
|
|
- if(CollectionUtils.isNotEmpty(watchingLogs)){
|
|
|
+ batchUpdateFsUserCourseWatchLog(logs, 100);
|
|
|
+ if (CollectionUtils.isNotEmpty(watchingLogs)) {
|
|
|
fsTagUpdateService.onCourseWatchingBatch(watchingLogs);
|
|
|
}
|
|
|
}
|
|
|
@@ -513,13 +512,13 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsCourseWatchLog> finishedLogs = new ArrayList<>();
|
|
|
for (String key : keys) {
|
|
|
//取key中数据
|
|
|
- Long videoId=null;
|
|
|
- Long userId=null;
|
|
|
+ Long videoId = null;
|
|
|
+ Long userId = null;
|
|
|
try {
|
|
|
String[] parts = key.split(":");
|
|
|
userId = Long.parseLong(parts[3]);
|
|
|
videoId = Long.parseLong(parts[4]);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("key中id为null:{}", key);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -541,12 +540,12 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
if (videoDuration != null && videoDuration != 0) {
|
|
|
boolean complete = false;
|
|
|
// 判断百分比
|
|
|
- if(config.getCompletionMode() == 1 && config.getAnswerRate() != null){
|
|
|
+ if (config.getCompletionMode() == 1 && config.getAnswerRate() != null) {
|
|
|
long percentage = (duration * 100 / videoDuration);
|
|
|
complete = percentage >= config.getAnswerRate();
|
|
|
}
|
|
|
// 判断分钟数
|
|
|
- if(config.getCompletionMode() == 2 && config.getMinutesNum() != null){
|
|
|
+ if (config.getCompletionMode() == 2 && config.getMinutesNum() != null) {
|
|
|
int i = config.getMinutesNum() * 60;
|
|
|
complete = videoDuration > i;
|
|
|
}
|
|
|
@@ -554,7 +553,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
if (complete) {
|
|
|
watchLog.setLogType(2); // 设置状态为“已完成”
|
|
|
watchLog.setFinishTime(new Date());
|
|
|
- String heartbeatKey ="h5OpenUser:watch:heartbeat:" + userId + ":" + videoId;
|
|
|
+ String heartbeatKey = "h5OpenUser:watch:heartbeat:" + userId + ":" + videoId;
|
|
|
// 完课删除心跳记录
|
|
|
redisCache.deleteObject(heartbeatKey);
|
|
|
// 完课删除看课时长记录
|
|
|
@@ -567,10 +566,10 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
logs.add(watchLog);
|
|
|
}
|
|
|
|
|
|
- batchUpdateFsCourseWatchLogIsOpen(logs,100);
|
|
|
+ batchUpdateFsCourseWatchLogIsOpen(logs, 100);
|
|
|
|
|
|
// 完课打标签
|
|
|
- if(CollectionUtils.isNotEmpty(finishedLogs)){
|
|
|
+ if (CollectionUtils.isNotEmpty(finishedLogs)) {
|
|
|
fsTagUpdateService.onCourseWatchFinishedBatch(finishedLogs);
|
|
|
}
|
|
|
}
|
|
|
@@ -596,7 +595,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
try {
|
|
|
fsCourseWatchLogMapper.batchUpdateWatchLogIsOpen(batchList);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("第 {} 批日志更新失败:{}",(i / batchSize) + 1,e.getMessage(),e);
|
|
|
+ log.error("第 {} 批日志更新失败:{}", (i / batchSize) + 1, e.getMessage(), e);
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
@@ -639,9 +638,8 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FsCourseWatchLog getWatchCourseLogVideoBySop(Long videoId,String qwUserId,Long externalId )
|
|
|
- {
|
|
|
- return fsCourseWatchLogMapper.getWatchCourseLogVideoBySop(videoId,qwUserId,externalId);
|
|
|
+ public FsCourseWatchLog getWatchCourseLogVideoBySop(Long videoId, String qwUserId, Long externalId) {
|
|
|
+ return fsCourseWatchLogMapper.getWatchCourseLogVideoBySop(videoId, qwUserId, externalId);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -649,20 +647,20 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
public List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVO(FsCourseWatchLogListParam param) {
|
|
|
|
|
|
// 因为selectFsCourseWatchLogListVO 这个方法中查询了看课日志记录表 需要限制创建时间必传
|
|
|
- if((StringUtils.isEmpty(param.getSTime()) || StringUtils.isEmpty(param.getETime())) &&
|
|
|
+ if ((StringUtils.isEmpty(param.getSTime()) || StringUtils.isEmpty(param.getETime())) &&
|
|
|
(StringUtils.isEmpty(param.getUpSTime()) || StringUtils.isEmpty(param.getUpETime())) &&
|
|
|
- (StringUtils.isEmpty(param.getScheduleEndTime()) || StringUtils.isEmpty(param.getScheduleStartTime()))){
|
|
|
+ (StringUtils.isEmpty(param.getScheduleEndTime()) || StringUtils.isEmpty(param.getScheduleStartTime()))) {
|
|
|
throw new RuntimeException("请输入创建时间或营期时间或更新时间其中一个");
|
|
|
}
|
|
|
|
|
|
// 待看课-未注册
|
|
|
- if(ObjectUtil.equal(param.getLogType(),5)){
|
|
|
+ if (ObjectUtil.equal(param.getLogType(), 5)) {
|
|
|
param.setLogType(3);
|
|
|
param.setIsVip(0);
|
|
|
}
|
|
|
|
|
|
// 待看课-已注册
|
|
|
- if(ObjectUtil.equal(param.getLogType(),6)){
|
|
|
+ if (ObjectUtil.equal(param.getLogType(), 6)) {
|
|
|
param.setLogType(3);
|
|
|
param.setIsVip(1);
|
|
|
}
|
|
|
@@ -692,8 +690,8 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
@Override
|
|
|
public List<FsCourseWatchLogListVO> selectFsCourseWatchLogListByParam(FsCourseWatchLogListParam param) {
|
|
|
|
|
|
- if (param != null){
|
|
|
- if (param.getScheduleStartTime() != null && param.getScheduleEndTime() != null){
|
|
|
+ if (param != null) {
|
|
|
+ if (param.getScheduleStartTime() != null && param.getScheduleEndTime() != null) {
|
|
|
List<String> sopUserLogsVOS = sopUserLogsMapper.selectSopUserLogsByDate(param.getScheduleStartTime(), param.getScheduleEndTime());
|
|
|
param.setSopIds(sopUserLogsVOS);
|
|
|
}
|
|
|
@@ -701,7 +699,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsCourseWatchLogListVO> fsCourseWatchLogListVOS = fsCourseWatchLogMapper.selectFsCourseWatchLogListByParam(param);
|
|
|
|
|
|
|
|
|
- return fsCourseWatchLogListVOS ;
|
|
|
+ return fsCourseWatchLogListVOS;
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
@@ -712,9 +710,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
FsCourseWatchLog finishLog = fsCourseWatchLogMapper.selectFsCourseWatchLogByLogId(341170L);
|
|
|
QwUser qwUser = qwUserMapper.selectQwUserById(Long.valueOf(finishLog.getQwUserId()));
|
|
|
QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(finishLog.getQwExternalContactId());
|
|
|
- FsCourseFinishTemp finishTemp = fsCourseFinishTempMapper.selectFsCourseFinishTempByCompanyUserId(finishLog.getCompanyUserId(),finishLog.getVideoId());
|
|
|
+ FsCourseFinishTemp finishTemp = fsCourseFinishTempMapper.selectFsCourseFinishTempByCompanyUserId(finishLog.getCompanyUserId(), finishLog.getVideoId());
|
|
|
QwSopCourseFinishTempSetting setting = new QwSopCourseFinishTempSetting();
|
|
|
- if (finishTemp!=null){
|
|
|
+ if (finishTemp != null) {
|
|
|
// List<QwSopCourseFinishTempSetting> tempSettings = JSON.parseArray(finishTemp.getSetting(), QwSopCourseFinishTempSetting.class);
|
|
|
// 设置时间格式
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -738,7 +736,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
sopLogs.setExternalUserId(externalContact.getExternalUserId());
|
|
|
sopLogs.setExternalUserName(externalContact.getName());
|
|
|
sopLogs.setFsUserId(finishLog.getUserId());
|
|
|
- List<QwSopCourseFinishTempSetting.Setting> list = JSONArray.parseArray(finishTemp.getSetting(),QwSopCourseFinishTempSetting.Setting.class);
|
|
|
+ List<QwSopCourseFinishTempSetting.Setting> list = JSONArray.parseArray(finishTemp.getSetting(), QwSopCourseFinishTempSetting.Setting.class);
|
|
|
setting.setSetting(list);
|
|
|
sopLogs.setContentJson(JSON.toJSONString(setting));
|
|
|
|
|
|
@@ -746,7 +744,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
|
|
|
//封装消息体
|
|
|
- SendSopParamDetails sopParamDetailsB=new SendSopParamDetails();
|
|
|
+ SendSopParamDetails sopParamDetailsB = new SendSopParamDetails();
|
|
|
sopParamDetailsB.setSopLogId(sopLogs.getId());
|
|
|
sopParamDetailsB.setExternalUserId(sopLogs.getExternalUserId());
|
|
|
sopParamDetailsB.setExternalUserName(sopLogs.getExternalUserName());
|
|
|
@@ -757,7 +755,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
// //设置为已发送并更新
|
|
|
// finishLog.setSendFinishMsg(1);
|
|
|
// fsCourseWatchLogMapper.updateFsCourseWatchLog(finishLog);
|
|
|
- sendSocket("sendMsg",JSONObject.toJSONString(sopParamDetailsB),qwUser.getAppKey());
|
|
|
+ sendSocket("sendMsg", JSONObject.toJSONString(sopParamDetailsB), qwUser.getAppKey());
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -774,18 +772,18 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void sendSocket(String cmd,String message,String appKey){
|
|
|
- MsgBean msgBean=new MsgBean();
|
|
|
+ public void sendSocket(String cmd, String message, String appKey) {
|
|
|
+ MsgBean msgBean = new MsgBean();
|
|
|
msgBean.setCmd(cmd);
|
|
|
msgBean.setData(message);
|
|
|
msgBean.setKey(appKey);
|
|
|
- JSONObject params=new JSONObject();
|
|
|
- params.put("id",appKey);
|
|
|
- params.put("message",JSONObject.toJSONString(msgBean));
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("id", appKey);
|
|
|
+ params.put("message", JSONObject.toJSONString(msgBean));
|
|
|
FsSysConfig config = configUtil.getSysConfig();
|
|
|
String domainName = config.getHookUrl();
|
|
|
- HttpRequest.post(domainName+"/app/qwmsg/receiveMsg")
|
|
|
- .body(JSONObject.toJSONString(params),"application/json;charset=UTF-8")
|
|
|
+ HttpRequest.post(domainName + "/app/qwmsg/receiveMsg")
|
|
|
+ .body(JSONObject.toJSONString(params), "application/json;charset=UTF-8")
|
|
|
.execute().body();
|
|
|
}
|
|
|
|
|
|
@@ -805,15 +803,15 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsCourseWatchLog> finishedLogs = new ArrayList<>();
|
|
|
for (String key : keys) {
|
|
|
//取key中数据
|
|
|
- Long qwUserId=null;
|
|
|
- Long videoId=null;
|
|
|
- Long externalId=null;
|
|
|
+ Long qwUserId = null;
|
|
|
+ Long videoId = null;
|
|
|
+ Long externalId = null;
|
|
|
try {
|
|
|
String[] parts = key.split(":");
|
|
|
qwUserId = Long.parseLong(parts[3]);
|
|
|
externalId = Long.parseLong(parts[4]);
|
|
|
videoId = Long.parseLong(parts[5]);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("key中id为null:{}", key);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -835,7 +833,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
Long videoDuration = 0L;
|
|
|
try {
|
|
|
videoDuration = getVideoDuration(videoId);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("视频时长识别错误:{}", key);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -843,12 +841,12 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
if (videoDuration != null && videoDuration != 0) {
|
|
|
boolean complete = false;
|
|
|
// 判断百分比
|
|
|
- if(config.getCompletionMode() == 1 && config.getAnswerRate() != null){
|
|
|
+ if (config.getCompletionMode() == 1 && config.getAnswerRate() != null) {
|
|
|
long percentage = (duration * 100 / videoDuration);
|
|
|
complete = percentage >= config.getAnswerRate();
|
|
|
}
|
|
|
// 判断分钟数
|
|
|
- if(config.getCompletionMode() == 2 && config.getMinutesNum() != null){
|
|
|
+ if (config.getCompletionMode() == 2 && config.getMinutesNum() != null) {
|
|
|
int i = config.getMinutesNum() * 60;
|
|
|
complete = videoDuration > i;
|
|
|
}
|
|
|
@@ -856,7 +854,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
if (complete) {
|
|
|
watchLog.setLogType(2); // 设置状态为“已完成”
|
|
|
watchLog.setFinishTime(new Date());
|
|
|
- String heartbeatKey ="h5user:watch:heartbeat:" + qwUserId+ ":" + externalId + ":" + videoId;
|
|
|
+ String heartbeatKey = "h5user:watch:heartbeat:" + qwUserId + ":" + externalId + ":" + videoId;
|
|
|
// 完课删除心跳记录
|
|
|
redisCache.deleteObject(heartbeatKey);
|
|
|
// 完课删除看课时长记录
|
|
|
@@ -869,10 +867,10 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
logs.add(watchLog);
|
|
|
}
|
|
|
|
|
|
- batchUpdateFsCourseWatchLog(logs,100);
|
|
|
+ batchUpdateFsCourseWatchLog(logs, 100);
|
|
|
|
|
|
// 完课打标签
|
|
|
- if(CollectionUtils.isNotEmpty(finishedLogs)){
|
|
|
+ if (CollectionUtils.isNotEmpty(finishedLogs)) {
|
|
|
fsTagUpdateService.onCourseWatchFinishedBatch(finishedLogs);
|
|
|
}
|
|
|
}
|
|
|
@@ -889,15 +887,15 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
for (String key : keys) {
|
|
|
FsCourseWatchLog watchLog = new FsCourseWatchLog();
|
|
|
//取key中数据
|
|
|
- Long qwUserId=null;
|
|
|
- Long videoId=null;
|
|
|
- Long externalId=null;
|
|
|
+ Long qwUserId = null;
|
|
|
+ Long videoId = null;
|
|
|
+ Long externalId = null;
|
|
|
try {
|
|
|
String[] parts = key.split(":");
|
|
|
qwUserId = Long.parseLong(parts[3]);
|
|
|
externalId = Long.parseLong(parts[4]);
|
|
|
videoId = Long.parseLong(parts[5]);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.error("key中id为null:{}", key);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -918,15 +916,15 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
watchLog.setLogType(4);
|
|
|
// 从 Redis 中删除该记录
|
|
|
redisCache.deleteObject(key);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
watchLog.setLogType(1);
|
|
|
watchingLogs.add(watchLog);
|
|
|
}
|
|
|
logs.add(watchLog);
|
|
|
}
|
|
|
- batchUpdateFsCourseWatchLog(logs,100);
|
|
|
+ batchUpdateFsCourseWatchLog(logs, 100);
|
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(watchingLogs)){
|
|
|
+ if (CollectionUtils.isNotEmpty(watchingLogs)) {
|
|
|
fsTagUpdateService.onCourseWatchingBatch(watchingLogs);
|
|
|
}
|
|
|
}
|
|
|
@@ -952,26 +950,26 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsQwCourseWatchLogVO> watchLogs = fsCourseWatchLogMapper.selectFsCourseWatchLogByNoDayAndVoidIdByTime(fsUserCourseVideo.getVideoId(), DateUtil.formatLocalDateTime(start), DateUtil.formatLocalDateTime(end));
|
|
|
for (FsQwCourseWatchLogVO fsCourseWatchLog : watchLogs) {
|
|
|
Date firstTime = fsCourseWatchLog.getFirstTime();
|
|
|
- Long day=1L;
|
|
|
- if (fsCourseWatchLog.getLineTime()==null){
|
|
|
+ Long day = 1L;
|
|
|
+ if (fsCourseWatchLog.getLineTime() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
//不是第一次 看课程
|
|
|
- if (firstTime!=null){
|
|
|
+ if (firstTime != null) {
|
|
|
LocalDate firstLocalDate = firstTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
day = ChronoUnit.DAYS.between(firstLocalDate, currentDate);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//是先导课
|
|
|
- if (fsUserCourseVideo.getIsFirst()!=null&&fsUserCourseVideo.getIsFirst()==1){
|
|
|
+ if (fsUserCourseVideo.getIsFirst() != null && fsUserCourseVideo.getIsFirst() == 1) {
|
|
|
int count = qwWatchLogMapper.selectQwWatchLogIsFirst(fsCourseWatchLog.getQwExternalContactId());
|
|
|
- if (count>0){
|
|
|
+ if (count > 0) {
|
|
|
continue;
|
|
|
}
|
|
|
- day=0L;
|
|
|
+ day = 0L;
|
|
|
//不是先导课
|
|
|
- }else {
|
|
|
- day=1L;
|
|
|
+ } else {
|
|
|
+ day = 1L;
|
|
|
QwExternalContact qwExternalContact = new QwExternalContact();
|
|
|
qwExternalContact.setId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
qwExternalContact.setFirstTime(fsCourseWatchLog.getCreateTime());
|
|
|
@@ -983,18 +981,19 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
|
|
|
qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
|
|
|
qwWatchLog.setDay(day);
|
|
|
- qwWatchLog.setStatus(fsCourseWatchLog.getLogType()==3?0:fsCourseWatchLog.getLogType()==2?2:1);
|
|
|
+ qwWatchLog.setStatus(fsCourseWatchLog.getLogType() == 3 ? 0 : fsCourseWatchLog.getLogType() == 2 ? 2 : 1);
|
|
|
qwWatchLog.setProject(project);
|
|
|
qwWatchLog.setCreateTime(fsCourseWatchLog.getCreateTime());
|
|
|
QwWatchLogs.add(qwWatchLog);
|
|
|
}
|
|
|
- if (!QwWatchLogs.isEmpty()){
|
|
|
+ if (!QwWatchLogs.isEmpty()) {
|
|
|
qwWatchLogMapper.insertQwWatchLogBatch(QwWatchLogs);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void addCourseWatchLogDay() {
|
|
|
|
|
|
@@ -1005,53 +1004,54 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
for (FsUserCourseVideo fsUserCourseVideo : fsUserCourseVideos) {
|
|
|
ArrayList<QwWatchLog> QwWatchLogs = new ArrayList<>();
|
|
|
List<FsQwCourseWatchLogVO> watchLogs = fsCourseWatchLogMapper.selectFsCourseWatchLogByNoDayAndVoidId(fsUserCourseVideo.getVideoId());
|
|
|
- for (FsQwCourseWatchLogVO fsCourseWatchLog : watchLogs) {
|
|
|
- Date firstTime = fsCourseWatchLog.getFirstTime();
|
|
|
- Long day=1L;
|
|
|
- if (fsCourseWatchLog.getLineTime()==null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- //不是第一次 看课程
|
|
|
- if (firstTime!=null){
|
|
|
- LocalDate firstLocalDate = firstTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- day = ChronoUnit.DAYS.between(firstLocalDate, currentDate);
|
|
|
- }else {
|
|
|
- //是先导课
|
|
|
- if (fsUserCourseVideo.getIsFirst()!=null&&fsUserCourseVideo.getIsFirst()==1){
|
|
|
- int count = qwWatchLogMapper.selectQwWatchLogIsFirst(fsCourseWatchLog.getQwExternalContactId());
|
|
|
- if (count>0){
|
|
|
- continue;
|
|
|
- }
|
|
|
- day=0L;
|
|
|
- //不是先导课
|
|
|
- }else {
|
|
|
- day=1L;
|
|
|
- QwExternalContact qwExternalContact = new QwExternalContact();
|
|
|
- qwExternalContact.setId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
- qwExternalContact.setFirstTime(fsCourseWatchLog.getCreateTime());
|
|
|
- qwExternalContactMapper.updateQwExternalContact(qwExternalContact);
|
|
|
+ for (FsQwCourseWatchLogVO fsCourseWatchLog : watchLogs) {
|
|
|
+ Date firstTime = fsCourseWatchLog.getFirstTime();
|
|
|
+ Long day = 1L;
|
|
|
+ if (fsCourseWatchLog.getLineTime() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //不是第一次 看课程
|
|
|
+ if (firstTime != null) {
|
|
|
+ LocalDate firstLocalDate = firstTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ day = ChronoUnit.DAYS.between(firstLocalDate, currentDate);
|
|
|
+ } else {
|
|
|
+ //是先导课
|
|
|
+ if (fsUserCourseVideo.getIsFirst() != null && fsUserCourseVideo.getIsFirst() == 1) {
|
|
|
+ int count = qwWatchLogMapper.selectQwWatchLogIsFirst(fsCourseWatchLog.getQwExternalContactId());
|
|
|
+ if (count > 0) {
|
|
|
+ continue;
|
|
|
}
|
|
|
+ day = 0L;
|
|
|
+ //不是先导课
|
|
|
+ } else {
|
|
|
+ day = 1L;
|
|
|
+ QwExternalContact qwExternalContact = new QwExternalContact();
|
|
|
+ qwExternalContact.setId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
+ qwExternalContact.setFirstTime(fsCourseWatchLog.getCreateTime());
|
|
|
+ qwExternalContactMapper.updateQwExternalContact(qwExternalContact);
|
|
|
}
|
|
|
- QwWatchLog qwWatchLog = new QwWatchLog();
|
|
|
- qwWatchLog.setExtId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
- qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
|
|
|
- qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
|
|
|
- qwWatchLog.setDay(day);
|
|
|
- qwWatchLog.setStatus(fsCourseWatchLog.getLogType()==3?0:fsCourseWatchLog.getLogType()==2?2:1);
|
|
|
- qwWatchLog.setProject(project);
|
|
|
- qwWatchLog.setCreateTime(fsCourseWatchLog.getCreateTime());
|
|
|
- QwWatchLogs.add(qwWatchLog);
|
|
|
- }
|
|
|
- if (!QwWatchLogs.isEmpty()){
|
|
|
- qwWatchLogMapper.insertQwWatchLogBatch(QwWatchLogs);
|
|
|
}
|
|
|
+ QwWatchLog qwWatchLog = new QwWatchLog();
|
|
|
+ qwWatchLog.setExtId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
+ qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
|
|
|
+ qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
|
|
|
+ qwWatchLog.setDay(day);
|
|
|
+ qwWatchLog.setStatus(fsCourseWatchLog.getLogType() == 3 ? 0 : fsCourseWatchLog.getLogType() == 2 ? 2 : 1);
|
|
|
+ qwWatchLog.setProject(project);
|
|
|
+ qwWatchLog.setCreateTime(fsCourseWatchLog.getCreateTime());
|
|
|
+ QwWatchLogs.add(qwWatchLog);
|
|
|
+ }
|
|
|
+ if (!QwWatchLogs.isEmpty()) {
|
|
|
+ qwWatchLogMapper.insertQwWatchLogBatch(QwWatchLogs);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void addCourseWatchLogDay2() {
|
|
|
|
|
|
@@ -1064,27 +1064,27 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
List<FsQwCourseWatchLogVO> watchLogs = fsCourseWatchLogMapper.selectFsCourseWatchLogByNoDayAndVoidId2(fsUserCourseVideo.getVideoId());
|
|
|
for (FsQwCourseWatchLogVO fsCourseWatchLog : watchLogs) {
|
|
|
Date firstTime = fsCourseWatchLog.getFirstTime();
|
|
|
- Long day=1L;
|
|
|
- if (fsCourseWatchLog.getLineTime()==null){
|
|
|
+ Long day = 1L;
|
|
|
+ if (fsCourseWatchLog.getLineTime() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
//不是第一次 看课程
|
|
|
- if (firstTime!=null){
|
|
|
+ if (firstTime != null) {
|
|
|
LocalDate firstLocalDate = firstTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
day = ChronoUnit.DAYS.between(firstLocalDate, currentDate);
|
|
|
- day=day-1;
|
|
|
- }else {
|
|
|
+ day = day - 1;
|
|
|
+ } else {
|
|
|
//是先导课
|
|
|
- if (fsUserCourseVideo.getIsFirst()!=null&&fsUserCourseVideo.getIsFirst()==1){
|
|
|
+ if (fsUserCourseVideo.getIsFirst() != null && fsUserCourseVideo.getIsFirst() == 1) {
|
|
|
int count = qwWatchLogMapper.selectQwWatchLogIsFirst(fsCourseWatchLog.getQwExternalContactId());
|
|
|
- if (count>0){
|
|
|
+ if (count > 0) {
|
|
|
continue;
|
|
|
}
|
|
|
- day=0L;
|
|
|
+ day = 0L;
|
|
|
//不是先导课
|
|
|
- }else {
|
|
|
- day=1L;
|
|
|
+ } else {
|
|
|
+ day = 1L;
|
|
|
QwExternalContact qwExternalContact = new QwExternalContact();
|
|
|
qwExternalContact.setId(fsCourseWatchLog.getQwExternalContactId());
|
|
|
qwExternalContact.setFirstTime(fsCourseWatchLog.getCreateTime());
|
|
|
@@ -1096,12 +1096,12 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
qwWatchLog.setLineTime(fsCourseWatchLog.getLineTime());
|
|
|
qwWatchLog.setQwUserId(Long.parseLong(fsCourseWatchLog.getQwUserId()));
|
|
|
qwWatchLog.setDay(day);
|
|
|
- qwWatchLog.setStatus(fsCourseWatchLog.getLogType()==3?0:fsCourseWatchLog.getLogType()==2?2:1);
|
|
|
+ qwWatchLog.setStatus(fsCourseWatchLog.getLogType() == 3 ? 0 : fsCourseWatchLog.getLogType() == 2 ? 2 : 1);
|
|
|
qwWatchLog.setProject(project);
|
|
|
qwWatchLog.setCreateTime(fsCourseWatchLog.getCreateTime());
|
|
|
QwWatchLogs.add(qwWatchLog);
|
|
|
}
|
|
|
- if (!QwWatchLogs.isEmpty()){
|
|
|
+ if (!QwWatchLogs.isEmpty()) {
|
|
|
qwWatchLogMapper.insertQwWatchLogBatch(QwWatchLogs);
|
|
|
}
|
|
|
|
|
|
@@ -1112,35 +1112,35 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Long getVideoDuration(Long videoId){
|
|
|
+ public Long getVideoDuration(Long videoId) {
|
|
|
//将视频时长也存到redis
|
|
|
String videoRedisKey = "h5user:video:duration:" + videoId;
|
|
|
- Long videoDuration=0L;
|
|
|
+ Long videoDuration = 0L;
|
|
|
try {
|
|
|
videoDuration = redisCache.getCacheObject(videoRedisKey);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
String string = redisCache.getCacheObject(videoRedisKey);
|
|
|
- videoDuration=Long.parseLong(string);
|
|
|
+ videoDuration = Long.parseLong(string);
|
|
|
log.error("key中id为S:{}", videoDuration);
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (videoDuration==null){
|
|
|
+ if (videoDuration == null) {
|
|
|
FsUserCourseVideo video = courseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
- videoDuration=video.getDuration();
|
|
|
- redisCache.setCacheObject(videoRedisKey,video.getDuration());
|
|
|
+ videoDuration = video.getDuration();
|
|
|
+ redisCache.setCacheObject(videoRedisKey, video.getDuration());
|
|
|
}
|
|
|
return videoDuration;
|
|
|
}
|
|
|
|
|
|
- public Long getVideoDurationIsOpen(Long videoId){
|
|
|
+ public Long getVideoDurationIsOpen(Long videoId) {
|
|
|
//将视频时长也存到redis
|
|
|
String videoRedisKey = "h5OpenUser:video:duration:" + videoId;
|
|
|
Long videoDuration = redisCache.getCacheObject(videoRedisKey);
|
|
|
- if (videoDuration==null){
|
|
|
+ if (videoDuration == null) {
|
|
|
FsUserCourseVideo video = courseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
- videoDuration=video.getDuration();
|
|
|
- redisCache.setCacheObject(videoRedisKey,video.getDuration());
|
|
|
+ videoDuration = video.getDuration();
|
|
|
+ redisCache.setCacheObject(videoRedisKey, video.getDuration());
|
|
|
}
|
|
|
return videoDuration;
|
|
|
}
|
|
|
@@ -1167,7 +1167,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
try {
|
|
|
fsCourseWatchLogMapper.batchUpdateWatchLog(batchList);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("第 {} 批日志更新失败:{}",(i / batchSize) + 1,e.getMessage(),e);
|
|
|
+ log.error("第 {} 批日志更新失败:{}", (i / batchSize) + 1, e.getMessage(), e);
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
@@ -1181,22 +1181,21 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public List<FsCourseWatchLogListVO> selectFsCourseWatchLogListVOexport(FsCourseWatchLogListParam param) {
|
|
|
|
|
|
|
|
|
- if (param.getSendType()==1&& param.getPeriodETime()!=null && param.getPeriodSTime()!=null) {
|
|
|
+ if (param.getSendType() == 1 && param.getPeriodETime() != null && param.getPeriodSTime() != null) {
|
|
|
List<Long> periodIds = userCoursePeriodDaysService.selectFsUserCoursePeriodDaysByTime(param.getPeriodSTime(), param.getPeriodETime());
|
|
|
|
|
|
- if (!periodIds.isEmpty()){
|
|
|
+ if (!periodIds.isEmpty()) {
|
|
|
List<Long> longs = userCoursePeriodService.selectFsUserCoursePeriodListByPeriodId(periodIds, param.getCompanyId());
|
|
|
- if (!longs.isEmpty()){
|
|
|
+ if (!longs.isEmpty()) {
|
|
|
param.setPeriodIds(longs);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
@@ -1217,69 +1216,69 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
.findFirst()
|
|
|
.orElse("无营期名称");
|
|
|
item.setPeriodIdName(periodName);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
item.setPeriodIdName("自动发课无营期名称");
|
|
|
}
|
|
|
|
|
|
// 项目
|
|
|
- if(ObjectUtils.isNotNull(item.getProject())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getProject())) {
|
|
|
String sysCourseProject = DictUtils.getDictLabel("sys_course_project", String.valueOf(item.getProject()));
|
|
|
- if(StringUtils.isNotBlank(sysCourseProject)){
|
|
|
+ if (StringUtils.isNotBlank(sysCourseProject)) {
|
|
|
item.setProjectName(sysCourseProject);
|
|
|
}
|
|
|
}
|
|
|
// 用户名
|
|
|
- if(ObjectUtils.isNotNull(item.getUserId())) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getUserId())) {
|
|
|
FsUser fsUser = fsUserCacheService.selectFsUserById(item.getUserId());
|
|
|
- if(ObjectUtils.isNotNull(fsUser)){
|
|
|
- item.setExternalUserName(String.format("%s_%d",fsUser.getNickName(),fsUser.getUserId()));
|
|
|
+ if (ObjectUtils.isNotNull(fsUser)) {
|
|
|
+ item.setExternalUserName(String.format("%s_%d", fsUser.getNickName(), fsUser.getUserId()));
|
|
|
item.setFsNickName(fsUser.getNickName());
|
|
|
item.setFsAvatar(fsUser.getAvatar());
|
|
|
}
|
|
|
}
|
|
|
// 公司名
|
|
|
- if(ObjectUtils.isNotNull(item.getCompanyId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getCompanyId())) {
|
|
|
Company company = companyCacheService.selectCompanyById(Long.valueOf(item.getCompanyId()));
|
|
|
- if(ObjectUtils.isNotNull(company)){
|
|
|
+ if (ObjectUtils.isNotNull(company)) {
|
|
|
item.setCompanyName(String.format("%s_%d", company.getCompanyName(), company.getCompanyId()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 销售名
|
|
|
- if(ObjectUtils.isNotNull(item.getCompanyUserId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getCompanyUserId())) {
|
|
|
CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(item.getCompanyUserId());
|
|
|
- if(ObjectUtils.isNotNull(companyUser)){
|
|
|
+ if (ObjectUtils.isNotNull(companyUser)) {
|
|
|
item.setCompanyUserName(String.format("%s_%d", companyUser.getNickName(), companyUser.getUserId()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 课程
|
|
|
- if(ObjectUtils.isNotNull(item.getCourseId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getCourseId())) {
|
|
|
FsUserCourse course = fsUserCourseCacheService.selectFsUserCourseByCourseId(item.getCourseId());
|
|
|
- if(ObjectUtils.isNotNull(course)){
|
|
|
+ if (ObjectUtils.isNotNull(course)) {
|
|
|
item.setCourseName(course.getCourseName());
|
|
|
}
|
|
|
}
|
|
|
// 小节
|
|
|
- if(ObjectUtils.isNotNull(item.getVideoId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getVideoId())) {
|
|
|
FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoCacheService.selectFsUserCourseVideoByVideoId(item.getVideoId());
|
|
|
- if(ObjectUtils.isNotNull(fsUserCourseVideo)){
|
|
|
+ if (ObjectUtils.isNotNull(fsUserCourseVideo)) {
|
|
|
item.setVideoName(fsUserCourseVideo.getTitle());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 企微用户名
|
|
|
- if(ObjectUtils.isNotNull(item.getQwUserId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getQwUserId())) {
|
|
|
String qwUserName = qwUserCacheService.queryQwUserNameByUserId(item.getQwUserId());
|
|
|
- if(StringUtils.isNotBlank(qwUserName)){
|
|
|
+ if (StringUtils.isNotBlank(qwUserName)) {
|
|
|
item.setQwUserName(qwUserName);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 企微外部联系人
|
|
|
- if(ObjectUtils.isNotNull(item.getQwExternalContactId())){
|
|
|
+ if (ObjectUtils.isNotNull(item.getQwExternalContactId())) {
|
|
|
String qwExternalContactName = qwExternalContactCacheService.selectQwExternalContactById(Long.valueOf(item.getQwExternalContactId()));
|
|
|
- if(StringUtils.isNotBlank(qwExternalContactName)){
|
|
|
+ if (StringUtils.isNotBlank(qwExternalContactName)) {
|
|
|
item.setExternalUserName(qwExternalContactName);
|
|
|
}
|
|
|
}
|
|
|
@@ -1300,32 +1299,276 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
|
|
|
@Override
|
|
|
public List<FsUserReportVO> selectFsUserReportVO(FsCourseWatchLogStatisticsListParam param) {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserPhone())){
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserPhone())) {
|
|
|
//加密手机号
|
|
|
param.setUserPhone(PhoneUtil.encryptPhone(param.getUserPhone()));
|
|
|
}
|
|
|
- return fsCourseWatchLogMapper.selectFsUserReportVO(param);
|
|
|
+ List<FsUserReportVO> userList = fsCourseWatchLogMapper.selectUserBaseInfo(param);
|
|
|
+ if (CollectionUtils.isEmpty(userList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<UserConditionDTO> userCondition = userList.stream()
|
|
|
+ .map(user -> new UserConditionDTO(user.getUserId(), user.getCompanyUserId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> userIds = userList.stream().map(FsUserReportVO::getUserId).collect(Collectors.toList());
|
|
|
+ // 3. 批量查询各项统计数据
|
|
|
+ Map<String, FsUserReportVO> watchStatsMap = fsCourseWatchLogMapper.selectWatchStatsByUserIds(userCondition, param)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ stats -> buildKey(stats.getUserId(), stats.getCompanyUserId()),
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+
|
|
|
+ Map<Long, FsUserReportVO> integralStatsMap = fsCourseWatchLogMapper.selectIntegralStatsByUserIds(userIds)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ Map<String, FsUserReportVO> redPacketStatsMap = fsCourseWatchLogMapper.selectRedPacketStatsByUserIds(userCondition, param)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ stats -> buildKey(stats.getUserId(), stats.getCompanyUserId()),
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+
|
|
|
+ Map<Long, FsUserReportVO> orderStatsMap = fsCourseWatchLogMapper.selectOrderStatsByUserIds(userIds)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(FsUserReportVO::getUserId, Function.identity()));
|
|
|
+ userList.forEach(user -> {
|
|
|
+ String key = buildKey(user.getUserId(), user.getCompanyUserId());
|
|
|
+ //看课统计
|
|
|
+ FsUserReportVO watchStats = watchStatsMap.get(key);
|
|
|
+ if (watchStats != null) {
|
|
|
+ user.setLastWatchTime(watchStats.getLastWatchTime());
|
|
|
+ user.setWatchCount(watchStats.getWatchCount());
|
|
|
+ user.setPeriodCount(watchStats.getPeriodCount());
|
|
|
+ user.setWatchStatus(watchStats.getWatchStatus());
|
|
|
+ }
|
|
|
+ //积分统计
|
|
|
+ FsUserReportVO fsUserReportVO = integralStatsMap.get(user.getUserId());
|
|
|
+ if (fsUserReportVO != null) {
|
|
|
+ user.setIntegral(fsUserReportVO.getIntegral());
|
|
|
+ user.setConsumedIntegral(fsUserReportVO.getConsumedIntegral());
|
|
|
+ }
|
|
|
+ //红包统计
|
|
|
+ FsUserReportVO redPacketStats = redPacketStatsMap.get(key);
|
|
|
+ if (redPacketStats != null) {
|
|
|
+ user.setReceivedAmount(redPacketStats.getReceivedAmount());
|
|
|
+ }
|
|
|
+ //订单统计
|
|
|
+ FsUserReportVO orderStats = orderStatsMap.get(user.getUserId());
|
|
|
+ if (orderStats != null) {
|
|
|
+ user.setOrderAmount(orderStats.getOrderAmount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return userList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<WatchLogReportVO> selectWatchLogReportVO(FsCourseWatchLogStatisticsListParam param) {
|
|
|
- if(StringUtils.isNotEmpty(param.getUserPhone())){
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserPhone())) {
|
|
|
//加密手机号
|
|
|
param.setUserPhone(PhoneUtil.encryptPhone(param.getUserPhone()));
|
|
|
}
|
|
|
- return fsCourseWatchLogMapper.selectWatchLogReportVO(param);
|
|
|
+ // 获取基础数据
|
|
|
+ List<WatchLogReportVO> baseData = getBaseDataByDimension(param);
|
|
|
+ if (CollectionUtils.isEmpty(baseData)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 获取统计数据和组装结果
|
|
|
+ return assembleStatisticsData(baseData, param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据维度获取基础数据
|
|
|
+ */
|
|
|
+ private List<WatchLogReportVO> getBaseDataByDimension(FsCourseWatchLogStatisticsListParam param) {
|
|
|
+ switch (param.getDimension()) {
|
|
|
+ case "user":
|
|
|
+ return fsCourseWatchLogMapper.selectUserBaseData(param);
|
|
|
+ case "sales":
|
|
|
+ return fsCourseWatchLogMapper.selectSalesBaseData(param);
|
|
|
+ case "company":
|
|
|
+ return fsCourseWatchLogMapper.selectCompanyBaseData(param);
|
|
|
+ default:
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装统计数据
|
|
|
+ */
|
|
|
+ private List<WatchLogReportVO> assembleStatisticsData(List<WatchLogReportVO> baseData, FsCourseWatchLogStatisticsListParam param) {
|
|
|
+ // 准备查询条件
|
|
|
+ List<UserConditionDTO> userCondition = baseData.stream()
|
|
|
+ .map(user -> new UserConditionDTO(user.getUserId(), user.getCompanyUserId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<Long> userIds = baseData.stream().map(WatchLogReportVO::getUserId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 批量查询统计数据
|
|
|
+ Map<String, WatchLogReportVO> watchMap = convertWatchStatsToMap(
|
|
|
+ fsCourseWatchLogMapper.selectUserWatchDetails(userCondition, param)
|
|
|
+ );
|
|
|
+ Map<Long, WatchLogReportVO> redPacketMap = convertRedPacketToMap(
|
|
|
+ fsCourseWatchLogMapper.selectRedPacketStats(userIds)
|
|
|
+ );
|
|
|
+ Map<Long, WatchLogReportVO> orderMap = convertOrderToMap(
|
|
|
+ fsCourseWatchLogMapper.selectOrderStats(userIds)
|
|
|
+ );
|
|
|
+ Map<Long, WatchLogReportVO> answerMap = convertAnswerToMap(
|
|
|
+ fsCourseWatchLogMapper.selectAnswerStats(userIds)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 组装数据
|
|
|
+ for (WatchLogReportVO item : baseData) {
|
|
|
+ String key = buildKey(item.getUserId(), item.getCompanyUserId());
|
|
|
+
|
|
|
+ // 看课数据
|
|
|
+ WatchLogReportVO watchStats = watchMap.get(key);
|
|
|
+ if (watchStats != null) {
|
|
|
+ setWatchData(item, watchStats, param.getDimension());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 红包数据
|
|
|
+ WatchLogReportVO redPacketStats = redPacketMap.get(item.getUserId());
|
|
|
+ if (redPacketStats != null) {
|
|
|
+ item.setRedPacketAmount(redPacketStats.getRedPacketAmount());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单数据
|
|
|
+ WatchLogReportVO order = orderMap.get(item.getUserId());
|
|
|
+ if (order != null) {
|
|
|
+ item.setHistoryOrderCount(order.getHistoryOrderCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 答题数据
|
|
|
+ WatchLogReportVO answer = answerMap.get(item.getUserId());
|
|
|
+ if (answer != null) {
|
|
|
+ setAnswerData(item, answer, param.getDimension());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return baseData;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置看课数据(根据不同维度设置不同字段)
|
|
|
+ */
|
|
|
+ private void setWatchData(WatchLogReportVO target, WatchLogReportVO source, String dimension) {
|
|
|
+ target.setTrainingCampName(source.getTrainingCampName());
|
|
|
+ target.setPeriodName(source.getPeriodName());
|
|
|
+ target.setVideoTitle(source.getVideoTitle());
|
|
|
+
|
|
|
+ if ("user".equals(dimension)) {
|
|
|
+ target.setWatchStatus(source.getWatchStatus());
|
|
|
+ target.setDuration(source.getDuration());
|
|
|
+ target.setCourseTime(source.getCourseTime());
|
|
|
+ target.setFinishTime(source.getFinishTime());
|
|
|
+ } else {
|
|
|
+ target.setFinishedCount(source.getFinishedCount());
|
|
|
+ target.setUnfinishedCount(source.getUnfinishedCount());
|
|
|
+ target.setCompletionRate(calculateCompletionRate(source));
|
|
|
+ target.setNotWatchedCount(source.getNotWatchedCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置答题数据(根据不同维度设置不同字段)
|
|
|
+ */
|
|
|
+ private void setAnswerData(WatchLogReportVO target, WatchLogReportVO source, String dimension) {
|
|
|
+ if ("user".equals(dimension)) {
|
|
|
+ target.setAnswerStatus(source.getAnswerStatus());
|
|
|
+ } else {
|
|
|
+ target.setNotAnsweredCount(source.getNotAnsweredCount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 看课数据转Map
|
|
|
+ */
|
|
|
+ public Map<String, WatchLogReportVO> convertWatchStatsToMap(List<WatchLogReportVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ return list.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ stats -> buildKey(stats.getUserId(), stats.getCompanyUserId()),
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 红包数据转Map
|
|
|
+ */
|
|
|
+ public Map<Long, WatchLogReportVO> convertRedPacketToMap(List<WatchLogReportVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ return list.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ WatchLogReportVO::getUserId,
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单数据转Map
|
|
|
+ */
|
|
|
+ public Map<Long, WatchLogReportVO> convertOrderToMap(List<WatchLogReportVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ return list.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ WatchLogReportVO::getUserId,
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 答题数据转Map
|
|
|
+ */
|
|
|
+ public Map<Long, WatchLogReportVO> convertAnswerToMap(List<WatchLogReportVO> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
+ return list.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ WatchLogReportVO::getUserId,
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing // 当出现重复键时,保留第一个值
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ private String buildKey(Long userId, Long companyUserId) {
|
|
|
+ return userId + "_" + companyUserId;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算完成率
|
|
|
+ */
|
|
|
+ private BigDecimal calculateCompletionRate(WatchLogReportVO watchStats) {
|
|
|
+ if (watchStats.getTotalLogCount() == 0) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ return BigDecimal.valueOf(watchStats.getFinishedCount() * 100.0 / watchStats.getTotalLogCount())
|
|
|
+ .setScale(2, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据看课记录id获取所有的外部联系人ids
|
|
|
+ *
|
|
|
* @param watchLogIds
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Long> getExContactIdsIdsByWatchLogIds(List<Long> watchLogIds){
|
|
|
+ public List<Long> getExContactIdsIdsByWatchLogIds(List<Long> watchLogIds) {
|
|
|
return fsCourseWatchLogMapper.getExContactIdsIdsByWatchLogIds(watchLogIds);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|