TASK:模块化;

This commit is contained in:
shahaibo
2025-04-25 15:34:35 +08:00
parent 1240a57405
commit 306f4f3987
7 changed files with 281 additions and 123 deletions

View File

@@ -52,7 +52,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify", "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease", "/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify", "/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback","/api/third/party/parseGoogleCredential","/api/third/party/receiveDesignResults","/api/third/party/parseWeChatCode" "/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback","/api/third/party/parseGoogleCredential","/api/third/party/receiveDesignResults","/api/third/party/parseWeChatCode","/api/third/party/receiveDesignParams"
, "api/account/schoolLogin", "api/account/enterpriseLogin", "api/account/organizationNameSearch" , "api/account/schoolLogin", "api/account/enterpriseLogin", "api/account/organizationNameSearch"
); );

View File

@@ -146,4 +146,11 @@ public class ThirdPartyController {
public Response<Boolean> receiveDesignResults(@Valid @RequestBody JSONObject responseObject) { public Response<Boolean> receiveDesignResults(@Valid @RequestBody JSONObject responseObject) {
return Response.success(designService.receiveDesignResults(responseObject)); return Response.success(designService.receiveDesignResults(responseObject));
} }
@ApiOperation(value = "接收Design入参")
@PostMapping("/receiveDesignParams")
@CrossOrigin
public Response<Boolean> receiveDesignParams(@Valid @RequestBody ReceiveDesignParam receiveDesignParam) {
return Response.success(designService.receiveDesignParams(receiveDesignParam));
}
} }

View File

@@ -0,0 +1,11 @@
package com.ai.da.model.dto;
import lombok.Data;
@Data
public class ReceiveCollectionElement {
private String url;
private String level1Type;
private String level2Type;
private String rgb;
}

View File

@@ -0,0 +1,13 @@
package com.ai.da.model.dto;
import lombok.Data;
import java.util.List;
@Data
public class ReceiveDesignParam {
private List<ReceiveCollectionElement> receiveCollectionElementList;
private Long projectId;
}

View File

@@ -117,4 +117,6 @@ public interface DesignService extends IService<Design> {
IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO); IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO);
CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery designCloudResultQuery); CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery designCloudResultQuery);
Boolean receiveDesignParams(ReceiveDesignParam receiveDesignParam);
} }

View File

