@ -63,7 +63,8 @@ import static org.apache.commons.lang3.StringUtils.join;
@Slf4j
public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService < TeacherOpenCourseMergeResourcesInfo > implements DeleteResourcesBy {
@Autowired private TeacherOpenCourseMergeResourcesInfoDao teacherOpenCourseMergeResourcesInfoDao ;
@Autowired
private TeacherOpenCourseMergeResourcesInfoDao teacherOpenCourseMergeResourcesInfoDao ;
@Autowired
private ResourcesInfoService resourcesInfoService ;
@Autowired
@ -99,6 +100,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
throw new PlatformException ( "批量删除开课资源拉取失败" , e ) ;
}
}
public void logicDeleteTeacherOpenCourseMergeResourcesInfo ( String ids ) {
try {
teacherOpenCourseMergeResourcesInfoDao . logicDeleteTeacherOpenCourseMergeResourcesInfo ( ids ) ;
@ -115,7 +117,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
} catch ( Exception e ) {
try {
teacherOpenCourseMergeResourcesInfoList . add ( JSONObject . parseObject ( teacherOpenCourseMergeResourcesInfoQuery . getTeacherOpenCourseMergeResourcesInfoJsonStr ( ) , TeacherOpenCourseMergeResourcesInfo . class ) ) ;
} catch ( Exception e1 ) { }
} catch ( Exception e1 ) {
}
}
ToolUtils . deleteNullList ( teacherOpenCourseMergeResourcesInfoList ) ;
if ( null ! = teacherOpenCourseMergeResourcesInfoList & & teacherOpenCourseMergeResourcesInfoList . size ( ) > 0 ) {
@ -299,24 +302,19 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
if ( StringUtils . isBlank ( teacherOpenCourseMergeCourseInfoId ) ) {
errMsg . add ( new String [ ] { "第" + ToolUtils . numberToLetter ( map . get ( columns [ 0 ] ) + 1 ) + "列,第" + ( i + 1 ) + "行开课课程为空" } ) ;
continue ;
} else
if ( StringUtils . isBlank ( teacherOpenCourseId ) ) {
} else if ( StringUtils . isBlank ( teacherOpenCourseId ) ) {
errMsg . add ( new String [ ] { "第" + ToolUtils . numberToLetter ( map . get ( columns [ 1 ] ) + 1 ) + "列,第" + ( i + 1 ) + "行教师开课为空" } ) ;
continue ;
} else
if ( StringUtils . isBlank ( resourcesInfoName ) ) {
} else if ( StringUtils . isBlank ( resourcesInfoName ) ) {
errMsg . add ( new String [ ] { "第" + ToolUtils . numberToLetter ( map . get ( columns [ 2 ] ) + 1 ) + "列,第" + ( i + 1 ) + "行资源名称为空" } ) ;
continue ;
} else
if ( StringUtils . isBlank ( resourcesInfoType ) ) {
} else if ( StringUtils . isBlank ( resourcesInfoType ) ) {
errMsg . add ( new String [ ] { "第" + ToolUtils . numberToLetter ( map . get ( columns [ 3 ] ) + 1 ) + "列,第" + ( i + 1 ) + "行资源类型 数据字典为空" } ) ;
continue ;
} else
if ( StringUtils . isBlank ( resourcesInfoContent ) ) {
} else if ( StringUtils . isBlank ( resourcesInfoContent ) ) {
errMsg . add ( new String [ ] { "第" + ToolUtils . numberToLetter ( map . get ( columns [ 4 ] ) + 1 ) + "列,第" + ( i + 1 ) + "行资源内容为空" } ) ;
continue ;
} else
{
} else {
//TODO 保存
TeacherOpenCourseMergeResourcesInfo teacherOpenCourseMergeResourcesInfo = new TeacherOpenCourseMergeResourcesInfo ( ) ;
teacherOpenCourseMergeResourcesInfo . setTeacherOpenCourseMergeCourseInfoId ( Long . parseLong ( teacherOpenCourseMergeCourseInfoId ) ) ;
@ -399,11 +397,15 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
public void copyFromResourcesInfo ( Set < Long > resourcesInfoIds ,
@NotNull ( message = "开课ID不能为空! " ) final Long teacherOpenCourseId , Map < Long , Long > courseInfoIdPair ) {
if ( ObjectUtil . isEmpty ( resourcesInfoIds ) ) { return ; }
if ( ObjectUtil . isEmpty ( resourcesInfoIds ) ) {
return ;
}
ResourcesInfoQuery resourcesInfoQuery = new ResourcesInfoQuery ( ) ;
resourcesInfoQuery . setResourcesInfoIds ( join ( resourcesInfoIds . toArray ( ) , "," ) ) ;
List < ResourcesInfo > resourcesInfoList = resourcesInfoService . getValuesByQuery ( resourcesInfoQuery ) ;
if ( ObjectUtil . isEmpty ( resourcesInfoList ) ) { return ; }
if ( ObjectUtil . isEmpty ( resourcesInfoList ) ) {
return ;
}
// 拷贝部分字段映射
CopyOptions copyOptions = CopyOptions . create ( ) . setFieldMapping ( MapUtil . of ( "courseInfoId" , "teacherOpenCourseMergeCourseInfoId" ) ) ;
@ -422,13 +424,15 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/ * *
* 重 置 开 课 课 程 ID 。 需 要 拿 到 新 旧 改 变 的 关 系
*
* @param copyToList
* @param courseInfoIdPair
* /
public void resetNewId ( List < TeacherOpenCourseMergeResourcesInfo > copyToList , Map < Long , Long > courseInfoIdPair ) {
if ( ObjectUtil . isEmpty ( courseInfoIdPair ) ) { return ; }
if ( ObjectUtil . isEmpty ( courseInfoIdPair ) ) {
return ;
}
copyToList . forEach ( item - > {
item . setTeacherOpenCourseMergeResourcesInfoId ( null ) ;
item . setTeacherOpenCourseMergeCourseInfoId ( courseInfoIdPair . get ( item . getTeacherOpenCourseMergeCourseInfoId ( ) ) ) ;
} ) ;
@ -455,6 +459,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/ * *
* 验 证 操 作 的 数 据 , 是 否 是 教 师 本 人 上 传 的
*
* @param resourcesInfoIds
* @param coreUser
* /
@ -470,6 +475,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/ * *
* 位 置 移 动
* 小 于 0 的 数 字 , 是 代 表 置 顶 。 大 于 0 代 表 非 置 顶
*
* @param id
* @param moveType
* /
@ -502,7 +508,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
BigDecimal minLinkOrder = minOrderClientLink . getOrderIndex ( ) ;
// 置顶就现有的最小值减1。但是需要确保结果小于0
calcedOrder = NumberUtil . sub ( min ( minLinkOrder . floatValue ( ) , 0 ) , 1 ) ;
} break ;
}
break ;
case MOVE_LEFT : {
@ -532,7 +539,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
// 左移位后的值
calcedOrder = RandomUtil . randomDouble ( min . doubleValue ( ) , max . doubleValue ( ) , 6 , RoundingMode . HALF_UP ) ;
} break ;
}
break ;
case MOVE_RIGHT : {
@ -561,7 +569,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
// 右移位后的值
calcedOrder = RandomUtil . randomDouble ( min . doubleValue ( ) , max . doubleValue ( ) , 6 , RoundingMode . HALF_UP ) ;
} break ;
}
break ;
default :
log . error ( "不支持的移动类型!" ) ;
break ;
@ -586,12 +595,11 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
* @param id 拖 动 元 素 的 ID
* @param leftId 左 元 素 ID 偏 小 数 值 对 应 的 元 素 ID
* @param rightId 右 元 素 ID 偏 大 数 值 对 应 的 元 素 ID
*
* < p >
* 左 侧 ( 上 ) = = > 右 侧 ( 下 )
* 小 数 值 = = > 大 数 值
*
* < p >
* 数 值 越 小 , 越 靠 前
*
* @Author : 87966
* @Date : 2023 / 1 / 9 16 : 44
* /
@ -666,6 +674,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
updateTemplate ( updatePO ) ;
}
}
/ * *
* 根 据 指 定 的 课 程 ID 和 章 节 ID 集 合 , 去 从 系 统 资 源 拷 贝 到 开 课 资 源 库
*
@ -700,7 +709,9 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
public void copyFromOpenCourseResourcesInfo ( List < TeacherOpenCourseMergeResourcesInfo > resourcesInfoList ,
@NotNull ( message = "开课ID不能为空! " ) final Long teacherOpenCourseId , Map < Long , Long > courseInfoIdPair ) {
if ( CollectionUtil . isEmpty ( resourcesInfoList ) ) { return ; }
if ( CollectionUtil . isEmpty ( resourcesInfoList ) ) {
return ;
}
resourcesInfoList . forEach ( item - > {
item . setTeacherOpenCourseId ( teacherOpenCourseId ) ;
@ -708,6 +719,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
} ) ;
resetNewId ( resourcesInfoList , courseInfoIdPair ) ;
resourcesInfoList . forEach ( item - > item . setTeacherOpenCourseMergeResourcesInfoId ( null ) ) ;
// 批量插入资源和开课关联表
insertBatch ( resourcesInfoList ) ;