|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongzheng.modules.goods.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -1215,6 +1216,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public boolean goodsBatchCopyIncrementTenant(GoodsBatchCopyTenantBo bo) {
|
|
|
//获取商品信息
|
|
|
List<Goods> goodsList = list(new LambdaQueryWrapper<Goods>()
|
|
@@ -1226,12 +1228,18 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
Long newTenantId = bo.getTenantId();
|
|
|
List<GoodsSpecAttributeRelation> newRelationList = new ArrayList<>();
|
|
|
for (Goods goods : goodsList) {
|
|
|
+ Long oldGoodsId = goods.getGoodsId();
|
|
|
+ Long newGoodsId = 0L;
|
|
|
//判断商品是否存在
|
|
|
- GoodsVo newGoods = this.baseMapper.queryGoodsByIdTenant(goods.getGoodsId(),newTenantId);
|
|
|
+ Goods newGoods = this.baseMapper.queryGoodsByTenant(goods.getCode(),newTenantId);
|
|
|
if (ObjectUtils.isNull(newGoods)){
|
|
|
//不存在(新增)
|
|
|
goods.setGoodsId(null);
|
|
|
- goods.setTeacherId(newTenantId);
|
|
|
+ goods.setTenantId(newTenantId);
|
|
|
+ }else {
|
|
|
+ //修改
|
|
|
+ goods.setGoodsId(newGoods.getGoodsId());
|
|
|
+ goods.setTenantId(newTenantId);
|
|
|
}
|
|
|
|
|
|
//供应方ID
|
|
@@ -1257,7 +1265,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
payServe.setServeId(null);
|
|
|
payServe.setTenantId(newTenantId);
|
|
|
iPayServeService.save(payServe);
|
|
|
- supply.setServerId(newPayServer.getServeId());
|
|
|
+ supply.setServerId(payServe.getServeId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1271,62 +1279,12 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
//教育类型
|
|
|
if (ObjectUtil.isNotNull(goods.getEducationTypeId())){
|
|
|
- CourseEducationType type = iCourseEducationTypeService.getById(goods.getEducationTypeId());
|
|
|
- if (ObjectUtil.isNotNull(type)){
|
|
|
- CourseEducationType newType = iCourseEducationTypeService.getEducationTypeBytenant(type.getEncoder(),newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newType)){
|
|
|
- goods.setEducationTypeId(newType.getId());
|
|
|
- }else {
|
|
|
- type.setId(null);
|
|
|
- type.setTenantId(newTenantId);
|
|
|
- iCourseEducationTypeService.save(type);
|
|
|
- goods.setEducationTypeId(type.getId());
|
|
|
- }
|
|
|
- }
|
|
|
+ goods.setEducationTypeId(getNewEducationTypeId(goods.getEducationTypeId(),newTenantId));
|
|
|
}
|
|
|
|
|
|
//业务层次
|
|
|
if (ObjectUtil.isNotNull(goods.getBusinessId())){
|
|
|
- CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
|
|
|
- if (ObjectUtil.isNotNull(business)){
|
|
|
- CourseBusiness newBusiness = iCourseBusinessService.getBusinessByTenant(business.getEncoder(),newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newBusiness)){
|
|
|
- goods.setBusinessId(newBusiness.getId());
|
|
|
- }else {
|
|
|
- business.setId(null);
|
|
|
- business.setTenantId(newTenantId);
|
|
|
- //项目ID
|
|
|
- if (ObjectUtils.isNotNull(business.getProjectId())){
|
|
|
- CourseProjectType projectType = iCourseProjectTypeService.getById(business.getProjectId());
|
|
|
- if (ObjectUtil.isNotNull(projectType)){
|
|
|
- CourseProjectType newProject = iCourseProjectTypeService.getProjectByTenant(projectType.getEncoder(), newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newProject)){
|
|
|
- business.setProjectId(newProject.getId().intValue());
|
|
|
- }else {
|
|
|
- //新增项目
|
|
|
- //判断项目的教育类型是否存在
|
|
|
- CourseEducationType educationType = iCourseEducationTypeService.getById(projectType.getEducationId());
|
|
|
- CourseEducationType newEducationType = iCourseEducationTypeService.getEducationTypeBytenant(educationType.getEncoder(), newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newEducationType)){
|
|
|
- projectType.setEducationId(newEducationType.getId().intValue());
|
|
|
- }else {
|
|
|
- educationType.setId(null);
|
|
|
- educationType.setTenantId(newTenantId);
|
|
|
- iCourseEducationTypeService.save(educationType);
|
|
|
- projectType.setEducationId(educationType.getId().intValue());
|
|
|
- }
|
|
|
- projectType.setId(null);
|
|
|
- projectType.setTenantId(newTenantId);
|
|
|
- iCourseProjectTypeService.save(projectType);
|
|
|
- business.setProjectId(projectType.getId().intValue());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- iCourseBusinessService.save(business);
|
|
|
- goods.setBusinessId(business.getId());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ goods.setBusinessId(getNewBusinessId(goods.getBusinessId(),newTenantId));
|
|
|
}
|
|
|
|
|
|
//所属院校
|
|
@@ -1347,45 +1305,12 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
//所属专业
|
|
|
if (ObjectUtil.isNotNull(goods.getMajorId())){
|
|
|
- Major major = iMajorService.getById(goods.getMajorId());
|
|
|
- if (ObjectUtil.isNotNull(major)){
|
|
|
- Major newMajor = iMajorService.getMajorByTenant(major.getEncoder(),newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newMajor)){
|
|
|
- goods.setMajorId(newMajor.getId());
|
|
|
- }else {
|
|
|
- major.setId(null);
|
|
|
- major.setTenantId(newTenantId);
|
|
|
- iMajorService.save(major);
|
|
|
- goods.setMajorId(major.getId());
|
|
|
- }
|
|
|
- }
|
|
|
+ goods.setMajorId(getNewMajorId(goods.getMajorId(),newTenantId));
|
|
|
}
|
|
|
|
|
|
//项目
|
|
|
if (ObjectUtil.isNotNull(goods.getProjectId())){
|
|
|
- CourseProjectType project = iCourseProjectTypeService.getById(goods.getProjectId());
|
|
|
- if (ObjectUtil.isNotNull(project)){
|
|
|
- CourseProjectType newProject = iCourseProjectTypeService.getProjectByTenant(project.getEncoder(),newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newProject)){
|
|
|
- goods.setProjectId(newProject.getId().intValue());
|
|
|
- }else {
|
|
|
- project.setId(null);
|
|
|
- project.setTenantId(newTenantId);
|
|
|
- //判断项目的教育类型是否存在
|
|
|
- CourseEducationType educationType = iCourseEducationTypeService.getById(project.getEducationId());
|
|
|
- CourseEducationType newEducationType = iCourseEducationTypeService.getEducationTypeBytenant(educationType.getEncoder(), newTenantId);
|
|
|
- if (ObjectUtil.isNotNull(newEducationType)){
|
|
|
- project.setEducationId(newEducationType.getId().intValue());
|
|
|
- }else {
|
|
|
- educationType.setId(null);
|
|
|
- educationType.setTenantId(newTenantId);
|
|
|
- iCourseEducationTypeService.save(educationType);
|
|
|
- project.setEducationId(educationType.getId().intValue());
|
|
|
- }
|
|
|
- iCourseProjectTypeService.save(project);
|
|
|
- goods.setProjectId(project.getId().intValue());
|
|
|
- }
|
|
|
- }
|
|
|
+ goods.setProjectId(getNewProjectTypeId(goods.getProjectId().longValue(),newTenantId).intValue());
|
|
|
}
|
|
|
|
|
|
//讲义
|
|
@@ -1451,127 +1376,192 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
|
|
|
//证书模板
|
|
|
if (ObjectUtils.isNotNull(goods.getCertificateTpId())){
|
|
|
- CertificateTp certificateTp = iCertificateTpService.getById(goods.getCertificateTpId());
|
|
|
- if (ObjectUtils.isNotNull(certificateTp)){
|
|
|
- CertificateTp newCertificateTp =iCertificateTpService.getCertificateTpByTenant(certificateTp.getCode(),newTenantId);
|
|
|
- if (ObjectUtils.isNotNull(newCertificateTp)){
|
|
|
- goods.setCertificateTpId(newCertificateTp.getTpId());
|
|
|
- }else {
|
|
|
- certificateTp.setTpId(null);
|
|
|
- certificateTp.setTenantId(newTenantId);
|
|
|
- certificateTp.setCertificateId(getNewCertificateId(certificateTp.getCertificateId(),newTenantId));
|
|
|
- certificateTp.setTpId(getNewCertificateTypeId(certificateTp.getTpId(),newTenantId));
|
|
|
- iCertificateTpService.save(certificateTp);
|
|
|
- goods.setCertificateTpId(certificateTp.getTpId());
|
|
|
- }
|
|
|
- }
|
|
|
+ goods.setCertificateTpId(getNewCertificateTpId(goods.getCertificateTpId(),newTenantId));
|
|
|
}
|
|
|
|
|
|
//规格模板
|
|
|
if (ObjectUtils.isNotNull(goods.getSpecTemplateId())){
|
|
|
- List<GoodsSpecAttributeRelation> attributeRelationList = goodsSpecAttributeRelationService
|
|
|
- .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
- .eq(GoodsSpecAttributeRelation::getGoodsId, goods.getGoodsId()));
|
|
|
- if (CollectionUtils.isNotEmpty(attributeRelationList)){
|
|
|
- for (GoodsSpecAttributeRelation relation : attributeRelationList) {
|
|
|
- GoodsSpecTemplate specTemplate = goodsSpecTemplateService.getById(relation.getSpecTemplateId());
|
|
|
- GoodsSpecTemplate newSpecTemplate = goodsSpecTemplateService.getSpecTpByTenant(specTemplate.getName(),specTemplate.getCreateTime(),newTenantId);
|
|
|
- if (ObjectUtils.isNotNull(newSpecTemplate)){
|
|
|
- //更新
|
|
|
- List<Long> specIds = goodsSpecService.getIdsByTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
- if (CollectionUtils.isNotEmpty(specIds)){
|
|
|
- //删除关联信息
|
|
|
- List<Long> specAttrIds = goodsSpecAttributeService.getIdsByTenant(specIds);
|
|
|
- if (CollectionUtils.isNotEmpty(specAttrIds)){
|
|
|
- goodsSpecAttributeService.deleteByIdsTenant(specAttrIds);
|
|
|
- goodsSpecAttributeRelationService.deleteByTemplateIdTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
- }
|
|
|
- goodsSpecService.deleteByIdsTenant(specIds);
|
|
|
- }
|
|
|
- //新增关联
|
|
|
- List<GoodsSpec> specList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>()
|
|
|
- .eq(GoodsSpec::getSpecTemplateId, specTemplate.getSpecTemplateId()));
|
|
|
- if (CollectionUtils.isNotEmpty(specList)){
|
|
|
- specList.forEach(item -> {
|
|
|
- Long oldSpecId = item.getSpecId();
|
|
|
- item.setSpecId(null);
|
|
|
- item.setSpecTemplateId(newSpecTemplate.getSpecTemplateId());
|
|
|
- item.setTenantId(newTenantId);
|
|
|
- goodsSpecService.save(item);
|
|
|
- List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
- .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
- .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
- if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
- List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
- .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
- .eq(GoodsSpecAttributeRelation::getSpecTemplateId, specTemplate.getSpecTemplateId()));
|
|
|
- if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
- newRelationList.addAll(relationList);
|
|
|
- }
|
|
|
- List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
- attrItem.setSpecAttributeId(null);
|
|
|
- attrItem.setSpecId(item.getSpecId());
|
|
|
- attrItem.setTenantId(newTenantId);
|
|
|
- return attrItem;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- goodsSpecAttributeService.saveBatch(collect);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- }else {
|
|
|
- Long oldSpecTemplateId = specTemplate.getSpecTemplateId();
|
|
|
- //新增
|
|
|
- specTemplate.setSpecTemplateId(null);
|
|
|
- specTemplate.setTenantId(newTenantId);
|
|
|
- goodsSpecTemplateService.save(specTemplate);
|
|
|
- //新增关联
|
|
|
- List<GoodsSpec> specList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>()
|
|
|
- .eq(GoodsSpec::getSpecTemplateId, oldSpecTemplateId));
|
|
|
- if (CollectionUtils.isNotEmpty(specList)){
|
|
|
- specList.forEach(item -> {
|
|
|
- Long oldSpecId = item.getSpecId();
|
|
|
- item.setSpecId(null);
|
|
|
- item.setSpecTemplateId(specTemplate.getSpecTemplateId());
|
|
|
- item.setTenantId(newTenantId);
|
|
|
- goodsSpecService.save(item);
|
|
|
- List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
- .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
- .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
- if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
- List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
- .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
- .eq(GoodsSpecAttributeRelation::getSpecTemplateId,oldSpecTemplateId));
|
|
|
- if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
- newRelationList.addAll(relationList);
|
|
|
- }
|
|
|
- List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
- attrItem.setSpecAttributeId(null);
|
|
|
- attrItem.setSpecId(item.getSpecId());
|
|
|
- attrItem.setTenantId(newTenantId);
|
|
|
- return attrItem;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- goodsSpecAttributeService.saveBatch(collect);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ Long oldSpecTemplateId = goods.getSpecTemplateId();
|
|
|
+ Long newSpecTemplateId = 0L;
|
|
|
+ GoodsSpecTemplate specTemplate = goodsSpecTemplateService.getById(oldSpecTemplateId);
|
|
|
+ GoodsSpecTemplate newSpecTemplate = goodsSpecTemplateService.getSpecTpByTenant(specTemplate.getName(),specTemplate.getCreateTime(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSpecTemplate)){
|
|
|
+ //更新
|
|
|
+ List<Long> specIds = goodsSpecService.getIdsByTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
+ if (CollectionUtils.isNotEmpty(specIds)){
|
|
|
+ //删除关联信息
|
|
|
+ List<Long> specAttrIds = goodsSpecAttributeService.getIdsByTenant(specIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttrIds)){
|
|
|
+ goodsSpecAttributeService.deleteByIdsTenant(specAttrIds);
|
|
|
+ goodsSpecAttributeRelationService.deleteByTemplateIdTenant(newSpecTemplate.getSpecTemplateId(),newTenantId);
|
|
|
+ }
|
|
|
+ goodsSpecService.deleteByIdsTenant(specIds);
|
|
|
+ }
|
|
|
+ newSpecTemplateId = newSpecTemplate.getSpecTemplateId();
|
|
|
+ }else {
|
|
|
+ //新增
|
|
|
+ specTemplate.setEducationTypeId(getNewEducationTypeId(specTemplate.getEducationTypeId(),newTenantId));
|
|
|
+ specTemplate.setBusinessId(getNewBusinessId(specTemplate.getBusinessId(), newTenantId));
|
|
|
+ specTemplate.setSpecTemplateId(null);
|
|
|
+ specTemplate.setTenantId(newTenantId);
|
|
|
+ goodsSpecTemplateService.save(specTemplate);
|
|
|
+ newSpecTemplateId = specTemplate.getSpecTemplateId();
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增关联
|
|
|
+ List<GoodsSpec> specList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>()
|
|
|
+ .eq(GoodsSpec::getSpecTemplateId, oldSpecTemplateId));
|
|
|
+ if (CollectionUtils.isNotEmpty(specList)){
|
|
|
+ for (GoodsSpec item : specList) {
|
|
|
+ Long oldSpecId = item.getSpecId();
|
|
|
+ item.setSpecId(null);
|
|
|
+ item.setSpecTemplateId(newSpecTemplateId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ goodsSpecService.save(item);
|
|
|
+ List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
+ .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
+ List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
+ attrItem.setSpecAttributeId(null);
|
|
|
+ attrItem.setSpecId(item.getSpecId());
|
|
|
+ attrItem.setTenantId(newTenantId);
|
|
|
+ return attrItem;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ goodsSpecAttributeService.saveBatch(collect);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ //模板属性值关联
|
|
|
+ List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId,oldSpecTemplateId));
|
|
|
+ if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
+ newRelationList.addAll(relationList);
|
|
|
+ }
|
|
|
+ goods.setSpecTemplateId(newSpecTemplateId);
|
|
|
+ }
|
|
|
|
|
|
+ if (ObjectUtils.isNull(goods.getGoodsId())){
|
|
|
+ //新增
|
|
|
+ save(goods);
|
|
|
+ }else {
|
|
|
+ //修改
|
|
|
+ baseMapper.updateByTenant(goods);
|
|
|
}
|
|
|
+ newGoodsId = goods.getGoodsId();
|
|
|
|
|
|
//商品课程
|
|
|
+ List<CourseMenuExam> newCourseMenuExamList = new ArrayList<>();
|
|
|
+ disposeGoodsCourse(oldGoodsId,newGoodsId,newTenantId,newCourseMenuExamList);
|
|
|
+ //商品试卷
|
|
|
+ disposeGoodsAttached(oldGoodsId,newGoodsId,newTenantId);
|
|
|
+
|
|
|
+ //处理商品试卷
|
|
|
+ if (CollectionUtils.isNotEmpty(newCourseMenuExamList)){
|
|
|
+ for (CourseMenuExam menuExam : newCourseMenuExamList) {
|
|
|
+ menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId));
|
|
|
+ }
|
|
|
+ iCourseMenuExamService.saveBatch(newCourseMenuExamList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //规格模板商品重新绑定
|
|
|
+ if (CollectionUtils.isNotEmpty(newRelationList)){
|
|
|
+ for (GoodsSpecAttributeRelation relation : newRelationList) {
|
|
|
+ relation.setId(null);
|
|
|
+ relation.setTenantId(newTenantId);
|
|
|
+ //模板ID
|
|
|
+ if (ObjectUtils.isNotNull(relation.getSpecTemplateId())){
|
|
|
+ GoodsSpecTemplate specTemplate = goodsSpecTemplateService.getById(relation.getSpecTemplateId());
|
|
|
+ GoodsSpecTemplate newSpecTemplate = goodsSpecTemplateService.getSpecTpByTenant(specTemplate.getName(),specTemplate.getCreateTime(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSpecTemplate)){
|
|
|
+ relation.setSpecTemplateId(newSpecTemplate.getSpecTemplateId());
|
|
|
+ }else {
|
|
|
+ relation.setSpecTemplateId(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //商品ID
|
|
|
+ if (ObjectUtils.isNotNull(relation.getGoodsId())){
|
|
|
+ Goods goods = getById(relation.getGoodsId());
|
|
|
+ Goods newGoods = baseMapper.queryGoodsByTenant(goods.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newGoods)){
|
|
|
+ relation.setGoodsId(newGoods.getGoodsId());
|
|
|
+ }else {
|
|
|
+ relation.setGoodsId(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //规格属性IDS
|
|
|
+ if (StringUtils.isNotBlank(relation.getSpecAttributeIds())){
|
|
|
+ List<Long> ids = Arrays.asList(relation.getSpecAttributeIds().split(",")).stream().map(x -> Long.valueOf(x)).collect(Collectors.toList());
|
|
|
+ List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService.listByIds(ids);
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
+ List<Long> newIds = new ArrayList<>();
|
|
|
+ specAttributeList.forEach(item -> {
|
|
|
+ GoodsSpecAttribute newSpecAttribute = goodsSpecAttributeService.getSpecAttrByTenant(item.getName(),item.getCreateTime(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSpecAttribute)){
|
|
|
+ newIds.add(newSpecAttribute.getSpecAttributeId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (CollectionUtils.isNotEmpty(newIds)){
|
|
|
+ relation.setSpecAttributeIds(newIds.stream().map(x -> x.toString()).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsSpecAttributeRelationService.saveBatch(newRelationList);
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disposeGoodsAttached(Long oldGoodsId,Long newGoodsId,Long newTenantId){
|
|
|
+ List<GoodsAttached> goodsAttached = iGoodsAttachedService
|
|
|
+ .list(new LambdaQueryWrapper<GoodsAttached>()
|
|
|
+ .eq(GoodsAttached::getGoodsId, oldGoodsId));
|
|
|
+ if (CollectionUtils.isEmpty(goodsAttached)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ iGoodsAttachedService.deleteByIdTenant(newGoodsId,newTenantId);
|
|
|
+ //题库
|
|
|
+ for (GoodsAttached attached : goodsAttached) {
|
|
|
+ attached.setId(null);
|
|
|
+ attached.setTenantId(newTenantId);
|
|
|
+ attached.setGoodsId(newGoodsId);
|
|
|
+ Long majorId = attached.getMajorId();
|
|
|
+ switch (attached.getType()){
|
|
|
+ case 1:
|
|
|
+ //模块卷
|
|
|
+ attached.setMajorId(getNewModuleExamId(majorId,newTenantId));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //章卷
|
|
|
+ attached.setMajorId(getNewChapterExamId(majorId,newTenantId));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //试卷
|
|
|
+ attached.setMajorId(getNewExamId(majorId,newTenantId));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iGoodsAttachedService.saveBatch(goodsAttached);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private void disposeGoodsCourse(Goods goods,Long newTenantId){
|
|
|
+ private void disposeGoodsCourse(Long oldGoodsId,Long newGoodsId,Long newTenantId,List<CourseMenuExam> menuExamList){
|
|
|
List<GoodsCourse> goodsCourseList = iGoodsCourseService
|
|
|
.list(new LambdaQueryWrapper<GoodsCourse>()
|
|
|
- .eq(GoodsCourse::getGoodsId, goods.getGoodsId()));
|
|
|
+ .eq(GoodsCourse::getGoodsId, oldGoodsId));
|
|
|
+ if (CollectionUtils.isEmpty(goodsCourseList)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //删除之前关联重新添加
|
|
|
+ iGoodsCourseService.deleteByIdTenant(newGoodsId,newTenantId);
|
|
|
for (GoodsCourse goodsCourse : goodsCourseList) {
|
|
|
Course course = iCourseService.getById(goodsCourse.getCourseId());
|
|
|
if(ObjectUtils.isNotNull(course)){
|
|
@@ -1591,31 +1581,409 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
iCourseService.save(course);
|
|
|
newCourseId = course.getCourseId();
|
|
|
}
|
|
|
- List<CourseMenu> courseMenuList = iCourseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
- .eq(CourseMenu::getCourseId, oldCourseId));
|
|
|
+ //商品课程关联
|
|
|
+ iCourseMenuService.deleteByIdTenant(newCourseId,newTenantId);
|
|
|
+ List<CourseMenu> courseMenuList = iCourseMenuService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
+ .eq(CourseMenu::getCourseId, oldCourseId)
|
|
|
+ .eq(CourseMenu::getStatus,1));
|
|
|
if (CollectionUtils.isNotEmpty(courseMenuList)){
|
|
|
for (CourseMenu courseMenu : courseMenuList) {
|
|
|
+ courseMenu.setId(null);
|
|
|
+ courseMenu.setTenantId(newTenantId);
|
|
|
courseMenu.setCourseId(newCourseId);
|
|
|
Long menuId = courseMenu.getMenuId();
|
|
|
switch (courseMenu.getType()){
|
|
|
case 1:
|
|
|
//模块
|
|
|
- CourseModule module = iCourseModuleService.getById(menuId);
|
|
|
- if (ObjectUtils.isNotNull(module)){
|
|
|
- CourseModule newModule = iCourseModuleService.getModuleByTenant(module.getCode(),newTenantId);
|
|
|
- if (ObjectUtils.isNotNull(newModule)){
|
|
|
- courseMenu.setMenuId(newModule.getTenantId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ courseMenu.setMenuId(getNewModuleId(menuId,newTenantId));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //章
|
|
|
+ courseMenu.setMenuId(getNewChapterId(menuId,newTenantId));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //节
|
|
|
+ courseMenu.setMenuId(getNewSectionId(menuId,newTenantId));
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ iCourseMenuService.saveBatch(courseMenuList);
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsCourse.setId(null);
|
|
|
+ goodsCourse.setCourseId(newCourseId);
|
|
|
+ goodsCourse.setGoodsId(newGoodsId);
|
|
|
+ goodsCourse.setTenantId(newTenantId);
|
|
|
+ iGoodsCourseService.save(goodsCourse);
|
|
|
+
|
|
|
+ //课程试卷
|
|
|
+ iCourseMenuExamService.deleteByIdTenant(newCourseId,newTenantId);
|
|
|
+ List<CourseMenuExam> courseMenuExamList = iCourseMenuExamService
|
|
|
+ .list(new LambdaQueryWrapper<CourseMenuExam>()
|
|
|
+ .eq(CourseMenuExam::getCourseId, oldCourseId));
|
|
|
+ if (CollectionUtils.isNotEmpty(courseMenuExamList)){
|
|
|
+ for (CourseMenuExam item : courseMenuExamList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setCourseId(newCourseId);
|
|
|
+ item.setModuleId(getNewModuleId(item.getModuleId(),newTenantId));
|
|
|
+ item.setChapterId(getNewChapterId(item.getChapterId(),newTenantId));
|
|
|
+ item.setSectionId(getNewSectionId(item.getSectionId(),newTenantId));
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ }
|
|
|
+ menuExamList.addAll(courseMenuExamList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private Long getNewModuleExamId(Long moduleExamId,Long newTenantId){
|
|
|
+ QuestionModule questionModule = iQuestionModuleService.getById(moduleExamId);
|
|
|
+ if (ObjectUtils.isNotNull(questionModule)){
|
|
|
+ Long oldModuleExamId = questionModule.getModuleExamId();
|
|
|
+ Long newModuleExamId = 0L;
|
|
|
+ QuestionModule newQuestionModule = iQuestionModuleService.getModuleByTenant(questionModule.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newQuestionModule)){
|
|
|
+ newModuleExamId = newQuestionModule.getTenantId();
|
|
|
+ }else {
|
|
|
+ questionModule.setModuleExamId(null);
|
|
|
+ questionModule.setTenantId(newTenantId);
|
|
|
+ iQuestionModuleService.save(questionModule);
|
|
|
+ newModuleExamId = questionModule.getModuleExamId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除之前的关联
|
|
|
+ iQuestionBusinessService.deleteByIdAndTenant(newModuleExamId,newTenantId,4);
|
|
|
+ //新关联
|
|
|
+ List<QuestionBusiness> questionBusinessList = iQuestionBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, oldModuleExamId)
|
|
|
+ .eq(QuestionBusiness::getType,4));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionBusinessList)){
|
|
|
+ for (QuestionBusiness item : questionBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ item.setMajorId(newModuleExamId);
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(questionBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //模块章卷
|
|
|
+ iQuestionModuleChapterService.deleteByIdAndTenant(newModuleExamId,newTenantId);
|
|
|
+ List<QuestionModuleChapter> questionModuleChapterList = iQuestionModuleChapterService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionModuleChapter>()
|
|
|
+ .eq(QuestionModuleChapter::getModuleExamId, oldModuleExamId));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionModuleChapterList)){
|
|
|
+ for (QuestionModuleChapter item : questionModuleChapterList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setModuleExamId(newModuleExamId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setChapterExamId(getNewChapterExamId(item.getChapterExamId(),newTenantId));
|
|
|
+ }
|
|
|
+ iQuestionModuleChapterService.saveBatch(questionModuleChapterList);
|
|
|
+ }
|
|
|
+ return newModuleExamId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewChapterExamId(Long oldChapterExamId,Long newTenantId){
|
|
|
+ QuestionChapter questionChapter = iQuestionChapterService.getOne(new LambdaQueryWrapper<QuestionChapter>().eq(QuestionChapter::getChapterExamId,oldChapterExamId));
|
|
|
+ if (ObjectUtils.isNotNull(questionChapter)){
|
|
|
+ Long newChapterExamId = 0L;
|
|
|
+ QuestionChapter newQuestionChapter = iQuestionChapterService.getChaptereExamByTenant(questionChapter.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newQuestionChapter)){
|
|
|
+ newChapterExamId = newQuestionChapter.getChapterExamId();
|
|
|
+ }else {
|
|
|
+ questionChapter.setChapterExamId(null);
|
|
|
+ questionChapter.setTenantId(newTenantId);
|
|
|
+ iQuestionChapterService.save(questionChapter);
|
|
|
+ newChapterExamId = questionChapter.getChapterExamId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除之前的关联
|
|
|
+ iQuestionBusinessService.deleteByIdAndTenant(newChapterExamId,newTenantId,3);
|
|
|
+ //新关联
|
|
|
+ List<QuestionBusiness> questionBusinessList = iQuestionBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, oldChapterExamId)
|
|
|
+ .eq(QuestionBusiness::getType,3));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionBusinessList)){
|
|
|
+ for (QuestionBusiness item : questionBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setMajorId(newChapterExamId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(questionBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //章试卷
|
|
|
+ iQuestionChapterExamService.deleteByIdAndTenant(newChapterExamId,newTenantId);
|
|
|
+ List<QuestionChapterExam> questionChapterExamList = iQuestionChapterExamService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionChapterExam>()
|
|
|
+ .eq(QuestionChapterExam::getChapterExamId, oldChapterExamId));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionChapterExamList)){
|
|
|
+ for (QuestionChapterExam item : questionChapterExamList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setChapterExamId(newChapterExamId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setExamId(getNewExamId(item.getExamId(),newTenantId));
|
|
|
+ }
|
|
|
+ iQuestionChapterExamService.saveBatch(questionChapterExamList);
|
|
|
+ }
|
|
|
+ return newChapterExamId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewExamId(Long oldExamId,Long newTenantId){
|
|
|
+ Exam exam = iExamService.getById(oldExamId);
|
|
|
+ if (ObjectUtils.isNotNull(exam)){
|
|
|
+ Long newExamId = 0L;
|
|
|
+ Exam newExam = iExamService.getExamByTenant(exam.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newExam)){
|
|
|
+ newExamId = newExam.getExamId();
|
|
|
+ }else {
|
|
|
+ //试卷类型
|
|
|
+ ExamPaper examPaper = iExamPaperService.getById(exam.getExamPaperId());
|
|
|
+ if (ObjectUtils.isNotNull(examPaper)){
|
|
|
+ ExamPaper newExamPaper = iExamPaperService.getExamPaperByTenant(examPaper.getEncoder(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newExamPaper)){
|
|
|
+ exam.setExamPaperId(newExamPaper.getPaperId());
|
|
|
+ }else {
|
|
|
+ examPaper.setPaperId(null);
|
|
|
+ examPaper.setTenantId(newTenantId);
|
|
|
+ iExamPaperService.save(examPaper);
|
|
|
+ exam.setExamPaperId(examPaper.getPaperId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exam.setExamId(null);
|
|
|
+ exam.setTenantId(newTenantId);
|
|
|
+ iExamService.save(exam);
|
|
|
+ newExamId = exam.getExamId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除之前的关联
|
|
|
+ iQuestionBusinessService.deleteByIdAndTenant(newExamId,newTenantId,2);
|
|
|
+ //新关联
|
|
|
+ List<QuestionBusiness> questionBusinessList = iQuestionBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, oldExamId)
|
|
|
+ .eq(QuestionBusiness::getMajorId,2));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionBusinessList)){
|
|
|
+ for (QuestionBusiness item : questionBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setMajorId(newExamId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(questionBusinessList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //试卷题目关联
|
|
|
+ iExamQuestionService.deleteByIdAndTenant(newExamId,newTenantId);
|
|
|
+ List<ExamQuestion> examQuestionList = iExamQuestionService
|
|
|
+ .list(new LambdaQueryWrapper<ExamQuestion>()
|
|
|
+ .eq(ExamQuestion::getExamId, oldExamId));
|
|
|
+ if (CollectionUtils.isNotEmpty(examQuestionList)){
|
|
|
+ for (ExamQuestion item : examQuestionList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setExamId(newExamId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setQuestionId(getNewQuestionId(item.getQuestionId(),newTenantId));
|
|
|
+ }
|
|
|
+ iExamQuestionService.saveBatch(examQuestionList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return newExamId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewQuestionId(Long oldQuestionId,Long newTenantId){
|
|
|
+ Question question = iQuestionService.getById(oldQuestionId);
|
|
|
+ if (ObjectUtils.isNotNull(question)){
|
|
|
+ Long newQuestionId = 0L;
|
|
|
+ Question newQuestion = iQuestionService.getQuestionByTenant(question.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newQuestion)){
|
|
|
+ newQuestionId = newQuestion.getQuestionId();
|
|
|
+ }else {
|
|
|
+ //新增
|
|
|
+ question.setQuestionId(null);
|
|
|
+ question.setTenantId(newTenantId);
|
|
|
+ iQuestionService.save(question);
|
|
|
+ newQuestionId = question.getQuestionId();
|
|
|
+ }
|
|
|
+ //删除之前的关联
|
|
|
+ iQuestionBusinessService.deleteByIdAndTenant(newQuestionId,newTenantId,1);
|
|
|
+ //新关联
|
|
|
+ List<QuestionBusiness> questionBusinessList = iQuestionBusinessService
|
|
|
+ .list(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, oldQuestionId)
|
|
|
+ .eq(QuestionBusiness::getType,1));
|
|
|
+ if (CollectionUtils.isNotEmpty(questionBusinessList)){
|
|
|
+ for (QuestionBusiness item : questionBusinessList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setMajorId(newQuestionId);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setEducationTypeId(getNewEducationTypeId(item.getEducationTypeId(), newTenantId));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(questionBusinessList);
|
|
|
+ }
|
|
|
+ return newQuestionId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewModuleId(Long oldModuleId,Long newTenantId){
|
|
|
+ CourseModule module = iCourseModuleService.getById(oldModuleId);
|
|
|
+ if (ObjectUtils.isNotNull(module)){
|
|
|
+ Long newModuleId = 0L;
|
|
|
+ CourseModule newModule = iCourseModuleService.getModuleByTenant(module.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newModule)){
|
|
|
+ newModuleId = newModule.getModuleId();
|
|
|
+ }else {
|
|
|
+ module.setModuleId(null);
|
|
|
+ module.setTenantId(newTenantId);
|
|
|
+ iCourseModuleService.save(module);
|
|
|
+ newModuleId = module.getModuleId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除之前的关联
|
|
|
+ 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));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ iCourseModuleChapterService.saveBatch(moduleChapterList);
|
|
|
+ }
|
|
|
+ return newModuleId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewChapterId(Long oldChapterId,Long newTenantId){
|
|
|
+ CourseChapter chapter = iCourseChapterService.getById(oldChapterId);
|
|
|
+ if (ObjectUtils.isNotNull(chapter)){
|
|
|
+ Long newChapterId = 0L;
|
|
|
+ CourseChapter newChapter = iCourseChapterService.getChapterByTenant(chapter.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newChapter)){
|
|
|
+ newChapterId = newChapter.getChapterId();
|
|
|
+ }else {
|
|
|
+ chapter.setChapterId(null);
|
|
|
+ chapter.setTenantId(newTenantId);
|
|
|
+ iCourseChapterService.save(chapter);
|
|
|
+ newChapterId = chapter.getChapterId();
|
|
|
+ }
|
|
|
+ //删除之前的关联
|
|
|
+ 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));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ iCourseChapterSectionService.saveBatch(chapterSectionList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return newChapterId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ private Long getNewSectionId(Long oldSectionId,Long newTenantId){
|
|
|
+ CourseSection section = iCourseSectionService.getById(oldSectionId);
|
|
|
+ if (ObjectUtils.isNotNull(section)){
|
|
|
+ Long newSectionId = 0L;
|
|
|
+ CourseSection newSection = iCourseSectionService.getSectionByTenant(section.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newSection)){
|
|
|
+ newSectionId = newSection.getSectionId();
|
|
|
+ }else {
|
|
|
+ //新增
|
|
|
+ section.setSectionId(null);
|
|
|
+ section.setTenantId(newTenantId);
|
|
|
+ iCourseSectionService.save(section);
|
|
|
+ newSectionId = section.getSectionId();
|
|
|
+ }
|
|
|
+ //删除之前的关联
|
|
|
+ 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));
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId));
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId));
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId));
|
|
|
+ }
|
|
|
+ iCourseSectionBusinessService.saveBatch(sectionBusinessList);
|
|
|
+ }
|
|
|
+ return newSectionId;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
private Long getNewCertificateId(Long certificateId,Long newTenantId){
|
|
|
CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
|
if (ObjectUtils.isNotNull(certificateCommon)){
|
|
@@ -1637,6 +2005,24 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private Long getNewCertificateTpId(Long certificateTpId,Long newTenantId){
|
|
|
+ CertificateTp certificateTp = iCertificateTpService.getById(certificateTpId);
|
|
|
+ if (ObjectUtils.isNotNull(certificateTp)){
|
|
|
+ CertificateTp newCertificateTp =iCertificateTpService.getCertificateTpByTenant(certificateTp.getCode(),newTenantId);
|
|
|
+ if (ObjectUtils.isNotNull(newCertificateTp)){
|
|
|
+ return newCertificateTp.getTpId();
|
|
|
+ }else {
|
|
|
+ certificateTp.setTpId(null);
|
|
|
+ certificateTp.setTenantId(newTenantId);
|
|
|
+ certificateTp.setCertificateId(getNewCertificateId(certificateTp.getCertificateId(),newTenantId));
|
|
|
+ certificateTp.setTypeId(getNewCertificateTypeId(certificateTp.getTypeId(),newTenantId));
|
|
|
+ iCertificateTpService.save(certificateTp);
|
|
|
+ return certificateTp.getTpId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
private Long getNewCertificateTypeId(Long certificateTypeId,Long newTenantId){
|
|
|
Certificate certificate = iCertificateService.getById(certificateTypeId);
|
|
|
if (ObjectUtils.isNotNull(certificate)){
|
|
@@ -1652,7 +2038,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
private Long getNewEducationTypeId(Long oldEducationTypeId,Long newTenantId){
|
|
|
//教育类型
|
|
|
CourseEducationType educationType = iCourseEducationTypeService.getById(oldEducationTypeId);
|
|
@@ -1697,16 +2082,34 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
if (ObjectUtils.isNull(major)){
|
|
|
return null;
|
|
|
}
|
|
|
+ Long newMajorId = 0L;
|
|
|
Major newMajor = iMajorService.getMajorByTenant(major.getEncoder(), newTenantId);
|
|
|
if (ObjectUtil.isNull(newMajor)){
|
|
|
//新增专业
|
|
|
major.setId(null);
|
|
|
major.setTenantId(newTenantId);
|
|
|
iMajorService.save(major);
|
|
|
+ newMajorId = major.getId();
|
|
|
+ }else {
|
|
|
+ newMajorId = newMajor.getId();
|
|
|
+ }
|
|
|
|
|
|
- return major.getId();
|
|
|
+ //专业项目关联
|
|
|
+ iMajorProjectService.deleteByIdTenant(newMajorId,newTenantId);
|
|
|
+ List<MajorProject> majorProjectList = iMajorProjectService
|
|
|
+ .list(new LambdaQueryWrapper<MajorProject>()
|
|
|
+ .eq(MajorProject::getMajorId, majorId));
|
|
|
+ if (CollectionUtil.isNotEmpty(majorProjectList)){
|
|
|
+ for (MajorProject item : majorProjectList) {
|
|
|
+ item.setId(null);
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
+ item.setMajorId(newMajorId);
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(),newTenantId));
|
|
|
+ }
|
|
|
+ iMajorProjectService.saveBatch(majorProjectList);
|
|
|
}
|
|
|
- return newMajor.getId();
|
|
|
+
|
|
|
+ return newMajorId;
|
|
|
}
|
|
|
|
|
|
private Long getNewBusinessId(Long businessId,Long newTenantId){
|
|
@@ -1720,6 +2123,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
//新增业务层次
|
|
|
business.setId(null);
|
|
|
business.setTenantId(newTenantId);
|
|
|
+ business.setProjectId(getNewProjectTypeId(business.getProjectId().longValue(),newTenantId).intValue());
|
|
|
iCourseBusinessService.save(business);
|
|
|
return business.getId();
|
|
|
}
|