mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
Compare commits
12 Commits
250422-dem
...
test-gx
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe9019d87 | ||
|
|
be8c4464dc | ||
|
|
c7f1a1e810 | ||
|
|
87350c74f9 | ||
|
|
67f55c51b8 | ||
|
|
645c58e8c4 | ||
|
|
dd6e64d6ac | ||
|
|
754d41e087 | ||
|
|
fedf8ec527 | ||
|
|
e2ac6a5b96 | ||
|
|
66320dab97 | ||
|
|
5312d9f5f4 |
@@ -2,16 +2,11 @@ package com.xboe.data.service.impl;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import com.boe.feign.api.serverall.entity.UserData;
|
import com.boe.feign.api.serverall.entity.UserData;
|
||||||
import com.xboe.constants.CacheName;
|
|
||||||
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.cache.Cache;
|
|
||||||
import org.springframework.cache.CacheManager;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.retry.annotation.Recover;
|
import org.springframework.retry.annotation.Recover;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -44,9 +39,6 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
TeacherDao teacherDao;
|
TeacherDao teacherDao;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CacheManager cacheManager;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -67,8 +59,6 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
|||||||
a.setDeleted(user.getDeleted());
|
a.setDeleted(user.getDeleted());
|
||||||
}
|
}
|
||||||
a.setLoginName(user.getCode());
|
a.setLoginName(user.getCode());
|
||||||
a.setMobile(user.getMobile());
|
|
||||||
a.setEmail(user.getEmail());
|
|
||||||
log.info("更新账号code");
|
log.info("更新账号code");
|
||||||
accountDao.update(a);
|
accountDao.update(a);
|
||||||
} else {
|
} else {
|
||||||
@@ -81,18 +71,14 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
|||||||
a.setRegTime(LocalDateTime.now());
|
a.setRegTime(LocalDateTime.now());
|
||||||
a.setSysId(user.getKid());
|
a.setSysId(user.getKid());
|
||||||
a.setStatus(1);
|
a.setStatus(1);
|
||||||
a.setMobile(user.getMobile());
|
|
||||||
a.setEmail(user.getEmail());
|
|
||||||
accountDao.save(a);
|
accountDao.save(a);
|
||||||
log.info("账号不存在,新添加账号【" + user.getId() + "】");
|
log.info("账号不存在,新添加账号【" + user.getId() + "】");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u != null) {
|
if (u != null) {
|
||||||
//更新部分用户字段
|
//更新部分用户字段
|
||||||
u.setDepartId(user.getDepartId());
|
u.setDepartId(user.getDepartId());
|
||||||
u.setDepartName(user.getDepartName());
|
u.setDepartName(user.getDepartName());
|
||||||
u.setName(user.getName());
|
u.setName(user.getName());
|
||||||
u.setMobileNo(user.getMobile());
|
|
||||||
//2022-12-8 去掉用户类型的更新,因为返回的数据都是学员,
|
//2022-12-8 去掉用户类型的更新,因为返回的数据都是学员,
|
||||||
//u.setUserType(user.getUserType());
|
//u.setUserType(user.getUserType());
|
||||||
if (user.getLearningDuration() > 0) { //不大于0才会更新
|
if (user.getLearningDuration() > 0) { //不大于0才会更新
|
||||||
@@ -120,17 +106,9 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
|||||||
} else {
|
} else {
|
||||||
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
||||||
}
|
}
|
||||||
u.setMobileNo(user.getMobile());
|
|
||||||
userDao.save(u);
|
userDao.save(u);
|
||||||
log.info("添加新用户");
|
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())) {
|
if (StringUtils.isNotBlank(user.getDepartId())) {
|
||||||
org = orgDao.get(user.getDepartId());
|
org = orgDao.get(user.getDepartId());
|
||||||
|
|||||||
@@ -314,10 +314,8 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
User user = userService.get(ct.getTeacherId());
|
User user = userService.get(ct.getTeacherId());
|
||||||
if(t!=null) {
|
if(t!=null) {
|
||||||
ct.setRemark(t.getDescription());
|
ct.setRemark(t.getDescription());
|
||||||
ct.setSupplier(t.getSupplier());
|
|
||||||
ct.setTeacherType(t.getTeacherType());
|
|
||||||
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
teacherCourseDto.setCourseId(ct.getCourseId());
|
||||||
@@ -337,7 +335,7 @@ public class CoursePortalApi extends ApiBaseController{
|
|||||||
List<String> list=new ArrayList<>();
|
List<String> list=new ArrayList<>();
|
||||||
list.add(ct.getTeacherId());
|
list.add(ct.getTeacherId());
|
||||||
getTeacherInfo(request.getHeader("Xboe-Access-Token"),list);
|
getTeacherInfo(request.getHeader("Xboe-Access-Token"),list);
|
||||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
teacherCourseDto.setCourseId(ct.getCourseId());
|
||||||
|
|||||||
@@ -341,6 +341,8 @@ public interface ICourseService {
|
|||||||
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
||||||
|
|
||||||
|
|
||||||
List<Course> findByIds(List<String> courseIds);
|
|
||||||
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;
|
||||||
@@ -15,17 +14,11 @@ import java.util.stream.Stream;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.management.Query;
|
import javax.management.Query;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.core.orm.*;
|
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;
|
||||||
@@ -122,9 +115,6 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private IEventDataSender eventSender;
|
private IEventDataSender eventSender;
|
||||||
|
|
||||||
@Resource
|
|
||||||
RestHighLevelClient restHighLevelClient;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -458,7 +448,6 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
List<Course> paginate = paginate(listByFilters2, pageIndex, pageSize);
|
List<Course> paginate = paginate(listByFilters2, pageIndex, pageSize);
|
||||||
PageList<Course> rs = new PageList<>();
|
PageList<Course> rs = new PageList<>();
|
||||||
rs.setCount(listByFilters2.size());
|
rs.setCount(listByFilters2.size());
|
||||||
rs.setPageSize(pageSize);
|
|
||||||
rs.setList(paginate);
|
rs.setList(paginate);
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
@@ -491,7 +480,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
String sql = "SELECT DISTINCT\n" +
|
String sql = "SELECT DISTINCT\n" +
|
||||||
"rt.course_id\n" +
|
"rt.course_id\n" +
|
||||||
"FROM\n" +
|
"FROM\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" +
|
"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" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"WHERE\n" +
|
"WHERE\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
@@ -514,7 +503,7 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
String sql = "SELECT DISTINCT\n" +
|
String sql = "SELECT DISTINCT\n" +
|
||||||
"pt.course_id\n" +
|
"pt.course_id\n" +
|
||||||
"FROM\n" +
|
"FROM\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" +
|
"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" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"WHERE\n" +
|
"WHERE\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
@@ -571,8 +560,8 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
String sql = "SELECT DISTINCT\n" +
|
String sql = "SELECT DISTINCT\n" +
|
||||||
"\tc.id \n" +
|
"\tc.id \n" +
|
||||||
"FROM\n" +
|
"FROM\n" +
|
||||||
"\tboe_new.student s\n" +
|
"\tboe.student s\n" +
|
||||||
"\tINNER JOIN boe_new.grow_task gt ON s.pid = gt.grow_id\n" +
|
"\tINNER JOIN boe.grow_task gt ON s.pid = gt.grow_id\n" +
|
||||||
"\tINNER JOIN boe_course c ON gt.course_id = c.id \n" +
|
"\tINNER JOIN boe_course c ON gt.course_id = c.id \n" +
|
||||||
"WHERE\n" +
|
"WHERE\n" +
|
||||||
"\ts.type = 14 \n" +
|
"\ts.type = 14 \n" +
|
||||||
@@ -864,14 +853,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
|
||||||
@@ -1580,13 +1567,6 @@ public class CourseServiceImpl implements ICourseService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Course> findByIds(List<String> courseIds) {
|
|
||||||
QueryBuilder query = QueryBuilder.from(Course.class);
|
|
||||||
query.addFilter(FieldFilters.in("id", courseIds));
|
|
||||||
return courseDao.findList(query.builder());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countWaitAudit(String aid) {
|
public int countWaitAudit(String aid) {
|
||||||
@@ -1998,17 +1978,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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
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;
|
||||||
@@ -219,11 +214,11 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
redisTemplate.opsForValue().set(teacherVo.get(0).getTeacherId(), teacherVo.get(0).getStatus());
|
redisTemplate.opsForValue().set(teacherVo.get(0).getTeacherId(), teacherVo.get(0).getStatus());
|
||||||
//设置过期时间为1天
|
//设置过期时间为1天
|
||||||
redisTemplate.expire(teacherVo.get(0).getTeacherId(), 24 * 60 * 60, TimeUnit.SECONDS);
|
redisTemplate.expire(teacherVo.get(0).getTeacherId(), 24 * 60 * 60, TimeUnit.SECONDS);
|
||||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
|
||||||
ct.setTeacherName("BOE教师");
|
ct.setTeacherName("BOE教师");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,49 +253,6 @@ 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);//学习的内容
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,6 +367,8 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
studyService.saveStudyInfo(sci,token);
|
studyService.saveStudyInfo(sci,token);
|
||||||
//学习记录成功后处理
|
//学习记录成功后处理
|
||||||
studyService.appendStudyDuration(sci.getStudyId(),sci.getStudyItemId(),sci.getContentId(),sci.getDuration());
|
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);
|
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
//System.out.println("在线课学习记录"+allUserList);
|
//System.out.println("在线课学习记录"+allUserList);
|
||||||
|
|||||||
@@ -3,16 +3,9 @@ package com.xboe.school.study.api;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.xboe.module.course.entity.Course;
|
|
||||||
import com.xboe.module.course.service.ICourseService;
|
|
||||||
import org.apache.commons.compress.utils.Lists;
|
|
||||||
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.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -49,15 +42,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IStudyCourseService service;
|
IStudyCourseService service;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
ICourseService courseService;
|
|
||||||
|
|
||||||
@Value("${xboe.upload.file.http_path}")
|
|
||||||
private String httpPath;
|
|
||||||
|
|
||||||
@Value("${xboe.image.course.default}")
|
|
||||||
private String defaultCourseImage;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PhpOnlineStudyRecordScheduledTasks phpOnlineStudyRecordScheduledTasks;
|
private PhpOnlineStudyRecordScheduledTasks phpOnlineStudyRecordScheduledTasks;
|
||||||
|
|
||||||
@@ -70,9 +54,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
try {
|
try {
|
||||||
dto.setAccountId(getCurrent().getAccountId());
|
dto.setAccountId(getCurrent().getAccountId());
|
||||||
PageList<CourseStudyDto> rs=search.search(page.getStartRow(),page.getPageSize(), dto);
|
PageList<CourseStudyDto> rs=search.search(page.getStartRow(),page.getPageSize(), dto);
|
||||||
|
|
||||||
handleCourseImage(rs);
|
|
||||||
|
|
||||||
return success(rs);
|
return success(rs);
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("查询报名学习ES失败",e);
|
log.error("查询报名学习ES失败",e);
|
||||||
@@ -80,51 +61,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCourseImage(PageList<CourseStudyDto> rs) {
|
|
||||||
if (rs == null || CollectionUtil.isEmpty(rs.getList())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> emptyImageCourseIds = Lists.newArrayList();
|
|
||||||
for(CourseStudyDto courseStudyDto : rs.getList()) {
|
|
||||||
if(StringUtils.isBlank(courseStudyDto.getCourseImage())) {
|
|
||||||
// 过滤课程类型
|
|
||||||
if(courseStudyDto.getCourseType()==10
|
|
||||||
|| courseStudyDto.getCourseType()==20){
|
|
||||||
emptyImageCourseIds.add(courseStudyDto.getCourseId());
|
|
||||||
}else{
|
|
||||||
log.warn("课程图片为空,课程id为:{},课程类型:{}",courseStudyDto.getCourseId(),courseStudyDto.getCourseType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(CollectionUtil.isEmpty(emptyImageCourseIds)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Course> courseList = courseService.findByIds(emptyImageCourseIds);
|
|
||||||
if(CollectionUtil.isNotEmpty(courseList)){
|
|
||||||
// courseList转换成map
|
|
||||||
Map<String, Course> courseMap = courseList.stream().collect(Collectors.toMap(Course::getId, course -> course));
|
|
||||||
|
|
||||||
// 赋值ES图片
|
|
||||||
for(CourseStudyDto courseStudyDto : rs.getList()) {
|
|
||||||
if(emptyImageCourseIds.contains(courseStudyDto.getCourseId())) {
|
|
||||||
Course currentCourse = courseMap.get(courseStudyDto.getCourseId());
|
|
||||||
if(null!=currentCourse){
|
|
||||||
if(StringUtils.isNotBlank(currentCourse.getCoverImg())){
|
|
||||||
// 拼接域名
|
|
||||||
courseStudyDto.setCourseImage(httpPath + currentCourse.getCoverImg());
|
|
||||||
}else{
|
|
||||||
// 赋值默认图片
|
|
||||||
courseStudyDto.setCourseImage(defaultCourseImage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value="/list-by-ids",method = {RequestMethod.POST})
|
@RequestMapping(value="/list-by-ids",method = {RequestMethod.POST})
|
||||||
public JsonResponse<List<StudyCourse>> search(@RequestBody List<String> ids){
|
public JsonResponse<List<StudyCourse>> search(@RequestBody List<String> ids){
|
||||||
if(ids.isEmpty()) {
|
if(ids.isEmpty()) {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import org.springframework.data.redis.core.ScanOptions;
|
|||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -35,7 +33,7 @@ public class StudyCourseTask {
|
|||||||
public void saveStudyCourseItemLastTime() {
|
public void saveStudyCourseItemLastTime() {
|
||||||
// 1. 定义匹配模式(匹配所有目标key)
|
// 1. 定义匹配模式(匹配所有目标key)
|
||||||
final String KEY_PATTERN = "studyContentId:*:last_active";
|
final String KEY_PATTERN = "studyContentId:*:last_active";
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
|
||||||
// 2. 使用SCAN安全遍历(避免阻塞)
|
// 2. 使用SCAN安全遍历(避免阻塞)
|
||||||
ScanOptions options = ScanOptions.scanOptions()
|
ScanOptions options = ScanOptions.scanOptions()
|
||||||
.match(KEY_PATTERN)
|
.match(KEY_PATTERN)
|
||||||
@@ -61,17 +59,12 @@ public class StudyCourseTask {
|
|||||||
String studyContentId = parts[1];
|
String studyContentId = parts[1];
|
||||||
|
|
||||||
// 7. 获取存储的时间点(示例逻辑)
|
// 7. 获取存储的时间点(示例逻辑)
|
||||||
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
String lastStudyTimeStr = redisTemplate.opsForValue().get(redisKey);
|
||||||
if (redisValue == null) continue;
|
if (lastStudyTimeStr == null) continue;
|
||||||
String[] partValues = redisValue.split("&");
|
int lastStudyTime = Integer.parseInt(lastStudyTimeStr);
|
||||||
int lastStudyTime = Integer.parseInt(partValues[0]);
|
|
||||||
LocalDateTime timestamp = null;
|
|
||||||
if (partValues.length >= 2){
|
|
||||||
timestamp = LocalDateTime.parse(partValues[1], formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 8. 更新数据库(调用已有服务方法)
|
// 8. 更新数据库(调用已有服务方法)
|
||||||
studyService.updateStudyCourseItemLastTime(studyContentId, lastStudyTime, timestamp);
|
studyService.updateStudyCourseItemLastTime(studyContentId, lastStudyTime, "system_job");
|
||||||
|
|
||||||
// 9. 删除Redis键(原子操作)
|
// 9. 删除Redis键(原子操作)
|
||||||
redisTemplate.delete(redisKey);
|
redisTemplate.delete(redisKey);
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
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;
|
||||||
@@ -131,11 +129,4 @@ public class StudyCourseItem extends IdEntity {
|
|||||||
@Column(name = "status",length=1)
|
@Column(name = "status",length=1)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 视频播放进度
|
|
||||||
* */
|
|
||||||
// @Column(name = "progress_video")
|
|
||||||
@Transient
|
|
||||||
private BigDecimal progressVideo;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -8,6 +7,7 @@ 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,12 +35,11 @@ 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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源学习记录
|
* 资源学习记录
|
||||||
@@ -100,5 +99,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);
|
void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime, String systemJob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ 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.data.redis.core.StringRedisTemplate;
|
||||||
@@ -326,25 +330,19 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
// 更新 前端传输已学习时长
|
// 更新 前端传输已学习时长
|
||||||
@Override
|
@Override
|
||||||
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 优化 多次更新改一次更新
|
// 20250303 优化 多次更新改一次更新
|
||||||
// 更新Redis中的最后活跃时间(带30秒过期)
|
// 更新Redis中的最后活跃时间(带30秒过期)
|
||||||
redisTemplate.opsForValue().set(
|
redisTemplate.opsForValue().set(
|
||||||
"studyContentId:" + studyContentId + ":last_active",
|
"studyContentId:" + studyContentId + ":last_active",
|
||||||
value,
|
String.valueOf(lastStudyTime),
|
||||||
Duration.ofSeconds(2592000)
|
Duration.ofSeconds(2592000)
|
||||||
);
|
);
|
||||||
log.info("-study-video-time-redis保存---value = " + value);
|
|
||||||
// Duration.ofDays(30) 也就是 2592000秒
|
// Duration.ofDays(30) 也就是 2592000秒
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime,LocalDateTime timestamp) {
|
public void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime,String aid) {
|
||||||
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);
|
||||||
@@ -352,9 +350,8 @@ 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", timestamp==null ? now : timestamp);
|
update.addUpdateField("lastTime", now);
|
||||||
scItemDao.update(update.builder());
|
scItemDao.update(update.builder());
|
||||||
log.info("-study-video-time-mysql保存---studyContentId = " + studyContentId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -76,9 +76,6 @@ xboe:
|
|||||||
encryptor:
|
encryptor:
|
||||||
algorithm: PBEWithMD5AndDES
|
algorithm: PBEWithMD5AndDES
|
||||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||||
image:
|
|
||||||
course:
|
|
||||||
default: http://192.168.0.253/pc/images/bgimg/course.png
|
|
||||||
xxl:
|
xxl:
|
||||||
job:
|
job:
|
||||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||||
|
|||||||
@@ -108,9 +108,7 @@ xboe:
|
|||||||
from: boeu_learning@boe.com.cn
|
from: boeu_learning@boe.com.cn
|
||||||
user:
|
user:
|
||||||
security:
|
security:
|
||||||
image:
|
|
||||||
course:
|
|
||||||
default: http://10.251.132.75/pc/images/bgimg/course.png
|
|
||||||
jasypt:
|
jasypt:
|
||||||
encryptor:
|
encryptor:
|
||||||
algorithm: PBEWithMD5AndDES
|
algorithm: PBEWithMD5AndDES
|
||||||
|
|||||||
@@ -74,9 +74,6 @@ xboe:
|
|||||||
encryptor:
|
encryptor:
|
||||||
algorithm: PBEWithMD5AndDES
|
algorithm: PBEWithMD5AndDES
|
||||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||||
image:
|
|
||||||
course:
|
|
||||||
default: https://u.boe.com/pc/images/bgimg/course.png
|
|
||||||
xxl:
|
xxl:
|
||||||
job:
|
job:
|
||||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ xboe:
|
|||||||
file:
|
file:
|
||||||
temp_path: /tmp
|
temp_path: /tmp
|
||||||
save_path: /home/www/elearning/upload
|
save_path: /home/www/elearning/upload
|
||||||
http_path: https://u-pre.boe.com/upload
|
http_path: http://10.251.186.27/upload
|
||||||
externalinterface:
|
externalinterface:
|
||||||
url:
|
url:
|
||||||
system: http://localhost:9091
|
system: http://localhost:9091
|
||||||
@@ -108,9 +108,7 @@ xboe:
|
|||||||
from: boeu_learning@boe.com.cn
|
from: boeu_learning@boe.com.cn
|
||||||
user:
|
user:
|
||||||
security:
|
security:
|
||||||
image:
|
|
||||||
course:
|
|
||||||
default: https://u-pre.boe.com/pc/images/bgimg/course.png
|
|
||||||
jasypt:
|
jasypt:
|
||||||
encryptor:
|
encryptor:
|
||||||
algorithm: PBEWithMD5AndDES
|
algorithm: PBEWithMD5AndDES
|
||||||
|
|||||||
Reference in New Issue
Block a user