@@ -1798,20 +1798,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
public String designCloud ( CloudTaskDTO cloudTaskDTO ) {
if ( cloudTaskDTO . getBuildType ( ) . equals ( BuildType . DESIGN . getValue ( ) ) ) {
Long projectId = cloudTaskDTO . getProjectId ( ) ;
// Project project = projectService.getById(projectId);
// project.setParentId(projectId);
// project.setId(null);
// project.setName(project.getName() + "_cloud");
// LocalDateTime now = LocalDateTime.now();
// project.setCreateTime(now);
// project.setUpdateTime(now);
// projectService.getBaseMapper().insert(project);
// Long workspaceId = workspaceService.getByProjectId(projectId);
// Workspace workspace = workspaceService.getById(workspaceId);
// workspace.setProjectId(project.getId());
// workspace.setId(null);
// workspaceService.getBaseMapper().insert(workspace);
DesignCollectionDTO designDTO = transDesignParam ( projectId ) ;
designDTO . setDesignNum ( cloudTaskDTO . getNums ( ) ) ;
AuthPrincipalVo userInfo = UserContext . getUserHolder ( ) ;
@@ -1858,91 +1844,183 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if ( ! StringUtil . isNullOrEmpty ( prompt ) ) {
prompt = pythonService . promptTranslate ( prompt ) ;
}
for ( ToProductImageVO toProductImageVO : toProductImageDTO . getToProductImageVOList ( ) ) {
String taskId ;
if ( toProductImageVO . getElementType ( ) . equals ( " DesignOutfit " ) ) {
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
Long designItemId = tDesignPythonOutfit . getDesignItemId ( ) ;
QueryWrapper < DesignItemDetail > designItemDetailQueryWrapper = new QueryWrapper < > ( ) ;
designItemDetailQueryWrapper . lambda ( ) . eq ( DesignItemDetail : : getDesignItemId , designItemId ) ;
designItemDetailQueryWrapper . lambda ( ) . ne ( DesignItemDetail : : getType , " Body " ) ;
List < DesignItemDetail > designItemDetails = designItemDetailMapper . selectList ( designItemDetailQueryWrapper ) ;
String collect = designItemDetails . stream ( ) . map ( DesignItemDetail : : getType ) . collect ( Collectors . joining ( " , " ) ) ;
int fullBatches = toProductImageDTO . getToProductImageVOList ( ) . size ( ) / cloudTaskDTO . getNums ( ) ; // 可整除的次数
int remainder = toProductImageDTO . getToProductImageVOList ( ) . size ( ) % cloudTaskDTO . getNums ( ) ; // 剩下的余数
Long designId = tDesignPythonOutfit . getDesignId ( ) ;
Design design = designMapper . selectById ( designId ) ;
String productType = " overall " ;
if ( design . getSingleOverall ( ) . equals ( " single " ) ) {
productType = " single " ;
sb . append ( collect ) ;
} else {
if ( collect . contains ( " Tops " ) ) {
sb . append ( " a handsome man, " ) ;
for ( int i1 = 0 ; i1 < fullBatches ; i1 + + ) {
for ( ToProductImageVO toProductImageVO : toProductImageDTO . getToProductImageVOList ( ) ) {
String taskId ;
if ( toProductImageVO . getElementType ( ) . equals ( " DesignOutfit " ) ) {
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
Long designItemId = tDesignPythonOutfit . getDesignItemId ( ) ;
QueryWrapper < DesignItemDetail > designItemDetailQueryWrapper = new QueryWrapper < > ( ) ;
designItemDetailQueryWrapper . lambda ( ) . eq ( DesignItemDetail : : getDesignItemId , designItemId ) ;
designItemDetailQueryWrapper . lambda ( ) . ne ( DesignItemDetail : : getType , " Body " ) ;
List < DesignItemDetail > designItemDetails = designItemDetailMapper . selectList ( designItemDetailQueryWrapper ) ;
String collect = designItemDetails . stream ( ) . map ( DesignItemDetail : : getType ) . collect ( Collectors . joining ( " , " ) ) ;
Long designId = tDesignPythonOutfit . getDesignId ( ) ;
Design design = designMapper . selectById ( designId ) ;
String productType = " overall " ;
if ( design . getSingleOverall ( ) . equals ( " single " ) ) {
productType = " single " ;
sb . append ( collect ) ;
} else {
sb . append ( " a beautiful women, " ) ;
if ( collect . contains ( " Tops " ) ) {
sb . append ( " a handsome man, " ) ;
} else {
sb . append ( " a beautiful women, " ) ;
}
sb . append ( " wearing " ) . append ( collect ) ;
}
sb . append ( " wearing " ) . append ( collect ) ;
}
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
} else {
sb . append ( " ,high quality clothing details," ) . append ( prompt ) . append ( " , 8K realistic,HDR " ) ;
}
// 走模型
pythonService . toProductImageBatch ( tDesignPythonOutfit . getDesignUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , productType ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( tDesignPythonOutfit . getId ( ) ) ;
toProductImageResult . setElementType ( " DesignOutfit " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
toProductImageResult . setTaskIdBatch ( batchTaskId ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
result . add ( toProductImageResult ) ;
} else {
sb . append ( " ,high quality clothing details, " ) . append ( prompt ) . append ( " ,8K realistic,HDR " ) ;
}
// 走模型
pythonService . toProductImageBatch ( tDesignPythonOutfit . getDesignUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , productType ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( tDesignPythonOutfit . getId ( ) ) ;
toProductImageResult . setElementType ( " DesignOutfit " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
// toProductImageResult.setUrl(productImageUrl);
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
toProductImageResult . setTaskIdBatch ( batchTaskId ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result . add ( toProductImageResult ) ;
} else {
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
} else {
sb . append ( " ,high quality clothing details, " ) . append ( prompt ) . append ( " ,8K realistic,HDR " ) ;
}
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
} else {
sb . append ( " ,high quality clothing details, " ) . append ( prompt ) . append ( " ,8K realistic,HDR " ) ;
}
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
ToProductElement toProductElement = toProductElementMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
// 走模型
pythonService . toProductImageBatch ( toProductElement . getUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , " overall " ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( toProductElement . getId ( ) ) ;
toProductImageResult . setElementType ( " ProductElement " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
// toProductImageResult.setUrl(productImageUrl) ;
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( task Id ) ;
toProductImageResult . setProjectId ( project Id ) ;
toProductImageResult . setTaskIdBatch ( batchTaskId ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
ToProductElement toProductElement = toProductElementMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
// 走模型
pythonService . toProductImageBatch ( toProductElement . getUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , " overall " ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( toProductElement . getId ( ) ) ;
toProductImageResult . setElementType ( " ProductElement " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
toProductImageResult. setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( project Id ) ;
toProductImageResult . setTaskIdBatch ( batchTask Id ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
result . add ( toProductImageResult ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . ins ert ( toProductImageResult ) ;
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result . add ( toProductImageResult ) ;
i + + ;
sb = new StringBuild er( " The best quality, masterpiece, real image. " ) ;
// 添加需要扣除的积分到预扣除区
c reditsService . addRecordToCreditsDeduction ( userHolder . getId ( ) , taskId , CreditsEventsEnum . TO_PRODUCT_IMAGE ) ;
}
i + + ;
sb = new StringBuilder ( " The best quality, masterpiece, real image. " ) ;
// 添加需要扣除的积分到预扣除区
creditsService . addRecordToCreditsDeduction ( userHolder . getId ( ) , taskId , CreditsEventsEnum . TO_PRODUCT_IMAGE ) ;
}
if ( remainder > 0 ) {
List < ToProductImageVO > tempList = new ArrayList < > ( toProductImageDTO . getToProductImageVOList ( ) ) ;
Collections . shuffle ( tempList ) ; // 打乱顺序
// 取前 remainder 个
List < ToProductImageVO > randomPick = tempList . subList ( 0 , remainder ) ;
for ( ToProductImageVO toProductImageVO : randomPick ) {
String taskId ;
if ( toProductImageVO . getElementType ( ) . equals ( " DesignOutfit " ) ) {
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
Long designItemId = tDesignPythonOutfit . getDesignItemId ( ) ;
QueryWrapper < DesignItemDetail > designItemDetailQueryWrapper = new QueryWrapper < > ( ) ;
designItemDetailQueryWrapper . lambda ( ) . eq ( DesignItemDetail : : getDesignItemId , designItemId ) ;
designItemDetailQueryWrapper . lambda ( ) . ne ( DesignItemDetail : : getType , " Body " ) ;
List < DesignItemDetail > designItemDetails = designItemDetailMapper . selectList ( designItemDetailQueryWrapper ) ;
String collect = designItemDetails . stream ( ) . map ( DesignItemDetail : : getType ) . collect ( Collectors . joining ( " , " ) ) ;
Long designId = tDesignPythonOutfit . getDesignId ( ) ;
Design design = designMapper . selectById ( designId ) ;
String productType = " overall " ;
if ( design . getSingleOverall ( ) . equals ( " single " ) ) {
productType = " single " ;
sb . append ( collect ) ;
} else {
if ( collect . contains ( " Tops " ) ) {
sb . append ( " a handsome man, " ) ;
} else {
sb . append ( " a beautiful women, " ) ;
}
sb . append ( " wearing " ) . append ( collect ) ;
}
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
} else {
sb . append ( " ,high quality clothing details, " ) . append ( prompt ) . append ( " ,8K realistic,HDR " ) ;
}
// 走模型
pythonService . toProductImageBatch ( tDesignPythonOutfit . getDesignUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , productType ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( tDesignPythonOutfit . getId ( ) ) ;
toProductImageResult . setElementType ( " DesignOutfit " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
toProductImageResult . setTaskIdBatch ( batchTaskId ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
result . add ( toProductImageResult ) ;
} else {
if ( StringUtils . isEmpty ( prompt ) ) {
sb . append ( " ,high quality clothing details,8K realistic,HDR " ) ;
} else {
sb . append ( " ,high quality clothing details, " ) . append ( prompt ) . append ( " ,8K realistic,HDR " ) ;
}
taskId = UUID . randomUUID ( ) + " - " + i + " - " + userHolder . getId ( ) ;
ToProductElement toProductElement = toProductElementMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
// 走模型
pythonService . toProductImageBatch ( toProductElement . getUrl ( ) , taskId , sb . toString ( ) , toProductImageDTO . getImageStrength ( ) , " overall " ) ;
ToProductImageResult toProductImageResult = new ToProductImageResult ( ) ;
toProductImageResult . setElementId ( toProductElement . getId ( ) ) ;
toProductImageResult . setElementType ( " ProductElement " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
toProductImageResult . setTaskIdBatch ( batchTaskId ) ;
if ( userLikeGroupId ! = null ) {
toProductImageResult . setUserLikeGroupId ( userLikeGroupId ) ;
}
toProductImageResult . setImageStrength ( toProductImageDTO . getImageStrength ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
result . add ( toProductImageResult ) ;
}
i + + ;
sb = new StringBuilder ( " The best quality, masterpiece, real image. " ) ;
// 添加需要扣除的积分到预扣除区
creditsService . addRecordToCreditsDeduction ( userHolder . getId ( ) , taskId , CreditsEventsEnum . TO_PRODUCT_IMAGE ) ;
}
}
CloudTask cloudTask = CopyUtil . copyObject ( cloudTaskDTO , CloudTask . class ) ;
cloudTask . setProjectId ( projectId ) ;
cloudTask . setTaskId ( batchTaskId ) ;
@@ -2012,7 +2090,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult . setElementType ( " ToProductImage " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
// toProductImageResult.setUrl(productImageUrl);
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
@@ -2025,7 +2102,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
toProductImageResult . setDirection ( toProductImageDTO . getDirection ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result . add ( toProductImageResult ) ;
} else {
ToProductElement toProductElement = toProductElementMapper . selectById ( toProductImageVO . getElementId ( ) ) ;
@@ -2036,7 +2112,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult . setElementType ( " ProductElement " ) ;
toProductImageResult . setCreateTime ( LocalDateTime . now ( ) ) ;
toProductImageResult . setToProductImageRecordId ( toProductImageRecord . getId ( ) ) ;
// toProductImageResult.setUrl(productImageUrl);
toProductImageResult . setIsLike ( 0 ) ;
toProductImageResult . setTaskId ( taskId ) ;
toProductImageResult . setProjectId ( projectId ) ;
@@ -2049,11 +2124,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}
toProductImageResult . setDirection ( toProductImageDTO . getDirection ( ) ) ;
toProductImageResultMapper . insert ( toProductImageResult ) ;
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result . add ( toProductImageResult ) ;
}
// 添加需要扣除的积分到预扣除区
// creditsService. addRecordToCreditsDeduction( userHolder.getId(), taskId, CreditsEventsEnum. RELIGHT) ;
creditsService. addRecordToCreditsDeduction( userHolder. getId ( ) , taskId , CreditsEventsEnum. RELIGHT) ;
}
CloudTask cloudTask = CopyUtil . copyObject ( cloudTaskDTO , CloudTask . class ) ;
cloudTask . setProjectId ( projectId ) ;
@@ -2244,7 +2318,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
log . info ( " 增加image_id关联运行时间: " + totalTimeInSeconds + " 秒 " ) ;
//design
startTime = System . currentTimeMillis ( ) ;
String requestId = UUID . randomUUID ( ) . toString ( ) ;
String requestId = UUID . randomUUID ( ) . toString ( ) + " _ " + userInfo . getId ( ) ;
pythonObjects . setRequestId ( requestId ) ;
AuthPrincipalVo userHolder = UserContext . getUserHolder ( ) ;
String taskId = pythonService . designBatch ( pythonObjects , userHolder . getId ( ) , elementVO . getDesignNum ( ) , requestId ) ;
@@ -2631,4 +2705,80 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return result ;
}
@Resource
private PanToneMapper panToneMapper ;
@Override
public Boolean receiveDesignParams ( ReceiveDesignParam receiveDesignParam ) {
List < ReceiveCollectionElement > receiveCollectionElementList = receiveDesignParam . getReceiveCollectionElementList ( ) ;
if ( ! CollectionUtils . isEmpty ( receiveCollectionElementList ) ) {
Project project = projectService . getById ( receiveDesignParam . getProjectId ( ) ) ;
// Project project = projectService.getById(1750L);
List < CollectionElement > collectionElementList = new ArrayList < > ( ) ;
Date date = new Date ( ) ;
for ( ReceiveCollectionElement receiveCollectionElement : receiveCollectionElementList ) {
CollectionElement collectionElement = new CollectionElement ( ) ;
if ( receiveCollectionElement . getLevel1Type ( ) . equals ( CollectionLevel1TypeEnum . PRINT_BOARD . getRealName ( ) ) ) {
String url = receiveCollectionElement . getUrl ( ) ;
String [ ] split = url . split ( " / " ) ;
String pictureName = split [ split . length - 1 ] ;
String [ ] split1 = pictureName . split ( " \\ . " ) ;
collectionElement . setLevel1Type ( receiveCollectionElement . getLevel1Type ( ) ) ;
collectionElement . setAccountId ( project . getAccountId ( ) ) ;
collectionElement . setProjectId ( project . getId ( ) ) ;
collectionElement . setLevel2Type ( receiveCollectionElement . getLevel2Type ( ) ) ;
collectionElement . setName ( split1 [ 0 ] ) ;
collectionElement . setUrl ( url ) ;
collectionElement . setHasPin ( ( byte ) 0 ) ;
collectionElement . setCreateDate ( date ) ;
} else if ( receiveCollectionElement . getLevel1Type ( ) . equals ( CollectionLevel1TypeEnum . MOOD_BOARD . getRealName ( ) ) ) {
String url = receiveCollectionElement . getUrl ( ) ;
String [ ] split = url . split ( " / " ) ;
String pictureName = split [ split . length - 1 ] ;
String [ ] split1 = pictureName . split ( " \\ . " ) ;
collectionElement . setLevel1Type ( receiveCollectionElement . getLevel1Type ( ) ) ;
collectionElement . setAccountId ( project . getAccountId ( ) ) ;
collectionElement . setProjectId ( project . getId ( ) ) ;
collectionElement . setName ( split1 [ 0 ] ) ;
collectionElement . setUrl ( url ) ;
collectionElement . setHasPin ( ( byte ) 0 ) ;
collectionElement . setCreateDate ( date ) ;
} else if ( receiveCollectionElement . getLevel1Type ( ) . equals ( CollectionLevel1TypeEnum . SKETCH_BOARD . getRealName ( ) ) ) {
String url = receiveCollectionElement . getUrl ( ) ;
String [ ] split = url . split ( " / " ) ;
String pictureName = split [ split . length - 1 ] ;
String [ ] split1 = pictureName . split ( " \\ . " ) ;
collectionElement . setLevel1Type ( receiveCollectionElement . getLevel1Type ( ) ) ;
collectionElement . setAccountId ( project . getAccountId ( ) ) ;
collectionElement . setProjectId ( project . getId ( ) ) ;
collectionElement . setLevel2Type ( receiveCollectionElement . getLevel2Type ( ) ) ;
collectionElement . setName ( split1 [ 0 ] ) ;
collectionElement . setUrl ( url ) ;
collectionElement . setHasPin ( ( byte ) 0 ) ;
collectionElement . setCreateDate ( date ) ;
} else if ( receiveCollectionElement . getLevel1Type ( ) . equals ( CollectionLevel1TypeEnum . COLOR_BOARD . getRealName ( ) ) ) {
String color = receiveCollectionElement . getRgb ( ) ;
int [ ] rgb = Arrays . stream ( color . split ( " \\ s+ " ) ) . mapToInt ( Integer : : parseInt ) . toArray ( ) ;
QueryWrapper < PanTone > queryWrapper = new QueryWrapper < > ( ) ;
queryWrapper . eq ( " r " , rgb [ 0 ] ) ;
queryWrapper . eq ( " g " , rgb [ 1 ] ) ;
queryWrapper . eq ( " b " , rgb [ 2 ] ) ;
PanTone panTone = panToneMapper . selectOne ( queryWrapper ) ;
if ( Objects . nonNull ( panTone ) ) {
collectionElement . setLevel1Type ( receiveCollectionElement . getLevel1Type ( ) ) ;
collectionElement . setAccountId ( project . getAccountId ( ) ) ;
collectionElement . setProjectId ( project . getId ( ) ) ;
collectionElement . setName ( panTone . getName ( ) ) ;
collectionElement . setHasPin ( ( byte ) 0 ) ;
collectionElement . setColorRgb ( color ) ;
collectionElement . setCreateDate ( date ) ;
}
}
collectionElementList . add ( collectionElement ) ;
}
collectionElementService . saveBatch ( collectionElementList ) ;
}
return Boolean . TRUE ;
}
}