mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 02:16:49 +08:00
Compare commits
3 Commits
zcwy0815-l
...
zcwy0731-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7be0acf350 | ||
|
|
87892fe8ef | ||
|
|
a0c891cd35 |
@@ -84,6 +84,7 @@
|
||||
<artifactId>xboe-module-es</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>it.sauronsoftware</groupId>
|
||||
<artifactId>jave</artifactId>
|
||||
|
||||
@@ -133,6 +133,4 @@ public interface CacheName {
|
||||
* 字典缓存key
|
||||
* */
|
||||
String KEY_DICT="dict";
|
||||
|
||||
String STUDY_KEY = "StudyKey:";
|
||||
}
|
||||
|
||||
@@ -84,11 +84,6 @@ public class CourseContent extends BaseEntity {
|
||||
@Column(name = "duration")
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 视频播放进度
|
||||
* */
|
||||
@Column(name = "progress_video")
|
||||
private Float progressVideo;
|
||||
|
||||
/**用于学习时的状态显示,非存储字段*/
|
||||
@Transient
|
||||
|
||||
@@ -82,7 +82,4 @@ public interface ICourseContentService{
|
||||
* @return
|
||||
*/
|
||||
CourseAssess getAssess(String ccid);
|
||||
|
||||
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.xboe.module.course.service.impl;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -143,17 +141,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
return assess;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateProcessVideo(String id, String courseId, Float progressVideo) {
|
||||
// 处理 processVideo 为 null 的情况
|
||||
if (progressVideo == null) {
|
||||
progressVideo = 0.00f;
|
||||
}
|
||||
String sql = "UPDATE boe_course_content SET progress_video = "+ progressVideo+" WHERE id = "+ id+" AND course_id = "+ courseId+" ";
|
||||
ccDao.sqlUpdate(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateName(String id, String name) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 考试名称
|
||||
* */
|
||||
@Column(name = "test_name",length = 50)
|
||||
@Column(name = "test_name",nullable = false,length = 50)
|
||||
private String testName;
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 考试时长 分钟
|
||||
* */
|
||||
@Column(name = "test_duration")
|
||||
@Column(name = "test_duration",nullable = false)
|
||||
private Integer testDuration;
|
||||
/**
|
||||
* 显示解析
|
||||
@@ -107,13 +107,13 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 考试的类型
|
||||
* */
|
||||
@Column(name = "test_type")
|
||||
@Column(name = "test_type",nullable = false)
|
||||
private Integer testType;
|
||||
|
||||
/**
|
||||
* 发布状态 ,是否已发布
|
||||
*/
|
||||
@Column(name = "published",length = 1)
|
||||
@Column(name = "published",length = 1,nullable = false)
|
||||
private Boolean published;
|
||||
/**
|
||||
* 发布时间
|
||||
@@ -154,7 +154,7 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 范围,1表独立使用,2表课程内部
|
||||
* */
|
||||
@Column(name = "range_type")
|
||||
@Column(name = "range_type",nullable = false)
|
||||
private Integer rangeType;
|
||||
|
||||
/**
|
||||
@@ -178,4 +178,5 @@ public class ExamTest extends BaseEntity {
|
||||
|
||||
@Transient
|
||||
private String paperName;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@ package com.xboe.school.study.api;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.api.vo.*;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -92,6 +95,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 用于查询课程的学习记录
|
||||
* @param pager
|
||||
@@ -283,7 +287,11 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 记录学习信息,在学习每个资源时都要记录.前端用户打开课程资源按规则调用带着课程及学习信息调用此接口。
|
||||
* @param
|
||||
* @return 返回学习条目的id
|
||||
*/
|
||||
@PostMapping("/study")
|
||||
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
|
||||
|
||||
@@ -313,32 +321,18 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
//检查是否已存在
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
if(item!=null) {
|
||||
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
|
||||
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
|
||||
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()) {
|
||||
// }
|
||||
//如果记录存在,但是进度不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());
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
||||
log.info("在线课学习记录"+allUserList);
|
||||
return success(item.getId());
|
||||
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(sci.getCourseId())){
|
||||
@@ -535,7 +529,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/study-video-time")
|
||||
public JsonResponse<Boolean> study(String itemId,Integer videoTime,String contentId , String courseId,Float progressVideo){
|
||||
public JsonResponse<Boolean> study(String studyId,String itemId,Integer videoTime){
|
||||
|
||||
if(StringUtils.isBlank(itemId)){
|
||||
return error("参数错误");
|
||||
@@ -545,10 +539,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
//检查是否已存在
|
||||
try {
|
||||
studyService.updateLastTime(itemId,videoTime, getCurrent().getAccountId());
|
||||
if (contentId != null && courseId != null && progressVideo != null){
|
||||
contentService.updateProcessVideo(contentId, courseId, progressVideo);
|
||||
}
|
||||
studyService.updateLastTime(itemId,videoTime,getCurrent().getAccountId());
|
||||
return success(true);
|
||||
}catch(Exception e) {
|
||||
log.error("记录最后学习时间错误",e);
|
||||
|
||||
@@ -98,12 +98,8 @@ public class StudyServiceImpl implements IStudyService{
|
||||
//sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setLastTime(ldt);
|
||||
scItemDao.saveOrUpdate(sci);
|
||||
if (sci.getId() != null){
|
||||
|
||||
dto.setStudyItemId(sci.getId());
|
||||
}else {
|
||||
log.info("学习记录插入失败"+sci.getId());
|
||||
throw new IllegalArgumentException("学习记录插入失败");
|
||||
}
|
||||
//检查是否全部学习完成
|
||||
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token);
|
||||
|
||||
@@ -184,15 +180,17 @@ public class StudyServiceImpl implements IStudyService{
|
||||
query.addFilter(FieldFilters.eq("courseId",courseId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)) {
|
||||
query.addFilter(FieldFilters.eq("aname", name));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
}
|
||||
int pageIndex2 = (pageIndex-1)*10;
|
||||
int pageIndex2 = pageIndex-1;
|
||||
if(status!=null) {
|
||||
if(status==3) {
|
||||
query.addFilter(FieldFilters.eq("status", 2));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if(status==2){
|
||||
query.addFilter(FieldFilters.eq("status",9));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if (status == 1) {
|
||||
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
|
||||
|
||||
Reference in New Issue
Block a user