mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 02:16:49 +08:00
Compare commits
2 Commits
player-202
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ff8703576 | ||
|
|
d5b774a9ad |
@@ -239,10 +239,6 @@
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.3.0</version> <!-- 请根据实际需求选择版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xboe.module.course.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -8,22 +7,9 @@ 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.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.module.course.dto.CourseParam;
|
||||
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;
|
||||
@@ -35,6 +21,13 @@ 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;
|
||||
@@ -68,9 +61,6 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 教师需要审核的课程
|
||||
@@ -368,10 +358,8 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
//修改在线课开课状态=已开课
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
CourseParam param = new CourseParam();
|
||||
param.setId(c.getId());
|
||||
param.setOrgId(c.getOrgId());
|
||||
param.setOrgName(c.getOrgName());
|
||||
thirdApi.updateOrSaveCourse(param,token);
|
||||
param.setId(courseId);
|
||||
thirdApi.updateOnLineStatua(param,token);
|
||||
}
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
@@ -445,79 +433,16 @@ 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
|
||||
@@ -548,4 +473,5 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ 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;
|
||||
@@ -48,6 +46,8 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ public class CourseFileApi extends ApiBaseController {
|
||||
}
|
||||
String fileFullPath = SysConstant.getConfigValue(BaseConstant.CONFIG_UPLOAD_FILES_SAVEPATH) + file.getFilePath();
|
||||
if ("mp3,mp4".indexOf(file.getFileType()) > -1){
|
||||
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
|
||||
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
|
||||
Encoder encoder = new Encoder();
|
||||
try {
|
||||
//System.out.println(fileFullPath);
|
||||
@@ -278,8 +278,8 @@ public class CourseFileApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("读取视频时长错误", e);
|
||||
return error("视频解析失败,尝试重新上传或联系管理员", "视频解析失败,尝试重新上传或联系管理员");
|
||||
log.error("读取视频时长错误");
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,23 +7,17 @@ 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;
|
||||
@@ -82,9 +76,6 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 课程的初始化
|
||||
* @return
|
||||
@@ -331,8 +322,6 @@ 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()) {
|
||||
@@ -424,33 +413,6 @@ 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<>();
|
||||
|
||||
@@ -147,6 +147,22 @@ public class CourseManageApi extends ApiBaseController{
|
||||
dto.setOrgIds(ids);
|
||||
dto.setReadIds(userOrgIds.getReadIds());
|
||||
PageList<Course> coursePageList = courseService.findPage(pager.getPageIndex(), pager.getPageSize(),dto);
|
||||
// 补充审核人和审核时间(取最近一条审核记录)- 批量查询优化
|
||||
if (coursePageList != null && coursePageList.getList() != null && !coursePageList.getList().isEmpty()) {
|
||||
List<String> courseIds = coursePageList.getList().stream().map(Course::getId).collect(Collectors.toList());
|
||||
Map<String, CourseHRBPAudit> latestAuditMap = hrbpAuditService.findLatestByCourseIds(courseIds);
|
||||
for (Course c : coursePageList.getList()) {
|
||||
try {
|
||||
CourseHRBPAudit latest = latestAuditMap.get(c.getId());
|
||||
if (latest != null) {
|
||||
c.setAuditUser(latest.getAuditUser());
|
||||
c.setAuditTime(latest.getAuditTime());
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// ignore single course enrich error
|
||||
}
|
||||
}
|
||||
}
|
||||
return success(coursePageList);
|
||||
}catch(Exception e) {
|
||||
log.error("管理课程列表查询错误",e);
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
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> {
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
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,7 +1,6 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -217,47 +216,6 @@ 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审核完成
|
||||
@@ -442,6 +400,15 @@ public class Course extends BaseEntity {
|
||||
@Transient
|
||||
private String teacher;
|
||||
|
||||
/**审核人名称(列表展示用)*/
|
||||
@Transient
|
||||
private String auditUser;
|
||||
|
||||
/**审核时间(列表展示用)*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Transient
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){
|
||||
super.setId(id);
|
||||
this.name=name;
|
||||
|
||||
@@ -8,12 +8,9 @@ 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;
|
||||
|
||||
/**
|
||||
* 课程内容表
|
||||
* */
|
||||
@@ -96,9 +93,6 @@ public class CourseContent extends BaseEntity {
|
||||
/**用于学习时的状态显示,非存储字段*/
|
||||
@Transient
|
||||
private Integer status;
|
||||
|
||||
@Transient
|
||||
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
|
||||
|
||||
public CourseContent() {
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.xboe.module.course.service;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.course.dto.CourseHRBPAuditDto;
|
||||
@@ -56,5 +57,10 @@ public interface ICourseHRBPAuditService {
|
||||
*/
|
||||
PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize,int userType, CourseHRBPAudit info);
|
||||
|
||||
/**
|
||||
* 查询一组课程的最近一次审核记录,返回键为courseId的映射。
|
||||
*/
|
||||
Map<String, CourseHRBPAudit> findLatestByCourseIds(List<String> courseIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.xboe.module.course.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -263,4 +265,27 @@ public class CourseHRBPAuditServiceImpl implements ICourseHRBPAuditService {
|
||||
return courseHRBPAuditDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, CourseHRBPAudit> findLatestByCourseIds(List<String> courseIds) {
|
||||
Map<String, CourseHRBPAudit> result = new HashMap<String, CourseHRBPAudit>();
|
||||
if (courseIds == null || courseIds.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
// 按 addTime 倒序,使首次出现的courseId即为该课程的最近一条审核记录
|
||||
List<CourseHRBPAudit> audits = courseHRBPAuditDao.findList(
|
||||
OrderCondition.desc("addTime"),
|
||||
FieldFilters.in("courseId", courseIds)
|
||||
);
|
||||
for (CourseHRBPAudit a : audits) {
|
||||
if (!result.containsKey(a.getCourseId())) {
|
||||
result.put(a.getCourseId(), a);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("批量查询课程审核记录错误", e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,18 +15,9 @@ 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;
|
||||
@@ -37,7 +28,6 @@ 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;
|
||||
@@ -51,6 +41,24 @@ 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;
|
||||
@@ -117,15 +125,8 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Resource
|
||||
RestHighLevelClient restHighLevelClient;
|
||||
|
||||
@Resource
|
||||
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
|
||||
|
||||
@Resource
|
||||
private ModifyLogDao modifyLogDao;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 生成过滤条件
|
||||
*
|
||||
@@ -182,7 +183,7 @@ 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) {
|
||||
}else if (dto.getDevice() == Course.DEVICE_INTERNAL) {
|
||||
filters.add(FieldFilters.eq("device", Course.DEVICE_INTERNAL));
|
||||
}
|
||||
|
||||
@@ -280,13 +281,13 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//// Set<String>list=new HashSet<>();
|
||||
//// if(s!=null&&!s.isEmpty()){
|
||||
//// list=Arrays.stream(s.split(",")).collect(Collectors.toSet());
|
||||
//// }else {
|
||||
//// }else {
|
||||
//// Set<String> ss = getSeache(dto);
|
||||
//// String courseSearch=String.join(",",ss);
|
||||
//// redisTemplate.opsForValue().set("course_search",courseSearch);
|
||||
//// //设置过期时间为1分钟
|
||||
//// redisTemplate.expire("course_search", 1, TimeUnit.MINUTES);
|
||||
//// }
|
||||
//// }
|
||||
// Set<String> list = getSeache(dto);
|
||||
// //有权限的查询,也同时查询出创建人的数据,在权限上
|
||||
// if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
@@ -366,9 +367,8 @@ 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();
|
||||
//// PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
//// long endTime = System.nanoTime();
|
||||
// //log.info("查询出的条数:"+rs.getCount());
|
||||
// if(!mergedList.isEmpty()){
|
||||
// //去掉未发布的课程
|
||||
@@ -425,30 +425,30 @@ public class CourseServiceImpl implements ICourseService {
|
||||
if (TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
if (dto.getIsSystemAdmin() == null || !dto.getIsSystemAdmin()) {
|
||||
List<String> finalStrings = strings;
|
||||
log.info("dto为" + dto);
|
||||
if (dto.getIsCreateCourse() != null && dto.getIsCreateCourse()) {
|
||||
log.info("dto为"+dto);
|
||||
if(dto.getIsCreateCourse()!=null&&dto.getIsCreateCourse()){
|
||||
listByFilters2.removeIf(e -> {
|
||||
//去掉未发布的课程
|
||||
if (!e.getPublished() && seache.contains(e.getId()) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
return true;
|
||||
}
|
||||
//去掉所有条件都不符合的课程
|
||||
if (!seache.contains(e.getId()) && !dto.getReadIds().contains(e.getId()) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
if(!seache.contains(e.getId())&&!dto.getReadIds().contains(e.getId())&& !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//将需要隐藏的做标记
|
||||
listByFilters2.forEach(e -> {
|
||||
if ((seache.contains(e.getId()) || dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
if ((seache.contains(e.getId())||dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
|
||||
e.setIsPermission(false);
|
||||
} else {
|
||||
e.setIsPermission(true);
|
||||
}
|
||||
});
|
||||
listByFilters2.sort(Comparator.comparing(Course::getIsPermission).reversed());
|
||||
} else {
|
||||
List<Course> collect = listByFilters2.stream().filter(e -> dto.getReadIds().contains(e.getOrgId()) || dto.getOrgAid().equals(e.getSysCreateAid()) || finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
|
||||
}else{
|
||||
List<Course> collect = listByFilters2.stream().filter(e ->dto.getReadIds().contains(e.getOrgId())||dto.getOrgAid().equals(e.getSysCreateAid())||finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
|
||||
List<Course> paginate = paginate(collect, pageIndex, pageSize);
|
||||
PageList<Course> rs = new PageList<>();
|
||||
rs.setCount(collect.size());
|
||||
@@ -462,45 +462,9 @@ 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<>();
|
||||
@@ -904,7 +868,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
}
|
||||
|
||||
// 删除ES数据
|
||||
deletedStudyResourceBatchByCourseIdAndType(id, c.getType());
|
||||
deletedStudyResourceBatchByCourseIdAndType(id,c.getType());
|
||||
} else {
|
||||
//彻底删除,课件设置为无课程状态
|
||||
courseDao.setDeleted(id);
|
||||
@@ -956,7 +920,6 @@ 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()) {
|
||||
@@ -1039,15 +1002,12 @@ 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);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1096,15 +1056,12 @@ 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);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -1134,15 +1091,12 @@ 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);
|
||||
}
|
||||
}
|
||||
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
|
||||
@@ -2059,41 +2013,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,17 +9,11 @@ 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;
|
||||
@@ -27,7 +21,6 @@ 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;
|
||||
@@ -110,9 +103,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 用于查询课程的学习记录
|
||||
* @param pager
|
||||
@@ -216,11 +206,6 @@ 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) {
|
||||
@@ -246,7 +231,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs.put("isCrowd",pass);
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
@@ -336,35 +320,6 @@ 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>
|
||||
|
||||
@@ -119,9 +119,6 @@ jasypt:
|
||||
boe:
|
||||
domain: http://10.251.186.27
|
||||
|
||||
kjb:
|
||||
aicoreUrl: http://10.251.186.27:8088
|
||||
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
|
||||
215
sql/20251115/数据迁移SQL脚本.sql
Normal file
215
sql/20251115/数据迁移SQL脚本.sql
Normal file
@@ -0,0 +1,215 @@
|
||||
-- 数据迁移SQL(项目与报名)
|
||||
-- 执行顺序:
|
||||
-- 1.1 查看项目数据量
|
||||
-- 1.2 预览项目数据
|
||||
-- 1.3 迁移项目信息
|
||||
-- 1.4 验证项目迁移结果
|
||||
-- 2.1 查看报名数据量(按项目ID)
|
||||
-- 2.2 预览报名数据
|
||||
-- 2.3 获取新项目ID
|
||||
-- 2.4 写入报名数据(使用新项目ID)
|
||||
-- 2.5 验证报名迁移结果
|
||||
|
||||
-- 任务1:项目数据迁移(eln_boe_mixture_project -> boe_new.project_info),条件:is_deleted='0' AND program_name='社招新员工在线入职学习'
|
||||
-- 步骤1.1:查看符合条件的数据量(执行前验证)
|
||||
SELECT COUNT(*) AS data_count
|
||||
FROM elearninglms.eln_boe_mixture_project
|
||||
WHERE is_deleted = '0'
|
||||
AND program_name = '社招新员工在线入职学习';
|
||||
|
||||
-- 步骤1.2:查看要迁移的数据详情(执行前验证)
|
||||
SELECT *
|
||||
FROM elearninglms.eln_boe_mixture_project
|
||||
WHERE is_deleted = '0'
|
||||
AND program_name = '社招新员工在线入职学习';
|
||||
|
||||
-- 步骤1.3:执行数据迁移(INSERT INTO ... SELECT)
|
||||
INSERT INTO boe_new.project_info (
|
||||
name,
|
||||
pic_url,
|
||||
type,
|
||||
begin_time,
|
||||
end_time,
|
||||
manager_id,
|
||||
remark,
|
||||
status,
|
||||
num_value,
|
||||
introduction,
|
||||
new_type,
|
||||
deleted,
|
||||
unlock_mode,
|
||||
rank_flag,
|
||||
attach_switch,
|
||||
bpm_flag,
|
||||
load_flag,
|
||||
create_time,
|
||||
create_id,
|
||||
update_time,
|
||||
update_id
|
||||
)
|
||||
SELECT
|
||||
p.program_name AS name,
|
||||
p.theme_url AS pic_url,
|
||||
1 AS type, -- 项目类别固定为1
|
||||
CASE
|
||||
WHEN p.open_start_time IS NOT NULL AND p.open_start_time > 0
|
||||
THEN FROM_UNIXTIME(p.open_start_time)
|
||||
WHEN p.start_time IS NOT NULL AND p.start_time > 0
|
||||
THEN FROM_UNIXTIME(p.start_time)
|
||||
ELSE NULL
|
||||
END AS begin_time,
|
||||
CASE
|
||||
WHEN p.open_end_time IS NOT NULL AND p.open_end_time > 0
|
||||
THEN FROM_UNIXTIME(p.open_end_time)
|
||||
WHEN p.end_time IS NOT NULL AND p.end_time > 0
|
||||
THEN FROM_UNIXTIME(p.end_time)
|
||||
ELSE NULL
|
||||
END AS end_time,
|
||||
p.project_manager_id AS manager_id,
|
||||
COALESCE(p.program_desc, p.program_desc_nohtml, '') AS remark,
|
||||
CASE
|
||||
WHEN p.status = '0' THEN 0 -- 临时 → 草稿
|
||||
WHEN p.status = '1' THEN 1 -- 正常 → 已发布
|
||||
WHEN p.status = '2' THEN -1 -- 停用 → 已结束
|
||||
ELSE 0
|
||||
END AS status,
|
||||
p.program_code AS num_value,
|
||||
COALESCE(p.program_desc_nohtml, p.program_desc, '') AS introduction,
|
||||
2 AS new_type, -- 学习项目
|
||||
0 AS deleted, -- 未删除
|
||||
1 AS unlock_mode, -- 自由模式
|
||||
0 AS rank_flag, -- 不显示积分排行榜
|
||||
1 AS attach_switch, -- 共享文档开启
|
||||
0 AS bpm_flag, -- 报名审批关闭
|
||||
0 AS load_flag, -- 下载成绩关闭
|
||||
FROM_UNIXTIME(p.created_at) AS create_time,
|
||||
CAST(p.created_by AS UNSIGNED) AS create_id,
|
||||
FROM_UNIXTIME(COALESCE(p.updated_at, p.created_at)) AS update_time,
|
||||
CAST(COALESCE(p.updated_by, p.created_by) AS UNSIGNED) AS update_id
|
||||
FROM elearninglms.eln_boe_mixture_project p
|
||||
WHERE p.is_deleted = '0'
|
||||
AND p.program_name = '社招新员工在线入职学习'
|
||||
AND NOT EXISTS (
|
||||
-- 防止重复插入:如果项目名称已存在则跳过
|
||||
SELECT 1
|
||||
FROM boe_new.project_info pi
|
||||
WHERE pi.name = p.program_name
|
||||
AND pi.deleted = 0
|
||||
);
|
||||
|
||||
-- 步骤1.4:验证迁移结果
|
||||
SELECT
|
||||
COUNT(*) AS migrated_count,
|
||||
name,
|
||||
status,
|
||||
begin_time,
|
||||
end_time
|
||||
FROM boe_new.project_info
|
||||
WHERE name = '社招新员工在线入职学习'
|
||||
AND deleted = 0
|
||||
GROUP BY name, status, begin_time, end_time;
|
||||
|
||||
-- 任务2:项目报名数据迁移(eln_boe_mixture_project_enroll -> boe_base.boe_study_course)
|
||||
-- 迁移全部报名数据(包括已删除记录,按 is_deleted 映射状态)
|
||||
|
||||
-- 步骤2.1:查看符合条件的数据量(执行前验证)
|
||||
-- 注意:需要先将 '123xxx' 替换为实际的项目ID(kid)
|
||||
SELECT COUNT(*) AS enroll_count
|
||||
FROM elearninglms.eln_boe_mixture_project_enroll
|
||||
WHERE program_id = '123xxx'; -- 请替换为实际的项目ID(kid)
|
||||
|
||||
-- 步骤2.2:查看要迁移的数据详情(执行前验证)
|
||||
SELECT *
|
||||
FROM elearninglms.eln_boe_mixture_project_enroll
|
||||
WHERE program_id = '123xxx' -- 请替换为实际的项目ID(kid)
|
||||
LIMIT 100;
|
||||
|
||||
-- 步骤2.3:获取新项目ID
|
||||
SET @new_project_id = (
|
||||
SELECT id FROM boe_new.project_info
|
||||
WHERE name = '社招新员工在线入职学习' AND deleted = 0
|
||||
ORDER BY id DESC LIMIT 1
|
||||
);
|
||||
|
||||
-- 步骤2.4:写入报名数据(使用新项目ID)
|
||||
INSERT INTO boe_base.boe_study_course (
|
||||
course_id,
|
||||
course_type,
|
||||
course_name,
|
||||
aid,
|
||||
aname,
|
||||
source,
|
||||
add_time,
|
||||
start_time,
|
||||
last_score,
|
||||
status,
|
||||
progress,
|
||||
remark
|
||||
)
|
||||
SELECT
|
||||
pi.id AS course_id, -- 使用新项目表的自增ID
|
||||
90 AS course_type,
|
||||
COALESCE(pi.name, p.program_name, '') AS course_name,
|
||||
e.user_id AS aid,
|
||||
COALESCE(u.real_name, '') AS aname,
|
||||
CASE
|
||||
WHEN e.enroll_method = 'self' THEN 1
|
||||
WHEN e.enroll_method = 'admin' THEN 2
|
||||
WHEN e.enroll_method = 'manager' THEN 3
|
||||
ELSE 1
|
||||
END AS source,
|
||||
FROM_UNIXTIME(e.enroll_time) AS add_time,
|
||||
FROM_UNIXTIME(e.enroll_time) AS start_time,
|
||||
NULL AS last_score,
|
||||
CASE
|
||||
WHEN e.enroll_type = '1' AND e.approved_state = '1' AND e.is_deleted = '0' THEN 2
|
||||
WHEN e.enroll_type = '3' THEN 8
|
||||
WHEN e.cancel_state = '1' THEN 8
|
||||
WHEN e.is_deleted = '1' THEN 8
|
||||
ELSE 1
|
||||
END AS status,
|
||||
0 AS progress,
|
||||
CONCAT('迁移自项目报名表,报名ID:', e.kid) AS remark
|
||||
FROM elearninglms.eln_boe_mixture_project_enroll e
|
||||
LEFT JOIN elearninglms.eln_boe_mixture_project p
|
||||
ON e.program_id = p.kid
|
||||
LEFT JOIN boe_new.project_info pi
|
||||
ON p.program_name = pi.name AND pi.deleted = 0
|
||||
LEFT JOIN elearninglms.eln_fw_user u
|
||||
ON e.user_id = u.kid
|
||||
WHERE e.program_id = '123xxx' -- 请替换为实际的项目ID(kid)
|
||||
AND pi.id = @new_project_id -- 使用新项目ID
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM boe_base.boe_study_course sc
|
||||
WHERE sc.course_id = @new_project_id
|
||||
AND sc.aid = e.user_id
|
||||
);
|
||||
|
||||
-- 步骤2.5:验证迁移结果
|
||||
SELECT
|
||||
COUNT(*) AS migrated_count,
|
||||
status,
|
||||
COUNT(CASE WHEN last_score IS NOT NULL THEN 1 END) AS has_score_count
|
||||
FROM boe_base.boe_study_course
|
||||
WHERE course_id = @new_project_id
|
||||
GROUP BY status;
|
||||
|
||||
-- 回滚SQL
|
||||
-- 回滚步骤R1:确认新项目ID(如变量丢失可重新获取)
|
||||
--SET @new_project_id = (
|
||||
-- SELECT id FROM boe_new.project_info
|
||||
-- WHERE name = '社招新员工在线入职学习' AND deleted = 0
|
||||
-- ORDER BY id DESC LIMIT 1
|
||||
--);
|
||||
--
|
||||
---- 回滚步骤R2:回滚报名数据(按备注标记,仅删除本次迁移写入的数据)
|
||||
--DELETE FROM boe_base.boe_study_course
|
||||
--WHERE course_id = @new_project_id
|
||||
-- AND remark LIKE '迁移自项目报名表%';
|
||||
--
|
||||
---- 回滚步骤R3:回滚项目信息(谨慎执行,确认仅影响本次迁移记录)
|
||||
--DELETE FROM boe_new.project_info
|
||||
--WHERE id = @new_project_id
|
||||
-- AND name = '社招新员工在线入职学习'
|
||||
-- AND deleted = 0;
|
||||
187
sql/20251115/数据迁移方案文档.md
Normal file
187
sql/20251115/数据迁移方案文档.md
Normal file
@@ -0,0 +1,187 @@
|
||||
# 数据迁移方案文档
|
||||
|
||||
## 一、迁移概述
|
||||
|
||||
本次迁移涉及两个数据迁移任务:
|
||||
1. **项目数据迁移**:从 `elearninglms.eln_boe_mixture_project` 迁移到 `boe_new.project_info`
|
||||
2. **项目报名数据迁移**:从 `elearninglms.eln_boe_mixture_project_enroll` 迁移到 `boe_base.boe_study_course`
|
||||
|
||||
---
|
||||
|
||||
## 二、任务1:项目数据迁移
|
||||
|
||||
### 2.1 迁移信息
|
||||
|
||||
- **源表**:`elearninglms.eln_boe_mixture_project`
|
||||
- **目标表**:`boe_new.project_info`
|
||||
- **迁移条件**:`is_deleted='0'` AND `program_name='社招新员工在线入职学习'`
|
||||
|
||||
### 2.2 字段映射关系
|
||||
|
||||
| 源表字段 | 目标表字段 | 说明 | 转换规则 |
|
||||
|---------|-----------|------|---------|
|
||||
| `kid` | - | 项目ID(varchar) | 不直接映射,目标表id为自增 |
|
||||
| `program_name` | `name` | 项目名称 | 直接映射 |
|
||||
| `program_desc` | `remark` | 项目描述/说明 | 直接映射 |
|
||||
| `theme_url` | `pic_url` | 封面图地址 | 直接映射 |
|
||||
| `start_time` / `open_start_time` | `begin_time` | 开始时间 | 优先使用 `open_start_time`,空则用 `start_time`,需转换为 timestamp |
|
||||
| `end_time` / `open_end_time` | `end_time` | 结束时间 | 优先使用 `open_end_time`,空则用 `end_time`,需转换为 timestamp |
|
||||
| `project_manager_id` | `manager_id` | 项目经理ID | 直接映射 |
|
||||
| `status` | `status` | 状态 | 需要转换:'0'→0(草稿), '1'→1(已发布), '2'→-1(已结束) |
|
||||
| `created_at` | `create_time` | 创建时间 | 需转换为 timestamp |
|
||||
| `created_by` | `create_id` | 创建人ID | 需转换为 bigint |
|
||||
| `updated_at` | `update_time` | 更新时间 | 需转换为 timestamp |
|
||||
| `updated_by` | `update_id` | 更新人ID | 需转换为 bigint |
|
||||
| `program_code` | `num_value` | 项目编号 | 直接映射 |
|
||||
| `program_desc` / `program_desc_nohtml` | `introduction` | 项目介绍 | 优先使用 `program_desc_nohtml` |
|
||||
|
||||
### 2.3 默认值设置
|
||||
|
||||
- `type`: 1(项目类别)
|
||||
- `new_type`: 2(学习项目)
|
||||
- `deleted`: 0(未删除)
|
||||
- `unlock_mode`: 1(自由模式)
|
||||
- `rank_flag`: 0(不显示积分排行榜)
|
||||
- `attach_switch`: 1(共享文档开启)
|
||||
- `bpm_flag`: 0(报名审批关闭)
|
||||
- `load_flag`: 0(下载成绩关闭)
|
||||
|
||||
### 2.4 注意事项
|
||||
|
||||
1. 目标表的 `id` 字段为自增主键,无需手动设置
|
||||
2. 时间字段需要从 int(时间戳)转换为 timestamp
|
||||
3. 状态字段需要根据源表的值进行映射转换
|
||||
4. 如果源表中存在多条符合条件的记录,需要确认是否全部迁移或仅迁移最新的一条
|
||||
|
||||
---
|
||||
|
||||
## 三、任务2:项目报名数据迁移
|
||||
|
||||
### 3.1 迁移信息
|
||||
|
||||
- **源表**:`elearninglms.eln_boe_mixture_project_enroll`
|
||||
- **目标表**:`boe_base.boe_study_course`
|
||||
- **迁移条件**:`program_id='123xxx'`(注意:实际执行时需要替换为真实的项目ID)
|
||||
- **重要说明**:**迁移全部报名数据,包括已删除的记录(is_deleted='1')**。已删除的记录在状态映射时会被标记为"终止"状态(status=8)
|
||||
|
||||
### 3.2 字段映射关系
|
||||
|
||||
| 源表字段 | 目标表字段 | 说明 | 转换规则 |
|
||||
|---------|-----------|------|---------|
|
||||
| `program_id` | `course_id` | 项目ID(作为课程ID) | 直接映射 |
|
||||
| `user_id` | `aid` | 学员ID | 直接映射 |
|
||||
| - | `last_score` | 学习成绩 | 初始设置为 NULL,后续需要从成绩表关联更新 |
|
||||
| `enroll_type` + `approved_state` | `status` | 完成状态 | 根据业务规则映射(见下方) |
|
||||
| `enroll_time` | `add_time` | 加入时间(报名时间) | 需转换为 datetime |
|
||||
| `enroll_time` | `start_time` | 开始学习时间 | 需转换为 datetime |
|
||||
|
||||
### 3.3 状态映射规则
|
||||
|
||||
根据 `boe_study_course` 表的 status 定义:
|
||||
- `STATUS_NOSTUDY = 1`(未开始学习)
|
||||
- `STATUS_STUDYING = 2`(学习中)
|
||||
- `STATUS_ABORTED = 8`(终止)
|
||||
- `STATUS_FINISH = 9`(学习完成)
|
||||
|
||||
**状态映射逻辑**:
|
||||
```sql
|
||||
CASE
|
||||
WHEN enroll_type = '1' AND approved_state = '1' AND is_deleted = '0' THEN 2 -- 报名成功且审批同意 → 学习中
|
||||
WHEN enroll_type = '3' THEN 8 -- 拒绝报名 → 终止
|
||||
WHEN cancel_state = '1' THEN 8 -- 取消审批同意 → 终止
|
||||
WHEN is_deleted = '1' THEN 8 -- 已删除 → 终止
|
||||
ELSE 1 -- 其他情况 → 未开始
|
||||
END AS status
|
||||
```
|
||||
|
||||
### 3.4 其他字段设置
|
||||
|
||||
- `course_type`: 需要根据项目类型设置(默认为项目类型对应的课程类型)
|
||||
- `course_name`: 需要关联项目表获取项目名称
|
||||
- `aname`: 需要关联用户表获取学员姓名
|
||||
- `source`: 根据 `enroll_method` 映射('self'→1, 'admin'→2, 'manager'→3)
|
||||
- `progress`: 初始设置为 0 或 NULL
|
||||
- `last_score`: 初始设置为 NULL,需要后续从成绩表更新
|
||||
|
||||
### 3.5 注意事项
|
||||
|
||||
1. **学习成绩(last_score)**:源表中没有直接的成绩字段,需要:
|
||||
- 方案A:从其他成绩表(如 `eln_ln_examination_result_user`)关联获取
|
||||
- 方案B:先设置为 NULL,后续通过业务逻辑更新
|
||||
|
||||
2. **完成状态(status)**:需要根据业务逻辑判断,当前映射规则仅供参考,实际使用时需要根据业务需求调整
|
||||
|
||||
3. **项目ID替换**:SQL中的 `'123xxx'` 需要替换为实际的项目ID
|
||||
|
||||
4. **数据去重**:确保 `(course_id, aid)` 组合的唯一性,避免重复插入
|
||||
|
||||
5. **关联查询**:可能需要关联用户表获取学员姓名等信息
|
||||
|
||||
6. **全部数据迁移**:本次迁移会包含所有符合条件的报名记录,包括已删除的记录。已删除的记录会根据 `is_deleted='1'` 映射为终止状态(status=8)
|
||||
|
||||
---
|
||||
|
||||
## 四、执行步骤
|
||||
|
||||
### 4.1 执行前准备
|
||||
|
||||
1. **备份数据**:执行迁移前,务必备份源表和目标表
|
||||
2. **验证条件**:确认迁移条件是否正确(特别是项目名称和项目ID)
|
||||
3. **数据检查**:检查源表中符合条件的数据量
|
||||
4. **环境确认**:确认目标数据库连接和权限
|
||||
|
||||
### 4.2 执行顺序
|
||||
|
||||
1. **先执行任务1**:迁移项目数据
|
||||
2. **获取新项目ID**:记录迁移后的项目ID(如果需要)
|
||||
3. **更新任务2的SQL**:将项目ID替换为实际值
|
||||
4. **执行任务2**:迁移项目报名数据
|
||||
|
||||
### 4.3 执行后验证
|
||||
|
||||
1. **数据量核对**:对比源表和目标表的记录数
|
||||
2. **关键字段验证**:抽查关键字段是否正确迁移
|
||||
3. **业务功能验证**:在系统中验证迁移后的数据是否正常
|
||||
|
||||
---
|
||||
|
||||
## 五、风险评估与回滚方案
|
||||
|
||||
### 5.1 风险点
|
||||
|
||||
1. **数据量**:如果数据量较大,可能影响系统性能
|
||||
2. **字段类型不匹配**:时间戳转换、状态值转换可能出错
|
||||
3. **数据完整性**:关联字段可能缺失或无效
|
||||
4. **业务逻辑**:状态映射规则可能与实际业务不符
|
||||
|
||||
### 5.2 回滚方案
|
||||
|
||||
1. **备份恢复**:使用备份数据恢复目标表
|
||||
2. **删除迁移数据**:根据迁移条件删除已迁移的数据
|
||||
3. **数据修复**:手动修复错误的数据
|
||||
|
||||
---
|
||||
|
||||
## 六、附录
|
||||
|
||||
### 6.1 相关表结构
|
||||
|
||||
- `elearninglms.eln_boe_mixture_project`:源项目表
|
||||
- `boe_new.project_info`:目标项目表
|
||||
- `elearninglms.eln_boe_mixture_project_enroll`:源报名表
|
||||
- `boe_base.boe_study_course`:目标课程学习表
|
||||
|
||||
### 6.2 状态值对照表
|
||||
|
||||
**项目状态映射**:
|
||||
- '0'(临时)→ 0(草稿)
|
||||
- '1'(正常)→ 1(已发布)
|
||||
- '2'(停用)→ -1(已结束)
|
||||
|
||||
**学习状态映射**:
|
||||
- 1:未开始学习
|
||||
- 2:学习中
|
||||
- 8:终止
|
||||
- 9:学习完成
|
||||
|
||||
---
|
||||
Reference in New Issue
Block a user