TASK:AiDA模块化
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,9 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.python.vo.DesignPythonObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@@ -8,6 +12,8 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -279,6 +285,77 @@ public class RedisUtil {
|
||||
redisTemplate.expire(redisKey, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public void addPathToCache(Long collectionId, Long userId, String path) {
|
||||
// Redis 中的键,唯一标识由 collectionId 和 userId 组成
|
||||
String redisKey = "path:cache:" + collectionId + ":" + userId;
|
||||
|
||||
// 增加路径的计数
|
||||
redisTemplate.opsForHash().increment(redisKey, path, 1);
|
||||
|
||||
// 设置过期时间为 2 小时(7200 秒)
|
||||
redisTemplate.expire(redisKey, 8, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
public int getPathUsageCount(Long collectionId, Long userId, String path) {
|
||||
String redisKey = "path:cache:" + collectionId + ":" + userId;
|
||||
|
||||
// 获取路径的使用次数
|
||||
Object count = redisTemplate.opsForHash().get(redisKey, path);
|
||||
return count != null ? Integer.parseInt(count.toString()) : 0;
|
||||
}
|
||||
|
||||
public void addAssembledObjects(Long collectionId, Set<DesignPythonObject> assembledObjects) {
|
||||
// Redis 中的键,使用 collectionId 来唯一标识
|
||||
String redisKey = "collection:assembledObjects:" + collectionId;
|
||||
|
||||
// 将 assembledObjects 转换为 JSON 格式存储,避免直接存储对象
|
||||
String assembledObjectsJson = convertToJson(assembledObjects);
|
||||
|
||||
// 使用 Redis 的 set 操作更新集合
|
||||
redisTemplate.opsForValue().set(redisKey, assembledObjectsJson);
|
||||
|
||||
// 设置过期时间为 5 分钟(300 秒)
|
||||
redisTemplate.expire(redisKey, 30, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
// 将 Set<DesignPythonObject> 转换为 JSON 格式
|
||||
private String convertToJson(Set<DesignPythonObject> assembledObjects) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.writeValueAsString(assembledObjects);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<DesignPythonObject> getAssembledObjects(Long collectionId) {
|
||||
// Redis 中的键,使用 collectionId 来唯一标识
|
||||
String redisKey = "collection:assembledObjects:" + collectionId;
|
||||
|
||||
// 从 Redis 获取存储的 JSON 字符串
|
||||
String assembledObjectsJson = (String) redisTemplate.opsForValue().get(redisKey);
|
||||
|
||||
if (assembledObjectsJson == null) {
|
||||
return new HashSet<>(); // 如果没有找到数据,返回一个空的 Set
|
||||
}
|
||||
|
||||
// 将 JSON 字符串转换为 Set<DesignPythonObject>
|
||||
return convertFromJson(assembledObjectsJson);
|
||||
}
|
||||
|
||||
// 将 JSON 字符串转换为 Set<DesignPythonObject>
|
||||
private Set<DesignPythonObject> convertFromJson(String json) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 使用 TypeReference 来指定目标类型是 Set<DesignPythonObject>
|
||||
return objectMapper.readValue(json, new TypeReference<Set<DesignPythonObject>>() {});
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return new HashSet<>(); // 如果转换失败,返回空的 Set
|
||||
}
|
||||
}
|
||||
|
||||
public final static String PAYMENT_INFO_LAST_SCAN_TIME = "PaymentInfoLastScanTime";
|
||||
|
||||
public final static String AFFILIATE_LINK_VIEW_KEY = "AffiliateLink:view:";
|
||||
@@ -293,13 +370,126 @@ public class RedisUtil {
|
||||
return redisTemplate.opsForValue().increment(key, 0);
|
||||
}
|
||||
|
||||
public void batchDeleteKeysWithSamePrefix(String prefix){
|
||||
Set<String> keys = redisTemplate.keys(prefix + "*");
|
||||
assert keys != null;
|
||||
if (!keys.isEmpty()){
|
||||
redisTemplate.delete(keys);
|
||||
/**
|
||||
* 记录任务的耗时到Redis
|
||||
* @param taskKey 任务标识,如 "taskA"
|
||||
* @param elapsedTime 本次耗时,单位为毫秒
|
||||
*/
|
||||
public void recordTaskElapsedTime(String taskKey, long elapsedTime) {
|
||||
String hashKey = "task:stats";
|
||||
|
||||
// 累加总耗时
|
||||
redisTemplate.opsForHash().increment(hashKey, taskKey + ":totalTime", elapsedTime);
|
||||
|
||||
// 增加计数器
|
||||
redisTemplate.opsForHash().increment(hashKey, taskKey + ":count", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务的平均耗时
|
||||
* @param taskKey 任务标识,如 "taskA"
|
||||
* @return 平均耗时(毫秒)
|
||||
*/
|
||||
public double getTaskAverageTime(String taskKey) {
|
||||
String hashKey = "task:stats";
|
||||
|
||||
// 获取总耗时和计数
|
||||
Object totalTime = redisTemplate.opsForHash().get(hashKey, taskKey + ":totalTime");
|
||||
Object count = redisTemplate.opsForHash().get(hashKey, taskKey + ":count");
|
||||
|
||||
// 计算平均值
|
||||
if (totalTime == null || count == null) {
|
||||
return 0;
|
||||
}
|
||||
return Double.parseDouble(totalTime.toString()) / Long.parseLong(count.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除指定任务的统计数据
|
||||
* @param taskKey 任务标识,如 "taskA"
|
||||
*/
|
||||
public void clearTaskStats(String taskKey) {
|
||||
String hashKey = "task:stats";
|
||||
|
||||
// 删除总耗时和计数器
|
||||
redisTemplate.opsForHash().delete(hashKey, taskKey + ":totalTime", taskKey + ":count");
|
||||
}
|
||||
|
||||
public void recordTaskElapsedTime(String taskKey, double elapsedTimeInSeconds) {
|
||||
// 将耗时转换为 BigDecimal,并四舍五入保留四位小数
|
||||
BigDecimal elapsedTime = new BigDecimal(elapsedTimeInSeconds).setScale(4, RoundingMode.HALF_UP);
|
||||
|
||||
// 累加总耗时(以毫秒为单位)
|
||||
redisTemplate.opsForHash().increment("task:stats", taskKey + ":totalTime", elapsedTime.doubleValue());
|
||||
|
||||
// 增加计数器
|
||||
redisTemplate.opsForHash().increment("task:stats", taskKey + ":count", 1);
|
||||
}
|
||||
|
||||
// 获取第一部分(Sketch)耗时
|
||||
public double getFirstSketchTime() {
|
||||
// 获取 "firstSketchTime:totalTime" 对应的值,并返回(单位为秒)
|
||||
Object time = redisTemplate.opsForHash().get("task:stats", "firstSketchTime:totalTime");
|
||||
return time != null ? (double) time : 0.0;
|
||||
}
|
||||
|
||||
// 获取第二部分(获取特征值)耗时
|
||||
public double getGetAttributeRecognitionTime() {
|
||||
// 获取 "getAttributeRecognitionTime:totalTime" 对应的值,并返回(单位为秒)
|
||||
Object time = redisTemplate.opsForHash().get("task:stats", "getAttributeRecognitionTime:totalTime");
|
||||
return time != null ? (double) time : 0.0;
|
||||
}
|
||||
|
||||
// 获取第三部分(搭配 Sketch)耗时
|
||||
public double getOtherSketchTime() {
|
||||
// 获取 "otherSketchTime:totalTime" 对应的值,并返回(单位为秒)
|
||||
Object time = redisTemplate.opsForHash().get("task:stats", "otherSketchTime:totalTime");
|
||||
return time != null ? (double) time : 0.0;
|
||||
}
|
||||
|
||||
// 清理三部分的缓存
|
||||
public void clearTaskElapsedTimeCache() {
|
||||
// 删除第一部分的缓存
|
||||
redisTemplate.opsForHash().delete("task:stats", "firstSketchTime:totalTime");
|
||||
redisTemplate.opsForHash().delete("task:stats", "firstSketchTime:count");
|
||||
|
||||
// 删除第二部分的缓存
|
||||
redisTemplate.opsForHash().delete("task:stats", "getAttributeRecognitionTime:totalTime");
|
||||
redisTemplate.opsForHash().delete("task:stats", "getAttributeRecognitionTime:count");
|
||||
|
||||
// 删除第三部分的缓存
|
||||
redisTemplate.opsForHash().delete("task:stats", "otherSketchTime:totalTime");
|
||||
redisTemplate.opsForHash().delete("task:stats", "otherSketchTime:count");
|
||||
}
|
||||
|
||||
public boolean incrementLikeCount(Long userId, String sketchPath) {
|
||||
String redisKey = "user_like_count:" + userId;
|
||||
try {
|
||||
redisTemplate.opsForHash().increment(redisKey, sketchPath, 1);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("Error incrementing like count for userId {} and sketchPath {}: {}", userId, sketchPath, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLikeCount(Long userId, String sketchPath) {
|
||||
String redisKey = "user_like_count:" + userId;
|
||||
Object count = redisTemplate.opsForHash().get(redisKey, sketchPath);
|
||||
return count != null ? Integer.parseInt(count.toString()) : 0;
|
||||
}
|
||||
|
||||
public void storeMaxLikeCount(Long userId, int maxLikeCount) {
|
||||
String redisKey = "user_max_like_count:" + userId;
|
||||
redisTemplate.opsForValue().set(redisKey, String.valueOf(maxLikeCount));
|
||||
}
|
||||
|
||||
public int getMaxLikeCount(Long userId) {
|
||||
String redisKey = "user_max_like_count:" + userId;
|
||||
String maxLikeCount = redisTemplate.opsForValue().get(redisKey);
|
||||
return maxLikeCount != null ? Integer.parseInt(maxLikeCount) : 0;
|
||||
}
|
||||
|
||||
|
||||
public final static String STRIPE_EXCEPTION_LOG = "StripeException:";
|
||||
}
|
||||
|
||||
83
src/main/java/com/ai/da/controller/ProjectController.java
Normal file
83
src/main/java/com/ai/da/controller/ProjectController.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.ModuleSaveDTO;
|
||||
import com.ai.da.model.dto.ProjectDTO;
|
||||
import com.ai.da.model.dto.ProjectQueryDTO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.UserLikeGroupService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(tags = "Project模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/project")
|
||||
public class ProjectController {
|
||||
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "新增或编辑", notes = "传入project")
|
||||
public Response<Long> saveOrUpdateProject(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
return Response.success(workspaceService.saveOrUpdateProject(projectDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/page")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperation(value = "分页查询", notes = "传入project")
|
||||
public Response<PageBaseResponse<ProjectVO>> page(@Valid @RequestBody ProjectQueryDTO projectQueryDTO) {
|
||||
return Response.success(PageBaseResponse.success(userLikeGroupService.getPage(projectQueryDTO)));
|
||||
}
|
||||
|
||||
// @PostMapping("/detail")
|
||||
// @ApiOperationSupport(order = 3)
|
||||
// @ApiOperation(value = "详情", notes = "传入project")
|
||||
// public Response saveOrUpdateProject(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
// return Response.success(workspaceService.saveOrUpdateProject(projectDTO));
|
||||
// }
|
||||
//
|
||||
@PostMapping("/choose")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperation(value = "选择", notes = "传入project")
|
||||
public Response<ProjectChooseVO> choose(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
return Response.success(userLikeGroupService.choose(projectDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/getModuleContent")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperation(value = "获取模块内容", notes = "传入project")
|
||||
public Response<ModuleChooseVO> getModuleContent(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
return Response.success(userLikeGroupService.getModuleContent(projectDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/saveModuleContent")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "存储模块内容", notes = "传入project")
|
||||
public Response<ModuleChooseVO> saveModuleContent(@Valid @RequestBody ModuleSaveDTO moduleSaveDTO) {
|
||||
return Response.success(userLikeGroupService.saveModuleContent(moduleSaveDTO));
|
||||
}
|
||||
//
|
||||
// @PostMapping("/delete")
|
||||
// @ApiOperationSupport(order = 5)
|
||||
// @ApiOperation(value = "删除", notes = "传入project")
|
||||
// public Response saveOrUpdateProject(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
// return Response.success(workspaceService.saveOrUpdateProject(projectDTO));
|
||||
// }
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.controller;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.dto.ProjectDTO;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
@@ -131,4 +132,11 @@ public class WorkspaceController {
|
||||
public Response<List<StyleVO>> styleList() {
|
||||
return Response.success(workspaceService.styleList());
|
||||
}
|
||||
|
||||
@PostMapping("/saveOrUpdateProject")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "新增或编辑", notes = "传入project")
|
||||
public Response saveOrUpdateProject(@Valid @RequestBody ProjectDTO projectDTO) {
|
||||
return Response.success(workspaceService.saveOrUpdateProject(projectDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -11,4 +13,5 @@ import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
*/
|
||||
public interface CollectionElementMapper extends CommonMapper<CollectionElement> {
|
||||
|
||||
List<CollectionElement> selectDeleteList();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -12,4 +14,6 @@ import com.ai.da.mapper.primary.entity.Collection;
|
||||
public interface CollectionMapper extends CommonMapper<Collection> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertCollection(Collection collection);
|
||||
|
||||
List<Collection> selectDeleteList();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.DesignItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -12,4 +14,6 @@ import com.ai.da.mapper.primary.entity.DesignItem;
|
||||
public interface DesignItemMapper extends CommonMapper<DesignItem> {
|
||||
|
||||
Long insertDesignItem(DesignItem designItem);
|
||||
|
||||
List<DesignItem> selectDeleteList();
|
||||
}
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface DesignMapper extends CommonMapper<Design> {
|
||||
Long insertDesign(Design design);
|
||||
|
||||
List<UserDesignStatisticDTO> getDesignStatistic(String startTime, String endTime, List<Long> ids, String email);
|
||||
|
||||
List<Design> selectDeleteList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Project;
|
||||
|
||||
public interface ProjectMapper extends CommonMapper<Project> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.SketchData;
|
||||
|
||||
public interface SketchDataMapper extends CommonMapper<SketchData> {
|
||||
}
|
||||
@@ -29,4 +29,5 @@ public interface TDesignPythonOutfitDetailMapper extends CommonMapper<TDesignPyt
|
||||
@Delete("DELETE FROM t_design_python_outfit_detail WHERE design_python_outfit_id = #{designPythonOutfitId}")
|
||||
void deleteByDesignPythonOutfitIdPhysical(@Param("designPythonOutfitId") Long designPythonOutfitId);
|
||||
|
||||
List<TDesignPythonOutfitDetail> selectListDelete();
|
||||
}
|
||||
|
||||
@@ -25,4 +25,5 @@ public interface TDesignPythonOutfitMapper extends CommonMapper<TDesignPythonOut
|
||||
*/
|
||||
List<TDesignPythonOutfitVO> selectTDesignPythonOutfitPage(IPage page, TDesignPythonOutfitVO tDesignPythonOutfit);
|
||||
|
||||
List<TDesignPythonOutfit> selectListDelete();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -12,4 +14,6 @@ import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
public interface UserLikeGroupMapper extends CommonMapper<UserLikeGroup> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertUserLikeGroup(UserLikeGroup userLikeGroup);
|
||||
|
||||
List<UserLikeGroup> getMoreThan50UserLikeAccount();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserPreferenceLogTest;
|
||||
|
||||
public interface UserPreferenceLogMapper extends CommonMapper<UserPreferenceLogTest> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserPreferenceLogPrediction;
|
||||
import com.ai.da.mapper.primary.entity.UserPreferenceLogTest;
|
||||
|
||||
public interface UserPreferenceLogPredictionMapper extends CommonMapper<UserPreferenceLogPrediction> {
|
||||
}
|
||||
@@ -86,4 +86,6 @@ public class CollectionElement implements Serializable {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateDate;
|
||||
|
||||
private Long projectId;
|
||||
}
|
||||
|
||||
35
src/main/java/com/ai/da/mapper/primary/entity/Project.java
Normal file
35
src/main/java/com/ai/da/mapper/primary/entity/Project.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("project")
|
||||
public class Project implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long accountId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String process;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("sketch_data")
|
||||
public class SketchData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long accountId;
|
||||
private Long collectionId;
|
||||
private String path;
|
||||
private int type;//1 旧算法 2新算法
|
||||
}
|
||||
@@ -58,4 +58,6 @@ public class UserLikeGroup implements Serializable {
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateDate;
|
||||
|
||||
private Long projectId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("user_preference_log_prediction")
|
||||
public class UserPreferenceLogPrediction implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long userLikeGroupId;
|
||||
private Long accountId;
|
||||
private String path;
|
||||
private LocalDateTime dataTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("user_preference_log_test")
|
||||
public class UserPreferenceLogTest implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
private Long userLikeGroupId;
|
||||
private Long accountId;
|
||||
private String path;
|
||||
private LocalDateTime dataTime;
|
||||
|
||||
}
|
||||
@@ -97,5 +97,7 @@ public class Workspace implements Serializable {
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
private Integer isDeleted;
|
||||
|
||||
private Long projectId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
36
src/main/java/com/ai/da/model/dto/ModuleSaveDTO.java
Normal file
36
src/main/java/com/ai/da/model/dto/ModuleSaveDTO.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.model.vo.CollectionColorVO;
|
||||
import com.ai.da.model.vo.CollectionElementVO;
|
||||
import com.ai.da.model.vo.MoodBoardModuleChooseVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ModuleSaveDTO {
|
||||
private Long projectId;
|
||||
|
||||
private MoodBoardModuleSaveDTO moodBoard;
|
||||
|
||||
@ApiModelProperty("印花板图片 数组")
|
||||
private List<DesignCollectionPrintElementDTO> printBoard;
|
||||
|
||||
@NotEmpty(message = "colorBoards.cannot.be.empty")
|
||||
@ApiModelProperty("颜色板RGB值 数组")
|
||||
private List<CollectionColorDTO> colorBoard;
|
||||
|
||||
@ApiModelProperty("手稿板图片id 数组")
|
||||
private List<CollectionSketchDTO> sketchBoard;
|
||||
|
||||
// private MoodBoardModuleChooseVO moodBoard;
|
||||
// private List<CollectionElementVO> printBoard;
|
||||
// private List<CollectionColorVO> colorBoard;
|
||||
// private List<CollectionElementVO> sketchBoard;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MoodBoardModuleSaveDTO {
|
||||
private List<DesignCollectionElementDTO> moodBoards;
|
||||
|
||||
private Long moodTemplateId;
|
||||
|
||||
private String moodboardPosition;
|
||||
}
|
||||
29
src/main/java/com/ai/da/model/dto/ProjectDTO.java
Normal file
29
src/main/java/com/ai/da/model/dto/ProjectDTO.java
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Project;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-08-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProjectDTO extends Project {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long styleId;
|
||||
|
||||
// private String process;
|
||||
|
||||
private Workspace workspace;
|
||||
|
||||
private List<String> moduleList;
|
||||
}
|
||||
37
src/main/java/com/ai/da/model/dto/ProjectQueryDTO.java
Normal file
37
src/main/java/com/ai/da/model/dto/ProjectQueryDTO.java
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Project;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.vo.PageQueryBaseVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author SHAHAIBO
|
||||
* @since 2023-08-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProjectQueryDTO extends PageQueryBaseVo {
|
||||
|
||||
@ApiModelProperty("项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty("开始时间 时间戳")
|
||||
private Long startDate;
|
||||
|
||||
@ApiModelProperty("开始时间 时间戳")
|
||||
private Long endDate;
|
||||
|
||||
private List<Long> classificationIdList;
|
||||
|
||||
@ApiModelProperty("1交集2并集")
|
||||
private Integer intersection;
|
||||
}
|
||||
@@ -19,4 +19,5 @@ public class WorkspaceSaveDTO extends Workspace {
|
||||
|
||||
private Long styleId;
|
||||
|
||||
private String process;
|
||||
}
|
||||
|
||||
34
src/main/java/com/ai/da/model/enums/DesignProcess.java
Normal file
34
src/main/java/com/ai/da/model/enums/DesignProcess.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum DesignProcess implements IEnumDisplay {
|
||||
|
||||
SERIES_DESIGN("Series design"),
|
||||
SINGLE_DESIGN("Single design"),
|
||||
FINISHED_PRODUCT("Finished product"),
|
||||
PRINT_DESIGN("Print design"),
|
||||
SKETCH_COLLAGE_PROCESS("Sketch Collage process"),
|
||||
THREE_D_PLATE_MAKING("3D plate making");
|
||||
|
||||
private final String value;
|
||||
|
||||
DesignProcess(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static DesignProcess getProcess(String value) {
|
||||
for (DesignProcess process : values()) {
|
||||
if (process.value.equalsIgnoreCase(value)) {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/ai/da/model/enums/Module.java
Normal file
39
src/main/java/com/ai/da/model/enums/Module.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.ai.da.model.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum Module implements IEnumDisplay {
|
||||
moodBoard("MoodBoard"),
|
||||
printBoard("PrintBoard"),
|
||||
colorBoard("ColorBoard"),
|
||||
sketchBoard("SketchBoard"),
|
||||
mannequin("Mannequin"),
|
||||
design("Design"),
|
||||
toProduct("To Product"),
|
||||
relight("Relight"),
|
||||
poseTransfer("Pose Transfer"),
|
||||
canvas("Canvas"),
|
||||
patternMaking3D("3D Pattern Making"),
|
||||
deReconstruction("De/Reconstruction");
|
||||
|
||||
private final String value;
|
||||
|
||||
Module(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static Module getName(String value) {
|
||||
for (Module module : values()) {
|
||||
if (module.value.equalsIgnoreCase(value)) {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching constant for [" + value + "]");
|
||||
}
|
||||
}
|
||||
14
src/main/java/com/ai/da/model/vo/CavasModuleChooseVO.java
Normal file
14
src/main/java/com/ai/da/model/vo/CavasModuleChooseVO.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.model.dto.PortfolioDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CavasModuleChooseVO {
|
||||
private PortfolioDTO portfolioDTO;
|
||||
private Integer beenPublished;
|
||||
}
|
||||
17
src/main/java/com/ai/da/model/vo/DesignModuleChooseVO.java
Normal file
17
src/main/java/com/ai/da/model/vo/DesignModuleChooseVO.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DesignModuleChooseVO {
|
||||
@ApiModelProperty("分组id")
|
||||
private Long userGroupId;
|
||||
|
||||
@ApiModelProperty("分组详细数组")
|
||||
private java.util.List<UserLikeVO> userLikeDetails;
|
||||
}
|
||||
34
src/main/java/com/ai/da/model/vo/ModuleChooseVO.java
Normal file
34
src/main/java/com/ai/da/model/vo/ModuleChooseVO.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.model.dto.PortfolioDTO;
|
||||
import com.ai.da.model.dto.ToProductImageDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@ApiModel("用户choose详细-响应")
|
||||
public class ModuleChooseVO {
|
||||
private Long projectId;
|
||||
private Long collectionId;
|
||||
|
||||
private MoodBoardModuleChooseVO moodBoard;
|
||||
private List<CollectionElementVO> printBoard;
|
||||
private List<CollectionColorVO> colorBoard;
|
||||
private List<CollectionElementVO> sketchBoard;
|
||||
// private moodBoardModuleChooseVO mannequin;
|
||||
private DesignModuleChooseVO design;
|
||||
private List<ToProductImageResultVO> toProduct;
|
||||
private List<ToProductImageResultVO> relight;
|
||||
|
||||
private CavasModuleChooseVO canvas;
|
||||
// private moodBoardModuleChooseVO poseTransfer;
|
||||
// private moodBoardModuleChooseVO patternMaking3D;
|
||||
// private moodBoardModuleChooseVO deReconstruction;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class MoodBoardModuleChooseVO {
|
||||
private String moodTemplateId;
|
||||
|
||||
private String moodTemplateUrl;
|
||||
private String moodTemplateName;
|
||||
private String moodboardPosition;
|
||||
|
||||
private List<CollectionElementVO> moodBoards;
|
||||
}
|
||||
37
src/main/java/com/ai/da/model/vo/ProjectChooseVO.java
Normal file
37
src/main/java/com/ai/da/model/vo/ProjectChooseVO.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.model.dto.PortfolioDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@ApiModel("用户choose详细-响应")
|
||||
public class ProjectChooseVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
// @ApiModelProperty("分组id")
|
||||
// private Long userGroupId;
|
||||
//
|
||||
// @ApiModelProperty("分组详细数组")
|
||||
// private List<UserLikeVO> userLikeDetails;
|
||||
//
|
||||
// @ApiModelProperty("关联的collection")
|
||||
// private UserLikeCollectionVO collection;
|
||||
//
|
||||
// private String sex;
|
||||
//
|
||||
// private Integer beenPublished;
|
||||
//
|
||||
//// private Portfolio portfolio;
|
||||
// private PortfolioDTO portfolioDTO;
|
||||
|
||||
private WorkspaceVO workspaceVO;
|
||||
|
||||
private String process;
|
||||
}
|
||||
21
src/main/java/com/ai/da/model/vo/ProjectVO.java
Normal file
21
src/main/java/com/ai/da/model/vo/ProjectVO.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("用户savedCollection分组-响应")
|
||||
public class ProjectVO {
|
||||
|
||||
@ApiModelProperty("分组ID")
|
||||
private Long id;
|
||||
|
||||
private UserLikeGroupVO userLikeGroupVO;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private Long updateDate;
|
||||
}
|
||||
@@ -51,4 +51,8 @@ public class ValidateElementVO {
|
||||
private List<String> requestIdList;
|
||||
|
||||
private Integer designNum;
|
||||
|
||||
private Long collectionId;
|
||||
|
||||
private Long accountId;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import com.ai.da.common.config.FileProperties;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.CollocationMapper;
|
||||
import com.ai.da.mapper.primary.DressingMapper;
|
||||
import com.ai.da.mapper.primary.SketchDataMapper;
|
||||
import com.ai.da.mapper.primary.UserPreferenceLogMapper;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||
import com.ai.da.mapper.secondary.entity.AttributeRetrieval;
|
||||
@@ -32,6 +35,7 @@ import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -224,7 +228,8 @@ public class PythonService {
|
||||
* @return
|
||||
*/
|
||||
public DesignPythonObjects covertDesignParam(BigDecimal systemScale, String singleOverall,
|
||||
String switchCategory, ValidateElementVO elementVO, String processId) {
|
||||
String switchCategory, ValidateElementVO elementVO, String processId, Set<DesignPythonObject> assembledObjects, Long collectionId) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
DesignPythonObjects designPythonObjects = new DesignPythonObjects();
|
||||
List<DesignPythonObject> objects = new ArrayList<>();
|
||||
designPythonObjects.setObjects(objects);
|
||||
@@ -236,16 +241,20 @@ public class PythonService {
|
||||
elementVO.setNoPinPrintNum(noPinPrintNum);
|
||||
|
||||
int[] sketchNumbers = new int[3];
|
||||
|
||||
int designNum = elementVO.getDesignNum();
|
||||
Set<DesignPythonObject> assembledObjects = new HashSet<>(); // 用于存储已组装的 DesignPythonObject
|
||||
if (CollectionUtil.isEmpty(assembledObjects)) {
|
||||
assembledObjects = new HashSet<>(); // 用于存储已组装的 DesignPythonObject
|
||||
}
|
||||
DesignPythonObject lastAssembledObject = null; // 上一次组装的对象
|
||||
|
||||
long totalContainsTime = 0; // 用于累计 contains 方法的时间
|
||||
int containsCheckCount = 0; // contains 方法调用次数
|
||||
|
||||
for (int i = 0; i < designNum; i++) {
|
||||
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, sketchNumbers, systemScale);
|
||||
if (designPictureType == null) break;
|
||||
|
||||
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
||||
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPrintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
||||
if (designPrintPictureType == null) break;
|
||||
|
||||
updateSketchNumbers(designPictureType, sketchNumbers);
|
||||
@@ -260,56 +269,63 @@ public class PythonService {
|
||||
noPrintNum--;
|
||||
break;
|
||||
}
|
||||
|
||||
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
||||
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
||||
elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPintPictureTypeLayout(elementVO.getModelSex()));
|
||||
elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPrintPictureTypeLayout(elementVO.getModelSex()));
|
||||
|
||||
List<String> beforeAssemblyHasUseMd5List = new ArrayList<>(elementVO.getHasUseMd5List());
|
||||
elementVO.setCollectionId(collectionId);
|
||||
DesignPythonObject pythonObject = createDesignPythonObject(elementVO, designPictureType, systemScale, singleOverall, switchCategory, i);
|
||||
|
||||
// List<String> afterAssemblyHasUseMd5List = elementVO.getHasUseMd5List();
|
||||
// 如果当前对象与已组装的对象重复,则跳过当前组装
|
||||
DesignPythonObject designPythonObjectCopy = getCopy(pythonObject);
|
||||
|
||||
// 计算 contains 方法的执行时间
|
||||
long startTime = System.nanoTime();
|
||||
boolean isDuplicate = assembledObjects.contains(designPythonObjectCopy);
|
||||
long endTime = System.nanoTime();
|
||||
System.out.println("单次 方法调用耗时(纳秒): " + (endTime - startTime));
|
||||
totalContainsTime += (endTime - startTime);
|
||||
containsCheckCount++;
|
||||
|
||||
if (isDuplicate) {
|
||||
// if (lastAssembledObject != null && assembledObjects.contains(lastAssembledObject)) {
|
||||
// // 如果当前组装与前一个组装的对象重复,且前一个组装也重复,结束组装
|
||||
// System.out.println("当前组装的对象与前两个组装的对象重复,结束组装。");
|
||||
// break;
|
||||
// }
|
||||
elementVO.setHasUseMd5List(beforeAssemblyHasUseMd5List);
|
||||
i --;
|
||||
|
||||
switch (designPrintPictureType) {
|
||||
case PIN:
|
||||
pinPrintNum++;
|
||||
break;
|
||||
case NO_PIN:
|
||||
noPinPrintNum++;
|
||||
break;
|
||||
case NO:
|
||||
noPrintNum++;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 将当前对象添加到已组装的集合中,并记录
|
||||
assembledObjects.add(designPythonObjectCopy);
|
||||
// lastAssembledObject = designPythonObjectCopy; // 更新上一次组装的对象
|
||||
for (DesignPythonItem item : pythonObject.getItems()) {
|
||||
redisUtil.addPathToCache(collectionId, userHolder.getId(), item.getPath());
|
||||
}
|
||||
|
||||
objects.add(pythonObject);
|
||||
redisUtil.addProcessId(processId, i + 1);
|
||||
}
|
||||
|
||||
// 输出统计结果
|
||||
System.out.println("contains 方法调用次数: " + containsCheckCount);
|
||||
System.out.println("contains 方法累计执行时间(纳秒): " + totalContainsTime);
|
||||
System.out.println("contains 方法平均执行时间(纳秒): " + (containsCheckCount > 0 ? totalContainsTime / containsCheckCount : 0));
|
||||
|
||||
redisUtil.addAssembledObjects(collectionId, assembledObjects);
|
||||
return designPythonObjects;
|
||||
}
|
||||
|
||||
private DesignPythonObject getCopy(DesignPythonObject pythonObject) {
|
||||
DesignPythonObject designPythonObjectCopy = CopyUtil.copyObject(pythonObject, DesignPythonObject.class);
|
||||
designPythonObjectCopy.setObjectSign(null);
|
||||
DesignPythonBasic basic = designPythonObjectCopy.getBasic();
|
||||
basic.setSave_name(null);
|
||||
designPythonObjectCopy.setBasic(basic);
|
||||
// DesignPythonBasic basic = designPythonObjectCopy.getBasic();
|
||||
// basic.setSave_name(null);
|
||||
// designPythonObjectCopy.setBasic(basic);
|
||||
List<DesignPythonItem> items = designPythonObjectCopy.getItems();
|
||||
List<DesignPythonItem> itemsCopy = new ArrayList<>();
|
||||
for (DesignPythonItem item : items) {
|
||||
@@ -355,7 +371,17 @@ public class PythonService {
|
||||
private DesignPythonObject createDesignPythonObject(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, String singleOverall, String switchCategory, int i) {
|
||||
DesignPythonObject pythonObject = new DesignPythonObject();
|
||||
pythonObject.setItems(coverToDesignPythonItemNew(elementVO, designPictureType, systemScale));
|
||||
pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
||||
// pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
||||
// if (CollectionUtil.isNotEmpty(elementVO.getRequestIdList())) {
|
||||
// pythonObject.setObjectSign(elementVO.getRequestIdList().get(i));
|
||||
// }
|
||||
return pythonObject;
|
||||
}
|
||||
|
||||
private DesignPythonObject createDesignPythonObjectNew(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, String singleOverall, String switchCategory, int i, Long accountId) {
|
||||
DesignPythonObject pythonObject = new DesignPythonObject();
|
||||
pythonObject.setItems(coverToDesignPythonItemNewNew(elementVO, designPictureType, systemScale, accountId));
|
||||
// pythonObject.setBasic(coverToBasic(pythonObject.getItems().get(0), singleOverall, switchCategory, elementVO.getDesignLibraryModelPoint()));
|
||||
if (CollectionUtil.isNotEmpty(elementVO.getRequestIdList())) {
|
||||
pythonObject.setObjectSign(elementVO.getRequestIdList().get(i));
|
||||
}
|
||||
@@ -486,7 +512,7 @@ public class PythonService {
|
||||
// }
|
||||
|
||||
//计算当前的Print图片类型
|
||||
private CurrentDesignPrintPictureTypeEnum calculateCurrentDesignPintPictureType(long pinPrintNum, long noPinPrintNum, long noPrintNum) {
|
||||
private CurrentDesignPrintPictureTypeEnum calculateCurrentDesignPrintPictureType(long pinPrintNum, long noPinPrintNum, long noPrintNum) {
|
||||
List<Integer> codes = Lists.newArrayList();
|
||||
if (pinPrintNum > 0) {
|
||||
//pin默认优先选择 不参与计算 后续有调整再说
|
||||
@@ -511,7 +537,7 @@ public class PythonService {
|
||||
}
|
||||
|
||||
//计算当前的Print图片类型具体分布位置 0. 上衣 1.下衣 2.上衣和下衣都print
|
||||
private List<String> calculateCurrentDesignPintPictureTypeLayout(String modelSex) {
|
||||
private List<String> calculateCurrentDesignPrintPictureTypeLayout(String modelSex) {
|
||||
if (modelSex.equals(Sex.FEMALE.getValue())) {
|
||||
Long randomIndex = RandomsUtil.randomSysFile(0L, 3L);
|
||||
if (randomIndex == 0) {
|
||||
@@ -607,6 +633,81 @@ public class PythonService {
|
||||
|
||||
private List<DesignPythonItem> coverToDesignPythonItemNew(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale) {
|
||||
List<DesignPythonItem> itemList = new ArrayList<>();
|
||||
|
||||
// 第一部分:计算 第一件 Sketch 耗时
|
||||
long firstSketchStartTime = System.currentTimeMillis();
|
||||
DesignPythonItem designPythonItem = calculatePythonItem(elementVO, designPictureType);
|
||||
long firstSketchEndTime = System.currentTimeMillis();
|
||||
|
||||
// 记录第一部分耗时(秒)
|
||||
redisUtil.recordTaskElapsedTime("firstSketchTime", (firstSketchEndTime - firstSketchStartTime) / 1000.0);
|
||||
|
||||
if (Objects.nonNull(designPythonItem)) {
|
||||
itemList.add(designPythonItem);
|
||||
|
||||
if (elementVO.getSingleOverall().equals(SingleOverallEnum.OVERALL.getRealName())) {
|
||||
List<String> otherSketchCategoryList = getOtherSketchCategoryList(elementVO.getModelSex(), designPythonItem);
|
||||
|
||||
// 提前缓存 AttributeRecognition 结果,减少多次调用
|
||||
long getAttributeStartTime = System.currentTimeMillis();
|
||||
JSONObject attributeRecognition = getAttributeRecognitionCached(designPythonItem, elementVO);
|
||||
long getAttributeEndTime = System.currentTimeMillis();
|
||||
|
||||
// 记录第二部分获取特征值耗时(秒)
|
||||
redisUtil.recordTaskElapsedTime("getAttributeRecognitionTime", (getAttributeEndTime - getAttributeStartTime) / 1000.0);
|
||||
|
||||
if (!otherSketchCategoryList.isEmpty()) {
|
||||
long otherSketchStartTime = System.currentTimeMillis();
|
||||
// for (String styleCategory : otherSketchCategoryList) {
|
||||
// DesignPythonItem otherSketch = processAttributeRecognition(attributeRecognition, elementVO, designPictureType, styleCategory, systemScale);
|
||||
// }
|
||||
|
||||
otherSketchCategoryList.parallelStream().forEach(styleCategory -> {
|
||||
DesignPythonItem otherSketch = processAttributeRecognition(attributeRecognition, elementVO, designPictureType, styleCategory, systemScale);
|
||||
synchronized (itemList) {
|
||||
itemList.add(otherSketch);
|
||||
}
|
||||
});
|
||||
long otherSketchEndTime = System.currentTimeMillis();
|
||||
|
||||
// 记录第三部分搭配 Sketch 耗时(秒)
|
||||
redisUtil.recordTaskElapsedTime("otherSketchTime", (otherSketchEndTime - otherSketchStartTime) / 1000.0);
|
||||
}
|
||||
|
||||
itemList.addAll(calculatePythonItemHairstyleShoes(elementVO, elementVO.getDesignLibraryModelPoint()));
|
||||
}
|
||||
}
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
private JSONObject getAttributeRecognitionCached(DesignPythonItem designPythonItem, ValidateElementVO elementVO) {
|
||||
try {
|
||||
String cacheKey = String.format("attributeRecognition:%s:%s:%s",
|
||||
MD5Utils.encryptFile(minioUtil.download(designPythonItem.getPath())),
|
||||
designPythonItem.getType(),
|
||||
elementVO.getModelSex());
|
||||
long startContainTime = System.nanoTime();
|
||||
if (redisUtil.hasKey(cacheKey)) {
|
||||
long endContainTime = System.nanoTime();
|
||||
log.info("redisUtil.hasKey(cacheKey) time: {} seconds", (endContainTime - startContainTime) / 1_000_000_000.0);
|
||||
return JSONObject.parseObject(redisUtil.getFromString(cacheKey));
|
||||
} else {
|
||||
long startTime = System.nanoTime();
|
||||
JSONObject attributeRecognition = getAttributeRecognition(designPythonItem.getPath(), designPythonItem.getType(), elementVO.getModelSex());
|
||||
redisUtil.addToString(cacheKey, attributeRecognition.toJSONString());
|
||||
long endTime = System.nanoTime();
|
||||
log.info("getAttributeRecognition execution time: {} seconds", (endTime - startTime) / 1_000_000_000.0);
|
||||
return attributeRecognition;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to get AttributeRecognition: {}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<DesignPythonItem> coverToDesignPythonItemNewNew(ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, BigDecimal systemScale, Long accountId) {
|
||||
List<DesignPythonItem> itemList = new ArrayList<>();
|
||||
DesignPythonItem designPythonItem = calculatePythonItem(elementVO, designPictureType);
|
||||
if (Objects.nonNull(designPythonItem)) {
|
||||
itemList.add(designPythonItem);
|
||||
@@ -625,13 +726,31 @@ public class PythonService {
|
||||
return itemList;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private SketchDataMapper sketchDataMapper;
|
||||
|
||||
private DesignPythonItem processAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, CurrentDesignPictureTypeEnum designPictureType, String styleCategory, BigDecimal systemScale) {
|
||||
switch (designPictureType) {
|
||||
case PIN:
|
||||
return processPinAttributeRecognition(attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
case NO_PIN:
|
||||
case SYS_FILE:
|
||||
return processNoPinOrSysFileAttributeRecognition(attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
List<DesignPythonItem> designPythonItemList = processNoPinOrSysFileAttributeRecognition(attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
DesignPythonItem designPythonItem = designPythonItemList.get(i);
|
||||
|
||||
SketchData sketchData = new SketchData();
|
||||
sketchData.setAccountId(elementVO.getAccountId());
|
||||
sketchData.setPath(designPythonItem.getPath());
|
||||
if (i == 0) {
|
||||
sketchData.setType(2);
|
||||
}else {
|
||||
sketchData.setType(1);
|
||||
}
|
||||
sketchData.setCollectionId(elementVO.getCollectionId());
|
||||
sketchDataMapper.insert(sketchData);
|
||||
}
|
||||
return designPythonItemList.get(1);
|
||||
default:
|
||||
throw new BusinessException("unknown designPictureType");
|
||||
}
|
||||
@@ -645,44 +764,335 @@ public class PythonService {
|
||||
return coverSketchToDesignPythonItem(collectPin.get(randomNum).getId(), collectPin.get(randomNum), elementVO);
|
||||
} else {
|
||||
List<CollectionElement> collectNoPin = getFilteredCollectionElements(elementVO.getSketchBoardElements(), 0, styleCategory);
|
||||
return processNoPinOrSysFileAttributeRecognitionWithPool(collectNoPin, attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
List<DesignPythonItem> designPythonItemList = processNoPinOrSysFileAttributeRecognitionWithPool(collectNoPin, attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
DesignPythonItem designPythonItem = designPythonItemList.get(i);
|
||||
|
||||
SketchData sketchData = new SketchData();
|
||||
sketchData.setAccountId(elementVO.getAccountId());
|
||||
sketchData.setPath(designPythonItem.getPath());
|
||||
if (i == 0) {
|
||||
// 第一个 新算法
|
||||
sketchData.setType(2);
|
||||
}else {
|
||||
// 后一个 老算法
|
||||
sketchData.setType(1);
|
||||
}
|
||||
sketchData.setCollectionId(elementVO.getCollectionId());
|
||||
sketchDataMapper.insert(sketchData);
|
||||
}
|
||||
return designPythonItemList.get(1);
|
||||
}
|
||||
}
|
||||
|
||||
private DesignPythonItem processNoPinOrSysFileAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
private List<DesignPythonItem> processNoPinOrSysFileAttributeRecognition(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
List<CollectionElement> collectNoPin = getFilteredCollectionElements(elementVO.getSketchBoardElements(), 0, styleCategory);
|
||||
return processNoPinOrSysFileAttributeRecognitionWithPool(collectNoPin, attributeRecognition, elementVO, styleCategory, systemScale);
|
||||
}
|
||||
|
||||
private DesignPythonItem processNoPinOrSysFileAttributeRecognitionWithPool(List<CollectionElement> collectionElements, JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
int poolNum = 20;
|
||||
private List<DesignPythonItem> processNoPinOrSysFileAttributeRecognitionWithPool(List<CollectionElement> collectionElements, JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
int poolNum = 40;
|
||||
List<DesignPythonItem> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
int collectionNoPinSize = collectionElements.size();
|
||||
if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
||||
int randomNum = RandomsUtil.randomSysFile(collectionNoPinSize);
|
||||
return coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||
CollectionElement collectionElement = getRomdomCollectionElement(collectionElements, null, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
if (Objects.isNull(collectionElement)) {
|
||||
log.info("bug");
|
||||
}
|
||||
DesignPythonItem designPythonItemNew = coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
result.add(designPythonItemNew);
|
||||
DesignPythonItem designPythonItemOld = coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||
result.add(designPythonItemOld);
|
||||
return result;
|
||||
} else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
||||
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectionNoPinSize);
|
||||
poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
|
||||
if (poolNum < 20) {
|
||||
poolNum = 40;
|
||||
}
|
||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
|
||||
CollectionElement collectionElementNew = getRomdomCollectionElement(collectionElements, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
if (Objects.isNull(collectionElementNew)) {
|
||||
log.info("bug");
|
||||
}
|
||||
DesignPythonItem designPythonItemNew = coverSketchToDesignPythonItem(null, collectionElementNew, elementVO);
|
||||
result.add(designPythonItemNew);
|
||||
collectionElements.addAll(list);
|
||||
int randomNum = RandomsUtil.randomSysFile(collectionElements.size());
|
||||
if (randomNum < collectionNoPinSize) {
|
||||
return coverSketchToDesignPythonItem(collectionElements.get(randomNum).getId(), collectionElements.get(randomNum), elementVO);
|
||||
} else {
|
||||
return coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||
}
|
||||
DesignPythonItem designPythonItemOld = coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||
// if (randomNum < collectionNoPinSize) {
|
||||
// return coverSketchToDesignPythonItem(collectionElements.get(randomNum).getId(), collectionElements.get(randomNum), elementVO);
|
||||
// } else {
|
||||
// return coverSketchToDesignPythonItem(null, collectionElements.get(randomNum), elementVO);
|
||||
// }
|
||||
result.add(designPythonItemOld);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
System.out.println("bug");
|
||||
}
|
||||
int randomNum = RandomsUtil.randomSysFile(list.size());
|
||||
return coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
|
||||
CollectionElement collectionElementNew = getRomdomCollectionElement(null, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
DesignPythonItem designPythonItemNew = coverSketchToDesignPythonItem(null, collectionElementNew, elementVO);
|
||||
result.add(designPythonItemNew);
|
||||
DesignPythonItem designPythonItemOld = coverSketchToDesignPythonItem(null, list.get(randomNum), elementVO);
|
||||
result.add(designPythonItemOld);
|
||||
return result;
|
||||
}
|
||||
|
||||
// private DesignPythonItem processNoPinOrSysFileAttributeRecognitionWithPoolNew(List<CollectionElement> collectionElements, JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
// int poolNum = 20;
|
||||
// if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
// int collectionNoPinSize = collectionElements.size();
|
||||
// if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
||||
// CollectionElement collectionElement = getRomdomCollectionElement(collectionElements, null, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
// return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
// } else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
||||
// BigDecimal collectNoPinSize = BigDecimal.valueOf(collectionNoPinSize);
|
||||
// poolNum = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN).intValue();
|
||||
// List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
//// collectionElements.addAll(list);
|
||||
//// int randomNum = RandomsUtil.randomSysFile(collectionElements.size());
|
||||
//
|
||||
// CollectionElement collectionElement = getRomdomCollectionElement(collectionElements, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
// return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
// }
|
||||
// }
|
||||
// List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
// CollectionElement collectionElement = getRomdomCollectionElement(null, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
// return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
// }
|
||||
|
||||
private DesignPythonItem processNoPinOrSysFileAttributeRecognitionWithPoolNew(List<CollectionElement> collectionElements, JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory, BigDecimal systemScale) {
|
||||
int poolNum = 20;
|
||||
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
int collectionNoPinSize = collectionElements.size();
|
||||
if (systemScale.compareTo(BigDecimal.ZERO) == 0) {
|
||||
CollectionElement collectionElement = getRomdomCollectionElement(collectionElements, null, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
} else if (systemScale.compareTo(BigDecimal.ONE) != 0) {
|
||||
BigDecimal collectNoPinSize = BigDecimal.valueOf(collectionNoPinSize);
|
||||
|
||||
// 使用 BigDecimal 类型来计算 poolNum
|
||||
BigDecimal poolNumAsBigDecimal = collectNoPinSize.divide(systemScale, 0, RoundingMode.DOWN);
|
||||
|
||||
// 比较 poolNum + collectNoPinSize 是否小于 20
|
||||
if (poolNumAsBigDecimal.add(collectNoPinSize).compareTo(BigDecimal.valueOf(20)) < 0) {
|
||||
// 判断成立,设置 poolNum 为 20 - collectNoPinSize
|
||||
poolNum = BigDecimal.valueOf(20).subtract(collectNoPinSize).intValue();
|
||||
}
|
||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
CollectionElement collectionElement = getRomdomCollectionElement(collectionElements, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
}
|
||||
}
|
||||
List<CollectionElement> list = getSystemSketchPool(attributeRecognition, styleCategory, elementVO.getModelSex(), poolNum, elementVO.getStyle());
|
||||
// int randomNum = RandomsUtil.randomSysFile(list.size());
|
||||
CollectionElement collectionElement = getRomdomCollectionElement(null, list, systemScale, elementVO.getCollectionId(), elementVO.getAccountId());
|
||||
return coverSketchToDesignPythonItem(null, collectionElement, elementVO);
|
||||
}
|
||||
|
||||
private CollectionElement getRomdomCollectionElement(List<CollectionElement> noPinSketchList, List<CollectionElement> systemSketchList, BigDecimal systemScale, Long collectionId, Long accountId) {
|
||||
// 确定选择的池子:根据 systemScale 决定选取 noPin 或 system
|
||||
boolean selectNoPin = Math.random() < (1 - systemScale.doubleValue());
|
||||
|
||||
List<CollectionElement> selectedList = new ArrayList<>();
|
||||
if (selectNoPin) {
|
||||
if (!CollectionUtils.isEmpty(noPinSketchList)) {
|
||||
selectedList.addAll(noPinSketchList);
|
||||
}else {
|
||||
selectedList.addAll(systemSketchList);
|
||||
}
|
||||
}else {
|
||||
selectedList.addAll(systemSketchList);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isEmpty(selectedList)) {
|
||||
return null; // 如果选中的池子为空,返回 null
|
||||
}
|
||||
|
||||
// 计算每个元素的得分
|
||||
Map<CollectionElement, Double> scoreMap = new HashMap<>();
|
||||
for (CollectionElement element : selectedList) {
|
||||
double baseScore = Math.random(); // 基础分:0 到 1 的随机数
|
||||
|
||||
// 根据是否是之前用过或喜欢过的 sketch 调整得分
|
||||
double adjustment = 0.0;
|
||||
int likedSketch = isLikedSketch(element, accountId);
|
||||
int maxLikedSketch = getMaxLikedSketchNum(accountId);
|
||||
if (maxLikedSketch > 0) {
|
||||
if (likedSketch > 0) {
|
||||
adjustment = Math.log(1 + likedSketch)/Math.log(1 + maxLikedSketch);
|
||||
}
|
||||
}
|
||||
|
||||
double finalScore = adjustment;
|
||||
// double finalScore = 0.7 * baseScore + 0.3 * adjustment;
|
||||
scoreMap.put(element, finalScore);
|
||||
}
|
||||
|
||||
// 按得分排序并返回最高分的元素
|
||||
return selectedList.stream()
|
||||
.sorted((e1, e2) -> Double.compare(scoreMap.get(e2), scoreMap.get(e1))) // 按分数降序排序
|
||||
.findFirst()
|
||||
.orElse(null); // 如果池子为空,返回 null
|
||||
}
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
// 检查是否是 like 过的 sketch
|
||||
private int isLikedSketch(CollectionElement element, Long accountId) {
|
||||
String redisKey = "user_liked_sketch:" + accountId;
|
||||
|
||||
// 尝试从 Redis 获取该 sketch path 的喜欢次数
|
||||
Integer likedCount = (Integer) redisTemplate.opsForHash().get(redisKey, element.getUrl());
|
||||
if (likedCount != null) {
|
||||
return likedCount; // 如果缓存中有,直接返回
|
||||
}
|
||||
|
||||
// 如果缓存中没有,则查询数据库
|
||||
QueryWrapper<UserPreferenceLogTest> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UserPreferenceLogTest::getPath, element.getUrl());
|
||||
qw.lambda().eq(UserPreferenceLogTest::getAccountId, accountId);
|
||||
// List<UserPreferenceLogTest> userPreferenceLogTests = userPreferenceLogMapper.selectList(qw);
|
||||
// if (CollectionUtils.isEmpty(userPreferenceLogTests)) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// 将结果存入 Redis
|
||||
// redisTemplate.opsForHash().put(redisKey, element.getUrl(), userPreferenceLogTests.size());
|
||||
//
|
||||
// 返回查询到的结果
|
||||
// return userPreferenceLogTests.size();
|
||||
return 10;
|
||||
}
|
||||
|
||||
private int getMaxLikedSketchNum(Long accountId) {
|
||||
// String redisKey = "user_liked_sketch:" + accountId + ":maxLikes";
|
||||
//
|
||||
// // 尝试从 Redis 获取最大喜欢次数
|
||||
// String maxLikesStr = (String) redisTemplate.opsForValue().get(redisKey);
|
||||
// if (maxLikesStr != null) {
|
||||
// return Integer.parseInt(maxLikesStr); // 如果缓存中有,直接返回
|
||||
// }
|
||||
//
|
||||
// // 如果缓存中没有,则查询数据库
|
||||
// QueryWrapper<UserPreferenceLogTest> qw = new QueryWrapper<>();
|
||||
// qw.lambda().eq(UserPreferenceLogTest::getAccountId, accountId);
|
||||
// List<UserPreferenceLogTest> userPreferenceLogTests = userPreferenceLogMapper.selectList(qw);
|
||||
// if (CollectionUtils.isEmpty(userPreferenceLogTests)) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// // 按路径统计数量
|
||||
// Map<String, Long> pathCountMap = userPreferenceLogTests.stream()
|
||||
// .collect(Collectors.groupingBy(UserPreferenceLogTest::getPath, Collectors.counting()));
|
||||
//
|
||||
// // 获取最大喜欢次数
|
||||
// int maxLiked = pathCountMap.values().stream()
|
||||
// .max(Long::compare)
|
||||
// .orElse(0L)
|
||||
// .intValue();
|
||||
//
|
||||
// // 将最大喜欢次数存入 Redis
|
||||
// redisTemplate.opsForValue().set(redisKey, String.valueOf(maxLiked));
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
||||
private List<CollectionElement> getFilteredCollectionElements(List<CollectionElement> elements, int hasPin, String styleCategory) {
|
||||
return CollectionUtil.isNotEmpty(elements) ? elements.stream().filter(o -> o.getHasPin() == hasPin && o.getLevel2Type().equals(styleCategory)).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
// 历史使用记录,可以通过一个 Map 存储 MD5 或 ID
|
||||
private static Map<String, Integer> usageHistory = new HashMap<>();
|
||||
|
||||
// 给定扰动参数
|
||||
private static final double DISTURBANCE_FACTOR = 1;
|
||||
|
||||
private static double calculateScore(CollectionElement element, boolean isNoPin, double systemScale, int noPinCount, int systemCount) {
|
||||
double score = 0.0;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<CollectionElement> noPinSketchList = new ArrayList<>();
|
||||
List<CollectionElement> systemSketchList = new ArrayList<>();
|
||||
|
||||
// 构造 noPin 和 system 的元素
|
||||
for (int i = 0; i < 50; i++) {
|
||||
CollectionElement element = new CollectionElement();
|
||||
element.setMd5("noPin_" + i); // 设置 md5 前缀为 noPin
|
||||
noPinSketchList.add(element);
|
||||
}
|
||||
for (int i = 0; i < 50; i++) {
|
||||
CollectionElement element = new CollectionElement();
|
||||
element.setMd5("system_" + i); // 设置 md5 前缀为 system
|
||||
systemSketchList.add(element);
|
||||
}
|
||||
|
||||
// 设置 systemScale 测试值
|
||||
double systemScale = 0.6;
|
||||
|
||||
// 模拟测试次数
|
||||
int totalTests = 1000000;
|
||||
int noPinWinCount = 0;
|
||||
|
||||
for (int i = 0; i < totalTests; i++) {
|
||||
CollectionElement highestElement = getHighestScoredElement(noPinSketchList, systemSketchList, systemScale);
|
||||
if (highestElement != null && highestElement.getMd5().startsWith("noPin")) {
|
||||
noPinWinCount++;
|
||||
}
|
||||
}
|
||||
|
||||
double probability = (double) noPinWinCount / totalTests;
|
||||
System.out.printf("Probability of highest score being noPin: %.4f%n", probability);
|
||||
}
|
||||
|
||||
private static CollectionElement getHighestScoredElement(List<CollectionElement> noPinSketchList,
|
||||
List<CollectionElement> systemSketchList,
|
||||
double systemScale) {
|
||||
// 获取 noPin 列表中得分最高的元素
|
||||
CollectionElement highestNoPinElement = getHighestScoreElement(noPinSketchList, true, systemScale,
|
||||
noPinSketchList.size(), systemSketchList.size());
|
||||
// 获取 system 列表中得分最高的元素
|
||||
CollectionElement highestSystemElement = getHighestScoreElement(systemSketchList, false, systemScale,
|
||||
noPinSketchList.size(), systemSketchList.size());
|
||||
|
||||
// 比较两者得分并返回最高分的元素
|
||||
// if (highestNoPinElement != null && highestSystemElement != null) {
|
||||
// return highestNoPinElement.getScore() >= highestSystemElement.getScore() ? highestNoPinElement : highestSystemElement;
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
private static CollectionElement getHighestScoreElement(List<CollectionElement> sketchList,
|
||||
boolean isNoPin,
|
||||
double systemScale,
|
||||
int noPinCount,
|
||||
int systemCount) {
|
||||
double maxScore = Double.NEGATIVE_INFINITY;
|
||||
CollectionElement highestElement = null;
|
||||
|
||||
for (CollectionElement element : sketchList) {
|
||||
double score = calculateScore(element, isNoPin, systemScale, noPinCount, systemCount);
|
||||
// element.setScore(score); // 设置得分以便比较
|
||||
// if (score > maxScore) {
|
||||
// maxScore = score;
|
||||
// highestElement = element;
|
||||
// }
|
||||
}
|
||||
return highestElement;
|
||||
}
|
||||
|
||||
|
||||
private DesignPythonItem processAttributeRecognitionBySameCategory(JSONObject attributeRecognition, ValidateElementVO elementVO, String styleCategory) {
|
||||
List<CollectionElement> list = getSystemSketchPoolBySameCategory(attributeRecognition, styleCategory, elementVO.getModelSex(), elementVO.getStyle());
|
||||
int randomNum = RandomsUtil.randomSysFile(list.size());
|
||||
@@ -866,7 +1276,7 @@ public class PythonService {
|
||||
paramArray.add(paramJSONObject);
|
||||
String param = JSON.toJSONString(paramArray, SerializerFeature.DisableCircularReferenceDetect);
|
||||
|
||||
log.info("PythonService##design 请求参数:####{}", param);
|
||||
// log.info("PythonService##design 请求参数:####{}", param);
|
||||
RequestBody body = RequestBody.create(mediaType, param);
|
||||
Request request = new Request.Builder()
|
||||
.url(accessPythonIp + ":" + accessPythonPort + "/api/attribute_recognition")
|
||||
@@ -879,7 +1289,7 @@ public class PythonService {
|
||||
if (response.isSuccessful()) {
|
||||
String responseBody = Objects.requireNonNull(response.body()).string();
|
||||
JSONObject responseObject = JSON.parseObject(responseBody);
|
||||
log.info("PythonService##responseObject###{}", responseObject);
|
||||
// log.info("PythonService##responseObject###{}", responseObject);
|
||||
return responseObject;
|
||||
} else {
|
||||
log.error("PythonService##design 请求异常:{}", response);
|
||||
@@ -1634,10 +2044,10 @@ public class PythonService {
|
||||
pythonItem.setPath(sysFileVO.getUrl());
|
||||
pythonItem.setBusinessId(sysFileVO.getId());
|
||||
if (SysFileLevel2TypeEnum.SHOES.getRealName().equals(type)) {
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
pythonItem.setColor(randomColor.getRgbValue());
|
||||
pythonItem.setGradient(randomColor.getGradientMinioUrl());
|
||||
pythonItem.setGradientString(randomColor.getGradientString());
|
||||
// CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
// pythonItem.setColor(randomColor.getRgbValue());
|
||||
// pythonItem.setGradient(randomColor.getGradientMinioUrl());
|
||||
// pythonItem.setGradientString(randomColor.getGradientString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2000,10 +2410,10 @@ public class PythonService {
|
||||
designPythonItemBlouse.setPath(path);
|
||||
//所有的icon都是none
|
||||
designPythonItemBlouse.setIcon("none");
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
designPythonItemBlouse.setGradientString(randomColor.getGradientString());
|
||||
// CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
// designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
// designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
// designPythonItemBlouse.setGradientString(randomColor.getGradientString());
|
||||
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
|
||||
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) {
|
||||
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
|
||||
@@ -2025,14 +2435,17 @@ public class PythonService {
|
||||
designPythonItemBlouse.setElementId(elementId);
|
||||
designPythonItemBlouse.setBusinessId(elementId);
|
||||
}
|
||||
if (Objects.isNull(collectionElement)) {
|
||||
log.info("bug");
|
||||
}
|
||||
designPythonItemBlouse.setType(collectionElement.getLevel2Type());
|
||||
designPythonItemBlouse.setPath(collectionElement.getUrl());
|
||||
//所有的icon都是none
|
||||
designPythonItemBlouse.setIcon("none");
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
designPythonItemBlouse.setGradientString(randomColor.getGradientString());
|
||||
// CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
// designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
// designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
// designPythonItemBlouse.setGradientString(randomColor.getGradientString());
|
||||
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
|
||||
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) {
|
||||
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
|
||||
@@ -3799,4 +4212,98 @@ public class PythonService {
|
||||
throw new BusinessException("design.interface.exception");
|
||||
}
|
||||
|
||||
|
||||
public DesignPythonObjects covertDesignParamTest(BigDecimal systemScale, String singleOverall,
|
||||
String switchCategory, ValidateElementVO elementVO, String processId, Set<DesignPythonObject> assembledObjects, Long collectionId) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
DesignPythonObjects designPythonObjects = new DesignPythonObjects();
|
||||
List<DesignPythonObject> objects = new ArrayList<>();
|
||||
designPythonObjects.setObjects(objects);
|
||||
// designPythonObjects.setProcess_id(processId);
|
||||
|
||||
long pinPrintNum = calculateDesignPinPrintNum(elementVO.getPrintBoardElements());
|
||||
long noPinPrintNum = calculateDesignNoPinPrintNum(elementVO.getPrintBoardElements(), elementVO.getDesignNum());
|
||||
long noPrintNum = elementVO.getDesignNum() - pinPrintNum - noPinPrintNum;
|
||||
elementVO.setNoPinPrintNum(noPinPrintNum);
|
||||
|
||||
int[] sketchNumbers = new int[3];
|
||||
int designNum = elementVO.getDesignNum();
|
||||
if (CollectionUtil.isEmpty(assembledObjects)) {
|
||||
assembledObjects = new HashSet<>(); // 用于存储已组装的 DesignPythonObject
|
||||
}
|
||||
DesignPythonObject lastAssembledObject = null; // 上一次组装的对象
|
||||
|
||||
long totalContainsTime = 0; // 用于累计 contains 方法的时间
|
||||
int containsCheckCount = 0; // contains 方法调用次数
|
||||
|
||||
for (int i = 0; i < designNum; i++) {
|
||||
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, sketchNumbers, systemScale);
|
||||
if (designPictureType == null) break;
|
||||
|
||||
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPrintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
||||
if (designPrintPictureType == null) break;
|
||||
|
||||
updateSketchNumbers(designPictureType, sketchNumbers);
|
||||
switch (designPrintPictureType) {
|
||||
case PIN:
|
||||
pinPrintNum--;
|
||||
break;
|
||||
case NO_PIN:
|
||||
noPinPrintNum--;
|
||||
break;
|
||||
case NO:
|
||||
noPrintNum--;
|
||||
break;
|
||||
}
|
||||
|
||||
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
||||
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
||||
elementVO.setDesignPrintPictureTypeLayoutList(calculateCurrentDesignPrintPictureTypeLayout(elementVO.getModelSex()));
|
||||
|
||||
List<String> beforeAssemblyHasUseMd5List = new ArrayList<>(elementVO.getHasUseMd5List());
|
||||
elementVO.setCollectionId(collectionId);
|
||||
DesignPythonObject pythonObject = createDesignPythonObject(elementVO, designPictureType, systemScale, singleOverall, switchCategory, i);
|
||||
|
||||
// List<String> afterAssemblyHasUseMd5List = elementVO.getHasUseMd5List();
|
||||
// 如果当前对象与已组装的对象重复,则跳过当前组装
|
||||
DesignPythonObject designPythonObjectCopy = getCopy(pythonObject);
|
||||
|
||||
// 计算 contains 方法的执行时间
|
||||
long startTime = System.nanoTime();
|
||||
boolean isDuplicate = assembledObjects.contains(designPythonObjectCopy);
|
||||
long endTime = System.nanoTime();
|
||||
// System.out.println("单次 方法调用耗时(纳秒): " + (endTime - startTime));
|
||||
totalContainsTime += (endTime - startTime);
|
||||
containsCheckCount++;
|
||||
|
||||
if (isDuplicate) {
|
||||
// if (lastAssembledObject != null && assembledObjects.contains(lastAssembledObject)) {
|
||||
// System.out.println("当前组装的对象与前两个组装的对象重复,结束组装。");
|
||||
// break;
|
||||
// }
|
||||
elementVO.setHasUseMd5List(beforeAssemblyHasUseMd5List);
|
||||
i --;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 将当前对象添加到已组装的集合中,并记录
|
||||
assembledObjects.add(designPythonObjectCopy);
|
||||
// lastAssembledObject = designPythonObjectCopy; // 更新上一次组装的对象
|
||||
// for (DesignPythonItem item : pythonObject.getItems()) {
|
||||
// redisUtil.addPathToCache(collectionId, userHolder.getId(), item.getPath());
|
||||
// }
|
||||
|
||||
objects.add(pythonObject);
|
||||
// redisUtil.addProcessId(processId, i + 1);
|
||||
}
|
||||
|
||||
// 输出统计结果
|
||||
// System.out.println("contains 方法调用次数: " + containsCheckCount);
|
||||
// System.out.println("contains 方法累计执行时间(纳秒): " + totalContainsTime);
|
||||
// System.out.println("contains 方法平均执行时间(纳秒): " + (containsCheckCount > 0 ? totalContainsTime / containsCheckCount : 0));
|
||||
|
||||
redisUtil.addAssembledObjects(collectionId, assembledObjects);
|
||||
return designPythonObjects;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
import com.ai.da.model.vo.CollectionColorVO;
|
||||
import com.ai.da.model.vo.UserLikeCollectionVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
@@ -25,4 +29,8 @@ public interface CollectionService extends IService<Collection> {
|
||||
* 查询choose关联的collection
|
||||
*/
|
||||
UserLikeCollectionVO chooseCollection(Long id);
|
||||
|
||||
String getMoodboardPositionString(Long id);
|
||||
|
||||
List<CollectionColorVO> resolveColorBoard(List<CollectionElement> collectionElements);
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ public interface DesignService extends IService<Design> {
|
||||
|
||||
Integer designProcess(String processId);
|
||||
|
||||
void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam);
|
||||
|
||||
void relationImageId(DesignPythonObjects objects);
|
||||
|
||||
List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignCollectionDTO);
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface SysFileService extends IService<SysFile> {
|
||||
List<SysFileVO> getByUrlList(List<String> urlList);
|
||||
|
||||
List<SysFile> getByIds(List<Long> ids);
|
||||
|
||||
SysFile getOneBySex(Long styleId, String sex);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.mapper.primary.entity.CanvasElementUpload;
|
||||
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
import com.ai.da.model.dto.ExportSaveDTO;
|
||||
import com.ai.da.model.dto.ProductImageInitializeDTO;
|
||||
import com.ai.da.model.dto.ProductImageLikeDTO;
|
||||
import com.ai.da.model.dto.ToProductImageDTO;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -37,6 +37,8 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
*/
|
||||
UserLikeChooseVO choose(Long userGroupId);
|
||||
|
||||
ProjectChooseVO choose(ProjectDTO projectDTO);
|
||||
|
||||
void deleteTrialData(Long id);
|
||||
|
||||
void updateDate(Long id,String timeZone);
|
||||
@@ -72,4 +74,10 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
String download();
|
||||
|
||||
Boolean productImageInitialize(ProductImageInitializeDTO productImageInitializeDTO);
|
||||
|
||||
IPage<ProjectVO> getPage(ProjectQueryDTO projectQueryDTO);
|
||||
|
||||
ModuleChooseVO getModuleContent(ProjectDTO projectDTO);
|
||||
|
||||
ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.dto.ProjectDTO;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
@@ -11,6 +12,7 @@ import com.ai.da.model.vo.StyleVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
@@ -53,4 +55,9 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
Workspace getCurrentWorkspace();
|
||||
|
||||
List<StyleVO> styleList();
|
||||
|
||||
@Transactional
|
||||
Long saveOrUpdateProject(ProjectDTO projectDTO);
|
||||
|
||||
Long getByProjectId(Long projectId);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.ai.da.model.vo.UserLikeCollectionVO;
|
||||
import com.ai.da.service.CollectionElementService;
|
||||
import com.ai.da.service.CollectionService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
@@ -196,7 +195,8 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
return response;
|
||||
}
|
||||
|
||||
private String getMoodboardPositionString(Long id) {
|
||||
@Override
|
||||
public String getMoodboardPositionString(Long id) {
|
||||
QueryWrapper<MoodboardPosition> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(MoodboardPosition::getCollectionId, id);
|
||||
List<MoodboardPosition> moodboardPositions = moodboardPositionMapper.selectList(qw);
|
||||
@@ -258,7 +258,8 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
|
||||
}
|
||||
}
|
||||
|
||||
private List<CollectionColorVO> resolveColorBoard(List<CollectionElement> collectionElements) {
|
||||
@Override
|
||||
public List<CollectionColorVO> resolveColorBoard(List<CollectionElement> collectionElements) {
|
||||
return CopyUtil.copyList(collectionElements, CollectionColorVO.class, (o, d) -> {
|
||||
String name = o.getName();
|
||||
if (StringUtils.isBlank(name)) {
|
||||
|
||||
@@ -6,7 +6,9 @@ import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.enums.SysFileLevel1TypeEnum;
|
||||
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.StyleMapper;
|
||||
import com.ai.da.mapper.primary.SysFileMapper;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.SysFile;
|
||||
import com.ai.da.model.vo.SysFileVO;
|
||||
import com.ai.da.service.SysFileService;
|
||||
@@ -43,6 +45,8 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
@Resource
|
||||
private StyleMapper styleMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
@@ -267,4 +271,30 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
queryWrapper.in("id", ids);
|
||||
return sysFileMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysFile getOneBySex(Long styleId, String sex) {
|
||||
Style style = new Style();
|
||||
if (styleId != null) {
|
||||
style = styleMapper.selectById(styleId);
|
||||
}
|
||||
QueryWrapper<SysFile> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||
qw.lambda().eq(SysFile::getLevel2Type, sex);
|
||||
if (style.getId() != null) {
|
||||
qw.lambda().eq(SysFile::getLevel3Type, style.getName());
|
||||
}
|
||||
List<SysFile> sysFileList = sysFileMapper.selectList(qw);
|
||||
if (!CollectionUtils.isEmpty(sysFileList)) {
|
||||
return sysFileList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Style style = new Style();
|
||||
if (Objects.nonNull(style)) {
|
||||
System.out.println("buxing");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,20 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.enums.CreditsEventsEnum;
|
||||
import com.ai.da.common.enums.DesignTypeEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.response.ResultEnum;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
|
||||
import com.ai.da.mapper.secondary.entity.AttributeRecognitionJSON;
|
||||
import com.ai.da.model.dto.PortfolioDTO;
|
||||
import com.ai.da.model.dto.ProductImageInitializeDTO;
|
||||
import com.ai.da.model.dto.ProductImageLikeDTO;
|
||||
import com.ai.da.model.dto.ToProductImageDTO;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.Module;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.service.*;
|
||||
@@ -24,19 +27,24 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.gson.Gson;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -58,6 +66,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
@Resource
|
||||
private UserLikeService userLikeService;
|
||||
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@Resource
|
||||
private UserLikeMapper userLikeMapper;
|
||||
|
||||
@@ -69,10 +80,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
@Resource
|
||||
private DesignMapper designMapper;
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
@Resource
|
||||
private SysFileMapper sysFileMapper;
|
||||
@Resource
|
||||
private LibraryMapper libraryMapper;
|
||||
@Resource
|
||||
private GenerateDetailMapper generateDetailMapper;
|
||||
@Resource
|
||||
private PortfolioMapper portfolioMapper;
|
||||
@Resource
|
||||
private TagsMapper tagsMapper;
|
||||
@@ -86,6 +101,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private ProductImageAttributeMapper productImageAttributeMapper;
|
||||
@Resource
|
||||
private UserLikeSortMapper userLikeSortMapper;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private PortfolioService portfolioService;
|
||||
|
||||
@Override
|
||||
public void deleteUserGroup(Long userGroupId) {
|
||||
@@ -208,6 +229,94 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return new UserLikeChooseVO(userGroupId, userLikeVOS, userLikeCollection, sex, beenPublished, portfolioDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectChooseVO choose(ProjectDTO projectDTO) {
|
||||
|
||||
Project project = projectMapper.selectById(projectDTO.getId());
|
||||
|
||||
// List<String> moduleList = projectDTO.getModuleList();
|
||||
// for (String module : moduleList) {
|
||||
//
|
||||
// }
|
||||
|
||||
Long workspaceId = workspaceService.getByProjectId(project.getId());
|
||||
WorkspaceVO workspaceVO = workspaceService.getByIdNew(workspaceId);
|
||||
|
||||
String process = project.getProcess();
|
||||
|
||||
// UserLikeGroup group = getByProjectId(projectDTO.getId());
|
||||
// if (Objects.isNull(group)) {
|
||||
// throw new BusinessException("history.not.found");
|
||||
// }
|
||||
// List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(group.getId());
|
||||
// String sex = null;
|
||||
//
|
||||
// QueryWrapper<UserLikeSort> userLikeSortQw = new QueryWrapper<>();
|
||||
// userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, group.getId());
|
||||
// List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw);
|
||||
// if (CollectionUtil.isEmpty(userLikeSortList)) {
|
||||
// Integer sort = 1;
|
||||
// for (UserLikeVO userLikeVO : userLikeVOS) {
|
||||
// UserLikeSort userLikeSort = new UserLikeSort();
|
||||
// userLikeSort.setUserLikeId(userLikeVO.getId());
|
||||
// userLikeSort.setUserLikeGroupId(group.getId());
|
||||
// userLikeSort.setSort(sort);
|
||||
// userLikeSortMapper.insert(userLikeSort);
|
||||
// sort ++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// userLikeVOS.forEach(o -> {
|
||||
// TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
|
||||
// o.setUrl(tDesignPythonOutfit1.getDesignUrl());
|
||||
// if (o.getUrl().contains("/")) {
|
||||
// int index = o.getUrl().lastIndexOf("/");
|
||||
// o.setPictureName(o.getUrl().substring(index + 1));
|
||||
// }
|
||||
// o.setDesignOutfitUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
|
||||
// QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||
// qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
|
||||
// List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
|
||||
// if (CollectionUtil.isNotEmpty(tDesignPythonOutfits)) {
|
||||
// TDesignPythonOutfit tDesignPythonOutfit = tDesignPythonOutfits.get(0);
|
||||
// o.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
// }
|
||||
//
|
||||
// QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
// userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId());
|
||||
// List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
// if (CollectionUtil.isNotEmpty(userLikeSorts)) {
|
||||
// UserLikeSort userLikeSort = userLikeSorts.get(0);
|
||||
// o.setSort(userLikeSort.getSort());
|
||||
// o.setUserLikeSortId(userLikeSort.getId());
|
||||
// }
|
||||
// });
|
||||
// UserLikeCollectionVO userLikeCollection = collectionService.chooseCollection(group.getCollectionId());
|
||||
// Integer beenPublished = 0;
|
||||
// QueryWrapper<Portfolio> qw = new QueryWrapper<>();
|
||||
// qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, group.getId());
|
||||
// List<Portfolio> portfolios = portfolioMapper.selectList(qw);
|
||||
//// Portfolio portfolio = new Portfolio();
|
||||
// PortfolioDTO portfolioDTO = new PortfolioDTO();
|
||||
// if (CollectionUtil.isNotEmpty(portfolios)) {
|
||||
//// portfolio = portfolios.get(0);
|
||||
// portfolioDTO = CopyUtil.copyObject(portfolios.get(0), PortfolioDTO.class);
|
||||
// beenPublished = 1;
|
||||
// portfolioDTO.setTagsDTO(tagsMapper.getTagByPortfolioId(portfolioDTO.getId()));
|
||||
// }
|
||||
return new ProjectChooseVO(projectDTO.getId(), workspaceVO, process);
|
||||
}
|
||||
|
||||
private UserLikeGroup getByProjectId(Long projectId) {
|
||||
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(UserLikeGroup::getProjectId, projectId);
|
||||
List<UserLikeGroup> userLikeGroupList = userLikeGroupMapper.selectList(qw);
|
||||
if (CollectionUtil.isEmpty(userLikeGroupList)) {
|
||||
throw new BusinessException("Lack of associated userLikeGroup.");
|
||||
}
|
||||
return userLikeGroupList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTrialData(Long userId) {
|
||||
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
||||
@@ -1022,4 +1131,560 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
return attributeRetrieval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ProjectVO> getPage(ProjectQueryDTO query) {
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
// 分页数据
|
||||
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
queryWrapper.eq("account_id", authPrincipalVo.getId());
|
||||
if (!StringUtils.isEmpty(query.getProjectName())) {
|
||||
queryWrapper.like("name", query.getProjectName());
|
||||
}
|
||||
if (Objects.nonNull(query.getStartDate())) {
|
||||
queryWrapper.ge("update_time", new Date(query.getStartDate()));
|
||||
}
|
||||
if (Objects.nonNull(query.getEndDate())) {
|
||||
queryWrapper.le("update_time", new Date(query.getEndDate()));
|
||||
}
|
||||
// 新增分类过滤
|
||||
if (CollectionUtil.isNotEmpty(query.getClassificationIdList())) {
|
||||
List<Long> projectIdList = new ArrayList<>();
|
||||
if (query.getIntersection() == 0) {
|
||||
for (Long classificationId : query.getClassificationIdList()) {
|
||||
projectIdList.addAll(classificationService.getLibraryIdListByClassificationId(classificationId));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(projectIdList)) {
|
||||
queryWrapper.in("id", projectIdList);
|
||||
}else {
|
||||
return new Page<>();
|
||||
}
|
||||
}else {
|
||||
for (int i = 0; i < query.getClassificationIdList().size(); i++) {
|
||||
List<Long> historyIdListByClassificationId = classificationService.getLibraryIdListByClassificationId(query.getClassificationIdList().get(i));
|
||||
if (i == 0) {
|
||||
projectIdList.addAll(historyIdListByClassificationId);
|
||||
}else {
|
||||
projectIdList.retainAll(historyIdListByClassificationId);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(projectIdList)) {
|
||||
return new Page<>();
|
||||
}
|
||||
}
|
||||
queryWrapper.in("id", projectIdList);
|
||||
}
|
||||
}
|
||||
queryWrapper.orderByDesc("update_date");
|
||||
IPage<Project> page = projectMapper.selectPage(
|
||||
new Page<>(query.getPage(), query.getSize()), queryWrapper);
|
||||
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||
return new Page<>();
|
||||
}
|
||||
Set<Long> projectIdSet = page.getRecords().stream().map(Project::getId).collect(Collectors.toSet());
|
||||
QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper = new QueryWrapper<>();
|
||||
userLikeGroupQueryWrapper.lambda().in(UserLikeGroup::getProjectId, projectIdSet);
|
||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(userLikeGroupQueryWrapper);
|
||||
|
||||
List<Long> groupIds = userLikeGroups.stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
||||
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
|
||||
// if (CollectionUtils.isEmpty(groupDetails)) {
|
||||
// throw new BusinessException("groupDetails.not.found");
|
||||
// }
|
||||
Map<Long, List<UserLikeVO>> groupDetailMap = groupDetails.stream()
|
||||
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
|
||||
|
||||
Account account = accountService.getById(authPrincipalVo.getId());
|
||||
IPage<ProjectVO> convert = page.convert((Function<Project, ProjectVO>) project -> {
|
||||
if (project != null) {
|
||||
ProjectVO projectVO = CopyUtil.copyObject(project, ProjectVO.class);
|
||||
projectVO.setUpdateDate(project.getUpdateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
|
||||
QueryWrapper<UserLikeGroup> userLikeGroupQueryWrapper1 = new QueryWrapper<>();
|
||||
userLikeGroupQueryWrapper1.lambda().eq(UserLikeGroup::getProjectId, projectVO.getId());
|
||||
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectOne(userLikeGroupQueryWrapper1);
|
||||
UserLikeGroupVO userLikeGroupVO = CopyUtil.copyObject(userLikeGroup, UserLikeGroupVO.class);
|
||||
userLikeGroupVO.setAuthor(account.getUserName());
|
||||
//count 和detail
|
||||
if (groupDetailMap.keySet().contains(userLikeGroupVO.getId())) {
|
||||
List<UserLikeVO> details = groupDetailMap.get(userLikeGroupVO.getId());
|
||||
for (UserLikeVO detail : details) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId());
|
||||
detail.setUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
}
|
||||
userLikeGroupVO.setGroupDetails(details);
|
||||
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());
|
||||
}else {
|
||||
userLikeGroupVO.setSketchCount(0);
|
||||
}
|
||||
if (userLikeGroupVO.getOriginal() == 0) {
|
||||
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
|
||||
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
|
||||
if (Objects.nonNull(byId)) {
|
||||
String portfolioName = byId.getPortfolioName();
|
||||
userLikeGroupVO.setOriginalPortfolioName(portfolioName);
|
||||
}
|
||||
}
|
||||
projectVO.setUserLikeGroupVO(userLikeGroupVO);
|
||||
return projectVO;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return convert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleChooseVO getModuleContent(ProjectDTO projectDTO) {
|
||||
ModuleChooseVO moduleChooseVO = new ModuleChooseVO();
|
||||
moduleChooseVO.setProjectId(projectDTO.getId());
|
||||
// UserLikeCollectionVO userLikeCollectionVO = new UserLikeCollectionVO();
|
||||
for (String module : projectDTO.getModuleList()) {
|
||||
if (module.equals(Module.colorBoard.name())) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.COLOR_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
moduleChooseVO.setColorBoard(collectionService.resolveColorBoard(collectionElements));
|
||||
}else if (module.equals(Module.moodBoard.name())) {
|
||||
MoodBoardModuleChooseVO moodBoardModuleChooseVO = new MoodBoardModuleChooseVO();
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
qw.lambda().ne(CollectionElement::getCollectionId, 0);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Long collectionId = null;
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
if (collectionElement.getCollectionId() != null) {
|
||||
collectionId = collectionElement.getCollectionId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Collection collection = collectionService.getById(collectionId);
|
||||
if (null != collection.getMoodboardPosition()) {
|
||||
String moodboardPositionString = collectionService.getMoodboardPositionString(collection.getId());
|
||||
if (StringUtils.isEmpty(moodboardPositionString)) {
|
||||
moodBoardModuleChooseVO.setMoodboardPosition(collection.getMoodboardPosition());
|
||||
}else {
|
||||
moodBoardModuleChooseVO.setMoodboardPosition(moodboardPositionString);
|
||||
}
|
||||
}
|
||||
if (collection.getMoodTemplateId() != null) {
|
||||
CollectionElement layoutElement = collectionElementMapper.selectById(collection.getMoodTemplateId());
|
||||
moodBoardModuleChooseVO.setMoodTemplateId(collection.getMoodTemplateId());
|
||||
moodBoardModuleChooseVO.setMoodTemplateName(layoutElement.getName());
|
||||
moodBoardModuleChooseVO.setMoodTemplateUrl(minioUtil.getPreSignedUrl(layoutElement.getUrl(), 24 * 60));
|
||||
}
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
String url = collectionElement.getUrl();
|
||||
collectionElementVO.setOriginalUrl(url);
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
}
|
||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
}
|
||||
moodBoardModuleChooseVO.setMoodBoards(list);
|
||||
moduleChooseVO.setMoodBoard(moodBoardModuleChooseVO);
|
||||
}else if (module.equals(Module.printBoard.name())) {
|
||||
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setIsPin(collectionElement.getHasPin());
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
String url = collectionElement.getUrl();
|
||||
collectionElementVO.setOriginalUrl(url);
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
}
|
||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setPrintBoard(list);
|
||||
}else if (module.equals(Module.sketchBoard.name())) {
|
||||
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectDTO.getId());
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
collectionElementVO.setIsPin(collectionElement.getHasPin());
|
||||
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
String url = collectionElement.getUrl();
|
||||
collectionElementVO.setOriginalUrl(url);
|
||||
if (minioUtil.doesObjectExist(url)) {
|
||||
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
|
||||
if (url.contains(".")) {
|
||||
String[] split = url.split("\\.");
|
||||
collectionElementVO.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
|
||||
} else {
|
||||
collectionElementVO.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
|
||||
}
|
||||
}
|
||||
if (minioUtil.doesObjectExist(collectionElementVO.getOriginalUrl())) {
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setSketchBoard(list);
|
||||
}else if (module.equals(Module.design.name())) {
|
||||
DesignModuleChooseVO vo = new DesignModuleChooseVO();
|
||||
UserLikeGroup group = getByProjectId(projectDTO.getId());
|
||||
Long userGroupId = group.getId();
|
||||
// if (Objects.isNull(group)) {
|
||||
// throw new BusinessException("history.not.found");
|
||||
// }
|
||||
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userGroupId);
|
||||
String sex = null;
|
||||
|
||||
QueryWrapper<UserLikeSort> userLikeSortQw = new QueryWrapper<>();
|
||||
userLikeSortQw.lambda().eq(UserLikeSort::getUserLikeGroupId, userGroupId);
|
||||
List<UserLikeSort> userLikeSortList = userLikeSortMapper.selectList(userLikeSortQw);
|
||||
if (CollectionUtil.isEmpty(userLikeSortList)) {
|
||||
Integer sort = 1;
|
||||
for (UserLikeVO userLikeVO : userLikeVOS) {
|
||||
UserLikeSort userLikeSort = new UserLikeSort();
|
||||
userLikeSort.setUserLikeId(userLikeVO.getId());
|
||||
userLikeSort.setUserLikeGroupId(userGroupId);
|
||||
userLikeSort.setSort(sort);
|
||||
userLikeSortMapper.insert(userLikeSort);
|
||||
sort ++;
|
||||
}
|
||||
}
|
||||
|
||||
userLikeVOS.forEach(o -> {
|
||||
TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
|
||||
o.setUrl(tDesignPythonOutfit1.getDesignUrl());
|
||||
if (o.getUrl().contains("/")) {
|
||||
int index = o.getUrl().lastIndexOf("/");
|
||||
o.setPictureName(o.getUrl().substring(index + 1));
|
||||
}
|
||||
o.setDesignOutfitUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
|
||||
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
|
||||
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfits)) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = tDesignPythonOutfits.get(0);
|
||||
o.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
}
|
||||
|
||||
QueryWrapper<UserLikeSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(UserLikeSort::getUserLikeId, o.getId());
|
||||
List<UserLikeSort> userLikeSorts = userLikeSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(userLikeSorts)) {
|
||||
UserLikeSort userLikeSort = userLikeSorts.get(0);
|
||||
o.setSort(userLikeSort.getSort());
|
||||
o.setUserLikeSortId(userLikeSort.getId());
|
||||
}
|
||||
});
|
||||
vo.setUserGroupId(userGroupId);
|
||||
vo.setUserLikeDetails(userLikeVOS);
|
||||
}else if (module.equals(Module.canvas.name())) {
|
||||
CavasModuleChooseVO vo = new CavasModuleChooseVO();
|
||||
|
||||
UserLikeGroup userLikeGroup = getByProjectId(projectDTO.getId());
|
||||
|
||||
Integer beenPublished = 0;
|
||||
QueryWrapper<Portfolio> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, userLikeGroup.getId());
|
||||
List<Portfolio> portfolios = portfolioMapper.selectList(qw);
|
||||
|
||||
PortfolioDTO portfolioDTO = new PortfolioDTO();
|
||||
if (CollectionUtil.isNotEmpty(portfolios)) {
|
||||
|
||||
portfolioDTO = CopyUtil.copyObject(portfolios.get(0), PortfolioDTO.class);
|
||||
beenPublished = 1;
|
||||
portfolioDTO.setTagsDTO(tagsMapper.getTagByPortfolioId(portfolioDTO.getId()));
|
||||
}
|
||||
vo.setBeenPublished(beenPublished);
|
||||
vo.setPortfolioDTO(portfolioDTO);
|
||||
moduleChooseVO.setCanvas(vo);
|
||||
}else if (module.equals(Module.toProduct.name())) {
|
||||
UserLikeGroup userLikeGroup = getByProjectId(projectDTO.getId());
|
||||
Long userLikeGroupId = userLikeGroup.getId();
|
||||
|
||||
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ToProductImageResult::getIsLike, 1);
|
||||
qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, userLikeGroupId);
|
||||
qw.lambda().eq(ToProductImageResult::getResultType, "ToProductImage");
|
||||
List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(qw);
|
||||
for (ToProductImageResult toProductImageResult : toProductImageResults) {
|
||||
toProductImageResult.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
}
|
||||
List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class);
|
||||
for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) {
|
||||
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
}else {
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setToProduct(toProductImageResultVOS);
|
||||
}else if (module.equals(Module.relight.name())) {
|
||||
UserLikeGroup userLikeGroup = getByProjectId(projectDTO.getId());
|
||||
Long userLikeGroupId = userLikeGroup.getId();
|
||||
|
||||
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ToProductImageResult::getIsLike, 1);
|
||||
qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, userLikeGroupId);
|
||||
qw.lambda().eq(ToProductImageResult::getResultType, "Relight");
|
||||
List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(qw);
|
||||
for (ToProductImageResult toProductImageResult : toProductImageResults) {
|
||||
toProductImageResult.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||
}
|
||||
List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class);
|
||||
for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) {
|
||||
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
||||
}else {
|
||||
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
|
||||
toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setToProduct(toProductImageResultVOS);
|
||||
}
|
||||
}
|
||||
return moduleChooseVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleChooseVO saveModuleContent(ModuleSaveDTO moduleSaveDTO) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
Long projectId = moduleSaveDTO.getProjectId();
|
||||
if (Objects.nonNull(moduleSaveDTO.getMoodBoard())) {
|
||||
MoodBoardModuleSaveDTO moodBoard = moduleSaveDTO.getMoodBoard();
|
||||
if (moodBoard.getMoodTemplateId() != null) {
|
||||
// moodboard合成图存储
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, moduleSaveDTO.getProjectId());
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
qw.lambda().eq(CollectionElement::getCollectionId, 0);
|
||||
List<CollectionElement> compositeImageList = collectionElementMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(compositeImageList)) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
|
||||
collectionElement.setProjectId(moduleSaveDTO.getProjectId());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
|
||||
// 合成图位置信息通过collectElementId关联(旧逻辑通过collectionId关联)
|
||||
designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), collectionElement.getId());
|
||||
}
|
||||
}else {
|
||||
CollectionElement compositeImage = compositeImageList.get(0);
|
||||
if (!Objects.equals(compositeImage.getId(), moodBoard.getMoodTemplateId())) {
|
||||
compositeImage.setProjectId(null);
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(moodBoard.getMoodTemplateId());
|
||||
collectionElement.setProjectId(moduleSaveDTO.getProjectId());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
|
||||
// 合成图位置信息通过collectElementId关联(旧逻辑通过collectionId关联)
|
||||
designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), collectionElement.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<DesignCollectionElementDTO> moodBoards = moodBoard.getMoodBoards();
|
||||
if (CollectionUtil.isNotEmpty(moodBoards)) {
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
qw.lambda().ne(CollectionElement::getCollectionId, 0);
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
|
||||
for (DesignCollectionElementDTO board : moodBoards) {
|
||||
if (board.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) {
|
||||
Library library = libraryMapper.selectById(board.getId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
collectionElement.setName(library.getName());
|
||||
collectionElement.setUrl(library.getUrl());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElement.setMd5(library.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else if (board.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
|
||||
GenerateDetail generateDetail = generateDetailMapper.selectById(board.getId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName());
|
||||
// collectionElement.setName(generateDetail.get());
|
||||
collectionElement.setUrl(generateDetail.getUrl());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElement.setMd5(generateDetail.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else {
|
||||
if (old.contains(board.getId())) {
|
||||
old.remove(board.getId());
|
||||
}else {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getId());
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(moduleSaveDTO.getPrintBoard())){
|
||||
List<DesignCollectionPrintElementDTO> printBoards = moduleSaveDTO.getPrintBoard();
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
|
||||
for (DesignCollectionPrintElementDTO board : printBoards) {
|
||||
if (board.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) {
|
||||
Library library = libraryMapper.selectById(board.getId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(library.getName());
|
||||
collectionElement.setUrl(library.getUrl());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(library.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else if (board.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
|
||||
GenerateDetail generateDetail = generateDetailMapper.selectById(board.getId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
// collectionElement.setName(generateDetail.get());
|
||||
collectionElement.setUrl(generateDetail.getUrl());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(generateDetail.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else {
|
||||
if (old.contains(board.getId())) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getId());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setUpdateDate(new Date());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
old.remove(board.getId());
|
||||
}else {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getId());
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setUpdateDate(new Date());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(moduleSaveDTO.getColorBoard())){
|
||||
List<CollectionColorDTO> colorBoards = moduleSaveDTO.getColorBoard();
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.COLOR_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
|
||||
for (CollectionColorDTO board : colorBoards) {
|
||||
if (old.contains(Long.valueOf(board.getId()))) {
|
||||
old.remove(Long.valueOf(board.getId()));
|
||||
}else {
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel2Type(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName());
|
||||
collectionElement.setName(board.getName());
|
||||
collectionElement.setHasPin((byte) 0);
|
||||
collectionElement.setColorRgb(board.getRgbValue());
|
||||
collectionElement.setMd5("0");
|
||||
collectionElement.setGradientString(board.getGradientString());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}
|
||||
}
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(moduleSaveDTO.getSketchBoard())){
|
||||
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(CollectionElement::getProjectId, projectId);
|
||||
qw.lambda().eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
|
||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(qw);
|
||||
Set<Long> old = collectionElements.stream().map(CollectionElement::getId).collect(Collectors.toSet());
|
||||
List<CollectionSketchDTO> sketchBoards = moduleSaveDTO.getSketchBoard();
|
||||
for (CollectionSketchDTO board : sketchBoards) {
|
||||
if (board.getDesignType().equals(DesignTypeEnum.LIBRARY.getRealName())) {
|
||||
Library library = libraryMapper.selectById(board.getSketchBoardId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setName(library.getName());
|
||||
collectionElement.setUrl(library.getUrl());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(library.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else if (board.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
|
||||
GenerateDetail generateDetail = generateDetailMapper.selectById(board.getSketchBoardId());
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
// collectionElement.setName(generateDetail.get());
|
||||
collectionElement.setUrl(generateDetail.getUrl());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setMd5(generateDetail.getMd5());
|
||||
collectionElement.setCreateDate(new Date());
|
||||
collectionElementMapper.insert(collectionElement);
|
||||
}else {
|
||||
if (old.contains(board.getSketchBoardId())) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getSketchBoardId());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setUpdateDate(new Date());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
old.remove(board.getSketchBoardId());
|
||||
}else {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getSketchBoardId());
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setUpdateDate(new Date());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectionElementMapper.deleteBatchIds(old);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,24 @@ import com.ai.da.common.response.ResultEnum;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
import com.ai.da.mapper.primary.entity.*;
|
||||
import com.ai.da.model.dto.ProjectDTO;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||
import com.ai.da.model.enums.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -30,6 +34,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -46,6 +51,9 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
@Resource
|
||||
private WorkspaceMapper workspaceMapper;
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Resource
|
||||
private StyleMapper styleMapper;
|
||||
|
||||
@@ -67,6 +75,9 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
@Value("${minio.bucketName.users}")
|
||||
private String users;
|
||||
|
||||
@Resource
|
||||
private SysFileService sysFileService;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<WorkspaceVO> selectWorkspacePage(IPage<WorkspaceVO> page, WorkspaceVO workspace) {
|
||||
@@ -583,6 +594,107 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
return styleVOS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Long saveOrUpdateProject(ProjectDTO projectDTO) {
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
if (projectDTO.getId() != null) {
|
||||
Long projectId = projectDTO.getId();
|
||||
|
||||
if (projectDTO.getName() != null) {
|
||||
Project project = projectMapper.selectById(projectId);
|
||||
project.setName(projectDTO.getName());
|
||||
projectMapper.updateById(project);
|
||||
}
|
||||
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Workspace::getProjectId, projectDTO.getId());
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(workspaces)) {
|
||||
throw new BusinessException("Lack of associated workspace.");
|
||||
}else {
|
||||
Workspace workspace = workspaces.get(0);
|
||||
Workspace workspaceNew = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspaceNew.setId(workspace.getId());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
workspaceMapper.updateById(workspaceNew);
|
||||
}
|
||||
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(projectDTO.getWorkspace().getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}else {
|
||||
WorkspaceRelStyle workspaceRelStyleOld = workspaceRelStyles.get(0);
|
||||
if (!Objects.equals(workspaceRelStyleOld.getStyleId(), projectDTO.getStyleId())) {
|
||||
workspaceRelStyleOld.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.updateById(workspaceRelStyleOld);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
QueryWrapper<WorkspaceRelStyle> wRSQW = new QueryWrapper<>();
|
||||
wRSQW.lambda().eq(WorkspaceRelStyle::getWorkspaceId, projectDTO.getWorkspace().getId());
|
||||
List<WorkspaceRelStyle> workspaceRelStyles = workspaceRelStyleMapper.selectList(wRSQW);
|
||||
if (!CollectionUtils.isEmpty(workspaceRelStyles)) {
|
||||
workspaceRelStyleMapper.deleteBatchIds(workspaceRelStyles);
|
||||
}
|
||||
}
|
||||
return projectId;
|
||||
}else {
|
||||
Project project = CopyUtil.copyObject(projectDTO, Project.class);
|
||||
project.setAccountId(userInfo.getId());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
project.setCreateTime(now);
|
||||
project.setUpdateTime(now);
|
||||
projectMapper.insert(project);
|
||||
|
||||
Workspace workspace = CopyUtil.copyObject(projectDTO.getWorkspace(), Workspace.class);
|
||||
workspace.setIsLastIndex(0);
|
||||
workspace.setAccountId(userInfo.getId());
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setCreateTime(LocalDateTime.now());
|
||||
workspace.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
if (projectDTO.getProcess().equals(DesignProcess.SERIES_DESIGN.name())) {
|
||||
SysFile sysFile = sysFileService.getOneBySex(projectDTO.getStyleId(), projectDTO.getWorkspace().getSex());
|
||||
|
||||
if (projectDTO.getWorkspace().getSex().equals(Sex.FEMALE.getValue())) {
|
||||
workspace.setMannequinFemaleId(sysFile.getId());
|
||||
workspace.setMannequinFemaleType("System");
|
||||
}else {
|
||||
workspace.setMannequinMaleId(sysFile.getId());
|
||||
workspace.setMannequinMaleType("System");
|
||||
}
|
||||
}
|
||||
|
||||
workspaceMapper.insert(workspace);
|
||||
|
||||
if (projectDTO.getStyleId() != null) {
|
||||
WorkspaceRelStyle rel = new WorkspaceRelStyle();
|
||||
rel.setWorkspaceId(workspace.getId());
|
||||
rel.setStyleId(projectDTO.getStyleId());
|
||||
workspaceRelStyleMapper.insert(rel);
|
||||
}
|
||||
return project.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getByProjectId(Long projectId) {
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Workspace::getProjectId, projectId);
|
||||
List<Workspace> workspaceList = workspaceMapper.selectList(qw);
|
||||
if (CollectionUtils.isEmpty(workspaceList)) {
|
||||
throw new BusinessException("Lack of associated workspace.");
|
||||
}
|
||||
return workspaceList.get(0).getId();
|
||||
}
|
||||
|
||||
public static List<File> getPNGFiles(String directoryPath) {
|
||||
List<File> pngFiles = new ArrayList<>();
|
||||
File directory = new File(directoryPath);
|
||||
|
||||
@@ -20,7 +20,7 @@ spring.security.jwtExpiration=8640000000
|
||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
||||
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**,\
|
||||
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**
|
||||
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**,/api/project/**
|
||||
spring.security.authApi=/auth/login
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ai.da.mapper.primary.CollectionElementMapper">
|
||||
|
||||
<select id="selectDeleteList" resultType="com.ai.da.mapper.primary.entity.CollectionElement">
|
||||
SELECT * FROM t_collection_element
|
||||
WHERE collection_id not IN
|
||||
(SELECT collection_id FROM t_user_like_group
|
||||
WHERE collection_id != 0
|
||||
GROUP BY collection_id)
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -18,4 +18,11 @@
|
||||
#{createDate});
|
||||
</insert>
|
||||
|
||||
<select id="selectDeleteList" resultType="com.ai.da.mapper.primary.entity.Collection">
|
||||
SELECT * FROM t_collection
|
||||
WHERE id not IN
|
||||
(SELECT collection_id FROM t_user_like_group
|
||||
WHERE collection_id != 0
|
||||
GROUP BY collection_id)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -30,4 +30,11 @@
|
||||
#{createDate});
|
||||
</insert>
|
||||
|
||||
<select id="selectDeleteList" resultType="com.ai.da.mapper.primary.entity.DesignItem">
|
||||
SELECT * FROM t_design_item
|
||||
WHERE collection_id not IN
|
||||
(SELECT collection_id FROM t_user_like_group
|
||||
WHERE collection_id != 0
|
||||
GROUP BY collection_id)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -65,4 +65,11 @@
|
||||
ORDER BY a.account_id ASC;-->
|
||||
</select>
|
||||
|
||||
<select id="selectDeleteList" resultType="com.ai.da.mapper.primary.entity.Design">
|
||||
SELECT * FROM t_design
|
||||
WHERE collection_id not IN
|
||||
(SELECT collection_id FROM t_user_like_group
|
||||
WHERE collection_id != 0
|
||||
GROUP BY collection_id)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -25,4 +25,8 @@
|
||||
select * from t_design_python_outfit_detail where is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListDelete" resultMap="tDesignPythonOutfitDetailResultMap">
|
||||
select * from t_design_python_outfit_detail
|
||||
where is_deleted = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -20,4 +20,8 @@
|
||||
select * from t_design_python_outfit where is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectListDelete" resultMap="tDesignPythonOutfitResultMap">
|
||||
select * from t_design_python_outfit
|
||||
where is_deleted = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -14,13 +14,24 @@
|
||||
|
||||
<insert id="insertUserLikeGroup" parameterType="com.ai.da.mapper.primary.entity.UserLikeGroup" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
insert into t_user_like_group
|
||||
(account_id,collection_id,`name`,create_date,update_date)
|
||||
(account_id,collection_id,`name`,create_date,update_date)
|
||||
values(
|
||||
#{accountId},
|
||||
#{collectionId},
|
||||
#{name},
|
||||
#{createDate},
|
||||
#{updateDate});
|
||||
#{accountId},
|
||||
#{collectionId},
|
||||
#{name},
|
||||
#{createDate},
|
||||
#{updateDate});
|
||||
</insert>
|
||||
|
||||
<select id="getMoreThan50UserLikeAccount" resultMap="BaseResultMap">
|
||||
SELECT d.account_id
|
||||
FROM t_design_item_detail d
|
||||
JOIN t_user_like ul ON d.design_item_id = ul.design_item_id
|
||||
JOIN t_user_like_group ulg ON ul.user_like_group_id = ulg.id
|
||||
WHERE ulg.account_id != -1
|
||||
GROUP BY d.account_id
|
||||
having count(*) >= 200
|
||||
ORDER BY COUNT(*) DESC
|
||||
limit 10;
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user