Compare commits

..

20 Commits

Author SHA1 Message Date
sunhonglai
cdf9698f71 修改注解 2025-04-07 15:09:04 +08:00
sunhonglai
74bcec72bc 修改学习时长取值 2025-04-01 09:59:59 +08:00
sunhonglai
b8c171bf86 Merge branch '250331-bugfix-shl-newmaster' into 250331-bugfix-shl
# Conflicts:
#	servers/boe-server-all/src/main/java/com/xboe/school/study/service/impl/StudyServiceImpl.java
2025-04-01 09:51:14 +08:00
sunhonglai
175e7f6c28 查询课程和修改课程学习上报进度,增加视频播放进度的处理 2025-04-01 08:32:41 +08:00
sunhonglai
5705bb8529 查询课程和修改课程学习上报进度,增加视频播放进度的处理 2025-03-31 13:14:14 +08:00
sunhonglai
87e5dd81f8 查询课程和修改课程学习上报进度,增加视频播放进度的处理 2025-03-31 11:27:13 +08:00
joshen
9924769bc8 Merge remote-tracking branch 'yx/master-20250227-lyc' into release-20250328-master 2025-03-29 12:38:10 +08:00
670788339
d4964ca7f1 日志 2025-03-29 12:22:11 +08:00
670788339
efdfa6f00c study-video-time 最后修改时间调整 2025-03-29 10:51:08 +08:00
joshen
ceb30f7f1d Merge remote-tracking branch 'yx/master-20250227-lyc' into release-20250328-master
# Conflicts:
#	servers/boe-server-all/src/main/java/com/xboe/module/course/entity/CourseTeacher.java
#	servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java
2025-03-28 15:32:27 +08:00
joshen
60d891edcf Merge remote-tracking branch 'yx/250324-casebugfix-zsh' 2025-03-26 16:54:25 +08:00
emcchui
b9f00f2602 SZX-927:学员端-个人设置-手机号未同步到 2025-03-25 08:47:19 +08:00
emcchui
77884d3e7e SZX-927:学员端-个人设置-手机号未同步到 2025-03-25 08:39:48 +08:00
emcchui
3a9a8d86af SZX-927:学员端-个人设置-手机号未同步到 2025-03-24 18:10:41 +08:00
emcchui
3a139925c9 SZX-927:学员端-个人设置-手机号未同步到 2025-03-24 17:41:22 +08:00
emcchui
fdc0c7959e SZX-927:学员端-个人设置-手机号未同步到 2025-03-24 16:27:50 +08:00
sunhonglai
a1352ec813 修改后端返回分页结果 2025-03-24 09:23:06 +08:00
670788339
c9db78ea94 在线课-外部讲师 补充 2025-03-21 09:42:02 +08:00
670788339
f33de0c326 在线课-外部讲师 2025-03-20 20:57:49 +08:00
670788339
4be72391ad 在线课-外部讲师报错 添加讲师类型 2025-03-20 17:37:04 +08:00
8 changed files with 116 additions and 26 deletions

View File

