Merge branch 'dev/dev_xp' into dev/3.1_release_merge

This commit is contained in:
2025-11-18 10:28:44 +08:00
25 changed files with 5248 additions and 5326 deletions

View File

@@ -6,10 +6,7 @@ import com.ai.da.common.utils.RedisUtil;
import com.ai.da.model.dto.GenerateThroughImageTextDTO; import com.ai.da.model.dto.GenerateThroughImageTextDTO;
import com.ai.da.model.vo.GenerateResultVO; import com.ai.da.model.vo.GenerateResultVO;
import com.ai.da.model.vo.PoseTransformationVO; import com.ai.da.model.vo.PoseTransformationVO;
import com.ai.da.service.CloudTaskService; import com.ai.da.service.*;
import com.ai.da.service.DesignService;
import com.ai.da.service.GenerateService;
import com.ai.da.service.UserLikeGroupService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
@@ -17,17 +14,16 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
@@ -37,25 +33,22 @@ import java.util.Objects;
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor
public class GenerateConsumer { public class GenerateConsumer {
@Resource private final GenerateService generateService;
private GenerateService generateService;
@Resource private final UserLikeGroupService userLikeGroupService;
private UserLikeGroupService userLikeGroupService;
@Resource private final DesignService designService;
private DesignService designService;
@Resource private final CloudTaskService cloudTaskService;
private CloudTaskService cloudTaskService;
@Autowired private final RabbitMQProperties rabbitMQProperties;
private RabbitMQProperties rabbitMQProperties;
@Resource private final RedisUtil redisUtil;
private RedisUtil redisUtil;
private final MessageCenterService messageCenterService;
@Value("${redis.key.orderForGenerate}") @Value("${redis.key.orderForGenerate}")
private String consumptionOrderKey; private String consumptionOrderKey;

View File

@@ -3,13 +3,12 @@ package com.ai.da.controller;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response; import com.ai.da.common.response.Response;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*; import com.ai.da.model.vo.*;
import com.ai.da.model.vo.CommentVO; import com.ai.da.model.vo.CommentVO;
import com.ai.da.model.vo.PortfolioVO; import com.ai.da.model.vo.PortfolioVO;
import com.ai.da.model.vo.UserLikeChooseVO;
import com.ai.da.service.PortfolioService; import com.ai.da.service.PortfolioService;
import com.ai.da.service.UserFollowService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -29,6 +28,9 @@ public class PortfolioController {
@Resource @Resource
private PortfolioService portfolioService; private PortfolioService portfolioService;
@Resource
private UserFollowService userFollowService;
@ApiOperation(value = "发布作品集") @ApiOperation(value = "发布作品集")
@PostMapping("/publish") @PostMapping("/publish")
public Response<Long> publish(@RequestParam("file") MultipartFile canvas, @RequestParam("data") String data) { public Response<Long> publish(@RequestParam("file") MultipartFile canvas, @RequestParam("data") String data) {
@@ -138,13 +140,13 @@ public class PortfolioController {
@ApiOperation(value = "获取关注列表") @ApiOperation(value = "获取关注列表")
@PostMapping("/getFolloweeList") @PostMapping("/getFolloweeList")
public Response<List<AccountFollowVO>> getFolloweeList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) { public Response<List<AccountFollowVO>> getFolloweeList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
return Response.success(portfolioService.getFolloweeList(getFollowListDTO)); return Response.success(userFollowService.getFolloweeList(getFollowListDTO));
} }
@ApiOperation(value = "获取粉丝列表") @ApiOperation(value = "获取粉丝列表")
@PostMapping("/getFollowerList") @PostMapping("/getFollowerList")
public Response<List<AccountFollowVO>> getFollowerList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) { public Response<List<AccountFollowVO>> getFollowerList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
return Response.success(portfolioService.getFollowerList(getFollowListDTO)); return Response.success(userFollowService.getFollowerList(getFollowListDTO));
} }

View File

@@ -95,10 +95,6 @@ public interface DesignService extends IService<Design> {
Integer designProcess(String processId); Integer designProcess(String processId);
void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam);
void relationImageId(DesignPythonObjects objects);
List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignCollectionDTO); List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignCollectionDTO);
List<String> getModel(List<Long> designItemIdList); List<String> getModel(List<Long> designItemIdList);
@@ -124,6 +120,4 @@ public interface DesignService extends IService<Design> {
Boolean cloudTaskNameUpdate(CloudTaskDTO cloudTaskDTO); Boolean cloudTaskNameUpdate(CloudTaskDTO cloudTaskDTO);
Boolean cloudTaskDelete(CloudTaskDTO cloudTaskDTO); Boolean cloudTaskDelete(CloudTaskDTO cloudTaskDTO);
String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId);
} }

View File

@@ -0,0 +1,9 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.MoodboardPosition;
import com.baomidou.mybatisplus.extension.service.IService;
public interface MoodboardPositionService extends IService<MoodboardPosition> {
void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam);
}

View File

@@ -47,20 +47,8 @@ public interface PortfolioService extends IService<Portfolio> {
void cancelFollow(Long followeeId); void cancelFollow(Long followeeId);
Long getFolloweeCount(Long accountId);
List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO);
Long getFollowerCount(Long accountId);
List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO);
Integer getIfFollowed(Long followeeId, Long followerId);
Long getPortfolioCount(Long accountId); Long getPortfolioCount(Long accountId);
List<Long> getFolloweeList(Long accountId);
// List<PortfolioVO> queryPortfolioByTag(String tagName, Long tagId); // List<PortfolioVO> queryPortfolioByTag(String tagName, Long tagId);
void setPortfolioToPublic(Long portfolioId); void setPortfolioToPublic(Long portfolioId);

View File

@@ -2,6 +2,7 @@ package com.ai.da.service;
import com.ai.da.mapper.primary.entity.PythonTAllInfo; import com.ai.da.mapper.primary.entity.PythonTAllInfo;
import com.ai.da.python.vo.DesignPythonObjects;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**
@@ -14,4 +15,6 @@ public interface PythonTAllInfoService extends IService<PythonTAllInfo> {
Long getImageIdByPath(String path); Long getImageIdByPath(String path);
void relationImageId(DesignPythonObjects pythonObjects);
} }

View File

@@ -0,0 +1,9 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.ToProductImageResult;
import com.baomidou.mybatisplus.extension.service.IService;
public interface ToProductImageResultService extends IService<ToProductImageResult> {
Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url);
}

View File

@@ -0,0 +1,24 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.UserFollow;
import com.ai.da.model.dto.GetFollowListDTO;
import com.ai.da.model.vo.AccountFollowVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface UserFollowService extends IService<UserFollow> {
Long getFollowerCount(Long accountId);
List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO);
Long getFolloweeCount(Long accountId);
List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO);
Integer getIfFollowed(Long followeeId, Long followerId);
List<Long> getFolloweeList(Long accountId);
}

View File

@@ -42,7 +42,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
void deleteTrialData(Long id); void deleteTrialData(Long id);
void updateDate(Long id,String timeZone); void updateDate(Long id, String timeZone);
Long exportSave(MultipartFile file, Long projectId, String module, Long designItemDetailId); Long exportSave(MultipartFile file, Long projectId, String module, Long designItemDetailId);
@@ -121,6 +121,4 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
Boolean toProductImageElementDelete(Long id); Boolean toProductImageElementDelete(Long id);
ToProductElementVO convertRelightElement(Long id); ToProductElementVO convertRelightElement(Long id);
Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url);
} }

View File

@@ -70,4 +70,6 @@ public interface WorkspaceService extends IService<Workspace> {
String getProjectSexById(Long projectId); String getProjectSexById(Long projectId);
String getStyleByProjectId(Long projectId); String getStyleByProjectId(Long projectId);
String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId);
} }

View File

