|
|
@@ -1625,7 +1625,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
disposeGoodsCourse(oldGoodsId,newGoodsId,newTenantId,newCourseMenuExamList,recordList);
|
|
|
//课程双师
|
|
|
disposeGoodsCourseTeacher(oldGoodsId,newGoodsId,newTenantId);
|
|
|
- //商品试卷
|
|
|
+ //题库商品
|
|
|
disposeGoodsAttached(oldGoodsId,newGoodsId,newTenantId,recordList);
|
|
|
|
|
|
//处理商品试卷
|
|
|
@@ -2461,6 +2461,106 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ private void disposeModule(Long oldModuleId,Long newTenantId,Long oldCourseId,Long newCourseId,List<SysGoodsCopyRecord> array){
|
|
|
+ CourseModule module = iCourseModuleService.getById(oldModuleId);
|
|
|
+ if (ObjectUtils.isNotNull(module)){
|
|
|
+ Long oid = module.getModuleId();
|
|
|
+ Long newModuleId = getNewIdByTenant(oid,GoodsCopyEnum.COURSE_MODULE.getType(),newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newModuleId)){
|
|
|
+ module.setModuleId(null);
|
|
|
+ module.setTenantId(newTenantId);
|
|
|
+ iCourseModuleService.save(module);
|
|
|
+ newModuleId = module.getModuleId();
|
|
|
+ addSysGoodsRecord(oid,newModuleId,GoodsCopyEnum.COURSE_MODULE.getType(),newTenantId,array);
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除之前的关联
|
|
|
+ iCourseModuleBusinessService.deleteByIdAndTenant(newModuleId,newTenantId);
|
|
|
+ //新关联
|
|
|
+ List<CourseModuleBusiness> moduleBusinessList = iCourseModuleBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<CourseModuleBusiness>()
|
|
|
+ .eq(CourseModuleBusiness::getModuleId, oldModuleId));
|
|
|
+ if (CollectionUtils.isNotEmpty(moduleBusinessList)){
|
|
|
+ for (CourseModuleBusiness item : moduleBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setModuleId(newModuleId);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ iCourseModuleBusinessService.saveBatch(moduleBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //模块章
|
|
|
+ iCourseModuleChapterService.deleteByIdAndTenant(newModuleId,newTenantId);
|
|
|
+ List<CourseModuleChapter> moduleChapterList = iCourseModuleChapterService
|
|
|
+ .list(new LambdaQueryWrapper<CourseModuleChapter>()
|
|
|
+ .eq(CourseModuleChapter::getModuleId, oldModuleId));
|
|
|
+ if (CollectionUtils.isNotEmpty(moduleChapterList)){
|
|
|
+ for (CourseModuleChapter item : moduleChapterList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setModuleId(newModuleId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setChapterId(getNewChapterId(item.getChapterId(),newTenantId,array));
|
|
|
+ }
|
|
|
+ iCourseModuleChapterService.saveBatch(moduleChapterList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //课程模块关联
|
|
|
+ List<CourseMenu> courseMenus = iCourseMenuService.selectByNotTenant(newCourseId,1,newModuleId,newTenantId);
|
|
|
+ if (CollectionUtils.isEmpty(courseMenus)){
|
|
|
+ List<CourseMenu> list = iCourseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .eq(CourseMenu::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenu::getMenuId, oid)
|
|
|
+ .eq(CourseMenu::getType, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ for (CourseMenu item : list) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCourseId(newCourseId);
|
|
|
+ item.setMenuId(newModuleId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ iCourseMenuService.saveBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //课程模块试卷
|
|
|
+ iCourseMenuExamService.deleteModuleByIdTenant(newCourseId,newModuleId,newTenantId);
|
|
|
+ List<CourseMenuExam> examList = iCourseMenuExamService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenuExam>()
|
|
|
+ .eq(CourseMenuExam::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenuExam::getModuleId, oldModuleId));
|
|
|
+ if (CollectionUtils.isNotEmpty(examList)){
|
|
|
+ for (CourseMenuExam menuExam : examList) {
|
|
|
+ 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){
|
|
|
+ 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.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,array));
|
|
|
+ menuExam.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ iCourseMenuExamService.saveBatch(examList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private Long getNewChapterId(Long oldChapterId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
CourseChapter chapter = iCourseChapterService.getById(oldChapterId);
|
|
|
if (ObjectUtils.isNotNull(chapter)){
|
|
|
@@ -4394,7 +4494,64 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
@Override
|
|
|
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 -> {
|
|
|
+ Goods newGoods = getGoodsByTenantTwo(goods.getGoodsName(), goods.getCode(), newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newGoods)){
|
|
|
+ throw new CustomException("该机构不存在此商品,请先复制商品!");
|
|
|
+ }
|
|
|
+ Long newGoodsId = newGoods.getGoodsId();
|
|
|
+ //商品课程
|
|
|
+ List<CourseMenuExam> newCourseMenuExamList = new ArrayList<>();
|
|
|
+ List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
+ if (goods.getGoodsType() == 2){
|
|
|
+ //题库商品
|
|
|
+ disposeGoodsAttached(oldGoodsId,newGoodsId,newTenantId,recordList);
|
|
|
+ }else {
|
|
|
+ disposeGoodsCourse(oldGoodsId,newGoodsId,newTenantId,newCourseMenuExamList,recordList);
|
|
|
+ }
|
|
|
|
|
|
+ //处理商品试卷
|
|
|
+ if (CollectionUtils.isNotEmpty(newCourseMenuExamList)){
|
|
|
+ for (CourseMenuExam menuExam : newCourseMenuExamList) {
|
|
|
+ menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,recordList));
|
|
|
+ }
|
|
|
+ iCourseMenuExamService.saveBatch(newCourseMenuExamList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 2://模块复制
|
|
|
+ Course course = iCourseService.getById(bo.getCourseId());
|
|
|
+ bo.getTenantId().forEach(newTenantId -> {
|
|
|
+ List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
+ Long newCourseId = iCourseService.getCourseByTenantTwo(course.getCourseName(), course.getCode(), newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newCourseId)){
|
|
|
+ throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
|
+ }
|
|
|
+ disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 3://章复制
|
|
|
+ Course courseTwo = iCourseService.getById(bo.getCourseId());
|
|
|
+ bo.getTenantId().forEach(newTenantId -> {
|
|
|
+ List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
+ Long newCourseId = iCourseService.getCourseByTenantTwo(courseTwo.getCourseName(), courseTwo.getCode(), newTenantId);
|
|
|
+ if (ObjectUtils.isNull(newCourseId)){
|
|
|
+ throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
|
|
|
+ }
|
|
|
+// disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return false;
|
|
|
}
|