|
@@ -4305,291 +4305,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- @Transactional
|
|
|
|
- public boolean goodsBatchCopyIncrementTenantTwo() {
|
|
|
|
- List<String> strings = Arrays.asList("575736195212958",
|
|
|
|
- "309214838568311", "142421998426961", "645402213016729", "321476160028741");
|
|
|
|
-
|
|
|
|
- //获取商品信息
|
|
|
|
- List<Goods> goodsList = list(new LambdaQueryWrapper<Goods>()
|
|
|
|
- .eq(Goods::getGoodsStatus, 1)
|
|
|
|
- .isNull(Goods::getSpecTemplateId));
|
|
|
|
- if (CollectionUtils.isEmpty(goodsList)) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- Long tenantId = 867735392558919680L;
|
|
|
|
-
|
|
|
|
- List<GoodsSpecAttributeRelation> newRelationList = new ArrayList<>();
|
|
|
|
- List<SysGoodsCopyRecord> recordList = new ArrayList<>();
|
|
|
|
- for (String string : strings) {
|
|
|
|
- Long newTenantId = Long.valueOf(string);
|
|
|
|
- for (Goods goods : goodsList) {
|
|
|
|
- Long oldGoodsId = goods.getGoodsId();
|
|
|
|
- //判断商品是否存在
|
|
|
|
- Long newGoodsId = getNewIdByTenant(goods.getGoodsId(), GoodsCopyEnum.GOODS.getType(), newTenantId);
|
|
|
|
-// Goods newGoods = this.baseMapper.queryGoodsByTenant(goods.getCode(),newTenantId);
|
|
|
|
- if (ObjectUtils.isNull(newGoodsId)) {
|
|
|
|
- //不存在(新增)
|
|
|
|
- goods.setGoodsId(null);
|
|
|
|
- goods.setTenantId(newTenantId);
|
|
|
|
- } else {
|
|
|
|
- //修改
|
|
|
|
- goods.setGoodsId(newGoodsId);
|
|
|
|
- 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);
|
|
|
|
- Long newId = baseMapper.getNewHandoutsId(courseHandouts.getHandoutsName(), courseHandouts.getEncoder(), newTenantId);
|
|
|
|
- if (ObjectUtil.isNull(newId)) {
|
|
|
|
- //讲义业务层次
|
|
|
|
- List<CourseHandoutsBusiness> handoutsBusinessList = iCourseHandoutsBusinessService
|
|
|
|
- .list(new LambdaQueryWrapper<CourseHandoutsBusiness>()
|
|
|
|
- .eq(CourseHandoutsBusiness::getHandoutsId, courseHandouts.getHandoutsId()));
|
|
|
|
- courseHandouts.setHandoutsId(null);
|
|
|
|
- courseHandouts.setTenantId(newTenantId);
|
|
|
|
- iCourseHandoutsService.save(courseHandouts);
|
|
|
|
- newId = courseHandouts.getHandoutsId();
|
|
|
|
- addSysGoodsRecord(oid, courseHandouts.getHandoutsId(), GoodsCopyEnum.COURSE_HANDOUTS.getType(), newTenantId, recordList);
|
|
|
|
- goods.setHandoutsId(courseHandouts.getHandoutsId());
|
|
|
|
- if (CollectionUtils.isNotEmpty(handoutsBusinessList)) {
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- goods.setHandoutsId(newId);
|
|
|
|
- //讲义文件
|
|
|
|
- iCourseFileService.deleteByTenant(newId, newTenantId);
|
|
|
|
- List<CourseFile> courseFileList = iCourseFileService.list(new LambdaQueryWrapper<CourseFile>().eq(CourseFile::getHandoutsId, oid).eq(CourseFile::getStatus, 1));
|
|
|
|
- if (CollectionUtils.isNotEmpty(courseFileList)) {
|
|
|
|
- //重新添加讲义文件
|
|
|
|
- handleCourseFile(courseFileList, newId, newTenantId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //科目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);
|
|
|
|
-// GoodsSpecTemplate newSpecTemplate = goodsSpecTemplateService.getSpecTpByTenant(specTemplate.getName(),specTemplate.getCreateTime(),newTenantId);
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (ObjectUtils.isNull(goods.getGoodsId())) {
|
|
|
|
- //新增
|
|
|
|
- save(goods);
|
|
|
|
- addSysGoodsRecord(oldGoodsId, goods.getGoodsId(), GoodsCopyEnum.GOODS.getType(), newTenantId, recordList);
|
|
|
|
- } else {
|
|
|
|
- //修改
|
|
|
|
- baseMapper.updateByTenant(goods);
|
|
|
|
- }
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|