|
|
@@ -157,6 +157,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
private ICourseHandoutsService iCourseHandoutsService;
|
|
|
@Autowired
|
|
|
private ICourseHandoutsBusinessService iCourseHandoutsBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseFileService iCourseFileService;
|
|
|
|
|
|
@Autowired
|
|
|
private ICourseEducationTierService iCourseEducationTierService;
|
|
|
@@ -497,6 +499,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getCoverUrl()), Goods::getCoverUrl, bo.getCoverUrl());
|
|
|
lqw.eq(bo.getClassHours() != null, Goods::getClassHours, bo.getClassHours());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getStandPriceJson()), Goods::getStandPriceJson, bo.getStandPriceJson());
|
|
|
+ lqw.in(bo.getGoodsIds() != null, Goods::getGoodsId, bo.getGoodsIds());
|
|
|
return entity2Vo(this.list(lqw));
|
|
|
}
|
|
|
|
|
|
@@ -571,7 +574,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
menuListAddBo.setMenuList(bo.getMenuList());
|
|
|
iCourseMenuService.insertByGoodsAddBo(menuListAddBo);
|
|
|
}
|
|
|
-
|
|
|
+ Long goodsId = add.getGoodsId();
|
|
|
//七大员商品,默认绑定七大员学员资料模板
|
|
|
CourseEducationType educationType = iCourseEducationTypeService.getById(add.getEducationTypeId());
|
|
|
CourseBusiness business = iCourseBusinessService.getById(add.getBusinessId());
|
|
|
@@ -587,9 +590,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
.eq(ProfileTp::getStatus,1));
|
|
|
profileTpList.forEach(item -> {
|
|
|
if (StringUtils.isNotBlank(item.getGoodsIds())){
|
|
|
- List<String> goodsIds = Arrays.asList(item.getGoodsIds().split(","));
|
|
|
- goodsIds.add(add.getGoodsId().toString());
|
|
|
- item.setGoodsIds(goodsIds.stream().collect(Collectors.joining(",")));
|
|
|
+ String ids = item.getGoodsIds();
|
|
|
+ item.setGoodsIds(ids+","+goodsId);
|
|
|
}
|
|
|
});
|
|
|
iProfileTpService.updateBatchById(profileTpList);
|
|
|
@@ -737,20 +739,20 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
|
|
|
//修改商品课程节观看权限
|
|
|
- /* List<CourseMenuAddBo> menuList = bo.getMenuList();
|
|
|
- if (CollectionUtils.isEmpty(menuList)) {
|
|
|
- //商品下没有课程/节
|
|
|
- iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
|
|
|
- .set(CourseSectionWatchPer::getStatus, 0)
|
|
|
- .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId()));
|
|
|
- } else {
|
|
|
- //对比观看权限
|
|
|
- List<Long> courseIds = menuList.stream().map(CourseMenuAddBo::getCourseId).collect(Collectors.toList());
|
|
|
- iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
|
|
|
- .set(CourseSectionWatchPer::getStatus, 0)
|
|
|
- .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
|
|
|
- .notIn(CourseSectionWatchPer::getCourseId, courseIds));
|
|
|
- }*/
|
|
|
+// List<CourseMenuAddBo> menuList = bo.getMenuList();
|
|
|
+// if (CollectionUtils.isEmpty(menuList)) {
|
|
|
+// //商品下没有课程/节
|
|
|
+// iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
|
|
|
+// .set(CourseSectionWatchPer::getStatus, 0)
|
|
|
+// .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId()));
|
|
|
+// } else {
|
|
|
+// //对比观看权限
|
|
|
+// List<Long> courseIds = menuList.stream().map(CourseMenuAddBo::getCourseId).collect(Collectors.toList());
|
|
|
+// iCourseSectionWatchPerService.update(new LambdaUpdateWrapper<CourseSectionWatchPer>()
|
|
|
+// .set(CourseSectionWatchPer::getStatus, 0)
|
|
|
+// .eq(CourseSectionWatchPer::getGoodsId, bo.getGoodsId())
|
|
|
+// .notIn(CourseSectionWatchPer::getCourseId, courseIds));
|
|
|
+// }
|
|
|
|
|
|
return this.updateById(update);
|
|
|
}
|
|
|
@@ -1518,10 +1520,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
if (ObjectUtil.isNotNull(courseHandouts)){
|
|
|
Long oid = courseHandouts.getHandoutsId();
|
|
|
Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId);
|
|
|
-// CourseHandouts newCourseHandouts = iCourseHandoutsService.getHandoutsByTenant(courseHandouts.getEncoder(),newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newId)){
|
|
|
- goods.setHandoutsId(newId);
|
|
|
- }else {
|
|
|
+ if (ObjectUtil.isNull(newId)){
|
|
|
//讲义业务层次
|
|
|
List<CourseHandoutsBusiness> handoutsBusinessList = iCourseHandoutsBusinessService
|
|
|
.list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
|
|
|
@@ -1529,6 +1528,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
courseHandouts.setHandoutsId(null);
|
|
|
courseHandouts.setTenantId(newTenantId);
|
|
|
iCourseHandoutsService.save(courseHandouts);
|
|
|
+ newId = courseHandouts.getHandoutsId();
|
|
|
addSysGoodsRecord(oid,courseHandouts.getHandoutsId(),GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId,recordList);
|
|
|
goods.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
if (CollectionUtils.isNotEmpty(handoutsBusinessList)){
|
|
|
@@ -1548,6 +1548,14 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
iCourseHandoutsBusinessService.saveBatch(collect);
|
|
|
}
|
|
|
}
|
|
|
+ goods.setHandoutsId(newId);
|
|
|
+ //讲义文件
|
|
|
+ iCourseFileService.deleteByTenant(newId,newTenantId);
|
|
|
+ List<CourseFile> courseFileList = iCourseFileService.list(new LambdaQueryWrapper<CourseFile>().eq(CourseFile::getHandoutsId, oid).eq(CourseFile::getStatus, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(courseFileList)){
|
|
|
+ //重新添加讲义文件
|
|
|
+ handleCourseFile(courseFileList,newId,newTenantId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1751,6 +1759,37 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private void handleCourseFile(List<CourseFile> courseFileList, Long newId, Long newTenantId) {
|
|
|
+ //父级
|
|
|
+ List<CourseFile> collect = courseFileList.stream().filter(x -> ObjectUtils.isNull(x.getParentId()) || x.getParentId() == 0).collect(Collectors.toList());
|
|
|
+ List<CourseFile> collect1 = courseFileList.stream().filter(x -> ObjectUtils.isNotNull(x.getParentId()) && x.getParentId() != 0).collect(Collectors.toList());
|
|
|
+ for (CourseFile item : collect) {
|
|
|
+ item.setOldId(item.getFileId());
|
|
|
+ item.setFileId(null);
|
|
|
+ item.setHandoutsId(newId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ iCourseFileService.save(item);
|
|
|
+ recursionHandle(item,collect1,newId,newTenantId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void recursionHandle(CourseFile file, List<CourseFile> courseFiles, Long newId, Long newTenantId) {
|
|
|
+ List<CourseFile> collect = courseFiles.stream().filter(x -> x.getParentId().equals(file.getOldId())).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(collect)){
|
|
|
+ for (CourseFile courseFile : collect) {
|
|
|
+ courseFile.setOldId(courseFile.getFileId());
|
|
|
+ courseFile.setFileId(null);
|
|
|
+ courseFile.setHandoutsId(newId);
|
|
|
+ courseFile.setTenantId(newTenantId);
|
|
|
+ courseFile.setParentId(file.getFileId());
|
|
|
+ iCourseFileService.save(courseFile);
|
|
|
+ recursionHandle(courseFile,courseFiles,newId,newTenantId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean goodsCopyOne(GoodsBatchCopyTenantBo bo){
|
|
|
|
|
|
log.info("一建商品复制开始:"+ DateUtils.getTime());
|
|
|
@@ -2575,15 +2614,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
.eq(CourseMenuExam::getCourseId, oldCourseId)
|
|
|
.eq(CourseMenuExam::getModuleId, oldModuleId));
|
|
|
if (CollectionUtils.isNotEmpty(examList)){
|
|
|
+ List<CourseMenuExam> newCourseExams = new ArrayList<>();
|
|
|
for (CourseMenuExam menuExam : examList) {
|
|
|
- if (ObjectUtils.isNotNull(menuExam.getChapterId()) || menuExam.getChapterId() != 0){
|
|
|
+ if (ObjectUtils.isNotNull(menuExam.getChapterId()) && menuExam.getChapterId() != 0){
|
|
|
Long newChapterId = getNewIdByTenant(menuExam.getChapterId(),GoodsCopyEnum.COURSE_CHAPTER.getType(),newTenantId);
|
|
|
if (ObjectUtils.isNull(newChapterId)){
|
|
|
continue;
|
|
|
}
|
|
|
menuExam.setChapterId(newChapterId);
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(menuExam.getSectionId()) || menuExam.getSectionId() != 0){
|
|
|
+ if (ObjectUtils.isNotNull(menuExam.getSectionId()) && menuExam.getSectionId() != 0){
|
|
|
Long newSectionId = getNewIdByTenant(menuExam.getSectionId(),GoodsCopyEnum.COURSE_SECTION.getType(),newTenantId);
|
|
|
if (ObjectUtils.isNull(newSectionId)){
|
|
|
continue;
|
|
|
@@ -2595,8 +2635,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
menuExam.setModuleId(newModuleId);
|
|
|
menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,array));
|
|
|
menuExam.setTenantId(newTenantId);
|
|
|
+ newCourseExams.add(menuExam);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(newCourseExams)){
|
|
|
+ iCourseMenuExamService.saveBatch(newCourseExams);
|
|
|
}
|
|
|
- iCourseMenuExamService.saveBatch(examList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2653,6 +2696,131 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private void disposeChapter(Long oldChapterId,Long oldModuleId,Long newTenantId,Long oldCourseId,Long newCourseId,List<SysGoodsCopyRecord> array){
|
|
|
+ CourseChapter chapter = iCourseChapterService.getById(oldChapterId);
|
|
|
+ if (ObjectUtils.isNotNull(chapter)){
|
|
|
+ Long oid = chapter.getChapterId();
|
|
|
+ Long newChapterId = getNewIdByTenant(oid,GoodsCopyEnum.COURSE_CHAPTER.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newChapterId)){
|
|
|
+ chapter.setChapterId(null);
|
|
|
+ chapter.setTenantId(newTenantId);
|
|
|
+ iCourseChapterService.save(chapter);
|
|
|
+ newChapterId = chapter.getChapterId();
|
|
|
+ addSysGoodsRecord(oid,newChapterId,GoodsCopyEnum.COURSE_CHAPTER.getType(),newTenantId,array);
|
|
|
+ }
|
|
|
+ //删除之前的关联
|
|
|
+ iCourseChapterBusinessService.deleteByIdAndTenant(newChapterId,newTenantId);
|
|
|
+ //新关联
|
|
|
+ List<CourseChapterBusiness> chapterBusinessList = iCourseChapterBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<CourseChapterBusiness>()
|
|
|
+ .eq(CourseChapterBusiness::getChapterId, oldChapterId));
|
|
|
+ if (CollectionUtils.isNotEmpty(chapterBusinessList)){
|
|
|
+ for (CourseChapterBusiness item : chapterBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setChapterId(newChapterId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId,array));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
+ }
|
|
|
+ iCourseChapterBusinessService.saveBatch(chapterBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //章节关联
|
|
|
+ iCourseChapterSectionService.deleteByIdAndTenant(newChapterId,newTenantId);
|
|
|
+ List<CourseChapterSection> chapterSectionList = iCourseChapterSectionService
|
|
|
+ .list(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
+ .eq(CourseChapterSection::getChapterId, oldChapterId));
|
|
|
+ if (CollectionUtils.isNotEmpty(chapterSectionList)){
|
|
|
+ for (CourseChapterSection item : chapterSectionList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setChapterId(newChapterId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setSectionId(getNewSectionId(item.getSectionId(),newTenantId,array));
|
|
|
+ }
|
|
|
+ iCourseChapterSectionService.saveBatch(chapterSectionList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotNull(oldModuleId)){
|
|
|
+ //模块章关联
|
|
|
+ Long newModuleId = getNewIdByTenant(oldModuleId,GoodsCopyEnum.COURSE_MODULE.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newModuleId)){
|
|
|
+ throw new CustomException("当前章节模块在对应机构不存在,请检查!");
|
|
|
+ }
|
|
|
+ CourseModuleChapter moduleChapter = iCourseModuleChapterService.getByTenant(newModuleId,newChapterId,newTenantId);
|
|
|
+ if (ObjectUtils.isNull(moduleChapter)){
|
|
|
+ //不存在就新增
|
|
|
+ CourseModuleChapter oldEntity = iCourseModuleChapterService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseModuleChapter>()
|
|
|
+ .eq(CourseModuleChapter::getModuleId, oldModuleId)
|
|
|
+ .eq(CourseModuleChapter::getChapterId, oldChapterId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(oldEntity)){
|
|
|
+ oldEntity.setId(null);
|
|
|
+ oldEntity.setModuleId(newModuleId);
|
|
|
+ oldEntity.setChapterId(newChapterId);
|
|
|
+ oldEntity.setTenantId(newTenantId);
|
|
|
+ iCourseModuleChapterService.save(oldEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //课程章试卷
|
|
|
+ iCourseMenuExamService.deleteChapterByIdTenant(newCourseId,newModuleId,newChapterId,newTenantId);
|
|
|
+ List<CourseMenuExam> examList = iCourseMenuExamService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenuExam>()
|
|
|
+ .eq(CourseMenuExam::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenuExam::getModuleId, oldModuleId)
|
|
|
+ .eq(CourseMenuExam::getChapterId,oldChapterId));
|
|
|
+ if (CollectionUtils.isNotEmpty(examList)){
|
|
|
+ List<CourseMenuExam> newCourseExams = new ArrayList<>();
|
|
|
+ for (CourseMenuExam menuExam : examList) {
|
|
|
+ if (ObjectUtils.isNotNull(menuExam.getSectionId()) && menuExam.getSectionId() != 0){
|
|
|
+ Long newSectionId = getNewIdByTenant(menuExam.getSectionId(),GoodsCopyEnum.COURSE_SECTION.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newSectionId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ menuExam.setSectionId(newSectionId);
|
|
|
+ }
|
|
|
+ menuExam.setId(null);
|
|
|
+ menuExam.setCourseId(newCourseId);
|
|
|
+ menuExam.setModuleId(newModuleId);
|
|
|
+ menuExam.setChapterId(newChapterId);
|
|
|
+ menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,array));
|
|
|
+ menuExam.setTenantId(newTenantId);
|
|
|
+ newCourseExams.add(menuExam);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(newCourseExams)){
|
|
|
+ iCourseMenuExamService.saveBatch(newCourseExams);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //课程章关联
|
|
|
+ List<CourseMenu> courseMenus = iCourseMenuService.selectByNotTenant(newCourseId,2,newChapterId,newTenantId);
|
|
|
+ if (CollectionUtils.isEmpty(courseMenus)){
|
|
|
+ //新增
|
|
|
+ List<CourseMenu> list = iCourseMenuService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .eq(CourseMenu::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenu::getMenuId, oldChapterId)
|
|
|
+ .eq(CourseMenu::getType, 2));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ for (CourseMenu item : list) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCourseId(newCourseId);
|
|
|
+ item.setMenuId(newChapterId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ iCourseMenuService.saveBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Long getNewSectionId(Long oldSectionId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
CourseSection section = iCourseSectionService.getById(oldSectionId);
|
|
|
if (ObjectUtils.isNotNull(section)){
|
|
|
@@ -2689,6 +2857,109 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private void disposeSection(Long oldSectionId,Long oldChapterId,Long oldModuleId,Long newTenantId,Long oldCourseId,Long newCourseId,List<SysGoodsCopyRecord> array){
|
|
|
+ CourseSection section = iCourseSectionService.getById(oldSectionId);
|
|
|
+ if (ObjectUtils.isNotNull(section)){
|
|
|
+ Long oid = section.getSectionId();
|
|
|
+ Long newSectionId = getNewIdByTenant(oid,GoodsCopyEnum.COURSE_SECTION.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newSectionId)){
|
|
|
+ //新增
|
|
|
+ section.setSectionId(null);
|
|
|
+ section.setTenantId(newTenantId);
|
|
|
+ iCourseSectionService.save(section);
|
|
|
+ newSectionId = section.getSectionId();
|
|
|
+ addSysGoodsRecord(oid,newSectionId,GoodsCopyEnum.COURSE_SECTION.getType(),newTenantId,array);
|
|
|
+ }
|
|
|
+ //删除之前的关联
|
|
|
+ iCourseSectionBusinessService.deleteByIdAndTenant(newSectionId,newTenantId);
|
|
|
+ //新关联
|
|
|
+ List<CourseSectionBusiness> sectionBusinessList = iCourseSectionBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<CourseSectionBusiness>()
|
|
|
+ .eq(CourseSectionBusiness::getSectionId, oldSectionId));
|
|
|
+ if (CollectionUtils.isNotEmpty(sectionBusinessList)){
|
|
|
+ for (CourseSectionBusiness item : sectionBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setSectionId(newSectionId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId,array));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
+ }
|
|
|
+ iCourseSectionBusinessService.saveBatch(sectionBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotNull(oldChapterId)){
|
|
|
+ //模块章节关联
|
|
|
+ Long newChapterId = getNewIdByTenant(oldChapterId,GoodsCopyEnum.COURSE_CHAPTER.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newChapterId)){
|
|
|
+ throw new CustomException("当前章节在对应机构不存在,请检查!");
|
|
|
+ }
|
|
|
+ CourseChapterSection moduleChapter = iCourseChapterSectionService.getByTenant(newChapterId,newSectionId,newTenantId);
|
|
|
+ if (ObjectUtils.isNull(moduleChapter)){
|
|
|
+ //不存在就新增
|
|
|
+ CourseChapterSection oldEntity = iCourseChapterSectionService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
+ .eq(CourseChapterSection::getChapterId, oldChapterId)
|
|
|
+ .eq(CourseChapterSection::getSectionId, oldSectionId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(oldEntity)){
|
|
|
+ oldEntity.setId(null);
|
|
|
+ oldEntity.setSectionId(newSectionId);
|
|
|
+ oldEntity.setChapterId(newChapterId);
|
|
|
+ oldEntity.setTenantId(newTenantId);
|
|
|
+ iCourseChapterSectionService.save(oldEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long newModuleId = getNewIdByTenant(oldModuleId,GoodsCopyEnum.COURSE_MODULE.getType(),newTenantId);
|
|
|
+ //课程章试卷
|
|
|
+ iCourseMenuExamService.deleteSectionByIdTenant(newCourseId,newModuleId,newChapterId,newSectionId,newTenantId);
|
|
|
+ List<CourseMenuExam> examList = iCourseMenuExamService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenuExam>()
|
|
|
+ .eq(CourseMenuExam::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenuExam::getModuleId, oldModuleId)
|
|
|
+ .eq(CourseMenuExam::getChapterId,oldChapterId)
|
|
|
+ .eq(CourseMenuExam::getSectionId,oldSectionId));
|
|
|
+ if (CollectionUtils.isNotEmpty(examList)){
|
|
|
+ for (CourseMenuExam menuExam : examList) {
|
|
|
+ menuExam.setSectionId(newSectionId);
|
|
|
+ menuExam.setId(null);
|
|
|
+ menuExam.setCourseId(newCourseId);
|
|
|
+ menuExam.setModuleId(newModuleId);
|
|
|
+ menuExam.setChapterId(newChapterId);
|
|
|
+ menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,array));
|
|
|
+ menuExam.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ iCourseMenuExamService.saveBatch(examList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //课程节关联
|
|
|
+ List<CourseMenu> courseMenus = iCourseMenuService.selectByNotTenant(newCourseId,3,newSectionId,newTenantId);
|
|
|
+ if (CollectionUtils.isEmpty(courseMenus)){
|
|
|
+ //新增
|
|
|
+ List<CourseMenu> list = iCourseMenuService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .eq(CourseMenu::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenu::getMenuId, oldChapterId)
|
|
|
+ .eq(CourseMenu::getType, 2));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ for (CourseMenu item : list) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCourseId(newCourseId);
|
|
|
+ item.setMenuId(newSectionId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ iCourseMenuService.saveBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private Long getNewCertificateId(Long certificateId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
|
if (ObjectUtils.isNotNull(certificateCommon)){
|
|
|
@@ -4534,13 +4805,13 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public boolean goodsNodeCopyAddTenant(GoodsNodeCopyTenantBo bo) {
|
|
|
Goods goods = getById(bo.getGoodsId());
|
|
|
if (ObjectUtils.isNull(goods)){
|
|
|
throw new CustomException("商品信息获取有误");
|
|
|
}
|
|
|
Long oldGoodsId = goods.getGoodsId();
|
|
|
- String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
switch (bo.getType()){
|
|
|
case 1://课程复制
|
|
|
bo.getTenantId().forEach(newTenantId -> {
|
|
|
@@ -4587,14 +4858,94 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
if (ObjectUtils.isNull(newCourseId)){
|
|
|
throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
|
}
|
|
|
-// disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
+ disposeChapter(bo.getChapterId(),bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
});
|
|
|
break;
|
|
|
+ case 4://节复制
|
|
|
+ Course courseSection = iCourseService.getById(bo.getCourseId());
|
|
|
+ bo.getTenantId().forEach(newTenantId -> {
|
|
|
+ List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
+ Long newCourseId = iCourseService.getCourseByTenantTwo(courseSection.getCourseName(), courseSection.getCode(), newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newCourseId)){
|
|
|
+ throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
|
+ }
|
|
|
+ disposeSection(bo.getSectionId(),bo.getChapterId(),bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public Goods queryGoodsByIdTenant(Long goodsId, Long tenantId) {
|
|
|
+ return baseMapper.queryGoodsByIdTenant(goodsId,tenantId);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean goodsHandoutsCopyAddTenant(GoodsHandoutsCopyTenantBo bo) {
|
|
|
+ CourseHandouts handouts = iCourseHandoutsService.getById(bo.getHandoutsId());
|
|
|
+ if (ObjectUtils.isNull(handouts)){
|
|
|
+ throw new CustomException("讲义不存在,请检查!");
|
|
|
}
|
|
|
+ List<SysGoodsCopyRecord> array = new ArrayList<>();
|
|
|
+
|
|
|
+ Long oldId = handouts.getHandoutsId();
|
|
|
+ Goods goods = getById(bo.getGoodsId());
|
|
|
+ for (Long tenantId : bo.getTenantId()) {
|
|
|
+ //讲义复制
|
|
|
+ Goods goodsTwo = baseMapper.getGoodsByTenantTwo(goods.getGoodsName(), goods.getCode(), tenantId);
|
|
|
+ if (ObjectUtils.isNull(goodsTwo)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Long> goodsIds = iCourseHandoutsService.getGoodsIds(goodsTwo.getHandoutsId(),tenantId);
|
|
|
+ if (goodsIds.stream().allMatch(x -> x.equals(goodsTwo.getGoodsId()))){
|
|
|
+ //删除讲义
|
|
|
+ iCourseHandoutsService.removeHandouts(goodsTwo.getHandoutsId(),tenantId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增
|
|
|
+ handouts.setHandoutsId(null);
|
|
|
+ handouts.setTenantId(tenantId);
|
|
|
+ iCourseHandoutsService.save(handouts);
|
|
|
+ Long newId = handouts.getHandoutsId();
|
|
|
+
|
|
|
+ //业务层次
|
|
|
+ List<CourseHandoutsBusiness> list = iCourseHandoutsBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
|
|
|
+ .eq(CourseHandoutsBusiness::getHandoutsId, oldId));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ List<CourseHandoutsBusiness> collect = list.stream().map(business -> {
|
|
|
+ business.setId(null);
|
|
|
+ business.setTenantId(tenantId);
|
|
|
+ //项目
|
|
|
+ business.setEducationId(getNewEducationTypeId(business.getEducationId(), tenantId,array));
|
|
|
+ //业务
|
|
|
+ business.setBusinessId(getNewBusinessId(business.getBusinessId(), tenantId,array));
|
|
|
+ //科目
|
|
|
+ business.setSubjectId(getNewSubjectId(business.getSubjectId(), tenantId,array));
|
|
|
+ //讲义
|
|
|
+ business.setHandoutsId(newId);
|
|
|
+ return business;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ iCourseHandoutsBusinessService.saveBatch(collect);
|
|
|
+ }
|
|
|
+
|
|
|
+ //讲义文件
|
|
|
+ List<CourseFile> courseFileList = iCourseFileService.list(new LambdaQueryWrapper<CourseFile>().eq(CourseFile::getHandoutsId, oldId).eq(CourseFile::getStatus, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(courseFileList)){
|
|
|
+ //重新添加讲义文件
|
|
|
+ handleCourseFile(courseFileList,newId,tenantId);
|
|
|
+ }
|
|
|
+
|
|
|
+ updateHandoutsId(goodsTwo.getGoodsId(),tenantId,newId);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
+ private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
|
|
|
+ baseMapper.updateHandoutsId(goodsId,tenantId,handoutsId);
|
|
|
}
|
|
|
|
|
|
@Override
|