Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
8
src/main/java/com/ai/da/service/CloudTaskService.java
Normal file
8
src/main/java/com/ai/da/service/CloudTaskService.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface CloudTaskService extends IService<CloudTask> {
|
||||
CloudTask getByTaskId(String taskId);
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public interface CreditsService extends IService<CreditsDetail> {
|
||||
|
||||
Boolean creditsPreDeduction(CreditsEventsEnum event, Integer num);
|
||||
|
||||
Boolean creditsPreDeduction(Integer credits);
|
||||
|
||||
void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum);
|
||||
|
||||
Boolean taskCreditsDeduction(Long accountId, String taskId);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.primary.entity.Design;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.CollectionSketchVO;
|
||||
import com.ai.da.model.vo.DesignCollectionVO;
|
||||
import com.ai.da.model.vo.DesignItemDetailVO;
|
||||
import com.ai.da.model.vo.DesignLikeVO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.vo.DesignPythonObjects;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -109,9 +108,13 @@ public interface DesignService extends IService<Design> {
|
||||
|
||||
DesignCollectionVO getDesignResult(String requestId, List<String> objectSignList);
|
||||
|
||||
String designCloud(DesignCollectionDTO designDTO);
|
||||
String designCloud(CloudTaskDTO cloudTaskDTO);
|
||||
|
||||
void processDesignBatch(Map<String, Object> designBatchResult);
|
||||
|
||||
Boolean sort(UserLikeSortDTO userLikeSortDTO);
|
||||
|
||||
IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO);
|
||||
|
||||
CloudTaskResultVO getDesignCloudResult(DesignCloudResultQuery designCloudResultQuery);
|
||||
}
|
||||
|
||||
@@ -63,4 +63,6 @@ public interface GenerateService extends IService<Generate> {
|
||||
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
||||
|
||||
List<Map<String, String>> getAllPose();
|
||||
|
||||
void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress);
|
||||
}
|
||||
|
||||
28
src/main/java/com/ai/da/service/ProjectService.java
Normal file
28
src/main/java/com/ai/da/service/ProjectService.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Design;
|
||||
import com.ai.da.mapper.primary.entity.Project;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.CollectionSketchVO;
|
||||
import com.ai.da.model.vo.DesignCollectionVO;
|
||||
import com.ai.da.model.vo.DesignItemDetailVO;
|
||||
import com.ai.da.model.vo.DesignLikeVO;
|
||||
import com.ai.da.python.vo.DesignPythonObjects;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2022-09-11
|
||||
*/
|
||||
public interface ProjectService extends IService<Project> {
|
||||
|
||||
Set<Long> getChildProjectIdSet(Long projectId);
|
||||
}
|
||||
@@ -109,4 +109,8 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
Boolean delete(Long projectId);
|
||||
|
||||
Boolean brandDNADelete(BrandDNADTO brandDNADTO);
|
||||
|
||||
void toProductBatch(String taskId, String url, String progress);
|
||||
|
||||
void relightBatch(String taskId, String url, String progress);
|
||||
}
|
||||
|
||||
@@ -1388,6 +1388,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
config.setJdbcUrl("jdbc:mysql://code-create.com.hk:3306/db1nfvsgmjp3b8");
|
||||
config.setUsername("uafqtz4gsvfrw");
|
||||
config.setPassword("aida123456.");
|
||||
// config.setJdbcUrl("jdbc:mysql://18.167.251.121:33008/aida");
|
||||
// config.setUsername("aida_con");
|
||||
// config.setPassword("123456");
|
||||
// config.setJdbcUrl("jdbc:mysql://localhost:3306/code-create-local?serverTimezone=UTC");
|
||||
// config.setUsername("root");
|
||||
// config.setPassword("root");
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.CloudTaskMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.CloudTask;
|
||||
import com.ai.da.service.ClassificationService;
|
||||
import com.ai.da.service.CloudTaskService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CloudTaskServiceImpl extends ServiceImpl<CloudTaskMapper, CloudTask> implements CloudTaskService {
|
||||
@Resource
|
||||
private CloudTaskMapper cloudTaskMapper;
|
||||
|
||||
@Override
|
||||
public CloudTask getByTaskId(String taskId) {
|
||||
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||
return cloudTaskMapper.selectOne(qw);
|
||||
}
|
||||
}
|
||||
@@ -227,6 +227,32 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean creditsPreDeduction(Integer credits) {
|
||||
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
|
||||
// 1、获取当前在积分预扣除区,未来需要预扣除的积分总和
|
||||
Set<String> keys = redisUtil.getKeysFromString(creditsDeduction + ":" + accountId + ":*");
|
||||
List<String> multiValue = redisUtil.getMultiValue(keys);
|
||||
// 1.1 预扣除区 积分总和
|
||||
int sum = multiValue.stream().mapToInt(Integer::parseInt).sum();
|
||||
// 1.2 加上本次操作需要扣除的积分
|
||||
sum += credits;
|
||||
|
||||
// 2、获取当前积分
|
||||
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
||||
BigDecimal subtract = existingCredits.subtract(new BigDecimal(sum));
|
||||
|
||||
// 3、判断剩余积分是否够本次操作
|
||||
if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 3.1 不够,直接返回余额不够,充值
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecordToCreditsDeduction(Long accountId, String taskId, CreditsEventsEnum creditsEventsEnum) {
|
||||
// 5、添加当前任务的预扣积分到redis 任务有效期一天,若待扣积分两天还没被移除,说明任务已经失败,待扣积分自动失效
|
||||
|
||||
@@ -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.*;
|
||||
@@ -22,8 +25,12 @@ import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.*;
|
||||
@@ -37,6 +44,7 @@ import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -93,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;
|
||||
@@ -110,12 +124,26 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
|
||||
@Resource
|
||||
private DesignBatchMapper designBatchMapper;
|
||||
|
||||
@Resource
|
||||
private UserLikeSortMapper userLikeSortMapper;
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
@Resource
|
||||
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<>();
|
||||
|
||||
@@ -308,8 +336,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
Long collectionId;
|
||||
if (null == collectionIdParam) {
|
||||
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
|
||||
// String moodboardPosition = designDTO.getMoodboardPosition();
|
||||
// parseMoodboardPosition(moodboardPosition, collectionId);
|
||||
}else {
|
||||
collectionId = collectionIdParam;
|
||||
}
|
||||
@@ -1769,23 +1795,427 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public String designCloud(DesignCollectionDTO designDTO) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
//校验collection element
|
||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||
//design
|
||||
return designBatch(designDTO, userInfo, null, elementVO);
|
||||
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();
|
||||
|
||||
//校验collection element
|
||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||
|
||||
//design
|
||||
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
|
||||
return taskId;
|
||||
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
||||
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||
// 判断用户当前积分是否够本次生成消耗
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||
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();
|
||||
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);
|
||||
cloudTask.setStatus(0);
|
||||
cloudTaskMapper.insert(cloudTask);
|
||||
return batchTaskId;
|
||||
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {
|
||||
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||
// 判断用户当前积分是否够本次生成消耗
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||
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);
|
||||
cloudTask.setStatus(0);
|
||||
cloudTaskMapper.insert(cloudTask);
|
||||
return batchTaskId;
|
||||
} else if (cloudTaskDTO.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(cloudTaskDTO.getCostCredits());
|
||||
if (!preDeduction) {
|
||||
throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
|
||||
}
|
||||
List<PoseTransformBatchDTO> poseTransformList = cloudTaskDTO.getPoseTransform();
|
||||
if (CollectionUtil.isNotEmpty(poseTransformList)) {
|
||||
String taskBatchId = UUID.randomUUID().toString() + "-" + accountId;
|
||||
for (PoseTransformBatchDTO poseTransformBatchDTO : poseTransformList) {
|
||||
// 1、判断用户当前积分是否够本次生成消耗
|
||||
CreditsEventsEnum creditsEventsEnum = CreditsEventsEnum.POSE_TRANSFORMATION;
|
||||
|
||||
// 3、生成唯一id 使用uuid,由于uuid重复的几率很小,故取消对uuid重复性的校验
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String taskId = uuid + "-" + accountId;
|
||||
|
||||
PoseTransformation poseTransformation = new PoseTransformation();
|
||||
poseTransformation.setProjectId(cloudTaskDTO.getProjectId());
|
||||
poseTransformation.setAccountId(accountId);
|
||||
poseTransformation.setUniqueId(taskId);
|
||||
poseTransformation.setProductImage(poseTransformBatchDTO.getProductImage());
|
||||
poseTransformation.setPoseId(poseTransformBatchDTO.getPoseId());
|
||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||
poseTransformation.setTaskIdBatch(taskBatchId);
|
||||
poseTransformationMapper.insert(poseTransformation);
|
||||
|
||||
Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId);
|
||||
if (b){
|
||||
// 6、添加预扣除积分到redis
|
||||
creditsService.addRecordToCreditsDeduction(accountId, uuid, creditsEventsEnum);
|
||||
// 6.1 添加积分扣除记录到db
|
||||
creditsService.preInsert(accountId, creditsEventsEnum.getName(), uuid, Boolean.TRUE, null);
|
||||
}else {
|
||||
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
|
||||
}
|
||||
}
|
||||
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||
cloudTask.setProjectId(cloudTask.getProjectId());
|
||||
cloudTask.setTaskId(taskBatchId);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
cloudTask.setCreateTime(now);
|
||||
cloudTask.setUpdateTime(now);
|
||||
cloudTask.setStatus(0);
|
||||
cloudTaskMapper.insert(cloudTask);
|
||||
return taskBatchId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String designBatch(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, Long collectionIdParam, ValidateElementVO elementVO) {
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
|
||||
//编辑sketchBoard
|
||||
collectionElementService.editSketchBoardsElement(elementVO, designDTO.getSketchBoards());
|
||||
private DesignCollectionDTO transDesignParam(Long projectId) {
|
||||
DesignCollectionDTO designCollectionDTO = new DesignCollectionDTO();
|
||||
List<CollectionElement> collectionElementList = collectionElementService.getByProjectId(projectId);
|
||||
if (CollectionUtil.isNotEmpty(collectionElementList)) {
|
||||
Map<String, List<CollectionElement>> groupedMap = collectionElementList.stream().collect(Collectors.groupingBy(CollectionElement::getLevel1Type));
|
||||
if (CollectionUtil.isNotEmpty(groupedMap.get("Moodboard"))) {
|
||||
List<DesignCollectionElementDTO> moodBoards = new ArrayList<>();
|
||||
List<CollectionElement> moodboardList = groupedMap.get("Moodboard");
|
||||
for (CollectionElement collectionElement : moodboardList) {
|
||||
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
|
||||
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId()));
|
||||
}else {
|
||||
DesignCollectionElementDTO dto = new DesignCollectionElementDTO();
|
||||
dto.setId(collectionElement.getId());
|
||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
moodBoards.add(dto);
|
||||
}
|
||||
}
|
||||
designCollectionDTO.setMoodBoards(moodBoards);
|
||||
}else {
|
||||
designCollectionDTO.setMoodBoards(new ArrayList<>());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) {
|
||||
List<DesignCollectionPrintElementDTO> printBoards = new ArrayList<>();
|
||||
List<CollectionElement> printBoardList = groupedMap.get("Printboard");
|
||||
for (CollectionElement collectionElement : printBoardList) {
|
||||
DesignCollectionPrintElementDTO dto = new DesignCollectionPrintElementDTO();
|
||||
dto.setId(collectionElement.getId());
|
||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
printBoards.add(dto);
|
||||
}
|
||||
designCollectionDTO.setPrintBoards(printBoards);
|
||||
}else {
|
||||
designCollectionDTO.setPrintBoards(new ArrayList<>());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) {
|
||||
List<CollectionColorDTO> colorBoards = new ArrayList<>();
|
||||
List<CollectionElement> colorBoardList = groupedMap.get("Colorboard");
|
||||
for (CollectionElement collectionElement : colorBoardList) {
|
||||
CollectionColorDTO dto = new CollectionColorDTO();
|
||||
String name = collectionElement.getName();
|
||||
if (name.contains("_")) {
|
||||
String[] split = name.split("_");
|
||||
dto.setId(Integer.valueOf(split[0]));
|
||||
dto.setName(split[1]);
|
||||
dto.setTcx(split[2]);
|
||||
}
|
||||
dto.setRgbValue(collectionElement.getColorRgb());
|
||||
if (collectionElement.getGradientString() != null && !collectionElement.getGradientString().equals("null")) {
|
||||
dto.setGradientString(collectionElement.getGradientString());
|
||||
}
|
||||
colorBoards.add(dto);
|
||||
}
|
||||
designCollectionDTO.setColorBoards(colorBoards);
|
||||
}else {
|
||||
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) {
|
||||
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
||||
List<CollectionElement> sketchBoardList = groupedMap.get("Sketchboard");
|
||||
for (CollectionElement collectionElement : sketchBoardList) {
|
||||
CollectionSketchDTO dto = new CollectionSketchDTO();
|
||||
dto.setSketchBoardId(collectionElement.getId());
|
||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
dto.setLevel2Type(collectionElement.getLevel2Type());
|
||||
dto.setIsPin(collectionElement.getHasPin());
|
||||
sketchBoards.add(dto);
|
||||
}
|
||||
designCollectionDTO.setSketchBoards(sketchBoards);
|
||||
}else {
|
||||
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||
}
|
||||
}else {
|
||||
designCollectionDTO.setMoodBoards(new ArrayList<>());
|
||||
designCollectionDTO.setPrintBoards(new ArrayList<>());
|
||||
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
|
||||
//编辑printBoard
|
||||
collectionElementService.editPrintBoardsElement(elementVO, designDTO.getPrintBoards());
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceService.getById(workspaceId);
|
||||
designCollectionDTO.setSystemScale(
|
||||
BigDecimal.valueOf(workspace.getSystemDesignerPercentage())
|
||||
.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)
|
||||
);
|
||||
designCollectionDTO.setModelSex(workspace.getSex());
|
||||
if (workspace.getSex().equals("Female")) {
|
||||
designCollectionDTO.setTemplateId(workspace.getMannequinFemaleId());
|
||||
designCollectionDTO.setModelType(workspace.getMannequinFemaleType());
|
||||
}
|
||||
if (workspace.getPosition().equals("Overall")) {
|
||||
designCollectionDTO.setSingleOverall("overall");
|
||||
}else {
|
||||
designCollectionDTO.setSingleOverall("single");
|
||||
designCollectionDTO.setSwitchCategory(workspace.getPosition());
|
||||
}
|
||||
designCollectionDTO.setTimeZone("Etc/GMT-8");
|
||||
return designCollectionDTO;
|
||||
}
|
||||
|
||||
private String designBatch(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, Long collectionIdParam, ValidateElementVO elementVO, CloudTaskDTO cloudTaskDTO, Long projectId) {
|
||||
//保存collection
|
||||
Long collectionId;
|
||||
if (null == collectionIdParam) {
|
||||
@@ -1796,16 +2226,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<Long> elementIds = getElementId(elementVO);
|
||||
//批量关联element 到 collection
|
||||
collectionElementService.relationCollection(elementIds, collectionId);
|
||||
//library转化为collection(生成)
|
||||
saveCollectionElemntsByLibrarys(elementVO, collectionId);
|
||||
//generate转化为collection(生成)
|
||||
saveCollectionElemntsByGenerates(elementVO, collectionId);
|
||||
//保存颜色版
|
||||
collectionElementService.saveColorBoard(designDTO.getColorBoards(), collectionId, designDTO.getTimeZone());
|
||||
//保存design
|
||||
Long designId = saveOne(designDTO, collectionId, userInfo.getId());
|
||||
//计算library
|
||||
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
|
||||
|
||||
//组装design入参
|
||||
long startTime = System.currentTimeMillis();
|
||||
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
|
||||
@@ -1826,17 +2249,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
String taskId = pythonService.designBatch(pythonObjects, userHolder.getId(), elementVO.getDesignNum(), requestId);
|
||||
|
||||
DesignBatch designBatch = new DesignBatch();
|
||||
|
||||
designBatch.setAccountId(userInfo.getId());
|
||||
designBatch.setDesignId(designId);
|
||||
designBatch.setCollectionId(collectionId);
|
||||
designBatch.setTaskId(taskId);
|
||||
designBatch.setCreateTime(LocalDateTime.now());
|
||||
designBatch.setStatus(0);
|
||||
designBatch.setTotalNum(elementVO.getDesignNum());
|
||||
designBatchMapper.insert(designBatch);
|
||||
|
||||
endTime = System.currentTimeMillis();
|
||||
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||
log.info("design python端运行时间:" + totalTimeInSeconds + " 秒");
|
||||
@@ -1844,9 +2256,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
startTime = System.currentTimeMillis();
|
||||
generateLibrary(elementVO, designDTO.getTimeZone());
|
||||
//处理关联关系,修复element覆盖得情况
|
||||
List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
|
||||
// List<Long> relationElementIds = relationElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||
// handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
|
||||
endTime = System.currentTimeMillis();
|
||||
totalTimeInSeconds = (endTime - startTime) / 1000;
|
||||
log.info("处理关联关系运行时间:" + totalTimeInSeconds + " 秒");
|
||||
@@ -1863,6 +2275,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
// 将上下文存入全局设计上下文中
|
||||
designContext.put(taskId, context);
|
||||
CloudTask cloudTask = CopyUtil.copyObject(cloudTaskDTO, CloudTask.class);
|
||||
cloudTask.setProjectId(projectId);
|
||||
cloudTask.setDesignId(designId);
|
||||
cloudTask.setCollectionId(collectionId);
|
||||
cloudTask.setTaskId(taskId);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
cloudTask.setCreateTime(now);
|
||||
cloudTask.setUpdateTime(now);
|
||||
cloudTask.setStatus(0);
|
||||
cloudTaskMapper.insert(cloudTask);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@@ -1875,28 +2297,29 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
if (progress.equals("ok")) {
|
||||
String taskId = (String) designBatchResult.get("task_id");
|
||||
QueryWrapper<DesignBatch> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(DesignBatch::getTaskId, taskId);
|
||||
List<DesignBatch> designBatches = designBatchMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(designBatches)) {
|
||||
DesignBatch designBatch = designBatches.get(0);
|
||||
designBatch.setStatus(1);
|
||||
designBatchMapper.updateById(designBatch);
|
||||
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||
List<CloudTask> cloudTaskList = cloudTaskMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(cloudTaskList)) {
|
||||
CloudTask cloudTask = cloudTaskList.get(0);
|
||||
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||
cloudTask.setStatus(1);
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
String taskId = (String) designBatchResult.get("task_id");
|
||||
QueryWrapper<DesignBatch> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(DesignBatch::getTaskId, taskId);
|
||||
List<DesignBatch> designBatches = designBatchMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(designBatches)) {
|
||||
DesignBatch designBatch = designBatches.get(0);
|
||||
if (designBatch.getCompletedNum() == null) {
|
||||
designBatch.setCompletedNum(1);
|
||||
QueryWrapper<CloudTask> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CloudTask::getTaskId, taskId);
|
||||
List<CloudTask> cloudTaskList = cloudTaskMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(cloudTaskList)) {
|
||||
CloudTask cloudTask = cloudTaskList.get(0);
|
||||
if (cloudTask.getCompletedNum() == null) {
|
||||
cloudTask.setCompletedNum(1);
|
||||
}else {
|
||||
designBatch.setCompletedNum(designBatch.getCompletedNum() + 1);
|
||||
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||
}
|
||||
designBatchMapper.updateById(designBatch);
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
|
||||
Integer i = (Integer) progress;
|
||||
@@ -1915,7 +2338,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
String timeZone = (String) context.get("timeZone");
|
||||
String singleOverall = (String) context.get("singleOverall");
|
||||
|
||||
DesignPythonObject item = pythonObjects.getObjects().get(i);
|
||||
DesignPythonObject item = pythonObjects.getObjects().get(i-1);
|
||||
DesignItem designItem = new DesignItem();
|
||||
designItem.setAccountId(userInfo.getId());
|
||||
designItem.setCollectionId(collectionId);
|
||||
@@ -2029,12 +2452,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i = 0; i < pythonObjects.getObjects().size(); i++) {
|
||||
//
|
||||
// }
|
||||
// response.setProcessId(pythonObjects.getProcess_id());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2050,4 +2467,168 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<CloudTaskVO> cloudPage(CloudPageDTO cloudPageDTO) {
|
||||
// 分页数据
|
||||
Set<Long> childProjectIdSet = projectService.getChildProjectIdSet(cloudPageDTO.getProjectId());
|
||||
childProjectIdSet.add(cloudPageDTO.getProjectId());
|
||||
QueryWrapper<CloudTask> queryWrapper = new QueryWrapper<>();
|
||||
if (CollectionUtil.isNotEmpty(childProjectIdSet)) {
|
||||
queryWrapper.lambda().in(CloudTask::getProjectId, childProjectIdSet);
|
||||
}else {
|
||||
return new Page<>();
|
||||
}
|
||||
IPage<CloudTask> page = cloudTaskMapper.selectPage(
|
||||
new Page<>(cloudPageDTO.getPage(), cloudPageDTO.getSize()), queryWrapper);
|
||||
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||
return new Page<>();
|
||||
}
|
||||
|
||||
IPage<CloudTaskVO> convert = page.convert((Function<CloudTask, CloudTaskVO>) cloudTask -> {
|
||||
if (cloudTask != null) {
|
||||
CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class);
|
||||
if (cloudTaskVO.getCompletedNum() == null) {
|
||||
cloudTaskVO.setProcess("0%");
|
||||
}else {
|
||||
BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum());
|
||||
BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums());
|
||||
|
||||
BigDecimal percent = completed
|
||||
.divide(total, 4, RoundingMode.HALF_UP) // 先计算小数百分比,保留4位防止精度问题
|
||||
.multiply(BigDecimal.valueOf(100)) // 乘以100变成百分比
|
||||
.setScale(2, RoundingMode.HALF_UP); // 最终保留2位小数
|
||||
|
||||
cloudTaskVO.setProcess(percent.toPlainString() + "%");
|
||||
}
|
||||
return cloudTaskVO;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return convert;
|
||||
}
|
||||
|
||||
@Value("${redis.key.toProductImageResultKey}")
|
||||
private String toProductImageResultKey;
|
||||
@Value("${redis.key.relightResultKey}")
|
||||
private String relightResultKey;
|
||||
|
||||
@Override
|
||||
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);
|
||||
List<TDesignPythonOutfit> list = designPythonOutfitMapper.selectList(qw);
|
||||
List<DesignCollectionItemVO> voList = new ArrayList<>();
|
||||
for (TDesignPythonOutfit tDesignPythonOutfit : list) {
|
||||
DesignCollectionItemVO vo = new DesignCollectionItemVO();
|
||||
vo.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
vo.setDesignOutfitUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
vo.setDesignItemId(tDesignPythonOutfit.getDesignItemId());
|
||||
voList.add(vo);
|
||||
}
|
||||
result.setDesign(voList);
|
||||
// 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(new ArrayList<>());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result.setDesign(new ArrayList<>());
|
||||
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.setId(toProductImageResult.getId());
|
||||
magicToolResultVO.setTaskId(toProductImageResult.getTaskId());
|
||||
magicToolResultVO.setStatus("Success");
|
||||
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));
|
||||
}
|
||||
results.add(magicToolResultVO);
|
||||
}
|
||||
result.setToProductImage(results);
|
||||
return result;
|
||||
} else if (query.getBuildType().equals(BuildType.RELIGHT.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.setId(toProductImageResult.getId());
|
||||
magicToolResultVO.setTaskId(toProductImageResult.getTaskId());
|
||||
magicToolResultVO.setStatus("Success");
|
||||
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 {
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId());
|
||||
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
|
||||
}
|
||||
results.add(magicToolResultVO);
|
||||
}
|
||||
result.setRelight(results);
|
||||
return result;
|
||||
} else if (query.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||
String taskId = query.getTaskId();
|
||||
QueryWrapper<PoseTransformation> poseTransformationQueryWrapper = new QueryWrapper<>();
|
||||
poseTransformationQueryWrapper.lambda().eq(PoseTransformation::getTaskIdBatch, taskId);
|
||||
List<PoseTransformation> poseTransformationList = poseTransformationMapper.selectList(poseTransformationQueryWrapper);
|
||||
List<PoseTransformationVO> voList = new ArrayList<>();
|
||||
for (PoseTransformation poseTransformation : poseTransformationList) {
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
|
||||
poseTransformationVO.setId(poseTransformation.getId());
|
||||
poseTransformationVO.setIsLiked(poseTransformation.getIsLiked());
|
||||
poseTransformationVO.setStatus("Success");
|
||||
poseTransformationVO.setTaskId(poseTransformation.getUniqueId());
|
||||
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
if (null != poseTransformation.getGifUrl()){
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (null != poseTransformation.getVideoUrl()){
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (null != poseTransformation.getFirstFrameUrl()){
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
voList.add(poseTransformationVO);
|
||||
}
|
||||
result.setPoseTransfer(voList);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -969,6 +969,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
@Resource
|
||||
private CloudTaskMapper cloudTaskMapper;
|
||||
|
||||
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
||||
// 1、存储模型返回的数据
|
||||
@@ -1202,4 +1204,54 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
return Arrays.asList(resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress) {
|
||||
// 1、存储模型返回的数据
|
||||
PoseTransformation poseTransformation;
|
||||
QueryWrapper<PoseTransformation> qw = new QueryWrapper<>();
|
||||
qw.eq("unique_id", taskId);
|
||||
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(qw);
|
||||
if (poseTransformations != null && poseTransformations.size() > 1){
|
||||
log.warn("通过taskId {} 查询到的PoseTransformation的结果不止一条", taskId);
|
||||
}else if (poseTransformations == null || poseTransformations.isEmpty()){
|
||||
return ;
|
||||
}
|
||||
poseTransformation = poseTransformations.get(0);
|
||||
poseTransformation.setGifUrl(gifUrl);
|
||||
poseTransformation.setVideoUrl(videoUrl);
|
||||
poseTransformation.setFirstFrameUrl(imageUrl);
|
||||
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.updateById(poseTransformation);
|
||||
|
||||
String taskIdBatch = poseTransformation.getTaskIdBatch();
|
||||
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||
if (Objects.nonNull(cloudTask)) {
|
||||
if (cloudTask.getCompletedNum() == null) {
|
||||
cloudTask.setCompletedNum(1);
|
||||
}else {
|
||||
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||
}
|
||||
if (progress.equals("OK")) {
|
||||
cloudTask.setStatus(1);
|
||||
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||
}
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
||||
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
||||
|
||||
// 2、更新redis
|
||||
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
// 3、执行积分扣除
|
||||
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||
String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||
if (flag) creditsService.updateChangedCredits(accountId, uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
@@ -25,6 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.base.Function;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -135,7 +137,9 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
PortfolioDTO portfolioDTO = JSONObject.parseObject(data, PortfolioDTO.class);
|
||||
QueryWrapper<Portfolio> existSameNameQw = new QueryWrapper<>();
|
||||
existSameNameQw.lambda().ne(Portfolio::getId, portfolioDTO.getId());
|
||||
if (null != portfolioDTO.getId()) {
|
||||
existSameNameQw.lambda().ne(Portfolio::getId, portfolioDTO.getId());
|
||||
}
|
||||
existSameNameQw.lambda().eq(Portfolio::getPortfolioName, portfolioDTO.getPortfolioName());
|
||||
existSameNameQw.lambda().eq(Portfolio::getAccountId, authPrincipalVo.getId());
|
||||
List<Portfolio> portfoliosSameName = portfolioMapper.selectList(existSameNameQw);
|
||||
@@ -148,6 +152,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
}
|
||||
if (file != null && file.getOriginalFilename() != null) {
|
||||
Long portfolioId;
|
||||
// 上传画布到minio
|
||||
String upload = minioUtil.upload("aida-canvas", String.valueOf(authPrincipalVo.getId()), file);
|
||||
Canvas canvas = new Canvas();
|
||||
canvas.setUrl(upload);
|
||||
@@ -155,21 +160,20 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
canvas.setAccountId(authPrincipalVo.getId());
|
||||
canvasMapper.insert(canvas);
|
||||
|
||||
// 创建portfolio
|
||||
Portfolio portfolio = new Portfolio();
|
||||
QueryWrapper<Portfolio> portfolioQueryWrapper = new QueryWrapper<>();
|
||||
portfolioQueryWrapper.lambda().eq(Portfolio::getProjectId, portfolioDTO.getProjectId());
|
||||
List<Portfolio> portfolioList = portfolioMapper.selectList(portfolioQueryWrapper);
|
||||
if (!CollectionUtils.isEmpty(portfolioList)) {
|
||||
portfolio = portfolioList.get(0);
|
||||
if (null != portfolioDTO.getId()) {
|
||||
portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
}
|
||||
// 关联的项目ID
|
||||
Long projectId = portfolioDTO.getProjectId();
|
||||
// 复制project表
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
if (project.getOriginal() == 0) {
|
||||
if (project.getOriginal() != null && project.getOriginal() == 0) {
|
||||
portfolio.setOriginal(0);
|
||||
portfolio.setOriginalAccountId(project.getOriginalAccountId());
|
||||
// TODO
|
||||
portfolio.setOriginalPortfolioId(project.getOriginalPortfolioId());
|
||||
} else {
|
||||
}else {
|
||||
portfolio.setOriginal(1);
|
||||
}
|
||||
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
|
||||
@@ -178,132 +182,79 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
portfolio.setUpdateDate(LocalDateTime.now());
|
||||
portfolio.setStatus(1);
|
||||
portfolio.setIsDeleted(0);
|
||||
portfolio.setUserLikeGroupSourceId(portfolioDTO.getUserLikeGroupId());
|
||||
portfolio.setCanvasId(canvas.getId());
|
||||
portfolio.setPortfolioDes(portfolioDTO.getPortfolioDes());
|
||||
|
||||
Long workspaceId = workspaceService.getByProjectId(project.getId());
|
||||
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
||||
|
||||
project.setId(null);
|
||||
project.setAccountId(-1L);
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
projectMapper.insert(project);
|
||||
Long projectIdCopy = project.getId();
|
||||
|
||||
workspace.setProjectId(projectIdCopy);
|
||||
workspace.setAccountId(-1L);
|
||||
workspaceMapper.insert(workspace);
|
||||
|
||||
if (portfolioDTO.getOpenSource() == 1) {
|
||||
// 副本存储对象
|
||||
ProjectSnapshot projectSnapshot = new ProjectSnapshot();
|
||||
// 根据项目ID获取项目设置
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceMapper.selectById(workspaceId);
|
||||
|
||||
project.setId(null);
|
||||
projectSnapshot.setProject(project);
|
||||
workspace.setId(null);
|
||||
projectSnapshot.setWorkspace(workspace);
|
||||
|
||||
portfolio.setPortfolioType("History");
|
||||
portfolio.setOpenSource(1);
|
||||
|
||||
List<CollectionElement> collectionElementListOld = collectionElementService.getByProjectId(projectId);
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setProjectId(projectIdCopy);
|
||||
element.setId(null);
|
||||
collectionElementMapper.insert(element);
|
||||
}
|
||||
projectSnapshot.setCollectionElementList(collectionElementListOld);
|
||||
|
||||
UserLikeGroup userLikeGroup = userLikeService.getUserLikeGroupByProjectId(projectId);
|
||||
if (Objects.nonNull(userLikeGroup)) {
|
||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
||||
userLikeGroupNew.setId(null);
|
||||
userLikeGroupNew.setAccountId(-1L);
|
||||
userLikeGroupNew.setProjectId(projectIdCopy);
|
||||
Long collectionIdOld = userLikeGroup.getCollectionId();
|
||||
QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
|
||||
designQueryWrapper.lambda().eq(Design::getCollectionId, collectionIdOld);
|
||||
Design designOld = designMapper.selectOne(designQueryWrapper);
|
||||
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
||||
projectSnapshot.setUserLikeGroup(userLikeGroup);
|
||||
|
||||
collectionOld.setId(null);
|
||||
collectionMapper.insert(collectionOld);
|
||||
Long collectionIdNew = collectionOld.getId();
|
||||
|
||||
portfolio.setCollectionId(collectionIdNew);
|
||||
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setCollectionId(collectionIdNew);
|
||||
collectionElementMapper.updateById(element);
|
||||
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
||||
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
||||
collectionElementRelationNew.setElementId(element.getId());
|
||||
collectionElementRelationNew.setCreateDate(new Date());
|
||||
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
||||
}
|
||||
|
||||
designOld.setCollectionId(collectionIdNew);
|
||||
designOld.setId(null);
|
||||
designMapper.insert(designOld);
|
||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
|
||||
List<UserLikeSnapshot> list = new ArrayList<>();
|
||||
for (UserLike userLike : userLikeList) {
|
||||
UserLikeSnapshot userLikeSnapshot = CopyUtil.copyObject(userLike, UserLikeSnapshot.class);
|
||||
|
||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
||||
designPythonOutfit.setDesignId(-1L);
|
||||
designPythonOutfit.setDesignItemId(-1L);
|
||||
designPythonOutfit.setCollectionId(collectionIdNew);
|
||||
designPythonOutfit.setId(null);
|
||||
|
||||
Long designItemIdOld = userLike.getDesignItemId();
|
||||
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
||||
designItemOld.setId(null);
|
||||
designItemOld.setAccountId(-1L);
|
||||
designItemOld.setDesignId(-1L);
|
||||
designItemOld.setCollectionId(collectionIdNew);
|
||||
designItemMapper.insert(designItemOld);
|
||||
Long designItemIdNew = designItemOld.getId();
|
||||
|
||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
||||
userLikeSnapshot.setDesignItem(designItemOld);
|
||||
userLikeSnapshot.setDesignPythonOutfit(designPythonOutfit);
|
||||
|
||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
tDesignPythonOutfitDetail.setId(null);
|
||||
tDesignPythonOutfitDetail.setDesignId(-1L);
|
||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
||||
}
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetailList = designPythonOutfitDetailMapper.selectList(qw);
|
||||
userLikeSnapshot.setTDesignPythonOutfitDetailList(tDesignPythonOutfitDetailList);
|
||||
|
||||
|
||||
userLike.setDesignItemId(designItemIdNew);
|
||||
userLike.setId(null);
|
||||
userLike.setDesignId(-1L);
|
||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
||||
userLikeMapper.insert(userLike);
|
||||
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemIdOld);
|
||||
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||
List<DesignItemDetailSnapshot> designItemDetailSnapshotList = new ArrayList<>();
|
||||
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
||||
DesignItemDetailSnapshot designItemDetailSnapshot = CopyUtil.copyObject(designItemDetailOld, DesignItemDetailSnapshot.class);
|
||||
Long designItemDetailIdOld = designItemDetailOld.getId();
|
||||
designItemDetailOld.setId(null);
|
||||
designItemDetailOld.setAccountId(-1L);
|
||||
designItemDetailOld.setDesignId(-1L);
|
||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
||||
designItemDetailMapper.insert(designItemDetailOld);
|
||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||
|
||||
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
||||
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
||||
List<DesignItemDetailPrint> designItemDetailPrints = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrints) {
|
||||
designItemDetailPrint.setId(null);
|
||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
||||
}
|
||||
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||
designItemDetailSnapshot.setDesignItemDetailPrintList(designItemDetailPrintList);
|
||||
designItemDetailSnapshotList.add(designItemDetailSnapshot);
|
||||
}
|
||||
userLikeSnapshot.setDesignItemDetailList(designItemDetailSnapshotList);
|
||||
list.add(userLikeSnapshot);
|
||||
}
|
||||
projectSnapshot.setUserLikeList(list);
|
||||
}
|
||||
String snapshotJson = JSONObject.toJSONString(projectSnapshot);
|
||||
portfolio.setSnapshot(snapshotJson);
|
||||
} else {
|
||||
|
||||
portfolio.setPortfolioType("Canvas");
|
||||
|
||||
portfolio.setOpenSource(0);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(portfolioList)) {
|
||||
if (null != portfolioDTO.getId()) {
|
||||
portfolioMapper.updateById(portfolio);
|
||||
} else {
|
||||
portfolioMapper.insert(portfolio);
|
||||
@@ -551,22 +502,25 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
||||
if (vo.getOpenSource() == 1) {
|
||||
Long collectionId = portfolio.getCollectionId();
|
||||
List<CollectionElement> collectionElementList = collectionElementService.getByCollectionId(collectionId);
|
||||
for (CollectionElement element : collectionElementList) {
|
||||
if (StringUtils.isEmpty(element.getUrl())) {
|
||||
continue;
|
||||
if (!StringUtils.isEmpty(portfolio.getSnapshot())) {
|
||||
ProjectSnapshot projectSnapshot = JSONObject.parseObject(portfolio.getSnapshot(), ProjectSnapshot.class);
|
||||
List<CollectionElement> collectionElementList = projectSnapshot.getCollectionElementList();
|
||||
for (CollectionElement element : collectionElementList) {
|
||||
if (StringUtils.isEmpty(element.getUrl())) {
|
||||
continue;
|
||||
}
|
||||
element.setUrl(minioUtil.getPreSignedUrl(element.getUrl(), 24 * 60));
|
||||
}
|
||||
element.setUrl(minioUtil.getPreSignedUrl(element.getUrl(), 24 * 60));
|
||||
vo.setCollectionElementList(collectionElementList);
|
||||
List<UserLikeSnapshot> userLikeList = projectSnapshot.getUserLikeList();
|
||||
List<TDesignPythonOutfit> list = new ArrayList<>();
|
||||
for (UserLikeSnapshot userLikeSnapshot : userLikeList) {
|
||||
TDesignPythonOutfit designPythonOutfit = userLikeSnapshot.getDesignPythonOutfit();
|
||||
designPythonOutfit.setDesignUrl(minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
list.add(designPythonOutfit);
|
||||
}
|
||||
vo.setDesignPythonOutfitList(list);
|
||||
}
|
||||
vo.setCollectionElementList(collectionElementList);
|
||||
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId());
|
||||
List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw);
|
||||
for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) {
|
||||
tDesignPythonOutfit.setDesignUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
}
|
||||
vo.setDesignPythonOutfitList(designPythonOutfitList);
|
||||
}
|
||||
Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
|
||||
vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
|
||||
@@ -636,14 +590,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId());
|
||||
|
||||
Long projectId = portfolio.getProjectId();
|
||||
String snapshot = portfolio.getSnapshot();
|
||||
ProjectSnapshot projectSnapshot = JSONObject.parseObject(snapshot, ProjectSnapshot.class);
|
||||
|
||||
// QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
||||
// userLikeGroupQueryWrapper.lambda().eq(UserLikeGroup::getCollectionId, portfolio.getCollectionId());
|
||||
UserLikeGroup userLikeGroup = userLikeService.getUserLikeGroupByProjectId(projectId);
|
||||
Project project = projectSnapshot.getProject();
|
||||
|
||||
Long projectId = project.getId();
|
||||
|
||||
UserLikeGroup userLikeGroup = projectSnapshot.getUserLikeGroup();
|
||||
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
// Long projectIdOld = project.getId();
|
||||
project.setCreateTime(LocalDateTime.now());
|
||||
project.setId(null);
|
||||
project.setAccountId(authPrincipalVo.getId());
|
||||
@@ -667,7 +622,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
|
||||
Long projectIdNew = project.getId();
|
||||
|
||||
List<CollectionElement> collectionElementListOld = collectionElementService.getByProjectId(projectId);
|
||||
List<CollectionElement> collectionElementListOld = projectSnapshot.getCollectionElementList();
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setProjectId(projectIdNew);
|
||||
element.setId(null);
|
||||
@@ -677,7 +632,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
if (Objects.nonNull(userLikeGroup)) {
|
||||
Long portfolioUserLikeGroupId = userLikeGroup.getId();
|
||||
|
||||
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
|
||||
UserLikeGroup userLikeGroupNew = projectSnapshot.getUserLikeGroup();
|
||||
userLikeGroupNew.setId(null);
|
||||
userLikeGroupNew.setCreateDate(new Date());
|
||||
userLikeGroupNew.setProjectId(projectIdNew);
|
||||
@@ -695,236 +650,78 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
|
||||
}
|
||||
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
|
||||
Long collectionIdOld = userLikeGroup.getCollectionId();
|
||||
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
|
||||
// List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
|
||||
collectionOld.setId(null);
|
||||
collectionMapper.insert(collectionOld);
|
||||
Long collectionIdNew = collectionOld.getId();
|
||||
|
||||
Long workspaceServiceByProjectId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceMapper.selectById(workspaceServiceByProjectId);
|
||||
Design design = new Design();
|
||||
design.setCollectionId(collectionIdNew);
|
||||
design.setAccountId(authPrincipalVo.getId());
|
||||
if (workspace.getSex().equals(Sex.FEMALE.getValue())) {
|
||||
design.setTemplateId(workspace.getMannequinFemaleId());
|
||||
design.setModelType(workspace.getMannequinFemaleType());
|
||||
} else {
|
||||
design.setTemplateId(workspace.getMannequinMaleId());
|
||||
design.setModelType(workspace.getMannequinMaleType());
|
||||
}
|
||||
design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage()));
|
||||
if (workspace.getPosition().equals(Position.OVERALL.getValue())) {
|
||||
design.setSingleOverall("overall");
|
||||
design.setSwitchCategory("");
|
||||
} else {
|
||||
design.setSingleOverall("single");
|
||||
design.setSwitchCategory(workspace.getPosition());
|
||||
}
|
||||
design.setCreateDate(new Date());
|
||||
designMapper.insert(design);
|
||||
|
||||
userLikeGroupNew.setCollectionId(collectionIdNew);
|
||||
userLikeGroupNew.setCollectionId(null);
|
||||
userLikeGroupNew.setUpdateDate(new Date());
|
||||
userLikeGroupMapper.insert(userLikeGroupNew);
|
||||
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
|
||||
for (CollectionElement element : collectionElementListOld) {
|
||||
element.setCollectionId(collectionIdNew);
|
||||
collectionElementMapper.updateById(element);
|
||||
TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation();
|
||||
collectionElementRelationNew.setCollectionId(collectionIdNew);
|
||||
collectionElementRelationNew.setElementId(element.getId());
|
||||
collectionElementRelationNew.setCreateDate(new Date());
|
||||
collectionElementRelationMapper.insert(collectionElementRelationNew);
|
||||
}
|
||||
|
||||
List<UserLikeSnapshot> userLikeList = projectSnapshot.getUserLikeList();
|
||||
if (CollectionUtil.isNotEmpty(userLikeList)) {
|
||||
for (UserLikeSnapshot userLike : userLikeList) {
|
||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
||||
TDesignPythonOutfit designPythonOutfit = userLike.getDesignPythonOutfit();
|
||||
designPythonOutfit.setDesignId(null);
|
||||
designPythonOutfit.setDesignItemId(-1L);
|
||||
designPythonOutfit.setCollectionId(null);
|
||||
|
||||
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioUserLikeGroupId);
|
||||
designPythonOutfit.setId(null);
|
||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
||||
|
||||
for (UserLike userLike : userLikeList) {
|
||||
Long designOutfitIdOld = userLike.getDesignOutfitId();
|
||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
|
||||
designPythonOutfit.setDesignId(design.getId());
|
||||
designPythonOutfit.setDesignItemId(-1L);
|
||||
designPythonOutfit.setCollectionId(collectionIdNew);
|
||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = userLike.getTDesignPythonOutfitDetailList();
|
||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfitDetails)){
|
||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
tDesignPythonOutfitDetail.setId(null);
|
||||
tDesignPythonOutfitDetail.setDesignId(null);
|
||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
||||
}
|
||||
}
|
||||
|
||||
designPythonOutfit.setId(null);
|
||||
designPythonOutfitMapper.insert(designPythonOutfit);
|
||||
Long designOutfitIdNew = designPythonOutfit.getId();
|
||||
userLike.setDesignOutfitId(designOutfitIdNew);
|
||||
QueryWrapper<TDesignPythonOutfitDetail> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
|
||||
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
|
||||
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
|
||||
tDesignPythonOutfitDetail.setId(null);
|
||||
tDesignPythonOutfitDetail.setDesignId(design.getId());
|
||||
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
|
||||
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
|
||||
}
|
||||
DesignItem designItemOld = userLike.getDesignItem();
|
||||
designItemOld.setId(null);
|
||||
designItemOld.setAccountId(authPrincipalVo.getId());
|
||||
designItemOld.setDesignId(null);
|
||||
designItemOld.setCollectionId(null);
|
||||
designItemMapper.insert(designItemOld);
|
||||
Long designItemIdNew = designItemOld.getId();
|
||||
|
||||
Long designItemIdOld = userLike.getDesignItemId();
|
||||
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
|
||||
designItemOld.setId(null);
|
||||
designItemOld.setAccountId(authPrincipalVo.getId());
|
||||
designItemOld.setDesignId(design.getId());
|
||||
designItemOld.setCollectionId(collectionIdNew);
|
||||
designItemMapper.insert(designItemOld);
|
||||
Long designItemIdNew = designItemOld.getId();
|
||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
||||
designPythonOutfitMapper.updateById(designPythonOutfit);
|
||||
|
||||
designPythonOutfit.setDesignItemId(designItemIdNew);
|
||||
designPythonOutfitMapper.updateById(designPythonOutfit);
|
||||
userLike.setDesignItemId(designItemIdNew);
|
||||
userLike.setId(null);
|
||||
userLike.setDesignId(null);
|
||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
||||
userLikeMapper.insert(userLike);
|
||||
|
||||
userLike.setDesignItemId(designItemIdNew);
|
||||
userLike.setId(null);
|
||||
userLike.setDesignId(design.getId());
|
||||
userLike.setUserLikeGroupId(userLikeGroupNew.getId());
|
||||
userLikeMapper.insert(userLike);
|
||||
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemIdOld);
|
||||
List<DesignItemDetail> designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||
for (DesignItemDetail designItemDetailOld : designItemDetailListOld) {
|
||||
Long designItemDetailIdOld = designItemDetailOld.getId();
|
||||
designItemDetailOld.setId(null);
|
||||
designItemDetailOld.setAccountId(authPrincipalVo.getId());
|
||||
designItemDetailOld.setDesignId(design.getId());
|
||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
||||
designItemDetailMapper.insert(designItemDetailOld);
|
||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
||||
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
||||
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
||||
designItemDetailPrint.setId(null);
|
||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
||||
List<DesignItemDetailSnapshot> designItemDetailList = userLike.getDesignItemDetailList();
|
||||
if (CollectionUtil.isNotEmpty(designItemDetailList)) {
|
||||
for (DesignItemDetailSnapshot designItemDetailOld : designItemDetailList) {
|
||||
designItemDetailOld.setId(null);
|
||||
designItemDetailOld.setAccountId(authPrincipalVo.getId());
|
||||
designItemDetailOld.setDesignId(null);
|
||||
designItemDetailOld.setDesignItemId(designItemIdNew);
|
||||
designItemDetailMapper.insert(designItemDetailOld);
|
||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||
|
||||
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailOld.getDesignItemDetailPrintList();
|
||||
if (CollectionUtil.isNotEmpty(designItemDetailPrintList)) {
|
||||
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
||||
designItemDetailPrint.setId(null);
|
||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Long collectionId = portfolio.getCollectionId();
|
||||
// QueryWrapper<Design> getWorkspaceQw = new QueryWrapper<>();
|
||||
// getWorkspaceQw.lambda().eq(Design::getCollectionId, collectionId);
|
||||
// List<Design> designs = designMapper.selectList(getWorkspaceQw);
|
||||
// if (!CollectionUtils.isEmpty(designs)) {
|
||||
// Design design1 = designs.get(0);
|
||||
// Long accountId = authPrincipalVo.getId();
|
||||
// QueryWrapper<Workspace> currentWorkspaceQw = new QueryWrapper<>();
|
||||
// currentWorkspaceQw.lambda().eq(Workspace::getAccountId, accountId);
|
||||
// currentWorkspaceQw.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
// List<Workspace> workspaces = workspaceMapper.selectList(currentWorkspaceQw);
|
||||
// if (!CollectionUtils.isEmpty(workspaces)) {
|
||||
// Workspace workspace1 = workspaces.get(0);
|
||||
// workspace1.setIsLastIndex(0);
|
||||
// workspaceMapper.updateById(workspace1);
|
||||
// Workspace workspaceNew = new Workspace();
|
||||
// String workspaceName = "workspace of " + accountMapper.selectById(portfolio.getAccountId()).getUserName() + portfolio.getPortfolioName();
|
||||
// QueryWrapper<Workspace> existSameNameQw = new QueryWrapper<>();
|
||||
// existSameNameQw.lambda().eq(Workspace::getWorkSpaceName, workspaceName);
|
||||
// existSameNameQw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
|
||||
// List<Workspace> existSameNameList = workspaceMapper.selectList(existSameNameQw);
|
||||
// if (!CollectionUtils.isEmpty(existSameNameList)) {
|
||||
// workspaceName = workspaceName + "_copy";
|
||||
// }
|
||||
// workspaceNew.setWorkSpaceName(workspaceName);
|
||||
// workspaceNew.setAccountId(accountId);
|
||||
// workspaceNew.setIsDeleted(0);
|
||||
// workspaceNew.setIsLastIndex(1);
|
||||
// workspaceNew.setCreateTime(LocalDateTime.now());
|
||||
// workspaceNew.setSystemDesignerPercentage((design1.getSystemScale().multiply(BigDecimal.valueOf(100)).intValue()));
|
||||
// if (design1.getSingleOverall().equals("overall")) {
|
||||
// workspaceNew.setPosition("Overall");
|
||||
// } else {
|
||||
// workspaceNew.setPosition(design1.getSwitchCategory());
|
||||
// }
|
||||
// workspaceMapper.insert(workspaceNew);
|
||||
// if (design1.getModelType().equals("System")) {
|
||||
// SysFile sysFile = sysFileMapper.selectById(design1.getTemplateId());
|
||||
// if (sysFile.getLevel2Type().equals("Female")) {
|
||||
// workspaceNew.setSex("Female");
|
||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
// workspaceRelStyle.setStyleId(style.getId());
|
||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
// }
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// }
|
||||
// } else {
|
||||
// workspaceNew.setSex("Male");
|
||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
// if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
|
||||
// QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
|
||||
// styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
|
||||
// Style style = styleMapper.selectOne(styleQueryWrapper);
|
||||
// WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
|
||||
// workspaceRelStyle.setStyleId(style.getId());
|
||||
// workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
|
||||
// workspaceRelStyleMapper.insert(workspaceRelStyle);
|
||||
// }
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Library library = libraryMapper.selectById(design1.getTemplateId());
|
||||
// if (library.getLevel2Type().equals("Female")) {
|
||||
// workspaceNew.setSex("Female");
|
||||
// workspaceNew.setMannequinFemaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinFemaleType("Library");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinMaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinMaleType("System");
|
||||
// }
|
||||
// } else {
|
||||
// workspaceNew.setSex("Male");
|
||||
// workspaceNew.setMannequinMaleId(design1.getTemplateId());
|
||||
// workspaceNew.setMannequinMaleType("Library");
|
||||
// QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
// getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||
// List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
|
||||
// if (!CollectionUtils.isEmpty(anotherList)) {
|
||||
// SysFile anotherOne = anotherList.get(0);
|
||||
// workspaceNew.setMannequinFemaleId(anotherOne.getId());
|
||||
// workspaceNew.setMannequinFemaleType("System");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// workspaceMapper.updateById(workspaceNew);
|
||||
// }
|
||||
// }
|
||||
Long workspaceIdOld = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspaceCopy = workspaceMapper.selectById(workspaceIdOld);
|
||||
Workspace workspaceCopy = projectSnapshot.getWorkspace();
|
||||
workspaceCopy.setAccountId(authPrincipalVo.getId());
|
||||
workspaceCopy.setProjectId(projectIdNew);
|
||||
workspaceCopy.setId(null);
|
||||
|
||||
68
src/main/java/com/ai/da/service/impl/ProjectServiceImpl.java
Normal file
68
src/main/java/com/ai/da/service/impl/ProjectServiceImpl.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
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.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.enums.DesignTypeEnum;
|
||||
import com.ai.da.common.enums.SingleOverallEnum;
|
||||
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.python.vo.*;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.python.vo.DesignPythonItem.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Long> getChildProjectIdSet(Long projectId) {
|
||||
QueryWrapper<Project> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Project::getParentId, projectId);
|
||||
List<Project> projectList = projectMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(projectList)) {
|
||||
return projectList.stream().map(Project::getId).collect(Collectors.toSet());
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
@@ -355,6 +355,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private ToProductImageRecordMapper toProductImageRecordMapper;
|
||||
@Resource
|
||||
private ToProductImageResultMapper toProductImageResultMapper;
|
||||
@Resource
|
||||
private CloudTaskMapper cloudTaskMapper;
|
||||
|
||||
@Resource
|
||||
private PythonService pythonService;
|
||||
@@ -1283,6 +1285,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("account_id", authPrincipalVo.getId());
|
||||
queryWrapper.isNull("parent_id");
|
||||
if (!StringUtils.isEmpty(query.getProjectName())) {
|
||||
queryWrapper.like("name", query.getProjectName());
|
||||
}
|
||||
@@ -1400,51 +1403,35 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
MoodBoardModuleChooseVO moodBoardModuleChooseVO = new MoodBoardModuleChooseVO();
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
// qw.lambda().ne(CollectionElement::getCollectionId, 0);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Long collectionId = null;
|
||||
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
if (collectionElement.getCollectionId() != null) {
|
||||
collectionId = collectionElement.getCollectionId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Collection collection = collectionService.getById(collectionId);
|
||||
if (Objects.nonNull(collection)) {
|
||||
if (null != collection.getMoodboardPosition()) {
|
||||
String moodboardPositionString = collectionService.getMoodboardPositionString(collection.getId());
|
||||
if (StringUtils.isEmpty(moodboardPositionString)) {
|
||||
moodBoardModuleChooseVO.setMoodboardPosition(collection.getMoodboardPosition());
|
||||
}else {
|
||||
if (null != collectionElement.getIsCompositeImage() && collectionElement.getIsCompositeImage() == 1) {
|
||||
moodBoardModuleChooseVO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||
moodBoardModuleChooseVO.setMoodTemplateName(collectionElement.getName());
|
||||
moodBoardModuleChooseVO.setMoodTemplateUrl(minioUtil.getPreSignedUrl(collectionElement.getUrl(), 24 * 60));
|
||||
|
||||
String moodboardPositionString = collectionService.getMoodboardPositionString(collectionElement.getId());
|
||||
if (!StringUtils.isEmpty(moodboardPositionString)) {
|
||||
moodBoardModuleChooseVO.setMoodboardPosition(moodboardPositionString);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (collection.getMoodTemplateId() != null) {
|
||||
CollectionElement layoutElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
||||
moodBoardModuleChooseVO.setMoodTemplateId(collection.getMoodTemplateId());
|
||||
moodBoardModuleChooseVO.setMoodTemplateName(layoutElement.getName());
|
||||
moodBoardModuleChooseVO.setMoodTemplateUrl(minioUtil.getPreSignedUrl(layoutElement.getUrl(), 24 * 60));
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
String url = collectionElement.getUrl();
|
||||
collectionElementVO.setOriginalUrl(url);
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
}
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
if (Objects.equals(collectionElement.getId(), Long.valueOf(collection.getMoodTemplateId()))) {
|
||||
continue;
|
||||
}
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
String url = collectionElement.getUrl();
|
||||
collectionElementVO.setOriginalUrl(url);
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
}
|
||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
moodBoardModuleChooseVO.setMoodBoards(list);
|
||||
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
|
||||
}
|
||||
moodBoardModuleChooseVO.setMoodBoards(list);
|
||||
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
|
||||
}else if (module.equals(Module.printBoard.name())) {
|
||||
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
@@ -1655,8 +1642,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
List<ThreeDModule> threeDModules = threeDModuleMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(threeDModules)) {
|
||||
ThreeDModule threeDModule = threeDModules.get(0);
|
||||
ThreeDVO patternMaking3D = getLayoutDetail(threeDModule.getThreeDSimpleId());
|
||||
moduleChooseVO.setPatternMaking3D(patternMaking3D);
|
||||
if (null != threeDModule.getThreeDSimpleId()){
|
||||
ThreeDModuleVO threeDModuleVO = CopyUtil.copyObject(threeDModule, ThreeDModuleVO.class);
|
||||
if (null != threeDModule.getCollectionElementId()) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(threeDModule.getCollectionElementId());
|
||||
if (Objects.nonNull(collectionElement)) {
|
||||
threeDModuleVO.setPrintMinioUrl(minioUtil.getPreSignedUrl(collectionElement.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setPatternMaking3D(threeDModuleVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1677,6 +1672,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
CollectionElement compositeImage = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
|
||||
if (compositeImage.getProjectId() == null) {
|
||||
compositeImage.setProjectId(moduleSaveDTO.getProjectId());
|
||||
compositeImage.setIsCompositeImage(1);
|
||||
collectionElementMapper.updateById(compositeImage);
|
||||
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
|
||||
// 合成图位置信息通过collectElementId关联(旧逻辑通过collectionId关联)
|
||||
@@ -1904,7 +1900,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
}
|
||||
}
|
||||
if (moduleSaveDTO.getPatternMaking3D() != null) {
|
||||
if (Objects.nonNull(moduleSaveDTO.getPatternMaking3D())) {
|
||||
PatternMaking3DDTO patternMaking3D = moduleSaveDTO.getPatternMaking3D();
|
||||
|
||||
QueryWrapper<ThreeDModule> threeDModuleQueryWrapper = new QueryWrapper<>();
|
||||
threeDModuleQueryWrapper.lambda().eq(ThreeDModule::getProjectId, projectId);
|
||||
@@ -1913,12 +1910,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (CollectionUtils.isEmpty(threeDModuleList)) {
|
||||
ThreeDModule threeDModule = new ThreeDModule();
|
||||
threeDModule.setProjectId(projectId);
|
||||
threeDModule.setThreeDSimpleId(moduleSaveDTO.getPatternMaking3D());
|
||||
threeDModule.setThreeDSimpleId(patternMaking3D.getThreeDSimpleId());
|
||||
threeDModule.setX(patternMaking3D.getX());
|
||||
threeDModule.setY(patternMaking3D.getY());
|
||||
threeDModule.setCollectionElementId(patternMaking3D.getCollectionElementId());
|
||||
threeDModuleMapper.insert(threeDModule);
|
||||
}else {
|
||||
ThreeDModule threeDModule = threeDModuleList.get(0);
|
||||
if (!Objects.equals(moduleSaveDTO.getPatternMaking3D(), threeDModule.getThreeDSimpleId())) {
|
||||
threeDModule.setThreeDSimpleId(moduleSaveDTO.getPatternMaking3D());
|
||||
if (!Objects.equals(patternMaking3D.getThreeDSimpleId(), threeDModule.getThreeDSimpleId())) {
|
||||
threeDModule.setThreeDSimpleId(patternMaking3D.getThreeDSimpleId());
|
||||
threeDModule.setX(patternMaking3D.getX());
|
||||
threeDModule.setY(patternMaking3D.getY());
|
||||
threeDModule.setCollectionElementId(patternMaking3D.getCollectionElementId());
|
||||
threeDModuleMapper.updateById(threeDModule);
|
||||
}
|
||||
}
|
||||
@@ -2217,4 +2220,98 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
brandDNAMapper.deleteById(brandDNADTO.getId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toProductBatch(String taskId, String url, String progress) {
|
||||
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
|
||||
if (Objects.nonNull(toProductImageResult)) {
|
||||
toProductImageResult.setUrl(url);
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
String taskIdBatch = toProductImageResult.getTaskIdBatch();
|
||||
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||
if (Objects.nonNull(cloudTask)) {
|
||||
if (cloudTask.getCompletedNum() == null) {
|
||||
cloudTask.setCompletedNum(1);
|
||||
}else {
|
||||
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||
}
|
||||
if (progress.equals("OK")) {
|
||||
cloudTask.setStatus(1);
|
||||
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||
}
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
|
||||
String key = toProductImageResultKey + ":" + taskId;
|
||||
String imageName = url.substring(url.lastIndexOf("/") + 1);
|
||||
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, null);
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
Long accountId = Long.parseLong(taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
if (!status.equals("Invalid")) {
|
||||
// 4、扣除积分
|
||||
Boolean b = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
// 3、记录积分变更
|
||||
if (b) creditsService.insertToCreditsDetail(accountId,
|
||||
CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(),
|
||||
CreditsEventsEnum.TO_PRODUCT_IMAGE.getValue(),
|
||||
"negative", null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relightBatch(String taskId, String url, String progress) {
|
||||
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
|
||||
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
|
||||
if (Objects.nonNull(toProductImageResult)) {
|
||||
if (toProductImageResult.getBrightenValue() != null && toProductImageResult.getBrightenValue() != 1.0) {
|
||||
pythonService.bright(url, toProductImageResult.getBrightenValue());
|
||||
}
|
||||
toProductImageResult.setUrl(url);
|
||||
toProductImageResult.setResultType("Relight");
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
|
||||
String taskIdBatch = toProductImageResult.getTaskIdBatch();
|
||||
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||
if (Objects.nonNull(cloudTask)) {
|
||||
if (cloudTask.getCompletedNum() == null) {
|
||||
cloudTask.setCompletedNum(1);
|
||||
}else {
|
||||
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||
}
|
||||
if (progress.equals("OK")) {
|
||||
cloudTask.setStatus(1);
|
||||
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||
}
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
|
||||
String key = relightResultKey + ":" + taskId;
|
||||
String imageName = url.substring(url.lastIndexOf("/") + 1);
|
||||
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||
GenerateResultVO generateResultVO = new GenerateResultVO(taskId, toProductImageResult.getId(), url, status, null);
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
Long accountId = Long.parseLong(taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
if (!status.equals("Invalid")) {
|
||||
// 4、扣除积分
|
||||
Boolean b = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
// 3、记录积分变更
|
||||
if (b) creditsService.insertToCreditsDetail(accountId,
|
||||
CreditsEventsEnum.RELIGHT.getName(),
|
||||
CreditsEventsEnum.RELIGHT.getValue(),
|
||||
"negative", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user