mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
Compare commits
75 Commits
250422-dem
...
player-202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80b444c188 | ||
|
|
b0a0725373 | ||
|
|
59e42cda4f | ||
|
|
ec6d9100c2 | ||
|
|
562a4cc862 | ||
|
|
ae11017d67 | ||
|
|
fd473445de | ||
|
|
bfdbd4d38e | ||
|
|
640786391d | ||
|
|
71b00372f6 | ||
|
|
2e4b04d1d1 | ||
|
|
bffb85848f | ||
|
|
a9e34e42b9 | ||
|
|
84bd63ec0e | ||
|
|
1aba83a1b8 | ||
|
|
2b1211c83d | ||
|
|
fe3e8df37c | ||
|
|
8d9b360654 | ||
|
|
3379acdd1e | ||
|
|
9a3b394e03 | ||
|
|
7beb046d6d | ||
|
|
07b501742f | ||
|
|
748f7c5913 | ||
|
|
5954d54e44 | ||
|
|
4ede914452 | ||
|
|
00527271b6 | ||
|
|
308a16f4b4 | ||
|
|
302a673515 | ||
|
|
49b69db0bf | ||
|
|
8a0b05079a | ||
|
|
eaab48607d | ||
|
|
309599f43f | ||
|
|
20e3b001d5 | ||
|
|
a37f90aeaa | ||
|
|
e767345c1e | ||
|
|
6fe6f7c6e5 | ||
|
|
249a8d81a6 | ||
|
|
7abb00772b | ||
|
|
04e11f2e71 | ||
|
|
2feb149e92 | ||
|
|
16fa9cb028 | ||
|
|
cac466ba73 | ||
|
|
30d2a0cde2 | ||
|
|
541e542d9b | ||
|
|
aa04e16209 | ||
|
|
57e22492e5 | ||
|
|
1917647a99 | ||
|
|
f5f7ab3bc5 | ||
|
|
413a2ebc33 | ||
|
|
22db916abf | ||
|
|
8ce284ea7e | ||
|
|
c485757061 | ||
|
|
9a00b41cde | ||
|
|
59beaa5b74 | ||
|
|
9b9e97a8d4 | ||
|
|
200ec38038 | ||
|
|
7613f30ca7 | ||
|
|
248e0799bd | ||
|
|
618b0b3f62 | ||
|
|
5836b147c4 | ||
|
|
fb1d11ebab | ||
|
|
add1d6abb2 | ||
|
|
eafe17b99a | ||
|
|
d1b6573c25 | ||
|
|
1039f80aec | ||
|
|
efc0605115 | ||
|
|
d938425151 | ||
|
|
00510562ca | ||
|
|
3e70e71e5a | ||
|
|
24011a4470 | ||
|
|
8948165296 | ||
|
|
076b1828ad | ||
|
|
95312696f6 | ||
|
|
1aca002b8f | ||
|
|
50bdc39ce8 |
@@ -239,6 +239,10 @@
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.3.0</version> <!-- 请根据实际需求选择版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -45,10 +45,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -98,7 +95,8 @@ public class ThirdApi {
|
||||
private String syncOnLineScore;
|
||||
@Value("${coursesuilt.updateOnLineStatua}")
|
||||
private String updateOnLineStatua;
|
||||
|
||||
@Value("${coursesuilt.delOnLineById}")
|
||||
private String delOnLineById;
|
||||
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId() {
|
||||
@@ -398,4 +396,28 @@ public class ThirdApi {
|
||||
public void syncExamStudyRecord(ExamStudyRecordParam param) {
|
||||
externalRemoteClient.syncExamStudyRecord(param);
|
||||
}
|
||||
|
||||
public void delOnLineById(CourseParam param, String token) {
|
||||
log.info("---------------同步在线课删除 ------- param " + param);
|
||||
String resp = Optional.ofNullable(
|
||||
HttpRequest.post(delOnLineById).body(JSONUtil.toJsonStr(param)).header("token", token).execute()
|
||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
log.info("-------delOnLineById = " + resp);
|
||||
}
|
||||
|
||||
//获取字典信息
|
||||
public List<Dict> getDictItems(CommonSearchVo searcher) {
|
||||
try {
|
||||
List<Dict> dictList = dictRemoteClient.getList(searcher);
|
||||
if(!Objects.isNull(dictList) && dictList.size() > 0){
|
||||
// List<String> dicts = dictList.stream().map(Dict::getValue).collect(Collectors.toList());
|
||||
return dictList;
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("-------获取字典信息 = " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.course.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -7,9 +8,22 @@ import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.course.dto.CourseParam;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -21,13 +35,6 @@ import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.log.AutoLog;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
import com.xboe.module.course.dto.CourseHRBPAuditDto;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseAudit;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseHRBPAudit;
|
||||
import com.xboe.module.course.service.ICourseAuditService;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseHRBPAuditService;
|
||||
@@ -61,6 +68,9 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 教师需要审核的课程
|
||||
@@ -358,8 +368,10 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
//修改在线课开课状态=已开课
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
CourseParam param = new CourseParam();
|
||||
param.setId(courseId);
|
||||
thirdApi.updateOnLineStatua(param,token);
|
||||
param.setId(c.getId());
|
||||
param.setOrgId(c.getOrgId());
|
||||
param.setOrgName(c.getOrgName());
|
||||
thirdApi.updateOrSaveCourse(param,token);
|
||||
}
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
@@ -433,6 +445,9 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
param.setOrgName(dto.getCourse().getOrgName());
|
||||
thirdApi.updateOrSaveCourse(param,token);
|
||||
log.info("---------------在线课同步到讲师管理完毕 -------");
|
||||
//AI视频处理-调用接口
|
||||
this.sendMessageToKJB(dto);
|
||||
log.info("---------------AI视频处理-调用接口完毕 -------");
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("默认管理员提交直接发布处理失败",e);
|
||||
@@ -441,6 +456,66 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
}
|
||||
public void sendMessageToKJB(CourseFullDto dto) throws JsonProcessingException {
|
||||
Course course = dto.getCourse();
|
||||
log.info("---------------AI视频处理-调用接口 -------");
|
||||
log.info("aiSet:"+course.getAiSet()+",aiAbstract:"+course.getAiAbstract()+",aiDraft:"+course.getAiDraft()+",aiTranslate:"+course.getAiTranslate()+",languageCode:"+course.getLanguageCode());
|
||||
List<CourseTeacher> teachers = dto.getTeachers();
|
||||
StringBuilder teacherNames = new StringBuilder();
|
||||
for (CourseTeacher teacher : teachers) {
|
||||
teacherNames.append(teacher.getTeacherName()).append(",");
|
||||
}
|
||||
List<CourseContent> cclist = ccontentService.getByCourseId(course.getId());
|
||||
List<String> languageCode = course.getLanguageCode();
|
||||
String code = String.join(",", languageCode);
|
||||
List<BoeaiCourseDto> courseDtos = new ArrayList<>();
|
||||
BoeaiCourseDto boeaiCourseDto = new BoeaiCourseDto();
|
||||
List<BoeaiVideoResourceDto> videoList = new ArrayList<>();
|
||||
boeaiCourseDto = BoeaiCourseDto.builder()
|
||||
.courseId(course.getId())
|
||||
.title(course.getName())
|
||||
.description(course.getSummary())
|
||||
.instructor(teacherNames.toString())
|
||||
.chapterCount(1) //章节数
|
||||
.languageCode(code) //语言
|
||||
.aiTranslate(course.getAiTranslate())
|
||||
.aiAbstract(course.getAiAbstract())
|
||||
.aiDraft(course.getAiDraft())
|
||||
.aiSet(course.getAiSet())
|
||||
.languageStatus(course.getLanguageStatus())
|
||||
.build() ;
|
||||
for (CourseContent cc : cclist) {
|
||||
//筛选视频资源
|
||||
if(cc.getContentType() == 10 ){
|
||||
JSONObject json = JSONObject.parseObject(cc.getContent());
|
||||
if(json == null || json.getString("url") == null) {
|
||||
continue;
|
||||
}
|
||||
String videoUrl = json.getString("url");
|
||||
String videoUrlPerfix = "https://u-pre.boe.com/upload"; //测试
|
||||
//String videoUrlPerfix = "https://u.boe.com/upload"; //生产
|
||||
String videoType = videoUrl.substring(videoUrl.lastIndexOf(".")+1);
|
||||
videoList.add(BoeaiVideoResourceDto.builder()
|
||||
.courseId(cc.getCourseId())
|
||||
.videoId(cc.getId())
|
||||
.title(cc.getContentName())
|
||||
.originalUrl(videoUrlPerfix+videoUrl)
|
||||
.duration(cc.getDuration())
|
||||
.format(videoType)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
boeaiCourseDto.setBoeaiVideoResourceReqList(videoList);
|
||||
boeaiCourseDto.setVideoCount(videoList.size());
|
||||
|
||||
courseDtos.add(boeaiCourseDto);
|
||||
BoeaiCourseParamsReq paramReq = new BoeaiCourseParamsReq();
|
||||
paramReq.setBoeaiCourseReqList(courseDtos);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String message = objectMapper.writeValueAsString(paramReq);
|
||||
String url = aicoreUrl +"/aiVideo/saveCourse";
|
||||
HttpUtils.sendMessage(message,url);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
@@ -473,5 +548,4 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import it.sauronsoftware.jave.Encoder;
|
||||
import it.sauronsoftware.jave.MultimediaInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.orm.ObjectOptimisticLockingFailureException;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -46,8 +48,6 @@ import com.xboe.module.scorm.SCORMParser;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import com.xboe.standard.enums.BoedxCourseFileType;
|
||||
|
||||
import it.sauronsoftware.jave.Encoder;
|
||||
import it.sauronsoftware.jave.MultimediaInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -278,8 +278,8 @@ public class CourseFileApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("读取视频时长错误");
|
||||
// e.printStackTrace();
|
||||
log.error("读取视频时长错误", e);
|
||||
return error("视频解析失败,尝试重新上传或联系管理员", "视频解析失败,尝试重新上传或联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,23 @@ import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.boe.feign.api.serverall.entity.UserData;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.course.dto.BoeaiCourseDto;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.service.IStudyCourseService;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -76,6 +82,9 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 课程的初始化
|
||||
* @return
|
||||
@@ -322,6 +331,8 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
if(c.getSource()==2) {
|
||||
cids.add(c.getId());
|
||||
}
|
||||
log.info("---- KJB 开始获取课程摘要信息 ---");
|
||||
this.getCourseFromKJB(c);
|
||||
}
|
||||
List<Course> clist=null;
|
||||
if(!cids.isEmpty()) {
|
||||
@@ -413,6 +424,33 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
public void getCourseFromKJB(CourseFullText courseFull){
|
||||
String courseId = courseFull.getId();
|
||||
log.info("------------KJB---获取课程摘要信息---------;courseId = " + courseId);
|
||||
//String url = env.getProperty("kjb.url") + "/api/course/getCourseFromKJB?courseId=" + courseId;
|
||||
String url = aicoreUrl + "/aiVideo/getCourseList";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray courseIds = new JSONArray();
|
||||
courseIds.add(courseId);
|
||||
jsonObject.put("courseIds", courseIds);
|
||||
String result = HttpUtils.sendMessage(jsonObject.toJSONString(), url);
|
||||
|
||||
//将返回string 转为json对象
|
||||
log.info("---KJB --摘要接口返回结果result: "+result);
|
||||
JSONObject jsonResult = JSONObject.parseObject(result);
|
||||
String data = jsonResult.getString("rows");
|
||||
//json字符串转为实体对象
|
||||
// 直接解析为 List<Course>
|
||||
List<BoeaiCourseDto> boeaiCourseDto = JSON.parseArray(data, BoeaiCourseDto.class);
|
||||
//List<BoeaiCourseDto> aiVideoResourceRsp = Collections.singletonList(JSON.parseObject(data, BoeaiCourseDto.class));
|
||||
if(boeaiCourseDto != null && !boeaiCourseDto.isEmpty()){
|
||||
log.info("KJB摘要信息:"+boeaiCourseDto.get(0).getSummaryContent());
|
||||
courseFull.setAiAbstract(boeaiCourseDto.get(0).getAiAbstract());
|
||||
courseFull.setSummaryContent(boeaiCourseDto.get(0).getSummaryContent());
|
||||
}
|
||||
}
|
||||
|
||||
private void getTeacherStatusByCode(String token, PageList<CourseFullText> coursePageList) {
|
||||
log.info("获取教师信息通过工号 ");
|
||||
List<String> teacherCoeds = new ArrayList<>();
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
||||
import com.boe.feign.api.infrastructure.entity.Dict;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -170,17 +173,46 @@ public class CourseManageApi extends ApiBaseController{
|
||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
||||
List<CourseCrowd> crowds=courseService.findCrowdByCourseId(id);
|
||||
|
||||
//
|
||||
CommonSearchVo searcher = new CommonSearchVo();
|
||||
searcher.setPid(637L);
|
||||
searcher.setType(1);
|
||||
List<Dict> dictList = thirdApi.getDictItems(searcher);
|
||||
boolean isPermission = false;
|
||||
if(dictList != null && dictList.size() > 0){
|
||||
List<String> dicts = dictList.stream().map(Dict::getValue).collect(Collectors.toList());
|
||||
isPermission = dicts.contains(course.getOrgId());
|
||||
rs.put("dicts",dicts);
|
||||
}
|
||||
log.error("-------是否仅内网查看 = " + isPermission);
|
||||
rs.put("course",course);
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
rs.put("teachers",teachers);
|
||||
rs.put("crowds",crowds);
|
||||
rs.put("isPermission",isPermission);
|
||||
|
||||
|
||||
|
||||
return success(rs);
|
||||
|
||||
}
|
||||
@GetMapping("/getDictIds")
|
||||
public JsonResponse<Map<String,Object>> getDictIds(Long pid,Integer type){
|
||||
CommonSearchVo searcher = new CommonSearchVo();
|
||||
if(pid==null || type ==null){
|
||||
return badRequest("参数错误");
|
||||
}
|
||||
Map<String,Object> rs=new HashMap<String,Object>();
|
||||
searcher.setPid(pid);
|
||||
searcher.setType(type);
|
||||
List<Dict> dictList = thirdApi.getDictItems(searcher);
|
||||
rs.put("dicts",null);
|
||||
if(dictList != null && dictList.size() > 0){
|
||||
List<String> dicts = dictList.stream().map(Dict::getValue).collect(Collectors.toList());
|
||||
rs.put("dicts",dicts);
|
||||
}
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员审核列表,教师的审核不在这里,此审核也应该移动CourseAuditApi中去
|
||||
@@ -886,7 +918,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public JsonResponse<Boolean> delete(String id,Boolean erasable,String title,String remark){
|
||||
public JsonResponse<Boolean> delete(String id,Boolean erasable,String title,String remark, HttpServletRequest request){
|
||||
if(StringUtils.isBlank(id)){
|
||||
return badRequest("参数错误");
|
||||
}
|
||||
@@ -901,6 +933,11 @@ public class CourseManageApi extends ApiBaseController{
|
||||
try {
|
||||
CurrentUser cu=getCurrent();
|
||||
courseService.delete(id, erasable,cu.getAccountId(), cu.getName(), remark);
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
CourseParam param = new CourseParam();
|
||||
param.setId(id);
|
||||
thirdApi.delOnLineById(param,token);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("管理员删除课程错误",e);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseTeacherDeletedRecord;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CourseTeacherDeletedRecordDao extends BaseDao<CourseTeacherDeletedRecord> {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.ModifyLog;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ModifyLogDao extends BaseDao<ModifyLog> {
|
||||
|
||||
public void insert(String requestId, String location, String body, String remark) {
|
||||
ModifyLog entity = new ModifyLog();
|
||||
entity.setRequestId(requestId);
|
||||
entity.setLocation(location);
|
||||
entity.setBody(body);
|
||||
entity.setRemark(remark);
|
||||
|
||||
save(entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Huang Run
|
||||
* @date 2025年11月04日
|
||||
*/
|
||||
@Data
|
||||
public class AiVideoResourceRsp {
|
||||
//多语言字幕信息
|
||||
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 视频业务ID
|
||||
*/
|
||||
private String videoId;
|
||||
/**
|
||||
* 视频语言编码 如 zh-CN, en-US
|
||||
*/
|
||||
//private String languageCode;
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 视频标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 原始视频URL
|
||||
*/
|
||||
private String originalUrl;
|
||||
|
||||
/**
|
||||
* 视频时长(秒)
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 视频格式 mp4/avi等
|
||||
*/
|
||||
private String format;
|
||||
|
||||
/**
|
||||
* 状态 0-待处理 1-处理中 2-已完成 3-失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已审核 0-否 1-是
|
||||
*/
|
||||
private Integer isReviewed;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private String reviewerId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Transient;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BoeaiCourseDto {
|
||||
List<BoeaiVideoResourceDto> boeaiVideoResourceReqList;
|
||||
|
||||
|
||||
List<String> courseVideoIds;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
/**
|
||||
* 视频ID
|
||||
*/
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 课程标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 讲师名称
|
||||
*/
|
||||
private String instructor;
|
||||
|
||||
/**
|
||||
* 章节数
|
||||
*/
|
||||
private Integer chapterCount;
|
||||
|
||||
/**
|
||||
* 视频数
|
||||
*/
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 总时长(秒)
|
||||
*/
|
||||
private Integer totalDuration;
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 课程描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 视频语言编码 如 zh-CN, en-US
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 0:关闭;1:打开;
|
||||
* */
|
||||
|
||||
private Integer aiSet;
|
||||
/**
|
||||
* 摘要 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiAbstract;
|
||||
/**
|
||||
* 文稿 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiDraft;
|
||||
/**
|
||||
* 翻译 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiTranslate;
|
||||
|
||||
private Integer languageStatus;
|
||||
//摘要
|
||||
private String summaryContent;
|
||||
//摘要状态 0:下架;1:上架
|
||||
private Integer summaryStatus;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Huang Run
|
||||
* @date 2025年11月19日
|
||||
*/
|
||||
@Data
|
||||
public class BoeaiCourseParamsReq implements Serializable {
|
||||
List<BoeaiCourseDto> boeaiCourseReqList;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* 视频字幕表
|
||||
*/
|
||||
@Data
|
||||
public class BoeaiSubtitleRsp implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联视频ID
|
||||
*/
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 字幕语言(如 zh-CN, en-US)
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* WebVTT字幕文件URL(OSS地址)
|
||||
*/
|
||||
private String subtitleUrl;
|
||||
|
||||
/**
|
||||
* 是否原始字幕 0-翻译 1-原始
|
||||
*/
|
||||
private Byte isOriginal;
|
||||
|
||||
/**
|
||||
* 源语言/翻译来源(如 zh-CN)
|
||||
*/
|
||||
private String sourceLanguage;
|
||||
|
||||
/**
|
||||
* 翻译引擎(llm/google/deepl)
|
||||
*/
|
||||
private String translateEngine;
|
||||
|
||||
/**
|
||||
* 状态(0-待生成 1-生成中 2-已完成 3-失败)
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 字幕数据(JSON 数组格式,包含时间戳和翻译文本)
|
||||
*/
|
||||
private String subtitleData;
|
||||
|
||||
/**
|
||||
* WebVTT 格式字幕内容
|
||||
*/
|
||||
private String vttContent;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String errorMsg;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BoeaiVideoResourceDto {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 视频业务ID
|
||||
*/
|
||||
private String videoId;
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 视频标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 原始视频URL
|
||||
*/
|
||||
private String originalUrl;
|
||||
|
||||
/**
|
||||
* 视频时长(秒)
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 视频格式 mp4/avi等
|
||||
*/
|
||||
private String format;
|
||||
|
||||
/**
|
||||
* 状态 0-待处理 1-处理中 2-已完成 3-失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已审核 0-否 1-是
|
||||
*/
|
||||
private Integer isReviewed;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private String reviewerId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -34,6 +35,9 @@ public class Course extends BaseEntity {
|
||||
/**所有的设备*/
|
||||
public static int DEVICE_ALL=3;
|
||||
|
||||
/**仅内网*/
|
||||
public static int DEVICE_INTERNAL=4;
|
||||
|
||||
/**未提交,草稿*/
|
||||
public static final int STATUS_NONE=1;
|
||||
|
||||
@@ -213,6 +217,47 @@ public class Course extends BaseEntity {
|
||||
@Column(name = "device",length = 1)
|
||||
private Integer device;
|
||||
|
||||
|
||||
/**
|
||||
* 0:关闭;1:打开;
|
||||
* */
|
||||
// @Column(name = "ai_set",length = 1)
|
||||
@Transient
|
||||
private Integer aiSet;
|
||||
/**
|
||||
* 摘要 0:上架;1:下架;
|
||||
* */
|
||||
//@Column(name = "ai_abstract",length = 1)
|
||||
@Transient
|
||||
private Integer aiAbstract;
|
||||
/**
|
||||
* 文稿 0:上架;1:下架;
|
||||
* */
|
||||
// @Column(name = "ai_draft",length = 1)
|
||||
@Transient
|
||||
private Integer aiDraft;
|
||||
/**
|
||||
* 翻译 0:上架;1:下架;
|
||||
* */
|
||||
//@Column(name = "ai_translate",length = 1)
|
||||
@Transient
|
||||
private Integer aiTranslate;
|
||||
@Transient
|
||||
private Integer languageStatus;
|
||||
/**
|
||||
* 语言 zh-CN,en-US,ja-JP,ko-KR
|
||||
* */
|
||||
//Column(name = "language_code",length = 120)
|
||||
@Transient
|
||||
private List<String> languageCode;
|
||||
|
||||
//摘要
|
||||
@Transient
|
||||
private String summaryContent;
|
||||
//摘要状态 0:下架;1:上架
|
||||
@Transient
|
||||
private Integer summaryStatus;
|
||||
|
||||
/**
|
||||
* 课程状态,多人审核机制,所以这里并没有审核通过与不通过的状态了
|
||||
* 课程状态 1:未提交(草稿);2:已提交;3: 审核未通过,5审核完成
|
||||
|
||||
@@ -8,9 +8,12 @@ import javax.persistence.Transient;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
|
||||
import com.xboe.module.course.dto.BoeaiSubtitleRsp;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 课程内容表
|
||||
* */
|
||||
@@ -94,6 +97,9 @@ public class CourseContent extends BaseEntity {
|
||||
@Transient
|
||||
private Integer status;
|
||||
|
||||
@Transient
|
||||
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
|
||||
|
||||
public CourseContent() {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 课程任课教师删除记录
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "course_teacher_deleted_record")
|
||||
public class CourseTeacherDeletedRecord extends IdBaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 课程id
|
||||
*/
|
||||
@Column(name = "course_id", nullable = false, length = 20)
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 教师id,实际上就是aid
|
||||
*
|
||||
*/
|
||||
@Column(name = "teacher_id", nullable = false, length = 20)
|
||||
private String teacherId;
|
||||
|
||||
/**
|
||||
* 教师姓名
|
||||
*
|
||||
*/
|
||||
@Column(name = "teacher_name", length = 30)
|
||||
private String teacherName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 讲师删除记录表
|
||||
* 为了监控PngCode-SZX-1227问题临时创建的表
|
||||
*
|
||||
* @author guo jia
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(name = SysConstant.TABLE_PRE + "modify_log")
|
||||
public class ModifyLog extends IdBaseEntity {
|
||||
|
||||
/**
|
||||
* 请求ID
|
||||
*/
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 请求body
|
||||
*/
|
||||
private String body;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -15,9 +15,18 @@ import java.util.stream.Stream;
|
||||
import javax.annotation.Resource;
|
||||
import javax.management.Query;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -28,6 +37,7 @@ import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -41,24 +51,6 @@ import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.module.course.dao.CourseContentDao;
|
||||
import com.xboe.module.course.dao.CourseCrowdDao;
|
||||
import com.xboe.module.course.dao.CourseDao;
|
||||
import com.xboe.module.course.dao.CourseExamDao;
|
||||
import com.xboe.module.course.dao.CourseHRBPAuditDao;
|
||||
import com.xboe.module.course.dao.CourseHomeWorkDao;
|
||||
import com.xboe.module.course.dao.CourseSectionDao;
|
||||
import com.xboe.module.course.dao.CourseTeacherDao;
|
||||
import com.xboe.module.course.dao.CourseUpdateLogDao;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.dto.RankingDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseHRBPAudit;
|
||||
import com.xboe.module.course.entity.CourseSection;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.entity.CourseUpdateLog;
|
||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.interaction.service.ICourseGradeService;
|
||||
@@ -125,7 +117,14 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Resource
|
||||
RestHighLevelClient restHighLevelClient;
|
||||
|
||||
@Resource
|
||||
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
|
||||
|
||||
@Resource
|
||||
private ModifyLogDao modifyLogDao;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 生成过滤条件
|
||||
@@ -183,6 +182,8 @@ public class CourseServiceImpl implements ICourseService {
|
||||
filters.add(FieldFilters.in("device", Course.DEVICE_MOBILE, Course.DEVICE_ALL));
|
||||
} else if (dto.getDevice() == Course.DEVICE_ALL) {
|
||||
filters.add(FieldFilters.eq("device", Course.DEVICE_ALL));
|
||||
} else if (dto.getDevice() == Course.DEVICE_INTERNAL) {
|
||||
filters.add(FieldFilters.eq("device", Course.DEVICE_INTERNAL));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -365,6 +366,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
// // 使用distinct()配合自定义的去重条件
|
||||
// .filter(distinctByKey(c -> c.getId()))
|
||||
// .collect(Collectors.toList());
|
||||
|
||||
/// / PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
/// / long endTime = System.nanoTime();
|
||||
// //log.info("查询出的条数:"+rs.getCount());
|
||||
@@ -460,9 +462,45 @@ public class CourseServiceImpl implements ICourseService {
|
||||
rs.setCount(listByFilters2.size());
|
||||
rs.setPageSize(pageSize);
|
||||
rs.setList(paginate);
|
||||
if (!paginate.isEmpty()) {
|
||||
log.info("-----KJB------ getCourse");
|
||||
for (Course course : paginate) {
|
||||
this.getCourseFromKJB(course);
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
public void getCourseFromKJB(Course course){
|
||||
String courseId = course.getId();
|
||||
log.info("------------KJB---获取课程信息---------: courseId = " + courseId);
|
||||
//String url = env.getProperty("kjb.url") + "/api/course/getCourseFromKJB?courseId=" + courseId;
|
||||
String url = aicoreUrl + "/aiVideo/getCourseList";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray courseIds = new JSONArray();
|
||||
courseIds.add(courseId);
|
||||
jsonObject.put("courseIds", courseIds);
|
||||
String result = HttpUtils.sendMessage(jsonObject.toJSONString(), url);
|
||||
log.info("---KJB --getCourseList 接口返回结果result: "+result);
|
||||
JSONObject jsonResult = JSONObject.parseObject(result);
|
||||
String data = jsonResult.getString("rows");
|
||||
|
||||
List<BoeaiCourseDto> boeaiCourseDto = JSON.parseArray(data, BoeaiCourseDto.class);
|
||||
//List<BoeaiCourseDto> aiVideoResourceRsp = Collections.singletonList(JSON.parseObject(data, BoeaiCourseDto.class));
|
||||
if(boeaiCourseDto != null && !boeaiCourseDto.isEmpty()){
|
||||
log.info("KJB摘要信息:"+boeaiCourseDto.get(0).getSummaryContent());
|
||||
course.setSummaryContent(boeaiCourseDto.get(0).getSummaryContent());
|
||||
course.setSummaryStatus(boeaiCourseDto.get(0).getSummaryStatus());
|
||||
course.setAiSet(boeaiCourseDto.get(0).getAiSet());
|
||||
course.setAiAbstract(boeaiCourseDto.get(0).getAiAbstract());
|
||||
course.setAiDraft(boeaiCourseDto.get(0).getAiDraft());
|
||||
course.setAiTranslate(boeaiCourseDto.get(0).getAiTranslate());
|
||||
course.setLanguageStatus(boeaiCourseDto.get(0).getLanguageStatus());
|
||||
course.setLanguageCode(boeaiCourseDto.get(0).getLanguageCode() == null ? new ArrayList<>() :Arrays.asList(boeaiCourseDto.get(0).getLanguageCode().split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getSeache(CourseQueryDto dto) {
|
||||
//需要设置为隐藏的课程id
|
||||
Set<String> list = new HashSet<>();
|
||||
@@ -918,6 +956,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.save(ct);
|
||||
addBoeCourseTeacherModifyLog(ct, "M1位置讲师名修改", JSONUtil.toJsonStr(ct), null);
|
||||
}
|
||||
}
|
||||
if (full.getCrowds() != null && !full.getCrowds().isEmpty()) {
|
||||
@@ -1000,12 +1039,15 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
full.getCourse().setSysVersion(c.getSysVersion());
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
addBoeCourseTeacherModifyLog(ct, "M2位置讲师名修改", JSONUtil.toJsonStr(ct), null);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1054,12 +1096,15 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
full.getCourse().setSysVersion(c.getSysVersion());
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
addBoeCourseTeacherModifyLog(ct, "M3位置讲师名修改", JSONUtil.toJsonStr(ct), null);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1089,12 +1134,15 @@ public class CourseServiceImpl implements ICourseService {
|
||||
c.setPublishTime(LocalDateTime.now());
|
||||
courseDao.update(c);
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
createCourseTeacherDeletedRecord(c.getId());
|
||||
//先清空教师信息, 教师信息如果不一样了,也要加入到日志中
|
||||
courseTeacherDao.deleteByField("courseId", c.getId());
|
||||
if (full.getTeachers() != null && !full.getTeachers().isEmpty()) {
|
||||
for (CourseTeacher ct : full.getTeachers()) {
|
||||
ct.setCourseId(c.getId());
|
||||
courseTeacherDao.saveOrUpdate(ct);
|
||||
addBoeCourseTeacherModifyLog(ct, "M4位置讲师名修改", JSONUtil.toJsonStr(ct), null);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -2011,4 +2059,41 @@ public class CourseServiceImpl implements ICourseService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除boe_course_teacher数据时把删除的数据储存到boe_course_teacher_deleted_record表
|
||||
* boe_course_teacher表没有deleted字段,兼容处理
|
||||
*
|
||||
* @param courseId 课程ID
|
||||
*/
|
||||
private void createCourseTeacherDeletedRecord(String courseId) {
|
||||
List<CourseTeacherDeletedRecord> courseTeacherList = courseTeacherDao.findList(FieldFilters.eq("courseId", courseId)).stream().map(ct -> {
|
||||
CourseTeacherDeletedRecord courseTeacherDeletedRecord = new CourseTeacherDeletedRecord();
|
||||
courseTeacherDeletedRecord.setCourseId(ct.getCourseId());
|
||||
courseTeacherDeletedRecord.setTeacherId(ct.getTeacherId());
|
||||
courseTeacherDeletedRecord.setTeacherName(ct.getTeacherName());
|
||||
return courseTeacherDeletedRecord;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(courseTeacherList)) {
|
||||
courseTeacherDeletedRecordDao.saveList(courseTeacherList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加boe_course_teacher的teacher_name字段被改为"BOE教师"的监控
|
||||
*/
|
||||
private void addBoeCourseTeacherModifyLog(CourseTeacher ct, String location, String body, String remark) {
|
||||
try {
|
||||
if (ct == null) {
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(ct.getTeacherName(), "BOE教师")) {
|
||||
modifyLogDao.insert(null, location, body, remark);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("创建boe_course_teacher记录失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xboe.module.course.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
public static String sendMessage(String message,String url) {
|
||||
log.info("----------------发送消息开始 -------");
|
||||
//log.info("----------------发送消息url -------{}",url);
|
||||
log.info("----------------发送消息参数 -------{}",message);
|
||||
// POST 请求
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
// POST 请求
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
//HttpPost httpPost = new HttpPost("https://jsonplaceholder.typicode.com/posts");
|
||||
httpPost.setEntity(new StringEntity(message, StandardCharsets.UTF_8));
|
||||
httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
|
||||
HttpEntity responseEntity = response.getEntity();
|
||||
String responseBody = "";
|
||||
if (responseEntity != null) {
|
||||
responseBody = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
|
||||
System.out.println("Response Body: " + responseBody);
|
||||
}
|
||||
log.info("---------------发送消息响应 -------{}",responseBody);
|
||||
return responseBody;
|
||||
// System.out.println("状态码: " + response.getCode());
|
||||
// System.out.println("响应体: " + EntityUtils.toString(response.getEntity()));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("KJB-发送消息错误",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.popup.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import lombok.Data;
|
||||
@@ -24,12 +25,14 @@ public class Popup extends IdEntity {
|
||||
* 开始时间
|
||||
* */
|
||||
@Column(name = "start_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
* */
|
||||
@Column(name = "end_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
|
||||
|
||||
@@ -9,15 +9,25 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
||||
import com.boe.feign.api.infrastructure.entity.Dict;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.module.course.dto.AiVideoResourceRsp;
|
||||
import com.xboe.module.course.dto.BoeaiSubtitleRsp;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.vo.StudyTimeVo;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -100,6 +110,9 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 用于查询课程的学习记录
|
||||
* @param pager
|
||||
@@ -204,6 +217,11 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
List<CourseSection> sectionlist=sectionService.getByCourseId(cid);
|
||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(cid);
|
||||
|
||||
for (CourseContent cc : cclist) {
|
||||
log.info("根据视频信息查询AI字幕数据:cc = " + cc.toString());
|
||||
this.getVtt( cid , cc);
|
||||
}
|
||||
|
||||
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
||||
for(CourseTeacher ct : teachers) {
|
||||
Teacher t = teacherService.get(ct.getTeacherId());
|
||||
@@ -228,10 +246,34 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs.put("isCrowd",pass);
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
rs.put("teachers",teachers);
|
||||
// 未选择仅内网时isPermission = false,不用区分内外网
|
||||
boolean isPermission = false;
|
||||
if(course.getDevice() ==4){
|
||||
CommonSearchVo searcher = new CommonSearchVo();
|
||||
searcher.setPid(637L);
|
||||
searcher.setType(1);
|
||||
List<Dict> dictList = thirdApi.getDictItems(searcher);
|
||||
if(dictList != null && dictList.size() > 0){
|
||||
List<String> dicts = dictList.stream().map(Dict::getValue).collect(Collectors.toList());
|
||||
// 选择仅内网 并且字典中配置了此课程资源归属,那么只能内网观看 返回 truw
|
||||
isPermission = dicts.contains(course.getOrgId());
|
||||
}
|
||||
}
|
||||
rs.put("isPermission",isPermission);
|
||||
|
||||
CommonSearchVo warn = new CommonSearchVo();
|
||||
warn.setCode("course_warn");
|
||||
warn.setType(1);
|
||||
List<Dict> warns = thirdApi.getDictItems(warn);
|
||||
if(warns != null && warns.size() > 0){
|
||||
rs.put("warn",warns.get(0).getValue());
|
||||
rs.put("warnTitle",warns.get(0).getName());
|
||||
}
|
||||
|
||||
//检查是否已报名
|
||||
StudyCourse sc=service.findByCourseIdAndAid(cid, aid);
|
||||
@@ -275,19 +317,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
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);
|
||||
@@ -307,6 +336,35 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
public void getVtt(String couirseId, CourseContent cc){
|
||||
log.info("------KJB --------- getVtt couirseId = " + couirseId + " videoId = " + cc.getId());
|
||||
String url = aicoreUrl + "/aiVideo/getVideoVtt";
|
||||
JSONObject message = new JSONObject();
|
||||
message.put("courseId", couirseId);
|
||||
message.put("videoId", cc.getId());
|
||||
String result = HttpUtils.sendMessage(message.toJSONString(), url);
|
||||
if(StringUtils.isBlank(result)){
|
||||
log.error("未获取到AI字幕信息");
|
||||
return;
|
||||
}
|
||||
//将返回string 转为json对象
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String data = jsonObject.getString("data");
|
||||
//json字符串转为实体对象
|
||||
AiVideoResourceRsp aiVideoResourceRsp = JSON.parseObject(data, AiVideoResourceRsp.class);
|
||||
log.info("aiVideoResourceRsp:"+aiVideoResourceRsp);
|
||||
//循环json对象
|
||||
if(aiVideoResourceRsp != null){
|
||||
cc.setBoeaiSubtitleRspList(aiVideoResourceRsp.getBoeaiSubtitleRspList());
|
||||
// for (int i = 0; i < rows.size(); i++) {
|
||||
// JSONObject row = rows.getJSONObject(i);
|
||||
// //将json对象转为实体对象 CourseContentVtt
|
||||
// BoeaiSubtitleRsp vtt = row.toJavaObject(BoeaiSubtitleRsp.class);
|
||||
// boeaiSubtitleRspList.add(vtt);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在打开课程详细页面的时候,调用此接口,返回学习课程信息,上次学习的位置。<br/>
|
||||
* 如果没有就返回空<br>
|
||||
@@ -579,8 +637,8 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
try {
|
||||
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||
log.info("在线课学习记录"+allUserList);
|
||||
// List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||
// log.info("在线课学习记录"+allUserList);
|
||||
return success(true);
|
||||
}catch(Exception e) {
|
||||
log.error("记录内容学习完成错误",e);
|
||||
@@ -656,6 +714,90 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* appendtime 于 study-video-time 合并
|
||||
* */
|
||||
/*@RequestMapping(value="/updateStudyVideoTime1",method = {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<String> updateStudyVideoTime1(StudyTimeVo studyTime, HttpServletRequest request){
|
||||
|
||||
// 0 study-video-time , 1 appendtime
|
||||
if (studyTime.getType() == 0){
|
||||
if(StringUtils.isBlank(studyTime.getItemId())){
|
||||
return error("参数错误");
|
||||
}
|
||||
if(studyTime.getVideoTime()==null){
|
||||
return error("无时间点");
|
||||
}
|
||||
//检查是否已存在
|
||||
try {
|
||||
studyService.updateLastTime(studyTime.getItemId(),studyTime.getVideoTime(), getCurrent().getAccountId());
|
||||
if (studyTime.getContentId() != null && studyTime.getCourseId() != null && studyTime.getProgressVideo() != null){
|
||||
contentService.updateProcessVideo(studyTime.getContentId(), studyTime.getCourseId(), studyTime.getProgressVideo());
|
||||
}
|
||||
return success("true");
|
||||
}catch(Exception e) {
|
||||
log.error("updateStudyVideoTime type =0 记录最后学习时间错误",e);
|
||||
return error("updateStudyVideoTime type =0 记录最后学习时间失败 ",e.getMessage());
|
||||
}
|
||||
}else if(studyTime.getType() == 1){
|
||||
if(StringUtils.isBlank(studyTime.getStudyId())){
|
||||
return error("参数错误");
|
||||
}
|
||||
if(StringUtils.isBlank(studyTime.getCourseId())){
|
||||
return error("未指定课程");
|
||||
}
|
||||
if(StringUtils.isBlank(studyTime.getContentId())){
|
||||
return error("未指定资源内容");
|
||||
}
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
try {
|
||||
studyService.updateStudyDuration(studyTime.getStudyId(),null,studyTime.getContentId(),studyTime.getVideoTime(),studyTime.getCourseId());
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyTime.getStudyId() ,studyTime.getCourseId(), token);
|
||||
log.info("updateStudyVideoTime type =1 在线课学习记录 = " + allUserList);
|
||||
return success(studyTime.getId());
|
||||
}catch(Exception e) {
|
||||
log.error("updateStudyVideoTime type =1 记录学习时长错误",e);
|
||||
return error("updateStudyVideoTime type =1 记录学习时长错误 ",e.getMessage());
|
||||
}
|
||||
}else{
|
||||
return error("type不能为空");
|
||||
}
|
||||
}*/
|
||||
|
||||
@RequestMapping(value="/updateStudyVideoTime",method = {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<String> updateStudyVideoTime(StudyTimeVo studyTime, HttpServletRequest request){
|
||||
try {
|
||||
if(StringUtils.isBlank(studyTime.getItemId())){
|
||||
return error("参数错误");
|
||||
}
|
||||
if(studyTime.getVideoTime()==null){
|
||||
return error("无时间点");
|
||||
}
|
||||
if(StringUtils.isBlank(studyTime.getStudyId())){
|
||||
return error("参数错误");
|
||||
}
|
||||
if(StringUtils.isBlank(studyTime.getCourseId())){
|
||||
return error("未指定课程");
|
||||
}
|
||||
if(StringUtils.isBlank(studyTime.getContentId())){
|
||||
return error("未指定资源内容");
|
||||
}
|
||||
studyService.updateStudyDuration(studyTime.getStudyId(),studyTime.getItemId(),studyTime.getContentId(),studyTime.getVideoTime(),studyTime.getCourseId());
|
||||
if (studyTime.getContentId() != null && studyTime.getCourseId() != null && studyTime.getProgressVideo() != null){
|
||||
contentService.updateProcessVideo(studyTime.getContentId(), studyTime.getCourseId(), studyTime.getProgressVideo());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("updateStudyVideoTime",e);
|
||||
return error("学习时长记录失败",e.getMessage(),null);
|
||||
}
|
||||
return success("true");
|
||||
}
|
||||
|
||||
/**获取最后一次的学习内容*/
|
||||
@GetMapping("/last-study")
|
||||
public JsonResponse<Map<String,Object>> lastStudy(){
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.xboe.school.study.api;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.service.IStudyService;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -10,10 +12,13 @@ import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* @author by lyc
|
||||
@@ -26,13 +31,15 @@ public class StudyCourseTask {
|
||||
|
||||
private final IStudyService studyService;
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
* 获取redis 中学习结束的数据更新入库
|
||||
* */
|
||||
@XxlJob("saveStudyCourseItemLastTime")
|
||||
public void saveStudyCourseItemLastTime() {
|
||||
@XxlJob("saveStudyCourseItemLastTime2")
|
||||
public void saveStudyCourseItemLastTime2() {
|
||||
// 1. 定义匹配模式(匹配所有目标key)
|
||||
final String KEY_PATTERN = "studyContentId:*:last_active";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
@@ -59,7 +66,6 @@ public class StudyCourseTask {
|
||||
String[] parts = redisKey.split(":");
|
||||
if (parts.length < 2) continue;
|
||||
String studyContentId = parts[1];
|
||||
|
||||
// 7. 获取存储的时间点(示例逻辑)
|
||||
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
||||
if (redisValue == null) continue;
|
||||
@@ -69,19 +75,15 @@ public class StudyCourseTask {
|
||||
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) {
|
||||
@@ -102,5 +104,159 @@ public class StudyCourseTask {
|
||||
}
|
||||
|
||||
|
||||
@XxlJob("saveStudyCourseItemLastTime")
|
||||
public void saveStudyCourseItemLastTime() {
|
||||
// 1. 定义匹配模式(匹配所有目标key)
|
||||
final String KEY_PATTERN = "studyId:*:courseId:*:courseContentId:*:studyItemId:*";
|
||||
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());
|
||||
log.info("-定时任务 saveStudyCourseItemLastTime ---redisKey = " + redisKey);
|
||||
// 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 < 7) continue;
|
||||
String studyId = parts[1];
|
||||
String courseId = parts[3];
|
||||
String courseContentId = parts[5];
|
||||
String studyItemId = parts[7];
|
||||
// 7. 获取存储的时间点(示例逻辑)
|
||||
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
||||
log.info("-定时任务 saveStudyCourseItemLastTime ---redisValue = " + redisValue);
|
||||
if (redisValue == null) continue;
|
||||
String[] partValues = redisValue.split("&");
|
||||
int studyVideoTtime = Integer.parseInt(partValues[0]);
|
||||
int appendtime = Integer.parseInt(partValues[1]);
|
||||
LocalDateTime timestamp = null;
|
||||
if (partValues.length >= 2){
|
||||
timestamp = LocalDateTime.parse(partValues[2], formatter);
|
||||
}
|
||||
// 8. 更新数据库(调用已有服务方法)
|
||||
studyService.newAppendStudyDuration(studyId,null,courseContentId,appendtime,timestamp);
|
||||
log.info("-定时任务 saveStudyCourseItemLastTime ---studyItemId = " + studyItemId);
|
||||
if (studyItemId != null && !studyItemId.equals("null")){
|
||||
log.info("-定时任务 saveStudyCourseItemLastTime --- boolean studyItemId = " + (studyItemId != null));
|
||||
// 8. 更新数据库(调用已有服务方法)
|
||||
studyService.updateStudyCourseItemLastTime(studyItemId, studyVideoTtime, timestamp);
|
||||
}
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId , courseId, null);
|
||||
log.info("处理成功 allUserList: {}", allUserList);
|
||||
// 9. 删除Redis键(原子操作)
|
||||
redisTemplate.delete(redisKey);
|
||||
log.info("处理成功 key: {}, lastStudyTime: {}", redisKey, appendtime);
|
||||
} catch (Exception e) {
|
||||
log.error("处理失败 key: {}", redisKey, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
} catch (Exception e) {
|
||||
log.error("定时任务执行异常", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@XxlJob("saveStudyCourseItemLastTime1")
|
||||
public void saveStudyCourseItemLastTime1() {
|
||||
// 定义需要处理的键模式集合
|
||||
processKeys("studyContentId:*:last_active", this::handleLastActiveKey);
|
||||
processKeys("studyId:*:courseId:*:courseContentId:*", this::handleDurationKey);
|
||||
}
|
||||
|
||||
private void processKeys(String keyPattern, BiConsumer<String, String> keyHandler) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
ScanOptions options = ScanOptions.scanOptions()
|
||||
.match(keyPattern)
|
||||
.count(100)
|
||||
.build();
|
||||
|
||||
try (RedisConnection connection = Objects.requireNonNull(redisTemplate.getConnectionFactory()).getConnection()) {
|
||||
Cursor<byte[]> cursor = connection.scan(options);
|
||||
while (cursor.hasNext()) {
|
||||
String redisKey = new String(cursor.next());
|
||||
Long ttl = redisTemplate.getExpire(redisKey, TimeUnit.SECONDS);
|
||||
|
||||
if (ttl != null && ttl <= 2590200) {
|
||||
try {
|
||||
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
||||
if (redisValue != null) {
|
||||
// 调用对应的处理方法
|
||||
keyHandler.accept(redisKey, redisValue);
|
||||
}
|
||||
redisTemplate.delete(redisKey);
|
||||
log.info("Key processed: {}", redisKey);
|
||||
} catch (Exception e) {
|
||||
log.error("Process failed [{}]", redisKey, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
} catch (Exception e) {
|
||||
log.error("Key processing error: {}", keyPattern, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理 last_active 类型键
|
||||
private void handleLastActiveKey(String redisKey, String redisValue) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
String[] parts = redisKey.split(":");
|
||||
String studyContentId = parts[1];
|
||||
|
||||
String[] values = redisValue.split("&");
|
||||
int lastStudyTime = Integer.parseInt(values[0]);
|
||||
LocalDateTime timestamp = values.length >= 2 ?
|
||||
LocalDateTime.parse(values[1], formatter) : null;
|
||||
|
||||
studyService.updateStudyCourseItemLastTime(studyContentId, lastStudyTime, timestamp);
|
||||
}
|
||||
|
||||
// 处理 duration 类型键
|
||||
private void handleDurationKey(String redisKey, String redisValue) {
|
||||
String[] parts = redisKey.split(":");
|
||||
String studyId = parts[1];
|
||||
String courseId = parts[3];
|
||||
String courseContentId = parts[5];
|
||||
|
||||
String[] values = redisValue.split("&");
|
||||
int duration = Integer.parseInt(values[0]);
|
||||
LocalDateTime timestamp = values.length >= 2 ?
|
||||
LocalDateTime.parse(values[1], DateTimeFormatter.ISO_LOCAL_DATE_TIME) : null;
|
||||
|
||||
studyService.newAppendStudyDuration(studyId, null, courseContentId, duration, timestamp);
|
||||
|
||||
// 保留第三方调用
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId, courseId, null);
|
||||
log.info("Study records synced: {}", allUserList.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -101,4 +101,8 @@ public interface IStudyService {
|
||||
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||
|
||||
void updateStudyCourseItemLastTime(String studyContentId, int lastStudyTime, LocalDateTime timestamp);
|
||||
|
||||
void updateStudyDuration(String studyId,String studyItemId, String contentId, Integer videoTime,String courseId);
|
||||
|
||||
void newAppendStudyDuration(String studyId, String studyItemId, String courseContentId, int duration, LocalDateTime timestamp);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.xboe.module.course.entity.CourseExam;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.dao.StudyCourseItemDao;
|
||||
import com.xboe.school.study.dao.StudyExamDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.entity.StudyExam;
|
||||
import com.xboe.school.study.service.IStudyExamService;
|
||||
@@ -170,15 +171,32 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
}
|
||||
builder.addGroupBy("studyId");
|
||||
List<StudyExam> list1 = dao.findList(builder.builder());
|
||||
log.info("------------QueryBuilder list1.size = " + list1.size() + ",0 = " + list1.get(0));
|
||||
|
||||
if(list1 != null && list1.size() > 0){
|
||||
log.info("----------StudyExam--QueryBuilder list1.size = " + list1.size() + ",0 = " + list1.get(0));
|
||||
for(StudyExam item : list1){
|
||||
log.info("-----------------CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||
log.info("--------------StudyExam---CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||
log.info("----------准备判断进度-------totalContent = " + totalContent);
|
||||
log.info("--------StudyExam--准备判断进度-------totalContent = " + totalContent);
|
||||
scDao.finishCheck1(item.getStudyId(),item.getCourseId(),totalContent);
|
||||
log.info("----------判断进度完毕----------------------");
|
||||
log.info("--------StudyExam--判断进度完毕----------------------");
|
||||
}
|
||||
}else{
|
||||
QueryBuilder builder1 = QueryBuilder.from(StudyCourse.class);
|
||||
if (StringUtils.isEmpty(courseId)){
|
||||
return;
|
||||
}
|
||||
builder1.addFilter(FieldFilters.eq("courseId", courseId));
|
||||
List<StudyCourse> list2 = scDao.findList(builder1.builder());
|
||||
log.info("------------StudyCourse list2.size = " + list2.size() + ",0 = " + list2.get(0));
|
||||
for(StudyCourse item : list2){
|
||||
log.info("-------------StudyCourse----CourseId = " + item.getCourseId() + " , StudyId = " + item.getId() + " , StudentId = " + item.getAid());
|
||||
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||
log.info("--------StudyCourse--准备判断进度-------totalContent = " + totalContent);
|
||||
scDao.finishCheck1(item.getId(),item.getCourseId(),totalContent);
|
||||
log.info("--------StudyCourse--判断进度完毕----------------------");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
log.info("------异常----------------------:" +exception.getMessage());
|
||||
|
||||
@@ -116,34 +116,74 @@ public class StudyServiceImpl implements IStudyService{
|
||||
//增加内容的学习时长
|
||||
if(StringUtils.isNotBlank(studyItemId)) {
|
||||
//直接根据id更新
|
||||
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||
// scItemDao.update(hql,studyItemId);
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||
scItemDao.sqlUpdate(sql,studyItemId);
|
||||
//scItemDao.updateMultiFieldById(studyItemId, UpdateBuilder.create("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
|
||||
}else {
|
||||
//根据学习id和课程内容id更新
|
||||
// scItemDao.update(UpdateBuilder.from(StudyCourseItem.class)
|
||||
// .addUpdateField("studyDuration", "studyDuration+"+duration,FieldUpdateType.EXPRESSION)
|
||||
// .addFilter(FieldFilters.eq("studyId", studyId))
|
||||
// .addFilter(FieldFilters.eq("contentId", courseContentId))
|
||||
// .builder());
|
||||
//
|
||||
// String hql="Update StudyCourseItem set studyDuration=studyDuration+"+duration+",status=(case when status<2 then 2 else status end) where studyId=?1 and contentId=?2";
|
||||
// scItemDao.update(hql,studyId,courseContentId);
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where study_id=?1 and content_id=?2";
|
||||
scItemDao.sqlUpdate(sql,studyId,courseContentId);
|
||||
}
|
||||
|
||||
//追加课程的学习时长
|
||||
//scDao.updateMultiFieldById(studyId, UpdateBuilder.create("totalDuration", "totalDuration+"+duration,FieldUpdateType.EXPRESSION));
|
||||
|
||||
String sql="Update boe_study_course set total_duration=total_duration+"+duration+",status=(case when status<2 then 2 else status end),progress=(case when progress=0 then 1 else progress end),last_time = '"+LocalDateTime.now()+"' where id=?1";
|
||||
scDao.sqlUpdate(sql,studyId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void newAppendStudyDuration(String studyId,String studyItemId,String courseContentId, int duration,LocalDateTime timestamp) {
|
||||
|
||||
//增加内容的学习时长
|
||||
if(StringUtils.isNotBlank(studyItemId)) {
|
||||
//直接根据id更新
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where id=?1";
|
||||
scItemDao.sqlUpdate(sql,studyItemId);
|
||||
|
||||
}else {
|
||||
String sql="Update boe_study_course_item set study_duration=study_duration+"+duration+",status=(case when status<2 then 2 else status end) where study_id=?1 and content_id=?2";
|
||||
scItemDao.sqlUpdate(sql,studyId,courseContentId);
|
||||
}
|
||||
|
||||
String sql="Update boe_study_course set total_duration=total_duration+"+duration+",status=(case when status<2 then 2 else status end),progress=(case when progress=0 then 1 else progress end),last_time = '"+timestamp+"' where id=?1";
|
||||
scDao.sqlUpdate(sql,studyId);
|
||||
}
|
||||
|
||||
// 更新 前端传输已学习时长
|
||||
@Override
|
||||
public void updateStudyDuration(String studyId,String studyItemId,String courseContentId, Integer videoTime,String courseId) {
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
|
||||
String key = "studyId:" + studyId + ":courseId:" + courseId + ":courseContentId:" + courseContentId + ":studyItemId:" + studyItemId;
|
||||
String currentValue = redisTemplate.opsForValue().get(key);
|
||||
Integer lastDuration = 0;
|
||||
Integer oldVideoTime = 0;
|
||||
Integer sum = 10; // 原appendtime改为固定10秒调用一次接口
|
||||
if (currentValue != null) {
|
||||
String[] partValues = currentValue.split("&");
|
||||
oldVideoTime = Integer.parseInt(partValues[0]);
|
||||
lastDuration = Integer.parseInt(partValues[1]);
|
||||
sum += lastDuration;
|
||||
if(oldVideoTime > videoTime){
|
||||
videoTime = oldVideoTime;// 取最大值最终入库
|
||||
}
|
||||
};
|
||||
|
||||
String value = videoTime + "&" + sum + "&" + now.format(formatter); // study_video_time & appendtime & time
|
||||
log.info("-study-video-time-----value = " + value);
|
||||
|
||||
// 20250303 优化 多次更新改一次更新
|
||||
// 更新Redis中的最后活跃时间(带30秒过期)
|
||||
redisTemplate.opsForValue().set(
|
||||
key,
|
||||
value,
|
||||
Duration.ofSeconds(2592000)
|
||||
);
|
||||
log.info("- 合并 updateStudyDuration -redis保存---value = " + value);
|
||||
// Duration.ofDays(30) 也就是 2592000秒
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void appendStudyDuration(StudyTime st) {
|
||||
@@ -166,7 +206,21 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
@Override
|
||||
public List<StudyCourseItem> findByStudyId(String studyId) {
|
||||
return scItemDao.findList(OrderCondition.desc("lastTime"),FieldFilters.eq("studyId", studyId));
|
||||
List<StudyCourseItem> list = scItemDao.findList(OrderCondition.desc("lastTime"),FieldFilters.eq("studyId", studyId));
|
||||
for (StudyCourseItem item : list){
|
||||
log.info("-- studyIndex -查询上次学习的是什么资源。mysql查询---------------- item = " + item);
|
||||
String redisKey = "studyId:" + studyId + ":courseId:" + item.getCourseId() + ":courseContentId:" + item.getContentId() + ":studyItemId:" + item.getId();
|
||||
log.info("-- studyIndex -查询上次学习的是什么资源。查询用户的学习情况---------------- redisKey = " + redisKey);
|
||||
String redisValue = redisTemplate.opsForValue().get(redisKey);
|
||||
log.info("-- studyIndex -查询上次学习的是什么资源。查询用户的学习情况---------------- redisValue = " + redisValue);
|
||||
if (redisValue != null) {
|
||||
String[] values = redisValue.split("&");
|
||||
int duration = Integer.parseInt(values[0]);
|
||||
item.setLastStudyTime(duration);
|
||||
log.info("-- studyIndex -----set 结果---------------- LastStudyTime = " + item.getLastStudyTime());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,11 +282,12 @@ public class StudyServiceImpl implements IStudyService{
|
||||
return pageList;
|
||||
}
|
||||
}
|
||||
|
||||
String sql = "select a.id, a.course_id, a.course_name, a.aname, " +
|
||||
"IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
|
||||
"IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status,b.score " +
|
||||
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "' and aname like '%"+name+"%') a " +
|
||||
"left join " +
|
||||
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
|
||||
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status,MAX(item.score) score " +
|
||||
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
"where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' and item.aname like '%"+name+"%' group by bsc.id) b " +
|
||||
"on a.course_id = b.course_id and a.id = b.id " +
|
||||
@@ -261,6 +316,9 @@ public class StudyServiceImpl implements IStudyService{
|
||||
sc.setProgress(Integer.valueOf(objs[5].toString()));
|
||||
sc.setStatus(Integer.valueOf(objs[6].toString()));
|
||||
sc.setAname(objs[3].toString());
|
||||
if(objs[7] != null){
|
||||
sc.setScore(Float.valueOf(objs[7].toString()));
|
||||
}
|
||||
item.add(sc);
|
||||
}
|
||||
log.info("资源完成情况人员"+item);
|
||||
@@ -357,6 +415,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
log.info("-study-video-time-mysql保存---studyContentId = " + studyContentId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getLast(String aid) {
|
||||
//按lastTime排序,第一条,只是课件内容
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xboe.school.vo;
|
||||
|
||||
import com.xboe.school.study.entity.StudyTime;
|
||||
import lombok.Data;
|
||||
|
||||
/** appendtime 于 study-video-time 合并
|
||||
* appendtime 参数 StudyTime
|
||||
* study-video-time 参数 是 StudyTimeVo
|
||||
*/
|
||||
@Data
|
||||
public class StudyTimeVo extends StudyTime {
|
||||
|
||||
private String itemId;
|
||||
private Integer videoTime;
|
||||
// private String contentId; // 已继承
|
||||
// private String courseId; // 已继承
|
||||
private Float progressVideo;
|
||||
private Integer type; // 0 study-video-time , 1 appendtime
|
||||
}
|
||||
@@ -119,6 +119,9 @@ jasypt:
|
||||
boe:
|
||||
domain: http://10.251.186.27
|
||||
|
||||
kjb:
|
||||
aicoreUrl: http://10.251.186.27:8088
|
||||
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
|
||||
@@ -74,3 +74,4 @@ coursesuilt:
|
||||
syncCourseStudent: ${boe.domain}/manageApi/admin/teacherRecord/syncCourseStudent
|
||||
syncOnLineScore: ${boe.domain}/manageApi/admin/teacherRecord/syncOnLineScore
|
||||
updateOnLineStatua: ${boe.domain}/manageApi/admin/teacherRecord/updateOnLineStatua
|
||||
delOnLineById: ${boe.domain}/manageApi/admin/teacherRecord/delOnLineById
|
||||
Reference in New Issue
Block a user