@@ -143,6 +143,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Resource @Resource
private AffiliateService affiliateService; private AffiliateService affiliateService;
@Resource
private UserFollowService userFollowService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) { public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
@@ -261,8 +264,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
//判断是否常用ip 不是则发邮件提示 //判断是否常用ip 不是则发邮件提示
calculateExceptionIp(RequestInfoUtil.getIpAddress(request), account); calculateExceptionIp(RequestInfoUtil.getIpAddress(request), account);
return response; return response;
@@ -2050,8 +2053,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
personalHomepageVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); personalHomepageVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
personalHomepageVO.setPortfolioCount(portfolioService.getPortfolioCount(accountId)); personalHomepageVO.setPortfolioCount(portfolioService.getPortfolioCount(accountId));
personalHomepageVO.setFolloweeCount(portfolioService.getFolloweeCount(accountId)); personalHomepageVO.setFolloweeCount(userFollowService.getFolloweeCount(accountId));
personalHomepageVO.setFollowerCount(portfolioService.getFollowerCount(accountId)); personalHomepageVO.setFollowerCount(userFollowService.getFollowerCount(accountId));
personalHomepageVO.setHomepageViewCount(viewPersonalHomepageCount(0L)); personalHomepageVO.setHomepageViewCount(viewPersonalHomepageCount(0L));
@@ -2061,7 +2064,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// 只有本人才能看到个人主页浏览量 // 只有本人才能看到个人主页浏览量
personalHomepageVO.setHomepageViewCount(viewCount == null ? 0 : viewCount); personalHomepageVO.setHomepageViewCount(viewCount == null ? 0 : viewCount);
} else { } else {
personalHomepageVO.setIsFollow(portfolioService.getIfFollowed(accountId, currentUserId)); personalHomepageVO.setIsFollow(userFollowService.getIfFollowed(accountId, currentUserId));
// 非本人浏览主页时增加浏览量 // 非本人浏览主页时增加浏览量
viewsIncrease(accountId); viewsIncrease(accountId);
} }
@@ -2925,8 +2928,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
return response; return response;
} else { } else {
throw new IllegalArgumentException("Invalid ID token."); throw new IllegalArgumentException("Invalid ID token.");
@@ -3030,8 +3033,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
return response; return response;
} }
@@ -3122,8 +3125,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
QueryWrapper<AccountExtend> qw = new QueryWrapper<>(); QueryWrapper<AccountExtend> qw = new QueryWrapper<>();
qw.lambda().eq(AccountExtend::getAccountId, response.getUserId()); qw.lambda().eq(AccountExtend::getAccountId, response.getUserId());
@@ -3651,19 +3654,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
} }
// todo 机构管理员再次订阅时,需要同步机构的激活状态 // todo 机构管理员再次订阅时,需要同步机构的激活状态
private void setOrganizationStatus(Account adminAcc, boolean isActive){ private void setOrganizationStatus(Account adminAcc, boolean isActive) {
Organization organization; Organization organization;
if (Objects.nonNull(adminAcc.getOrganizationId())){ if (Objects.nonNull(adminAcc.getOrganizationId())) {
organization = organizationMapper.selectById(adminAcc.getOrganizationId()); organization = organizationMapper.selectById(adminAcc.getOrganizationId());
} else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())){ } else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())) {
organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName()); organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName());
} else { } else {
return; return;
} }
if (Objects.isNull(organization)){ if (Objects.isNull(organization)) {
organization = convenientInquiryService.addOrganization(adminAcc.getOrganizationName(), getOrganizationTypeByRole(adminAcc.getSystemUser())); organization = convenientInquiryService.addOrganization(adminAcc.getOrganizationName(), getOrganizationTypeByRole(adminAcc.getSystemUser()));
} }
if (isActive){ if (isActive) {
organization.setStatus(1); organization.setStatus(1);
} else { } else {
organization.setStatus(0); organization.setStatus(0);
@@ -3672,9 +3675,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
public String getOrganizationTypeByRole(Integer roleNum){ public String getOrganizationTypeByRole(Integer roleNum) {
String type; String type;
switch (roleNum){ switch (roleNum) {
case 5: case 5:
type = "Enterprise"; type = "Enterprise";
break; break;

View File

@@ -59,29 +59,19 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService { public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService {
@Resource private final CollectionElementMapper collectionElementMapper;
private CollectionElementMapper collectionElementMapper; private final EmailService emailService;
@Resource private final FileProperties fileProperties;
private FileProperties fileProperties; private final GenerateMapper generateMapper;
@Resource private final GenerateDetailMapper generateDetailMapper;
private PanToneService panToneService; private final LibraryModelPointService libraryModelPointService;
@Resource private final LibraryService libraryService;
private PythonService pythonService; private final MinioUtil minioUtil;
@Resource private final PanToneService panToneService;
private LibraryService libraryService; private final PythonService pythonService;
@Resource private final RedisUtil redisUtil;
private SysFileService sysFileService; private final SysFileService sysFileService;
@Resource private final TCollectionElementRelationService tCollectionElementRelationService;
private GenerateMapper generateMapper;
@Resource
private GenerateDetailMapper generateDetailMapper;
@Resource
private LibraryModelPointService libraryModelPointService;
@Resource
private TCollectionElementRelationService tCollectionElementRelationService;
@Resource
private MinioUtil minioUtil;
private final WorkspaceService workspaceService; private final WorkspaceService workspaceService;
@Value("${minio.bucketName.collectionElement}") @Value("${minio.bucketName.collectionElement}")
@@ -90,13 +80,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
private String gradientBucketName; private String gradientBucketName;
@Value("${minio.bucketName.users}") @Value("${minio.bucketName.users}")
private String userBucketName; private String userBucketName;
@Resource
private RedisUtil redisUtil;
// @Resource
// private RedisUtil redisUtil;
@Resource
private EmailService emailService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
@@ -330,8 +314,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD); String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> { List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){ if (StringUtil.isNullOrEmpty(o.getLevel2Type())) {
switch(d.getLevel1Type()){ switch (d.getLevel1Type()) {
case "Sketchboard": case "Sketchboard":
d.setLevel2Type("Outwear"); d.setLevel2Type("Outwear");
break; break;
@@ -391,8 +375,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
// // TODO:暂不处理 // // TODO:暂不处理
// } // }
} }
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){ if (StringUtil.isNullOrEmpty(o.getLevel2Type())) {
switch(d.getLevel1Type()){ switch (d.getLevel1Type()) {
case "Sketchboard": case "Sketchboard":
d.setLevel2Type("Outwear"); d.setLevel2Type("Outwear");
break; break;
@@ -595,9 +579,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String level3Type = null; String level3Type = null;
if ("Collection".equals(sketchBoard.getDesignType())) { if ("Collection".equals(sketchBoard.getDesignType())) {
level3Type = collectionElementMapper.selectOne(new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getId, sketchBoard.getSketchBoardId()).select(CollectionElement::getLevel3Type)).getLevel3Type(); level3Type = collectionElementMapper.selectOne(new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getId, sketchBoard.getSketchBoardId()).select(CollectionElement::getLevel3Type)).getLevel3Type();
} else if ("Library".equals(sketchBoard.getDesignType())){ } else if ("Library".equals(sketchBoard.getDesignType())) {
level3Type = libraryService.getById(sketchBoard.getSketchBoardId()).getLevel3Type(); level3Type = libraryService.getById(sketchBoard.getSketchBoardId()).getLevel3Type();
} else if ("Generate".equals(sketchBoard.getDesignType())){ } else if ("Generate".equals(sketchBoard.getDesignType())) {
GenerateDetail generateDetail = generateDetailMapper.selectById(sketchBoard.getSketchBoardId()); GenerateDetail generateDetail = generateDetailMapper.selectById(sketchBoard.getSketchBoardId());
assert generateDetail != null; assert generateDetail != null;
Generate generate = generateMapper.selectById(generateDetail.getGenerateId()); Generate generate = generateMapper.selectById(generateDetail.getGenerateId());
@@ -1032,8 +1016,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//保存 //保存
List<TCollectionElementRelation> relations = list.stream().map(element -> List<TCollectionElementRelation> relations = list.stream().map(element ->
TCollectionElementRelation.builder().elementId(element.getId()) TCollectionElementRelation.builder().elementId(element.getId())
.collectionId(element.getCollectionId()).createDate(new Date()).build()) .collectionId(element.getCollectionId()).createDate(new Date()).build())
.collect(Collectors.toList()); .collect(Collectors.toList());
tCollectionElementRelationService.saveBatch(relations); tCollectionElementRelationService.saveBatch(relations);
pageQuery.setPage(pageQuery.getPage() + 1); pageQuery.setPage(pageQuery.getPage() + 1);

View File

@@ -10,6 +10,7 @@ import com.ai.da.common.enums.SingleOverallEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum; import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.utils.*; import com.ai.da.common.utils.*;
import com.ai.da.mapper.primary.DesignItemMapper; import com.ai.da.mapper.primary.DesignItemMapper;
import com.ai.da.mapper.primary.DesignMapper;
import com.ai.da.mapper.primary.UserLikeMapper; import com.ai.da.mapper.primary.UserLikeMapper;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
@@ -27,6 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -55,37 +57,25 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignItem> implements DesignItemService { public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignItem> implements DesignItemService {
@Resource
private DesignItemMapper designItemMapper; private final CollectionElementService collectionElementService;
@Resource private final DesignMapper designMapper;
private SysFileService sysFileService; private final DesignItemMapper designItemMapper;
@Resource private final DesignItemDetailService designItemDetailService;
private PythonService pythonService; private final DesignItemDetailPrintService designItemDetailPrintService;
@Resource private final ITDesignPythonOutfitService designPythonOutfitService;
private DesignService designService; private final ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
@Resource private final LibraryService libraryService;
private DesignItemDetailService designItemDetailService; private final LibraryModelPointService libraryModelPointService;
@Resource private final MinioUtil minioUtil;
private LibraryModelPointService libraryModelPointService; private final PythonService pythonService;
@Resource private final PanToneService panToneService;
private LibraryService libraryService; private final SysFileService sysFileService;
@Resource private final UserLikeService userLikeService;
private CollectionElementService collectionElementService; private final UserLikeGroupService userLikeGroupService;
@Resource private final WorkspaceService workspaceService;
private ITDesignPythonOutfitService designPythonOutfitService;
@Resource
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
@Resource
private PanToneService panToneService;
@Resource
private DesignItemDetailPrintService designItemDetailPrintService;
@Resource
private MinioUtil minioUtil;
@Resource
private UserLikeService userLikeService;
@Resource
private UserLikeGroupService userLikeGroupService;
@Value("${minio.bucketName.modifiedSketch}") @Value("${minio.bucketName.modifiedSketch}")
private String modifiedSketchBucket; private String modifiedSketchBucket;
@@ -182,9 +172,9 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
SysFileVO sysFileVO = sysFileService.getById(idValue); SysFileVO sysFileVO = sysFileService.getById(idValue);
if (Objects.nonNull(sysFileVO)){ if (Objects.nonNull(sysFileVO)) {
return new GetNextSysElementVO(sysFileVO.getId(), level2Type, sysFileVO.getUrl()); return new GetNextSysElementVO(sysFileVO.getId(), level2Type, sysFileVO.getUrl());
}else { } else {
return new GetNextSysElementVO(); return new GetNextSysElementVO();
} }
} }
@@ -196,7 +186,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -246,7 +236,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -283,6 +273,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
} }
// todo check这个方法是否还在用 // todo check这个方法是否还在用
private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) { , Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) {
@@ -345,7 +336,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone)); designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone));
designItem.setDesignUrl(outfit.getString("synthesis_url")); designItem.setDesignUrl(outfit.getString("synthesis_url"));
designItem.setId(designItemId); designItem.setId(designItemId);
if (changeModelFlag){ if (changeModelFlag) {
designItem.setModelId(modelId); designItem.setModelId(modelId);
designItem.setModelType(modelType); designItem.setModelType(modelType);
} }
@@ -375,7 +366,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
// designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getType().toLowerCase())); // designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0)); designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0));
designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1)); designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1));
@@ -410,7 +401,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
JSONArray layers = outfit.getJSONArray("layers"); JSONArray layers = outfit.getJSONArray("layers");
Map<Integer, List<Long>> priorityOffset = null; Map<Integer, List<Long>> priorityOffset = null;
if (!isSingleCollectionFlag){ if (!isSingleCollectionFlag) {
priorityOffset = designSingleItemDTOList.stream() priorityOffset = designSingleItemDTOList.stream()
.collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset)); .collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset));
} }
@@ -444,7 +435,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url")); designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale")); designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale"));
designPythonOutfitDetail.setUserId(userId); designPythonOutfitDetail.setUserId(userId);
if (priorityOffset != null && !priorityOffset.isEmpty()){ if (priorityOffset != null && !priorityOffset.isEmpty()) {
designPythonOutfitDetail.setOffset(String.valueOf(priorityOffset.get(Math.abs(Integer.parseInt(jsonObject.getString("priority")))))); designPythonOutfitDetail.setOffset(String.valueOf(priorityOffset.get(Math.abs(Integer.parseInt(jsonObject.getString("priority"))))));
} }
designPythonOutfitDetail.setPriority((Integer) jsonObject.get("priority")); designPythonOutfitDetail.setPriority((Integer) jsonObject.get("priority"));
@@ -471,24 +462,24 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) { public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
// 记录入参 base64数据太长所以这里去掉 // 记录入参 base64数据太长所以这里去掉
DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO); DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO);
clone.getDesignSingleItemDTOList().forEach( i -> { clone.getDesignSingleItemDTOList().forEach(i -> {
// 渐变色 // 渐变色
if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){ if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())) {
log.info("set gradient colorImage为空便于日志打印"); log.info("set gradient colorImage为空便于日志打印");
i.getGradient().setColorImg(null); i.getGradient().setColorImg(null);
} }
// 画笔修改过的sketch // 画笔修改过的sketch
if (!StringUtil.isNullOrEmpty(i.getSketchString())){ if (!StringUtil.isNullOrEmpty(i.getSketchString())) {
log.info("set sketchString为空便于日志打印"); log.info("set sketchString为空便于日志打印");
i.setSketchString(null); i.setSketchString(null);
} }
// 标注过的mask // 标注过的mask
if (!StringUtil.isNullOrEmpty(i.getMaskUrl())){ if (!StringUtil.isNullOrEmpty(i.getMaskUrl())) {
log.info("set labelingMask为空便于日志打印"); log.info("set labelingMask为空便于日志打印");
i.setMaskUrl(null); i.setMaskUrl(null);
} }
if (!Objects.isNull(i.getPartialDesign()) && if (!Objects.isNull(i.getPartialDesign()) &&
!StringUtil.isNullOrEmpty(i.getPartialDesign().getPartialDesignBase64())){ !StringUtil.isNullOrEmpty(i.getPartialDesign().getPartialDesignBase64())) {
log.info("set partialDesignBase64为空便于日志打印"); log.info("set partialDesignBase64为空便于日志打印");
i.getPartialDesign().setPartialDesignBase64(null); i.getPartialDesign().setPartialDesignBase64(null);
} }
@@ -501,7 +492,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -514,10 +505,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
Map<Integer, List<Long>> priorityOffset = new HashMap<>(); Map<Integer, List<Long>> priorityOffset = new HashMap<>();
// 单品设计标志 // 单品设计标志
boolean isSingleCollectionFlag = true; boolean isSingleCollectionFlag = true;
if (design.getSingleOverall().equals("overall")){ if (design.getSingleOverall().equals("overall")) {
isSingleCollectionFlag = false; isSingleCollectionFlag = false;
// 优先级 1、判断当前入参中是否有model数据 无 -> 2、判断design item 中是否有model数据 无 -> 3、从design表中拿model数据 仍然没有 报错 // 优先级 1、判断当前入参中是否有model数据 无 -> 2、判断design item 中是否有model数据 无 -> 3、从design表中拿model数据 仍然没有 报错
if (!Objects.isNull(designSingleIncludeLayersDTO.getModelId()) && !StringUtil.isNullOrEmpty(designSingleIncludeLayersDTO.getModelType())){ if (!Objects.isNull(designSingleIncludeLayersDTO.getModelId()) && !StringUtil.isNullOrEmpty(designSingleIncludeLayersDTO.getModelType())) {
modelId = designSingleIncludeLayersDTO.getModelId(); modelId = designSingleIncludeLayersDTO.getModelId();
modelType = designSingleIncludeLayersDTO.getModelType(); modelType = designSingleIncludeLayersDTO.getModelType();
changeModelFlag = true; changeModelFlag = true;
@@ -543,7 +534,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
modelUrl = sysFile.getUrl(); modelUrl = sysFile.getUrl();
high = 700; high = 700;
width = 320; width = 320;
} else if (modelType.equals(ModelType.LIBRARY.getValue())){ } else if (modelType.equals(ModelType.LIBRARY.getValue())) {
Library libFile = libraryService.getById(modelId); Library libFile = libraryService.getById(modelId);
if (Objects.isNull(libFile)) { if (Objects.isNull(libFile)) {
throw new BusinessException("model.not.found"); throw new BusinessException("model.not.found");
@@ -560,10 +551,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl); designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl);
// 通过priority将offset关联到layers // 通过priority将offset关联到layers
try{ try {
priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream() priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
.collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset)); .collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset));
}catch (IllegalStateException e){ } catch (IllegalStateException e) {
// priority重复 // priority重复
log.info("服装的priority重复"); log.info("服装的priority重复");
throw new BusinessException("priority.cannot.be.repeated"); throw new BusinessException("priority.cannot.be.repeated");
@@ -580,7 +571,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 1、查询当前design item在不在history中 // 1、查询当前design item在不在history中
UserLike userLikeDesign = userLikeService.getByDesignItemId(designItem.getId()); UserLike userLikeDesign = userLikeService.getByDesignItemId(designItem.getId());
Boolean setNull = Boolean.FALSE; Boolean setNull = Boolean.FALSE;
if (!Objects.isNull(userLikeDesign) && userLikeDesign.getConverted() == 0){ if (!Objects.isNull(userLikeDesign) && userLikeDesign.getConverted() == 0) {
setNull = Boolean.TRUE; setNull = Boolean.TRUE;
} }
maskBase64ToPath(designSingleIncludeLayersDTO, setNull); maskBase64ToPath(designSingleIncludeLayersDTO, setNull);
@@ -598,7 +589,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// preview -> 不存数据库 submit -> 存数据库 // preview -> 不存数据库 submit -> 存数据库
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails; List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails;
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data == null || data.toJSONString().equals("{}") ) { if (data == null || data.toJSONString().equals("{}")) {
throw new BusinessException("python response data is null"); throw new BusinessException("python response data is null");
} }
JSONObject outfit = data.getJSONObject("0"); JSONObject outfit = data.getJSONObject("0");
@@ -626,17 +617,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId()); TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
// Assert.notNull(designItem, "design item detail layers does not exists!"); // Assert.notNull(designItem, "design item detail layers does not exists!");
// 如果当前item被like过需要更新t_user_like表和t_user_like_group表 // 如果当前item被like过需要更新t_user_like表和t_user_like_group表
if (!designSingleIncludeLayersDTO.getIsPreview()){ if (!designSingleIncludeLayersDTO.getIsPreview()) {
updateUserLikeDate(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone()); updateUserLikeDate(designSingleIncludeLayersDTO.getDesignItemId(), designSingleIncludeLayersDTO.getTimeZone());
// 更新项目更新时间 // 更新项目更新时间
if (Objects.nonNull(designSingleIncludeLayersDTO.getProjectId())){ if (Objects.nonNull(designSingleIncludeLayersDTO.getProjectId())) {
projectService.modifyProjectUpdateTime(designSingleIncludeLayersDTO.getProjectId()); projectService.modifyProjectUpdateTime(designSingleIncludeLayersDTO.getProjectId());
}else { } else {
log.error("design single projectId传入空值导致项目修改时间没有更新"); log.error("design single projectId传入空值导致项目修改时间没有更新");
} }
}else { } else {
updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone()); updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(), designSingleIncludeLayersDTO.getTimeZone());
} }
return assembleDesignSingleResponse(designItem.getId(), return assembleDesignSingleResponse(designItem.getId(),
@@ -653,11 +644,11 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
return selectById(designItemId); // 普通查询,不加锁 return selectById(designItemId); // 普通查询,不加锁
} }
private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long userId){ private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long userId) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
// 如果sketch截图不为空则将该截图上传并替换path // 如果sketch截图不为空则将该截图上传并替换path
if (!StringUtil.isNullOrEmpty(item.getSketchString())){ if (!StringUtil.isNullOrEmpty(item.getSketchString())) {
if (StringUtil.isNullOrEmpty(item.getPath())){ if (StringUtil.isNullOrEmpty(item.getPath())) {
throw new BusinessException("path.cannot.be.empty"); throw new BusinessException("path.cannot.be.empty");
} }
String sourcePath = item.getPath(); String sourcePath = item.getPath();
@@ -671,7 +662,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 将原图地址作为修改后的图片地址,放在不同的桶 // 将原图地址作为修改后的图片地址,放在不同的桶
String newPath = minioUtil.base64UploadToPath(item.getSketchString(), modifiedSketchBucket, path); String newPath = minioUtil.base64UploadToPath(item.getSketchString(), modifiedSketchBucket, path);
if (StringUtil.isNullOrEmpty(newPath)){ if (StringUtil.isNullOrEmpty(newPath)) {
log.error("修改过的sketch图片上传失败"); log.error("修改过的sketch图片上传失败");
throw new BusinessException("image.modify.failed"); throw new BusinessException("image.modify.failed");
} }
@@ -680,25 +671,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Boolean setNull){ private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Boolean setNull) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
// 如果sketch截图不为空则将该截图上传并替换path // 如果sketch截图不为空则将该截图上传并替换path
if (setNull){ if (setNull) {
log.info("服装类型为{} set maskUrl为null", item.getType()); log.info("服装类型为{} set maskUrl为null", item.getType());
item.setMaskUrl(null); item.setMaskUrl(null);
}else { } else {
if (!StringUtil.isNullOrEmpty(item.getMaskUrl())){ if (!StringUtil.isNullOrEmpty(item.getMaskUrl())) {
log.info("服装{} 的maskUrl不为null", item.getType()); log.info("服装{} 的maskUrl不为null", item.getType());
// 由于前端不好处理这块所以当mask没有做任何修改的时候仍然会传原始mask的minio地址 // 由于前端不好处理这块所以当mask没有做任何修改的时候仍然会传原始mask的minio地址
if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")){ if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")) {
// 当没有修改mask时还是用之前的mask地址 // 当没有修改mask时还是用之前的mask地址
item.setMaskUrl(item.getMaskMinioUrl()); item.setMaskUrl(item.getMaskMinioUrl());
log.info("服装{} 的maskUrl没有被编辑", item.getType()); log.info("服装{} 的maskUrl没有被编辑", item.getType());
}else { } else {
// 将原图地址作为修改后的图片地址,放在不同的桶 // 将原图地址作为修改后的图片地址,放在不同的桶
String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID()); String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID());
log.info("服装{} 的maskUrl已被编辑 新的path为{}", item.getType(), path); log.info("服装{} 的maskUrl已被编辑 新的path为{}", item.getType(), path);
if (StringUtil.isNullOrEmpty(path)){ if (StringUtil.isNullOrEmpty(path)) {
log.error("标注的mask图片上传失败"); log.error("标注的mask图片上传失败");
throw new BusinessException("image.modify.failed"); throw new BusinessException("image.modify.failed");
} }
@@ -710,53 +701,55 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
private void partialDesignBase64ToImage(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long accountId, boolean preview){ private void partialDesignBase64ToImage(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long accountId, boolean preview) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
PartialDesignDTO partialDesignDTO = item.getPartialDesign(); PartialDesignDTO partialDesignDTO = item.getPartialDesign();
if (!Objects.isNull(item.getPartialDesign()) if (!Objects.isNull(item.getPartialDesign())
&& !StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignBase64())){ && !StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignBase64())) {
String path ; String path;
if (!StringUtil.isNullOrEmpty(partialDesignDTO.getPartialDesignMinioPath()) && !preview){ if (!StringUtil.isNullOrEmpty(partialDesignDTO.getPartialDesignMinioPath()) && !preview) {
String sourcePath = partialDesignDTO.getPartialDesignMinioPath(); String sourcePath = partialDesignDTO.getPartialDesignMinioPath();
path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf(".")); path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf("."));
}else if (preview){ } else if (preview) {
path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_PREVIEW_FILENAME + "/" + UUID.randomUUID(); path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_PREVIEW_FILENAME + "/" + UUID.randomUUID();
}else { } else {
path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_FILENAME + "/" + UUID.randomUUID(); path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_FILENAME + "/" + UUID.randomUUID();
} }
String newPath = minioUtil.base64UploadToPath(partialDesignDTO.getPartialDesignBase64(), partialDesignBucket, path); String newPath = minioUtil.base64UploadToPath(partialDesignDTO.getPartialDesignBase64(), partialDesignBucket, path);
if (StringUtil.isNullOrEmpty(newPath)){ if (StringUtil.isNullOrEmpty(newPath)) {
log.error("局部design图片上传失败"); log.error("局部design图片上传失败");
throw new BusinessException("partial.design.failed"); throw new BusinessException("partial.design.failed");
} }
item.getPartialDesign().setPartialDesignMinioPath(newPath); item.getPartialDesign().setPartialDesignMinioPath(newPath);
}else if (Objects.isNull(item.getPartialDesign()) } else if (Objects.isNull(item.getPartialDesign())
|| StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignMinioPath())){ || StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignMinioPath())) {
item.setPartialDesign(new PartialDesignDTO(null)); item.setPartialDesign(new PartialDesignDTO(null));
} }
}); });
} }
@Override @Override
public Map<String, List<String>> setPriorityAndUndividedLayer(JSONArray layers){ public Map<String, List<String>> setPriorityAndUndividedLayer(JSONArray layers) {
HashMap<String, List<String>> priorityAndLayer = new HashMap<>(); HashMap<String, List<String>> priorityAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) { for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i); JSONObject jsonObject = layers.getJSONObject(i);
String priority = jsonObject.getString("priority"); String priority = jsonObject.getString("priority");
String category = jsonObject.getString("image_category").split("_")[0]; String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !priorityAndLayer.containsKey(priority)) priorityAndLayer.put(priority, Arrays.asList(jsonObject.getString("pattern_overall_image_url"), jsonObject.getString("pattern_print_image_url"))); if (!category.equals("body") && !priorityAndLayer.containsKey(priority))
priorityAndLayer.put(priority, Arrays.asList(jsonObject.getString("pattern_overall_image_url"), jsonObject.getString("pattern_print_image_url")));
} }
return priorityAndLayer; return priorityAndLayer;
} }
// 由于在design过程中没有priority 优先级的概念并且在design时不会出现上下两件使用相同服装类型的情况所以这里依然保留这个方法。 // 由于在design过程中没有priority 优先级的概念并且在design时不会出现上下两件使用相同服装类型的情况所以这里依然保留这个方法。
@Override @Override
public Map<String, String> setTypeAndUndividedLayer(JSONArray layers){ public Map<String, String> setTypeAndUndividedLayer(JSONArray layers) {
HashMap<String, String> typeAndLayer = new HashMap<>(); HashMap<String, String> typeAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) { for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i); JSONObject jsonObject = layers.getJSONObject(i);
String category = jsonObject.getString("image_category").split("_")[0]; String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !typeAndLayer.containsKey(category)) typeAndLayer.put(category, jsonObject.getString("pattern_image_url")); if (!category.equals("body") && !typeAndLayer.containsKey(category))
typeAndLayer.put(category, jsonObject.getString("pattern_image_url"));
} }
return typeAndLayer; return typeAndLayer;
} }
@@ -767,18 +760,18 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers(); ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers();
// 1、校验designItem是是否存在 // 1、校验designItem是是否存在
DesignItem designItem = selectById(designItemLayer.getDesignItemId()); DesignItem designItem = selectById(designItemLayer.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designItemLayer.getDesignItemId()); TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designItemLayer.getDesignItemId());
if (Objects.isNull(designPythonOutfit)){ if (Objects.isNull(designPythonOutfit)) {
throw new BusinessException("layers.does.not.exists"); throw new BusinessException("layers.does.not.exists");
} }
// 2、校验layers是否存在 // 2、校验layers是否存在
designItemLayer.getLayers().forEach(layer -> { designItemLayer.getLayers().forEach(layer -> {
TDesignPythonOutfitDetail detail = designPythonOutfitDetailService.getById(layer.getId()); TDesignPythonOutfitDetail detail = designPythonOutfitDetailService.getById(layer.getId());
if (Objects.isNull(detail)){ if (Objects.isNull(detail)) {
log.error(layer.getImageCategory() + " layer does not exists!"); log.error(layer.getImageCategory() + " layer does not exists!");
throw new BusinessException("layers.does.not.exists"); throw new BusinessException("layers.does.not.exists");
} }
@@ -833,24 +826,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
// 9、如果当前item被like过需要更新t_user_like表和t_user_like_group表 // 9、如果当前item被like过需要更新t_user_like表和t_user_like_group表
updateUserLikeDate(designItemLayer.getDesignItemId(),positionAndScaleVO.getTimeZone()); updateUserLikeDate(designItemLayer.getDesignItemId(), positionAndScaleVO.getTimeZone());
return designItemLayer; return designItemLayer;
} }
private void updateUserLikeDate(Long designItemId,String timeZone){ private void updateUserLikeDate(Long designItemId, String timeZone) {
UserLike userLike = userLikeService.getByDesignItemId(designItemId); UserLike userLike = userLikeService.getByDesignItemId(designItemId);
if (!ObjectUtil.isEmpty(userLike)){ if (!ObjectUtil.isEmpty(userLike)) {
Long userLikeGroupId = userLike.getUserLikeGroupId(); Long userLikeGroupId = userLike.getUserLikeGroupId();
// 更新t_user_like和t_user_like_group表的update_date // 更新t_user_like和t_user_like_group表的update_date
userLikeService.updateDate(designItemId,timeZone); userLikeService.updateDate(designItemId, timeZone);
userLikeGroupService.updateDate(userLikeGroupId,timeZone); userLikeGroupService.updateDate(userLikeGroupId, timeZone);
} }
} }
private void updateUserLikeConvertStatus(Long designItemId,String timeZone){
private void updateUserLikeConvertStatus(Long designItemId, String timeZone) {
UserLike userLike = userLikeService.getByDesignItemId(designItemId); UserLike userLike = userLikeService.getByDesignItemId(designItemId);
if (!ObjectUtil.isEmpty(userLike) && userLike.getConverted() == 0){ if (!ObjectUtil.isEmpty(userLike) && userLike.getConverted() == 0) {
// 更新t_user_like和t_user_like_group表的update_date // 更新t_user_like和t_user_like_group表的update_date
userLikeService.updateDate(designItemId,timeZone); userLikeService.updateDate(designItemId, timeZone);
} }
} }
@@ -886,7 +880,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 重置sketch的minio临时访问凭证 // 重置sketch的minio临时访问凭证
designItemClothesDetailVO.setPath(minioUtil.getPreSignedUrl(singleItem.getPath(), 24 * 60, true)); designItemClothesDetailVO.setPath(minioUtil.getPreSignedUrl(singleItem.getPath(), 24 * 60, true));
designItemClothesDetailVO.setMinIOPath(singleItem.getPath()); designItemClothesDetailVO.setMinIOPath(singleItem.getPath());
if (!StringUtil.isNullOrEmpty(singleItem.getColor())) designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor())); if (!StringUtil.isNullOrEmpty(singleItem.getColor()))
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject()); designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject());
designItemClothesDetailVO.setTrims(singleItem.getTrims()); designItemClothesDetailVO.setTrims(singleItem.getTrims());
designItemClothesDetailVO.setLayersObject(layersObject.stream().filter( designItemClothesDetailVO.setLayersObject(layersObject.stream().filter(
@@ -898,7 +893,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true); String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true);
designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl)); designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl));
if (priorityAndUndividedLayer.containsKey(singleItem.getPriority().toString())){ if (priorityAndUndividedLayer.containsKey(singleItem.getPriority().toString())) {
designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(0), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true)); designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(0), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
designItemClothesDetailVO.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(1), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true)); designItemClothesDetailVO.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(1), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
} }
@@ -932,13 +927,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
ArrayList<DesignItemDetailPrint> designItemDetailPrints, ArrayList<DesignItemDetailPrint> designItemDetailPrints,
String printType, String printType,
Map<Integer, Long> designItemDetailTypeIdMap, Map<Integer, Long> designItemDetailTypeIdMap,
String timeZone){ String timeZone) {
// todo 这边这样做对吗 // todo 这边这样做对吗
DesignSinglePrintDTO printObject; DesignSinglePrintDTO printObject;
if (printType.equals("print")){ if (printType.equals("print")) {
printObject = designSingleItem.getPrintObject(); printObject = designSingleItem.getPrintObject();
}else { } else {
printObject = designSingleItem.getTrims(); printObject = designSingleItem.getTrims();
} }
@@ -971,9 +966,9 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
// 对印花类型为Generate的图片路径进行特殊处理 // 对印花类型为Generate的图片路径进行特殊处理
private void setUriToMinioPath(DesignSinglePrint print){ private void setUriToMinioPath(DesignSinglePrint print) {
if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Generate")){ if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Generate")) {
if (!StringUtil.isNullOrEmpty(print.getPath())){ if (!StringUtil.isNullOrEmpty(print.getPath())) {
try { try {
URI uri = new URI(print.getPath()); URI uri = new URI(print.getPath());
String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png
@@ -1003,20 +998,20 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
@Override @Override
public List<DesignItem> selectDesignIdById(List<Long> designItemIdList){ public List<DesignItem> selectDesignIdById(List<Long> designItemIdList) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",designItemIdList); queryWrapper.in("id", designItemIdList);
return designItemMapper.selectList(queryWrapper); return designItemMapper.selectList(queryWrapper);
} }
private void saveCollectionElement(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){ private void saveCollectionElement(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
ArrayList<Library> libraries = new ArrayList<>(); ArrayList<Library> libraries = new ArrayList<>();
// 添加sketch到library // 添加sketch到library
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> {
if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")) {
String path = minioUtil.getPreSignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
@@ -1026,13 +1021,13 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designSingleIncludeLayersDTO.getGender(), designSingleIncludeLayersDTO.getGender(),
md5); md5);
// 加入到library // 加入到library
if (needAdd){ if (needAdd) {
Library library = new Library(); Library library = new Library();
library.setAccountId(UserContext.getUserHolder().getId()); library.setAccountId(UserContext.getUserHolder().getId());
library.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()); library.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
library.setLevel2Type(designSingleItem.getType()); library.setLevel2Type(designSingleItem.getType());
library.setLevel3Type(designSingleIncludeLayersDTO.getGender()); library.setLevel3Type(designSingleIncludeLayersDTO.getGender());
String ageGroup = designService.getAgeGroupByProjectOrCollectionId(designSingleIncludeLayersDTO.getProjectId(), null); String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designSingleIncludeLayersDTO.getProjectId(), null);
library.setAgeGroup(ageGroup); library.setAgeGroup(ageGroup);
library.setUrl(designSingleItem.getPath()); library.setUrl(designSingleItem.getPath());
library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
@@ -1047,7 +1042,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 添加print到library // 添加print到library
designSingleItem.getPrintObject().getPrints().forEach(print -> { designSingleItem.getPrintObject().getPrints().forEach(print -> {
if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")) {
String path = minioUtil.getPreSignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
@@ -1057,7 +1052,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
null, null,
md5); md5);
// 加入到library // 加入到library
if (needAdd){ if (needAdd) {
Library library = new Library(); Library library = new Library();
library.setAccountId(UserContext.getUserHolder().getId()); library.setAccountId(UserContext.getUserHolder().getId());
library.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); library.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
@@ -1073,17 +1068,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
}); });
} ); });
libraryService.saveBatch(libraries); libraryService.saveBatch(libraries);
} }
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){ public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("create_date", startTime) queryWrapper.gt("create_date", startTime)
.lt("create_date", endTime) .lt("create_date", endTime)
.select("count(distinct design_id) as count"); .select("count(distinct design_id) as count");
if (!accountIds.isEmpty()){ if (!accountIds.isEmpty()) {
queryWrapper.in("account_id", accountIds); queryWrapper.in("account_id", accountIds);
} }
@@ -1091,7 +1086,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
Object countObj = result.get(0).get("count"); Object countObj = result.get(0).get("count");
return (Long) countObj; return (Long) countObj;
}else { } else {
return 0L; return 0L;
} }
} }
@@ -1099,14 +1094,15 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
@Resource @Resource
private UserLikeMapper userLikeMapper; private UserLikeMapper userLikeMapper;
@Override @Override
public void convertHistoryMaskWithoutGradient(){ public void convertHistoryMaskWithoutGradient() {
// 1、获取全部需要转换的designOutfitId // 1、获取全部需要转换的designOutfitId
// 1、获取t_user_like表中design_item_id不为-1的所有design_item_id, design_outfit_id // 1、获取t_user_like表中design_item_id不为-1的所有design_item_id, design_outfit_id
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("design_item_id", -1) queryWrapper.ne("design_item_id", -1)
.ne("converted", 1) .ne("converted", 1)
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id"); .groupBy(Arrays.asList("design_outfit_id", " design_item_id")).select(" design_item_id", "design_outfit_id");
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper); List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
// List<Map<String, Object>> userLikes = userLikeMapper.selectMaps(queryWrapper); // List<Map<String, Object>> userLikes = userLikeMapper.selectMaps(queryWrapper);
@@ -1158,10 +1154,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (suffixes.containsKey("front") && suffixes.containsKey("back")) { if (suffixes.containsKey("front") && suffixes.containsKey("back")) {
String frontMask = suffixes.get("front"); String frontMask = suffixes.get("front");
String backMask = suffixes.get("back"); String backMask = suffixes.get("back");
pairs.add(new String[]{designItemPath.get(entry.getKey()),frontMask, backMask, frontMask}); pairs.add(new String[]{designItemPath.get(entry.getKey()), frontMask, backMask, frontMask});
} }
} }
log.info("总数 count + current : {} + {} = {}", count, groupedData.size(), count.get() + groupedData.size()); log.info("总数 count + current : {} + {} = {}", count, groupedData.size(), count.get() + groupedData.size());
count.addAndGet(groupedData.size()); count.addAndGet(groupedData.size());
}); });
@@ -1173,7 +1169,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
try { try {
// 写入JSON文件 // 写入JSON文件
objectMapper.writeValue(new File("mask_pairs.json"), pairs); objectMapper.writeValue(new File("mask_pairs.json"), pairs);
log.info("待合成mask的数量{}",pairs.size()); log.info("待合成mask的数量{}", pairs.size());
System.out.println("数据已成功写入mask_pairs.json文件"); System.out.println("数据已成功写入mask_pairs.json文件");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -1181,11 +1177,11 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateMaskUrl(){ public void updateMaskUrl() {
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("design_item_id", -1) queryWrapper.ne("design_item_id", -1)
.ne("converted", 1) .ne("converted", 1)
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id"); .groupBy(Arrays.asList("design_outfit_id", " design_item_id")).select(" design_item_id", "design_outfit_id");
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper); List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
log.info("userLike 总数 {}", userLikes.size()); log.info("userLike 总数 {}", userLikes.size());
@@ -1207,7 +1203,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 检查是否以'front'结尾 // 检查是否以'front'结尾
if (imageCategory.endsWith("front")) { if (imageCategory.endsWith("front")) {
String maskPath = maskUrl.replace("aida-clothing", "test" ); String maskPath = maskUrl.replace("aida-clothing", "test");
String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_")); String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_"));
if (backMaskIdMap.containsKey(prefix)) { if (backMaskIdMap.containsKey(prefix)) {
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail(); TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
@@ -1215,7 +1211,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now()); tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
tDesignPythonOutfitDetail.setId(backMaskIdMap.get(prefix)); tDesignPythonOutfitDetail.setId(backMaskIdMap.get(prefix));
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail); tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
}else { } else {
frontMaskMap.put(prefix, maskPath); frontMaskMap.put(prefix, maskPath);
} }
@@ -1237,7 +1233,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now()); tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId()); tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId());
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail); tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
}else { } else {
backMaskIdMap.put(prefix, designPythonOutfitDetail.getId()); backMaskIdMap.put(prefix, designPythonOutfitDetail.getId());
} }
} }

