mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 02:16:49 +08:00
Compare commits
19 Commits
250408-bug
...
250331-bug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdf9698f71 | ||
|
|
74bcec72bc | ||
|
|
b8c171bf86 | ||
|
|
175e7f6c28 | ||
|
|
5705bb8529 | ||
|
|
87e5dd81f8 | ||
|
|
9924769bc8 | ||
|
|
d4964ca7f1 | ||
|
|
efdfa6f00c | ||
|
|
ceb30f7f1d | ||
|
|
500fb090fb | ||
|
|
ee95435d01 | ||
|
|
76f0d1933a | ||
|
|
58d6f49006 | ||
|
|
c8ffdd561f | ||
|
|
98611edcaa | ||
|
|
8aea21bde7 | ||
|
|
a79f6b43b2 | ||
|
|
81ea19f0f3 |
@@ -8,9 +8,11 @@ import cn.hutool.json.JSONUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.boe.feign.api.courseweb.entity.ExamTestDto;
|
import com.boe.feign.api.courseweb.entity.ExamTestDto;
|
||||||
import com.boe.feign.api.courseweb.entity.ProjectStudyDto;
|
import com.boe.feign.api.courseweb.entity.ProjectStudyDto;
|
||||||
|
import com.boe.feign.api.courseweb.remote.ExternalRemoteClient;
|
||||||
import com.boe.feign.api.courseweb.remote.OffCourseRemoteClient;
|
import com.boe.feign.api.courseweb.remote.OffCourseRemoteClient;
|
||||||
import com.boe.feign.api.courseweb.remote.ProjectAdminRemoteClient;
|
import com.boe.feign.api.courseweb.remote.ProjectAdminRemoteClient;
|
||||||
import com.boe.feign.api.courseweb.remote.ProjectRemoteClient;
|
import com.boe.feign.api.courseweb.remote.ProjectRemoteClient;
|
||||||
|
import com.boe.feign.api.courseweb.reps.ExamStudyRecordParam;
|
||||||
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
||||||
import com.boe.feign.api.infrastructure.entity.Dict;
|
import com.boe.feign.api.infrastructure.entity.Dict;
|
||||||
import com.boe.feign.api.infrastructure.remote.DictRemoteClient;
|
import com.boe.feign.api.infrastructure.remote.DictRemoteClient;
|
||||||
@@ -73,6 +75,8 @@ public class ThirdApi {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectRemoteClient projectRemoteClient;
|
private ProjectRemoteClient projectRemoteClient;
|
||||||
|
@Resource
|
||||||
|
ExternalRemoteClient externalRemoteClient;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DictRemoteClient dictRemoteClient;
|
private DictRemoteClient dictRemoteClient;
|
||||||
@@ -262,11 +266,19 @@ public class ThirdApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<StudyCourse> getStudyCourseList(String studyId, String courseId, String token) {
|
public List<StudyCourse> getStudyCourseList(String studyId, String courseId, String token) {
|
||||||
|
log.info(" 1 studyId = "+ studyId + " ,courseId = " + courseId );
|
||||||
|
if ( studyId == null || courseId == null ){
|
||||||
|
log.error(" 在线课学习记录 参数不能为空 ");
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
StudyCourseVo studyCourseVo = new StudyCourseVo();
|
StudyCourseVo studyCourseVo = new StudyCourseVo();
|
||||||
studyCourseVo.setStudyId(studyId);
|
studyCourseVo.setStudyId(studyId);
|
||||||
studyCourseVo.setCourseId(courseId);
|
studyCourseVo.setCourseId(courseId);
|
||||||
ProjectStudyDto projectStudyDto = new ProjectStudyDto();
|
ProjectStudyDto projectStudyDto = new ProjectStudyDto();
|
||||||
BeanUtil.copyProperties(studyCourseVo, studyCourseVo);
|
// BeanUtil.copyProperties(studyCourseVo, studyCourseVo);
|
||||||
|
projectStudyDto.setStudyId(Long.parseLong(studyId));
|
||||||
|
projectStudyDto.setCourseId(Long.parseLong(courseId));
|
||||||
|
log.info(" 12 在线课学习记录 studyId = "+ projectStudyDto.getStudyId() + " ,courseId = " + projectStudyDto.getCourseId() );
|
||||||
projectRemoteClient.updateStudyStatus(projectStudyDto);
|
projectRemoteClient.updateStudyStatus(projectStudyDto);
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -382,4 +394,8 @@ public class ThirdApi {
|
|||||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||||
log.info("updateOrSaveCourse = " + resp);
|
log.info("updateOrSaveCourse = " + resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void syncExamStudyRecord(ExamStudyRecordParam param) {
|
||||||
|
externalRemoteClient.syncExamStudyRecord(param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,4 +56,5 @@ public class CourseTeacher extends IdBaseEntity {
|
|||||||
/**讲师类型 1 内部讲师 2外部讲师*/
|
/**讲师类型 1 内部讲师 2外部讲师*/
|
||||||
@Transient
|
@Transient
|
||||||
private Integer teacherType;
|
private Integer teacherType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,5 +341,8 @@ public interface ICourseService {
|
|||||||
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
||||||
|
|
||||||
|
|
||||||
void deletedStudyResourceBatchByCourseIdAndType(String courseId,Integer courseType);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.xboe.module.course.service.impl;
|
package com.xboe.module.course.service.impl;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@@ -20,11 +19,6 @@ import com.xboe.core.orm.*;
|
|||||||
import com.xboe.school.study.dao.StudyCourseDao;
|
import com.xboe.school.study.dao.StudyCourseDao;
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
import com.xboe.school.study.entity.StudyCourse;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
|
||||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
|
||||||
import org.hibernate.mapping.IdGenerator;
|
import org.hibernate.mapping.IdGenerator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
@@ -121,9 +115,6 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private IEventDataSender eventSender;
|
private IEventDataSender eventSender;
|
||||||
|
|
||||||
@Resource
|
|
||||||
RestHighLevelClient restHighLevelClient;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -863,14 +854,12 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
log.error("未配置事件消息发送的实现");
|
log.error("未配置事件消息发送的实现");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除ES数据
|
|
||||||
deletedStudyResourceBatchByCourseIdAndType(id,c.getType());
|
|
||||||
} else {
|
} else {
|
||||||
//彻底删除,课件设置为无课程状态
|
//彻底删除,课件设置为无课程状态
|
||||||
courseDao.setDeleted(id);
|
courseDao.setDeleted(id);
|
||||||
}
|
}
|
||||||
//记录删除日志信息
|
//记录删除日志信息
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1990,17 +1979,5 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids);
|
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deletedStudyResourceBatchByCourseIdAndType(String courseId, Integer courseType) {
|
|
||||||
DeleteByQueryRequest request = new DeleteByQueryRequest("new_study_resource");
|
|
||||||
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
|
||||||
boolQueryBuilder.must(QueryBuilders.matchQuery("courseId", courseId));
|
|
||||||
boolQueryBuilder.must(QueryBuilders.matchQuery("courseType", courseType));
|
|
||||||
request.setQuery(boolQueryBuilder);
|
|
||||||
try {
|
|
||||||
restHighLevelClient.deleteByQuery(request, RequestOptions.DEFAULT);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.boe.feign.api.courseweb.reps.ExamStudyRecordParam;
|
||||||
|
import com.xboe.api.ThirdApi;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -37,7 +39,10 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
AloneExamDao aeDao;
|
AloneExamDao aeDao;
|
||||||
|
@Resource
|
||||||
|
private ThirdApi thirdApi;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void save(AloneExamAnswer aea){
|
public void save(AloneExamAnswer aea){
|
||||||
@@ -101,7 +106,18 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
|||||||
// //这种情况汶是不存在的
|
// //这种情况汶是不存在的
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
ExamStudyRecordParam param = new ExamStudyRecordParam();
|
||||||
|
param.setTestId(aea.getTestId());
|
||||||
|
param.setAid(aea.getAid());
|
||||||
|
thirdApi.syncExamStudyRecord(param);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package com.xboe.school.study.api;
|
package com.xboe.school.study.api;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.constants.CacheName;
|
import com.xboe.constants.CacheName;
|
||||||
@@ -253,6 +258,49 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
rs.put("progress", sc.getProgress());
|
rs.put("progress", sc.getProgress());
|
||||||
//查询上次学习的是什么资源。查询用户的学习情况
|
//查询上次学习的是什么资源。查询用户的学习情况
|
||||||
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
||||||
|
// 和内容匹配,根据内容的视频时长,计算学习进度
|
||||||
|
if(CollectionUtil.isNotEmpty(items) && CollectionUtil.isNotEmpty(cclist)){
|
||||||
|
// 根据ID转换map
|
||||||
|
Map<String, CourseContent> contentMap = cclist.stream().collect(Collectors.toMap(CourseContent::getId, Function.identity()));
|
||||||
|
for (StudyCourseItem item : items) {
|
||||||
|
CourseContent content = contentMap.get(item.getContentId());
|
||||||
|
if(null == content){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(null==item.getLastStudyTime()
|
||||||
|
|| item.getLastStudyTime()<=0
|
||||||
|
|| null==content.getDuration()
|
||||||
|
|| content.getDuration()<=0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询redis上面的key,并解析value获取到lastStudyTime
|
||||||
|
String lastActive = redisTemplate.opsForValue().get("studyContentId:" + item.getId() + ":last_active");
|
||||||
|
if (StringUtil.isNotBlank(lastActive)) {
|
||||||
|
String[] parts = lastActive.split("&");
|
||||||
|
if (parts.length == 2) {
|
||||||
|
int lastStudyTimeRedis = Integer.parseInt(parts[0]);
|
||||||
|
log.info("study-video-time-redis获取---lastStudyTimeRedis = " + lastStudyTimeRedis);
|
||||||
|
if(lastStudyTimeRedis>0){
|
||||||
|
item.setLastStudyTime(lastStudyTimeRedis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal lastStudyTime = new BigDecimal(item.getLastStudyTime());
|
||||||
|
BigDecimal duration = new BigDecimal(content.getDuration());
|
||||||
|
BigDecimal progress = lastStudyTime.divide(duration, 10, RoundingMode.HALF_UP);
|
||||||
|
if(progress.compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
progress = BigDecimal.ZERO;
|
||||||
|
}else if(progress.compareTo(BigDecimal.ONE) > 0){
|
||||||
|
progress = BigDecimal.ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.setProgressVideo(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rs.put("contentStudys",items);//学习的内容
|
rs.put("contentStudys",items);//学习的内容
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,6 +393,8 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
//追加学习时长
|
//追加学习时长
|
||||||
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||||
|
|
||||||
|
log.info(" 1 在线课学习记录 sci.getStudyId() = "+ sci.getStudyId() + " , sci.getCourseId() = " + sci.getCourseId() );
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
return success(item.getId());
|
return success(item.getId());
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package com.xboe.school.study.api;
|
||||||
|
|
||||||
|
import com.xboe.school.study.service.IStudyService;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
|
import org.springframework.data.redis.core.Cursor;
|
||||||
|
import org.springframework.data.redis.core.ScanOptions;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author by lyc
|
||||||
|
* @date 2025/3/3
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class StudyCourseTask {
|
||||||
|
|
||||||
|
private final IStudyService studyService;
|
||||||
|
private final StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务
|
||||||
|
* 获取redis 中学习结束的数据更新入库
|
||||||
|
* */
|
||||||
|
@XxlJob("saveStudyCourseItemLastTime")
|
||||||
|
public void saveStudyCourseItemLastTime() {
|
||||||
|
// 1. 定义匹配模式(匹配所有目标key)
|
||||||
|
final String KEY_PATTERN = "studyContentId:*:last_active";
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
// 2. 使用SCAN安全遍历(避免阻塞)
|
||||||
|
ScanOptions options = ScanOptions.scanOptions()
|
||||||
|
.match(KEY_PATTERN)
|
||||||
|
.count(100) // 分页大小
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (RedisConnection connection = Objects.requireNonNull(redisTemplate.getConnectionFactory()).getConnection()) {
|
||||||
|
Cursor<byte[]> cursor = connection.scan(options);
|
||||||
|
// 3. 遍历处理符合条件的key
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
String redisKey = new String(cursor.next());
|
||||||
|
// 4. 获取剩余TTL(秒)
|
||||||
|
Long ttl = redisTemplate.getExpire(redisKey, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
// 5. 过滤条件:剩余时间 >= 29天23小时30分钟(转换为秒)
|
||||||
|
// 总需时间 = (30天 - 30分钟) = 29天23小时30分钟 = 2590200秒
|
||||||
|
// 5分钟 300秒 || 2592000 - 300 = 2591700
|
||||||
|
if (ttl <= 2590200) {
|
||||||
|
try {
|
||||||
|
// 6. 提取studyContentId
|
||||||
|
String[] parts = redisKey.split(":");
|
||||||
|
if (parts.length < 2) continue;
|
||||||
|
String studyContentId = parts[1];
|
||||||
|
|
||||||
|
// 7. 获取存储的时间点(示例逻辑)
|
||||||
|
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
||||||
|
if (redisValue == null) continue;
|
||||||
|
String[] partValues = redisValue.split("&");
|
||||||
|
int lastStudyTime = Integer.parseInt(partValues[0]);
|
||||||
|
LocalDateTime timestamp = null;
|
||||||
|
if (partValues.length >= 2){
|
||||||
|
timestamp = LocalDateTime.parse(partValues[1], formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 更新数据库(调用已有服务方法)
|
||||||
|
studyService.updateStudyCourseItemLastTime(studyContentId, lastStudyTime, timestamp);
|
||||||
|
|
||||||
|
// 9. 删除Redis键(原子操作)
|
||||||
|
redisTemplate.delete(redisKey);
|
||||||
|
|
||||||
|
log.info("处理成功 key: {}, lastStudyTime: {}", redisKey, lastStudyTime);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理失败 key: {}", redisKey, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("定时任务执行异常", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* // 新增日志逻辑
|
||||||
|
if (ttl <= 172800) {
|
||||||
|
studyService.saveCourseExpireLog(
|
||||||
|
studyContentId,
|
||||||
|
lastStudyTime,
|
||||||
|
redisKey,
|
||||||
|
ttl,
|
||||||
|
"system_job"
|
||||||
|
);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.xboe.school.study.entity;
|
package com.xboe.school.study.entity;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.xboe.core.SysConstant;
|
import com.xboe.core.SysConstant;
|
||||||
@@ -128,5 +130,11 @@ public class StudyCourseItem extends IdEntity {
|
|||||||
*/
|
*/
|
||||||
@Column(name = "status",length=1)
|
@Column(name = "status",length=1)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频播放进度
|
||||||
|
* */
|
||||||
|
@Transient
|
||||||
|
private BigDecimal progressVideo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xboe.school.study.service;
|
package com.xboe.school.study.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -7,7 +8,6 @@ import com.xboe.common.PageList;
|
|||||||
import com.xboe.school.study.dto.StudyContentDto;
|
import com.xboe.school.study.dto.StudyContentDto;
|
||||||
import com.xboe.school.study.entity.StudyCourseItem;
|
import com.xboe.school.study.entity.StudyCourseItem;
|
||||||
import com.xboe.school.study.entity.StudyTime;
|
import com.xboe.school.study.entity.StudyTime;
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学习情况处理,比较综合一个处理类
|
* 学习情况处理,比较综合一个处理类
|
||||||
@@ -35,11 +35,12 @@ public interface IStudyService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新最后的学习时间,及学习时间点
|
* 更新最后的学习时间,及学习时间点
|
||||||
|
*
|
||||||
* @param studyContentId
|
* @param studyContentId
|
||||||
* @param lastStudyTime
|
* @param lastStudyTime
|
||||||
* @param aid
|
* @param aid
|
||||||
*/
|
*/
|
||||||
void updateLastTime(String studyContentId,int lastStudyTime,String aid);
|
void updateLastTime(String studyContentId, int lastStudyTime, String aid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源学习记录
|
* 资源学习记录
|
||||||
@@ -99,4 +100,5 @@ public interface IStudyService {
|
|||||||
|
|
||||||
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||||
|
|
||||||
|
void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime, LocalDateTime timestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xboe.school.study.service.impl;
|
package com.xboe.school.study.service.impl;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -9,12 +10,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import com.xboe.module.article.entity.Article;
|
|
||||||
import com.xboe.module.interaction.entity.Shares;
|
|
||||||
import com.xboe.school.study.entity.StudyCourse;
|
|
||||||
import com.xboe.system.user.entity.User;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
@@ -51,7 +49,10 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UserDao userDao;
|
UserDao userDao;
|
||||||
|
@Autowired
|
||||||
|
StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StudyCourseItem checkHas(String studyId,String contentId) {
|
public StudyCourseItem checkHas(String studyId,String contentId) {
|
||||||
List<StudyCourseItem> items = scItemDao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
List<StudyCourseItem> items = scItemDao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||||
@@ -324,8 +325,26 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
|
|
||||||
// 更新 前端传输已学习时长
|
// 更新 前端传输已学习时长
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public void updateLastTime(String studyContentId, int lastStudyTime,String aid) {
|
public void updateLastTime(String studyContentId, int lastStudyTime,String aid) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
String value = lastStudyTime + "&" + now.format(formatter); // 使用ISO8601时间格式
|
||||||
|
log.info("-study-video-time-----value = " + value);
|
||||||
|
// 20250303 优化 多次更新改一次更新
|
||||||
|
// 更新Redis中的最后活跃时间(带30秒过期)
|
||||||
|
redisTemplate.opsForValue().set(
|
||||||
|
"studyContentId:" + studyContentId + ":last_active",
|
||||||
|
value,
|
||||||
|
Duration.ofSeconds(2592000)
|
||||||
|
);
|
||||||
|
log.info("-study-video-time-redis保存---value = " + value);
|
||||||
|
// Duration.ofDays(30) 也就是 2592000秒
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime,LocalDateTime timestamp) {
|
||||||
|
log.info("-study-video-time-定时---studyContentId = " + studyContentId + ",lastStudyTime = " + lastStudyTime + ", timestamp = " + timestamp);
|
||||||
// 更新最后的学习时间点
|
// 更新最后的学习时间点
|
||||||
LocalDateTime now=LocalDateTime.now();
|
LocalDateTime now=LocalDateTime.now();
|
||||||
UpdateBuilder update=UpdateBuilder.from(StudyCourseItem.class);
|
UpdateBuilder update=UpdateBuilder.from(StudyCourseItem.class);
|
||||||
@@ -333,9 +352,9 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
//只记录时间长的时候的处理
|
//只记录时间长的时候的处理
|
||||||
update.addFilter(FieldFilters.lt("lastStudyTime", lastStudyTime));
|
update.addFilter(FieldFilters.lt("lastStudyTime", lastStudyTime));
|
||||||
update.addUpdateField("lastStudyTime", lastStudyTime);
|
update.addUpdateField("lastStudyTime", lastStudyTime);
|
||||||
update.addUpdateField("lastTime", now);
|
update.addUpdateField("lastTime", timestamp==null ? now : timestamp);
|
||||||
scItemDao.update(update.builder());
|
scItemDao.update(update.builder());
|
||||||
//增加用户的学习时长,在api中调用
|
log.info("-study-video-time-mysql保存---studyContentId = " + studyContentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user