mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 02:16:49 +08:00
Compare commits
1 Commits
release-20
...
master-202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3e84feb48 |
@@ -45,7 +45,10 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -95,8 +98,7 @@ public class ThirdApi {
|
||||
private String syncOnLineScore;
|
||||
@Value("${coursesuilt.updateOnLineStatua}")
|
||||
private String updateOnLineStatua;
|
||||
@Value("${coursesuilt.delOnLineById}")
|
||||
private String delOnLineById;
|
||||
|
||||
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId() {
|
||||
@@ -396,28 +398,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,11 @@ package com.xboe.data.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.boe.feign.api.serverall.entity.UserData;
|
||||
import com.xboe.constants.CacheName;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.retry.annotation.Recover;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -44,9 +39,6 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
@Autowired
|
||||
TeacherDao teacherDao;
|
||||
|
||||
@Resource
|
||||
private CacheManager cacheManager;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -67,8 +59,6 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
a.setDeleted(user.getDeleted());
|
||||
}
|
||||
a.setLoginName(user.getCode());
|
||||
a.setMobile(user.getMobile());
|
||||
a.setEmail(user.getEmail());
|
||||
log.info("更新账号code");
|
||||
accountDao.update(a);
|
||||
} else {
|
||||
@@ -81,18 +71,14 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
a.setRegTime(LocalDateTime.now());
|
||||
a.setSysId(user.getKid());
|
||||
a.setStatus(1);
|
||||
a.setMobile(user.getMobile());
|
||||
a.setEmail(user.getEmail());
|
||||
accountDao.save(a);
|
||||
log.info("账号不存在,新添加账号【" + user.getId() + "】");
|
||||
}
|
||||
|
||||
if (u != null) {
|
||||
//更新部分用户字段
|
||||
u.setDepartId(user.getDepartId());
|
||||
u.setDepartName(user.getDepartName());
|
||||
u.setName(user.getName());
|
||||
u.setMobileNo(user.getMobile());
|
||||
//2022-12-8 去掉用户类型的更新,因为返回的数据都是学员,
|
||||
//u.setUserType(user.getUserType());
|
||||
if (user.getLearningDuration() > 0) { //不大于0才会更新
|
||||
@@ -120,17 +106,9 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
} else {
|
||||
u.setShowHome(true);//band16以下,及其它无bandLevel的信息
|
||||
}
|
||||
u.setMobileNo(user.getMobile());
|
||||
userDao.save(u);
|
||||
log.info("添加新用户");
|
||||
}
|
||||
|
||||
Cache cache = cacheManager.getCache(CacheName.NAME_USER);
|
||||
if(cache != null) {
|
||||
cache.evict(CacheName.KEY_ACCOUNT + user.getId());
|
||||
cache.evict(CacheName.KEY_USER + user.getId());
|
||||
}
|
||||
|
||||
//对机构的判断,不为空时才会处理,为空时不处理
|
||||
if (StringUtils.isNotBlank(user.getDepartId())) {
|
||||
org = orgDao.get(user.getDepartId());
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
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;
|
||||
@@ -147,22 +144,6 @@ 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);
|
||||
@@ -189,46 +170,17 @@ 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中去
|
||||
@@ -934,7 +886,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public JsonResponse<Boolean> delete(String id,Boolean erasable,String title,String remark, HttpServletRequest request){
|
||||
public JsonResponse<Boolean> delete(String id,Boolean erasable,String title,String remark){
|
||||
if(StringUtils.isBlank(id)){
|
||||
return badRequest("参数错误");
|
||||
}
|
||||
@@ -949,11 +901,6 @@ 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);
|
||||
|
||||
@@ -314,10 +314,8 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
User user = userService.get(ct.getTeacherId());
|
||||
if(t!=null) {
|
||||
ct.setRemark(t.getDescription());
|
||||
ct.setSupplier(t.getSupplier());
|
||||
ct.setTeacherType(t.getTeacherType());
|
||||
if(redisTemplate.opsForValue().get(ct.getTeacherId())!=null){
|
||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||
ct.setTeacherName("BOE教师");
|
||||
}
|
||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
||||
@@ -329,15 +327,13 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
||||
teacherCourseDto.setId(ct.getId());
|
||||
if(user!=null){
|
||||
teacherCourseDto.setUserNo(user.getUserNo());
|
||||
}
|
||||
teacherCourseDto.setUserNo(user.getUserNo());
|
||||
teacherCourseDtos.add(teacherCourseDto);
|
||||
}else if (redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
||||
List<String> list=new ArrayList<>();
|
||||
list.add(ct.getTeacherId());
|
||||
getTeacherInfo(request.getHeader("Xboe-Access-Token"),list);
|
||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
||||
if(Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1")){
|
||||
ct.setTeacherName("BOE教师");
|
||||
}
|
||||
teacherCourseDto.setCourseId(ct.getCourseId());
|
||||
@@ -349,9 +345,7 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
teacherCourseDto.setSysCreateBy(ct.getSysCreateBy());
|
||||
teacherCourseDto.setSysCreateTime(ct.getSysCreateTime());
|
||||
teacherCourseDto.setId(ct.getId());
|
||||
if(user!=null){
|
||||
teacherCourseDto.setUserNo(user.getUserNo());
|
||||
}
|
||||
teacherCourseDto.setUserNo(user.getUserNo());
|
||||
teacherCourseDtos.add(teacherCourseDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ public class Course extends BaseEntity {
|
||||
/**所有的设备*/
|
||||
public static int DEVICE_ALL=3;
|
||||
|
||||
/**仅内网*/
|
||||
public static int DEVICE_INTERNAL=4;
|
||||
|
||||
/**未提交,草稿*/
|
||||
public static final int STATUS_NONE=1;
|
||||
|
||||
@@ -400,15 +397,6 @@ 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;
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -57,10 +56,5 @@ public interface ICourseHRBPAuditService {
|
||||
*/
|
||||
PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize,int userType, CourseHRBPAudit info);
|
||||
|
||||
/**
|
||||
* 查询一组课程的最近一次审核记录,返回键为courseId的映射。
|
||||
*/
|
||||
Map<String, CourseHRBPAudit> findLatestByCourseIds(List<String> courseIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -341,6 +341,8 @@ public interface ICourseService {
|
||||
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
||||
|
||||
|
||||
List<Course> findByIds(List<String> courseIds);
|
||||
void deletedStudyResourceBatchByCourseIdAndType(String courseId,Integer courseType);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -265,27 +263,4 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xboe.module.course.service.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -15,17 +14,11 @@ import java.util.stream.Stream;
|
||||
import javax.annotation.Resource;
|
||||
import javax.management.Query;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -122,9 +115,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Autowired(required = false)
|
||||
private IEventDataSender eventSender;
|
||||
|
||||
@Resource
|
||||
RestHighLevelClient restHighLevelClient;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -183,8 +173,6 @@ 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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -460,7 +448,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
List<Course> paginate = paginate(listByFilters2, pageIndex, pageSize);
|
||||
PageList<Course> rs = new PageList<>();
|
||||
rs.setCount(listByFilters2.size());
|
||||
rs.setPageSize(pageSize);
|
||||
rs.setList(paginate);
|
||||
return rs;
|
||||
}
|
||||
@@ -866,14 +853,12 @@ public class CourseServiceImpl implements ICourseService {
|
||||
log.error("未配置事件消息发送的实现");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除ES数据
|
||||
deletedStudyResourceBatchByCourseIdAndType(id,c.getType());
|
||||
} else {
|
||||
//彻底删除,课件设置为无课程状态
|
||||
courseDao.setDeleted(id);
|
||||
}
|
||||
//记录删除日志信息
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1582,13 +1567,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findByIds(List<String> courseIds) {
|
||||
QueryBuilder query = QueryBuilder.from(Course.class);
|
||||
query.addFilter(FieldFilters.in("id", courseIds));
|
||||
return courseDao.findList(query.builder());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int countWaitAudit(String aid) {
|
||||
@@ -2000,17 +1978,5 @@ public class CourseServiceImpl implements ICourseService {
|
||||
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletedStudyResourceBatchByCourseIdAndType(String courseId, Integer courseType) {
|
||||
DeleteByQueryRequest request = new DeleteByQueryRequest("new_study_resource");
|
||||
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
|
||||
boolQueryBuilder.must(QueryBuilders.matchQuery("courseId", courseId));
|
||||
boolQueryBuilder.must(QueryBuilders.matchQuery("courseType", courseType));
|
||||
request.setQuery(boolQueryBuilder);
|
||||
try {
|
||||
restHighLevelClient.deleteByQuery(request, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -25,14 +24,12 @@ 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;
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
package com.xboe.school.study.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||
import com.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.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;
|
||||
@@ -222,11 +214,11 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
redisTemplate.opsForValue().set(teacherVo.get(0).getTeacherId(), teacherVo.get(0).getStatus());
|
||||
//设置过期时间为1天
|
||||
redisTemplate.expire(teacherVo.get(0).getTeacherId(), 24 * 60 * 60, TimeUnit.SECONDS);
|
||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
|
||||
ct.setTeacherName("BOE教师");
|
||||
}
|
||||
}
|
||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && ( t==null || t.getTeacherType() == 1)){
|
||||
if (Objects.equals(redisTemplate.opsForValue().get(ct.getTeacherId()), "1") && t.getTeacherType() == 1 ){
|
||||
ct.setTeacherName("BOE教师");
|
||||
}
|
||||
}
|
||||
@@ -235,29 +227,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
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);
|
||||
@@ -284,36 +253,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
rs.put("progress", sc.getProgress());
|
||||
//查询上次学习的是什么资源。查询用户的学习情况
|
||||
List<StudyCourseItem> items=studyService.findByStudyId(sc.getId());
|
||||
// 和内容匹配,根据内容的视频时长,计算学习进度
|
||||
if(CollectionUtil.isNotEmpty(items) && CollectionUtil.isNotEmpty(cclist)){
|
||||
// 根据ID转换map
|
||||
Map<String, CourseContent> contentMap = cclist.stream().collect(Collectors.toMap(CourseContent::getId, Function.identity()));
|
||||
for (StudyCourseItem item : items) {
|
||||
CourseContent content = contentMap.get(item.getContentId());
|
||||
if(null == content){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(null==item.getLastStudyTime()
|
||||
|| item.getLastStudyTime()<=0
|
||||
|| null==content.getDuration()
|
||||
|| content.getDuration()<=0){
|
||||
continue;
|
||||
}
|
||||
|
||||
BigDecimal lastStudyTime = new BigDecimal(item.getLastStudyTime());
|
||||
BigDecimal duration = new BigDecimal(content.getDuration());
|
||||
BigDecimal progress = lastStudyTime.divide(duration, 10, RoundingMode.HALF_UP);
|
||||
if(progress.compareTo(BigDecimal.ZERO) < 0){
|
||||
progress = BigDecimal.ZERO;
|
||||
}else if(progress.compareTo(BigDecimal.ONE) > 0){
|
||||
progress = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
item.setProgressVideo(progress);
|
||||
}
|
||||
}
|
||||
|
||||
rs.put("contentStudys",items);//学习的内容
|
||||
}
|
||||
|
||||
@@ -592,8 +531,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);
|
||||
@@ -669,90 +608,6 @@ 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(){
|
||||
|
||||
@@ -3,16 +3,9 @@ package com.xboe.school.study.api;
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -49,15 +42,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
||||
@Autowired
|
||||
IStudyCourseService service;
|
||||
|
||||
@Autowired
|
||||
ICourseService courseService;
|
||||
|
||||
@Value("${xboe.upload.file.http_path}")
|
||||
private String httpPath;
|
||||
|
||||
@Value("${xboe.image.course.default}")
|
||||
private String defaultCourseImage;
|
||||
|
||||
@Resource
|
||||
private PhpOnlineStudyRecordScheduledTasks phpOnlineStudyRecordScheduledTasks;
|
||||
|
||||
@@ -70,9 +54,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
||||
try {
|
||||
dto.setAccountId(getCurrent().getAccountId());
|
||||
PageList<CourseStudyDto> rs=search.search(page.getStartRow(),page.getPageSize(), dto);
|
||||
|
||||
handleCourseImage(rs);
|
||||
|
||||
return success(rs);
|
||||
}catch(Exception e) {
|
||||
log.error("查询报名学习ES失败",e);
|
||||
@@ -80,51 +61,6 @@ public class StudyCourseESApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCourseImage(PageList<CourseStudyDto> rs) {
|
||||
if (rs == null || CollectionUtil.isEmpty(rs.getList())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> emptyImageCourseIds = Lists.newArrayList();
|
||||
for(CourseStudyDto courseStudyDto : rs.getList()) {
|
||||
if(StringUtils.isBlank(courseStudyDto.getCourseImage())) {
|
||||
// 过滤课程类型
|
||||
if(courseStudyDto.getCourseType()==10
|
||||
|| courseStudyDto.getCourseType()==20){
|
||||
emptyImageCourseIds.add(courseStudyDto.getCourseId());
|
||||
}else{
|
||||
log.warn("课程图片为空,课程id为:{},课程类型:{}",courseStudyDto.getCourseId(),courseStudyDto.getCourseType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(CollectionUtil.isEmpty(emptyImageCourseIds)){
|
||||
return;
|
||||
}
|
||||
|
||||
List<Course> courseList = courseService.findByIds(emptyImageCourseIds);
|
||||
if(CollectionUtil.isNotEmpty(courseList)){
|
||||
// courseList转换成map
|
||||
Map<String, Course> courseMap = courseList.stream().collect(Collectors.toMap(Course::getId, course -> course));
|
||||
|
||||
// 赋值ES图片
|
||||
for(CourseStudyDto courseStudyDto : rs.getList()) {
|
||||
if(emptyImageCourseIds.contains(courseStudyDto.getCourseId())) {
|
||||
Course currentCourse = courseMap.get(courseStudyDto.getCourseId());
|
||||
if(null!=currentCourse){
|
||||
if(StringUtils.isNotBlank(currentCourse.getCoverImg())){
|
||||
// 拼接域名
|
||||
courseStudyDto.setCourseImage(httpPath + currentCourse.getCoverImg());
|
||||
}else{
|
||||
// 赋值默认图片
|
||||
courseStudyDto.setCourseImage(defaultCourseImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value="/list-by-ids",method = {RequestMethod.POST})
|
||||
public JsonResponse<List<StudyCourse>> search(@RequestBody List<String> ids){
|
||||
if(ids.isEmpty()) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -12,13 +10,10 @@ 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
|
||||
@@ -31,15 +26,14 @@ public class StudyCourseTask {
|
||||
|
||||
private final IStudyService studyService;
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
* 获取redis 中学习结束的数据更新入库
|
||||
* */
|
||||
@XxlJob("saveStudyCourseItemLastTime2")
|
||||
public void saveStudyCourseItemLastTime2() {
|
||||
@XxlJob("saveStudyCourseItemLastTime")
|
||||
public void saveStudyCourseItemLastTime() {
|
||||
log.info("------定时任务-获取redis 中学习结束的数据更新入库------" );
|
||||
// 1. 定义匹配模式(匹配所有目标key)
|
||||
final String KEY_PATTERN = "studyContentId:*:last_active";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
@@ -54,9 +48,10 @@ public class StudyCourseTask {
|
||||
// 3. 遍历处理符合条件的key
|
||||
while (cursor.hasNext()) {
|
||||
String redisKey = new String(cursor.next());
|
||||
log.info("------定时任务-获取redis 中学习结束的数据更新入库------redisKey = " + redisKey );
|
||||
// 4. 获取剩余TTL(秒)
|
||||
Long ttl = redisTemplate.getExpire(redisKey, TimeUnit.SECONDS);
|
||||
|
||||
log.info("------定时任务-获取redis 中学习结束的数据更新入库------ttl = " + ttl );
|
||||
// 5. 过滤条件:剩余时间 >= 29天23小时30分钟(转换为秒)
|
||||
// 总需时间 = (30天 - 30分钟) = 29天23小时30分钟 = 2590200秒
|
||||
// 5分钟 300秒 || 2592000 - 300 = 2591700
|
||||
@@ -66,6 +61,7 @@ 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;
|
||||
@@ -75,15 +71,19 @@ public class StudyCourseTask {
|
||||
if (partValues.length >= 2){
|
||||
timestamp = LocalDateTime.parse(partValues[1], formatter);
|
||||
}
|
||||
log.info("-定时任务-获取redis 中学习结束的数据更新入库---studyContentId = " + studyContentId + ",lastStudyTime = " + lastStudyTime + ", timestamp = " + timestamp);
|
||||
// 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) {
|
||||
@@ -104,159 +104,5 @@ 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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.xboe.school.study.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
@@ -131,11 +129,4 @@ public class StudyCourseItem extends IdEntity {
|
||||
@Column(name = "status",length=1)
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 视频播放进度
|
||||
* */
|
||||
// @Column(name = "progress_video")
|
||||
@Transient
|
||||
private BigDecimal progressVideo;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.xboe.common.PageList;
|
||||
import com.xboe.school.study.dto.StudyContentDto;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.entity.StudyTime;
|
||||
import com.xboe.system.user.entity.User;
|
||||
|
||||
/**
|
||||
* 学习情况处理,比较综合一个处理类
|
||||
@@ -35,12 +36,11 @@ public interface IStudyService {
|
||||
|
||||
/**
|
||||
* 更新最后的学习时间,及学习时间点
|
||||
*
|
||||
* @param studyContentId
|
||||
* @param lastStudyTime
|
||||
* @param aid
|
||||
*/
|
||||
void updateLastTime(String studyContentId, int lastStudyTime, String aid);
|
||||
void updateLastTime(String studyContentId,int lastStudyTime,String aid);
|
||||
|
||||
/**
|
||||
* 资源学习记录
|
||||
@@ -101,8 +101,4 @@ 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,7 +10,6 @@ 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;
|
||||
@@ -171,32 +170,15 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
}
|
||||
builder.addGroupBy("studyId");
|
||||
List<StudyExam> list1 = dao.findList(builder.builder());
|
||||
if(list1 != null && list1.size() > 0){
|
||||
log.info("----------StudyExam--QueryBuilder list1.size = " + list1.size() + ",0 = " + list1.get(0));
|
||||
for(StudyExam item : list1){
|
||||
log.info("--------------StudyExam---CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||
log.info("--------StudyExam--准备判断进度-------totalContent = " + totalContent);
|
||||
scDao.finishCheck1(item.getStudyId(),item.getCourseId(),totalContent);
|
||||
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--判断进度完毕----------------------");
|
||||
}
|
||||
}
|
||||
log.info("------------QueryBuilder list1.size = " + list1.size() + ",0 = " + list1.get(0));
|
||||
|
||||
for(StudyExam item : list1){
|
||||
log.info("-----------------CourseId = " + item.getCourseId() + " , StudyId = " + item.getStudyId() + " , StudentId = " + item.getStudentId());
|
||||
int totalContent = courseContentDao.getCount(item.getCourseId());
|
||||
log.info("----------准备判断进度-------totalContent = " + totalContent);
|
||||
scDao.finishCheck1(item.getStudyId(),item.getCourseId(),totalContent);
|
||||
log.info("----------判断进度完毕----------------------");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
log.info("------异常----------------------:" +exception.getMessage());
|
||||
|
||||
@@ -10,6 +10,10 @@ import java.util.Map;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.xboe.module.article.entity.Article;
|
||||
import com.xboe.module.interaction.entity.Shares;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -116,74 +120,34 @@ 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) {
|
||||
@@ -206,21 +170,7 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
@Override
|
||||
public List<StudyCourseItem> findByStudyId(String 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;
|
||||
return scItemDao.findList(OrderCondition.desc("lastTime"),FieldFilters.eq("studyId", studyId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,12 +232,11 @@ 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,b.score " +
|
||||
"IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
|
||||
"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,MAX(item.score) score " +
|
||||
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
|
||||
"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 " +
|
||||
@@ -316,9 +265,6 @@ 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);
|
||||
@@ -415,7 +361,6 @@ public class StudyServiceImpl implements IStudyService{
|
||||
log.info("-study-video-time-mysql保存---studyContentId = " + studyContentId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getLast(String aid) {
|
||||
//按lastTime排序,第一条,只是课件内容
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,105 +1,159 @@
|
||||
boe:
|
||||
domain: http://192.168.0.253
|
||||
spring:
|
||||
# application.yml
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 1000MB
|
||||
max-request-size: 1000MB
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/java/static
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.253:8848
|
||||
config:
|
||||
server-addr: 192.168.0.253:8848
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
redis:
|
||||
database: 1
|
||||
host: 192.168.0.253
|
||||
host: 192.168.0.101
|
||||
password: boe@123
|
||||
port: 6379
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
min-idle: 0
|
||||
max-idle: 30
|
||||
max-wait: 10000ms
|
||||
shutdown-timeout: 100ms
|
||||
jpa:
|
||||
database: MYSQL
|
||||
properties:
|
||||
hibernate:
|
||||
naming_strategy: org.hibernate.cfg.EJB3NamingStrategy
|
||||
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: none
|
||||
ddl-auto: update
|
||||
datasource:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.253:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.101:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: boe#1234A
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
hikari:
|
||||
auto-commit: true
|
||||
minimum-idle: 5
|
||||
idle-timeout: 60000
|
||||
connection-timeout: 30000
|
||||
max-lifetime: 1800000
|
||||
maximum-pool-size: 20
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
hibernate:
|
||||
SQL: ERROR
|
||||
config: classpath:log/logback-@profileActive@.xml
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/10/static
|
||||
server:
|
||||
port: 9090
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
session:
|
||||
timeout: 30m
|
||||
encoding:
|
||||
charset: UTF-8
|
||||
enabled: true
|
||||
force: true
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
servlet:
|
||||
multipart:
|
||||
maxFileSize: 1024MB
|
||||
maxRequestSize: 1024MB
|
||||
mvc:
|
||||
static-path-pattern: /cdn/**
|
||||
|
||||
#logging.level.org.hibernate.SQL=DEBUG
|
||||
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
#logging.config=classpath:log/logback-@profileActive@.xml
|
||||
|
||||
# logging:
|
||||
# config: classpath:log/logback-${spring.profiles.active}.xml
|
||||
# level:
|
||||
# org:
|
||||
# hibernate:
|
||||
# SQL: DEBUG
|
||||
# type:
|
||||
# descriptor:
|
||||
# sql:
|
||||
# BasicBinder: TRACE
|
||||
|
||||
xcaching:
|
||||
specs:
|
||||
favorites:
|
||||
timeout: 10s
|
||||
praises:
|
||||
timeout: 10s
|
||||
shares:
|
||||
timeout: 10s
|
||||
|
||||
xboe:
|
||||
api:
|
||||
cross_filter: true
|
||||
local:
|
||||
dev: true
|
||||
upload:
|
||||
file:
|
||||
temp_path: /tmp
|
||||
temp_path: D:/Projects/BOE/10/static/temp
|
||||
save_path: /home/www/elearning/upload
|
||||
http_path: http://192.168.0.253/upload
|
||||
http_path: http://127.0.0.1/upload
|
||||
externalinterface:
|
||||
url:
|
||||
system: http://127.0.0.1:9091
|
||||
system: http://localhost:9091
|
||||
old:
|
||||
base:
|
||||
url: http://192.168.0.253
|
||||
url: http://192.168.0.101
|
||||
server:
|
||||
userbasic:
|
||||
url: http://192.168.0.101/userbasic
|
||||
stat:
|
||||
base:
|
||||
url: http://127.0.0.1:9080
|
||||
server:
|
||||
userbasic:
|
||||
url: http://192.168.0.253/userbasic
|
||||
elasticsearch:
|
||||
server:
|
||||
ip: 192.168.0.253
|
||||
ip: 192.168.0.101
|
||||
port: 9200
|
||||
user:
|
||||
password:
|
||||
email:
|
||||
url: http://192.168.0.253/api/b1/email/send
|
||||
url: http://192.168.0.101/api/b1/email/send
|
||||
from: boeu_learning@boe.com.cn
|
||||
user:
|
||||
security:
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||
image:
|
||||
course:
|
||||
default: http://192.168.0.253/pc/images/bgimg/course.png
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
admin:
|
||||
addresses: http://192.168.0.253/jobAdmin
|
||||
executor:
|
||||
appname: java-servers-job-api
|
||||
port: 9995
|
||||
address:
|
||||
ip:
|
||||
logpath: /var/log/xxl-job/dw/
|
||||
logretentiondays: 30
|
||||
aop-log-record:
|
||||
#是否开启日志记录
|
||||
enabled: true
|
||||
#不进行拦截的包或者类
|
||||
excludeClassNames:
|
||||
activemq:
|
||||
broker-url: tcp://192.168.0.253:61616
|
||||
user: admin
|
||||
password: admin
|
||||
elasticsearch:
|
||||
host: 192.168.0.253
|
||||
port: 9200
|
||||
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||
|
||||
boe:
|
||||
domain: http://127.0.0.1
|
||||
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
read-timeout: 30
|
||||
write-timeout: 30
|
||||
max-idle-connections: 200
|
||||
keep-alive-duration: 300
|
||||
|
||||
|
||||
|
||||
orgTree:
|
||||
orgTreeList: ${boe.domain}/userbasic/org/list
|
||||
orgChildTreeList: ${boe.domain}/userbasic/org/childOrgs
|
||||
|
||||
userBasic:
|
||||
searchUserList: ${boe.domain}/userbasic/user/list
|
||||
getUserBasicInfo: ${boe.domain}/userbasic/user/getUserBasicInfo
|
||||
getTeacherIds: ${boe.domain}/userbasic/user/getTeacherInfo
|
||||
|
||||
audience:
|
||||
usersByAudienceList: ${boe.domain}/userbasic/audience/memberList
|
||||
getOrgUsers: ${boe.domain}/userbasic/user/getOrgUsers
|
||||
|
||||
statApi:
|
||||
userdynamicList: ${boe.domain}/statApi/xboe/m/stat/userdynamic/list
|
||||
|
||||
infrasApi:
|
||||
dict: ${boe.domain}/infrasApi/dict/list
|
||||
|
||||
manageApi:
|
||||
stu:
|
||||
offcourse: ${boe.domain}/manageApi/stu/offcourse/getOffCourseId
|
||||
editExam: ${boe.domain}/manageApi/admin/project/editExam
|
||||
getStudyStatus: ${boe.domain}/manageApi/stu/project/completeStatus
|
||||
coursesuilt:
|
||||
getStudyStatus: ${boe.domain}/manageApi/stu/project/completeStatus
|
||||
@@ -108,9 +108,7 @@ xboe:
|
||||
from: boeu_learning@boe.com.cn
|
||||
user:
|
||||
security:
|
||||
image:
|
||||
course:
|
||||
default: http://10.251.132.75/pc/images/bgimg/course.png
|
||||
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
|
||||
@@ -74,9 +74,6 @@ xboe:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||
image:
|
||||
course:
|
||||
default: https://u.boe.com/pc/images/bgimg/course.png
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
|
||||
@@ -84,7 +84,7 @@ xboe:
|
||||
file:
|
||||
temp_path: /tmp
|
||||
save_path: /home/www/elearning/upload
|
||||
http_path: https://u-pre.boe.com/upload
|
||||
http_path: http://10.251.186.27/upload
|
||||
externalinterface:
|
||||
url:
|
||||
system: http://localhost:9091
|
||||
@@ -108,9 +108,7 @@ xboe:
|
||||
from: boeu_learning@boe.com.cn
|
||||
user:
|
||||
security:
|
||||
image:
|
||||
course:
|
||||
default: https://u-pre.boe.com/pc/images/bgimg/course.png
|
||||
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
|
||||
@@ -74,4 +74,3 @@ 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
|
||||
@@ -1,13 +1,13 @@
|
||||
# application-pro.yml
|
||||
# application-dev.yml
|
||||
spring:
|
||||
redis:
|
||||
database: 1
|
||||
host: 192.168.0.253
|
||||
password: boe@123
|
||||
database: 2
|
||||
port: 6379
|
||||
host: 192.168.0.101
|
||||
password: boe@123
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
ddl-auto: none
|
||||
open-in-view: false
|
||||
properties:
|
||||
hibernate:
|
||||
@@ -16,44 +16,39 @@ spring:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
db1:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://192.168.0.253:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
jdbc-url: jdbc:mysql://192.168.0.101:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: boe#1234A
|
||||
db2:
|
||||
driverClassName: com.mysql.jdbc.Driver
|
||||
jdbc-url: jdbc:mysql://192.168.0.253:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
jdbc-url: jdbc:mysql://192.168.0.101:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
username: root
|
||||
password: boe#1234A
|
||||
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/java/static
|
||||
web:
|
||||
resources:
|
||||
static-locations: file:E:/Projects/BOE/java/static
|
||||
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
hibernate:
|
||||
SQL: ERROR
|
||||
# type:
|
||||
# descriptor:
|
||||
# sql:
|
||||
# BasicBinder: TRACE
|
||||
SQL: DEBUG
|
||||
type:
|
||||
descriptor:
|
||||
sql:
|
||||
BasicBinder: TRACE
|
||||
config: classpath:log/logback-dev.xml
|
||||
|
||||
|
||||
|
||||
xboe:
|
||||
api:
|
||||
cross_filter: true
|
||||
upload:
|
||||
file:
|
||||
temp_path: /tmp
|
||||
save_path: /home/www/elearning/upload
|
||||
http_path: http://192.168.0.253/upload
|
||||
temp_path: E:/Projects/BOE/java/static/temp
|
||||
save_path: E:/Projects/BOE/java/static/upload
|
||||
http_path: http://localhost:9090/upload
|
||||
inner:
|
||||
data:
|
||||
sync:
|
||||
baseurl: http://127.0.0.1:9090
|
||||
baseurl: http://localhost:9090
|
||||
|
||||
jasypt:
|
||||
encryptor:
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
-- 数据迁移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;
|
||||
@@ -1,187 +0,0 @@
|
||||
# 数据迁移方案文档
|
||||
|
||||
## 一、迁移概述
|
||||
|
||||
本次迁移涉及两个数据迁移任务:
|
||||
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