View File

@@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -61,56 +62,47 @@ import static com.ai.da.python.vo.DesignPythonItem.*;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> implements DesignService { public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> implements DesignService {
@Resource private final CloudTaskMapper cloudTaskMapper;
private DesignMapper designMapper; private final CloudTaskService cloudTaskService;
@Resource private final CreditsService creditsService;
private CollectionElementService collectionElementService; private final CollectionElementService collectionElementService;
@Resource private final CollectionService collectionService;
private CollectionService collectionService; private final CollectionSortService collectionSortService;
@Resource private final ColorLoopUpTableService colorLoopUpTableService;
private PythonService pythonService; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource private final DesignBatchMapper designBatchMapper;
private LibraryService libraryService; private final DesignMapper designMapper;
@Resource private final DesignItemService designItemService;
private GenerateDetailMapper generateDetailMapper; private final DesignItemDetailMapper designItemDetailMapper;
@Resource private final DesignItemDetailService designItemDetailService;
private DesignItemService designItemService; private final DesignItemDetailPrintService designItemDetailPrintService;
@Resource private final TDesignPythonOutfitMapper designPythonOutfitMapper;
private DesignItemDetailService designItemDetailService; private final ITDesignPythonOutfitService designPythonOutfitService;
@Resource private final ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
private FileProperties fileProperties; private final FileProperties fileProperties;
@Resource private final GenerateDetailMapper generateDetailMapper;
private UserLikeGroupService userLikeGroupService; private final LibraryService libraryService;
@Resource private final MinioUtil minioUtil;
private UserLikeService userLikeService; private final MoodboardPositionMapper moodboardPositionMapper;
@Resource private final ProjectService projectService;
private SysFileService sysFileService; private final PythonService pythonService;
@Resource private final PanToneMapper panToneMapper;
private TCollectionElementRelationService tCollectionElementRelationService; private final PanToneService panToneService;
@Resource private final PoseTransformationMapper poseTransformationMapper;
private ITDesignPythonOutfitService designPythonOutfitService; private final PythonTAllInfoService pythonTAllInfoService;
@Resource private final RedisUtil redisUtil;
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService; private final SysFileService sysFileService;
@Resource private final TCollectionElementRelationService tCollectionElementRelationService;
private PanToneService panToneService; private final ToProductImageResultMapper toProductImageResultMapper;
@Resource private final ToProductElementMapper toProductElementMapper;
private PythonTAllInfoService pythonTAllInfoService; private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final UserLikeGroupService userLikeGroupService;
private DesignItemDetailPrintService designItemDetailPrintService; private final UserLikeService userLikeService;
private final UserBehaviorMapper userBehaviorMapper;
@Resource private final UserPreferenceLogMapper userPreferenceLogMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final WorkspaceService workspaceService;
@Resource
private DesignItemDetailMapper designItemDetailMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private ToProductElementMapper toProductElementMapper;
@Resource
private MoodboardPositionMapper moodboardPositionMapper;
@Resource
private CollectionSortService collectionSortService;
@Value("${minio.endpoint}") @Value("${minio.endpoint}")
private String endpoint; private String endpoint;
@@ -123,34 +115,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Value("${access.python.port:''}") @Value("${access.python.port:''}")
private String accessPythonPort; private String accessPythonPort;
@Resource
private RedisUtil redisUtil;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Resource
private DesignBatchMapper designBatchMapper;
@Resource
private ProjectService projectService;
@Resource
private WorkspaceService workspaceService;
@Resource
private CloudTaskMapper cloudTaskMapper;
@Resource
private CloudTaskService cloudTaskService;
@Resource
private CreditsService creditsService;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private ColorLoopUpTableService colorLoopUpTableService;
@Resource
private UserBehaviorMapper userBehaviorMapper;
@Resource
private UserPreferenceLogMapper userPreferenceLogMapper;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>();
@@ -323,11 +287,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList()); // List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
// handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds); // handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
// //保存python返回信息 // //保存python返回信息
//// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
/// / return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
// //保存designItem 和detail // //保存designItem 和detail
// return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone()); // return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
// } // }
private String designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, private String designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
Long collectionIdParam, ValidateElementVO elementVO) { Long collectionIdParam, ValidateElementVO elementVO) {
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) { // if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
@@ -342,7 +306,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Long collectionId; Long collectionId;
if (null == collectionIdParam) { if (null == collectionIdParam) {
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition()); collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
}else { } else {
collectionId = collectionIdParam; collectionId = collectionIdParam;
} }
List<Long> elementIds = getElementId(elementVO); List<Long> elementIds = getElementId(elementVO);
@@ -388,7 +352,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// 生成library - 根据设计元素生成设计库信息 // 生成library - 根据设计元素生成设计库信息
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String ageGroup = getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId); String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId);
generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup); generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup);
//处理关联关系,修复element覆盖得情况 //处理关联关系,修复element覆盖得情况
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId); // List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
@@ -419,124 +383,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return requestId; return requestId;
} }
public String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId){
if (Objects.nonNull(projectId)){
Workspace workspace = workspaceService.getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())){
return workspace.getAgeGroup();
}
} else if (Objects.nonNull(collectionId) && collectionId != 0){
List<CollectionElement> byCollectionId = collectionElementService.getByCollectionId(collectionId);
if (byCollectionId != null && !byCollectionId.isEmpty()){
projectId = byCollectionId.get(0).getProjectId();
if (projectId != null && projectId != 0L){
Workspace workspace = workspaceService.getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())){
return workspace.getAgeGroup();
}
}
}
}
return AgeGroup.ADULT.getValue();
}
@Override
public void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam) {
if (!StringUtils.isEmpty(moodboardPosition)) {
// 将 JSON 字符串解析为 JSONObject
JSONObject moodboardPositionJson = JSONObject.parseObject(moodboardPosition);
// 准备保存的 MoodboardPosition 列表
List<MoodboardPosition> moodboardPositions = new ArrayList<>();
// 遍历 JSON 对象的 key即样式类型
for (String key : moodboardPositionJson.keySet()) {
// 特殊处理 "class" 字段
if ("class".equals(key)) {
// 获取 "class" 字段的值并将其转为 List<String>
JSONArray classArray = moodboardPositionJson.getJSONArray(key);
if (classArray != null) {
for (int j = 0; j < classArray.size(); j++) {
// 将 classList 存入 MoodboardPosition或者其他结构
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(classArray.getString(j)) // 设置 class 字段
.setSequence(j) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
continue; // 跳过 "class" 字段的常规处理
}
JSONArray styleArray = moodboardPositionJson.getJSONArray(key);
if (styleArray != null) {
for (int i = 0; i < styleArray.size(); i++) {
// 获取当前样式数据
JSONObject styleData = styleArray.getJSONObject(i);
// 构建 MoodboardPosition 实例
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(styleData.toJSONString()) // 样式数据存为 JSON 字符串
.setSequence(i) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
}
// 如果解析结果非空,保存到数据库
if (!moodboardPositions.isEmpty()) {
for (MoodboardPosition position : moodboardPositions) {
moodboardPositionMapper.insert(position);
}
log.info("成功解析并保存 {} 条 MoodboardPosition 数据", moodboardPositions.size());
} else {
log.warn("未找到可保存的 MoodboardPosition 数据");
}
} else {
log.warn("传入的 moodboardPosition 字段为空");
}
}
@Override
public void relationImageId(DesignPythonObjects pythonObjects) {
if (Objects.isNull(pythonObjects)) {
return;
}
pythonObjects.getObjects().forEach(
o -> {
for (DesignPythonItem item : o.getItems()) {
List<Long> list = new ArrayList<>();
list.add(1L);
list.add(1L);
item.setOffset(list);
item.setResize_scale(new Float[]{1.0f,1.0f});
String path = item.getPath();
if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path();
Long imageId = pythonTAllInfoService.getImageIdByPath(bodyPath);
item.setImage_id(imageId);
} else {
Long imageId = pythonTAllInfoService.getImageIdByPath(path);
item.setImage_id(imageId);
}
}
}
);
}
@Override @Override
public List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignDTO) { public List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignDTO) {
List<CollectionSketchDTO> sketchBoards = new ArrayList<>(); List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
@@ -610,18 +456,18 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
}else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) { } else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId()); GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId());
libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type()); libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type());
String url = generateDetail.getUrl(); String url = generateDetail.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
@@ -639,7 +485,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
@@ -662,7 +508,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
list.add(1L); list.add(1L);
list.add(1L); list.add(1L);
item.setOffset(list); item.setOffset(list);
item.setResize_scale(new Float[]{1.0f,1.0f}); item.setResize_scale(new Float[]{1.0f, 1.0f});
String path = item.getPath(); String path = item.getPath();
if (StringUtils.isEmpty(path)) { if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path(); String bodyPath = item.getBody_path();
@@ -757,8 +603,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
LocalCacheUtils.setDesignProcessCache(userId, saveNames); LocalCacheUtils.setDesignProcessCache(userId, saveNames);
} }
@Resource
private MinioUtil minioUtil;
private DesignCollectionVO savePythonDesignItemAndDetailSingle(DesignPythonObjects pythonObjects, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject outfit, String singleOverall, Map<String, Object> context) { private DesignCollectionVO savePythonDesignItemAndDetailSingle(DesignPythonObjects pythonObjects, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject outfit, String singleOverall, Map<String, Object> context) {
Object designCollectionVO = context.get("DesignCollectionVO"); Object designCollectionVO = context.get("DesignCollectionVO");
@@ -769,7 +613,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
response.setDesignId(designId); response.setDesignId(designId);
response.setCollectionId(collectionId); response.setCollectionId(collectionId);
response.setProcessId(pythonObjects.getProcess_id()); response.setProcessId(pythonObjects.getProcess_id());
}else { } else {
response = (DesignCollectionVO) designCollectionVO; response = (DesignCollectionVO) designCollectionVO;
designCollectionItems = response.getDesignCollectionItems(); designCollectionItems = response.getDesignCollectionItems();
} }
@@ -882,7 +726,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
log.info("detail.getType():{}", detail.getType()); log.info("detail.getType():{}", detail.getType());
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
log.info("layer : {}", typeAndUndividedLayer.get(designItemDetail.getType())); log.info("layer : {}", typeAndUndividedLayer.get(designItemDetail.getType()));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
@@ -893,7 +737,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -928,6 +772,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
return response; return response;
} }
private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject, String singleOverall) { , Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject, String singleOverall) {
DesignCollectionVO response = new DesignCollectionVO(); DesignCollectionVO response = new DesignCollectionVO();
@@ -1005,8 +850,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
List<DesignItemDetail> designItemDetails = Lists.newArrayList(); List<DesignItemDetail> designItemDetails = Lists.newArrayList();
Map<String, Integer> typePriority = list.stream().collect(Collectors.toMap(d -> d.getImageCategory().split("_")[0], Map<String, Integer> typePriority = list.stream().collect(Collectors.toMap(d -> d.getImageCategory().split("_")[0],
d -> Math.abs(d.getPriority()), d -> Math.abs(d.getPriority()),
(existing, replacement) -> replacement)); (existing, replacement) -> replacement));
Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers); Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers);
for (DesignPythonItem detail : item.getItems()) { for (DesignPythonItem detail : item.getItems()) {
if (null == detail) { if (null == detail) {
@@ -1018,7 +863,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
@@ -1029,7 +874,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -1197,7 +1042,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public DesignLikeVO like(DesignLikeDTO designLikeDTO) { public DesignLikeVO like(DesignLikeDTO designLikeDTO) {
Long userGroupId = designLikeDTO.getUserGroupId();; Long userGroupId = designLikeDTO.getUserGroupId();
Long groupDetailId; Long groupDetailId;
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
DesignItem designItem = designItemService.getById(designLikeDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(designLikeDTO.getDesignItemId());
@@ -1389,7 +1234,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public String generateHighDesign(GenerateHighDesignDTO generateHighDesignDTO) { public String generateHighDesign(GenerateHighDesignDTO generateHighDesignDTO) {
DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
String highUrl = pythonService.generateHighDesign(designItem.getDesignUrl()); String highUrl = pythonService.generateHighDesign(designItem.getDesignUrl());
@@ -1401,7 +1246,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public Boolean deleteHighDesign(GenerateHighDesignDTO generateHighDesignDTO) { public Boolean deleteHighDesign(GenerateHighDesignDTO generateHighDesignDTO) {
DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
if (StringUtils.isEmpty(designItem.getHighDesignUrl())) { if (StringUtils.isEmpty(designItem.getHighDesignUrl())) {
@@ -1444,7 +1289,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
// 为没有优先级的衣服添加优先级 // 为没有优先级的衣服添加优先级
if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")){ if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")) {
designItemDetailService.setDesignItemDetailPriority(designItemDetails); designItemDetailService.setDesignItemDetailPriority(designItemDetails);
} }
@@ -1456,7 +1301,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
response.setHighDesignUrl(designItem.getHighDesignUrl()); response.setHighDesignUrl(designItem.getHighDesignUrl());
List<DesignItemDetail> filterDetail = designItemDetails.stream() List<DesignItemDetail> filterDetail = designItemDetails.stream()
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType()) .filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType())
|| TOPS.contains(f.getType()) || BOTTOMS.contains(f.getType())|| OTHERS.contains(f.getType())) || TOPS.contains(f.getType()) || BOTTOMS.contains(f.getType()) || OTHERS.contains(f.getType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> { response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId()); d.setId(o.getId());
@@ -1465,10 +1310,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
d.setScope(o.getPath().startsWith("aida-sys-image") ? "sys" : "user"); d.setScope(o.getPath().startsWith("aida-sys-image") ? "sys" : "user");
d.setLevel1Type(converTypeToLevel1(o.getType())); d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class)); d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())){ if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())) {
d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (!StringUtil.isNullOrEmpty(o.getUndividedLayerWithSinglePrint())){ if (!StringUtil.isNullOrEmpty(o.getUndividedLayerWithSinglePrint())) {
d.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(o.getUndividedLayerWithSinglePrint(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); d.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(o.getUndividedLayerWithSinglePrint(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
// 根据designItemDetailId获取印花 // 根据designItemDetailId获取印花
@@ -1489,7 +1334,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String preSigned = StringUtil.isNullOrEmpty(o.getPartialDesign()) ? null : minioUtil.getPreSignedUrl(o.getPartialDesign(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String preSigned = StringUtil.isNullOrEmpty(o.getPartialDesign()) ? null : minioUtil.getPreSignedUrl(o.getPartialDesign(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
d.setPartialDesign(new PartialDesignDTO(o.getPartialDesign(), preSigned)); d.setPartialDesign(new PartialDesignDTO(o.getPartialDesign(), preSigned));
DesignItemDetailCanvas designItemDetailCanvas = designItemDetailService.getDIDCByDesignItemDetailId(o.getId()); DesignItemDetailCanvas designItemDetailCanvas = designItemDetailService.getDIDCByDesignItemDetailId(o.getId());
if (Objects.nonNull(designItemDetailCanvas)){ if (Objects.nonNull(designItemDetailCanvas)) {
d.setCanvasId(designItemDetailCanvas.getExportFileId()); d.setCanvasId(designItemDetailCanvas.getExportFileId());
} }
})); }));
@@ -1627,7 +1472,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
}); });
if (!CollectionUtil.isEmpty(designItemDetailIdColor)){ if (!CollectionUtil.isEmpty(designItemDetailIdColor)) {
Map<String, PantoneVO> pantoneByRgbBatch = panToneService.getPantoneByRgbBatch(new ArrayList<>(designItemDetailIdColor.values())); Map<String, PantoneVO> pantoneByRgbBatch = panToneService.getPantoneByRgbBatch(new ArrayList<>(designItemDetailIdColor.values()));
designItemDetailVO.getClothes().forEach(c -> { designItemDetailVO.getClothes().forEach(c -> {
PantoneVO pantoneVO = pantoneByRgbBatch.get(designItemDetailIdColor.get(c.getId())); PantoneVO pantoneVO = pantoneByRgbBatch.get(designItemDetailIdColor.get(c.getId()));
@@ -1649,13 +1494,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (flag) { if (flag) {
// 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误 // 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId()); List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
if (Objects.isNull(details)){ if (Objects.isNull(details)) {
log.error("Layer information is empty! DesignPythonOutfitId is " + designPythonOutfit.getId()); log.error("Layer information is empty! DesignPythonOutfitId is " + designPythonOutfit.getId());
throw new BusinessException("layer.information.not.found"); throw new BusinessException("layer.information.not.found");
} }
// 为没有优先级的图层添加优先级 // 为没有优先级的图层添加优先级
if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")){ if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")) {
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details); designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details);
} }
@@ -1705,16 +1550,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designSinglePrint.setMinIOPath(detailPrint.getPath()); designSinglePrint.setMinIOPath(detailPrint.getPath());
designSinglePrint.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE); designSinglePrint.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE);
List<Float> scales; List<Float> scales;
try{ try {
scales = JSONArray.parseArray(detailPrint.getScale(), Float.class); scales = JSONArray.parseArray(detailPrint.getScale(), Float.class);
}catch (JSONException e){ } catch (JSONException e) {
Float scale = Float.valueOf(detailPrint.getScale()); Float scale = Float.valueOf(detailPrint.getScale());
if (designSinglePrint.getIfSingle()){ if (designSinglePrint.getIfSingle()) {
List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(detailPrint.getPath()); List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(detailPrint.getPath());
List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath); List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath);
scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1)); scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1));
}else { } else {
scales = Arrays.asList(scale, scale); scales = Arrays.asList(scale, scale);
} }
} }
@@ -1727,15 +1572,15 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// if (print.getSingleOrOverall().equals("single")) { // if (print.getSingleOrOverall().equals("single")) {
List<Float> scales; List<Float> scales;
Boolean ifSingle = print.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE; Boolean ifSingle = print.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE;
try{ try {
scales = JSONArray.parseArray(print.getScale(), Float.class); scales = JSONArray.parseArray(print.getScale(), Float.class);
}catch (JSONException e){ } catch (JSONException e) {
Float scale = Float.valueOf(print.getScale()); Float scale = Float.valueOf(print.getScale());
if (ifSingle){ if (ifSingle) {
List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(print.getPath()); List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(print.getPath());
List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath); List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath);
scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1)); scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1));
}else { } else {
scales = Arrays.asList(scale, scale); scales = Arrays.asList(scale, scale);
} }
} }
@@ -1756,27 +1601,27 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
@Override @Override
public List<String> getModel(List<Long> designItemIdList){ public List<String> getModel(List<Long> designItemIdList) {
ArrayList<String> models = new ArrayList<>(); ArrayList<String> models = new ArrayList<>();
List<DesignItem> designIdById = designItemService.selectDesignIdById(designItemIdList); List<DesignItem> designIdById = designItemService.selectDesignIdById(designItemIdList);
if (CollectionUtil.isEmpty(designIdById)){ if (CollectionUtil.isEmpty(designIdById)) {
log.info("according to the designItemIdList cannot find the designIdList"); log.info("according to the designItemIdList cannot find the designIdList");
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
List<Long> designIdList = designIdById.stream().map(DesignItem::getDesignId).collect(Collectors.toList()); List<Long> designIdList = designIdById.stream().map(DesignItem::getDesignId).collect(Collectors.toList());
List<Design> designs = selectList(designIdList); List<Design> designs = selectList(designIdList);
if (CollectionUtil.isEmpty(designIdList)){ if (CollectionUtil.isEmpty(designIdList)) {
log.info("according to the designIdList cannot find the design"); log.info("according to the designIdList cannot find the design");
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromLibIds)){ if (!CollectionUtil.isEmpty(modelFromLibIds)) {
models.addAll(libraryService.getByIds(modelFromLibIds).stream() models.addAll(libraryService.getByIds(modelFromLibIds).stream()
.map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromSysIds)){ if (!CollectionUtil.isEmpty(modelFromSysIds)) {
models.addAll(sysFileService.getByIds(modelFromSysIds).stream() models.addAll(sysFileService.getByIds(modelFromSysIds).stream()
.map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
@@ -1785,21 +1630,21 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return models; return models;
} }
private List<Design> selectList(List<Long> designIdList){ private List<Design> selectList(List<Long> designIdList) {
QueryWrapper<Design> queryWrapper = new QueryWrapper<>(); QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",designIdList); queryWrapper.in("id", designIdList);
return designMapper.selectList(queryWrapper); return designMapper.selectList(queryWrapper);
} }
// 查询指定用户在指定时间内使用了多少次design // 查询指定用户在指定时间内使用了多少次design
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){ public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds) {
QueryWrapper<Design> queryWrapper = new QueryWrapper<>(); QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("create_date", startTime) queryWrapper.gt("create_date", startTime)
.lt("create_date", endTime) .lt("create_date", endTime)
.select("count(id) as count"); .select("count(id) as count");
if (!Objects.isNull(accountIds) && !accountIds.isEmpty() ){ if (!Objects.isNull(accountIds) && !accountIds.isEmpty()) {
queryWrapper.in("account_id", accountIds); queryWrapper.in("account_id", accountIds);
} }
@@ -1807,7 +1652,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
Object countObj = result.get(0).get("count"); Object countObj = result.get(0).get("count");
return (Long) countObj; return (Long) countObj;
}else { } else {
return 0L; return 0L;
} }
} }
@@ -1885,7 +1730,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//design //design
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId); String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
return taskId; return taskId;
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) { } else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage(); ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
// 判断用户当前积分是否够本次生成消耗 // 判断用户当前积分是否够本次生成消耗
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
@@ -1974,17 +1819,17 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (design.getSingleOverall().equals("single")) { if (design.getSingleOverall().equals("single")) {
productType = "single"; productType = "single";
sb.append(collect); sb.append(collect);
}else { } else {
if (collect.contains("Tops")) { if (collect.contains("Tops")) {
sb.append("a handsome man,"); sb.append("a handsome man,");
}else { } else {
sb.append("a beautiful women,"); sb.append("a beautiful women,");
} }
sb.append("wearing ").append(collect); sb.append("wearing ").append(collect);
} }
if (StringUtils.isEmpty(prompt)) { if (StringUtils.isEmpty(prompt)) {
sb.append(",high quality clothing details,8K realistic,HDR"); sb.append(",high quality clothing details,8K realistic,HDR");
}else { } else {
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR"); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
} }
// 走模型 // 走模型
@@ -2017,17 +1862,17 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setImageStrength(randomFromRange); toProductImageResult.setImageStrength(randomFromRange);
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
}else { } else {
if (StringUtils.isEmpty(prompt)) { if (StringUtils.isEmpty(prompt)) {
sb.append(",high quality clothing details,8K realistic,HDR"); sb.append(",high quality clothing details,8K realistic,HDR");
}else { } else {
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR"); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
} }
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
@@ -2061,19 +1906,19 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setImageStrength(randomFromRange); toProductImageResult.setImageStrength(randomFromRange);
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
sb = new StringBuilder("The best quality, masterpiece, real image."); sb = new StringBuilder("The best quality, masterpiece, real image.");
} }
return batchTaskId; return batchTaskId;
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) { } else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage(); ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
// 判断用户当前积分是否够本次生成消耗 // 判断用户当前积分是否够本次生成消耗
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
@@ -2140,7 +1985,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String s = ""; String s = "";
if (!StringUtil.isNullOrEmpty(prompt)) { if (!StringUtil.isNullOrEmpty(prompt)) {
s = pythonService.promptTranslate(prompt); s = pythonService.promptTranslate(prompt);
}else { } else {
s = "Snow moutain, snowy day, natural light"; s = "Snow moutain, snowy day, natural light";
} }
Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums()); Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums());
@@ -2188,18 +2033,18 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
// 走模型 // 走模型
pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
}else { } else {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型 // 走模型
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
@@ -2233,14 +2078,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
// 走模型 // 走模型
pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
} }
return batchTaskId; return batchTaskId;
@@ -2309,12 +2154,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
poseTransformationMapper.insert(poseTransformation); poseTransformationMapper.insert(poseTransformation);
Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId); Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId);
if (b){ if (b) {
// 6、添加预扣除积分到redis // 6、添加预扣除积分到redis
creditsService.addRecordToCreditsDeduction(accountId, taskBatchId, creditsEventsEnum, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(accountId, taskBatchId, creditsEventsEnum, cloudTaskDTO.getNums());
// 6.1 添加积分扣除记录到db // 6.1 添加积分扣除记录到db
creditsService.preInsert(accountId, creditsEventsEnum.getName(), taskBatchId, Boolean.TRUE, null, cloudTaskDTO.getNums()); creditsService.preInsert(accountId, creditsEventsEnum.getName(), taskBatchId, Boolean.TRUE, null, cloudTaskDTO.getNums());
}else { } else {
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode()); throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
} }
} }
@@ -2366,7 +2211,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) { if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId())); designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId())); designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId()));
}else { } else {
DesignCollectionElementDTO dto = new DesignCollectionElementDTO(); DesignCollectionElementDTO dto = new DesignCollectionElementDTO();
dto.setId(collectionElement.getId()); dto.setId(collectionElement.getId());
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
@@ -2374,7 +2219,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
} }
designCollectionDTO.setMoodBoards(moodBoards); designCollectionDTO.setMoodBoards(moodBoards);
}else { } else {
designCollectionDTO.setMoodBoards(new ArrayList<>()); designCollectionDTO.setMoodBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) {
@@ -2387,7 +2232,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
printBoards.add(dto); printBoards.add(dto);
} }
designCollectionDTO.setPrintBoards(printBoards); designCollectionDTO.setPrintBoards(printBoards);
}else { } else {
designCollectionDTO.setPrintBoards(new ArrayList<>()); designCollectionDTO.setPrintBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) {
@@ -2409,7 +2254,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
colorBoards.add(dto); colorBoards.add(dto);
} }
designCollectionDTO.setColorBoards(colorBoards); designCollectionDTO.setColorBoards(colorBoards);
}else { } else {
designCollectionDTO.setColorBoards(new ArrayList<>()); designCollectionDTO.setColorBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) {
@@ -2424,7 +2269,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
sketchBoards.add(dto); sketchBoards.add(dto);
} }
designCollectionDTO.setSketchBoards(sketchBoards); designCollectionDTO.setSketchBoards(sketchBoards);
}else { } else {
designCollectionDTO.setSketchBoards(new ArrayList<>()); designCollectionDTO.setSketchBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Models"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Models"))) {
@@ -2442,10 +2287,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
} }
}else { } else {
designCollectionDTO.setMannequins(new ArrayList<>()); designCollectionDTO.setMannequins(new ArrayList<>());
} }
}else { } else {
designCollectionDTO.setMoodBoards(new ArrayList<>()); designCollectionDTO.setMoodBoards(new ArrayList<>());
designCollectionDTO.setPrintBoards(new ArrayList<>()); designCollectionDTO.setPrintBoards(new ArrayList<>());
designCollectionDTO.setColorBoards(new ArrayList<>()); designCollectionDTO.setColorBoards(new ArrayList<>());
@@ -2465,7 +2310,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
if (workspace.getPosition().equals("Overall")) { if (workspace.getPosition().equals("Overall")) {
designCollectionDTO.setSingleOverall("overall"); designCollectionDTO.setSingleOverall("overall");
}else { } else {
designCollectionDTO.setSingleOverall("single"); designCollectionDTO.setSingleOverall("single");
designCollectionDTO.setSwitchCategory(workspace.getPosition()); designCollectionDTO.setSwitchCategory(workspace.getPosition());
} }
@@ -2479,7 +2324,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Long collectionId; Long collectionId;
if (null == collectionIdParam) { if (null == collectionIdParam) {
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition()); collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
}else { } else {
collectionId = collectionIdParam; collectionId = collectionIdParam;
} }
List<Long> elementIds = getElementId(elementVO); List<Long> elementIds = getElementId(elementVO);
@@ -2526,7 +2371,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
log.info("design python端运行时间" + totalTimeInSeconds + ""); log.info("design python端运行时间" + totalTimeInSeconds + "");
//生成library //生成library
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String ageGroup = getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId); String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId);
generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup); generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup);
//处理关联关系,修复element覆盖得情况 //处理关联关系,修复element覆盖得情况
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId); // List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
@@ -2577,7 +2422,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
cloudTaskMapper.updateById(cloudTask); cloudTaskMapper.updateById(cloudTask);
} }
} }
}else { } else {
String taskId = (String) designBatchResult.get("task_id"); String taskId = (String) designBatchResult.get("task_id");
// QueryWrapper<CloudTask> qw = new QueryWrapper<>(); // QueryWrapper<CloudTask> qw = new QueryWrapper<>();
// qw.lambda().eq(CloudTask::getTaskId, taskId); // qw.lambda().eq(CloudTask::getTaskId, taskId);
@@ -2609,7 +2454,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String timeZone = (String) context.get("timeZone"); String timeZone = (String) context.get("timeZone");
String singleOverall = (String) context.get("singleOverall"); String singleOverall = (String) context.get("singleOverall");
DesignPythonObject item = pythonObjects.getObjects().get(i-1); DesignPythonObject item = pythonObjects.getObjects().get(i - 1);
DesignItem designItem = new DesignItem(); DesignItem designItem = new DesignItem();
designItem.setAccountId(userInfo.getId()); designItem.setAccountId(userInfo.getId());
designItem.setCollectionId(collectionId); designItem.setCollectionId(collectionId);
@@ -2686,7 +2531,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
@@ -2696,7 +2541,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -2757,7 +2602,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class); CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class);
if (cloudTaskVO.getCompletedNum() == null) { if (cloudTaskVO.getCompletedNum() == null) {
cloudTaskVO.setProcess("0%"); cloudTaskVO.setProcess("0%");
}else { } else {
BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum()); BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum());
BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums()); BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums());
@@ -2813,7 +2658,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// }); // });
// result.setDesign(PageBaseResponse.success(convert)); // result.setDesign(PageBaseResponse.success(convert));
return result; return result;
}else { } else {
result.setDesign(new ArrayList<>()); result.setDesign(new ArrayList<>());
return result; return result;
} }
@@ -2838,7 +2683,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { } else {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
} }
@@ -2864,7 +2709,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { } else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId()); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
} }
@@ -2885,13 +2730,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
poseTransformationVO.setStatus("Success"); poseTransformationVO.setStatus("Success");
poseTransformationVO.setTaskId(poseTransformation.getUniqueId()); poseTransformationVO.setTaskId(poseTransformation.getUniqueId());
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
if (null != poseTransformation.getGifUrl()){ if (null != poseTransformation.getGifUrl()) {
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (null != poseTransformation.getVideoUrl()){ if (null != poseTransformation.getVideoUrl()) {
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (null != poseTransformation.getFirstFrameUrl()){ if (null != poseTransformation.getFirstFrameUrl()) {
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
voList.add(poseTransformationVO); voList.add(poseTransformationVO);
@@ -2902,9 +2747,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return result; return result;
} }
@Resource
private PanToneMapper panToneMapper;
@Override @Override
public Boolean receiveDesignParams(ReceiveDesignParam receiveDesignParam) { public Boolean receiveDesignParams(ReceiveDesignParam receiveDesignParam) {
List<ReceiveCollectionElement> receiveCollectionElementList = receiveDesignParam.getReceiveCollectionElementList(); List<ReceiveCollectionElement> receiveCollectionElementList = receiveDesignParam.getReceiveCollectionElementList();
@@ -2928,7 +2770,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setUrl(url); collectionElement.setUrl(url);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName())) {
String url = receiveCollectionElement.getUrl(); String url = receiveCollectionElement.getUrl();
String[] split = url.split("/"); String[] split = url.split("/");
String pictureName = split[split.length - 1]; String pictureName = split[split.length - 1];
@@ -2940,7 +2782,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setUrl(url); collectionElement.setUrl(url);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
String url = receiveCollectionElement.getUrl(); String url = receiveCollectionElement.getUrl();
String[] split = url.split("/"); String[] split = url.split("/");
String pictureName = split[split.length - 1]; String pictureName = split[split.length - 1];
@@ -2955,7 +2797,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
libraryService.processSketchBoards(url, collectionElement.getLevel2Type()); libraryService.processSketchBoards(url, collectionElement.getLevel2Type());
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName())) {
/*String color = receiveCollectionElement.getHsv(); /*String color = receiveCollectionElement.getHsv();
String[] parts = color.split("\\s+"); String[] parts = color.split("\\s+");
int h = Math.round(Float.parseFloat(parts[0])); int h = Math.round(Float.parseFloat(parts[0]));

File diff suppressed because it is too large Load Diff

View File

@@ -17,21 +17,20 @@ import com.ai.da.model.enums.Sex;
import com.ai.da.model.vo.LibraryModelPointVO; import com.ai.da.model.vo.LibraryModelPointVO;
import com.ai.da.python.PythonService; import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonObjects; import com.ai.da.python.vo.DesignPythonObjects;
import com.ai.da.service.DesignService;
import com.ai.da.service.LibraryModelPointService; import com.ai.da.service.LibraryModelPointService;
import com.ai.da.service.LibraryService; import com.ai.da.service.LibraryService;
import com.ai.da.service.PythonTAllInfoService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -45,17 +44,13 @@ import java.util.Objects;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointMapper, LibraryModelPoint> implements LibraryModelPointService { public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointMapper, LibraryModelPoint> implements LibraryModelPointService {
@Resource private final LibraryModelPointMapper libraryModelPointMapper;
private LibraryModelPointMapper libraryModelPointMapper; private final LibraryService libraryService;
@Resource private final MinioUtil minioUtil;
private LibraryService libraryService; private final PythonService pythonService;
@Resource private final PythonTAllInfoService pythonTAllInfoService;
private PythonService pythonService;
@Resource
private DesignService designService;
@Autowired
private MinioUtil minioUtil;
@Override @Override
public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) { public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) {
@@ -63,7 +58,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
// 不管是保存还是另存为都需要传模特的libraryId // 不管是保存还是另存为都需要传模特的libraryId
Library libModel = libraryService.getById(libraryModelPointDTO.getLibraryId()); Library libModel = libraryService.getById(libraryModelPointDTO.getLibraryId());
if (Objects.isNull(libModel)){ if (Objects.isNull(libModel)) {
throw new BusinessException("model.not.found"); throw new BusinessException("model.not.found");
} }
@@ -72,9 +67,9 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
// 标志是否有更改过模特比例(即更换模特图) // 标志是否有更改过模特比例(即更换模特图)
boolean flag = !url.equals(libModel.getUrl()); boolean flag = !url.equals(libModel.getUrl());
if (libraryModelPointDTO.getIsCovered()){ if (libraryModelPointDTO.getIsCovered()) {
// 更新模特图片 // 更新模特图片
if (flag){ if (flag) {
libModel.setUrl(url); libModel.setUrl(url);
libModel.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false)); libModel.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false));
List<Integer> imagesWidthAndHeight = minioUtil.getImagesWidthAndHeight(url); List<Integer> imagesWidthAndHeight = minioUtil.getImagesWidthAndHeight(url);
@@ -84,7 +79,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
libraryService.updateById(libModel); libraryService.updateById(libModel);
} }
if (Objects.nonNull(libraryModelPointDTO.getTemplateId())){ if (Objects.nonNull(libraryModelPointDTO.getTemplateId())) {
// 覆盖保存,即更新原有数据(点位数据和模特图片) // 覆盖保存,即更新原有数据(点位数据和模特图片)
LibraryModelPoint modelPoint = getById(libraryModelPointDTO.getTemplateId()); LibraryModelPoint modelPoint = getById(libraryModelPointDTO.getTemplateId());
if (Objects.isNull(modelPoint)) { if (Objects.isNull(modelPoint)) {
@@ -97,7 +92,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
updateById(modelPoint); updateById(modelPoint);
libraryModelPointVO.setTemplateId(modelPoint.getId()); libraryModelPointVO.setTemplateId(modelPoint.getId());
libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId()); libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId());
}else { } else {
// 新增模特点位信息 // 新增模特点位信息
LibraryModelPoint libraryModelPoint = resolvePoint(libraryModelPointDTO); LibraryModelPoint libraryModelPoint = resolvePoint(libraryModelPointDTO);
libraryModelPoint.setModelType("Library"); libraryModelPoint.setModelType("Library");
@@ -107,7 +102,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId()); libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId());
} }
}else { } else {
// 不覆盖,即另存为 // 不覆盖,即另存为
// 新增模特library信息 // 新增模特library信息
Library saveAsModel = new Library(); Library saveAsModel = new Library();
@@ -169,7 +164,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
if (!byId.getLevel2Type().equals(libraryModelPointDTO.getModelSex())) { if (!byId.getLevel2Type().equals(libraryModelPointDTO.getModelSex())) {
if (byId.getLevel2Type().equals(Sex.FEMALE.getValue())) { if (byId.getLevel2Type().equals(Sex.FEMALE.getValue())) {
libraryService.checkModel(Sex.FEMALE.getValue(), Collections.singletonList(byId.getId()), 1); libraryService.checkModel(Sex.FEMALE.getValue(), Collections.singletonList(byId.getId()), 1);
}else { } else {
libraryService.checkModel(Sex.MALE.getValue(), Collections.singletonList(byId.getId()), 1); libraryService.checkModel(Sex.MALE.getValue(), Collections.singletonList(byId.getId()), 1);
} }
byId.setLevel2Type(libraryModelPointDTO.getModelSex()); byId.setLevel2Type(libraryModelPointDTO.getModelSex());
@@ -226,7 +221,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
public String modelsDot(ModelsDotDTO modelsDotDTO) { public String modelsDot(ModelsDotDTO modelsDotDTO) {
DesignPythonObjects objects = pythonService.covertModelsDotParam( DesignPythonObjects objects = pythonService.covertModelsDotParam(
modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(), ""); modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(), "");
designService.relationImageId(objects); pythonTAllInfoService.relationImageId(objects);
JSONObject jsonObject = pythonService.designNew(objects); JSONObject jsonObject = pythonService.designNew(objects);
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data == null) { if (data == null) {

View File

@@ -8,20 +8,15 @@ import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.MinioUtil; import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.RedisUtil; import com.ai.da.common.utils.RedisUtil;
import com.ai.da.common.websocket.NotificationConnection; import com.ai.da.common.websocket.NotificationConnection;
import com.ai.da.mapper.primary.CanvasMapper; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.NotificationMapper; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.mapper.primary.SysNotificationReadStatusMapper;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.mapper.primary.entity.Notification;
import com.ai.da.mapper.primary.entity.Portfolio;
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
import com.ai.da.model.dto.GetNotificationDTO; import com.ai.da.model.dto.GetNotificationDTO;
import com.ai.da.model.dto.PublishSysNotificationDTO; import com.ai.da.model.dto.PublishSysNotificationDTO;
import com.ai.da.model.enums.Language; import com.ai.da.model.enums.Language;
import com.ai.da.model.vo.NotificationVO; import com.ai.da.model.vo.NotificationVO;
import com.ai.da.service.AccountService; import com.ai.da.service.AccountService;
import com.ai.da.service.MessageCenterService; import com.ai.da.service.MessageCenterService;
import com.ai.da.service.PortfolioService; import com.ai.da.service.UserFollowService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -31,12 +26,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.mysql.cj.util.StringUtils; import com.mysql.cj.util.StringUtils;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -45,22 +39,18 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor
public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements MessageCenterService { public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements MessageCenterService {
@Resource private final AccountService accountService;
private NotificationConnection notificationConnection; private final CanvasMapper canvasMapper;
@Resource private final MinioUtil minioUtil;
private SysNotificationReadStatusMapper sysNotificationReadStatusMapper; private final NotificationConnection notificationConnection;
@Resource private final PortfolioMapper portfolioMapper;
private AccountService accountService; private final RedisUtil redisUtil;
@Resource private final SysNotificationReadStatusMapper sysNotificationReadStatusMapper;
private MinioUtil minioUtil; private final UserFollowService userFollowService;
@Resource
private PortfolioService portfolioService;
@Resource
private CanvasMapper canvasMapper;
@Resource
private RedisUtil redisUtil;
@Value("${redis.key.newPosted}") @Value("${redis.key.newPosted}")
private String lastViewNewPostedTimeKey; private String lastViewNewPostedTimeKey;
@@ -84,12 +74,12 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
@Override @Override
public PageBaseResponse<NotificationVO> getHistoryNotification(GetNotificationDTO getNotificationDTO) { public PageBaseResponse<NotificationVO> getHistoryNotification(GetNotificationDTO getNotificationDTO) {
log.info("获取历史消息parameter => {}", getNotificationDTO); log.info("获取历史消息parameter => {}", getNotificationDTO);
if (StringUtil.isNullOrEmpty(getNotificationDTO.getType())){ if (StringUtil.isNullOrEmpty(getNotificationDTO.getType())) {
throw new BusinessException("type.cannot.be.empty"); throw new BusinessException("type.cannot.be.empty");
} }
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
// 查动态 // 查动态
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")){ if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")) {
return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize()); return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize());
} }
@@ -99,7 +89,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
queryWrapper.eq("type", getNotificationDTO.getType()); queryWrapper.eq("type", getNotificationDTO.getType());
} }
if (getNotificationDTO.getType().equals("system")){ if (getNotificationDTO.getType().equals("system")) {
queryWrapper.lambda().eq(Notification::getType, "system") queryWrapper.lambda().eq(Notification::getType, "system")
.and(wrapper -> wrapper .and(wrapper -> wrapper
.isNull(Notification::getReceiverId) .isNull(Notification::getReceiverId)
@@ -116,35 +106,35 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
IPage<NotificationVO> convert = notificationPage.convert(o -> { IPage<NotificationVO> convert = notificationPage.convert(o -> {
NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class); NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class);
Account senderAccount = accountService.getById(notificationVO.getSenderId()); Account senderAccount = accountService.getById(notificationVO.getSenderId());
if (Objects.nonNull(senderAccount)){ if (Objects.nonNull(senderAccount)) {
notificationVO.setUserName(senderAccount.getUserName()); notificationVO.setUserName(senderAccount.getUserName());
}else { } else {
notificationVO.setUserName("--"); notificationVO.setUserName("--");
} }
// notificationVO.setSenderUserAvatar(StringUtils.isNullOrEmpty(senderAccount.getAvatar()) ? null : minioUtil.getPreSignedUrl(senderAccount.getAvatar(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); // notificationVO.setSenderUserAvatar(StringUtils.isNullOrEmpty(senderAccount.getAvatar()) ? null : minioUtil.getPreSignedUrl(senderAccount.getAvatar(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
if (Objects.isNull(notificationVO.getPortfolioId())){ if (Objects.isNull(notificationVO.getPortfolioId())) {
notificationVO.setPortfolioId(null); notificationVO.setPortfolioId(null);
}else { } else {
Portfolio byId = portfolioService.getById(notificationVO.getPortfolioId()); Portfolio byId = portfolioMapper.selectById(notificationVO.getPortfolioId());
if (!Objects.isNull(byId)){ if (!Objects.isNull(byId)) {
if (Objects.isNull(byId.getPortfolioName())){ if (Objects.isNull(byId.getPortfolioName())) {
notificationVO.setPortfolioName(null); notificationVO.setPortfolioName(null);
}else { } else {
notificationVO.setPortfolioName(byId.getPortfolioName()); notificationVO.setPortfolioName(byId.getPortfolioName());
} }
}else { } else {
String name = UserContext.getUserHolder().getLanguage().equals("ENGLISH") ? CommonConstant.PORTFOLIO_DELETED_EN : CommonConstant.PORTFOLIO_DELETED_CN; String name = UserContext.getUserHolder().getLanguage().equals("ENGLISH") ? CommonConstant.PORTFOLIO_DELETED_EN : CommonConstant.PORTFOLIO_DELETED_CN;
notificationVO.setPortfolioName(name); notificationVO.setPortfolioName(name);
} }
} }
// 设置单个人 系统消息是否已读 // 设置单个人 系统消息是否已读
if (notificationVO.getType().equals("system")){ if (notificationVO.getType().equals("system")) {
if (unreadSysNotificationIds.contains(notificationVO.getId())){ if (unreadSysNotificationIds.contains(notificationVO.getId())) {
notificationVO.setIsRead(0); notificationVO.setIsRead(0);
}else { } else {
notificationVO.setIsRead(1); notificationVO.setIsRead(1);
} }
}else { } else {
String avatar = Objects.isNull(senderAccount) || StringUtil.isNullOrEmpty(senderAccount.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : senderAccount.getAvatar(); String avatar = Objects.isNull(senderAccount) || StringUtil.isNullOrEmpty(senderAccount.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : senderAccount.getAvatar();
notificationVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); notificationVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
@@ -153,9 +143,9 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return PageBaseResponse.success(convert); return PageBaseResponse.success(convert);
} }
public void prePushMessage(Notification notification){ public void prePushMessage(Notification notification) {
// 先判断点赞、关注记录是不是唯一 // 先判断点赞、关注记录是不是唯一
if (!getUniqueLikeAndFollow(notification)){ if (!getUniqueLikeAndFollow(notification)) {
// 1、将数据存数据库 // 1、将数据存数据库
if (!notification.getType().equals("system")) { if (!notification.getType().equals("system")) {
notification.setIsRead(0); notification.setIsRead(0);
@@ -171,18 +161,19 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
/** /**
* 只记录唯一点赞和关注 * 只记录唯一点赞和关注
* 重复点赞、关注只会记录最新的一次操作 * 重复点赞、关注只会记录最新的一次操作
*
* @param notification * @param notification
* @return * @return
*/ */
public Boolean getUniqueLikeAndFollow(Notification notification){ public Boolean getUniqueLikeAndFollow(Notification notification) {
Notification existNotification= null; Notification existNotification = null;
// 对单个作品的点赞和对某个人的关注 具有唯一性 // 对单个作品的点赞和对某个人的关注 具有唯一性
if (notification.getType().equals("like") || notification.getType().equals("follow")){ if (notification.getType().equals("like") || notification.getType().equals("follow")) {
existNotification = baseMapper.getUniqueLikeAndFollow(notification.getType(), notification.getSenderId(), existNotification = baseMapper.getUniqueLikeAndFollow(notification.getType(), notification.getSenderId(),
notification.getReceiverId(), notification.getPortfolioId()); notification.getReceiverId(), notification.getPortfolioId());
} }
if (!Objects.isNull(existNotification)){ if (!Objects.isNull(existNotification)) {
// 有记录,则更新 1、删除状态 为0 2、已读状态 为0 3、创建时间 为最新时间 4、更新时间 为最新时间 // 有记录,则更新 1、删除状态 为0 2、已读状态 为0 3、创建时间 为最新时间 4、更新时间 为最新时间
baseMapper.updateUniqueLikeAndFollow(existNotification.getId(), LocalDateTime.now()); baseMapper.updateUniqueLikeAndFollow(existNotification.getId(), LocalDateTime.now());
return Boolean.TRUE; return Boolean.TRUE;
@@ -204,11 +195,11 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
// 系统未读消息 // 系统未读消息
count = getUnreadSystemNotification(); count = getUnreadSystemNotification();
} }
if (type.equals("follow")){ if (type.equals("follow")) {
HashMap<String, Object> followee = new HashMap<>(); HashMap<String, Object> followee = new HashMap<>();
HashMap<String, Object> follower = new HashMap<>(); HashMap<String, Object> follower = new HashMap<>();
follower.put("followerCount",portfolioService.getFollowerCount(receiverId)); follower.put("followerCount", userFollowService.getFollowerCount(receiverId));
followee.put("followeeCount",portfolioService.getFolloweeCount(receiverId)); followee.put("followeeCount", userFollowService.getFolloweeCount(receiverId));
resp.add(followee); resp.add(followee);
resp.add(follower); resp.add(follower);
} }
@@ -229,7 +220,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
.eq("receiver_id", receiverId) .eq("receiver_id", receiverId)
.eq("is_deleted", 0); .eq("is_deleted", 0);
if (!type.equals("follow")){ if (!type.equals("follow")) {
queryWrapper.eq("portfolio_id", portfolioId); queryWrapper.eq("portfolio_id", portfolioId);
} }
if (type.equals("comment")) { if (type.equals("comment")) {
@@ -296,13 +287,13 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
} }
// 一键已读 // 一键已读
public void setReadAll(String type){ public void setReadAll(String type) {
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
// 指定某个用户的某种类型的数据,将未读数据全部已读 // 指定某个用户的某种类型的数据,将未读数据全部已读
if (!type.equals("system")){ if (!type.equals("system")) {
// 个人消息已读 // 个人消息已读
baseMapper.setPersonalNotificationAllRead(type, accountId, LocalDateTime.now()); baseMapper.setPersonalNotificationAllRead(type, accountId, LocalDateTime.now());
}else { } else {
// 系统消息已读 // 系统消息已读
// 1、先确定当前用户未读的系统消息有哪些 // 1、先确定当前用户未读的系统消息有哪些
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId); List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
@@ -322,44 +313,44 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
prePushMessage(notification); prePushMessage(notification);
} }
public Long getNewPostedCount(Long accountId){ public Long getNewPostedCount(Long accountId) {
// 1.1 获取我关注的所有用户 // 1.1 获取我关注的所有用户
List<Long> followeeList = portfolioService.getFolloweeList(accountId); List<Long> followeeList = userFollowService.getFolloweeList(accountId);
// 1.2 查询我关注的用户在我上次查看动态之后发布的作品数量 // 1.2 查询我关注的用户在我上次查看动态之后发布的作品数量
String lastViewTime = redisUtil.getFromString(lastViewNewPostedTimeKey + ":" + accountId); String lastViewTime = redisUtil.getFromString(lastViewNewPostedTimeKey + ":" + accountId);
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
if (!followeeList.isEmpty()){ if (!followeeList.isEmpty()) {
queryWrapper.in("account_id", followeeList); queryWrapper.in("account_id", followeeList);
}else { } else {
return 0L; return 0L;
} }
if (!StringUtil.isNullOrEmpty(lastViewTime)){ if (!StringUtil.isNullOrEmpty(lastViewTime)) {
queryWrapper.gt("create_date", lastViewTime); queryWrapper.gt("create_date", lastViewTime);
}else { } else {
return 0L; return 0L;
} }
return portfolioService.getBaseMapper().selectCount(queryWrapper); return portfolioMapper.selectCount(queryWrapper);
} }
/** /**
* 获取关注用户发布的新作品 分页查询 * 获取关注用户发布的新作品 分页查询
*/ */
public PageBaseResponse<NotificationVO> getNewPosted(Long accountId, Integer page, Integer size){ public PageBaseResponse<NotificationVO> getNewPosted(Long accountId, Integer page, Integer size) {
// 1、获取关注用户发布的所有作品 // 1、获取关注用户发布的所有作品
// 1.1 获取我关注的所有用户 // 1.1 获取我关注的所有用户
List<Long> followeeList = portfolioService.getFolloweeList(accountId); List<Long> followeeList = userFollowService.getFolloweeList(accountId);
// 1.2 分页查询我关注的用户发布的作品 // 1.2 分页查询我关注的用户发布的作品
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
if (!followeeList.isEmpty()){ if (!followeeList.isEmpty()) {
queryWrapper.in("account_id", followeeList); queryWrapper.in("account_id", followeeList);
}else { } else {
return new PageBaseResponse<>(new ArrayList<>(), page, size, 0, 0); return new PageBaseResponse<>(new ArrayList<>(), page, size, 0, 0);
} }
queryWrapper.orderByDesc("create_date"); queryWrapper.orderByDesc("create_date");
Page<Portfolio> portfolioPage = portfolioService.getBaseMapper().selectPage(new Page<>(page, size), queryWrapper); Page<Portfolio> portfolioPage = portfolioMapper.selectPage(new Page<>(page, size), queryWrapper);
// 2、组装返回的数据 // 2、组装返回的数据
IPage<NotificationVO> convert = portfolioPage.convert(o -> { IPage<NotificationVO> convert = portfolioPage.convert(o -> {
@@ -404,7 +395,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
if (language.equals(Language.ENGLISH.name())) { if (language.equals(Language.ENGLISH.name())) {
notification.setContent("Your video generation task in Project " + projectName + " has failed."); notification.setContent("Your video generation task in Project " + projectName + " has failed.");
} else { } else {
notification.setContent("视频生成任务失败。"); notification.setContent("视频生成任务失败。");
} }
} }

View File

@@ -0,0 +1,90 @@
package com.ai.da.service.impl;
import com.ai.da.mapper.primary.MoodboardPositionMapper;
import com.ai.da.mapper.primary.entity.MoodboardPosition;
import com.ai.da.service.MoodboardPositionService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class MoodboardPositionServiceImpl extends ServiceImpl<MoodboardPositionMapper, MoodboardPosition> implements MoodboardPositionService {
@Override
public void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam) {
if (!StringUtils.isEmpty(moodboardPosition)) {
// 将 JSON 字符串解析为 JSONObject
JSONObject moodboardPositionJson = JSONObject.parseObject(moodboardPosition);
// 准备保存的 MoodboardPosition 列表
List<MoodboardPosition> moodboardPositions = new ArrayList<>();
// 遍历 JSON 对象的 key即样式类型
for (String key : moodboardPositionJson.keySet()) {
// 特殊处理 "class" 字段
if ("class".equals(key)) {
// 获取 "class" 字段的值并将其转为 List<String>
JSONArray classArray = moodboardPositionJson.getJSONArray(key);
if (classArray != null) {
for (int j = 0; j < classArray.size(); j++) {
// 将 classList 存入 MoodboardPosition或者其他结构
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(classArray.getString(j)) // 设置 class 字段
.setSequence(j) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
continue; // 跳过 "class" 字段的常规处理
}
JSONArray styleArray = moodboardPositionJson.getJSONArray(key);
if (styleArray != null) {
for (int i = 0; i < styleArray.size(); i++) {
// 获取当前样式数据
JSONObject styleData = styleArray.getJSONObject(i);
// 构建 MoodboardPosition 实例
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(styleData.toJSONString()) // 样式数据存为 JSON 字符串
.setSequence(i) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
}
// 如果解析结果非空,保存到数据库
if (!moodboardPositions.isEmpty()) {
for (MoodboardPosition position : moodboardPositions) {
baseMapper.insert(position);
}
log.info("成功解析并保存 {} 条 MoodboardPosition 数据", moodboardPositions.size());
} else {
log.warn("未找到可保存的 MoodboardPosition 数据");
}
} else {
log.warn("传入的 moodboardPosition 字段为空");
}
}
}

View File

@@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function; import com.google.common.base.Function;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -45,107 +46,41 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService { public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
@Resource private final AccountMapper accountMapper;
private UserLikeGroupMapper userLikeGroupMapper; private final CanvasMapper canvasMapper;
private final CollectionMapper collectionMapper;
@Resource private final CollectionElementMapper collectionElementMapper;
private CollectionMapper collectionMapper; private final CollectionElementService collectionElementService;
private final CollectionSortMapper collectionSortMapper;
@Resource private final CollectionSortService collectionSortService;
private CollectionElementService collectionElementService; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
private final TCollectionElementRelationMapper collectionElementRelationMapper;
@Resource private final DesignMapper designMapper;
private CollectionElementMapper collectionElementMapper; private final DesignItemMapper designItemMapper;
@Resource private final DesignItemDetailMapper designItemDetailMapper;
private CollectionSortService collectionSortService; private final DesignItemDetailPrintMapper designItemDetailPrintMapper;
@Resource private final TDesignPythonOutfitMapper designPythonOutfitMapper;
private CollectionSortMapper collectionSortMapper; private final TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
@Resource private final MinioUtil minioUtil;
private TCollectionElementRelationMapper collectionElementRelationMapper; private final ProjectMapper projectMapper;
private final PortfolioMapper portfolioMapper;
@Resource private final PortfolioTagsMapper portfolioTagsMapper;
private PortfolioMapper portfolioMapper; private final PoseTransformationMapper poseTransformationMapper;
private final TagsMapper tagsMapper;
@Resource private final TagsService tagsService;
private UserLikeService userLikeService; private final ToProductImageResultMapper toProductImageResultMapper;
private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final UserFollowMapper userFollowMapper;
private UserLikeMapper userLikeMapper; private final UserFollowService userFollowService;
private final UserLikeService userLikeService;
@Resource private final UserLikeMapper userLikeMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final UserLikeGroupMapper userLikeGroupMapper;
private final UserLikeGroupService userLikeGroupService;
@Resource private final WorkspaceMapper workspaceMapper;
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper; private final WorkspaceService workspaceService;
@Resource
private DesignItemMapper designItemMapper;
@Resource
private DesignItemDetailMapper designItemDetailMapper;
@Resource
private DesignItemDetailPrintMapper designItemDetailPrintMapper;
@Resource
private MinioUtil minioUtil;
@Resource
private WorkspaceService workspaceService;
@Resource
private DesignMapper designMapper;
@Resource
private UserLikeGroupService userLikeGroupService;
@Resource
private CanvasMapper canvasMapper;
@Resource
private AccountMapper accountMapper;
@Resource
private WorkspaceMapper workspaceMapper;
@Resource
private SysFileMapper sysFileMapper;
@Resource
private LibraryMapper libraryMapper;
@Resource
private StyleMapper styleMapper;
@Resource
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
@Resource
private UserFollowMapper userFollowMapper;
@Resource
private PortfolioTagsMapper portfolioTagsMapper;
@Resource
private TagsService tagsService;
@Resource
private TagsMapper tagsMapper;
@Resource
private ProjectMapper projectMapper;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -585,7 +520,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
vo.setIsLike(0); vo.setIsLike(0);
} }
// 设置当前用户是否关注了所查看作品的作者 // 设置当前用户是否关注了所查看作品的作者
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId()); Integer ifFollowed = userFollowService.getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId());
vo.setIsFollow(ifFollowed); vo.setIsFollow(ifFollowed);
avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar(); avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar();
} }
@@ -1157,7 +1092,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)) { if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)) {
return false; return false;
} else { } else {
UserLikeGroup userLikeGroup = userLikeGroupService.getById(userLikeGroupId); UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(userLikeGroupId);
// 不是原创的作品不能参与活动 // 不是原创的作品不能参与活动
if (userLikeGroup.getOriginal().equals(0)) { if (userLikeGroup.getOriginal().equals(0)) {
throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode()); throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode());
@@ -1276,86 +1211,6 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
messageCenterService.pushMessage("follow", followeeId); messageCenterService.pushMessage("follow", followeeId);
} }
public Long getFolloweeCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("follower_id", accountId).select("followee_id");
return userFollowMapper.selectCount(queryWrapper);
}
// 获取某个用户的关注列表 + 按名字查询
public List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 1、判断是否有按用户名查询
List<AccountFollowVO> followeeList;
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followeeList = userFollowMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followeeList = userFollowMapper.getFolloweeListByFollower(accountId, limit, offset, order);
}
if (!followeeList.isEmpty()) {
followeeList.forEach(followee -> {
String avatar = StringUtil.isNullOrEmpty(followee.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : followee.getAvatar();
followee.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
});
return followeeList;
}
return new ArrayList<>();
}
public Long getFollowerCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", accountId).select("follower_id");
return userFollowMapper.selectCount(queryWrapper);
}
// 获取某个用户的粉丝列表 + 按名字查询 需返回是否关注该粉丝
public List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 获取当前用户的所有粉丝
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id", "create_time");
List<UserFollow> userFollows = userFollowMapper.selectList(qw);
Map<Long, LocalDateTime> followeeMap = userFollows.stream().collect(Collectors.toMap(UserFollow::getFolloweeId, UserFollow::getCreateTime));
List<AccountFollowVO> followerList;
// 1、判断是否有按用户名查询粉丝
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followerList = userFollowMapper.getFollowerListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followerList = userFollowMapper.getFollowerListByFollowee(accountId, limit, offset, order);
}
if (!followerList.isEmpty()) {
// 判断当前用户是否与粉丝互关
followerList.forEach(follower -> {
String avatar = StringUtil.isNullOrEmpty(follower.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : follower.getAvatar();
follower.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
follower.setIsFollow(Objects.isNull(followeeMap.get(follower.getSenderId())) ? 0 : 1);
// follower.setFollowTime(followeeMap.get(follower.getUserId()));
});
return followerList;
}
return new ArrayList<>();
}
public Integer getIfFollowed(Long followeeId, Long followerId) {
// 设置当前用户是否关注了所查看作品的作者
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", followeeId).eq("follower_id", followerId);
UserFollow userFollow = userFollowMapper.selectOne(queryWrapper);
return Objects.isNull(userFollow) ? 0 : 1;
}
public Long getPortfolioCount(Long accountId) { public Long getPortfolioCount(Long accountId) {
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", accountId); queryWrapper.eq("account_id", accountId);
@@ -1363,19 +1218,6 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
/**
* 获取关注列表
*
* @param accountId
* @return
*/
public List<Long> getFolloweeList(Long accountId) {
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id");
List<UserFollow> userFollows = userFollowMapper.selectList(qw);
return userFollows.stream().map(UserFollow::getFolloweeId).collect(Collectors.toList());
}
public void setPortfolioToPublic(Long portfolioId) { public void setPortfolioToPublic(Long portfolioId) {
// 判断当前用户与作品用户是不是一家公司的 // 判断当前用户与作品用户是不是一家公司的

View File

@@ -4,6 +4,8 @@ package com.ai.da.service.impl;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.mapper.primary.PythonTAllInfoMapper; import com.ai.da.mapper.primary.PythonTAllInfoMapper;
import com.ai.da.mapper.primary.entity.PythonTAllInfo; import com.ai.da.mapper.primary.entity.PythonTAllInfo;
import com.ai.da.python.vo.DesignPythonItem;
import com.ai.da.python.vo.DesignPythonObjects;
import com.ai.da.service.PythonTAllInfoService; import com.ai.da.service.PythonTAllInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -13,7 +15,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* (PythonTAllInfo)表服务实现类 * (PythonTAllInfo)表服务实现类
@@ -48,4 +52,31 @@ public class PythonTAllInfoServiceImpl extends ServiceImpl<PythonTAllInfoMapper,
} }
return pythonTAllInfo.getId(); return pythonTAllInfo.getId();
} }
@Override
public void relationImageId(DesignPythonObjects pythonObjects) {
if (Objects.isNull(pythonObjects)) {
return;
}
pythonObjects.getObjects().forEach(
o -> {
for (DesignPythonItem item : o.getItems()) {
List<Long> list = new ArrayList<>();
list.add(1L);
list.add(1L);
item.setOffset(list);
item.setResize_scale(new Float[]{1.0f, 1.0f});
String path = item.getPath();
if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path();
Long imageId = getImageIdByPath(bodyPath);
item.setImage_id(imageId);
} else {
Long imageId = getImageIdByPath(path);
item.setImage_id(imageId);
}
}
}
);
}
} }

