Compare commits

...

21 Commits

Author SHA1 Message Date
huangrun
80b444c188 kjb接口添加配置 2025-11-21 14:27:21 +08:00
huangrun
b0a0725373 管理端端添加课程AI设置信息 2025-11-21 11:27:43 +08:00
huangrun
59e42cda4f 管理端端添加课程AI设置信息 2025-11-21 10:34:49 +08:00
huangrun
ec6d9100c2 学员端添加课程摘要信息 2025-11-20 16:04:46 +08:00
huangrun
562a4cc862 学员端添加课程摘要信息 2025-11-20 15:13:02 +08:00
huangrun
ae11017d67 学员端添加课程摘要信息 2025-11-20 14:43:11 +08:00
huangrun
fd473445de 学员端添加课程摘要信息 2025-11-20 14:38:56 +08:00
huangrun
bfdbd4d38e 学员端添加课程摘要信息 2025-11-20 14:36:45 +08:00
huangrun
640786391d 学员端添加课程摘要信息 2025-11-20 13:51:02 +08:00
huangrun
71b00372f6 参数添加字段 2025-11-19 20:07:00 +08:00
huangrun
2e4b04d1d1 AI字幕数据查询 2025-11-19 19:33:21 +08:00
huangrun
bffb85848f AI字幕数据查询 2025-11-19 18:07:46 +08:00
huangrun
a9e34e42b9 AI字幕数据查询 2025-11-19 17:49:38 +08:00
huangrun
84bd63ec0e AI字幕数据查询 2025-11-19 17:07:58 +08:00
huangrun
1aba83a1b8 参数添加字段 2025-11-19 15:28:06 +08:00
huangrun
2b1211c83d 参数添加字段 2025-11-19 14:34:30 +08:00
huangrun
fe3e8df37c 请求头指定编码 2025-11-19 12:43:52 +08:00
huangrun
8d9b360654 修改远程接口地址 2025-11-19 11:38:35 +08:00
huangrun
3379acdd1e 实体字段添加非表字段注解 2025-11-19 10:41:36 +08:00
huangrun
9a3b394e03 添加接口日志打印 2025-11-19 09:57:37 +08:00
huangrun
7beb046d6d 添加接口调用 2025-11-18 19:20:38 +08:00
14 changed files with 689 additions and 15 deletions

View File

@@ -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>

View File

@@ -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;
/**
* 教师需要审核的课程
@@ -435,16 +445,79 @@ 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);
e.printStackTrace();
return error("发布课程失败",e.getMessage());
}
}
}
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);
}
/***
* 审核
* @param dto
@@ -475,5 +548,4 @@ public class CourseAuditApi extends ApiBaseController{
}
}

View File

@@ -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<>();

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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字幕文件URLOSS地址
*/
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;
}

View File

@@ -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;
}

View File

@@ -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;
@@ -216,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审核完成

View File

@@ -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;
/**
* 课程内容表
* */
@@ -93,6 +96,9 @@ public class CourseContent extends BaseEntity {
/**用于学习时的状态显示,非存储字段*/
@Transient
private Integer status;
@Transient
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
public CourseContent() {

View File

@@ -18,10 +18,15 @@ 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;
@@ -32,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;
@@ -45,9 +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.dto.CourseFullDto;
import com.xboe.module.course.dto.CourseQueryDto;
import com.xboe.module.course.dto.RankingDto;
import com.xboe.module.course.service.ICourseFullTextSearch;
import com.xboe.module.course.service.ICourseService;
import com.xboe.module.interaction.service.ICourseGradeService;
@@ -120,6 +123,9 @@ public class CourseServiceImpl implements ICourseService {
@Resource
private ModifyLogDao modifyLogDao;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
/**
* 生成过滤条件
*
@@ -456,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<>();

View File

@@ -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);
}
}
}

View File

@@ -9,11 +9,17 @@ 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;
@@ -21,6 +27,7 @@ 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;
@@ -103,6 +110,9 @@ public class StudyCourseApi extends ApiBaseController{
@Autowired
StringRedisTemplate redisTemplate;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
/**
* 用于查询课程的学习记录
* @param pager
@@ -206,6 +216,11 @@ public class StudyCourseApi extends ApiBaseController{
List<CourseContent> cclist=contentService.getByCourseId(cid);
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) {
@@ -231,6 +246,7 @@ public class StudyCourseApi extends ApiBaseController{
}
}
rs.put("isCrowd",pass);
rs.put("contents",cclist);
rs.put("sections",sectionlist);
@@ -320,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>

View File

@@ -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