|
|
|
|
@@ -7,11 +7,14 @@ import com.ai.da.common.config.exception.BusinessException;
|
|
|
|
|
import com.ai.da.common.constant.CommonConstant;
|
|
|
|
|
import com.ai.da.common.context.UserContext;
|
|
|
|
|
import com.ai.da.common.enums.*;
|
|
|
|
|
import com.ai.da.common.response.PageBaseResponse;
|
|
|
|
|
import com.ai.da.common.response.ResultEnum;
|
|
|
|
|
import com.ai.da.common.utils.*;
|
|
|
|
|
import com.ai.da.mapper.primary.*;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.*;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.Collection;
|
|
|
|
|
import com.ai.da.model.dto.*;
|
|
|
|
|
import com.ai.da.model.enums.BuildType;
|
|
|
|
|
import com.ai.da.model.vo.*;
|
|
|
|
|
import com.ai.da.python.PythonService;
|
|
|
|
|
import com.ai.da.python.vo.*;
|
|
|
|
|
@@ -27,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.google.common.base.Function;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import okhttp3.*;
|
|
|
|
|
@@ -97,6 +101,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignItemDetailMapper designItemDetailMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ToProductImageResultMapper toProductImageResultMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ToProductElementMapper toProductElementMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MoodboardPositionMapper moodboardPositionMapper;
|
|
|
|
|
@@ -128,6 +138,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|
|
|
|
private CloudTaskMapper cloudTaskMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private CloudTaskService cloudTaskService;
|
|
|
|
|
@Resource
|
|
|
|
|
private CreditsService creditsService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ToProductImageRecordMapper toProductImageRecordMapper;
|
|
|
|
|
|
|
|
|
|
private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
@@ -1780,32 +1794,274 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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, project.getId());
|
|
|
|
|
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
|
|
|
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
|
|
|
|
|
|
|
|
|
DesignCollectionDTO designDTO = transDesignParam(projectId, project.getId());
|
|
|
|
|
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
|
|
|
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
|
|
|
|
//校验collection element
|
|
|
|
|
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
|
|
|
|
|
|
|
|
|
//校验collection element
|
|
|
|
|
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
|
|
|
|
//design
|
|
|
|
|
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, project.getId());
|
|
|
|
|
return taskId;
|
|
|
|
|
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
|
|
|
|
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
|
|
|
|
// 判断用户当前积分是否够本次生成消耗
|
|
|
|
|
// Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, toProductImageDTO.getToProductImageVOList().size());
|
|
|
|
|
// if (!preDeduction) {
|
|
|
|
|
// throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
|
|
|
|
// }
|
|
|
|
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
|
|
|
|
|
|
|
|
|
//design
|
|
|
|
|
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, project.getId());
|
|
|
|
|
return taskId;
|
|
|
|
|
String batchTaskId = UUID.randomUUID() + "-" + userHolder.getId();
|
|
|
|
|
|
|
|
|
|
Long projectId = cloudTaskDTO.getProjectId();
|
|
|
|
|
UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(projectId);
|
|
|
|
|
Long userLikeGroupId = null;
|
|
|
|
|
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
|
|
|
|
toProductImageRecord.setProjectId(projectId);
|
|
|
|
|
if (Objects.nonNull(userLikeGroup)) {
|
|
|
|
|
userLikeGroupId = userLikeGroup.getId();
|
|
|
|
|
toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
|
|
|
|
if (!StringUtils.isEmpty(toProductImageDTO.getPrompt())) {
|
|
|
|
|
toProductImageRecord.setPrompt(toProductImageDTO.getPrompt());
|
|
|
|
|
}
|
|
|
|
|
toProductImageRecordMapper.insert(toProductImageRecord);
|
|
|
|
|
|
|
|
|
|
List<ToProductImageResult> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
// 翻译
|
|
|
|
|
String prompt = toProductImageDTO.getPrompt();
|
|
|
|
|
StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image.");
|
|
|
|
|
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(","));
|
|
|
|
|
|
|
|
|
|
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.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();
|
|
|
|
|
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(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);
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
cloudTask.setCreateTime(now);
|
|
|
|
|
cloudTask.setUpdateTime(now);
|
|
|
|
|
cloudTaskMapper.insert(cloudTask);
|
|
|
|
|
return batchTaskId;
|
|
|
|
|
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {
|
|
|
|
|
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
|
|
|
|
// 判断用户当前积分是否够本次生成消耗
|
|
|
|
|
// Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, toProductImageDTO.getToProductImageVOList().size());
|
|
|
|
|
// if (!preDeduction) {
|
|
|
|
|
// throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
|
|
|
|
String batchTaskId = UUID.randomUUID() + "-" + userHolder.getId();
|
|
|
|
|
Long projectId = cloudTaskDTO.getProjectId();
|
|
|
|
|
UserLikeGroup userLikeGroup = userLikeGroupService.getByProjectId(projectId);
|
|
|
|
|
Long userLikeGroupId = null;
|
|
|
|
|
|
|
|
|
|
ToProductImageRecord toProductImageRecord = new ToProductImageRecord();
|
|
|
|
|
toProductImageRecord.setProjectId(projectId);
|
|
|
|
|
if (Objects.nonNull(userLikeGroup)) {
|
|
|
|
|
userLikeGroupId = userLikeGroup.getId();
|
|
|
|
|
toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toProductImageRecord.setCreateTime(LocalDateTime.now());
|
|
|
|
|
if (!StringUtils.isEmpty(toProductImageDTO.getPrompt())) {
|
|
|
|
|
toProductImageRecord.setPrompt(toProductImageDTO.getPrompt());
|
|
|
|
|
}
|
|
|
|
|
toProductImageRecordMapper.insert(toProductImageRecord);
|
|
|
|
|
|
|
|
|
|
List<ToProductImageResult> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
// 翻译
|
|
|
|
|
String prompt = toProductImageDTO.getPrompt();
|
|
|
|
|
String s = "";
|
|
|
|
|
if (!StringUtil.isNullOrEmpty(prompt)) {
|
|
|
|
|
s = pythonService.promptTranslate(prompt);
|
|
|
|
|
}else {
|
|
|
|
|
s = "Snow moutain, snowy day, natural light";
|
|
|
|
|
}
|
|
|
|
|
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
|
|
|
|
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
|
|
|
|
i ++;
|
|
|
|
|
if (toProductImageVO.getElementType().equals("ToProductImage")) {
|
|
|
|
|
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
|
|
|
|
|
String relightType = "overall";
|
|
|
|
|
if (toProductImageResult1.getElementType().equals("DesignOutfit")) {
|
|
|
|
|
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult1.getElementId());
|
|
|
|
|
Long designId = tDesignPythonOutfit.getDesignId();
|
|
|
|
|
Design design = designMapper.selectById(designId);
|
|
|
|
|
if (design.getSingleOverall().equals("single")) {
|
|
|
|
|
relightType = "single";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 走模型
|
|
|
|
|
pythonService.relightBatch(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection(), relightType);
|
|
|
|
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
|
|
|
|
toProductImageResult.setElementId(toProductImageResult1.getId());
|
|
|
|
|
toProductImageResult.setElementType("ToProductImage");
|
|
|
|
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
|
|
|
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
|
|
|
|
// toProductImageResult.setUrl(productImageUrl);
|
|
|
|
|
toProductImageResult.setIsLike(0);
|
|
|
|
|
toProductImageResult.setTaskId(taskId);
|
|
|
|
|
toProductImageResult.setProjectId(projectId);
|
|
|
|
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
|
|
|
|
if (null != userLikeGroupId) {
|
|
|
|
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
if (toProductImageDTO.getBrightenValue() != null) {
|
|
|
|
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
// 走模型
|
|
|
|
|
pythonService.relightBatch(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection(), "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(taskId);
|
|
|
|
|
toProductImageResult.setProjectId(projectId);
|
|
|
|
|
toProductImageResult.setTaskIdBatch(batchTaskId);
|
|
|
|
|
if (null != userLikeGroupId) {
|
|
|
|
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
if (toProductImageDTO.getBrightenValue() != null) {
|
|
|
|
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
|
|
|
|
cloudTask.setProjectId(projectId);
|
|
|
|
|
cloudTask.setTaskId(batchTaskId);
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
cloudTask.setCreateTime(now);
|
|
|
|
|
cloudTask.setUpdateTime(now);
|
|
|
|
|
cloudTaskMapper.insert(cloudTask);
|
|
|
|
|
return batchTaskId;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DesignCollectionDTO transDesignParam(Long projectId, Long projectIdNew) {
|
|
|
|
|
@@ -2228,30 +2484,58 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<DesignCollectionItemVO> getDesignCloudResult(DesignCloudResultQuery query) {
|
|
|
|
|
CloudTask cloudTask = cloudTaskService.getByTaskId(query.getTaskId());
|
|
|
|
|
if (Objects.nonNull(cloudTask)) {
|
|
|
|
|
Long collectionId = cloudTask.getCollectionId();
|
|
|
|
|
if (null != collectionId) {
|
|
|
|
|
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, collectionId);
|
|
|
|
|
Page<TDesignPythonOutfit> page = designPythonOutfitMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
|
|
|
|
IPage<DesignCollectionItemVO> convert = page.convert((Function<TDesignPythonOutfit, DesignCollectionItemVO>) outfit -> {
|
|
|
|
|
if (outfit != null) {
|
|
|
|
|
DesignCollectionItemVO vo = new DesignCollectionItemVO();
|
|
|
|
|
vo.setDesignOutfitId(outfit.getId());
|
|
|
|
|
vo.setDesignOutfitUrl(minioUtil.getPreSignedUrl(outfit.getDesignUrl(), 24 * 60));
|
|
|
|
|
vo.setDesignItemId(outfit.getDesignItemId());
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
return convert;
|
|
|
|
|
}else {
|
|
|
|
|
return new Page<>();
|
|
|
|
|
public CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery query) {
|
|
|
|
|
CloudTaskResultVO result = new CloudTaskResultVO();
|
|
|
|
|
if (query.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
|
|
|
|
CloudTask cloudTask = cloudTaskService.getByTaskId(query.getTaskId());
|
|
|
|
|
if (Objects.nonNull(cloudTask)) {
|
|
|
|
|
Long collectionId = cloudTask.getCollectionId();
|
|
|
|
|
if (null != collectionId) {
|
|
|
|
|
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
|
|
|
|
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, collectionId);
|
|
|
|
|
Page<TDesignPythonOutfit> page = designPythonOutfitMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
|
|
|
|
IPage<DesignCollectionItemVO> convert = page.convert((Function<TDesignPythonOutfit, DesignCollectionItemVO>) outfit -> {
|
|
|
|
|
if (outfit != null) {
|
|
|
|
|
DesignCollectionItemVO vo = new DesignCollectionItemVO();
|
|
|
|
|
vo.setDesignOutfitId(outfit.getId());
|
|
|
|
|
vo.setDesignOutfitUrl(minioUtil.getPreSignedUrl(outfit.getDesignUrl(), 24 * 60));
|
|
|
|
|
vo.setDesignItemId(outfit.getDesignItemId());
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
result.setDesign(PageBaseResponse.success(convert));
|
|
|
|
|
return result;
|
|
|
|
|
}else {
|
|
|
|
|
result.setDesign(PageBaseResponse.success(new Page<>()));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.setDesign(PageBaseResponse.success(new Page<>()));
|
|
|
|
|
return result;
|
|
|
|
|
} else if (query.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
|
|
|
|
List<MagicToolResultVO> results = new ArrayList<>();
|
|
|
|
|
QueryWrapper<ToProductImageResult> toProductImageResultQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
toProductImageResultQueryWrapper.lambda().eq(ToProductImageResult::getTaskIdBatch, query.getTaskId());
|
|
|
|
|
List<ToProductImageResult> toProductImageResultList = toProductImageResultMapper.selectList(toProductImageResultQueryWrapper);
|
|
|
|
|
for (ToProductImageResult toProductImageResult : toProductImageResultList) {
|
|
|
|
|
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
|
|
|
|
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
|
|
|
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
|
|
|
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
|
|
|
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
|
|
|
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
|
|
|
|
}else {
|
|
|
|
|
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.setToProductImage(results);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return new Page<>();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|