View File

@@ -0,0 +1,78 @@
package com.ai.da.service.impl;
import com.ai.da.mapper.primary.ToProductImageResultMapper;
import com.ai.da.mapper.primary.entity.CollectionSort;
import com.ai.da.mapper.primary.entity.ToProductImageResult;
import com.ai.da.mapper.primary.entity.UserLike;
import com.ai.da.service.CollectionSortService;
import com.ai.da.service.ToProductImageResultService;
import com.ai.da.service.UserLikeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Slf4j
@Service
@RequiredArgsConstructor
public class ToProductImageResultServiceImpl extends ServiceImpl<ToProductImageResultMapper, ToProductImageResult> implements ToProductImageResultService {
private final CollectionSortService collectionSortService;
private final UserLikeService userLikeService;
// 获取未被like的to product\relight的parentId
public Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url) {
// 卫语句处理null情况
if (toProductImageResult == null && StringUtil.isNullOrEmpty(url)) {
return null;
}
// 如果需要查询结果对象
if (toProductImageResult == null) {
toProductImageResult = baseMapper.selectOne(
new QueryWrapper<ToProductImageResult>().eq("url", url));
}
// 卫语句处理查询结果为空的情况
if (toProductImageResult == null) {
return null;
}
// 根据不同类型处理
String elementType = toProductImageResult.getElementType();
if ("DesignOutfit".equals(elementType)) {
return handleDesignOutfitCase(toProductImageResult);
} else if ("ToProductImage".equals(elementType)) {
// 两种情况 resultType : ToProductImage | Relight
return handleToProductImageCase(toProductImageResult);
}
return null;
}
private Long handleDesignOutfitCase(ToProductImageResult result) {
UserLike userLike = userLikeService.getByDesignOutfitId(result.getElementId());
if (userLike == null) {
return null;
}
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
userLike.getId(), "Design", result.getProjectId());
return collectionSort != null ? collectionSort.getId() : null;
}
private Long handleToProductImageCase(ToProductImageResult result) {
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
result.getElementId(), result.getResultType(), result.getProjectId());
if (Objects.isNull(collectionSort) && result.getElementType().equals("ToProductImage")) {
ToProductImageResult toProductImageResult = baseMapper.selectById(result.getElementId());
return getUnlikedResultParentId(toProductImageResult, null);
}
return collectionSort != null ? collectionSort.getParentId() : null;
}
}

