|
@@ -2612,6 +2612,127 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
}
|
|
}
|
|
return null;
|
|
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)){
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ iCourseMenuExamService.saveBatch(examList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }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){
|
|
private Long getNewSectionId(Long oldSectionId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
CourseSection section = iCourseSectionService.getById(oldSectionId);
|
|
CourseSection section = iCourseSectionService.getById(oldSectionId);
|
|
if (ObjectUtils.isNotNull(section)){
|
|
if (ObjectUtils.isNotNull(section)){
|
|
@@ -2648,6 +2769,109 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
}
|
|
}
|
|
return null;
|
|
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){
|
|
private Long getNewCertificateId(Long certificateId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
if (ObjectUtils.isNotNull(certificateCommon)){
|
|
if (ObjectUtils.isNotNull(certificateCommon)){
|
|
@@ -4493,13 +4717,13 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional
|
|
public boolean goodsNodeCopyAddTenant(GoodsNodeCopyTenantBo bo) {
|
|
public boolean goodsNodeCopyAddTenant(GoodsNodeCopyTenantBo bo) {
|
|
Goods goods = getById(bo.getGoodsId());
|
|
Goods goods = getById(bo.getGoodsId());
|
|
if (ObjectUtils.isNull(goods)){
|
|
if (ObjectUtils.isNull(goods)){
|
|
throw new CustomException("商品信息获取有误");
|
|
throw new CustomException("商品信息获取有误");
|
|
}
|
|
}
|
|
Long oldGoodsId = goods.getGoodsId();
|
|
Long oldGoodsId = goods.getGoodsId();
|
|
- String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
|
switch (bo.getType()){
|
|
switch (bo.getType()){
|
|
case 1://课程复制
|
|
case 1://课程复制
|
|
bo.getTenantId().forEach(newTenantId -> {
|
|
bo.getTenantId().forEach(newTenantId -> {
|
|
@@ -4546,14 +4770,24 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
if (ObjectUtils.isNull(newCourseId)){
|
|
if (ObjectUtils.isNull(newCourseId)){
|
|
throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
}
|
|
}
|
|
-// disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
|
|
|
+ disposeChapter(bo.getChapterId(),bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
});
|
|
});
|
|
break;
|
|
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 false;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|