mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
Merge branch 'zcwy0815-llf' into 104-master
# Conflicts: # servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java
This commit is contained in:
@@ -84,7 +84,6 @@
|
|||||||
<artifactId>xboe-module-es</artifactId>
|
<artifactId>xboe-module-es</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>it.sauronsoftware</groupId>
|
<groupId>it.sauronsoftware</groupId>
|
||||||
<artifactId>jave</artifactId>
|
<artifactId>jave</artifactId>
|
||||||
|
|||||||
@@ -133,4 +133,6 @@ public interface CacheName {
|
|||||||
* 字典缓存key
|
* 字典缓存key
|
||||||
* */
|
* */
|
||||||
String KEY_DICT="dict";
|
String KEY_DICT="dict";
|
||||||
|
|
||||||
|
String STUDY_KEY = "StudyKey:";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,11 @@ package com.xboe.school.study.api;
|
|||||||
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.stream.Collectors;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.api.vo.*;
|
import com.xboe.constants.CacheName;
|
||||||
import com.xboe.module.course.vo.TeacherVo;
|
import com.xboe.module.course.vo.TeacherVo;
|
||||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
|
||||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||||
import com.xboe.school.study.dao.StudyCourseDao;
|
import com.xboe.school.study.dao.StudyCourseDao;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
@@ -66,9 +64,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value="/xboe/school/study/course")
|
@RequestMapping(value="/xboe/school/study/course")
|
||||||
public class StudyCourseApi extends ApiBaseController{
|
public class StudyCourseApi extends ApiBaseController{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IStudyCourseService service;
|
IStudyCourseService service;
|
||||||
|
|
||||||
@@ -324,31 +320,35 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
if (StringUtils.isEmpty(token)) {
|
if (StringUtils.isEmpty(token)) {
|
||||||
token = request.getHeader("token");
|
token = request.getHeader("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//检查是否已存在
|
//检查是否已存在
|
||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
|
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
|
||||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success("");
|
|
||||||
// }
|
|
||||||
if(item!=null) {
|
if(item!=null) {
|
||||||
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
|
||||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
|
||||||
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
redisTemplate.opsForValue().set(studyKey,
|
||||||
|
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
|
||||||
|
String progressStr = redisTemplate.opsForValue().get(studyKey2);
|
||||||
|
if (progressStr != null && !progressStr.isEmpty()) {
|
||||||
|
// 尝试将 Redis 中的字符串转换为整数
|
||||||
|
int redisProgress = Integer.parseInt(progressStr);
|
||||||
|
// 假设 item.getProgress() 返回的是 int 类型
|
||||||
|
int sciProgress = sci.getProgress();
|
||||||
|
|
||||||
|
if (redisProgress < sciProgress && redisProgress < 100) {
|
||||||
|
// 执行一些操作
|
||||||
|
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||||
|
// }
|
||||||
|
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//追加学习时长
|
//追加学习时长
|
||||||
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||||
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());
|
||||||
|
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils.isBlank(sci.getCourseId())){
|
if(StringUtils.isBlank(sci.getCourseId())){
|
||||||
return error("无课程信息");
|
return error("无课程信息");
|
||||||
}
|
}
|
||||||
@@ -421,14 +421,6 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||||
if(item!=null) {
|
if(item!=null) {
|
||||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
|
||||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success("");
|
|
||||||
// }
|
|
||||||
if(item.getProgress()<100) {
|
if(item.getProgress()<100) {
|
||||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
|
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
|
||||||
}
|
}
|
||||||
@@ -534,14 +526,6 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
token = request.getHeader("token");
|
token = request.getHeader("token");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 20240815 特训营结营考试 临时代码
|
|
||||||
// if(itemId != null && redisTemplate.opsForValue().get(itemId)==null){
|
|
||||||
// redisTemplate.opsForValue().set(itemId,itemId);
|
|
||||||
// //设置过期时间为1天
|
|
||||||
// redisTemplate.expire(itemId, 60, TimeUnit.SECONDS);
|
|
||||||
// }else{
|
|
||||||
// return success(true);
|
|
||||||
// }
|
|
||||||
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
||||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
@@ -723,10 +707,9 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
return error("查询失败",e.getMessage());
|
return error("查询失败",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
||||||
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){
|
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
|
||||||
if(StringUtils.isBlank(studyId)){
|
if(StringUtils.isBlank(studyId)){
|
||||||
return error("无学习信息");
|
return error("无学习信息");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user