View File

@@ -0,0 +1,125 @@
package com.ai.da.service.impl;
import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.UserFollowMapper;
import com.ai.da.mapper.primary.entity.UserFollow;
import com.ai.da.model.dto.GetFollowListDTO;
import com.ai.da.model.vo.AccountFollowVO;
import com.ai.da.service.UserFollowService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFollow> implements UserFollowService {
private final MinioUtil minioUtil;
public Long getFolloweeCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("follower_id", accountId).select("followee_id");
return baseMapper.selectCount(queryWrapper);
}
// 获取某个用户的关注列表 + 按名字查询
public List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 1、判断是否有按用户名查询
List<AccountFollowVO> followeeList;
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followeeList = baseMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followeeList = baseMapper.getFolloweeListByFollower(accountId, limit, offset, order);
}
if (!followeeList.isEmpty()) {
followeeList.forEach(followee -> {
String avatar = StringUtil.isNullOrEmpty(followee.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : followee.getAvatar();
followee.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
});
return followeeList;
}
return new ArrayList<>();
}
public Long getFollowerCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", accountId).select("follower_id");
return baseMapper.selectCount(queryWrapper);
}
// 获取某个用户的粉丝列表 + 按名字查询 需返回是否关注该粉丝
public List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 获取当前用户的所有粉丝
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id", "create_time");
List<UserFollow> userFollows = baseMapper.selectList(qw);
Map<Long, LocalDateTime> followeeMap = userFollows.stream().collect(Collectors.toMap(UserFollow::getFolloweeId, UserFollow::getCreateTime));
List<AccountFollowVO> followerList;
// 1、判断是否有按用户名查询粉丝
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followerList = baseMapper.getFollowerListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followerList = baseMapper.getFollowerListByFollowee(accountId, limit, offset, order);
}
if (!followerList.isEmpty()) {
// 判断当前用户是否与粉丝互关
followerList.forEach(follower -> {
String avatar = StringUtil.isNullOrEmpty(follower.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : follower.getAvatar();
follower.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
follower.setIsFollow(Objects.isNull(followeeMap.get(follower.getSenderId())) ? 0 : 1);
// follower.setFollowTime(followeeMap.get(follower.getUserId()));
});
return followerList;
}
return new ArrayList<>();
}
public Integer getIfFollowed(Long followeeId, Long followerId) {
// 设置当前用户是否关注了所查看作品的作者
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", followeeId).eq("follower_id", followerId);
UserFollow userFollow = baseMapper.selectOne(queryWrapper);
return Objects.isNull(userFollow) ? 0 : 1;
}
/**
* 获取关注列表
*
* @param accountId
* @return
*/
public List<Long> getFolloweeList(Long accountId) {
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id");
List<UserFollow> userFollows = baseMapper.selectList(qw);
return userFollows.stream().map(UserFollow::getFolloweeId).collect(Collectors.toList());
}
}