@@ -2,11 +2,16 @@ package com.xboe.data.service.impl;
import java.time.LocalDateTime;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import com.boe.feign.api.serverall.entity.UserData;
import com.xboe.constants.CacheName;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
@@ -39,6 +44,9 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
@Autowired
TeacherDao teacherDao;
@Resource
private CacheManager cacheManager;
@Override
@Transactional
@@ -59,6 +67,8 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
a.setDeleted(user.getDeleted());
}
a.setLoginName(user.getCode());
a.setMobile(user.getMobile());
a.setEmail(user.getEmail());
log.info("更新账号code");
accountDao.update(a);
} else {
@@ -71,14 +81,18 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
a.setRegTime(LocalDateTime.now());
a.setSysId(user.getKid());
a.setStatus(1);
a.setMobile(user.getMobile());
a.setEmail(user.getEmail());
accountDao.save(a);
log.info("账号不存在,新添加账号【" + user.getId() + "");
}
if (u != null) {
//更新部分用户字段
u.setDepartId(user.getDepartId());
u.setDepartName(user.getDepartName());
u.setName(user.getName());
u.setMobileNo(user.getMobile());
//2022-12-8 去掉用户类型的更新,因为返回的数据都是学员,
//u.setUserType(user.getUserType());
if (user.getLearningDuration() > 0) { //不大于0才会更新
@@ -106,9 +120,17 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
} else {
u.setShowHome(true);//band16以下及其它无bandLevel的信息
}
u.setMobileNo(user.getMobile());
userDao.save(u);
log.info("添加新用户");
}
Cache cache = cacheManager.getCache(CacheName.NAME_USER);
if(cache != null) {
cache.evict(CacheName.KEY_ACCOUNT + user.getId());
cache.evict(CacheName.KEY_USER + user.getId());
}
//对机构的判断,不为空时才会处理,为空时不处理
if (StringUtils.isNotBlank(user.getDepartId())) {
org = orgDao.get(user.getDepartId());

View File

@@ -314,8 +314,10 @@ public class CoursePortalApi extends ApiBaseController{
User user = userService.get(ct.getTeacherId());
if(t!=null) {
ct.setRemark(t.getDescription());
ct.setSupplier(t.getSupplier());
ct.setTeacherType(t.getTeacherType());
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
ct.setTeacherName("BOE教师");
}
teacherCourseDto.setCourseId(ct.getCourseId());
@@ -335,7 +337,7 @@ public class CoursePortalApi extends ApiBaseController{
List<String> list=new ArrayList<>();
list.add(ct.getTeacherId());
getTeacherInfo(request.getHeader("Xboe-Access-Token"),list);
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
ct.setTeacherName("BOE教师");
}
teacherCourseDto.setCourseId(ct.getCourseId());

View File

@@ -448,6 +448,7 @@ public class CourseServiceImpl implements ICourseService {
List<Course> paginate = paginate(listByFilters2, pageIndex, pageSize);
PageList<Course> rs = new PageList<>();
rs.setCount(listByFilters2.size());
rs.setPageSize(pageSize);
rs.setList(paginate);
return rs;
}
@@ -480,7 +481,7 @@ public class CourseServiceImpl implements ICourseService {
String sql = "SELECT DISTINCT\n" +
"rt.course_id\n" +
"FROM\n" +
"boe.student s INNER JOIN boe.router_task rt on s.pid=rt.router_id inner join boe_course c on c.id=rt.course_id\n" +
"boe_new.student s INNER JOIN boe_new.router_task rt on s.pid=rt.router_id inner join boe_course c on c.id=rt.course_id\n" +
"\n" +
"WHERE\n" +
"\n" +
@@ -503,7 +504,7 @@ public class CourseServiceImpl implements ICourseService {
String sql = "SELECT DISTINCT\n" +
"pt.course_id\n" +
"FROM\n" +
"boe.student s INNER JOIN boe.project_task pt on s.pid=pt.project_id inner join boe_course c on c.id=pt.course_id\n" +
"boe_new.student s INNER JOIN boe_new.project_task pt on s.pid=pt.project_id inner join boe_course c on c.id=pt.course_id\n" +
"\n" +
"WHERE\n" +
"\n" +
@@ -560,8 +561,8 @@ public class CourseServiceImpl implements ICourseService {
String sql = "SELECT DISTINCT\n" +
"\tc.id \n" +
"FROM\n" +
"\tboe.student s\n" +
"\tINNER JOIN boe.grow_task gt ON s.pid = gt.grow_id\n" +
"\tboe_new.student s\n" +
"\tINNER JOIN boe_new.grow_task gt ON s.pid = gt.grow_id\n" +
"\tINNER JOIN boe_course c ON gt.course_id = c.id \n" +
"WHERE\n" +
"\ts.type = 14 \n" +

View File

@@ -1,9 +1,14 @@
package com.xboe.school.study.api;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
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.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
@@ -214,11 +219,11 @@ public class StudyCourseApi extends ApiBaseController{
redisTemplate.opsForValue().set(teacherVo.get(0).getTeacherId(), teacherVo.get(0).getStatus());
//设置过期时间为1天
redisTemplate.expire(teacherVo.get(0).getTeacherId(), 24 * 60 * 60, TimeUnit.SECONDS);
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
ct.setTeacherName("BOE教师");
}
}
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
ct.setTeacherName("BOE教师");
}
}
@@ -253,6 +258,49 @@ public class StudyCourseApi extends ApiBaseController{
rs.put("progress", sc.getProgress());
//查询上次学习的是什么资源。查询用户的学习情况
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);//学习的内容
}
@@ -367,8 +415,6 @@ public class StudyCourseApi extends ApiBaseController{
studyService.saveStudyInfo(sci,token);
//学习记录成功后处理
studyService.appendStudyDuration(sci.getStudyId(),sci.getStudyItemId(),sci.getContentId(),sci.getDuration());
log.info("在线课学习记录 sci.getStudyId() = "+ sci.getStudyId() + " , sci.getCourseId() = " + sci.getCourseId() );
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
log.info("在线课学习记录"+allUserList);
//System.out.println("在线课学习记录"+allUserList);

View File

@@ -10,6 +10,8 @@ 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;
@@ -33,7 +35,7 @@ public class StudyCourseTask {
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)
@@ -59,12 +61,17 @@ public class StudyCourseTask {
String studyContentId = parts[1];
// 7. 获取存储的时间点(示例逻辑)
String lastStudyTimeStr = redisTemplate.opsForValue().get(redisKey);
if (lastStudyTimeStr == null) continue;
int lastStudyTime = Integer.parseInt(lastStudyTimeStr);
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, "system_job");
studyService.updateStudyCourseItemLastTime(studyContentId, lastStudyTime, timestamp);
// 9. 删除Redis键原子操作
redisTemplate.delete(redisKey);

View File

@@ -1,10 +1,12 @@
package com.xboe.school.study.entity;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xboe.core.SysConstant;
@@ -128,5 +130,11 @@ public class StudyCourseItem extends IdEntity {
*/
@Column(name = "status",length=1)
private Integer status;
/**
* 视频播放进度
* */
@Transient
private BigDecimal progressVideo;
}

View File

@@ -1,5 +1,6 @@
package com.xboe.school.study.service;
import java.time.LocalDateTime;
import java.util.List;
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.entity.StudyCourseItem;
import com.xboe.school.study.entity.StudyTime;
import com.xboe.system.user.entity.User;
/**
* 学习情况处理,比较综合一个处理类
@@ -35,11 +35,12 @@ public interface IStudyService {
/**
* 更新最后的学习时间,及学习时间点
*
* @param studyContentId
* @param lastStudyTime
* @param aid
*/
void updateLastTime(String studyContentId,int lastStudyTime,String aid);
void updateLastTime(String studyContentId, int lastStudyTime, String aid);
/**
* 资源学习记录
@@ -99,5 +100,5 @@ public interface IStudyService {
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime, String systemJob);
void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime, LocalDateTime timestamp);
}

View File

@@ -10,10 +10,6 @@ import java.util.Map;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -330,19 +326,25 @@ public class StudyServiceImpl implements IStudyService{
// 更新 前端传输已学习时长
@Override
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",
String.valueOf(lastStudyTime),
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,String aid) {
public void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime,LocalDateTime timestamp) {
log.info("-study-video-time-定时---studyContentId = " + studyContentId + ",lastStudyTime = " + lastStudyTime + ", timestamp = " + timestamp);
// 更新最后的学习时间点
LocalDateTime now=LocalDateTime.now();
UpdateBuilder update=UpdateBuilder.from(StudyCourseItem.class);
@@ -350,8 +352,9 @@ public class StudyServiceImpl implements IStudyService{
//只记录时间长的时候的处理
update.addFilter(FieldFilters.lt("lastStudyTime", lastStudyTime));
update.addUpdateField("lastStudyTime", lastStudyTime);
update.addUpdateField("lastTime", now);
update.addUpdateField("lastTime", timestamp==null ? now : timestamp);
scItemDao.update(update.builder());
log.info("-study-video-time-mysql保存---studyContentId = " + studyContentId);
}
@Override