为模特和线稿设置性别

修改设置模特会增多问题
模型更换
设置可以切换男女兼容
TODO:扣除积分价格
转产品图模型未完成
This commit is contained in:
litianxiang
2025-09-30 17:22:23 +08:00
parent ea19e915db
commit ab6cc04483
13 changed files with 1147 additions and 217 deletions

13
pom.xml
View File

@@ -400,6 +400,19 @@
<classifier>${javacpp.platform.linux-x86_64}</classifier> <classifier>${javacpp.platform.linux-x86_64}</classifier>
</dependency> </dependency>
<dependency>
<groupId>com.volcengine</groupId>
<artifactId>volcengine-java-sdk-ark-runtime</artifactId>
<version>LATEST</version>
</dependency>
<!-- Google 认证库 -->
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>LATEST</version>
</dependency>
<!-- GIFEncoder 视频转gif--> <!-- GIFEncoder 视频转gif-->
<dependency> <dependency>

View File

@@ -0,0 +1,42 @@
package com.ai.da.common.constant;
/**
* 模型相关常量类
* 用于存放 chooseModelAndPrompt 方法中的字符串常量
*/
public class ModelConstants {
// 类型常量
public static final String PRINTBOARD = "Printboard";
public static final String MOODBOARD = "Moodboard";
public static final String SKETCHBOARD = "Sketchboard";
// 模型级别常量
public static final String ADVANCED = "advanced";
public static final String HIGH = "high";
public static final String NORMAL = "normal";
// 模型名称常量
public static final String PRINTBOARD_ADVANCED_T2I = "qwen-image";
public static final String MOODBOARD_ADVANCED = "doubao-seedream-3-0-t2i-250415";
public static final String PRINTBOARD_HIGH_T2I = "doubao-seedream-3-0-t2i-250415";
public static final String PRINTBOARD_HIGH_I2I = "doubao-seededit-3-0-i2i-250628";
public static final String PRINTBOARD_ADVANCED_I2I = "doubao-seedream-4-0-250828";
public static final String IMAGEN_MODEL = "imagen-4.0-generate-001";
public static final String NANO_BANANA = "gemini-2.5-flash-image-preview";
public static final String LOCAL_MODEL = "local";
// 风格常量
public static final String PAINTING_STYLE = "Painting Style";
public static final String ILLUSTRATION_STYLE = "Illustration Style";
public static final String REAL_STYLE = "Real Style";
// 映射键
public static final String PROMPT = "prompt";
public static final String USE_MODEL = "UseModel";
// 防止实例化
private ModelConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
}

View File

