Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -562,33 +562,33 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
//校验marketingSketch
|
||||
// 2023.12版本去掉了这个入参
|
||||
// if (CollectionUtil.isNotEmpty(designDTO.getMarketingSketchs())) {
|
||||
// //校验designType
|
||||
// validateDesignType(designDTO.getMarketingSketchs(),"marketingSketchs");
|
||||
// List<Long> printBoardIds = designDTO.getMarketingSketchs().stream()
|
||||
// .filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
|
||||
// .map(DesignCollectionElementDTO::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// if(!CollectionUtils.isEmpty(printBoardIds)){
|
||||
// List<CollectionElement> marketingSketchElements = collectionElementMapper.selectBatchIds(printBoardIds);
|
||||
// Assert.isTrue(CollectionUtil.isNotEmpty(marketingSketchElements)
|
||||
// && marketingSketchElements.size() == printBoardIds.size(), "get marketingSketch data is mismatch");
|
||||
// elementVO.setMarketingSketchElements(marketingSketchElements);
|
||||
// usedElementIds.addAll(printBoardIds);
|
||||
// }
|
||||
// //library
|
||||
// List<Long> libraryIds = designDTO.getMarketingSketchs().stream()
|
||||
// .filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
|
||||
// .map(DesignCollectionElementDTO::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// if(!CollectionUtils.isEmpty(libraryIds)){
|
||||
// List<Library> librarys = libraryService.getByIds(libraryIds);
|
||||
// //不校验了防止用户在library删除 对应不上
|
||||
// if(CollectionUtil.isNotEmpty(librarys)){
|
||||
// libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/* if (CollectionUtil.isNotEmpty(designDTO.getMarketingSketchs())) {
|
||||
//校验designType
|
||||
validateDesignType(designDTO.getMarketingSketchs(),"marketingSketchs");
|
||||
List<Long> printBoardIds = designDTO.getMarketingSketchs().stream()
|
||||
.filter(f ->f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
|
||||
.map(DesignCollectionElementDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(printBoardIds)){
|
||||
List<CollectionElement> marketingSketchElements = collectionElementMapper.selectBatchIds(printBoardIds);
|
||||
Assert.isTrue(CollectionUtil.isNotEmpty(marketingSketchElements)
|
||||
&& marketingSketchElements.size() == printBoardIds.size(), "get marketingSketch data is mismatch");
|
||||
elementVO.setMarketingSketchElements(marketingSketchElements);
|
||||
usedElementIds.addAll(printBoardIds);
|
||||
}
|
||||
//library
|
||||
List<Long> libraryIds = designDTO.getMarketingSketchs().stream()
|
||||
.filter(f ->f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
|
||||
.map(DesignCollectionElementDTO::getId)
|
||||
.collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(libraryIds)){
|
||||
List<Library> librarys = libraryService.getByIds(libraryIds);
|
||||
//不校验了防止用户在library删除 对应不上
|
||||
if(CollectionUtil.isNotEmpty(librarys)){
|
||||
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys,null));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//校验控制生成类型
|
||||
SingleOverallEnum singleOverall = SingleOverallEnum.of(designDTO.getSingleOverall());
|
||||
if (Objects.isNull(singleOverall)) {
|
||||
|
||||
@@ -2228,16 +2228,53 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
// Set<String> oldUrl = collectionElements.stream().map(CollectionElement::getUrl).collect(Collectors.toSet());
|
||||
List<CollectionElementRelModel> collectionElementRelModels = collectionElementMapper.selectByProject(projectId);
|
||||
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
|
||||
List<Long> inputMannequinId = mannequin.stream().map(MannequinDTO::getId).collect(Collectors.toList());
|
||||
|
||||
// 创建relationId到Model的映射
|
||||
Map<Long, CollectionElementRelModel> relationIdToModelMap = collectionElementRelModels.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CollectionElementRelModel::getRelationId,
|
||||
java.util.function.Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
List<Long> newReletionIds = new ArrayList<>();
|
||||
List<Long> toBeDeletedRelationIds = new ArrayList<>();
|
||||
|
||||
if (collectionElementRelModels.isEmpty()) {
|
||||
// 如果原本没有记录,所有输入的Mannequin都是新的
|
||||
newReletionIds = inputMannequinId;
|
||||
} else {
|
||||
// 获取所有已有的relationId集合
|
||||
Set<Long> relationIds = relationIdToModelMap.keySet();
|
||||
|
||||
// 1. 找出需要删除的:relationIds中有但inputMannequinId中没有的
|
||||
toBeDeletedRelationIds = relationIds.stream()
|
||||
.filter(id -> !inputMannequinId.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 找出新增的:inputMannequinId中有但relationIds中没有的
|
||||
newReletionIds = inputMannequinId.stream()
|
||||
.filter(id -> !relationIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (!toBeDeletedRelationIds.isEmpty()){
|
||||
Set<Long> toBeDeletedElementIdList = toBeDeletedRelationIds.stream()
|
||||
.map(relationIdToModelMap::get) // 获取对应的Model
|
||||
.filter(Objects::nonNull) // 过滤掉可能为null的情况
|
||||
.map(CollectionElementRelModel::getCollectionElementId) // 提取collectionElementId
|
||||
.collect(Collectors.toSet());
|
||||
collectionElementMapper.deleteBatchIds(toBeDeletedElementIdList);
|
||||
// 删除关联关系
|
||||
deleteByCollectionElementIdList(toBeDeletedElementIdList);
|
||||
}
|
||||
|
||||
for (MannequinDTO dto : mannequin) {
|
||||
if (null != dto.getCollectionElementId()) {
|
||||
old.remove(dto.getId());
|
||||
if (newReletionIds.isEmpty()){
|
||||
break;
|
||||
}else if (!newReletionIds.contains(dto.getId())){
|
||||
continue;
|
||||
}
|
||||
if (dto.getType().equals("System")) {
|
||||
@@ -2281,30 +2318,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
collectionElementRelModel.setRelationType("System");
|
||||
collectionElementRelModelMapper.insert(collectionElementRelModel);
|
||||
|
||||
}else {
|
||||
// if (old.contains(dto.getId())) {
|
||||
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setUpdateDate(new Date());
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// old.remove(dto.getId());
|
||||
// }else {
|
||||
// CollectionElement collectionElement = collectionElementMapper.selectById(dto.getId());
|
||||
// collectionElement.setProjectId(projectId);
|
||||
//// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
//// collectionElement.setHasPin(board.getIsPin());
|
||||
// collectionElement.setUpdateDate(new Date());
|
||||
// collectionElementMapper.updateById(collectionElement);
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(old)) {
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
// 删除关联关系
|
||||
deleteByCollectionElementIdList(old);
|
||||
}
|
||||
|
||||
}
|
||||
if (boundingBox) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user