@@ -15,9 +15,12 @@ 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 com.xboe.api.ThirdApi ;
import com.xboe.core.orm.* ;
import com.xboe.module.course.dao.* ;
import com.xboe.module.course.entity.* ;
import com.xboe.school.study.dao.StudyCourseDao ;
import com.xboe.school.study.entity.StudyCourse ;
import org.apache.commons.lang3.StringUtils ;
@@ -41,24 +44,9 @@ import com.xboe.common.beans.KeyValue;
import com.xboe.common.utils.IDGenerator ;
import com.xboe.common.utils.StringUtil ;
import com.xboe.core.event.IEventDataSender ;
import com.xboe.module.course.dao.CourseContentDao ;
import com.xboe.module.course.dao.CourseCrowdDao ;
import com.xboe.module.course.dao.CourseDao ;
import com.xboe.module.course.dao.CourseExamDao ;
import com.xboe.module.course.dao.CourseHRBPAuditDao ;
import com.xboe.module.course.dao.CourseHomeWorkDao ;
import com.xboe.module.course.dao.CourseSectionDao ;
import com.xboe.module.course.dao.CourseTeacherDao ;
import com.xboe.module.course.dao.CourseUpdateLogDao ;
import com.xboe.module.course.dto.CourseFullDto ;
import com.xboe.module.course.dto.CourseQueryDto ;
import com.xboe.module.course.dto.RankingDto ;
import com.xboe.module.course.entity.Course ;
import com.xboe.module.course.entity.CourseCrowd ;
import com.xboe.module.course.entity.CourseHRBPAudit ;
import com.xboe.module.course.entity.CourseSection ;
import com.xboe.module.course.entity.CourseTeacher ;
import com.xboe.module.course.entity.CourseUpdateLog ;
import com.xboe.module.course.service.ICourseFullTextSearch ;
import com.xboe.module.course.service.ICourseService ;
import com.xboe.module.interaction.service.ICourseGradeService ;
@@ -125,8 +113,9 @@ public class CourseServiceImpl implements ICourseService {
@Resource
RestHighLevelClient restHighLevelClient ;
@Resource
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao ;
/**
* 生成过滤条件
*
@@ -183,7 +172,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 ) ) ;
}
@@ -281,13 +270,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) {
@@ -367,8 +356,9 @@ 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 +415,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 ( ) ) ;
@@ -868,7 +858,7 @@ public class CourseServiceImpl implements ICourseService {
}
// 删除ES数据
deletedStudyResourceBatchByCourseIdAndType ( id , c . getType ( ) ) ;
deletedStudyResourceBatchByCourseIdAndType ( id , c . getType ( ) ) ;
} else {
//彻底删除,课件设置为无课程状态
courseDao . setDeleted ( id ) ;
@@ -1002,6 +992,8 @@ 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 ( ) ) {
@@ -1056,6 +1048,8 @@ 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 ( ) ) {
@@ -1091,6 +1085,8 @@ 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 ( ) ) {
@@ -2013,4 +2009,25 @@ 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 ) ;
}
}
}