@@ -41,7 +41,7 @@ public enum CreditsEventsEnum {
MOOD_BOARD("MoodBoard","5"), MOOD_BOARD("MoodBoard","5"),
SKETCH_BOARD("SketchBoard","5"), SKETCH_BOARD("SketchBoard","5"),
TO_PRODUCT_IMAGE("ToProductImage","5"), TO_PRODUCT_IMAGE("ToProductImage","5"),
TO_PRODUCT_IMAGE_FLUX("ToProductImageFlux","10"), TO_PRODUCT_IMAGE_ADVANCED("ToProductImageAdvanced","10"),
RELIGHT("Relight","5"), RELIGHT("Relight","5"),
RELIGHT_FLUX("RelightFlux","10"), RELIGHT_FLUX("RelightFlux","10"),
QUESTIONNAIRE("Questionnaire","100"), QUESTIONNAIRE("Questionnaire","100"),
@@ -51,6 +51,8 @@ public enum CreditsEventsEnum {
OTHER("Other","5"), OTHER("Other","5"),
WX_TEXT2IMG("WX_Text2Image", "5"), WX_TEXT2IMG("WX_Text2Image", "5"),
QWEN_TEXT2IMG("QWEN_Text2Image", "5"),
DOUBAO_TEXT2IMG("Doubao_Text2Image", "5"),
WX_ANIMATION("WX_Animation", "30"), WX_ANIMATION("WX_Animation", "30"),
FREEPIK_IMG2IMG("Freepik_img2img", "20"), FREEPIK_IMG2IMG("Freepik_img2img", "20"),
FLUX_IMG2IMG("Flux_img2img","10"), FLUX_IMG2IMG("Flux_img2img","10"),

View File

@@ -52,6 +52,12 @@ public class CollectionElement implements Serializable {
*/ */
private String level2Type; private String level2Type;
/**
* 三级类型 目前只为线稿标注性别
*/
@TableField("level3_type")
private String level3Type;
/** /**
* 元素名(如果是颜色board 存潘通id+潘通名字 形式 ""11_mds") * 元素名(如果是颜色board 存潘通id+潘通名字 形式 ""11_mds")
*/ */

View File

@@ -96,4 +96,6 @@ public interface GenerateService extends IService<Generate> {
String getFluxResult(String taskId, String objectName); String getFluxResult(String taskId, String objectName);
byte[] downloadVideoOrImage(String url); byte[] downloadVideoOrImage(String url);
String createGoogleAsyncTask(GenerateThroughImageTextDTO generateDTO, String useModel, String prompt);
} }

View File

@@ -63,4 +63,6 @@ public interface WorkspaceService extends IService<Workspace> {
SaveOrUpdateProjectVO saveOrUpdateProject(ProjectDTO projectDTO); SaveOrUpdateProjectVO saveOrUpdateProject(ProjectDTO projectDTO);
Long getByProjectId(Long projectId); Long getByProjectId(Long projectId);
String getProjectSexById(Long projectId);
} }

View File

@@ -23,6 +23,7 @@ import com.ai.da.python.vo.ImageSegmentation;
import com.ai.da.service.*; import com.ai.da.service.*;
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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
@@ -30,6 +31,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gson.Gson; import com.google.gson.Gson;
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.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -55,6 +57,7 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService { public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService {
@Resource @Resource
private CollectionElementMapper collectionElementMapper; private CollectionElementMapper collectionElementMapper;
@@ -79,6 +82,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Resource @Resource
private MinioUtil minioUtil; private MinioUtil minioUtil;
private WorkspaceService workspaceService;
@Value("${minio.bucketName.collectionElement}") @Value("${minio.bucketName.collectionElement}")
private String collectionElement; private String collectionElement;
@Value("${minio.bucketName.gradient}") @Value("${minio.bucketName.gradient}")
@@ -88,7 +93,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
// @Resource // @Resource
// private RedisUtil redisUtil; // private RedisUtil redisUtil;
@Resource @Resource
private EmailService emailService; private EmailService emailService;
@@ -103,7 +108,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String name; String name;
if (Objects.isNull(level1TypeEnum) && !uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())) { if (Objects.isNull(level1TypeEnum) && !uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())) {
throw new BusinessException("unknown.parameter.level1Type"); throw new BusinessException("unknown.parameter.level1Type");
} else if (uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())){ } else if (uploadDTO.getLevel1Type().equals(Module.deReconstruction.getValue())) {
name = "Construction"; name = "Construction";
} else { } else {
name = level1TypeEnum.getRealName(); name = level1TypeEnum.getRealName();
@@ -112,12 +117,12 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String path = minioUtil.upload(collectionElement, objectName, uploadDTO.getFile()); String path = minioUtil.upload(collectionElement, objectName, uploadDTO.getFile());
String level2Type = null; String level2Type = null;
if (uploadDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())){ if (uploadDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
if (StringUtil.isNullOrEmpty(uploadDTO.getGender())) { if (StringUtil.isNullOrEmpty(uploadDTO.getGender())) {
throw new BusinessException("gender.cannot.be.empty"); throw new BusinessException("gender.cannot.be.empty");
} }
level2Type = pythonService.getClothCategory(path,uploadDTO.getGender()); level2Type = pythonService.getClothCategory(path, uploadDTO.getGender());
}else if (!StringUtil.isNullOrEmpty(uploadDTO.getLevel2Type())){ } else if (!StringUtil.isNullOrEmpty(uploadDTO.getLevel2Type())) {
level2Type = uploadDTO.getLevel2Type(); level2Type = uploadDTO.getLevel2Type();
} }
@@ -199,8 +204,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//按时区计算 //按时区计算
element.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone())); element.setCreateDate(DateUtil.getByTimeZone(uploadDTO.getTimeZone()));
element.setLevel2Type(level2Type); element.setLevel2Type(level2Type);
if (Objects.nonNull(uploadDTO.getProjectId())){ if (Objects.nonNull(uploadDTO.getProjectId())) {
element.setProjectId(uploadDTO.getProjectId()); element.setProjectId(uploadDTO.getProjectId());
if (CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(element.getLevel1Type())) {
element.setLevel3Type(workspaceService.getProjectSexById(uploadDTO.getProjectId()));
}
} }
// String linuxDomain = fileProperties.getLinuxDomain(); // String linuxDomain = fileProperties.getLinuxDomain();
// if (!StringUtils.isEmpty(linuxDomain)) { // if (!StringUtils.isEmpty(linuxDomain)) {
@@ -265,7 +273,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
List<String> printPath = Arrays.asList(url1, url2); List<String> printPath = Arrays.asList(url1, url2);
//调取python 接口 //调取python 接口
String generateUrl = pythonService.generatePrint(printPath,userId); String generateUrl = pythonService.generatePrint(printPath, userId);
if (StringUtils.isEmpty(generateUrl)) { if (StringUtils.isEmpty(generateUrl)) {
throw new BusinessException("generate.interface.exception"); throw new BusinessException("generate.interface.exception");
} }
@@ -367,7 +375,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return Boolean.TRUE; return Boolean.TRUE;
} }
private CollectionElement resolveData(String path, String timeZone, Long userId){ private CollectionElement resolveData(String path, String timeZone, Long userId) {
// File file = new File(path); // File file = new File(path);
String name = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")); String name = path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf("."));
@@ -380,7 +388,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
element.setHasPin((byte) 0); element.setHasPin((byte) 0);
try { try {
element.setMd5(MD5Utils.encryptFile(minioUtil.download(path))); element.setMd5(MD5Utils.encryptFile(minioUtil.download(path)));
}catch (Exception e){ } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
/* catch (MinioException | IOException e) { /* catch (MinioException | IOException e) {
@@ -392,55 +400,82 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return element; return element;
} }
/**
* 验证和处理设计集合元素
* <p>
* 功能说明:
* - 验证设计集合DTO中的各种元素moodBoards、printBoards、sketchBoards等
* - 处理渐变色彩板的base64图片上传到MinIO
* - 校验PIN数量限制上衣、下衣、外套各不超过8个
* - 验证模特信息和模板点位
* - 转换并整合来自library和generate的元素数据
*
* @param designDTO 设计集合DTO包含所有设计元素信息
* @return ValidateElementVO 验证后的元素VO对象包含处理后的所有元素数据
* @throws BusinessException 当数据验证失败时抛出业务异常
*/
@Override @Override
public ValidateElementVO validateElement(DesignCollectionDTO designDTO) { public ValidateElementVO validateElement(DesignCollectionDTO designDTO) {
// 将设计DTO转换为验证元素VO对象
ValidateElementVO elementVO = CopyUtil.copyObject(designDTO, ValidateElementVO.class); ValidateElementVO elementVO = CopyUtil.copyObject(designDTO, ValidateElementVO.class);
// 处理颜色板中的渐变色彩
List<CollectionColorDTO> colorBoards = elementVO.getColorBoards(); List<CollectionColorDTO> colorBoards = elementVO.getColorBoards();
for (CollectionColorDTO colorBoard : colorBoards) { for (CollectionColorDTO colorBoard : colorBoards) {
if (Objects.nonNull(colorBoard.getGradient())) { if (Objects.nonNull(colorBoard.getGradient())) {
// 解析base64格式的渐变图片数据
String colorImg = colorBoard.getGradient().getColorImg(); String colorImg = colorBoard.getGradient().getColorImg();
String[] parts = colorImg.split(","); String[] parts = colorImg.split(",");
String imageType = parts[0].split("/")[1].split(";")[0]; String imageType = parts[0].split("/")[1].split(";")[0]; // 提取图片类型
String base64Data = parts[1]; String base64Data = parts[1]; // 提取base64数据
// 将base64图片上传到MinIO存储
String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType);
colorBoard.setGradientMinioUrl(gradientMinioUrl); colorBoard.setGradientMinioUrl(gradientMinioUrl);
colorBoard.getGradient().setColorImg(null); colorBoard.getGradient().setColorImg(null); // 清空原始base64数据
colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); // 保存渐变配置JSON
} }
} }
elementVO.setColorBoards(colorBoards); elementVO.setColorBoards(colorBoards);
List<Long> usedElementIds = elementVO.getUsedElementIds();
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements(); // 初始化用于收集各类元素的集合
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements(); List<Long> usedElementIds = elementVO.getUsedElementIds(); // 已使用的元素ID列表
//校验moodboard List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements(); // 来自library的元素
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements(); // 来自generate的元素
// ========== 校验和处理moodBoards情绪板 ==========
if (CollectionUtil.isNotEmpty(designDTO.getMoodBoards())) { if (CollectionUtil.isNotEmpty(designDTO.getMoodBoards())) {
//校验designType // 校验designType字段是否有效
validateDesignType(designDTO.getMoodBoards(), "moodBoards"); validateDesignType(designDTO.getMoodBoards(), "moodBoards");
// 提取类型为COLLECTION的moodBoard ID列表
List<Long> moodBoardIds = designDTO.getMoodBoards().stream() List<Long> moodBoardIds = designDTO.getMoodBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) .filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.map(DesignCollectionElementDTO::getId) .map(DesignCollectionElementDTO::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(moodBoardIds)) { if (!CollectionUtils.isEmpty(moodBoardIds)) {
// 从数据库批量查询moodBoard元素
List<CollectionElement> MoodBoardElements = collectionElementMapper.selectBatchIds(moodBoardIds); List<CollectionElement> MoodBoardElements = collectionElementMapper.selectBatchIds(moodBoardIds);
// 验证查询结果的完整性
if (CollectionUtil.isEmpty(MoodBoardElements) || MoodBoardElements.size() != moodBoardIds.size()) { if (CollectionUtil.isEmpty(MoodBoardElements) || MoodBoardElements.size() != moodBoardIds.size()) {
throw new BusinessException("get.moodBoards.data.is.mismatch"); throw new BusinessException("get.moodBoards.data.is.mismatch");
} }
elementVO.setMoodBoardElements(MoodBoardElements); elementVO.setMoodBoardElements(MoodBoardElements);
usedElementIds.addAll(moodBoardIds); usedElementIds.addAll(moodBoardIds); // 记录已使用的元素ID
} }
//library // 处理类型为LIBRARY的moodBoard元素
List<Long> libraryIds = designDTO.getMoodBoards().stream() List<Long> libraryIds = designDTO.getMoodBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) .filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(DesignCollectionElementDTO::getId) .map(DesignCollectionElementDTO::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(libraryIds)) { if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds); List<Library> librarys = libraryService.getByIds(libraryIds);
//校验防止用户在library删除 对应不上 // 不严格校验防止用户在library删除元素导致对应不上
if (CollectionUtil.isNotEmpty(librarys)) { if (CollectionUtil.isNotEmpty(librarys)) {
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, null)); libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, null));
} }
} }
// generate
// 处理类型为GENERATE的moodBoard元素
List<Long> generateIds = designDTO.getMoodBoards().stream() List<Long> generateIds = designDTO.getMoodBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName()))) .filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionElementDTO::getId) .map(DesignCollectionElementDTO::getId)
@@ -452,38 +487,45 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
} }
} }
// ========== 校验和处理printBoards印花板 ==========
if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) { if (CollectionUtil.isNotEmpty(designDTO.getPrintBoards())) {
//校验designType // 校验designType字段是否有效
validateDesignType(CopyUtil.copyList(designDTO.getPrintBoards(), DesignCollectionElementDTO.class), "printBoards"); validateDesignType(CopyUtil.copyList(designDTO.getPrintBoards(), DesignCollectionElementDTO.class), "printBoards");
// 提取类型为COLLECTION的printBoard ID列表
List<Long> printBoardIds = designDTO.getPrintBoards().stream() List<Long> printBoardIds = designDTO.getPrintBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) .filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
.map(DesignCollectionPrintElementDTO::getId) .map(DesignCollectionPrintElementDTO::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(printBoardIds)) { if (!CollectionUtils.isEmpty(printBoardIds)) {
//校验printboard // 从数据库批量查询printBoard元素
List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds); List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds);
// 验证查询结果的完整性
if (CollectionUtil.isEmpty(printBoardElements) || printBoardElements.size() != printBoardIds.size()) { if (CollectionUtil.isEmpty(printBoardElements) || printBoardElements.size() != printBoardIds.size()) {
throw new BusinessException("get.printBoards.data.is.mismatch"); throw new BusinessException("get.printBoards.data.is.mismatch");
} }
elementVO.setPrintBoardElements(printBoardElements); elementVO.setPrintBoardElements(printBoardElements);
usedElementIds.addAll(printBoardIds); usedElementIds.addAll(printBoardIds); // 记录已使用的元素ID
} }
//library // 处理类型为LIBRARY的printBoard元素
List<Long> libraryIds = designDTO.getPrintBoards().stream() List<Long> libraryIds = designDTO.getPrintBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) .filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(DesignCollectionPrintElementDTO::getId) .map(DesignCollectionPrintElementDTO::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(libraryIds)) { if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds); List<Library> librarys = libraryService.getByIds(libraryIds);
//校验防止用户在library删除 对应不上 // 不严格校验防止用户在library删除元素导致对应不上
if (CollectionUtil.isNotEmpty(librarys)) { if (CollectionUtil.isNotEmpty(librarys)) {
// 创建ID到printBoard元素的映射用于保持元素属性
Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards() Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
.stream() .stream()
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v)); .collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToPrintCollections(librarys, idToMap)); libraryCollectionElements.addAll(covertLibrarysToPrintCollections(librarys, idToMap));
} }
} }
// generate
// 处理类型为GENERATE的printBoard元素
List<Long> generateIds = designDTO.getPrintBoards().stream() List<Long> generateIds = designDTO.getPrintBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName()))) .filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(DesignCollectionPrintElementDTO::getId) .map(DesignCollectionPrintElementDTO::getId)
@@ -491,6 +533,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (CollectionUtil.isNotEmpty(generateIds)) { if (CollectionUtil.isNotEmpty(generateIds)) {
List<GenerateDetail> generateDetailList = generateDetailMapper.selectBatchIds(generateIds); List<GenerateDetail> generateDetailList = generateDetailMapper.selectBatchIds(generateIds);
if (CollectionUtil.isNotEmpty(generateDetailList)) { if (CollectionUtil.isNotEmpty(generateDetailList)) {
// 创建ID到printBoard元素的映射用于保持元素属性
Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards() Map<Long, DesignCollectionPrintElementDTO> idToMap = designDTO.getPrintBoards()
.stream() .stream()
.collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v)); .collect(Collectors.toMap(DesignCollectionPrintElementDTO::getId, v -> v));
@@ -498,80 +541,113 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
} }
} }
// ========== 校验和处理sketchBoards草图板 ==========
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) { if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
//校验PIN是否满足 上衣或者下衣必须不超过8 // 校验PIN数量限制:上衣、下衣、外套各不超过8
long topNum = 0; long topNum = 0;
long bottomNum = 0; long bottomNum = 0;
long outerwearNum = 0; long outerwearNum = 0;
if (designDTO.getModelSex().equals(Sex.FEMALE.getValue())) { //去掉与性别不符合的线稿元素 - 使用 Iterator 安全移除元素
topNum= designDTO.getSketchBoards().stream() Iterator<CollectionSketchDTO> sketchIterator = designDTO.getSketchBoards().iterator();
.filter(skecth -> skecth.getIsPin() == 1 while (sketchIterator.hasNext()) {
&& DesignPythonItem.DRESS_BLOUSE.contains(skecth.getLevel2Type())).count(); CollectionSketchDTO sketchBoard = sketchIterator.next();
bottomNum = designDTO.getSketchBoards().stream() String level2Type = sketchBoard.getLevel2Type();
.filter(skecth -> skecth.getIsPin() == 1 //判断性别和当前project性别是否一致不一致则移除
&& DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count(); String level3Type = collectionElementMapper.selectOne(new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getId, sketchBoard.getSketchBoardId()).select(CollectionElement::getLevel3Type)).getLevel3Type();
}else if (designDTO.getModelSex().equals(Sex.MALE.getValue())) { if (!level3Type.equalsIgnoreCase(designDTO.getModelSex())) {
topNum= designDTO.getSketchBoards().stream() sketchIterator.remove();
.filter(skecth -> skecth.getIsPin() == 1 }
&& DesignPythonItem.TOPS.contains(skecth.getLevel2Type())).count();
bottomNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.BOTTOMS.contains(skecth.getLevel2Type())).count();
}
outerwearNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.OUTWEAR.contains(skecth.getLevel2Type())).count();
if (topNum > 8 || bottomNum > 8 || outerwearNum > 8) {
throw new BusinessException("the.number.of.PIN.top.or.bottom.or.outerwear.sketchBoard.cannot.be.more.than.8", ResultEnum.PROMPT.getCode());
}
//校验designType
Boolean result = designDTO.getSketchBoards().stream()
.filter(mood -> StringUtils.isEmpty(mood.getDesignType()))
.findFirst().isPresent();
if (result) {
throw new BusinessException("sketchBoards.designType.cannot.be.empty");
} }
//再次判断草图板数量如果为null则跳出当前if
if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
List<Long> sketchBoardIds = designDTO.getSketchBoards().stream() // 根据模特性别统计不同类型的PIN数量
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) if (designDTO.getModelSex().equals(Sex.FEMALE.getValue())) {
.map(CollectionSketchDTO::getSketchBoardId) // 女性模特统计连衣裙和上衣类PIN数量
.collect(Collectors.toList()); topNum = designDTO.getSketchBoards().stream()
if (!CollectionUtils.isEmpty(sketchBoardIds)) { .filter(skecth -> skecth.getIsPin() == 1
//校验sketchBoard && DesignPythonItem.DRESS_BLOUSE.contains(skecth.getLevel2Type())).count();
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds); // 女性模特统计裙子和裤子类PIN数量
if (CollectionUtil.isEmpty(sketchBoardElements) || sketchBoardElements.size() != sketchBoardIds.size()) { bottomNum = designDTO.getSketchBoards().stream()
throw new BusinessException("get.sketchBoards.data.is.mismatch"); .filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.SKIRT_TROUSERS.contains(skecth.getLevel2Type())).count();
} else if (designDTO.getModelSex().equals(Sex.MALE.getValue())) {
// 男性模特统计上衣类PIN数量
topNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.TOPS.contains(skecth.getLevel2Type())).count();
// 男性模特统计下装类PIN数量
bottomNum = designDTO.getSketchBoards().stream()
.filter(skecth -> skecth.getIsPin() == 1
&& DesignPythonItem.BOTTOMS.contains(skecth.getLevel2Type())).count();
} }
elementVO.setSketchBoardElements(sketchBoardElements); // 统计外套类PIN数量男女通用
usedElementIds.addAll(sketchBoardIds); outerwearNum = designDTO.getSketchBoards().stream()
} .filter(skecth -> skecth.getIsPin() == 1
//library && DesignPythonItem.OUTWEAR.contains(skecth.getLevel2Type())).count();
List<Long> libraryIds = designDTO.getSketchBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) // 验证PIN数量限制每个类别不能超过8个
.map(CollectionSketchDTO::getSketchBoardId) if (topNum > 8 || bottomNum > 8 || outerwearNum > 8) {
.collect(Collectors.toList()); throw new BusinessException("the.number.of.PIN.top.or.bottom.or.outerwear.sketchBoard.cannot.be.more.than.8", ResultEnum.PROMPT.getCode());
if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds);
//不校验了防止用户在library删除 对应不上
if (CollectionUtil.isNotEmpty(librarys)) {
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, idToMap));
} }
}
// generate // 校验designType字段不能为空
List<Long> generateIds = designDTO.getSketchBoards().stream() Boolean result = designDTO.getSketchBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName()))) .filter(mood -> StringUtils.isEmpty(mood.getDesignType()))
.map(CollectionSketchDTO::getSketchBoardId) .findFirst().isPresent();
.collect((Collectors.toList())); if (result) {
if (CollectionUtil.isNotEmpty(generateIds)) { throw new BusinessException("sketchBoards.designType.cannot.be.empty");
List<GenerateDetail> generateDetailList = generateDetailMapper.selectBatchIds(generateIds); }
if (CollectionUtil.isNotEmpty(generateDetailList)) {
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards() // 提取类型为COLLECTION的sketchBoard ID列表
.stream() List<Long> sketchBoardIds = designDTO.getSketchBoards().stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v)); .filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
generateCollectionElements.addAll(covertGeneratesToCollections(generateDetailList, idToMap)); .map(CollectionSketchDTO::getSketchBoardId)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(sketchBoardIds)) {
// 从数据库查询验证sketchBoard元素是否存在
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds);
if (CollectionUtil.isEmpty(sketchBoardElements) || sketchBoardElements.size() != sketchBoardIds.size()) {
throw new BusinessException("get.sketchBoards.data.is.mismatch");
}
// 设置验证通过的sketchBoard元素到结果对象
elementVO.setSketchBoardElements(sketchBoardElements);
// 记录已使用的元素ID
usedElementIds.addAll(sketchBoardIds);
}
// 处理类型为LIBRARY的sketchBoard元素
List<Long> libraryIds = designDTO.getSketchBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName()))
.map(CollectionSketchDTO::getSketchBoardId)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(libraryIds)) {
List<Library> librarys = libraryService.getByIds(libraryIds);
// 不严格校验防止用户在library中删除元素导致对应不上
if (CollectionUtil.isNotEmpty(librarys)) {
// 创建ID到sketchBoard元素的映射用于保持元素属性
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, idToMap));
}
}
// 处理类型为GENERATE的sketchBoard元素
List<Long> generateIds = designDTO.getSketchBoards().stream()
.filter(o -> o.getDesignType().equals((DesignTypeEnum.GENERATE.getRealName())))
.map(CollectionSketchDTO::getSketchBoardId)
.collect((Collectors.toList()));
if (CollectionUtil.isNotEmpty(generateIds)) {
List<GenerateDetail> generateDetailList = generateDetailMapper.selectBatchIds(generateIds);
if (CollectionUtil.isNotEmpty(generateDetailList)) {
// 创建ID到sketchBoard元素的映射用于保持元素属性
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
generateCollectionElements.addAll(covertGeneratesToCollections(generateDetailList, idToMap));
}
} }
} }
} }
@@ -604,13 +680,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
} }
}*/ }*/
//校验控制生成类型
// ========== 校验控制生成类型参数 ==========
// 验证singleOverall参数单品/整体生成控制)
SingleOverallEnum singleOverall = SingleOverallEnum.of(designDTO.getSingleOverall()); SingleOverallEnum singleOverall = SingleOverallEnum.of(designDTO.getSingleOverall());
if (Objects.isNull(singleOverall)) { if (Objects.isNull(singleOverall)) {
log.error("未知singleOverall param{}", designDTO.getSingleOverall()); log.error("未知singleOverall param{}", designDTO.getSingleOverall());
log.info("入参 designDTO => {}", designDTO); log.info("入参 designDTO => {}", designDTO);
throw new BusinessException("unknown.parameter.singleOverall"); throw new BusinessException("unknown.parameter.singleOverall");
} }
// 如果是单品生成模式需要验证switchCategory参数
if (SingleOverallEnum.SINGLE.equals(singleOverall)) { if (SingleOverallEnum.SINGLE.equals(singleOverall)) {
SwitchCategoryEnum switchCategory = SwitchCategoryEnum.of(designDTO.getSwitchCategory()); SwitchCategoryEnum switchCategory = SwitchCategoryEnum.of(designDTO.getSwitchCategory());
if (Objects.isNull(switchCategory)) { if (Objects.isNull(switchCategory)) {
@@ -619,36 +699,57 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
throw new BusinessException("unknown.parameter.switchCategory"); throw new BusinessException("unknown.parameter.switchCategory");
} }
} }
// 校验模特
// ========== 校验和处理模特信息 ==========
if (!CollectionUtils.isEmpty(designDTO.getMannequins())) { if (!CollectionUtils.isEmpty(designDTO.getMannequins())) {
// 处理多个模特的情况 - 使用 Iterator 安全移除元素
List<DesignLibraryModelPointVO> designLibraryModelPointVOList = new ArrayList<>(); List<DesignLibraryModelPointVO> designLibraryModelPointVOList = new ArrayList<>();
for (MannequinDTO mannequin : designDTO.getMannequins()) { Iterator<MannequinDTO> mannequinIterator = designDTO.getMannequins().iterator();
while (mannequinIterator.hasNext()) {
MannequinDTO mannequin = mannequinIterator.next();
if (mannequin.getType().equals("System")) { if (mannequin.getType().equals("System")) {
// 处理系统模特
SysFileVO byId = sysFileService.getById(mannequin.getId()); SysFileVO byId = sysFileService.getById(mannequin.getId());
if (Objects.isNull(byId)){ if (Objects.isNull(byId)) {
log.info("未知模特:{}{}", mannequin.getId(), "System"); log.info("未知模特:{}{}", mannequin.getId(), "System");
throw new BusinessException("model.not.found"); throw new BusinessException("model.not.found");
} }
if (!designDTO.getModelSex().equalsIgnoreCase(byId.getLevel2Type())) {
mannequinIterator.remove();
continue;
}
// 注释:女性模特的风格设置(已禁用)
// if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) { // if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
// elementVO.setStyle(byId.getLevel3Type()); // elementVO.setStyle(byId.getLevel3Type());
// } // }
// 获取模特点位信息并计算模板点位
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType()); LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType());
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl())); designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}else { } else {
// 处理用户自定义模特
Library byId = libraryService.getById(mannequin.getId()); Library byId = libraryService.getById(mannequin.getId());
//如果当前模特性别和project模特性别不一致则为此模特进行design
if (!designDTO.getModelSex().equalsIgnoreCase(byId.getLevel2Type())) {
mannequinIterator.remove();
continue;
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType()); LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), mannequin.getType());
designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl())); designLibraryModelPointVOList.add(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} }
} }
elementVO.setMannequins(designLibraryModelPointVOList); elementVO.setMannequins(designLibraryModelPointVOList);
}else { } else {
// 处理单个模特的情况通过templateId指定
if (!StringUtils.isEmpty(designDTO.getModelType())) { if (!StringUtils.isEmpty(designDTO.getModelType())) {
if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) { if (designDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
// 处理用户自定义模特
Library byId = libraryService.getById(designDTO.getTemplateId()); Library byId = libraryService.getById(designDTO.getTemplateId());
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType()); LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl())); elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) { } else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
// 处理系统模特
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId()); SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
// 设置女性模特的风格类型
if (Objects.nonNull(byId) && !StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) { if (Objects.nonNull(byId) && !StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type()); elementVO.setStyle(byId.getLevel3Type());
} }
@@ -657,17 +758,25 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
} }
} }
// ========== 设置最终的验证结果参数 ==========
// 设置模特性别
elementVO.setModelSex(designDTO.getModelSex()); elementVO.setModelSex(designDTO.getModelSex());
// 设置请求ID列表用于批量查询
elementVO.setRequestIdList(designDTO.getRequestIdList()); elementVO.setRequestIdList(designDTO.getRequestIdList());
// 设置设计方案数量默认为8个
if (null != designDTO.getDesignNum()) { if (null != designDTO.getDesignNum()) {
elementVO.setDesignNum(designDTO.getDesignNum()); elementVO.setDesignNum(designDTO.getDesignNum());
}else { } else {
elementVO.setDesignNum(8); elementVO.setDesignNum(8);
} }
// 设置品牌信息(如果存在)
if (null != designDTO.getBrandId()) { if (null != designDTO.getBrandId()) {
elementVO.setBrandId(designDTO.getBrandId()); elementVO.setBrandId(designDTO.getBrandId()); // 设置品牌ID
elementVO.setBrandScale(designDTO.getBrandScale()); elementVO.setBrandScale(designDTO.getBrandScale()); // 设置品牌比例
} }
// 返回验证结果对象
return elementVO; return elementVO;
} }
@@ -784,7 +893,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (!CollectionUtils.isEmpty(sketchBoardIds)) { if (!CollectionUtils.isEmpty(sketchBoardIds)) {
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds); List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds);
elementVO.setSketchBoardElements(sketchBoardElements); elementVO.setSketchBoardElements(sketchBoardElements);
}else { } else {
elementVO.setSketchBoardElements(new ArrayList<>()); elementVO.setSketchBoardElements(new ArrayList<>());
} }
} }
@@ -804,7 +913,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (!CollectionUtils.isEmpty(printBoardIds)) { if (!CollectionUtils.isEmpty(printBoardIds)) {
List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds); List<CollectionElement> printBoardElements = collectionElementMapper.selectBatchIds(printBoardIds);
elementVO.setPrintBoardElements(printBoardElements); elementVO.setPrintBoardElements(printBoardElements);
}else { } else {
elementVO.setPrintBoardElements(new ArrayList<>()); elementVO.setPrintBoardElements(new ArrayList<>());
} }
} }
@@ -858,8 +967,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);
@@ -936,8 +1045,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
CollectionElement collectionElement = new CollectionElement(); CollectionElement collectionElement = new CollectionElement();
if (!Objects.isNull(elementId)) { if (!Objects.isNull(elementId)) {
if (!StringUtil.isNullOrEmpty(designType)){ if (!StringUtil.isNullOrEmpty(designType)) {
switch (designType){ switch (designType) {
case "collection": case "collection":
collectionElement = collectionElementMapper.selectById(elementId); collectionElement = collectionElementMapper.selectById(elementId);
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) { if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) {
@@ -948,11 +1057,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
case "library": case "library":
Library libraryElement = libraryService.getById(elementId); Library libraryElement = libraryService.getById(elementId);
if (!Objects.isNull(libraryElement)) { if (!Objects.isNull(libraryElement)) {
if (StringUtil.isNullOrEmpty(libraryElement.getLevel2Type()) || !(libraryElement.getLevel2Type()).equals(level2Type)){ if (StringUtil.isNullOrEmpty(libraryElement.getLevel2Type()) || !(libraryElement.getLevel2Type()).equals(level2Type)) {
libraryElement.setLevel2Type(level2Type); libraryElement.setLevel2Type(level2Type);
libraryService.updateById(libraryElement); libraryService.updateById(libraryElement);
} }
BeanUtils.copyProperties(libraryElement,collectionElement); BeanUtils.copyProperties(libraryElement, collectionElement);
} }
break; break;
} }
@@ -960,7 +1069,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
log.error("designType cannot be empty"); log.error("designType cannot be empty");
throw new BusinessException("element source type cannot be empty!"); throw new BusinessException("element source type cannot be empty!");
} }
}else { } else {
return null; return null;
} }
return collectionElement; return collectionElement;
@@ -977,7 +1086,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return collectionElementList; return collectionElementList;
} }
private Generate setGenerate(Long userId,String timeZone){ private Generate setGenerate(Long userId, String timeZone) {
Generate generate = new Generate(); Generate generate = new Generate();
generate.setAccountId(userId); generate.setAccountId(userId);
generate.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); generate.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
@@ -987,23 +1096,23 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return generate; return generate;
} }
private GenerateDetail setGenerateDetail(Long generateId, String url, String timeZone){ private GenerateDetail setGenerateDetail(Long generateId, String url, String timeZone) {
GenerateDetail generateDetail = new GenerateDetail(); GenerateDetail generateDetail = new GenerateDetail();
generateDetail.setGenerateId(generateId); generateDetail.setGenerateId(generateId);
generateDetail.setUrl(url); generateDetail.setUrl(url);
String md5; String md5;
try { try {
md5 = MD5Utils.encryptFile(minioUtil.download(url)); md5 = MD5Utils.encryptFile(minioUtil.download(url));
} catch (Exception e){ } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}/*catch (MinioException | IOException e) { }/*catch (MinioException | IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
}*/ }*/
// 通过MD5来确认当前图片是否有被like过避免重复like // 通过MD5来确认当前图片是否有被like过避免重复like
List<Map<String, Long>> libraryIds = generateDetailMapper.getLibraryIdThroughMD5(md5, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); List<Map<String, Long>> libraryIds = generateDetailMapper.getLibraryIdThroughMD5(md5, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
if (libraryIds.isEmpty()){ if (libraryIds.isEmpty()) {
generateDetail.setIsLike((byte) 0); generateDetail.setIsLike((byte) 0);
}else { } else {
generateDetail.setIsLike((byte) 1); generateDetail.setIsLike((byte) 1);
generateDetail.setLibraryId(libraryIds.get(0).get("library_id")); generateDetail.setLibraryId(libraryIds.get(0).get("library_id"));
} }
@@ -1087,14 +1196,14 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
(imageData.getImage_url(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false); (imageData.getImage_url(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
redisUtil.addToString(key, new Gson().toJson(imageData), CommonConstant.GENERATE_RESULT_EXPIRE_TIME); redisUtil.addToString(key, new Gson().toJson(imageData), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url())); resp.add(createCollectionElementVO(accountId, null, null, imageData.getImage_url(), imageData.getClothing_url()));
} else if (sourceType.equals("Library")){ } else if (sourceType.equals("Library")) {
// 从library中选择的图片需要更新数据库中对应图片的分割数据 // 从library中选择的图片需要更新数据库中对应图片的分割数据
String segmentedData = String.join(",", imageData.getClothing_url()); String segmentedData = String.join(",", imageData.getClothing_url());
library.setSegmentedData(segmentedData); library.setSegmentedData(segmentedData);
library.setUpdateDate(new Date()); library.setUpdateDate(new Date());
libraryService.updateById(library); libraryService.updateById(library);
resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), imageData.getClothing_url())); resp.add(createCollectionElementVO(accountId, id, library.getLevel1Type(), library.getUrl(), imageData.getClothing_url()));
}else { } else {
resp.add(createCollectionElementVO(accountId, id, collectionElement.getLevel1Type(), collectionElement.getUrl(), imageData.getClothing_url())); resp.add(createCollectionElementVO(accountId, id, collectionElement.getLevel1Type(), collectionElement.getUrl(), imageData.getClothing_url()));
} }
} }
@@ -1120,9 +1229,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
return vo; return vo;
} }
public void updateElementLevel2Type(Long elementId, String level2Type){ public void updateElementLevel2Type(Long elementId, String level2Type) {
CollectionElement collectionElement = baseMapper.selectById(elementId); CollectionElement collectionElement = baseMapper.selectById(elementId);
if (Objects.nonNull(collectionElement)){ if (Objects.nonNull(collectionElement)) {
collectionElement.setLevel2Type(level2Type); collectionElement.setLevel2Type(level2Type);
collectionElement.setUpdateDate(new Date()); collectionElement.setUpdateDate(new Date());
baseMapper.updateById(collectionElement); baseMapper.updateById(collectionElement);

View File

@@ -362,20 +362,25 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Long designId = saveOne(designDTO, collectionId, userInfo.getId()); Long designId = saveOne(designDTO, collectionId, userInfo.getId());
//计算library //计算library
// calculateLibraryAndSysFile(designDTO, elementVO, userInfo); // calculateLibraryAndSysFile(designDTO, elementVO, userInfo);
//组装design入参
// ========== AI设计生成阶段 ==========
// 组装design入参 - 将业务参数转换为Python AI服务所需的格式
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(), DesignPythonObjects pythonObjects = pythonService.covertDesignParam(designDTO.getSystemScale(),
designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId(), collectionIdParam); designDTO.getSingleOverall(), designDTO.getSwitchCategory(), elementVO, designDTO.getProcessId(), collectionIdParam);
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
long totalTimeInSeconds = (endTime - startTime) / 1000; long totalTimeInSeconds = (endTime - startTime) / 1000;
log.info("组装入参运行时间:" + totalTimeInSeconds + ""); log.info("组装入参运行时间:" + totalTimeInSeconds + "");
// pythonObjects增加image_id关联
// pythonObjects增加image_id关联 - 建立设计元素与图片的关联关系
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
relationImageIds(pythonObjects); relationImageIds(pythonObjects);
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
totalTimeInSeconds = (endTime - startTime) / 1000; totalTimeInSeconds = (endTime - startTime) / 1000;
log.info("增加image_id关联运行时间" + totalTimeInSeconds + ""); log.info("增加image_id关联运行时间" + totalTimeInSeconds + "");
//design
// design - 调用Python AI服务进行设计生成
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String requestId = UUID.randomUUID().toString(); String requestId = UUID.randomUUID().toString();
pythonObjects.setRequestId(requestId); pythonObjects.setRequestId(requestId);
@@ -383,10 +388,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
totalTimeInSeconds = (endTime - startTime) / 1000; totalTimeInSeconds = (endTime - startTime) / 1000;
log.info("design python端运行时间" + totalTimeInSeconds + ""); log.info("design python端运行时间" + totalTimeInSeconds + "");
//生成library // ========== 后处理阶段 ==========
// 生成library - 根据设计元素生成设计库信息
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
generateLibrary(elementVO, designDTO.getTimeZone()); generateLibrary(elementVO, designDTO.getTimeZone());
//处理关联关系,修复element覆盖得情况
// 处理关联关系,修复element覆盖的情况已注释
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId); // List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
// 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, relationElementIds); // handleCollectionElementRelation(collectionId, null != collectionIdParam, relationElementIds);
@@ -394,7 +402,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
totalTimeInSeconds = (endTime - startTime) / 1000; totalTimeInSeconds = (endTime - startTime) / 1000;
log.info("处理关联关系运行时间:" + totalTimeInSeconds + ""); log.info("处理关联关系运行时间:" + totalTimeInSeconds + "");
// 构建设计上下文信息 - 保存设计过程中的关键参数和状态
Map<String, Object> context = new HashMap<>(); Map<String, Object> context = new HashMap<>();
context.put("pythonObjects", pythonObjects); // 转换后的 Python 请求参数 context.put("pythonObjects", pythonObjects); // 转换后的 Python 请求参数
context.put("designId", designId); // 设计 ID context.put("designId", designId); // 设计 ID
@@ -404,11 +412,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
context.put("singleOverall", designDTO.getSingleOverall()); // 其他设计参数 context.put("singleOverall", designDTO.getSingleOverall()); // 其他设计参数
context.put("requestIdList", elementVO.getRequestIdList()); context.put("requestIdList", elementVO.getRequestIdList());
// 将上下文存入全局设计上下文中 // 将上下文存入全局设计上下文中 - 用于后续异步查询和处理
designContext.put(requestId, context); designContext.put(requestId, context);
//保存python返回信息;保存designItem和detail // 保存python返回信息;保存designItem和detail(注释说明)
// 注意:实际的设计结果保存是通过异步回调方式处理的,这里只是准备阶段
// return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall()); // return savePythonDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone(), responseJSONObject, designDTO.getSingleOverall());
// 返回请求ID - 客户端可以使用此ID查询设计进度和结果
return requestId; return requestId;
} }
@@ -2904,6 +2915,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setAccountId(project.getAccountId()); collectionElement.setAccountId(project.getAccountId());
collectionElement.setProjectId(project.getId()); collectionElement.setProjectId(project.getId());
collectionElement.setLevel2Type(receiveCollectionElement.getLevel2Type()); collectionElement.setLevel2Type(receiveCollectionElement.getLevel2Type());
collectionElement.setLevel3Type(workspaceService.getProjectSexById(project.getId()));
collectionElement.setName(split1[0]); collectionElement.setName(split1[0]);
collectionElement.setUrl(url); collectionElement.setUrl(url);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@ package com.ai.da.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.constant.CommonConstant; import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.constant.ModelConstants;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CollectionLevel1TypeEnum; import com.ai.da.common.enums.CollectionLevel1TypeEnum;
import com.ai.da.common.enums.CreditsEventsEnum; import com.ai.da.common.enums.CreditsEventsEnum;
@@ -405,9 +406,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<ToProductImageResultVO> toProduct(ToProductImageDTO toProductImageDTO) { public List<ToProductImageResultVO> toProduct(ToProductImageDTO toProductImageDTO) {
// 判断用户当前积分是否够本次生成消耗 // 判断用户当前积分是否够本次生成消耗
boolean fluxTask = !StringUtil.isNullOrEmpty(toProductImageDTO.getModelName()) boolean nanoBananaTask = !StringUtil.isNullOrEmpty(toProductImageDTO.getModelName())
&& toProductImageDTO.getModelName().equals("flux"); && toProductImageDTO.getModelName().equals(ModelConstants.ADVANCED)||toProductImageDTO.getModelName().equals(ModelConstants.HIGH);
CreditsEventsEnum creditsEventsEnum = fluxTask ? CreditsEventsEnum.TO_PRODUCT_IMAGE_FLUX : CreditsEventsEnum.TO_PRODUCT_IMAGE; CreditsEventsEnum creditsEventsEnum = nanoBananaTask ? CreditsEventsEnum.TO_PRODUCT_IMAGE_ADVANCED : CreditsEventsEnum.TO_PRODUCT_IMAGE;
Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, toProductImageDTO.getToProductImageVOList().size()); Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, toProductImageDTO.getToProductImageVOList().size());
if (!preDeduction) { if (!preDeduction) {
throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode()); throw new BusinessException("Your remaining credits are insufficient for this generation. Please recharge.", ResultEnum.WARNING.getCode());
@@ -487,12 +488,29 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR"); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
} }
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO(); ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
if (fluxTask){ if (nanoBananaTask){
if (childFlag){ if (childFlag){
sb.append(", Children's face"); sb.append(", Children's face");
} }
taskId = generateService.flux(CreditsEventsEnum.TO_PRODUCT_IMAGE_FLUX, sb.toString(), tDesignPythonOutfit.getDesignUrl(), childFlag); // 使用Google nanobanana模型
toProductImageResult.setModelName("flux"); GenerateThroughImageTextDTO generateDTO = new GenerateThroughImageTextDTO();
generateDTO.setUserId(userHolder.getId());
generateDTO.setLevel1Type("Product");
generateDTO.setLevel2Type("ToProduct");
generateDTO.setGender("unisex");
generateDTO.setCollectionElementId(tDesignPythonOutfit.getId());
generateDTO.setDesignType("DesignOutfit");
try {
//使用nano banana用这个提示词
String nanoPrompt = "Change the input image to the real image. Full length portrait, match the clothing size, clothing style, " +
"patterns, and fabric texture from the reference image, replicate garment design details precisely, " +
"maintain original color scheme, high fidelity to reference attire, realistic lighting, detailed fabric rendering.";
taskId = generateService.createGoogleAsyncTask(generateDTO, ModelConstants.NANO_BANANA, nanoPrompt);
} catch (Exception e) {
log.error("Google nanobanana generation failed", e);
throw new BusinessException("Generation failed, please try again");
}
toProductImageResult.setModelName("nanobanana");
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue()); toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
} else { } else {
// 走模型 // 走模型
@@ -547,9 +565,26 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
ToProductImageResultVO toProductImageResult = new ToProductImageResultVO(); ToProductImageResultVO toProductImageResult = new ToProductImageResultVO();
if (fluxTask){ if (nanoBananaTask){
taskId = generateService.flux(creditsEventsEnum, sb.toString(), toProductElement.getUrl(), childFlag); // 使用Google nanobanana模型
toProductImageResult.setModelName("flux"); GenerateThroughImageTextDTO generateDTO = new GenerateThroughImageTextDTO();
generateDTO.setUserId(userHolder.getId());
generateDTO.setLevel1Type("Product");
generateDTO.setLevel2Type("ToProduct");
generateDTO.setGender("unisex");
generateDTO.setCollectionElementId(toProductElement.getId());
generateDTO.setDesignType("ProductElement");
try {
//使用nano banana用这个提示词
String nanoPrompt = "Change the input image to the real image. Full length portrait, match the clothing size, clothing style, " +
"patterns, and fabric texture from the reference image, replicate garment design details precisely, " +
"maintain original color scheme, high fidelity to reference attire, realistic lighting, detailed fabric rendering.";
taskId = generateService.createGoogleAsyncTask(generateDTO, ModelConstants.NANO_BANANA, nanoPrompt);
} catch (Exception e) {
log.error("Google nanobanana generation failed", e);
throw new BusinessException("Generation failed, please try again");
}
toProductImageResult.setModelName("nanobanana");
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue()); toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
} else { } else {
// 走模型 // 走模型
@@ -2533,6 +2568,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()); collectionElement.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
collectionElement.setLevel2Type(board.getLevel2Type()); collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setLevel3Type(workspaceService.getProjectSexById(projectId));
collectionElement.setName(library.getName()); collectionElement.setName(library.getName());
collectionElement.setUrl(library.getUrl()); collectionElement.setUrl(library.getUrl());
collectionElement.setHasPin(board.getIsPin()); collectionElement.setHasPin(board.getIsPin());
@@ -2546,6 +2582,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()); collectionElement.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
collectionElement.setLevel2Type(board.getLevel2Type()); collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setLevel3Type(workspaceService.getProjectSexById(projectId));
// collectionElement.setName(generateDetail.get()); // collectionElement.setName(generateDetail.get());
collectionElement.setUrl(generateDetail.getUrl()); collectionElement.setUrl(generateDetail.getUrl());
collectionElement.setHasPin(board.getIsPin()); collectionElement.setHasPin(board.getIsPin());
@@ -2566,6 +2603,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElement.setLevel2Type(board.getLevel2Type()); collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setHasPin(board.getIsPin()); collectionElement.setHasPin(board.getIsPin());
collectionElement.setUpdateDate(new Date()); collectionElement.setUpdateDate(new Date());
if (CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName().equals(collectionElement.getLevel1Type())){
collectionElement.setLevel3Type(workspaceService.getProjectSexById(project.getId()));
}
collectionElementMapper.updateById(collectionElement); collectionElementMapper.updateById(collectionElement);
} }
} }
@@ -2675,6 +2715,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElement.setAccountId(accountId); collectionElement.setAccountId(accountId);
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName()); collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
collectionElement.setLevel3Type(workspaceService.getProjectSexById(project.getId()));
// collectionElement.setLevel2Type(board.getLevel2Type()); // collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setName(sysFile.getName()); collectionElement.setName(sysFile.getName());
collectionElement.setUrl(sysFile.getUrl()); collectionElement.setUrl(sysFile.getUrl());
@@ -2695,6 +2736,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElement.setAccountId(accountId); collectionElement.setAccountId(accountId);
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName()); collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
collectionElement.setLevel3Type(workspaceService.getProjectSexById(project.getId()));
// collectionElement.setLevel2Type(board.getLevel2Type()); // collectionElement.setLevel2Type(board.getLevel2Type());
collectionElement.setName(library.getName()); collectionElement.setName(library.getName());
collectionElement.setUrl(library.getUrl()); collectionElement.setUrl(library.getUrl());

