|
@@ -1,23 +1,54 @@
|
|
package com.zhongzheng.modules.distribution.service.impl;
|
|
package com.zhongzheng.modules.distribution.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.github.pagehelper.Page;
|
|
|
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionActivityGoodsAddBo;
|
|
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionActivityGoodsEditBo;
|
|
|
|
-import com.zhongzheng.modules.distribution.bo.DistributionActivityGoodsQueryBo;
|
|
|
|
|
|
+import com.zhongzheng.modules.bank.domain.*;
|
|
|
|
+import com.zhongzheng.modules.bank.service.*;
|
|
|
|
+import com.zhongzheng.modules.base.domain.Certificate;
|
|
|
|
+import com.zhongzheng.modules.base.domain.CertificateCommon;
|
|
|
|
+import com.zhongzheng.modules.base.domain.CertificateTp;
|
|
|
|
+import com.zhongzheng.modules.base.service.*;
|
|
|
|
+import com.zhongzheng.modules.course.domain.*;
|
|
|
|
+import com.zhongzheng.modules.course.service.*;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionActivityGoods;
|
|
import com.zhongzheng.modules.distribution.domain.DistributionActivityGoods;
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionActivityGoodsMapper;
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionActivityGoodsMapper;
|
|
import com.zhongzheng.modules.distribution.service.IDistributionActivityGoodsService;
|
|
import com.zhongzheng.modules.distribution.service.IDistributionActivityGoodsService;
|
|
-import com.zhongzheng.modules.distribution.vo.DistributionActivityGoodsVo;
|
|
|
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamPaper;
|
|
|
|
+import com.zhongzheng.modules.exam.service.IExamPaperService;
|
|
|
|
+import com.zhongzheng.modules.goods.bo.GoodsPullTenantBo;
|
|
|
|
+import com.zhongzheng.modules.goods.domain.*;
|
|
|
|
+import com.zhongzheng.modules.goods.service.*;
|
|
|
|
+import com.zhongzheng.modules.pay.domain.PayServe;
|
|
|
|
+import com.zhongzheng.modules.pay.domain.PaySupply;
|
|
|
|
+import com.zhongzheng.modules.pay.service.IPayServeService;
|
|
|
|
+import com.zhongzheng.modules.pay.service.IPaySupplyService;
|
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvCataService;
|
|
|
|
+import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
|
|
|
|
+import com.zhongzheng.modules.system.bo.GoodsCopyEnum;
|
|
|
|
+import com.zhongzheng.modules.system.domain.SysGoodsCopyRecord;
|
|
|
|
+import com.zhongzheng.modules.system.service.ISysGoodsCopyRecordService;
|
|
|
|
+import com.zhongzheng.modules.top.goods.domain.TopGoods;
|
|
|
|
+import com.zhongzheng.modules.top.goods.service.*;
|
|
|
|
+import com.zhongzheng.modules.user.domain.School;
|
|
|
|
+import com.zhongzheng.modules.user.service.ISchoolService;
|
|
|
|
+import net.polyv.common.v1.util.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -30,77 +61,1248 @@ import java.util.stream.Collectors;
|
|
@DS("slave")
|
|
@DS("slave")
|
|
public class DistributionActivityGoodsServiceImpl extends ServiceImpl<DistributionActivityGoodsMapper, DistributionActivityGoods> implements IDistributionActivityGoodsService {
|
|
public class DistributionActivityGoodsServiceImpl extends ServiceImpl<DistributionActivityGoodsMapper, DistributionActivityGoods> implements IDistributionActivityGoodsService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsCourseService iGoodsCourseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsAttachedService iGoodsAttachedService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseService iCourseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseMenuService iCourseMenuService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseMenuExamService iCourseMenuExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseModuleService iCourseModuleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseModuleBusinessService iCourseModuleBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseChapterSectionService iCourseChapterSectionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseModuleChapterService iCourseModuleChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseSectionWatchPerService iCourseSectionWatchPerService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsSpecTemplateService goodsSpecTemplateService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsSpecAttributeService goodsSpecAttributeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsSpecAttributeRelationService goodsSpecAttributeRelationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseEducationTypeService iCourseEducationTypeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseHandoutsService iCourseHandoutsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseHandoutsBusinessService iCourseHandoutsBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseEducationTierService iCourseEducationTierService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseProjectTypeService iCourseProjectTypeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseSectionService iCourseSectionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseSectionBusinessService iCourseSectionBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseBusinessService iCourseBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseSubjectService iCourseSubjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseSubjectProjectService iCourseSubjectProjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IExamService iExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IExamPaperService iExamPaperService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IExamQuestionService iExamQuestionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsSpecService goodsSpecService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionService iQuestionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionBusinessService iQuestionBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionChapterService iQuestionChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionChapterExamService iQuestionChapterExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionModuleService iQuestionModuleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IQuestionModuleChapterService iQuestionModuleChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICertificateService iCertificateService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICertificateCommonService iCertificateCommonService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICertificateTpService iCertificateTpService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsCourseTeacherService goodsCourseTeacherService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseChapterService iCourseChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseChapterBusinessService iCourseChapterBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPaySupplyService iPaySupplyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseStreamingService iCourseStreamingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICourseStreamingBusinessService iCourseStreamingBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPolyvVideoService iPolyvVideoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPolyvCataService iPolyvCataService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IProfileFieldService iProfileFieldService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IProfileTpService iProfileTpService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IProfileTpBusinessService iProfileTpBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IMajorService iMajorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IMajorProjectService iMajorProjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPayServeService iPayServeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISchoolService iSchoolService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysGoodsCopyRecordService iSysGoodsCopyRecordService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsCopyService iTopGoodsCopyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsCourseService iTopGoodsCourseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsAttachedService iTopGoodsAttachedService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseService iTopCourseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseMenuService iTopCourseMenuService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseMenuExamService iTopCourseMenuExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseModuleService iTopCourseModuleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseModuleBusinessService iTopCourseModuleBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseChapterSectionService iTopCourseChapterSectionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseModuleChapterService iTopCourseModuleChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseSectionWatchPerService iTopCourseSectionWatchPerService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsSpecTemplateService topGoodsSpecTemplateService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsSpecAttributeService topGoodsSpecAttributeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsSpecAttributeRelationService topGoodsSpecAttributeRelationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseEducationTypeService iTopCourseEducationTypeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseHandoutsService iTopCourseHandoutsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseHandoutsBusinessService iTopCourseHandoutsBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseEducationTierService iTopCourseEducationTierService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseProjectTypeService iTopCourseProjectTypeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseSectionService iTopCourseSectionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseSectionBusinessService iTopCourseSectionBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseBusinessService iTopCourseBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseSubjectService iTopCourseSubjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseSubjectProjectService iTopCourseSubjectProjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopExamService iTopExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopExamPaperService iTopExamPaperService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopExamQuestionService iTopExamQuestionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsSpecService topGoodsSpecService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionService iTopQuestionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionBusinessService iTopQuestionBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionChapterService iTopQuestionChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionChapterExamService iTopQuestionChapterExamService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionModuleService iTopQuestionModuleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopQuestionModuleChapterService iTopQuestionModuleChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCertificateService iTopCertificateService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCertificateCommonService iTopCertificateCommonService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCertificateTpService iTopCertificateTpService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopGoodsCourseTeacherService topGoodsCourseTeacherService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseChapterService iTopCourseChapterService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseChapterBusinessService iTopCourseChapterBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopPaySupplyService iTopPaySupplyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseStreamingService iTopCourseStreamingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopCourseStreamingBusinessService iTopCourseStreamingBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopPolyvVideoService iTopPolyvVideoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopPolyvCataService iTopPolyvCataService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopProfileFieldService iTopProfileFieldService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopProfileTpService iTopProfileTpService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopProfileTpBusinessService iTopProfileTpBusinessService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopMajorService iTopMajorService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopMajorProjectService iTopMajorProjectService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITopPayServeService iTopPayServeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public DistributionActivityGoodsVo queryById(Long id){
|
|
|
|
- DistributionActivityGoods db = this.baseMapper.selectById(id);
|
|
|
|
- return BeanUtil.toBean(db, DistributionActivityGoodsVo.class);
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public boolean pullGoods(GoodsPullTenantBo bo) {
|
|
|
|
+ String key = "GOODS_PULL";
|
|
|
|
+ Object object = redisCache.getCacheObject(key);
|
|
|
|
+ if (ObjectUtils.isNotNull(object)){
|
|
|
|
+ throw new CustomException("存在商品正在拉取中,请稍后重试!");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ redisCache.setCacheObject(key,DateUtils.getNowTime(),30, TimeUnit.MINUTES);
|
|
|
|
+ Long newTenantId = bo.getTenantId();
|
|
|
|
+ List<GoodsSpecAttributeRelation> newRelationList = new ArrayList<>();
|
|
|
|
+ List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
|
+ for (TopGoods goodsTop : bo.getGoodsList()) {
|
|
|
|
+ Long oldGoodsId = goodsTop.getGoodsId();
|
|
|
|
+ Goods goods = BeanUtil.toBean(goodsTop, Goods.class);
|
|
|
|
+ //新增
|
|
|
|
+ goods.setGoodsId(null);
|
|
|
|
+ goods.setTenantId(newTenantId);
|
|
|
|
+
|
|
|
|
+ //供应方ID
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getSupplyId())){
|
|
|
|
+ PaySupply supply = iPaySupplyService.getById(goods.getSupplyId());
|
|
|
|
+ if (ObjectUtils.isNotNull(supply)){
|
|
|
|
+ Long oldSupplyId = supply.getSupplyId();
|
|
|
|
+ //新机构是否存在
|
|
|
|
+ Long newSupplyId = getNewIdByTenant(supply.getSupplyId(), GoodsCopyEnum.PAY_SUPPLY.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNotNull(newSupplyId)){
|
|
|
|
+ goods.setSupplyId(newSupplyId);
|
|
|
|
+ }else {
|
|
|
|
+ supply.setSupplyId(null);
|
|
|
|
+ supply.setTenantId(newTenantId);
|
|
|
|
+ //服务类型ID
|
|
|
|
+ if (ObjectUtil.isNotNull(supply.getServerId())){
|
|
|
|
+ PayServe payServe = iPayServeService.getById(supply.getServerId());
|
|
|
|
+ Long oldServeId = payServe.getServeId();
|
|
|
|
+ if (ObjectUtils.isNotNull(payServe)){
|
|
|
|
+ Long newPayServerId = getNewIdByTenant(payServe.getServeId(), GoodsCopyEnum.PAY_SERVE.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newPayServerId)){
|
|
|
|
+ supply.setServerId(newPayServerId);
|
|
|
|
+ }else {
|
|
|
|
+ //新增服务
|
|
|
|
+ payServe.setServeId(null);
|
|
|
|
+ payServe.setTenantId(newTenantId);
|
|
|
|
+ iPayServeService.save(payServe);
|
|
|
|
+ supply.setServerId(payServe.getServeId());
|
|
|
|
+ addSysGoodsRecord(oldServeId,payServe.getServeId(),GoodsCopyEnum.PAY_SERVE.getType(),newTenantId,recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ iPaySupplyService.save(supply);
|
|
|
|
+ goods.setSupplyId(supply.getSupplyId());
|
|
|
|
+ addSysGoodsRecord(oldSupplyId,supply.getSupplyId(),GoodsCopyEnum.PAY_SUPPLY.getType(),newTenantId,recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //教育类型
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getEducationTypeId())){
|
|
|
|
+ goods.setEducationTypeId(getNewEducationTypeId(goods.getEducationTypeId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //业务层次
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getBusinessId())){
|
|
|
|
+ goods.setBusinessId(getNewBusinessId(goods.getBusinessId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //所属院校
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getSchoolId())){
|
|
|
|
+ School school = iSchoolService.getById(goods.getSchoolId());
|
|
|
|
+ if (ObjectUtil.isNotNull(school)){
|
|
|
|
+ Long oid = school.getId();
|
|
|
|
+ School newSchool = iSchoolService.getSchoolByTenant(school.getEncoder(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNotNull(newSchool)){
|
|
|
|
+ goods.setSchoolId(newSchool.getId());
|
|
|
|
+ }else {
|
|
|
|
+ school.setId(null);
|
|
|
|
+ school.setTenantId(newTenantId);
|
|
|
|
+ iSchoolService.save(school);
|
|
|
|
+ goods.setSchoolId(school.getId());
|
|
|
|
+ addSysGoodsRecord(oid,school.getId(),GoodsCopyEnum.SCHOOL.getType(),newTenantId,recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //所属专业
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getMajorId())){
|
|
|
|
+ goods.setMajorId(getNewMajorId(goods.getMajorId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //项目
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getProjectId())){
|
|
|
|
+ goods.setProjectId(getNewProjectTypeId(goods.getProjectId().longValue(),newTenantId,recordList).intValue());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //讲义
|
|
|
|
+ if (ObjectUtil.isNotNull(goods.getHandoutsId())){
|
|
|
|
+ CourseHandouts courseHandouts = iCourseHandoutsService.getById(goods.getHandoutsId());
|
|
|
|
+ if (ObjectUtil.isNotNull(courseHandouts)){
|
|
|
|
+ Long oid = courseHandouts.getHandoutsId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNotNull(newId)){
|
|
|
|
+ goods.setHandoutsId(newId);
|
|
|
|
+ }else {
|
|
|
|
+ //讲义业务层次
|
|
|
|
+ List<CourseHandoutsBusiness> handoutsBusinessList = iCourseHandoutsBusinessService
|
|
|
|
+ .list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
|
|
|
|
+ .eq(CourseHandoutsBusiness::getHandoutsId, courseHandouts.getHandoutsId()));
|
|
|
|
+ courseHandouts.setHandoutsId(null);
|
|
|
|
+ courseHandouts.setTenantId(newTenantId);
|
|
|
|
+ iCourseHandoutsService.save(courseHandouts);
|
|
|
|
+ addSysGoodsRecord(oid,courseHandouts.getHandoutsId(),GoodsCopyEnum.COURSE_HANDOUTS.getType(),newTenantId,recordList);
|
|
|
|
+ goods.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
|
+ if (CollectionUtils.isNotEmpty(handoutsBusinessList)){
|
|
|
|
+ List<CourseHandoutsBusiness> collect = handoutsBusinessList.stream().map(business -> {
|
|
|
|
+ business.setId(null);
|
|
|
|
+ business.setTenantId(newTenantId);
|
|
|
|
+ //项目
|
|
|
|
+ business.setEducationId(getNewEducationTypeId(business.getEducationId(), newTenantId,recordList));
|
|
|
|
+ //业务
|
|
|
|
+ business.setBusinessId(getNewBusinessId(business.getBusinessId(), newTenantId,recordList));
|
|
|
|
+ //科目
|
|
|
|
+ business.setSubjectId(getNewSubjectId(business.getSubjectId(), newTenantId,recordList));
|
|
|
|
+ //讲义
|
|
|
|
+ business.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
|
+ return business;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ iCourseHandoutsBusinessService.saveBatch(collect);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //科目ID,拼接
|
|
|
|
+ if (StringUtils.isNotBlank(goods.getSubjectIds())){
|
|
|
|
+ List<Long> subIds = new ArrayList<>();
|
|
|
|
+ List<Long> ids = Arrays.asList(goods.getSubjectIds().split(",")).stream().map(x -> Long.valueOf(x)).collect(Collectors.toList());
|
|
|
|
+ ids.forEach(item -> {
|
|
|
|
+ Long newSubjectId = getNewSubjectId(item, newTenantId,recordList);
|
|
|
|
+ if (ObjectUtils.isNotNull(newSubjectId)){
|
|
|
|
+ subIds.add(newSubjectId);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (CollectionUtils.isNotEmpty(subIds)){
|
|
|
|
+ goods.setSubjectIds(subIds.stream().map(x -> x.toString()).collect(Collectors.joining(",")));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //证书类型
|
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateTypeId())){
|
|
|
|
+ goods.setCertificateTypeId(getNewCertificateTypeId(goods.getCertificateTypeId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //证书
|
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateId())){
|
|
|
|
+ goods.setCertificateId(getNewCertificateId(goods.getCertificateId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //证书模板
|
|
|
|
+ if (ObjectUtils.isNotNull(goods.getCertificateTpId())){
|
|
|
|
+ goods.setCertificateTpId(getNewCertificateTpId(goods.getCertificateTpId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //规格模板
|
|
|
|
+ if (ObjectUtils.isNotNull(goods.getSpecTemplateId())){
|
|
|
|
+ Long oldSpecTemplateId = goods.getSpecTemplateId();
|
|
|
|
+ Long newSpecTemplateId = getNewIdByTenant(oldSpecTemplateId,GoodsCopyEnum.GOODS_SPEC_TEMPLATE.getType(),newTenantId);
|
|
|
|
+ GoodsSpecTemplate specTemplate = goodsSpecTemplateService.getById(oldSpecTemplateId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newSpecTemplateId)){
|
|
|
|
+ //更新
|
|
|
|
+ List<Long> specIds = goodsSpecService.getIdsByTenant(newSpecTemplateId,newTenantId);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(specIds)){
|
|
|
|
+ //删除关联信息
|
|
|
|
+ List<Long> specAttrIds = goodsSpecAttributeService.getIdsByTenant(specIds);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttrIds)){
|
|
|
|
+ goodsSpecAttributeService.deleteByIdsTenant(specAttrIds);
|
|
|
|
+ iSysGoodsCopyRecordService.deleteByTenantId(specAttrIds,GoodsCopyEnum.GOODS_SPEC_ATTRIBUTE.getType(),newTenantId);
|
|
|
|
+ goodsSpecAttributeRelationService.deleteByTemplateIdTenant(newSpecTemplateId,newTenantId);
|
|
|
|
+ }
|
|
|
|
+ goodsSpecService.deleteByIdsTenant(specIds);
|
|
|
|
+ iSysGoodsCopyRecordService.deleteByTenantId(specIds,GoodsCopyEnum.GOODS_SPEC.getType(),newTenantId);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //新增
|
|
|
|
+ specTemplate.setEducationTypeId(getNewEducationTypeId(specTemplate.getEducationTypeId(),newTenantId,recordList));
|
|
|
|
+ specTemplate.setBusinessId(getNewBusinessId(specTemplate.getBusinessId(), newTenantId,recordList));
|
|
|
|
+ specTemplate.setSpecTemplateId(null);
|
|
|
|
+ specTemplate.setTenantId(newTenantId);
|
|
|
|
+ goodsSpecTemplateService.save(specTemplate);
|
|
|
|
+ newSpecTemplateId = specTemplate.getSpecTemplateId();
|
|
|
|
+ addSysGoodsRecord(oldSpecTemplateId,newSpecTemplateId,GoodsCopyEnum.GOODS_SPEC_TEMPLATE.getType(),newTenantId,recordList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //新增关联
|
|
|
|
+ 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);
|
|
|
|
+ addSysGoodsRecord(oldSpecId,item.getSpecId(),GoodsCopyEnum.GOODS_SPEC.getType(),newTenantId,recordList);
|
|
|
|
+ List<GoodsSpecAttribute> specAttributeList = goodsSpecAttributeService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttribute>()
|
|
|
|
+ .eq(GoodsSpecAttribute::getSpecId, oldSpecId));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(specAttributeList)){
|
|
|
|
+ List<GoodsSpecAttribute> collect = specAttributeList.stream().map(attrItem -> {
|
|
|
|
+ attrItem.setOId(attrItem.getSpecAttributeId());
|
|
|
|
+ attrItem.setSpecAttributeId(null);
|
|
|
|
+ attrItem.setSpecId(item.getSpecId());
|
|
|
|
+ attrItem.setTenantId(newTenantId);
|
|
|
|
+ return attrItem;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ goodsSpecAttributeService.saveBatch(collect);
|
|
|
|
+ for (GoodsSpecAttribute attr : collect) {
|
|
|
|
+ addSysGoodsRecord(attr.getOId(),attr.getSpecAttributeId(),GoodsCopyEnum.GOODS_SPEC_ATTRIBUTE.getType(),newTenantId,recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //模板属性值关联
|
|
|
|
+ List<GoodsSpecAttributeRelation> relationList = goodsSpecAttributeRelationService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
|
|
|
|
+ .eq(GoodsSpecAttributeRelation::getSpecTemplateId,oldSpecTemplateId));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(relationList)){
|
|
|
|
+ newRelationList.addAll(relationList);
|
|
|
|
+ }
|
|
|
|
+ goods.setSpecTemplateId(newSpecTemplateId);
|
|
|
|
+ }
|
|
|
|
+ //新增
|
|
|
|
+ iGoodsService.save(goods);
|
|
|
|
+ addSysGoodsRecord(oldGoodsId,goods.getGoodsId(),GoodsCopyEnum.GOODS.getType(),newTenantId,recordList);
|
|
|
|
+ Long newGoodsId = goods.getGoodsId();
|
|
|
|
+
|
|
|
|
+ //商品课程
|
|
|
|
+ List<CourseMenuExam> newCourseMenuExamList = new ArrayList<>();
|
|
|
|
+ disposeGoodsCourse(oldGoodsId,newGoodsId,newTenantId,newCourseMenuExamList,recordList);
|
|
|
|
+ //课程双师
|
|
|
|
+ disposeGoodsCourseTeacher(oldGoodsId,newGoodsId,newTenantId);
|
|
|
|
+ //商品试卷
|
|
|
|
+ disposeGoodsAttached(oldGoodsId,newGoodsId,newTenantId,recordList);
|
|
|
|
+
|
|
|
|
+ //处理商品试卷
|
|
|
|
+ if (CollectionUtils.isNotEmpty(newCourseMenuExamList)){
|
|
|
|
+ for (CourseMenuExam menuExam : newCourseMenuExamList) {
|
|
|
|
+ menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,recordList));
|
|
|
|
+ }
|
|
|
|
+ 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());
|
|
|
|
+ Long newId = getNewIdByTenant(specTemplate.getSpecTemplateId(), GoodsCopyEnum.GOODS_SPEC_TEMPLATE.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ relation.setSpecTemplateId(newId);
|
|
|
|
+ }else {
|
|
|
|
+ relation.setSpecTemplateId(null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //商品ID
|
|
|
|
+ if (ObjectUtils.isNotNull(relation.getGoodsId())){
|
|
|
|
+ Goods goods = iGoodsService.getById(relation.getGoodsId());
|
|
|
|
+ Long newId = getNewIdByTenant(goods.getGoodsId(), GoodsCopyEnum.GOODS.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ relation.setGoodsId(newId);
|
|
|
|
+ }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 -> {
|
|
|
|
+ Long newId = getNewIdByTenant(item.getSpecAttributeId(), GoodsCopyEnum.GOODS_SPEC_ATTRIBUTE.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ newIds.add(newId);
|
|
|
|
+ }else {
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ redisCache.deleteObject(key);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ //释放
|
|
|
|
+ redisCache.deleteObject(key);
|
|
|
|
+ log.error("商品增量报错:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<DistributionActivityGoodsVo> queryList(DistributionActivityGoodsQueryBo bo) {
|
|
|
|
- LambdaQueryWrapper<DistributionActivityGoods> lqw = Wrappers.lambdaQuery();
|
|
|
|
- lqw.eq(bo.getDistributionId() != null, DistributionActivityGoods::getDistributionId, bo.getDistributionId());
|
|
|
|
- lqw.eq(bo.getGoodsId() != null, DistributionActivityGoods::getGoodsId, bo.getGoodsId());
|
|
|
|
- lqw.eq(bo.getProfitMax() != null, DistributionActivityGoods::getProfitMax, bo.getProfitMax());
|
|
|
|
- lqw.eq(bo.getStatus() != null, DistributionActivityGoods::getStatus, bo.getStatus());
|
|
|
|
- lqw.eq(bo.getProfitType() != null, DistributionActivityGoods::getProfitType, bo.getProfitType());
|
|
|
|
- lqw.eq(bo.getProfitOne() != null, DistributionActivityGoods::getProfitOne, bo.getProfitOne());
|
|
|
|
- lqw.eq(bo.getProfitTwo() != null, DistributionActivityGoods::getProfitTwo, bo.getProfitTwo());
|
|
|
|
- lqw.eq(bo.getProfitThree() != null, DistributionActivityGoods::getProfitThree, bo.getProfitThree());
|
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 实体类转化成视图对象
|
|
|
|
- *
|
|
|
|
- * @param collection 实体类集合
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private List<DistributionActivityGoodsVo> entity2Vo(Collection<DistributionActivityGoods> collection) {
|
|
|
|
- List<DistributionActivityGoodsVo> voList = collection.stream()
|
|
|
|
- .map(any -> BeanUtil.toBean(any, DistributionActivityGoodsVo.class))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- if (collection instanceof Page) {
|
|
|
|
- Page<DistributionActivityGoods> page = (Page<DistributionActivityGoods>)collection;
|
|
|
|
- Page<DistributionActivityGoodsVo> pageVo = new Page<>();
|
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
|
- pageVo.addAll(voList);
|
|
|
|
- voList = pageVo;
|
|
|
|
- }
|
|
|
|
- return voList;
|
|
|
|
|
|
+ private void disposeGoodsCourseTeacher(Long oldGoodsId, Long newGoodsId, Long newTenantId) {
|
|
|
|
+ //双师关联
|
|
|
|
+ goodsCourseTeacherService.deleteByIdTeanant(newGoodsId,newTenantId);
|
|
|
|
+ List<GoodsCourseTeacher> list = goodsCourseTeacherService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsCourseTeacher>()
|
|
|
|
+ .eq(GoodsCourseTeacher::getGoodsId, oldGoodsId));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
|
+ for (GoodsCourseTeacher teacher : list) {
|
|
|
|
+ teacher.setId(null);
|
|
|
|
+ teacher.setTenantId(newTenantId);
|
|
|
|
+ teacher.setGoodsId(newGoodsId);
|
|
|
|
+ if (StringUtils.isNotBlank(teacher.getCourseIds())){
|
|
|
|
+ String ids = Arrays.asList(teacher.getCourseIds().split(",")).stream().map(x -> {
|
|
|
|
+ Long oid = Long.valueOf(x);
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE.getType(),newTenantId);
|
|
|
|
+ return ObjectUtils.isNotNull(newId)?newId.toString() : "";
|
|
|
|
+ }).collect(Collectors.joining(","));
|
|
|
|
+ teacher.setCourseIds(ids);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ goodsCourseTeacherService.saveBatch(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public Boolean insertByAddBo(DistributionActivityGoodsAddBo bo) {
|
|
|
|
- DistributionActivityGoods add = BeanUtil.toBean(bo, DistributionActivityGoods.class);
|
|
|
|
- validEntityBeforeSave(add);
|
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.save(add);
|
|
|
|
|
|
+ private void addSysGoodsRecord(Long oldId,Long newId,Integer type,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ SysGoodsCopyRecord record = new SysGoodsCopyRecord();
|
|
|
|
+ record.setOldId(oldId);
|
|
|
|
+ record.setNewId(newId);
|
|
|
|
+ record.setType(type);
|
|
|
|
+ record.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ record.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ record.setTenantId(newTenantId);
|
|
|
|
+ iSysGoodsCopyRecordService.save(record);
|
|
|
|
+// array.add(record);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public Boolean updateByEditBo(DistributionActivityGoodsEditBo bo) {
|
|
|
|
- DistributionActivityGoods update = BeanUtil.toBean(bo, DistributionActivityGoods.class);
|
|
|
|
- validEntityBeforeSave(update);
|
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.updateById(update);
|
|
|
|
|
|
+ private void disposeGoodsAttached(Long oldGoodsId,Long newGoodsId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ 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,array));
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ //章卷
|
|
|
|
+ attached.setMajorId(getNewChapterExamId(majorId,newTenantId,array));
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ //试卷
|
|
|
|
+ attached.setMajorId(getNewExamId(majorId,newTenantId,array));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ iGoodsAttachedService.saveBatch(goodsAttached);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 保存前的数据校验
|
|
|
|
- *
|
|
|
|
- * @param entity 实体类数据
|
|
|
|
- */
|
|
|
|
- private void validEntityBeforeSave(DistributionActivityGoods entity){
|
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
|
|
|
+ private void disposeGoodsCourse(Long oldGoodsId,Long newGoodsId,Long newTenantId,List<CourseMenuExam> menuExamList,List<SysGoodsCopyRecord> array){
|
|
|
|
+ List<GoodsCourse> goodsCourseList = iGoodsCourseService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsCourse>()
|
|
|
|
+ .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)){
|
|
|
|
+ Long oldCourseId = course.getCourseId();
|
|
|
|
+ Long newCourseId = getNewIdByTenant(oldCourseId, GoodsCopyEnum.COURSE.getType(),newTenantId);
|
|
|
|
+// Course newCourse = iCourseService.getCourseByTenant(course.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNull(newCourseId)){
|
|
|
|
+ course.setCourseId(null);
|
|
|
|
+ course.setTenantId(newTenantId);
|
|
|
|
+ course.setEducationTypeId(getNewEducationTypeId(course.getEducationTypeId(),newTenantId,array));
|
|
|
|
+ course.setBusinessId(getNewBusinessId(course.getBusinessId(),newTenantId,array));
|
|
|
|
+ course.setSubjectId(getNewSubjectId(course.getSubjectId(), newTenantId,array));
|
|
|
|
+ course.setProjectId(getNewProjectTypeId(course.getProjectId(), newTenantId,array));
|
|
|
|
+ course.setMajorId(getNewMajorId(course.getMajorId(),newTenantId,array));
|
|
|
|
+ iCourseService.save(course);
|
|
|
|
+ newCourseId = course.getCourseId();
|
|
|
|
+ addSysGoodsRecord(oldCourseId,newCourseId,GoodsCopyEnum.COURSE.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+ //商品课程关联
|
|
|
|
+ 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:
|
|
|
|
+ //模块
|
|
|
|
+ courseMenu.setMenuId(getNewModuleId(menuId,newTenantId,array));
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ //章
|
|
|
|
+ courseMenu.setMenuId(getNewChapterId(menuId,newTenantId,array));
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ //节
|
|
|
|
+ courseMenu.setMenuId(getNewSectionId(menuId,newTenantId,array));
|
|
|
|
+ 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,array));
|
|
|
|
+ item.setChapterId(getNewChapterId(item.getChapterId(),newTenantId,array));
|
|
|
|
+ item.setSectionId(getNewSectionId(item.getSectionId(),newTenantId,array));
|
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
|
+ }
|
|
|
|
+ menuExamList.addAll(courseMenuExamList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
- if(isValid){
|
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
|
+ private Long getNewModuleExamId(Long moduleExamId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ QuestionModule questionModule = iQuestionModuleService.getById(moduleExamId);
|
|
|
|
+ if (ObjectUtils.isNotNull(questionModule)){
|
|
|
|
+ Long oldModuleExamId = questionModule.getModuleExamId();
|
|
|
|
+ Long newModuleExamId = getNewIdByTenant(oldModuleExamId, GoodsCopyEnum.QUESTION_MODULE.getType(),newTenantId);
|
|
|
|
+// QuestionModule newQuestionModule = iQuestionModuleService.getModuleByTenant(questionModule.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNull(newModuleExamId)){
|
|
|
|
+ questionModule.setModuleExamId(null);
|
|
|
|
+ questionModule.setTenantId(newTenantId);
|
|
|
|
+ iQuestionModuleService.save(questionModule);
|
|
|
|
+ newModuleExamId = questionModule.getModuleExamId();
|
|
|
|
+ addSysGoodsRecord(oldModuleExamId,newModuleExamId,GoodsCopyEnum.QUESTION_MODULE.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除之前的关联
|
|
|
|
+ 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,array));
|
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
|
+ 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,array));
|
|
|
|
+ }
|
|
|
|
+ iQuestionModuleChapterService.saveBatch(questionModuleChapterList);
|
|
|
|
+ }
|
|
|
|
+ return newModuleExamId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewChapterExamId(Long oldChapterExamId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ QuestionChapter questionChapter = iQuestionChapterService.getOne(new LambdaQueryWrapper<QuestionChapter>().eq(QuestionChapter::getChapterExamId,oldChapterExamId));
|
|
|
|
+ if (ObjectUtils.isNotNull(questionChapter)){
|
|
|
|
+ Long oid = questionChapter.getChapterExamId();
|
|
|
|
+ Long newChapterExamId = getNewIdByTenant(oid,GoodsCopyEnum.QUESTION_CHAPTER.getType(),newTenantId);
|
|
|
|
+// QuestionChapter newQuestionChapter = iQuestionChapterService.getChaptereExamByTenant(questionChapter.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNull(newChapterExamId)){
|
|
|
|
+ questionChapter.setChapterExamId(null);
|
|
|
|
+ questionChapter.setTenantId(newTenantId);
|
|
|
|
+ iQuestionChapterService.save(questionChapter);
|
|
|
|
+ newChapterExamId = questionChapter.getChapterExamId();
|
|
|
|
+ addSysGoodsRecord(oid,newChapterExamId,GoodsCopyEnum.QUESTION_CHAPTER.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除之前的关联
|
|
|
|
+ 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,array));
|
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
|
+ }
|
|
|
|
+ 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,array));
|
|
|
|
+ }
|
|
|
|
+ iQuestionChapterExamService.saveBatch(questionChapterExamList);
|
|
|
|
+ }
|
|
|
|
+ return newChapterExamId;
|
|
}
|
|
}
|
|
- return this.removeByIds(ids);
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
+ private Long getNewExamId(Long oldExamId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ Exam exam = iExamService.getById(oldExamId);
|
|
|
|
+ if (ObjectUtils.isNotNull(exam)){
|
|
|
|
+ Long oid = exam.getExamId();
|
|
|
|
+ Long newExamId = getNewIdByTenant(oid,GoodsCopyEnum.EXAM.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNull(newExamId)){
|
|
|
|
+ //试卷类型
|
|
|
|
+ ExamPaper examPaper = iExamPaperService.getById(exam.getExamPaperId());
|
|
|
|
+ if (ObjectUtils.isNotNull(examPaper)){
|
|
|
|
+ Long paperOid = examPaper.getPaperId();
|
|
|
|
+ Long newExamPaperId = getNewIdByTenant(paperOid, GoodsCopyEnum.EXAM_PAPER.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newExamPaperId)){
|
|
|
|
+ exam.setExamPaperId(newExamPaperId);
|
|
|
|
+ }else {
|
|
|
|
+ examPaper.setPaperId(null);
|
|
|
|
+ examPaper.setTenantId(newTenantId);
|
|
|
|
+ iExamPaperService.save(examPaper);
|
|
|
|
+ exam.setExamPaperId(examPaper.getPaperId());
|
|
|
|
+ addSysGoodsRecord(paperOid,examPaper.getPaperId(),GoodsCopyEnum.EXAM_PAPER.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ exam.setExamId(null);
|
|
|
|
+ exam.setTenantId(newTenantId);
|
|
|
|
+ iExamService.save(exam);
|
|
|
|
+ newExamId = exam.getExamId();
|
|
|
|
+ addSysGoodsRecord(oid,newExamId,GoodsCopyEnum.EXAM.getType(),newTenantId, array);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除之前的关联
|
|
|
|
+ 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,array));
|
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
|
+ }
|
|
|
|
+ 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,array));
|
|
|
|
+ }
|
|
|
|
+ iExamQuestionService.saveBatch(examQuestionList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newExamId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewQuestionId(Long oldQuestionId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ Question question = iQuestionService.getById(oldQuestionId);
|
|
|
|
+ if (ObjectUtils.isNotNull(question)){
|
|
|
|
+ Long oid = question.getQuestionId();
|
|
|
|
+ Long newQuestionId = getNewIdByTenant(oid,GoodsCopyEnum.QUESTION.getType(),newTenantId);
|
|
|
|
+// Question newQuestion = iQuestionService.getQuestionByTenant(question.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNull(newQuestionId)){
|
|
|
|
+ //新增
|
|
|
|
+ question.setQuestionId(null);
|
|
|
|
+ question.setTenantId(newTenantId);
|
|
|
|
+ iQuestionService.save(question);
|
|
|
|
+ newQuestionId = question.getQuestionId();
|
|
|
|
+ addSysGoodsRecord(oid,newQuestionId,GoodsCopyEnum.QUESTION.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+ //删除之前的关联
|
|
|
|
+ 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,array));
|
|
|
|
+ item.setBusinessId(getNewBusinessId(item.getBusinessId(), newTenantId,array));
|
|
|
|
+ item.setSubjectId(getNewSubjectId(item.getSubjectId(), newTenantId,array));
|
|
|
|
+ item.setProjectId(getNewProjectTypeId(item.getProjectId(), newTenantId,array));
|
|
|
|
+ }
|
|
|
|
+ iQuestionBusinessService.saveBatch(questionBusinessList);
|
|
|
|
+ }
|
|
|
|
+ return newQuestionId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewModuleId(Long oldModuleId,Long newTenantId,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);
|
|
|
|
+// CourseModule newModule = iCourseModuleService.getModuleByTenant(module.getCode(),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);
|
|
|
|
+ }
|
|
|
|
+ return newModuleId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewChapterId(Long oldChapterId,Long newTenantId,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);
|
|
|
|
+// CourseChapter newChapter = iCourseChapterService.getChapterByTenant(chapter.getCode(),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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newChapterId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewSectionId(Long oldSectionId,Long newTenantId,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);
|
|
|
|
+// CourseSection newSection = iCourseSectionService.getSectionByTenant(section.getCode(),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);
|
|
|
|
+ }
|
|
|
|
+ return newSectionId;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewCertificateId(Long certificateId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ CertificateCommon certificateCommon = iCertificateCommonService.getById(certificateId);
|
|
|
|
+ if (ObjectUtils.isNotNull(certificateCommon)){
|
|
|
|
+ Long oid = certificateCommon.getId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.CERTIFICATE_COMMON.getType(),newTenantId);
|
|
|
|
+// CertificateCommon newCertificateCommon = iCertificateCommonService.getCertificateByTenant(certificateCommon.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ return newId;
|
|
|
|
+ }else {
|
|
|
|
+ certificateCommon.setId(null);
|
|
|
|
+ certificateCommon.setTenantId(newTenantId);
|
|
|
|
+ //证书类型
|
|
|
|
+ //证书类型
|
|
|
|
+ if (ObjectUtils.isNotNull(certificateCommon.getCertificateTypeId())){
|
|
|
|
+ certificateCommon.setCertificateTypeId(getNewCertificateTypeId(certificateCommon.getCertificateTypeId(),newTenantId,array));
|
|
|
|
+ }
|
|
|
|
+ iCertificateCommonService.save(certificateCommon);
|
|
|
|
+ addSysGoodsRecord(oid,certificateCommon.getId(),GoodsCopyEnum.CERTIFICATE_COMMON.getType(),newTenantId,array);
|
|
|
|
+ return certificateCommon.getId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewCertificateTpId(Long certificateTpId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ CertificateTp certificateTp = iCertificateTpService.getById(certificateTpId);
|
|
|
|
+ if (ObjectUtils.isNotNull(certificateTp)){
|
|
|
|
+ Long oid = certificateTp.getTpId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.CERTIFICATE_TP.getType(),newTenantId);
|
|
|
|
+// CertificateTp newCertificateTp =iCertificateTpService.getCertificateTpByTenant(certificateTp.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ return newId;
|
|
|
|
+ }else {
|
|
|
|
+ certificateTp.setTpId(null);
|
|
|
|
+ certificateTp.setTenantId(newTenantId);
|
|
|
|
+ certificateTp.setCertificateId(getNewCertificateId(certificateTp.getCertificateId(),newTenantId,array));
|
|
|
|
+ certificateTp.setTypeId(getNewCertificateTypeId(certificateTp.getTypeId(),newTenantId,array));
|
|
|
|
+ iCertificateTpService.save(certificateTp);
|
|
|
|
+ addSysGoodsRecord(oid,certificateTp.getTpId(), GoodsCopyEnum.CERTIFICATE_TP.getType(),newTenantId,array);
|
|
|
|
+ return certificateTp.getTpId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewCertificateTypeId(Long certificateTypeId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ Certificate certificate = iCertificateService.getById(certificateTypeId);
|
|
|
|
+ if (ObjectUtils.isNotNull(certificate)){
|
|
|
|
+ Long oid = certificate.getId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.CERTIFICATE.getType(),newTenantId);
|
|
|
|
+// Certificate newCertificate = iCertificateService.getCertificateByTenant(certificate.getCode(),newTenantId);
|
|
|
|
+ if (ObjectUtils.isNotNull(newId)){
|
|
|
|
+ return newId;
|
|
|
|
+ }else {
|
|
|
|
+ certificate.setId(null);
|
|
|
|
+ certificate.setTenantId(newTenantId);
|
|
|
|
+ iCertificateService.save(certificate);
|
|
|
|
+ addSysGoodsRecord(oid,certificate.getId(),GoodsCopyEnum.CERTIFICATE.getType(),newTenantId,array);
|
|
|
|
+ return certificate.getId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ private Long getNewEducationTypeId(Long oldEducationTypeId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ //教育类型
|
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService.getById(oldEducationTypeId);
|
|
|
|
+ if (ObjectUtils.isNull(educationType)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long oId = educationType.getId();
|
|
|
|
+ Long newEducationTypeId = getNewIdByTenant(educationType.getId(), GoodsCopyEnum.COURSE_EDUCATION_TYPE.getType(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNull(newEducationTypeId)){
|
|
|
|
+ //新增教育类型
|
|
|
|
+ educationType.setId(null);
|
|
|
|
+ educationType.setTenantId(newTenantId);
|
|
|
|
+ iCourseEducationTypeService.save(educationType);
|
|
|
|
+ addSysGoodsRecord(oId,educationType.getId(),GoodsCopyEnum.COURSE_EDUCATION_TYPE.getType(),newTenantId,array);
|
|
|
|
+ return educationType.getId();
|
|
|
|
+ }
|
|
|
|
+ return newEducationTypeId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewProjectTypeId(Long projectTypeId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ //项目类型
|
|
|
|
+ CourseProjectType project = iCourseProjectTypeService.getById(projectTypeId);
|
|
|
|
+ if (ObjectUtils.isNull(project)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long oid = project.getId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_PROJECT_TYPE.getType(),newTenantId);
|
|
|
|
+// CourseProjectType newProject = iCourseProjectTypeService.getProjectByTenant(project.getEncoder(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNull(newId)){
|
|
|
|
+ //新增项目类型
|
|
|
|
+ project.setId(null);
|
|
|
|
+ project.setTenantId(newTenantId);
|
|
|
|
+ //教育类型
|
|
|
|
+ Long newEducationTypeId = getNewEducationTypeId(project.getEducationId().longValue(), newTenantId,array);
|
|
|
|
+ project.setEducationId(newEducationTypeId.intValue());
|
|
|
|
+ iCourseProjectTypeService.save(project);
|
|
|
|
+ addSysGoodsRecord(oid,project.getId(),GoodsCopyEnum.COURSE_PROJECT_TYPE.getType(),newTenantId,array);
|
|
|
|
+ return project.getId();
|
|
|
|
+ }
|
|
|
|
+ return newId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewMajorId(Long majorId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ //专业
|
|
|
|
+ Major major = iMajorService.getById(majorId);
|
|
|
|
+ if (ObjectUtils.isNull(major)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long oid = major.getId();
|
|
|
|
+ Long newMajorId = getNewIdByTenant(oid,GoodsCopyEnum.MAJOR.getType(),newTenantId);
|
|
|
|
+// Major newMajor = iMajorService.getMajorByTenant(major.getEncoder(), newTenantId);
|
|
|
|
+ if (ObjectUtil.isNull(newMajorId)){
|
|
|
|
+ //新增专业
|
|
|
|
+ major.setId(null);
|
|
|
|
+ major.setTenantId(newTenantId);
|
|
|
|
+ iMajorService.save(major);
|
|
|
|
+ newMajorId = major.getId();
|
|
|
|
+ addSysGoodsRecord(oid,major.getId(),GoodsCopyEnum.MAJOR.getType(),newTenantId,array);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //专业项目关联
|
|
|
|
+ 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,array));
|
|
|
|
+ }
|
|
|
|
+ iMajorProjectService.saveBatch(majorProjectList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return newMajorId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewBusinessId(Long businessId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ //业务层次
|
|
|
|
+ CourseBusiness business = iCourseBusinessService.getById(businessId);
|
|
|
|
+ if (ObjectUtils.isNull(business)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long oid = business.getId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_BUSINESS.getType(),newTenantId);
|
|
|
|
+// CourseBusiness newBusiness = iCourseBusinessService.getBusinessByTenant(business.getEncoder(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNull(newId)){
|
|
|
|
+ //新增业务层次
|
|
|
|
+ business.setId(null);
|
|
|
|
+ business.setTenantId(newTenantId);
|
|
|
|
+ business.setProjectId(getNewProjectTypeId(business.getProjectId().longValue(),newTenantId,array).intValue());
|
|
|
|
+ iCourseBusinessService.save(business);
|
|
|
|
+ addSysGoodsRecord(oid,business.getId(),GoodsCopyEnum.COURSE_BUSINESS.getType(),newTenantId,array);
|
|
|
|
+ return business.getId();
|
|
|
|
+ }
|
|
|
|
+ return newId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private Long getNewSubjectId(Long subjectId,Long newTenantId,List<SysGoodsCopyRecord> array){
|
|
|
|
+ //业务层次
|
|
|
|
+ CourseSubject courseSubject = iCourseSubjectService.getById(subjectId);
|
|
|
|
+ if (ObjectUtils.isNull(courseSubject)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long oid = courseSubject.getId();
|
|
|
|
+ Long newId = getNewIdByTenant(oid, GoodsCopyEnum.COURSE_SUBJECT.getType(),newTenantId);
|
|
|
|
+// CourseSubject newCourseSubject = iCourseSubjectService.getSubjectByTenant(courseSubject.getEncoder(),newTenantId);
|
|
|
|
+ if (ObjectUtil.isNull(newId)){
|
|
|
|
+ //业务项目关联
|
|
|
|
+ List<CourseSubjectProject> projectList = iCourseSubjectProjectService
|
|
|
|
+ .list(new LambdaQueryWrapper<CourseSubjectProject>()
|
|
|
|
+ .eq(CourseSubjectProject::getSubjectId, courseSubject.getId()));
|
|
|
|
+ //新增业务层次
|
|
|
|
+ courseSubject.setId(null);
|
|
|
|
+ courseSubject.setTenantId(newTenantId);
|
|
|
|
+ iCourseSubjectService.save(courseSubject);
|
|
|
|
+ addSysGoodsRecord(oid,courseSubject.getId(),GoodsCopyEnum.COURSE_SUBJECT.getType(),newTenantId,array);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(projectList)){
|
|
|
|
+ List<CourseSubjectProject> collect = projectList.stream().map(item -> {
|
|
|
|
+ item.setId(null);
|
|
|
|
+ item.setSubjectId(courseSubject.getId());
|
|
|
|
+ //项目ID
|
|
|
|
+ Long newProjectTypeId = getNewProjectTypeId(item.getProjectId(), newTenantId,array);
|
|
|
|
+ item.setProjectId(newProjectTypeId);
|
|
|
|
+ item.setTenantId(newTenantId);
|
|
|
|
+ return item;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ iCourseSubjectProjectService.saveBatch(collect);
|
|
|
|
+ }
|
|
|
|
+ return courseSubject.getId();
|
|
|
|
+ }
|
|
|
|
+ return newId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Long getNewIdByTenant(Long oldId, Integer type,Long tenantId){
|
|
|
|
+ if (ObjectUtils.isNull(oldId) || oldId <= 0L){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ SysGoodsCopyRecord record = iSysGoodsCopyRecordService.getNewIdByTenant(oldId,type,tenantId);
|
|
|
|
+ if (ObjectUtils.isEmpty(record)){
|
|
|
|
+// throw new CustomException(String.format("新ID查找失败old:%s,type:%s",oldId,type));
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ return record.getNewId();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+// throw new CustomException(String.format("(getone报错)新ID查找失败old:%s,type:%s",oldId,type));
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|