View File

@@ -29,7 +29,9 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Comparator; import java.util.Comparator;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -38,6 +40,7 @@ import com.google.common.base.Function;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.minio.errors.MinioException; import io.minio.errors.MinioException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -66,98 +69,54 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService { public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService {
@Resource private final UserLikeGroupMapper userLikeGroupMapper;
private UserLikeGroupMapper userLikeGroupMapper; private final AccountService accountService;
@Resource private final CollectionService collectionService;
private AccountService accountService; private final UserLikeService userLikeService;
@Resource private final WorkspaceService workspaceService;
private CollectionService collectionService; private final UserLikeMapper userLikeMapper;
@Resource private final MinioUtil minioUtil;
private UserLikeService userLikeService; private final TDesignPythonOutfitMapper designPythonOutfitMapper;
@Resource private final DesignMapper designMapper;
private WorkspaceService workspaceService; private final MoodboardPositionService moodboardPositionService;
@Resource private final SysFileMapper sysFileMapper;
private UserLikeMapper userLikeMapper; private final LibraryMapper libraryMapper;
@Resource private final GenerateDetailMapper generateDetailMapper;
private MinioUtil minioUtil; private final PortfolioMapper portfolioMapper;
@Resource private final TagsMapper tagsMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final DesignItemDetailService designItemDetailService;
@Resource private final CollectionElementMapper collectionElementMapper;
private DesignMapper designMapper; private final AttributeRetrievalMapper attributeRetrievalMapper;
@Resource private final ProductImageAttributeMapper productImageAttributeMapper;
private DesignService designService; private final CollectionSortMapper collectionSortMapper;
@Resource private final ClassificationService classificationService;
private SysFileMapper sysFileMapper; // private ProjectMapper projectMapper;
@Resource private final ProjectService projectService;
private LibraryMapper libraryMapper; private final LibraryModelPointMapper libraryModelPointMapper;
@Resource private final LibraryService libraryService;
private GenerateDetailMapper generateDetailMapper; private final BrandDNAMapper brandDNAMapper;
@Resource private final BrandRelLibraryMapper brandRelLibraryMapper;
private PortfolioMapper portfolioMapper; private final ThreeDLayoutMapper threeDLayoutMapper;
@Resource private final ThreeDPatternLayoutMapper threeDPatternLayoutMapper;
private TagsMapper tagsMapper; private final ThreeDDetailMapper threeDDetailMapper;
@Resource private final ThreeDSimpleMapper threeDSimpleMapper;
private DesignItemDetailService designItemDetailService; private final ThreeDModuleMapper threeDModuleMapper;
@Resource private final ProductImageService productImageService;
private CollectionElementMapper collectionElementMapper; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource private final CollectionSortService collectionSortService;
private AttributeRetrievalMapper attributeRetrievalMapper; private final GenerateService generateService;
@Resource private final ToProductElementMapper toProductElementMapper;
private ProductImageAttributeMapper productImageAttributeMapper; private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final ToProductImageResultMapper toProductImageResultMapper;
private CollectionSortMapper collectionSortMapper; private final ToProductImageResultService toProductImageResultService;
@Resource private final CloudTaskMapper cloudTaskMapper;
private ClassificationService classificationService; private final PythonService pythonService;
@Resource private final CreditsService creditsService;
// private ProjectMapper projectMapper; private final PoseTransformationMapper poseTransformationMapper;
private ProjectService projectService; private final ExportFileMapper exportFileMapper;
@Resource private final DesignItemDetailCanvasMapper designItemDetailCanvasMapper;
private PortfolioService portfolioService;
@Resource
private LibraryModelPointMapper libraryModelPointMapper;
@Resource
private LibraryService libraryService;
@Resource
private BrandDNAMapper brandDNAMapper;
@Resource
private BrandRelLibraryMapper brandRelLibraryMapper;
@Resource
private ThreeDLayoutMapper threeDLayoutMapper;
@Resource
private ThreeDPatternLayoutMapper threeDPatternLayoutMapper;
@Resource
private ThreeDDetailMapper threeDDetailMapper;
@Resource
private ThreeDSimpleMapper threeDSimpleMapper;
@Resource
private ThreeDModuleMapper threeDModuleMapper;
@Resource
private ProductImageService productImageService;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource
private CollectionSortService collectionSortService;
@Resource
private GenerateService generateService;
@Resource
private ToProductElementMapper toProductElementMapper;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private CloudTaskMapper cloudTaskMapper;
@Resource
private PythonService pythonService;
@Resource
private CreditsService creditsService;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Resource
private ExportFileMapper exportFileMapper;
@Resource
private DesignItemDetailCanvasMapper designItemDetailCanvasMapper;
@Value("${redis.key.generateResult}") @Value("${redis.key.generateResult}")
private String generateResultKey; private String generateResultKey;
@@ -2033,7 +1992,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
} }
if (userLikeGroupVO.getOriginal() == 0) { if (userLikeGroupVO.getOriginal() == 0) {
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName()); userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId()); Portfolio byId = portfolioMapper.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
if (Objects.nonNull(byId)) { if (Objects.nonNull(byId)) {
String portfolioName = byId.getPortfolioName(); String portfolioName = byId.getPortfolioName();
userLikeGroupVO.setOriginalPortfolioName(portfolioName); userLikeGroupVO.setOriginalPortfolioName(portfolioName);
@@ -2368,7 +2327,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (Objects.nonNull(toProductImageRecord)) { if (Objects.nonNull(toProductImageRecord)) {
vo.setPrompt(toProductImageRecord.getPrompt()); vo.setPrompt(toProductImageRecord.getPrompt());
} }
vo.setParentId(getUnlikedResultParentId(result, null)); vo.setParentId(toProductImageResultService.getUnlikedResultParentId(result, null));
// 按isLike分类 // 按isLike分类
if (result.getIsLike() != null && result.getIsLike() == 1) { if (result.getIsLike() != null && result.getIsLike() == 1) {
likedList.add(vo); likedList.add(vo);
@@ -2497,56 +2456,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
return duration.toHours() >= 1; return duration.toHours() >= 1;
} }
// 获取未被like的to product\relight的parentId
public Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url) {
// 卫语句处理null情况
if (toProductImageResult == null && StringUtil.isNullOrEmpty(url)) {
return null;
}
// 如果需要查询结果对象
if (toProductImageResult == null) {
toProductImageResult = toProductImageResultMapper.selectOne(
new QueryWrapper<ToProductImageResult>().eq("url", url));
}
// 卫语句处理查询结果为空的情况
if (toProductImageResult == null) {
return null;
}
// 根据不同类型处理
String elementType = toProductImageResult.getElementType();
if ("DesignOutfit".equals(elementType)) {
return handleDesignOutfitCase(toProductImageResult);
} else if ("ToProductImage".equals(elementType)) {
// 两种情况 resultType : ToProductImage | Relight
return handleToProductImageCase(toProductImageResult);
}
return null;
}
private Long handleDesignOutfitCase(ToProductImageResult result) {
UserLike userLike = userLikeService.getByDesignOutfitId(result.getElementId());
if (userLike == null) {
return null;
}
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
userLike.getId(), "Design", result.getProjectId());
return collectionSort != null ? collectionSort.getId() : null;
}
private Long handleToProductImageCase(ToProductImageResult result) {
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
result.getElementId(), result.getResultType(), result.getProjectId());
if (Objects.isNull(collectionSort) && result.getElementType().equals("ToProductImage")) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(result.getElementId());
return getUnlikedResultParentId(toProductImageResult, null);
}
return collectionSort != null ? collectionSort.getParentId() : null;
}
@Override @Override
@Transactional @Transactional
@@ -2568,7 +2477,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElementMapper.updateById(compositeImage); collectionElementMapper.updateById(compositeImage);
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) { if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
// 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联 // 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联
designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId()); moodboardPositionService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId());
} }
} }
} }
@@ -3358,12 +3267,13 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60)); toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60));
return toProductElementVO; return toProductElementVO;
} }
private String buildAdvancedPrompt(Long projectId, String prompt) { private String buildAdvancedPrompt(Long projectId, String prompt) {
String process = projectService.getById(projectId).getProcess(); String process = projectService.getById(projectId).getProcess();
String ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup(); String ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup();
String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image."; String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image.";
String suffixModelAdult = "Transform this image into a real model standing,"+suffixCommon; String suffixModelAdult = "Transform this image into a real model standing," + suffixCommon;
String suffixModelChild = "Transform this image into a real child model standing,"+suffixCommon; String suffixModelChild = "Transform this image into a real child model standing," + suffixCommon;
if ("SINGLE_DESIGN".equals(process) && "Adult".equals(ageGroup)) { if ("SINGLE_DESIGN".equals(process) && "Adult".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) { if (StringUtil.isNullOrEmpty(prompt)) {
return "Transform this image into a real garment showing in the white studio: garment on invisible mannequin" + suffixCommon; return "Transform this image into a real garment showing in the white studio: garment on invisible mannequin" + suffixCommon;

View File

@@ -12,17 +12,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 服务实现类 * 服务实现类
@@ -32,13 +29,10 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> implements UserLikeService { public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> implements UserLikeService {
@Resource private final UserLikeMapper userLikeMapper;
private UserLikeMapper userLikeMapper; private final UserLikeGroupMapper userLikeGroupMapper;
@Resource
private UserLikeGroupMapper userLikeGroupMapper;
@Resource
private DesignItemServiceImpl designItemService;
@Override @Override
public List<UserLikeVO> getGroupDetail(Long userGroupId) { public List<UserLikeVO> getGroupDetail(Long userGroupId) {
@@ -50,12 +44,6 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
return Lists.newArrayList(); return Lists.newArrayList();
} }
return CopyUtil.copyList(userLikes, UserLikeVO.class); return CopyUtil.copyList(userLikes, UserLikeVO.class);
// List<Long> designItemIds = userLikes.stream().map(UserLike::getDesignItemId).collect(Collectors.toList());
// List<DesignItem> designItems = designItemService.listByIds(designItemIds);
// Map<Long,String> idToUrlMap = designItems.stream().collect(Collectors.toMap(DesignItem::getId,DesignItem::getDesignUrl));
// return CopyUtil.copyList(userLikes,UserLikeVO.class,(o,d) ->{
// d.setUrl(idToUrlMap.get(o.getDesignItemId()));
// });
} }
@Override @Override
@@ -72,11 +60,11 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
} }
@Override @Override
public UserLike getByDesignItemId(Long designItemId){ public UserLike getByDesignItemId(Long designItemId) {
QueryWrapper<UserLike> qw = new QueryWrapper<>(); QueryWrapper<UserLike> qw = new QueryWrapper<>();
qw.eq("design_item_id",designItemId); qw.eq("design_item_id", designItemId);
List<UserLike> userLikes = baseMapper.selectList(qw); List<UserLike> userLikes = baseMapper.selectList(qw);
if (!userLikes.isEmpty()){ if (!userLikes.isEmpty()) {
return baseMapper.selectList(qw).get(0); return baseMapper.selectList(qw).get(0);
} }
return null; return null;
@@ -84,13 +72,13 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateDate(Long designItemId,String timeZone){ public void updateDate(Long designItemId, String timeZone) {
UpdateWrapper<UserLike> uw = new UpdateWrapper<>(); UpdateWrapper<UserLike> uw = new UpdateWrapper<>();
uw.eq("design_item_id",designItemId); uw.eq("design_item_id", designItemId);
uw.set("update_date",DateUtil.getByTimeZone(timeZone)); uw.set("update_date", DateUtil.getByTimeZone(timeZone));
uw.set("converted", 1); uw.set("converted", 1);
baseMapper.update(null,uw); baseMapper.update(null, uw);
} }
@Override @Override
@@ -123,12 +111,12 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
} }
@Override @Override
public UserLike getByDesignOutfitId(Long designOutfitId){ public UserLike getByDesignOutfitId(Long designOutfitId) {
QueryWrapper<UserLike> qw = new QueryWrapper<>(); QueryWrapper<UserLike> qw = new QueryWrapper<>();
qw.lambda().eq(UserLike::getDesignOutfitId, designOutfitId); qw.lambda().eq(UserLike::getDesignOutfitId, designOutfitId);
// 有脏数据 // 有脏数据
List<UserLike> userLikes = baseMapper.selectList(qw); List<UserLike> userLikes = baseMapper.selectList(qw);
if (!userLikes.isEmpty()){ if (!userLikes.isEmpty()) {
return userLikes.get(0); return userLikes.get(0);
} }
return null; return null;

View File

@@ -732,7 +732,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId) LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId)
.eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName()) .eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName())
.eq(CollectionElement::getLevel3Type, workspaceNew.getSex()); .eq(CollectionElement::getLevel3Type, workspaceNew.getSex());
if (collectionElementMapper.selectCount(queryWrapper) == 0){ if (collectionElementMapper.selectCount(queryWrapper) == 0) {
CollectionElement collectionElement = new CollectionElement(); CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(userInfo.getId()); collectionElement.setAccountId(userInfo.getId());
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
@@ -793,7 +793,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
Project project = CopyUtil.copyObject(projectDTO, Project.class); Project project = CopyUtil.copyObject(projectDTO, Project.class);
project.setAccountId(userInfo.getId()); project.setAccountId(userInfo.getId());
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
if (StringUtil.isNullOrEmpty(project.getName())){ if (StringUtil.isNullOrEmpty(project.getName())) {
Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId()); Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId());
project.setName("Untitled_" + seq); project.setName("Untitled_" + seq);
} }
@@ -980,4 +980,32 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return kvs; return kvs;
} }
@Override
public String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId) {
if (Objects.nonNull(projectId)) {
Workspace workspace = getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())) {
return workspace.getAgeGroup();
}
} else if (Objects.nonNull(collectionId) && collectionId != 0) {
List<CollectionElement> byCollectionId = getByCollectionId(collectionId);
if (byCollectionId != null && !byCollectionId.isEmpty()) {
projectId = byCollectionId.get(0).getProjectId();
if (projectId != null && projectId != 0L) {
Workspace workspace = getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())) {
return workspace.getAgeGroup();
}
}
}
}
return AgeGroup.ADULT.getValue();
}
private List<CollectionElement> getByCollectionId(Long collectionId) {
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CollectionElement::getCollectionId, collectionId);
return collectionElementMapper.selectList(queryWrapper);
}
} }