@@ -1798,20 +1798,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
public String designCloud(CloudTaskDTO cloudTaskDTO) { public String designCloud(CloudTaskDTO cloudTaskDTO) {
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) { if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
Long projectId = cloudTaskDTO.getProjectId(); 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); DesignCollectionDTO designDTO = transDesignParam(projectId);
designDTO.setDesignNum(cloudTaskDTO.getNums()); designDTO.setDesignNum(cloudTaskDTO.getNums());
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
@@ -1858,91 +1844,183 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (!StringUtil.isNullOrEmpty(prompt)) { if (!StringUtil.isNullOrEmpty(prompt)) {
prompt = pythonService.promptTranslate(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(); int fullBatches = toProductImageDTO.getToProductImageVOList().size() / cloudTaskDTO.getNums(); // 可整除的次数
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>(); int remainder = toProductImageDTO.getToProductImageVOList().size() % cloudTaskDTO.getNums(); // 剩下的余数
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(); for (int i1 = 0; i1 < fullBatches; i1++) {
Design design = designMapper.selectById(designId); for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
String productType = "overall"; String taskId;
if (design.getSingleOverall().equals("single")) { if (toProductImageVO.getElementType().equals("DesignOutfit")) {
productType = "single"; taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
sb.append(collect); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
}else {
if (collect.contains("Tops")) { Long designItemId = tDesignPythonOutfit.getDesignItemId();
sb.append("a handsome man,"); 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 { }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)) { }else {
sb.append(",high quality clothing details,8K realistic,HDR"); 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 { }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 {
pythonService.toProductImageBatch(tDesignPythonOutfit.getDesignUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), productType); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
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");
}
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId(); taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型 // 走模型
pythonService.toProductImageBatch(toProductElement.getUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), "overall"); pythonService.toProductImageBatch(toProductElement.getUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), "overall");
ToProductImageResult toProductImageResult = new ToProductImageResult(); ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductElement.getId()); toProductImageResult.setElementId(toProductElement.getId());
toProductImageResult.setElementType("ProductElement"); toProductImageResult.setElementType("ProductElement");
toProductImageResult.setCreateTime(LocalDateTime.now()); toProductImageResult.setCreateTime(LocalDateTime.now());
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId()); toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
// toProductImageResult.setUrl(productImageUrl); toProductImageResult.setIsLike(0);
toProductImageResult.setIsLike(0); toProductImageResult.setTaskId(taskId);
toProductImageResult.setTaskId(taskId); toProductImageResult.setProjectId(projectId);
toProductImageResult.setProjectId(projectId); toProductImageResult.setTaskIdBatch(batchTaskId);
toProductImageResult.setTaskIdBatch(batchTaskId); if (userLikeGroupId != null) {
if (userLikeGroupId != null) { toProductImageResult.setUserLikeGroupId(userLikeGroupId);
toProductImageResult.setUserLikeGroupId(userLikeGroupId); }
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength());
toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult);
} }
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength()); i ++;
toProductImageResultMapper.insert(toProductImageResult); sb = new StringBuilder("The best quality, masterpiece, real image.");
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60)); // 添加需要扣除的积分到预扣除区
result.add(toProductImageResult); creditsService.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 cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
cloudTask.setProjectId(projectId); cloudTask.setProjectId(projectId);
cloudTask.setTaskId(batchTaskId); cloudTask.setTaskId(batchTaskId);
@@ -2012,7 +2090,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setElementType("ToProductImage"); toProductImageResult.setElementType("ToProductImage");
toProductImageResult.setCreateTime(LocalDateTime.now()); toProductImageResult.setCreateTime(LocalDateTime.now());
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId()); toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
// toProductImageResult.setUrl(productImageUrl);
toProductImageResult.setIsLike(0); toProductImageResult.setIsLike(0);
toProductImageResult.setTaskId(taskId); toProductImageResult.setTaskId(taskId);
toProductImageResult.setProjectId(projectId); toProductImageResult.setProjectId(projectId);
@@ -2025,7 +2102,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result.add(toProductImageResult); result.add(toProductImageResult);
}else { }else {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
@@ -2036,7 +2112,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setElementType("ProductElement"); toProductImageResult.setElementType("ProductElement");
toProductImageResult.setCreateTime(LocalDateTime.now()); toProductImageResult.setCreateTime(LocalDateTime.now());
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId()); toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
// toProductImageResult.setUrl(productImageUrl);
toProductImageResult.setIsLike(0); toProductImageResult.setIsLike(0);
toProductImageResult.setTaskId(taskId); toProductImageResult.setTaskId(taskId);
toProductImageResult.setProjectId(projectId); toProductImageResult.setProjectId(projectId);
@@ -2049,11 +2124,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
result.add(toProductImageResult); 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 cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
cloudTask.setProjectId(projectId); cloudTask.setProjectId(projectId);
@@ -2244,7 +2318,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
log.info("增加image_id关联运行时间" + totalTimeInSeconds + ""); log.info("增加image_id关联运行时间" + totalTimeInSeconds + "");
//design //design
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String requestId = UUID.randomUUID().toString(); String requestId = UUID.randomUUID().toString() + "_" + userInfo.getId();
pythonObjects.setRequestId(requestId); pythonObjects.setRequestId(requestId);
AuthPrincipalVo userHolder = UserContext.getUserHolder(); AuthPrincipalVo userHolder = UserContext.getUserHolder();
String taskId = pythonService.designBatch(pythonObjects, userHolder.getId(), elementVO.getDesignNum(), requestId); String taskId = pythonService.designBatch(pythonObjects, userHolder.getId(), elementVO.getDesignNum(), requestId);
@@ -2631,4 +2705,80 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return result; 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;
}
} }

View File

@@ -1664,6 +1664,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
ModuleChooseVO result = new ModuleChooseVO(); ModuleChooseVO result = new ModuleChooseVO();
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
Long projectId = moduleSaveDTO.getProjectId(); Long projectId = moduleSaveDTO.getProjectId();
boolean boundingBox = false; boolean boundingBox = false;
if (Objects.nonNull(moduleSaveDTO.getMoodBoard())) { if (Objects.nonNull(moduleSaveDTO.getMoodBoard())) {
MoodBoardModuleSaveDTO moodBoard = moduleSaveDTO.getMoodBoard(); MoodBoardModuleSaveDTO moodBoard = moduleSaveDTO.getMoodBoard();
@@ -1679,32 +1680,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId()); designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId());
} }
} }
// QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
// qw.lambda().eq(CollectionElement::getProjectId, moduleSaveDTO.getProjectId());
// qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
//// qw.lambda().eq(CollectionElement::getCollectionId, 0);
// List<CollectionElement> compositeImageList = collectionElementMapper.selectList(qw);
// if (CollectionUtils.isEmpty(compositeImageList)) {
// CollectionElement collectionElement = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
// collectionElement.setProjectId(moduleSaveDTO.getProjectId());
// collectionElementMapper.updateById(collectionElement);
// if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
// // 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联
// designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), collectionElement.getId());
// }
// }else {
// CollectionElement compositeImage = compositeImageList.get(0);
// if (!Objects.equals(compositeImage.getId(), moodBoard.getMoodTemplateId())) {
// compositeImage.setProjectId(null);
// CollectionElement collectionElement = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
// collectionElement.setProjectId(moduleSaveDTO.getProjectId());
// collectionElementMapper.updateById(collectionElement);
// if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
// // 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联
// designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), collectionElement.getId());
// }
// }
// }
} }
List<DesignCollectionElementDTO> moodBoards = moodBoard.getMoodBoards(); List<DesignCollectionElementDTO> moodBoards = moodBoard.getMoodBoards();
if (CollectionUtil.isNotEmpty(moodBoards)) { if (CollectionUtil.isNotEmpty(moodBoards)) {