|
@@ -11,29 +11,29 @@ import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCourseFinishTemp;
|
|
|
import com.fs.course.domain.FsCourseWatchLog;
|
|
|
+import com.fs.course.domain.FsUserCourse;
|
|
|
import com.fs.course.domain.FsUserCourseVideo;
|
|
|
import com.fs.course.mapper.FsCourseFinishTempMapper;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
+import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
-import com.fs.course.param.FsCourseWatchLogListParam;
|
|
|
-import com.fs.course.param.FsCourseWatchLogParam;
|
|
|
-import com.fs.course.param.FsCourseWatchLogStatisticsListParam;
|
|
|
+import com.fs.course.param.*;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
-import com.fs.course.vo.FsCourseWatchLogListVO;
|
|
|
-import com.fs.course.vo.FsCourseWatchLogStatisticsListVO;
|
|
|
+import com.fs.course.vo.*;
|
|
|
+import com.fs.his.config.FsSysConfig;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.qw.Bean.MsgBean;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
+import com.fs.qw.domain.QwWatchLog;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
+import com.fs.qw.mapper.QwWatchLogMapper;
|
|
|
import com.fs.qw.param.SendSopParamDetails;
|
|
|
-import com.fs.qw.param.SopUserLogsVO;
|
|
|
import com.fs.qw.vo.QwSopCourseFinishTempSetting;
|
|
|
import com.fs.qw.vo.QwSopTempSetting;
|
|
|
import com.fs.sop.domain.QwSopLogs;
|
|
|
-import com.fs.sop.mapper.QwSopLogsMapper;
|
|
|
import com.fs.sop.mapper.SopUserLogsMapper;
|
|
|
-import com.fs.sop.service.IQwSopLogsService;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -41,9 +41,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.Duration;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 短链课程看课记录Service业务层处理
|
|
@@ -59,20 +65,23 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
private FsCourseWatchLogMapper fsCourseWatchLogMapper;
|
|
|
@Autowired
|
|
|
private SopUserLogsMapper sopUserLogsMapper;
|
|
|
- @Autowired
|
|
|
- private QwSopLogsMapper sopLogsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private IQwSopLogsService qwSopLogsService;
|
|
|
+ private FsUserCourseVideoMapper fsUserCourseVideoMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsUserCourseMapper fsUserCourseMapper;
|
|
|
@Autowired
|
|
|
private FsCourseFinishTempMapper fsCourseFinishTempMapper;
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
@Autowired
|
|
|
RedisCache redisCache;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private QwWatchLogMapper qwWatchLogMapper;
|
|
|
@Autowired
|
|
|
private FsUserCourseVideoMapper courseVideoMapper;
|
|
|
+ @Autowired
|
|
|
+ private ConfigUtil configUtil;
|
|
|
|
|
|
/**
|
|
|
* 查询短链课程看课记录
|
|
@@ -164,6 +173,10 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
return fsCourseWatchLogMapper.getWatchCourseVideo(userId,videoId,qwUserId,externalId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public FsCourseWatchLog getWatchCourseVideoH5(Long videoId, String qwUserId, Long externalId) {
|
|
|
+ return fsCourseWatchLogMapper.getWatchCourseLogVideoBySop(videoId,qwUserId,externalId);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public FsCourseWatchLog getWatchCourseLogVideoBySop(Long videoId,String qwUserId,Long externalId )
|
|
@@ -256,8 +269,6 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
return fsCourseWatchLogMapper.selectFsCourseWatchLogStatisticsListVO(param);
|
|
|
}
|
|
|
|
|
|
- private static final String hookUrl = "https://qwtool.ylrzcloud.com/app/";
|
|
|
-
|
|
|
|
|
|
public void sendSocket(String cmd,String message,String appKey){
|
|
|
MsgBean msgBean=new MsgBean();
|
|
@@ -267,7 +278,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
JSONObject params=new JSONObject();
|
|
|
params.put("id",appKey);
|
|
|
params.put("message",JSONObject.toJSONString(msgBean));
|
|
|
- HttpRequest.post(hookUrl+"qwmsg/receiveMsg")
|
|
|
+ FsSysConfig config = configUtil.getSysConfig();
|
|
|
+ String domainName = config.getHookUrl();
|
|
|
+ HttpRequest.post(domainName+"/app/qwmsg/receiveMsg")
|
|
|
.body(JSONObject.toJSONString(params),"application/json;charset=UTF-8")
|
|
|
.execute().body();
|
|
|
}
|
|
@@ -362,6 +375,138 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
|
|
|
batchUpdateFsCourseWatchLog(logs,100);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<FsCourseUserStatisticsListVO> selectFsCourseUserStatisticsListVO(FsCourseUserStatisticsListParam param) {
|
|
|
+ return fsCourseWatchLogMapper.selectFsCourseUserStatisticsListVO(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FsCourseOverVO> selectFsCourseWatchLogOverStatisticsListVO(FsCourseOverParam param) {
|
|
|
+ return fsCourseWatchLogMapper.selectFsCourseWatchLogOverStatisticsListVO(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addCourseWatchLogDay() {
|
|
|
+
|
|
|
+ List<FsUserCourse> courses = fsUserCourseMapper.selectFsUserCourseAllCourse();
|
|
|
+ for (FsUserCourse course : courses) {
|
|
|
+ Long project = course.getProject();
|
|
|
+ List<FsUserCourseVideo> fsUserCourseVideos = fsUserCourseVideoMapper.selectVideoByCourseId(course.getCourseId());
|
|
|
+ for (FsUserCourseVideo fsUserCourseVideo : fsUserCourseVideos) {
|
|
|
+ try {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("看课记录add异常:{}",course.getCourseId(),e);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void addCourseWatchLogDay2() {
|
|
|
+
|
|
|
+ List<FsUserCourse> courses = fsUserCourseMapper.selectFsUserCourseAllCourse();
|
|
|
+ for (FsUserCourse course : courses) {
|
|
|
+ Long project = course.getProject();
|
|
|
+ List<FsUserCourseVideo> fsUserCourseVideos = fsUserCourseVideoMapper.selectVideoByCourseId(course.getCourseId());
|
|
|
+ for (FsUserCourseVideo fsUserCourseVideo : fsUserCourseVideos) {
|
|
|
+ ArrayList<QwWatchLog> QwWatchLogs = new ArrayList<>();
|
|
|
+ List<FsQwCourseWatchLogVO> watchLogs = fsCourseWatchLogMapper.selectFsCourseWatchLogByNoDayAndVoidId2(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);
|
|
|
+ day=day-1;
|
|
|
+ }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);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public Long getVideoDuration(Long videoId){
|
|
|
//将视频时长也存到redis
|
|
|
String videoRedisKey = "h5user:video:duration:" + videoId;
|