BUGFIX: design存sketchboard到library;

This commit is contained in:
shahaibo
2023-10-12 15:35:55 +08:00
parent e3b7304bbf
commit 381d40c346
3 changed files with 34 additions and 1 deletions

View File

@@ -59,6 +59,7 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @return
*/
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone);
Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone, String modelSex);
/**
* 校验element
*

View File

@@ -240,6 +240,38 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return Boolean.TRUE;
}
@Override
public Boolean saveLibraryByCollectionElement(List<CollectionElement> elements,String timeZone, String modelSex){
if(CollectionUtils.isEmpty(elements)){
return Boolean.TRUE;
}
//获取已存在相同的library
List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList());
List<Library> existsLibrarys = libraryService.getByMD5List(md5List);
if(!CollectionUtils.isEmpty(existsLibrarys)){
//去重
List<String> existsMd5Lists = existsLibrarys.stream().map(Library::getMd5).collect(Collectors.toList());
elements = elements.stream().filter(element ->!existsMd5Lists.contains(element.getMd5())).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(elements)){
//都是重复的
return Boolean.TRUE;
}
String name = DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class,(o,d) ->{
if (d.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
d.setLevel3Type(modelSex);
}
d.setCreateDate(DateUtil.getByTimeZone(timeZone));
d.setName(name);
d.setId(null);
});
if (!libraryService.saveBatch(libraryList)) {
throw new BusinessException("Batch saving failed !");
}
return Boolean.TRUE;
}
private CollectionElement resolveData(String path, String timeZone,AuthPrincipalVo userInfo) {
File file = new File(path);
CollectionElement element = new CollectionElement();

View File

@@ -377,7 +377,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (!CollectionUtils.isEmpty(elementVO.getMarketingSketchElements())) {
elements.addAll(elementVO.getMarketingSketchElements());
}
collectionElementService.saveLibraryByCollectionElement(elements, timeZone);
collectionElementService.saveLibraryByCollectionElement(elements, timeZone, elementVO.getModelSex());
}
@Override