View File

@@ -3,6 +3,7 @@ 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.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CollectionLevel1TypeEnum; import com.ai.da.common.enums.CollectionLevel1TypeEnum;
import com.ai.da.common.enums.CollectionLevel2TypeEnum;
import com.ai.da.common.enums.LibraryLevel1TypeEnum; import com.ai.da.common.enums.LibraryLevel1TypeEnum;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.ResultEnum; import com.ai.da.common.response.ResultEnum;
@@ -16,6 +17,7 @@ import com.ai.da.model.enums.*;
import com.ai.da.model.vo.*; import com.ai.da.model.vo.*;
import com.ai.da.service.SysFileService; import com.ai.da.service.SysFileService;
import com.ai.da.service.WorkspaceService; import com.ai.da.service.WorkspaceService;
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 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;
@@ -717,27 +719,36 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
if (projectDTO.getProcess().equals(DesignProcess.SERIES_DESIGN.name()) || projectDTO.getProcess().equals(DesignProcess.SKETCH_COLLAGE_PROCESS.name())) { if (projectDTO.getProcess().equals(DesignProcess.SERIES_DESIGN.name()) || projectDTO.getProcess().equals(DesignProcess.SKETCH_COLLAGE_PROCESS.name())) {
if (!workspaceNew.getAgeGroup().equals(workspace.getAgeGroup()) || !workspaceNew.getSex().equals(workspace.getSex())) { if (!workspaceNew.getAgeGroup().equals(workspace.getAgeGroup()) || !workspaceNew.getSex().equals(workspace.getSex())) {
// 性别变更 清理sketch及模特 // 性别变更 清理sketch及模特
deleteMannequinByProjectId(projectId); // deleteMannequinByProjectId(projectId);
if (!workspaceNew.getSex().equals(workspace.getSex())) { if (!workspaceNew.getSex().equals(workspace.getSex())) {
deleteSketchByProjectId(projectId); // deleteSketchByProjectId(projectId);
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId)
.eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName())
.eq(CollectionElement::getLevel3Type, workspaceNew.getSex());
if (collectionElementMapper.selectCount(queryWrapper) == 0){
SysFile sysFile = sysFileService.getOneBySex(projectDTO.getStyleId(), projectDTO.getWorkspace().getSex(), projectDTO.getWorkspace().getAgeGroup());
CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(userInfo.getId());
collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
collectionElement.setLevel3Type(projectDTO.getWorkspace().getSex());
collectionElement.setName(sysFile.getName());
collectionElement.setUrl(sysFile.getUrl());
collectionElement.setMd5(sysFile.getMd5());
collectionElement.setCreateDate(new Date());
collectionElement.setHasPin((byte) 0);
collectionElementMapper.insert(collectionElement);
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
collectionElementRelModel.setRelationId(sysFile.getId());
collectionElementRelModel.setRelationType("System");
collectionElementRelModelMapper.insert(collectionElementRelModel);
}
} }
} }
SysFile sysFile = sysFileService.getOneBySex(projectDTO.getStyleId(), projectDTO.getWorkspace().getSex(), projectDTO.getWorkspace().getAgeGroup());
CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(userInfo.getId());
collectionElement.setProjectId(projectId);
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MODEL.getRealName());
collectionElement.setName(sysFile.getName());
collectionElement.setUrl(sysFile.getUrl());
collectionElement.setMd5(sysFile.getMd5());
collectionElement.setCreateDate(new Date());
collectionElement.setHasPin((byte) 0);
collectionElementMapper.insert(collectionElement);
CollectionElementRelModel collectionElementRelModel = new CollectionElementRelModel();
collectionElementRelModel.setCollectionElementId(collectionElement.getId());
collectionElementRelModel.setRelationId(sysFile.getId());
collectionElementRelModel.setRelationType("System");
collectionElementRelModelMapper.insert(collectionElementRelModel);
} }
workspaceNew.setId(workspace.getId()); workspaceNew.setId(workspace.getId());
workspace.setUpdateTime(LocalDateTime.now()); workspace.setUpdateTime(LocalDateTime.now());
@@ -857,6 +868,17 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return workspaceList.get(0).getId(); return workspaceList.get(0).getId();
} }
@Override
public String getProjectSexById(Long projectId) {
LambdaQueryWrapper<Workspace> workspaceLambdaQueryWrapper = new LambdaQueryWrapper<>();
workspaceLambdaQueryWrapper.eq(Workspace::getProjectId, projectId).select(Workspace::getSex);
Workspace workspace = workspaceMapper.selectOne(workspaceLambdaQueryWrapper);
if (workspace != null) {
return workspace.getSex();
}
return null;
}
public static List<File> getPNGFiles(String directoryPath) { public static List<File> getPNGFiles(String directoryPath) {
List<File> pngFiles = new ArrayList<>(); List<File> pngFiles = new ArrayList<>();
File directory = new File(directoryPath); File directory = new File(directoryPath);

View File

@@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "aida-461108",
"private_key_id": "b4afaabebb84da24502b318a5fa175f1dc5c096a",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCmk7LKrp8g9yD1\nWmF+mY2qHCEZ/5aIx6QRh0QoVPBL7Yi7ce009QxaE8fu8+QMgg8l3xMreXvgpt56\noFnVwpFusLjSdjgoFluElM2hYxXlO9q8cbBoU2nehOBLLJzGzkodT7xu/BOjNvKC\n//aTbjtJyk8Kj+ENa0/dPaUZs/PCtQqpAu8ag5nXrordVWfO0K25EjeYyoba35zk\nPp2fBi8KALZZI5Xfd2z9++K0K2mWWIMJic30idHvquj0WxlTRK2Pq8BmJXCQpJIi\nQ5E4egue16BfKjrF0Kxkpqd1RmdlEmaSKbbkZXe2z4jg0qknESRFOmRy8C3LnaB2\nHHJWLYM3AgMBAAECggEACUdroOQJSTTQSS/iWRhZ+S0yoC10nTnsZxg527qfiBs7\nOqB7WNqC+Ew8dDsca6CdvLuoaGDkCFJDTQwRn66u8JOM4sG4bxiPuzBEJBv45EQT\n8zCsuvhVNWgBdoPjAnq19jFdixvPnDqQrRYaY4FdxsaA5f24c57pW/xLGMYawLBt\n9RJZSuWmJdzKG1i5W8a8+4f/seNtuo2MtXU3mPJZPqRWPXTAZeaQPM/57ZQ+kzig\nOkAbQZNRmt1yPCjPCQD8vc8yCBMmjus/rlHXD/L7okYUlVZkob5I3FBrLl+ZyIXS\nqxEsBLBwRW3w8WbX+ZSVciQ72JK68W7LnOHSAENmAQKBgQDgBTCqp87KGLWVPb8w\nK+s1Sfh+nM3M4AlbLdcGBs1JCoddF6pAeY4wpf/ow1Tm4rqEuCYzMClPwxvkue+D\nY7lCQgy2FK3ahUzn8oVmvEPD/YPAojDSY3bH0lquHuS6oVKk834JUykButaAU3XY\nvUGNQuKdLKAeQRT8Q6um4m+EYQKBgQC+Wz6nYESKH6GiNnuFTH8hIkThPlbi4wua\nU1kGnPKe3ouE4zRLfPwQ6RRf1slQ/2hFLOatiTLYUgZWZQeBPSWp2EjYcOSzob+7\n11+KqeIRCD5DKxgf0cjJdihK9AM639OKlH2NvZ2507TksdeTPDzdaOMLwLWKexP5\nlYrdob0ulwKBgD81t7Gvf83Ogw4FSjkRa2Cx6ofvPrKcVIeBu7ZbnPkLG37M+qEO\nq2xWqorG8uHi/7YLL9wprr5u0yQKwuZT8SYc9PE7jIKoMjcQW0vNu2FF2zMzkIsM\nvatMU4Hl/awbcPJSMjH3YQ635WZ4Jjxtyl1NjhvDR7rBqmYzwe9o3QaBAoGANhPB\n1tbYYczepDCKIrI6o3US0FJfaJFLqInpDqHjoxJh3FyXbKKTEVLFwPxJsML+IjjB\nR6dkVGPo/P4yhZqTao7REvvvXMCksX5b3A6q9F+9IGPLtK5qNiFlDPYJPN59QC8z\nA+NMPZBRIW8MaP2B5Px5E8upRy/z2sGK86+RCP0CgYATGs75F97q+Zf8q+Pe3Nsb\ngqmhLoI3PZUSWgBcQgNF4nyCZceUrEl72wKO/NWLgxqQPtlra187ce69g7qARHLb\ntHq80nb0f7lil74B6+OlyNNO1htWA90fmGR2s16Mt0BwJRT+/EFuNqbJIUSLxKiW\nqlXBUbmHHzamo5DPYL8S/w==\n-----END PRIVATE KEY-----\n",
"client_email": "aida-239@aida-461108.iam.gserviceaccount.com",
"client_id": "103102077955178349079",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/aida-239%40aida-461108.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}

View File

@@ -38,7 +38,7 @@
<!-- 批量查询模块内容使用JOIN优化避免N+1查询 --> <!-- 批量查询模块内容使用JOIN优化避免N+1查询 -->
<select id="getModuleContentBatch" resultType="java.util.Map"> <select id="getModuleContentBatch" resultType="java.util.Map">
SELECT SELECT
cs.id as sort_id, cs.id as sort_id,
cs.parent_id, cs.parent_id,
cs.relation_id, cs.relation_id,
@@ -92,7 +92,7 @@
<!-- 批量查询ToProductImageResult及相关数据 --> <!-- 批量查询ToProductImageResult及相关数据 -->
<select id="getToProductImageResultBatch" resultType="java.util.Map"> <select id="getToProductImageResultBatch" resultType="java.util.Map">
SELECT SELECT
tpir.id, tpir.id,
tpir.url, tpir.url,
tpir.element_type, tpir.element_type,
@@ -119,7 +119,7 @@
<!-- 批量查询UserLike及相关设计数据 --> <!-- 批量查询UserLike及相关设计数据 -->
<select id="getUserLikeBatch" resultType="java.util.Map"> <select id="getUserLikeBatch" resultType="java.util.Map">
SELECT SELECT
ul.id, ul.id,
ul.design_item_id, ul.design_item_id,
ul.design_outfit_id, ul.design_outfit_id,
@@ -139,7 +139,7 @@
<!-- 批量查询ToProductElement数据 --> <!-- 批量查询ToProductElement数据 -->
<select id="getToProductElementBatch" resultType="java.util.Map"> <select id="getToProductElementBatch" resultType="java.util.Map">
SELECT SELECT
id, id,
url, url,
project_id, project_id,
@@ -154,7 +154,7 @@
<!-- 批量查询design模块的python outfit数据 --> <!-- 批量查询design模块的python outfit数据 -->
<select id="getDesignPythonOutfitBatch" resultType="java.util.Map"> <select id="getDesignPythonOutfitBatch" resultType="java.util.Map">
SELECT SELECT
tpo.id as outfit_id, tpo.id as outfit_id,
tpo.parent_id, tpo.parent_id,
tpo.url as outfit_url, tpo.url as outfit_url,
@@ -163,7 +163,7 @@
cs.id as sort_id cs.id as sort_id
FROM t_design_python_outfit tpo FROM t_design_python_outfit tpo
LEFT JOIN collection_sort cs ON cs.relation_id = tpo.id AND cs.relation_type = 'DesignPythonOutfit' LEFT JOIN collection_sort cs ON cs.relation_id = tpo.id AND cs.relation_type = 'DesignPythonOutfit'
WHERE tpo.parent_id IN WHERE tpo.parent_id IN
<foreach collection="outfitIds" item="outfitId" open="(" close=")" separator=","> <foreach collection="outfitIds" item="outfitId" open="(" close=")" separator=",">
#{outfitId} #{outfitId}
</foreach> </foreach>
@@ -172,11 +172,11 @@
<!-- 批量查询ToProductImageRecord数据 --> <!-- 批量查询ToProductImageRecord数据 -->
<select id="getToProductImageRecordBatch" resultType="java.util.Map"> <select id="getToProductImageRecordBatch" resultType="java.util.Map">
SELECT SELECT
id as record_id, id as record_id,
prompt prompt
FROM to_product_image_record FROM to_product_image_record
WHERE id IN WHERE id IN
<foreach collection="recordIds" item="recordId" open="(" close=")" separator=","> <foreach collection="recordIds" item="recordId" open="(" close=")" separator=",">
#{recordId} #{recordId}
</foreach> </foreach>