Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -12,26 +12,26 @@ public class MQConfig {
|
|||||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||||
// ==================================================================
|
// ==================================================================
|
||||||
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
||||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
// public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||||
//
|
//
|
||||||
// public static final String SR_QUEUE = "SR-queue-local";
|
// public static final String SR_QUEUE = "SR-queue-local";
|
||||||
public static final String SR_QUEUE = "SR-queue-dev";
|
// public static final String SR_QUEUE = "SR-queue-dev";
|
||||||
// public static final String SR_QUEUE = "SR-queue-prod";
|
public static final String SR_QUEUE = "SR-queue-prod";
|
||||||
//
|
//
|
||||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
||||||
public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
// public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
|
public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
|
||||||
//
|
//
|
||||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";
|
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";
|
||||||
|
|
||||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-dev";
|
// public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-dev";
|
||||||
// public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-prod";
|
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-prod";
|
||||||
|
|
||||||
public static final String RELIGHT_RESULT_QUEUE = "Relight-dev";
|
// public static final String RELIGHT_RESULT_QUEUE = "Relight-dev";
|
||||||
// public static final String RELIGHT_RESULT_QUEUE = "Relight-prod";
|
public static final String RELIGHT_RESULT_QUEUE = "Relight-prod";
|
||||||
public MQConfig() {
|
public MQConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MyTaskScheduler {
|
|||||||
|
|
||||||
// 定时任务,每十五天执行一次
|
// 定时任务,每十五天执行一次
|
||||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
// @Scheduled(cron = "0 0 0 ? * MON")
|
||||||
// @Scheduled(cron = "0 0 0 */15 * ?")
|
@Scheduled(cron = "0 0 0 */15 * ?")
|
||||||
public void checkExpiry() {
|
public void checkExpiry() {
|
||||||
// 检测正式用户是否快要过期
|
// 检测正式用户是否快要过期
|
||||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||||
@@ -83,7 +83,7 @@ public class MyTaskScheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @Scheduled(cron = "0 0 8 * * ?")
|
@Scheduled(cron = "0 0 8 * * ?")
|
||||||
public void sendTrialOrderExcelToManagements() {
|
public void sendTrialOrderExcelToManagements() {
|
||||||
// 获取前一天日期
|
// 获取前一天日期
|
||||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class AccountTask {
|
|||||||
accountService.refreshCreditsWeekly();
|
accountService.refreshCreditsWeekly();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||||
public void getPaidUser(){
|
public void getPaidUser(){
|
||||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
||||||
accountService.extendValidityForCC();
|
accountService.extendValidityForCC();
|
||||||
@@ -38,7 +38,7 @@ public class AccountTask {
|
|||||||
|
|
||||||
// 2、将到期用户置为游客
|
// 2、将到期用户置为游客
|
||||||
for(Account account : accountList){
|
for(Account account : accountList){
|
||||||
log.info("参与活动的用户到期,置为游客");
|
log.info("参与活动的用户{} : {} 于 {} 账号有效期到期,置为游客",account.getId(),account.getUserEmail(),account.getValidEndTime());
|
||||||
accountService.toVisitor(account);
|
accountService.toVisitor(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class AccountTask {
|
|||||||
|
|
||||||
// 2、将到期用户置为游客
|
// 2、将到期用户置为游客
|
||||||
for(Account account : accountList){
|
for(Account account : accountList){
|
||||||
log.info("用户有效期到期,置为游客");
|
log.info("用户{} : {} 于 {}账号有效期到期,置为游客", account.getId(), account.getUserEmail(),account.getValidEndTime());
|
||||||
accountService.toVisitor(account);
|
accountService.toVisitor(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -154,6 +151,8 @@ public class RedisUtil {
|
|||||||
return redisTemplate.keys(key);
|
return redisTemplate.keys(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getSize(String key){return redisTemplate.opsForSet().size(key);}
|
||||||
|
|
||||||
public List<String> getMultiValue(Set<String> keys){
|
public List<String> getMultiValue(Set<String> keys){
|
||||||
return redisTemplate.opsForValue().multiGet(keys);
|
return redisTemplate.opsForValue().multiGet(keys);
|
||||||
}
|
}
|
||||||
@@ -216,6 +215,19 @@ public class RedisUtil {
|
|||||||
return redisTemplate.opsForValue().increment(key, 0);
|
return redisTemplate.opsForValue().increment(key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getViewCount(String key) {
|
||||||
|
Object value = redisTemplate.opsForValue().get(key);
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
return Long.valueOf((Integer) value);
|
||||||
|
} else if (value instanceof Long) {
|
||||||
|
return (Long) value;
|
||||||
|
} else if (value instanceof String) {
|
||||||
|
return Long.valueOf((String) value);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unexpected value type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final static String PERSONAL_HOMEPAGE_VIEW_KEY = "PersonalHomepage:view:";
|
public final static String PERSONAL_HOMEPAGE_VIEW_KEY = "PersonalHomepage:view:";
|
||||||
|
|
||||||
public void increasePersonalHomepageViewCount(Long accountId) {
|
public void increasePersonalHomepageViewCount(Long accountId) {
|
||||||
@@ -228,5 +240,4 @@ public class RedisUtil {
|
|||||||
return redisTemplate.opsForValue().increment(key, 0);
|
return redisTemplate.opsForValue().increment(key, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,17 +82,16 @@ public class DesignDetailController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "mask数据兼容")
|
@ApiOperation(value = "mask数据兼容")
|
||||||
@PostMapping("/convertWithoutGradient")
|
@GetMapping("/convertWithoutGradient")
|
||||||
public Response<String> convertHistoryMaskWithoutGradient(){
|
public Response<String> convertHistoryMaskWithoutGradient(){
|
||||||
designItemService.convertHistoryMaskWithoutGradient();
|
designItemService.convertHistoryMaskWithoutGradient();
|
||||||
return Response.success("success");
|
return Response.success("success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@ApiOperation(value = "mask数据库路径更新")
|
||||||
private UserLikeService userLikeService;
|
@GetMapping("/updateMaskUrl")
|
||||||
@ApiOperation(value = "获取历史like中包含有渐变色的design")
|
public Response<String> updateMaskUrl(){
|
||||||
@PostMapping("/getHistoryLikeWithGradient")
|
designItemService.updateMaskUrl();
|
||||||
public Response<List<Map<String, Long>>> getHistoryLikeWithGradient(){
|
return Response.success("success");
|
||||||
return Response.success(userLikeService.getHistoryLikeWithGradient());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.ai.da.controller;
|
|||||||
|
|
||||||
import com.ai.da.common.response.Response;
|
import com.ai.da.common.response.Response;
|
||||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
import com.ai.da.model.dto.GenerateLikeDTO;
|
||||||
|
import com.ai.da.model.dto.GenerateModifyDTO;
|
||||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||||
|
import com.ai.da.model.dto.ImageToSketchDTO;
|
||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.service.GenerateService;
|
import com.ai.da.service.GenerateService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -83,5 +85,17 @@ public class GenerateController {
|
|||||||
return Response.success(generateResult);
|
return Response.success(generateResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "imageToSketch")
|
||||||
|
@PostMapping("/imageToSketch")
|
||||||
|
public Response<GenerateResultVO> imageToSketch(@Valid @RequestBody ImageToSketchDTO imageToSketchDTO) {
|
||||||
|
return Response.success(generateService.imageToSketch(imageToSketchDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
// modifySketch
|
||||||
|
@ApiOperation(value = "modifySketch")
|
||||||
|
@PostMapping("/modifySketch")
|
||||||
|
public Response<CollectionElementVO> modifySketch(@Valid @RequestBody GenerateModifyDTO generateModifyDTO) {
|
||||||
|
return Response.success(generateService.modifySketch(generateModifyDTO));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ public class SavedCollectionController {
|
|||||||
}
|
}
|
||||||
List<Long> groupIds = page.getRecords().stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
List<Long> groupIds = page.getRecords().stream().map(UserLikeGroup::getId).collect(Collectors.toList());
|
||||||
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
|
List<UserLikeVO> groupDetails = userLikeService.getGroupDetails(groupIds);
|
||||||
if (CollectionUtils.isEmpty(groupDetails)) {
|
// if (CollectionUtils.isEmpty(groupDetails)) {
|
||||||
throw new BusinessException("groupDetails.not.found");
|
// throw new BusinessException("groupDetails.not.found");
|
||||||
}
|
// }
|
||||||
Map<Long, List<UserLikeVO>> groupDetailMap = groupDetails.stream()
|
Map<Long, List<UserLikeVO>> groupDetailMap = groupDetails.stream()
|
||||||
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
|
.collect(Collectors.groupingBy(UserLikeVO::getUserLikeGroupId));
|
||||||
|
|
||||||
@@ -117,13 +117,17 @@ public class SavedCollectionController {
|
|||||||
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
|
userLikeGroupVO.setUpdateDate(group.getUpdateDate().getTime());
|
||||||
userLikeGroupVO.setAuthor(account.getUserName());
|
userLikeGroupVO.setAuthor(account.getUserName());
|
||||||
//count 和detail
|
//count 和detail
|
||||||
List<UserLikeVO> details = groupDetailMap.get(group.getId());
|
if (groupDetailMap.keySet().contains(group.getId())) {
|
||||||
for (UserLikeVO detail : details) {
|
List<UserLikeVO> details = groupDetailMap.get(group.getId());
|
||||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId());
|
for (UserLikeVO detail : details) {
|
||||||
detail.setUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
|
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);
|
||||||
}
|
}
|
||||||
userLikeGroupVO.setGroupDetails(details);
|
|
||||||
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());
|
|
||||||
if (userLikeGroupVO.getOriginal() == 0) {
|
if (userLikeGroupVO.getOriginal() == 0) {
|
||||||
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
|
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
|
||||||
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
|
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
|||||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfitDetail;
|
import com.ai.da.mapper.primary.entity.TDesignPythonOutfitDetail;
|
||||||
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import io.lettuce.core.dynamic.annotation.Param;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -24,4 +26,7 @@ public interface TDesignPythonOutfitDetailMapper extends CommonMapper<TDesignPyt
|
|||||||
*/
|
*/
|
||||||
List<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
|
List<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail);
|
||||||
|
|
||||||
|
@Delete("DELETE FROM t_design_python_outfit_detail WHERE design_python_outfit_id = #{designPythonOutfitId}")
|
||||||
|
void deleteByDesignPythonOutfitIdPhysical(@Param("designPythonOutfitId") Long designPythonOutfitId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,4 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface UserLikeMapper extends CommonMapper<UserLike> {
|
public interface UserLikeMapper extends CommonMapper<UserLike> {
|
||||||
|
|
||||||
List<Map<String, Long>> getHistoryLikeWithoutGradient();
|
|
||||||
|
|
||||||
List<Map<String, Long>> getHistoryLikeWithGradient();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,19 @@ public class Generate {
|
|||||||
*/
|
*/
|
||||||
private String seed;
|
private String seed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 -> 粗
|
||||||
|
* 2 -> 中
|
||||||
|
* 3 -> 细
|
||||||
|
* custom -> 自定义
|
||||||
|
*/
|
||||||
|
private String sketchStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sketch 风格参考图的collection_element_id
|
||||||
|
*/
|
||||||
|
private Long styleImageElementId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
18
src/main/java/com/ai/da/model/dto/GenerateModifyDTO.java
Normal file
18
src/main/java/com/ai/da/model/dto/GenerateModifyDTO.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ApiModel("修改imageToSketch提取出的sketch")
|
||||||
|
@Data
|
||||||
|
public class GenerateModifyDTO {
|
||||||
|
@ApiModelProperty("需要保存的图片的base64格式")
|
||||||
|
private String base64;
|
||||||
|
|
||||||
|
@ApiModelProperty("sketch所属性别")
|
||||||
|
private String gender;
|
||||||
|
|
||||||
|
@ApiModelProperty("sketch所属分类")
|
||||||
|
private String category;
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class GenerateThroughImageTextDTO {
|
|||||||
@ApiModelProperty("text image text-image")
|
@ApiModelProperty("text image text-image")
|
||||||
String generateType;
|
String generateType;
|
||||||
|
|
||||||
@ApiModelProperty("图片是update,还是从library中选择 collection || library")
|
@ApiModelProperty("图片来源:update,从library中选择,从toProductImage结果中选择 collection || library || productImage")
|
||||||
String designType;
|
String designType;
|
||||||
|
|
||||||
@NotBlank(message = "level1Type cannot be empty!")
|
@NotBlank(message = "level1Type cannot be empty!")
|
||||||
|
|||||||
22
src/main/java/com/ai/da/model/dto/ImageToSketchDTO.java
Normal file
22
src/main/java/com/ai/da/model/dto/ImageToSketchDTO.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package com.ai.da.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ApiModel("image to sketch")
|
||||||
|
@Data
|
||||||
|
public class ImageToSketchDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("上传图片的collection_element_id")
|
||||||
|
private Long elementId;
|
||||||
|
|
||||||
|
@ApiModelProperty("sketch线条风格 1->粗, 2->中, 3->细,传数字,自定义风格时,传空 ")
|
||||||
|
private String style;
|
||||||
|
|
||||||
|
@ApiModelProperty("自定义线条风格,上传图片的collection_element_id")
|
||||||
|
private Long styleImageId;
|
||||||
|
|
||||||
|
@ApiModelProperty("性别")
|
||||||
|
private String gender;
|
||||||
|
}
|
||||||
18
src/main/java/com/ai/da/model/enums/SketchGenerateType.java
Normal file
18
src/main/java/com/ai/da/model/enums/SketchGenerateType.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ai.da.model.enums;
|
||||||
|
|
||||||
|
public enum SketchGenerateType implements IEnumDisplay{
|
||||||
|
GENERATE("generate"),
|
||||||
|
|
||||||
|
EXTRACT("extract"),;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
SketchGenerateType(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/com/ai/da/model/enums/SketchStyle.java
Normal file
20
src/main/java/com/ai/da/model/enums/SketchStyle.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ai.da.model.enums;
|
||||||
|
|
||||||
|
public enum SketchStyle implements IEnumDisplay{
|
||||||
|
|
||||||
|
THICK("1"),
|
||||||
|
|
||||||
|
MEDIUM("2"),
|
||||||
|
|
||||||
|
THIN("3");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
SketchStyle(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,9 +28,10 @@ public class GenerateResultVO {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenerateResultVO(Long id, String url, String status) {
|
public GenerateResultVO(Long id, String url, String status, String category) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
this.category = category;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ public class PythonService {
|
|||||||
private String accessPythonIp;
|
private String accessPythonIp;
|
||||||
@Value("${access.python.port:''}")
|
@Value("${access.python.port:''}")
|
||||||
private String accessPythonPort;
|
private String accessPythonPort;
|
||||||
@Value("${access.python.address}")
|
|
||||||
private String fastApiPythonAddress;
|
|
||||||
@Value("${minio.bucketName.gradient}")
|
@Value("${minio.bucketName.gradient}")
|
||||||
private String gradientBucketName;
|
private String gradientBucketName;
|
||||||
@Value("${access.python.generate_sr_port}")
|
@Value("${access.python.generate_sr_port}")
|
||||||
@@ -2663,8 +2661,6 @@ public class PythonService {
|
|||||||
minioPath = minioUtil.base64UploadToPath(colorImg, gradientBucketName, null);
|
minioPath = minioUtil.base64UploadToPath(colorImg, gradientBucketName, null);
|
||||||
designSingleItem.getGradient().setColorImg(null);
|
designSingleItem.getGradient().setColorImg(null);
|
||||||
gradientString = JSONObject.toJSONString(designSingleItem.getGradient());
|
gradientString = JSONObject.toJSONString(designSingleItem.getGradient());
|
||||||
|
|
||||||
// todo 当渐变色不为空时,是否需要将颜色置为 0 0 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintToPython printToPython = resolveDesignSinglePrint(designSingleItem.getPrintObject().getPrints());
|
PrintToPython printToPython = resolveDesignSinglePrint(designSingleItem.getPrintObject().getPrints());
|
||||||
@@ -3470,4 +3466,64 @@ public class PythonService {
|
|||||||
//生成失败
|
//生成失败
|
||||||
throw new BusinessException("relightImage.interface.exception");
|
throw new BusinessException("relightImage.interface.exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String imageToSketch(String imagePath, String bucket, String objectName, String styleCode, String styleImageUrl){
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||||
|
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||||
|
.build();
|
||||||
|
MediaType paramMap = MediaType.parse("application/json");
|
||||||
|
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("image_url", imagePath);
|
||||||
|
map.put("style_image_url", styleImageUrl);
|
||||||
|
map.put("default_style", styleCode);
|
||||||
|
map.put("sketch_bucket", bucket);
|
||||||
|
map.put("sketch_name", objectName);
|
||||||
|
|
||||||
|
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||||
|
log.info("ImageToSketch请求python 参数:####{}", param);
|
||||||
|
RequestBody body = RequestBody.create(paramMap, param);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(accessPythonIp + ":" + accessPythonPort + "/api/image2sketch")
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Authorization", "Basic YWlkbGFiOjEyMw==")
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
Response response;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = client.newCall(request).execute();
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
log.error("PythonService##ImageToSketch异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
|
throw new BusinessException("generate.interface.error");
|
||||||
|
}
|
||||||
|
int responseCode = response.code();
|
||||||
|
String bodyString;
|
||||||
|
try {
|
||||||
|
bodyString = response.body().string();
|
||||||
|
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||||
|
// 基本不会有除200以外的code
|
||||||
|
log.info("ImageToSketch 失败。 Response code {}", responseCode);
|
||||||
|
throw new BusinessException("ImageToSketch 失败。 Response code " + responseCode);
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(bodyString);
|
||||||
|
if (response.isSuccessful() && jsonObject.get("msg").equals("OK!")) {
|
||||||
|
String sketchResult = jsonObject.get("data").toString();
|
||||||
|
log.info("ImageToSketch 结果 : {}", sketchResult);
|
||||||
|
return sketchResult;
|
||||||
|
}else {
|
||||||
|
log.info("ImageToSketch 失败。 Response code {}", responseCode);
|
||||||
|
throw new BusinessException("ImageToSketch 失败。 Response code " + responseCode);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("ImageToSketch 失败; error message => {}", e.getMessage());
|
||||||
|
response.close();
|
||||||
|
throw new BusinessException("generate.interface.error");
|
||||||
|
} finally {
|
||||||
|
response.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,6 @@ public interface DesignItemService extends IService<DesignItem> {
|
|||||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||||
|
|
||||||
void convertHistoryMaskWithoutGradient();
|
void convertHistoryMaskWithoutGradient();
|
||||||
|
|
||||||
|
void updateMaskUrl();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.ai.da.service;
|
|||||||
import com.ai.da.mapper.primary.entity.Generate;
|
import com.ai.da.mapper.primary.entity.Generate;
|
||||||
import com.ai.da.mapper.primary.entity.GenerateDetail;
|
import com.ai.da.mapper.primary.entity.GenerateDetail;
|
||||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
import com.ai.da.model.dto.GenerateLikeDTO;
|
||||||
|
import com.ai.da.model.dto.GenerateModifyDTO;
|
||||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||||
|
import com.ai.da.model.dto.ImageToSketchDTO;
|
||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
@@ -41,4 +43,8 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
void processRelightResult(String taskId, String url, String category);
|
void processRelightResult(String taskId, String url, String category);
|
||||||
|
|
||||||
List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList);
|
List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||||
|
|
||||||
|
GenerateResultVO imageToSketch(ImageToSketchDTO imageToSketchDTO);
|
||||||
|
|
||||||
|
CollectionElementVO modifySketch(GenerateModifyDTO generateModifyDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
|
|||||||
|
|
||||||
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail, List<Long> offset);
|
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail, List<Long> offset);
|
||||||
|
|
||||||
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
|
void deleteByDesignPythonOutfitIdLogical(Long designPythonOutfitId);
|
||||||
|
|
||||||
|
void deleteByDesignPythonOutfitIdPhysical(Long designPythonOutfitId);
|
||||||
|
|
||||||
void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details);
|
void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,4 @@ public interface UserLikeService extends IService<UserLike> {
|
|||||||
void updateDate(Long designItemId,String timeZone);
|
void updateDate(Long designItemId,String timeZone);
|
||||||
|
|
||||||
List<UserLike> getUserLikeList(Long id);
|
List<UserLike> getUserLikeList(Long id);
|
||||||
|
|
||||||
List<Map<String, Long>> getHistoryLikeWithGradient();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,19 +322,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("BINARY user_email", email);
|
queryWrapper.eq("BINARY user_email", email);
|
||||||
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
log.info(accountList.toString());
|
|
||||||
if (CollectionUtil.isEmpty(accountList)) {
|
if (CollectionUtil.isEmpty(accountList)) {
|
||||||
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||||
}
|
}
|
||||||
return accountList.get(0);
|
return accountList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忽略大小写
|
private Account getByEmailIgnoreCase(String email) {
|
||||||
private Account getAccountByEmail(String email) {
|
|
||||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("user_email", email);
|
queryWrapper.eq("user_email", email);
|
||||||
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
log.info(accountList.toString());
|
|
||||||
if (CollectionUtil.isEmpty(accountList)) {
|
if (CollectionUtil.isEmpty(accountList)) {
|
||||||
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||||
}
|
}
|
||||||
@@ -1043,10 +1040,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (StringUtils.isBlank(accountDesignWorksRegisterDTO.getLanguage())) {
|
if (StringUtils.isBlank(accountDesignWorksRegisterDTO.getLanguage())) {
|
||||||
account.setLanguage(Language.ENGLISH.name());
|
account.setLanguage(Language.ENGLISH.name());
|
||||||
}
|
}
|
||||||
account.setIsTrial(1);
|
account.setIsTrial(0);
|
||||||
account.setIsBeginner(1);
|
account.setIsBeginner(1);
|
||||||
|
account.setValidStartTime(Instant.now().toEpochMilli());
|
||||||
account.setCreateDate(new Date());
|
account.setCreateDate(new Date());
|
||||||
account.setCredits(BigDecimal.valueOf(100));
|
account.setCredits(BigDecimal.valueOf(0));
|
||||||
accountMapper.insert(account);
|
accountMapper.insert(account);
|
||||||
AccountLoginVO response = CopyUtil.copyObject(account, AccountLoginVO.class);
|
AccountLoginVO response = CopyUtil.copyObject(account, AccountLoginVO.class);
|
||||||
response.setEmail(account.getUserEmail());
|
response.setEmail(account.getUserEmail());
|
||||||
@@ -1133,7 +1131,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
Boolean flag = Boolean.FALSE;
|
Boolean flag = Boolean.FALSE;
|
||||||
try {
|
try {
|
||||||
// 不是新用户 直接延长使用期限
|
// 不是新用户 直接延长使用期限
|
||||||
userInfo = getAccountByEmail(email);
|
userInfo = getByEmailIgnoreCase(email);
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
// 通过邮箱找不到用户 说明是新用户 => 创建用户
|
// 通过邮箱找不到用户 说明是新用户 => 创建用户
|
||||||
flag = Boolean.TRUE;
|
flag = Boolean.TRUE;
|
||||||
@@ -1303,6 +1301,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
account.setUserName(email);
|
account.setUserName(email);
|
||||||
account.setUserPassword("Third-000000");
|
account.setUserPassword("Third-000000");
|
||||||
account.setLanguage(Language.ENGLISH.name());
|
account.setLanguage(Language.ENGLISH.name());
|
||||||
|
account.setValidStartTime(Instant.now().toEpochMilli());
|
||||||
account.setCreateDate(new Date());
|
account.setCreateDate(new Date());
|
||||||
account.setIsTrial(0);
|
account.setIsTrial(0);
|
||||||
account.setIsBeginner(1);
|
account.setIsBeginner(1);
|
||||||
|
|||||||
@@ -23,21 +23,27 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.mysql.cj.util.StringUtils;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,6 +91,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
|
|
||||||
@Value("${minio.bucketName.clothing}")
|
@Value("${minio.bucketName.clothing}")
|
||||||
private String clothingBucket;
|
private String clothingBucket;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long saveOne(DesignItem designItem) {
|
public Long saveOne(DesignItem designItem) {
|
||||||
@@ -372,7 +380,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
designPythonOutfitService.updateById(designPythonOutfit);
|
designPythonOutfitService.updateById(designPythonOutfit);
|
||||||
|
|
||||||
// 6、删除designPythonOutfitDetail表中原始的图层信息(逻辑删除)
|
// 6、删除designPythonOutfitDetail表中原始的图层信息(逻辑删除)
|
||||||
designPythonOutfitDetailService.deleteByDesignPythonOutfitId(designPythonOutfit.getId());
|
designPythonOutfitDetailService.deleteByDesignPythonOutfitIdLogical(designPythonOutfit.getId());
|
||||||
|
|
||||||
// 7、将新生成的图层信息存入designPythonOutfitDetail表
|
// 7、将新生成的图层信息存入designPythonOutfitDetail表
|
||||||
JSONArray layers = outfit.getJSONArray("layers");
|
JSONArray layers = outfit.getJSONArray("layers");
|
||||||
@@ -497,8 +505,15 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
// 所以,这里选择使用system或collection相同的地址,只是放在不同的桶,这样能保证图片服务器上,类似的sketch不会存在很多
|
// 所以,这里选择使用system或collection相同的地址,只是放在不同的桶,这样能保证图片服务器上,类似的sketch不会存在很多
|
||||||
sketchBase64ToPath(designSingleIncludeLayersDTO);
|
sketchBase64ToPath(designSingleIncludeLayersDTO);
|
||||||
|
|
||||||
// todo 将标注后的mask上传到minio,并将minio地址传给python端
|
// 将标注后的mask上传到minio,并将minio地址传给python端
|
||||||
maskBase64ToPath(designSingleIncludeLayersDTO);
|
// todo 如何当前design使用的仍是旧的mask 则置maskUrl为null
|
||||||
|
// 1、查询当前design item在不在history中
|
||||||
|
UserLike userLikeDesign = userLikeService.getByDesignItemId(designItem.getId());
|
||||||
|
Boolean setNull = Boolean.FALSE;
|
||||||
|
if (!Objects.isNull(userLikeDesign) && userLikeDesign.getConverted() == 0){
|
||||||
|
setNull = Boolean.TRUE;
|
||||||
|
}
|
||||||
|
maskBase64ToPath(designSingleIncludeLayersDTO, setNull);
|
||||||
|
|
||||||
// 组装入参
|
// 组装入参
|
||||||
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
|
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
|
||||||
@@ -581,22 +596,26 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){
|
private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Boolean setNull){
|
||||||
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
|
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
|
||||||
// 如果sketch截图不为空,则将该截图上传,并替换path
|
// 如果sketch截图不为空,则将该截图上传,并替换path
|
||||||
if (!StringUtil.isNullOrEmpty(item.getMaskUrl())){
|
if (setNull){
|
||||||
// 由于前端不好处理这块,所以,当mask没有做任何修改的时候,仍然会传原始mask的minio地址
|
item.setMaskUrl(null);
|
||||||
if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")){
|
}else {
|
||||||
// 当没有修改mask时,还是用之前的mask地址
|
if (!StringUtil.isNullOrEmpty(item.getMaskUrl())){
|
||||||
item.setMaskUrl(item.getMaskMinioUrl());
|
// 由于前端不好处理这块,所以,当mask没有做任何修改的时候,仍然会传原始mask的minio地址
|
||||||
}else {
|
if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")){
|
||||||
// 将原图地址作为修改后的图片地址,放在不同的桶
|
// 当没有修改mask时,还是用之前的mask地址
|
||||||
String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID());
|
item.setMaskUrl(item.getMaskMinioUrl());
|
||||||
if (StringUtil.isNullOrEmpty(path)){
|
}else {
|
||||||
log.error("标注的mask图片上传失败");
|
// 将原图地址作为修改后的图片地址,放在不同的桶
|
||||||
throw new BusinessException("image.modify.failed");
|
String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID());
|
||||||
|
if (StringUtil.isNullOrEmpty(path)){
|
||||||
|
log.error("标注的mask图片上传失败");
|
||||||
|
throw new BusinessException("image.modify.failed");
|
||||||
|
}
|
||||||
|
item.setMaskUrl(path);
|
||||||
}
|
}
|
||||||
item.setMaskUrl(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -909,228 +928,157 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo 1、新增一个字段 用于记录历史like的design中 没有新的mask的design
|
|
||||||
// 2、获取design detail时,当其design_item_id和design_python_outfit_id在like中时,重新调用design,并更新标志字段
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserLikeMapper userLikeMapper;
|
private UserLikeMapper userLikeMapper;
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void convertHistoryMaskWithoutGradient(){
|
public void convertHistoryMaskWithoutGradient(){
|
||||||
|
// 1、获取全部需要转换的designOutfitId
|
||||||
|
// 1、获取t_user_like表中design_item_id不为-1的所有design_item_id, design_outfit_id
|
||||||
|
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.ne("design_item_id", -1)
|
||||||
|
.ne("converted", 1)
|
||||||
|
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id");
|
||||||
|
|
||||||
// 查询用户like过的design 且没有使用渐变色的 design_item_id和design_python_outfit_id
|
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
|
||||||
List<Map<String, Long>> historyLikeWithoutGradient = userLikeMapper.getHistoryLikeWithoutGradient();
|
// List<Map<String, Object>> userLikes = userLikeMapper.selectMaps(queryWrapper);
|
||||||
log.info("historyLikeWithoutGradient total count : {}", historyLikeWithoutGradient.size());
|
log.info("userLike 总数 :{}", userLikes.size());
|
||||||
// 遍历list
|
// 用于存储结果
|
||||||
// 先试一下,刷新10条,需要花费的时间
|
List<String[]> pairs = new ArrayList<>();
|
||||||
|
AtomicInteger count = new AtomicInteger();
|
||||||
|
|
||||||
/*Map<String, Long> userLikeMap = historyLikeWithoutGradient.get(0);
|
// 2、查询指定designOutfitId对应的mask
|
||||||
log.info("test 替换mask" + userLikeMap.toString());
|
userLikes.forEach(item -> {
|
||||||
|
// 存储数据,按前缀分组
|
||||||
|
Map<Integer, Map<String, String>> groupedData = new HashMap<>();
|
||||||
|
Long designItemId = item.getDesignItemId();
|
||||||
|
Long designOutfitId = item.getDesignOutfitId();
|
||||||
|
|
||||||
// 查每个design_item_id和design_python_outfit_id的detail
|
List<TDesignPythonOutfitDetail> designPythonOutfitDetails = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designOutfitId);
|
||||||
DesignItemDetailVO detail = designService.detail(userLikeMap.get("design_outfit_id"), userLikeMap.get("design_item_id"));
|
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designItemId);
|
||||||
Long accountId = userLikeMap.get("account_id");
|
// 为没有优先级的sketch添加优先级
|
||||||
// 组装参数
|
designItemDetailService.setDesignItemDetailPriority(designItemDetails);
|
||||||
DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO = convertToDesignSingleIncludeLayersDTO(detail, accountId);
|
// 为没有优先级的图层添加优先级
|
||||||
if (Objects.isNull(designSingleIncludeLayersDTO)){
|
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(designPythonOutfitDetails);
|
||||||
throw new BusinessException("cannot find model");
|
Map<Integer, String> designItemPath = designItemDetails.stream()
|
||||||
}
|
.filter(designItemDetail -> !designItemDetail.getType().equals("Body"))
|
||||||
// 调用design single
|
.collect(Collectors.toMap(
|
||||||
designSingleIncludeLayers(designSingleIncludeLayersDTO, accountId);
|
DesignItemDetail::getPriority, // key: category 转为小写
|
||||||
|
DesignItemDetail::getPath // value: path 字段
|
||||||
|
));
|
||||||
|
// 遍历列表,拿出每个种类的前后片
|
||||||
|
designPythonOutfitDetails.forEach(designPythonOutfitDetail -> {
|
||||||
|
String imageCategory = designPythonOutfitDetail.getImageCategory();
|
||||||
|
String maskPath = designPythonOutfitDetail.getMaskUrl();
|
||||||
|
Integer priority = Math.abs(designPythonOutfitDetail.getPriority());
|
||||||
|
|
||||||
// 标志字段置为1
|
// 提取前缀和后缀
|
||||||
UserLike userLike = new UserLike();
|
if (imageCategory.contains("_")) {
|
||||||
userLike.setId(userLikeMap.get("id"));
|
String[] parts = imageCategory.split("_");
|
||||||
userLike.setConverted(1);
|
// String prefix = parts[0];
|
||||||
|
String suffix = parts[1];
|
||||||
|
|
||||||
userLikeMapper.updateById(userLike);*/
|
// 初始化前缀组
|
||||||
long start = System.currentTimeMillis();
|
groupedData.putIfAbsent(priority, new HashMap<>());
|
||||||
for (int i = 0; i < 10; i++){
|
groupedData.get(priority).put(suffix, maskPath);
|
||||||
try {
|
|
||||||
Map<String, Long> userLikeMap = historyLikeWithoutGradient.get(0);
|
|
||||||
log.info("test 替换mask" + userLikeMap.toString());
|
|
||||||
Long designItemId = userLikeMap.get("design_item_id");
|
|
||||||
Long designOutfitId = userLikeMap.get("design_outfit_id");
|
|
||||||
|
|
||||||
// 查每个design_item_id和design_python_outfit_id的detail
|
|
||||||
DesignItemDetailVO detail = designService.detail(designOutfitId, designItemId);
|
|
||||||
Long accountId = userLikeMap.get("account_id");
|
|
||||||
// 组装参数
|
|
||||||
DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO = convertToDesignSingleIncludeLayersDTO(detail, accountId);
|
|
||||||
if (Objects.isNull(designSingleIncludeLayersDTO)){
|
|
||||||
throw new BusinessException("cannot find model. designItemId: " + designItemId + "designOutfitId : " + designOutfitId );
|
|
||||||
}
|
}
|
||||||
// 调用design single
|
});
|
||||||
designSingleIncludeLayers(designSingleIncludeLayersDTO, accountId);
|
|
||||||
|
|
||||||
// 标志字段置为1
|
// 查找成对的front和back
|
||||||
UserLike userLike = new UserLike();
|
for (Map.Entry<Integer, Map<String, String>> entry : groupedData.entrySet()) {
|
||||||
userLike.setId(userLikeMap.get("id"));
|
Map<String, String> suffixes = entry.getValue();
|
||||||
userLike.setConverted(1);
|
if (suffixes.containsKey("front") && suffixes.containsKey("back")) {
|
||||||
|
String frontMask = suffixes.get("front");
|
||||||
userLikeMapper.updateById(userLike);
|
String backMask = suffixes.get("back");
|
||||||
}catch (BusinessException e){
|
pairs.add(new String[]{designItemPath.get(entry.getKey()),frontMask, backMask, frontMask});
|
||||||
log.error("mask convert error : {}", e.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
log.info("总数 count + current : {} + {} = {}", count, groupedData.size(), count.get() + groupedData.size());
|
||||||
long end = System.currentTimeMillis();
|
count.addAndGet(groupedData.size());
|
||||||
|
|
||||||
log.info("convert mask ,10条 执行时长:" + (end - start) + "毫秒");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DesignSingleIncludeLayersDTO convertToDesignSingleIncludeLayersDTO(DesignItemDetailVO designItemDetailVO, Long userId){
|
|
||||||
DesignSingleIncludeLayersDTO resp = new DesignSingleIncludeLayersDTO();
|
|
||||||
|
|
||||||
Long designItemId = designItemDetailVO.getDesignItemId();
|
|
||||||
String gender ;
|
|
||||||
String modelPath = designItemDetailVO.getOthers().get(0).getMinIOPath();
|
|
||||||
List<SysFileVO> modelSysFile = sysFileService.getByUrlList(Collections.singletonList(modelPath));
|
|
||||||
if (modelSysFile.isEmpty()){
|
|
||||||
log.error("cannot find model 【{}】 in t_sys_file ", modelPath);
|
|
||||||
return null;
|
|
||||||
}else {
|
|
||||||
gender = modelSysFile.get(0).getLevel2Type();
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.setDesignItemId(designItemId);
|
|
||||||
resp.setGender(gender);
|
|
||||||
resp.setIsPreview(Boolean.FALSE);
|
|
||||||
resp.setProcessId(String.valueOf(userId));
|
|
||||||
resp.setTimeZone("Etc/GMT-8");
|
|
||||||
List<DesignSingleItemDTO> designSingleItemDTOS = new ArrayList<>();
|
|
||||||
resp.setDesignSingleItemDTOList(designSingleItemDTOS);
|
|
||||||
|
|
||||||
designItemDetailVO.getClothes().forEach(cloth -> {
|
|
||||||
DesignSingleItemDTO itemDTO = CopyUtil.copyObject(cloth, DesignSingleItemDTO.class);
|
|
||||||
itemDTO.setChanged(Boolean.FALSE);
|
|
||||||
itemDTO.setDesignType("Library");
|
|
||||||
itemDTO.setPath(cloth.getMinIOPath());
|
|
||||||
PantoneVO color = cloth.getColor();
|
|
||||||
String colorString = color.getR() + " " + color.getG() + " " + color.getB();
|
|
||||||
itemDTO.setColor(colorString);
|
|
||||||
if (cloth.getLayersObject().isEmpty()){
|
|
||||||
itemDTO.setOffset(Arrays.asList(0L,0L));
|
|
||||||
itemDTO.setScale(new Float[]{1.0f,1.0f});
|
|
||||||
}else {
|
|
||||||
DesignPythonOutfitVO designPythonOutfitVO = cloth.getLayersObject().get(0);
|
|
||||||
itemDTO.setOffset(designPythonOutfitVO.getOffset());
|
|
||||||
itemDTO.setScale(designPythonOutfitVO.getScale());
|
|
||||||
}
|
|
||||||
// 统一设置mask为null,不用旧版mask
|
|
||||||
itemDTO.setMaskMinioUrl(null);
|
|
||||||
designSingleItemDTOS.add(itemDTO);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return resp;
|
// 将结果写入JSON文件
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // 格式化JSON输出
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 写入JSON文件
|
||||||
|
objectMapper.writeValue(new File("mask_pairs.json"), pairs);
|
||||||
|
log.info("待合成mask的数量:{}",pairs.size());
|
||||||
|
System.out.println("数据已成功写入mask_pairs.json文件");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// temp 用于处理历史like的design没有新的mask的问题
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long userId) {
|
public void updateMaskUrl(){
|
||||||
// 记录入参 base64数据太长,所以这里去掉
|
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
|
||||||
DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO);
|
queryWrapper.ne("design_item_id", -1)
|
||||||
clone.getDesignSingleItemDTOList().forEach( i -> {
|
.ne("converted", 1)
|
||||||
// 渐变色
|
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id");
|
||||||
if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){
|
|
||||||
log.info("set gradient colorImage为空,便于日志打印");
|
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
|
||||||
i.getGradient().setColorImg(null);
|
log.info("userLike 总数 :{}", userLikes.size());
|
||||||
}
|
ArrayList<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = new ArrayList<>();
|
||||||
// 画笔修改过的sketch
|
|
||||||
if (!StringUtil.isNullOrEmpty(i.getSketchString())){
|
|
||||||
log.info("set sketchString为空,便于日志打印");
|
// 2、查询指定designOutfitId对应的mask
|
||||||
i.setSketchString(null);
|
userLikes.forEach(item -> {
|
||||||
}
|
Long designOutfitId = item.getDesignOutfitId();
|
||||||
// 标注过的mask
|
|
||||||
if (!StringUtil.isNullOrEmpty(i.getMaskUrl())){
|
// 存储以front结尾的mask路径
|
||||||
log.info("set labelingMask为空,便于日志打印");
|
Map<String, String> frontMaskMap = new HashMap<>();
|
||||||
i.setMaskUrl(null);
|
HashMap<String, Long> backMaskIdMap = new HashMap<>();
|
||||||
}else {
|
List<TDesignPythonOutfitDetail> designPythonOutfitDetails = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designOutfitId);
|
||||||
// todo 允许为空吗?
|
// 遍历列表,拿出每个种类的前后片
|
||||||
// throw new BusinessException("labeling mask cannot be empty");
|
designPythonOutfitDetails.forEach(designPythonOutfitDetail -> {
|
||||||
}
|
String imageCategory = designPythonOutfitDetail.getImageCategory();
|
||||||
|
String maskUrl = designPythonOutfitDetail.getMaskUrl();
|
||||||
|
|
||||||
|
// 检查是否以'front'结尾
|
||||||
|
if (imageCategory.endsWith("front")) {
|
||||||
|
String maskPath = maskUrl.replace("aida-clothing", "test" );
|
||||||
|
String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_"));
|
||||||
|
if (backMaskIdMap.containsKey(prefix)) {
|
||||||
|
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||||
|
tDesignPythonOutfitDetail.setMaskUrl(maskPath);
|
||||||
|
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
|
||||||
|
tDesignPythonOutfitDetail.setId(backMaskIdMap.get(prefix));
|
||||||
|
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
|
||||||
|
}else {
|
||||||
|
frontMaskMap.put(prefix, maskPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||||
|
tDesignPythonOutfitDetail.setMaskUrl(maskPath);
|
||||||
|
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
|
||||||
|
tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId());
|
||||||
|
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageCategory.endsWith("back")) {
|
||||||
|
String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_"));
|
||||||
|
if (frontMaskMap.containsKey(prefix)) {
|
||||||
|
// 更新back的mask路径为front的mask路径
|
||||||
|
String frontMaskPath = frontMaskMap.get(prefix);
|
||||||
|
|
||||||
|
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||||
|
tDesignPythonOutfitDetail.setMaskUrl(frontMaskPath);
|
||||||
|
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
|
||||||
|
tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId());
|
||||||
|
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
|
||||||
|
}else {
|
||||||
|
backMaskIdMap.put(prefix, designPythonOutfitDetail.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("designSingle request入参 ==> " + JSONObject.toJSONString(clone));
|
log.info("更新总数:{}", tDesignPythonOutfitDetails.size());
|
||||||
|
designPythonOutfitDetailService.updateBatchById(tDesignPythonOutfitDetails);
|
||||||
// Long userId = UserContext.getUserHolder().getId();
|
log.info("更新完成");
|
||||||
DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId());
|
|
||||||
if (Objects.isNull(designItem)) {
|
|
||||||
throw new BusinessException("designItem.not.found");
|
|
||||||
}
|
|
||||||
Design design = designService.getById(designItem.getDesignId());
|
|
||||||
if (Objects.isNull(design)) {
|
|
||||||
throw new BusinessException("design.not.found");
|
|
||||||
}
|
|
||||||
|
|
||||||
DesignLibraryModelPointVO designLibraryModelPointVO = null;
|
|
||||||
// 设置模特
|
|
||||||
if (Objects.nonNull(design.getTemplateId())) {
|
|
||||||
String modelUrl;
|
|
||||||
Integer high;
|
|
||||||
Integer width;
|
|
||||||
if (design.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
|
||||||
SysFileVO sysFile = sysFileService.getById(design.getTemplateId());
|
|
||||||
if (Objects.isNull(sysFile)) {
|
|
||||||
throw new BusinessException("model.not.found");
|
|
||||||
}
|
|
||||||
modelUrl = sysFile.getUrl();
|
|
||||||
high = 700;
|
|
||||||
width = 320;
|
|
||||||
} else if (design.getModelType().equals(ModelType.LIBRARY.getValue())){
|
|
||||||
Library libFile = libraryService.getById(design.getTemplateId());
|
|
||||||
if (Objects.isNull(libFile)) {
|
|
||||||
throw new BusinessException("model.not.found");
|
|
||||||
}
|
|
||||||
modelUrl = libFile.getUrl();
|
|
||||||
high = libFile.getHigh();
|
|
||||||
width = libFile.getWidth();
|
|
||||||
}else {
|
|
||||||
throw new BusinessException("unknown.modelType");
|
|
||||||
}
|
|
||||||
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(design.getTemplateId(), design.getModelType());
|
|
||||||
if (Objects.isNull(modelPoint)) {
|
|
||||||
throw new BusinessException("modelPoint.not.found");
|
|
||||||
}
|
|
||||||
|
|
||||||
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 画笔修改的sketch截图 上传后替换path
|
|
||||||
// 由于用户在系统或自己上传sketch的基础上修改过的衣服,再次修改后,第一次修改的衣服不会回到某个池子被再次利用,
|
|
||||||
// 所以,这里选择使用system或collection相同的地址,只是放在不同的桶,这样能保证图片服务器上,类似的sketch不会存在很多
|
|
||||||
sketchBase64ToPath(designSingleIncludeLayersDTO);
|
|
||||||
|
|
||||||
// todo 将标注后的mask上传到minio,并将minio地址传给python端
|
|
||||||
// maskBase64ToPath(designSingleIncludeLayersDTO);
|
|
||||||
|
|
||||||
// 组装入参
|
|
||||||
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
|
|
||||||
designSingleIncludeLayersDTO, design.getSingleOverall(), design.getSwitchCategory(), designLibraryModelPointVO);
|
|
||||||
// design
|
|
||||||
JSONObject jsonObject = pythonService.designNew(objects);
|
|
||||||
// preview -> 不存数据库 submit -> 存数据库
|
|
||||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails;
|
|
||||||
JSONObject data = jsonObject.getJSONObject("data");
|
|
||||||
if (data == null) {
|
|
||||||
throw new BusinessException("python response data is null");
|
|
||||||
}
|
|
||||||
JSONObject outfit = data.getJSONObject("0");
|
|
||||||
|
|
||||||
JSONArray layers = outfit.getJSONArray("layers");
|
|
||||||
Map<String, String> categoryAndUndividedLayer = setTypeAndUndividedLayer(layers);
|
|
||||||
// 直接更新及保存图层信息,全部走submit 不走preview
|
|
||||||
saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId()
|
|
||||||
, userId, outfit, designSingleIncludeLayersDTO.getTimeZone()
|
|
||||||
, designSingleIncludeLayersDTO.getDesignSingleItemDTOList()
|
|
||||||
, categoryAndUndividedLayer);
|
|
||||||
|
|
||||||
// 如果当前item被like过,需要更新t_user_like表和t_user_like_group表
|
|
||||||
// - 这里,因为处理的都是like过的,所以都需要更新
|
|
||||||
updateUserLikeDate(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone());
|
|
||||||
|
|
||||||
// 数据替换完成即可,不需要返回数据
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -813,9 +813,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
// return new DesignLikeVO();
|
// return new DesignLikeVO();
|
||||||
// }
|
// }
|
||||||
List<CollectionElement> oldElements = collectionElementService.getByCollectionId(userLikeGroup.getCollectionId());
|
List<CollectionElement> oldElements = collectionElementService.getByCollectionId(userLikeGroup.getCollectionId());
|
||||||
if (CollectionUtil.isEmpty(oldElements)) {
|
// if (CollectionUtil.isEmpty(oldElements)) {
|
||||||
throw new BusinessException("old.elements.not.found");
|
// throw new BusinessException("old.elements.not.found");
|
||||||
}
|
// }
|
||||||
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designLikeDTO.getDesignItemId());
|
List<DesignItemDetail> designItemDetails = designItemDetailService.selectByDesignItemId(designLikeDTO.getDesignItemId());
|
||||||
if (CollectionUtil.isEmpty(designItemDetails)) {
|
if (CollectionUtil.isEmpty(designItemDetails)) {
|
||||||
throw new BusinessException("new.designItemDetails.not.found");
|
throw new BusinessException("new.designItemDetails.not.found");
|
||||||
@@ -867,8 +867,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
if (CollectionUtils.isEmpty(hasCollections)) {
|
if (CollectionUtils.isEmpty(hasCollections)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Long> oldIds = oldElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
|
||||||
List<Long> elementIds = hasCollections.stream().map(DesignItemDetail::getCollectionElementId).collect(Collectors.toList());
|
List<Long> elementIds = hasCollections.stream().map(DesignItemDetail::getCollectionElementId).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(oldElements)) {
|
||||||
|
return elementIds;
|
||||||
|
}
|
||||||
|
List<Long> oldIds = oldElements.stream().map(CollectionElement::getId).collect(Collectors.toList());
|
||||||
//本次新增collection个数
|
//本次新增collection个数
|
||||||
List<Long> adds = elementIds.stream().filter(id -> !oldIds.contains(id)).collect(Collectors.toList());
|
List<Long> adds = elementIds.stream().filter(id -> !oldIds.contains(id)).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isEmpty(adds)) {
|
if (CollectionUtils.isEmpty(adds)) {
|
||||||
@@ -934,7 +937,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userLike.getUserLikeGroupId());
|
List<UserLikeVO> userLikeVOS = userLikeService.getGroupDetail(userLike.getUserLikeGroupId());
|
||||||
if (CollectionUtils.isEmpty(userLikeVOS)) {
|
if (CollectionUtils.isEmpty(userLikeVOS)) {
|
||||||
//group 下面没有元素时候 直接删除
|
//group 下面没有元素时候 直接删除
|
||||||
userLikeGroupService.removeById(userLike.getUserLikeGroupId());
|
// userLikeGroupService.removeById(userLike.getUserLikeGroupId());
|
||||||
}
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
@@ -1001,7 +1004,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
response.setSingleOverall(design.getSingleOverall());
|
response.setSingleOverall(design.getSingleOverall());
|
||||||
response.setSwitchCategory(design.getSwitchCategory());
|
response.setSwitchCategory(design.getSwitchCategory());
|
||||||
response.setDesignItemId(designItemId);
|
response.setDesignItemId(designItemId);
|
||||||
// response.setDesignItemUrl(designItem.getDesignUrl());
|
|
||||||
response.setHighDesignUrl(designItem.getHighDesignUrl());
|
response.setHighDesignUrl(designItem.getHighDesignUrl());
|
||||||
List<DesignItemDetail> filterDetail = designItemDetails.stream()
|
List<DesignItemDetail> filterDetail = designItemDetails.stream()
|
||||||
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType())
|
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType())
|
||||||
@@ -1035,8 +1037,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
.filter(f -> SYS_HAIRSTYLE_SHOES_BODY.contains(f.getType()))
|
.filter(f -> SYS_HAIRSTYLE_SHOES_BODY.contains(f.getType()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
response.setOthers(CopyUtil.copyList(filterDetail2, DesignItemOthersDetailVO.class, (o, d) -> {
|
response.setOthers(CopyUtil.copyList(filterDetail2, DesignItemOthersDetailVO.class, (o, d) -> {
|
||||||
// todo 不确定businessId的作用,暂时取消传递,查看影响
|
|
||||||
// d.setId(o.getBusinessId());
|
|
||||||
d.setId(0L);
|
d.setId(0L);
|
||||||
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60));
|
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60));
|
||||||
d.setMinIOPath(o.getPath());
|
d.setMinIOPath(o.getPath());
|
||||||
@@ -1172,12 +1172,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details);
|
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details);
|
||||||
|
|
||||||
details.forEach(detail -> {
|
details.forEach(detail -> {
|
||||||
// List<Long> offset = new ArrayList<>();
|
|
||||||
// if (StringUtil.isNullOrEmpty(detail.getOffset()) || detail.getOffset().equals("null")) {
|
|
||||||
// offset = Arrays.asList(0L, 0L);
|
|
||||||
// } else {
|
|
||||||
// offset = Arrays.stream(detail.getOffset().replaceAll("\\[|\\]", "").split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail, null));
|
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail, null));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1185,11 +1179,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
designItemDetailVO.setDesignItemUrl(minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
|
designItemDetailVO.setDesignItemUrl(minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
|
||||||
// 2.1 填充clothes
|
// 2.1 填充clothes
|
||||||
designItemDetailVO.getClothes().forEach(c -> {
|
designItemDetailVO.getClothes().forEach(c -> {
|
||||||
// String type = c.getType().toLowerCase();
|
|
||||||
// List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter((detail -> detail.getImageCategory().equals(type + "_back") ||
|
|
||||||
// detail.getImageCategory().equals(type + "_front"))).collect(Collectors.toList());
|
|
||||||
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getPriority().equals(c.getPriority())).collect(Collectors.toList());
|
List<DesignPythonOutfitVO> outfitVOS = detailsVO.stream().filter(detail -> detail.getPriority().equals(c.getPriority())).collect(Collectors.toList());
|
||||||
|
|
||||||
c.setLayersObject(outfitVOS);
|
c.setLayersObject(outfitVOS);
|
||||||
});
|
});
|
||||||
// 2.2 填充others
|
// 2.2 填充others
|
||||||
|
|||||||
@@ -3,16 +3,12 @@ package com.ai.da.service.impl;
|
|||||||
import com.ai.da.common.config.exception.BusinessException;
|
import com.ai.da.common.config.exception.BusinessException;
|
||||||
import com.ai.da.common.constant.CommonConstant;
|
import com.ai.da.common.constant.CommonConstant;
|
||||||
import com.ai.da.common.context.UserContext;
|
import com.ai.da.common.context.UserContext;
|
||||||
import com.ai.da.common.enums.CollectionLevel2TypeEnum;
|
import com.ai.da.common.enums.*;
|
||||||
import com.ai.da.common.enums.CreditsEventsEnum;
|
|
||||||
import com.ai.da.common.enums.GenerateModeEnum;
|
|
||||||
import com.ai.da.common.enums.ModelNameEnum;
|
|
||||||
import com.ai.da.common.utils.*;
|
import com.ai.da.common.utils.*;
|
||||||
import com.ai.da.mapper.primary.*;
|
import com.ai.da.mapper.primary.*;
|
||||||
import com.ai.da.mapper.primary.entity.*;
|
import com.ai.da.mapper.primary.entity.*;
|
||||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
import com.ai.da.model.dto.*;
|
||||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
import com.ai.da.model.enums.SketchStyle;
|
||||||
import com.ai.da.model.dto.GenerateToPythonDTO;
|
|
||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.python.PythonService;
|
import com.ai.da.python.PythonService;
|
||||||
import com.ai.da.service.*;
|
import com.ai.da.service.*;
|
||||||
@@ -26,13 +22,16 @@ import com.google.gson.Gson;
|
|||||||
import io.minio.errors.MinioException;
|
import io.minio.errors.MinioException;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.ai.da.common.enums.CollectionLevel1TypeEnum.*;
|
import static com.ai.da.common.enums.CollectionLevel1TypeEnum.*;
|
||||||
@@ -77,6 +76,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
@Value("${minio.bucketName.slogan}")
|
@Value("${minio.bucketName.slogan}")
|
||||||
private String sloganBucket;
|
private String sloganBucket;
|
||||||
|
|
||||||
|
@Value("${minio.bucketName.users}")
|
||||||
|
private String userBucket;
|
||||||
|
|
||||||
@Value("${redis.key.relightResultKey}")
|
@Value("${redis.key.relightResultKey}")
|
||||||
private String relightResultKey;
|
private String relightResultKey;
|
||||||
|
|
||||||
@@ -88,6 +90,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
// 创建 Random 对象
|
// 创建 Random 对象
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
@Autowired
|
||||||
|
private ProductServiceImpl productServiceImpl;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GenerateCaptionVO generateCaption(Long sketchElementId) {
|
public GenerateCaptionVO generateCaption(Long sketchElementId) {
|
||||||
@@ -132,7 +136,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
text = modifyPrompt(text, generate, generateThroughImageTextDTO.getLevel1Type());
|
text = modifyPrompt(text, generate, generateThroughImageTextDTO.getLevel1Type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// todo 这一步现在还是有必要的吗?
|
// todo 这一步现在还是有必要的吗?
|
||||||
// 2.1 sketch或print在t_collection_element表/t_library表中的信息是否需要更新 如 level2Type
|
// 2.1 sketch或print在t_collection_element表/t_library表中的信息是否需要更新 如 level2Type
|
||||||
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
|
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
|
||||||
@@ -298,27 +301,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
generate.setGenerateType(generateType);
|
generate.setGenerateType(generateType);
|
||||||
|
|
||||||
/*switch (generateType) {
|
|
||||||
case "text":
|
|
||||||
if (StringUtil.isNullOrEmpty(text)) {
|
|
||||||
throw new BusinessException("please.input.the.caption");
|
|
||||||
}
|
|
||||||
generate.setText(text);
|
|
||||||
break;
|
|
||||||
case "image":
|
|
||||||
if (Objects.isNull(elementId)) {
|
|
||||||
throw new BusinessException("please.choose.an.image");
|
|
||||||
}
|
|
||||||
generate.setElementId(elementId);
|
|
||||||
break;
|
|
||||||
case "text-image":
|
|
||||||
if (StringUtil.isNullOrEmpty(text) || Objects.isNull(elementId)) {
|
|
||||||
throw new BusinessException("please.input.the.caption.and.choose.an.image");
|
|
||||||
}
|
|
||||||
generate.setText(text);
|
|
||||||
generate.setElementId(elementId);
|
|
||||||
default:
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String modifyPrompt(String userInput, Generate generate, String level1Type) {
|
private String modifyPrompt(String userInput, Generate generate, String level1Type) {
|
||||||
@@ -781,8 +763,101 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private GenerateMapper generateMapper;
|
private GenerateMapper generateMapper;
|
||||||
|
|
||||||
public List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList) {
|
public List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList) {
|
||||||
List<Map<String, Object>> byTypeAndTime = generateMapper.getByTypeAndTime(startTime, endTime, accountIdList);
|
List<Map<String, Object>> byTypeAndTime = generateMapper.getByTypeAndTime(startTime, endTime, accountIdList);
|
||||||
return byTypeAndTime;
|
return byTypeAndTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public GenerateResultVO imageToSketch(ImageToSketchDTO imageToSketchDTO) {
|
||||||
|
String bucket = userBucket;
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
log.info("imageToSketch parameter : {}", imageToSketchDTO);
|
||||||
|
|
||||||
|
CollectionElement collectionElement = collectionElementService.getById(imageToSketchDTO.getElementId());
|
||||||
|
String imagePath = collectionElement.getUrl();
|
||||||
|
|
||||||
|
log.info(minioUtil.getPreSignedUrl(imagePath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
String imageName = UUID.randomUUID().toString();
|
||||||
|
String objectName = accountId + "/imageToSketch/" + imageName;
|
||||||
|
String style = imageToSketchDTO.getStyle();
|
||||||
|
String styleCode = style.equals(SketchStyle.THICK.getValue()) ? "1" :
|
||||||
|
style.equals(SketchStyle.MEDIUM.getValue()) ? "2" :
|
||||||
|
style.equals(SketchStyle.THIN.getValue()) ? "3" : "Custom";
|
||||||
|
String styleImage;
|
||||||
|
if (!Objects.isNull(imageToSketchDTO.getStyleImageId())){
|
||||||
|
CollectionElement styleElement = collectionElementService.getById(imageToSketchDTO.getElementId());
|
||||||
|
styleImage = styleElement.getUrl();
|
||||||
|
} else {
|
||||||
|
styleImage = "";
|
||||||
|
}
|
||||||
|
String sketchPath = pythonService.imageToSketch(imagePath, bucket, objectName, styleCode, styleImage);
|
||||||
|
|
||||||
|
// 存DB
|
||||||
|
Generate generate = new Generate();
|
||||||
|
generate.setAccountId(accountId);
|
||||||
|
generate.setUniqueId(String.valueOf(0));
|
||||||
|
generate.setLevel1Type(SKETCH_BOARD.getRealName());
|
||||||
|
generate.setLevel2Type("ImageToSketch");
|
||||||
|
generate.setElementSource("collection");
|
||||||
|
generate.setElementId(imageToSketchDTO.getElementId());
|
||||||
|
generate.setGenerateType("image");
|
||||||
|
generate.setSketchStyle(styleCode);
|
||||||
|
generate.setStyleImageElementId(imageToSketchDTO.getElementId());
|
||||||
|
generate.setCreateDate(new Date());
|
||||||
|
baseMapper.insert(generate);
|
||||||
|
|
||||||
|
// 将生成结果存入DB
|
||||||
|
GenerateDetail generateDetail = new GenerateDetail();
|
||||||
|
generateDetail.setGenerateId(generate.getId());
|
||||||
|
generateDetail.setUrl(sketchPath);
|
||||||
|
generateDetail.setIsLike((byte)0);
|
||||||
|
generateDetail.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(sketchPath, 24 * 60), Boolean.FALSE));
|
||||||
|
generateDetail.setCreateDate(LocalDateTime.now());
|
||||||
|
generateDetailMapper.insert(generateDetail);
|
||||||
|
|
||||||
|
String clothCategory = pythonService.getClothCategory(sketchPath, imageToSketchDTO.getGender());
|
||||||
|
clothCategory = BusinessException.getMessageFromResource(clothCategory.toUpperCase());
|
||||||
|
|
||||||
|
return new GenerateResultVO(generateDetail.getId(), minioUtil.getPreSignedUrl(sketchPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), "Success", clothCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对提取出来的sketch做调整
|
||||||
|
// 输入 base64,以及 性别 分类,将图片添加到library
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CollectionElementVO modifySketch(GenerateModifyDTO generateModifyDTO) {
|
||||||
|
log.info("修改提取出的sketch,并加入到library");
|
||||||
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
String base64 = generateModifyDTO.getBase64();
|
||||||
|
String gender = generateModifyDTO.getGender();
|
||||||
|
String category = generateModifyDTO.getCategory();
|
||||||
|
|
||||||
|
// 将base64上传到minio
|
||||||
|
String path = accountId + "/sketchboard/" + gender.toLowerCase() + "/" + category + "/" + UUID.randomUUID();
|
||||||
|
String minioPath = minioUtil.base64UploadToPath(base64, userBucket, path);
|
||||||
|
|
||||||
|
log.info("修改后的图片 : {}", minioPath);
|
||||||
|
|
||||||
|
// 存入db 保存到t_collection_element
|
||||||
|
CollectionElement collectionElement = new CollectionElement();
|
||||||
|
collectionElement.setAccountId(accountId);
|
||||||
|
collectionElement.setCollectionId(0L);
|
||||||
|
collectionElement.setLevel1Type(SKETCH_BOARD.getRealName());
|
||||||
|
collectionElement.setLevel2Type(generateModifyDTO.getCategory());
|
||||||
|
collectionElement.setName(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||||
|
collectionElement.setUrl(minioPath);
|
||||||
|
collectionElement.setHasPin((byte)0);
|
||||||
|
collectionElement.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(minioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), Boolean.FALSE));
|
||||||
|
collectionElement.setCreateDate(new Date());
|
||||||
|
collectionElementService.save(collectionElement);
|
||||||
|
|
||||||
|
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||||
|
collectionElementVO.setMinIOPath(collectionElementVO.getUrl());
|
||||||
|
collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
|
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
|
return collectionElementVO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -35,6 +36,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
|
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
|
||||||
|
|
||||||
@@ -76,6 +78,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
@Resource
|
@Resource
|
||||||
private DesignItemDetailPrintMapper designItemDetailPrintMapper;
|
private DesignItemDetailPrintMapper designItemDetailPrintMapper;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MinioUtil minioUtil;
|
private MinioUtil minioUtil;
|
||||||
|
|
||||||
@@ -436,8 +439,31 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
return PageBaseResponse.success(new Page<>());
|
return PageBaseResponse.success(new Page<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<Portfolio> topThree = new ArrayList<>();
|
||||||
|
|
||||||
|
if (query.getPage() == 1 &&
|
||||||
|
(query.getGetMyPortfolio() != 1 || query.getGetLikePortfolio() != 1)) {
|
||||||
|
List<Long> topThreeLike = getTopThreeLikeFromRedis(RedisUtil.PORTFOLIO_LIKE_KEY);
|
||||||
|
log.info("top three like 的作品集的id : {}", topThreeLike);
|
||||||
|
List<Long> topThreeView = getTopThreeViewFromRedis(RedisUtil.PORTFOLIO_VIEW_KEY);
|
||||||
|
log.info("top three view 的作品集的id : {}", topThreeView);
|
||||||
|
QueryWrapper<Portfolio> queryLike = new QueryWrapper<>();
|
||||||
|
queryLike.in("id", topThreeLike);
|
||||||
|
QueryWrapper<Portfolio> queryView = new QueryWrapper<>();
|
||||||
|
queryView.in("id", topThreeView);
|
||||||
|
List<Portfolio> topThreeLikePortfolio = baseMapper.selectList(queryLike);
|
||||||
|
List<Portfolio> topThreeViewPortfolio = baseMapper.selectList(queryView);
|
||||||
|
topThree.addAll(topThreeLikePortfolio);
|
||||||
|
topThree.addAll(topThreeViewPortfolio);
|
||||||
|
}
|
||||||
|
|
||||||
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
|
qw.lambda().orderByDesc(Portfolio::getUpdateDate);
|
||||||
IPage<Portfolio> page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
IPage<Portfolio> page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||||
|
if (!topThree.isEmpty()) {
|
||||||
|
List<Portfolio> records = page.getRecords();
|
||||||
|
records.addAll(0, topThree);
|
||||||
|
page.setRecords(records);
|
||||||
|
}
|
||||||
IPage<PortfolioVO> convert = page.convert((Function<Portfolio, PortfolioVO>) portfolio -> {
|
IPage<PortfolioVO> convert = page.convert((Function<Portfolio, PortfolioVO>) portfolio -> {
|
||||||
if (portfolio != null) {
|
if (portfolio != null) {
|
||||||
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
|
||||||
@@ -670,8 +696,8 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
Long designItemDetailIdNew = designItemDetailOld.getId();
|
Long designItemDetailIdNew = designItemDetailOld.getId();
|
||||||
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<DesignItemDetailPrint> designItemDetailPrintQueryWrapper = new QueryWrapper<>();
|
||||||
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld);
|
||||||
DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper);
|
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintMapper.selectList(designItemDetailPrintQueryWrapper);
|
||||||
if (Objects.nonNull(designItemDetailPrint)) {
|
for (DesignItemDetailPrint designItemDetailPrint : designItemDetailPrintList) {
|
||||||
designItemDetailPrint.setId(null);
|
designItemDetailPrint.setId(null);
|
||||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew);
|
||||||
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
designItemDetailPrintMapper.insert(designItemDetailPrint);
|
||||||
@@ -960,6 +986,65 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
|||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Long> getTopThreeLikeFromRedis(String prefix) {
|
||||||
|
// 获取所有与 PORTFOLIO_LIKE_KEY 相关的 keys
|
||||||
|
Set<String> keys = redisUtil.getKeysFromString(prefix + "*");
|
||||||
|
|
||||||
|
List<Map.Entry<String, Long>> portfolioSizes = new ArrayList<>();
|
||||||
|
|
||||||
|
if (keys != null) {
|
||||||
|
for (String key : keys) {
|
||||||
|
// 获取 Set 的 size
|
||||||
|
Long size = redisUtil.getSize(key);
|
||||||
|
// 保存 key 和 size
|
||||||
|
portfolioSizes.add(new AbstractMap.SimpleEntry<>(key, size));
|
||||||
|
}
|
||||||
|
// 按 size 倒序排序
|
||||||
|
portfolioSizes.sort((e1, e2) -> e2.getValue().compareTo(e1.getValue()));
|
||||||
|
// 获取 size 最大的前三个
|
||||||
|
List<Long> top3PortfolioIds = portfolioSizes.stream()
|
||||||
|
.limit(3)
|
||||||
|
.map(Map.Entry::getKey)
|
||||||
|
.map(key -> key.replace(prefix, "")) // 去掉前缀,获取 portfolioId
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 输出 top3PortfolioIds
|
||||||
|
top3PortfolioIds.forEach(System.out::println);
|
||||||
|
return top3PortfolioIds;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> getTopThreeViewFromRedis(String prefix) {
|
||||||
|
// Step 1: Get all keys with the specific prefix
|
||||||
|
Set<String> keys = redisUtil.getKeysFromString(prefix + "*");
|
||||||
|
// Step 2: Create a map to store portfolioId and its corresponding value
|
||||||
|
Map<Long, Long> portfolioViews = new HashMap<>();
|
||||||
|
if (keys != null) {
|
||||||
|
for (String key : keys) {
|
||||||
|
// Get the value associated with the key
|
||||||
|
Long value = redisUtil.getViewCount(key);
|
||||||
|
if (!Objects.isNull(value)) {
|
||||||
|
// Extract the portfolioId from the key (assuming the key structure is consistent)
|
||||||
|
Long portfolioId = Long.valueOf(key.replace(prefix, ""));
|
||||||
|
portfolioViews.put(portfolioId, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Step 3: Find the top 3 portfolio IDs with the largest values
|
||||||
|
if (!portfolioViews.isEmpty()){
|
||||||
|
List<Long> top3PortfolioIds = portfolioViews.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.<Long, Long>comparingByValue().reversed())
|
||||||
|
.limit(3)
|
||||||
|
.map(Map.Entry::getKey)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
System.out.println("Top 3 Portfolio IDs: " + top3PortfolioIds);
|
||||||
|
return top3PortfolioIds;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void follow(Long followeeId) {
|
public void follow(Long followeeId) {
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
// 1、不能关注自己
|
// 1、不能关注自己
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ public class SuperResolutionServiceImpl extends ServiceImpl<TaskListMapper, Task
|
|||||||
|
|
||||||
ArrayList<String> uuidList = new ArrayList<>();
|
ArrayList<String> uuidList = new ArrayList<>();
|
||||||
for (SuperResolutionDTO superResolutionDTO : superResolutionDTOList) {
|
for (SuperResolutionDTO superResolutionDTO : superResolutionDTOList) {
|
||||||
// todo 校验倍率是否是2的幂次(前端已做)
|
|
||||||
|
|
||||||
// 2、生成唯一id 使用uuid 由于uuid重复的几率很小很小,故这里取消验证uuid是否已存在
|
// 2、生成唯一id 使用uuid 由于uuid重复的几率很小很小,故这里取消验证uuid是否已存在
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -106,18 +107,21 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId) {
|
public void deleteByDesignPythonOutfitIdLogical(Long designPythonOutfitId) {
|
||||||
// QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
|
|
||||||
// queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
|
|
||||||
// TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
|
||||||
// tDesignPythonOutfitDetail.setIsDeleted(1);
|
|
||||||
UpdateWrapper<TDesignPythonOutfitDetail> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<TDesignPythonOutfitDetail> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.eq("design_python_outfit_id", designPythonOutfitId);
|
updateWrapper.eq("design_python_outfit_id", designPythonOutfitId);
|
||||||
updateWrapper.set("is_deleted", (byte) 1);
|
updateWrapper.set("is_deleted", (byte) 1);
|
||||||
|
updateWrapper.set("update_date", new Date());
|
||||||
|
|
||||||
baseMapper.update(null, updateWrapper);
|
baseMapper.update(null, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByDesignPythonOutfitIdPhysical(Long designPythonOutfitId) {
|
||||||
|
// 执行物理删除
|
||||||
|
baseMapper.deleteByDesignPythonOutfitIdPhysical(designPythonOutfitId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details){
|
public void setDesignPythonOutfitDetailPriority(List<TDesignPythonOutfitDetail> details){
|
||||||
|
|||||||
@@ -70,8 +70,11 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
|
|||||||
public UserLike getByDesignItemId(Long designItemId){
|
public UserLike getByDesignItemId(Long designItemId){
|
||||||
QueryWrapper<UserLike> qw = new QueryWrapper<>();
|
QueryWrapper<UserLike> qw = new QueryWrapper<>();
|
||||||
qw.eq("design_item_id",designItemId);
|
qw.eq("design_item_id",designItemId);
|
||||||
|
List<UserLike> userLikes = baseMapper.selectList(qw);
|
||||||
return baseMapper.selectOne(qw);
|
if (!userLikes.isEmpty()){
|
||||||
|
return baseMapper.selectList(qw).get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,21 +94,4 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
|
|||||||
return userLikeMapper.selectList(qw);
|
return userLikeMapper.selectList(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Map<String, Long>> getHistoryLikeWithGradient(){
|
|
||||||
List<Map<String, Long>> historyLikeWithGradient = baseMapper.getHistoryLikeWithGradient();
|
|
||||||
return historyLikeWithGradient.stream()
|
|
||||||
.map(map -> {
|
|
||||||
Map<String, Long> newMap = new HashMap<>();
|
|
||||||
if (map.containsKey("design_item_id")) {
|
|
||||||
newMap.put("designItemId", map.get("design_item_id"));
|
|
||||||
}
|
|
||||||
if (map.containsKey("design_outfit_id")) {
|
|
||||||
newMap.put("designPythonOutfitId", map.get("design_outfit_id"));
|
|
||||||
}
|
|
||||||
return newMap;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#spring.profiles.active=test
|
#spring.profiles.active=test
|
||||||
|
|
||||||
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
#spring.profiles.active=prod
|
spring.profiles.active=prod
|
||||||
|
|
||||||
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
spring.profiles.active=dev
|
#spring.profiles.active=dev
|
||||||
|
|||||||
@@ -103,6 +103,28 @@
|
|||||||
a.design_outfit_id;
|
a.design_outfit_id;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getHistoryLikeWithoutModel" resultType="java.util.Map">
|
||||||
|
select b.design_item_id designItemId, b.design_outfit_id designOutfitId
|
||||||
|
from t_design_item_detail a
|
||||||
|
inner join t_user_like b on a.design_item_id = b.design_item_id
|
||||||
|
where a.path IN (
|
||||||
|
/*'aida-sys-image/models/Female/8ecbbec3-1a17-4b61-9d34-3f60acf66a85.png',
|
||||||
|
'aida-sys-image/models/male/d90ea1e0-dac4-4356-87b8-4b8d5d7b97fe.png',
|
||||||
|
'aida-sys-image/models/female/068c8165-d134-4fbd-a323-cd26846d3343.png',
|
||||||
|
'aida-sys-image/models/female/5ae883b9-914e-4a02-b5c1-14d424b7c721.png',
|
||||||
|
'aida-users/6/models/female/cd049392-75f8-46bb-b1b9-bc8822a63a70.png',
|
||||||
|
'aida-users/42/models/female/2380166a-c46e-4fe0-85ab-62f735a58b79.png',
|
||||||
|
'aida-users/6/models/female/2e4efb1e-b86b-4056-8367-cfca039707db.png',
|
||||||
|
'aida-users/6/models/female/e7450044-bf85-4d33-adb2-aedfe11b1d40.png',
|
||||||
|
'aida-users/6/models/female/5c43a00d-aeb0-4877-85ba-3ec15c3c9262.png',
|
||||||
|
'aida-users/6/models/female/2e2e5f52-50af-413b-be2c-9f030a62ec61.png',
|
||||||
|
'aida-users/6/models/female/114c9388-06f9-42a6-beeb-212afc9a06eb.png',
|
||||||
|
'aida-users/11484/models/female/1ebe8690-2cd3-4235-a5f7-136fe42e8a41.png',
|
||||||
|
'aida-users/6/models/female/834acb3a-f9c1-464c-b455-5d35c35515b7.png',*/
|
||||||
|
'aida-users/83/models/female/f5734e63-5293-4f62-a7e3-daa03ed6ad8c.png')
|
||||||
|
GROUP BY b.design_item_id, b.design_outfit_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -209,3 +209,10 @@ BELT=Belt
|
|||||||
CORSAGE=Corsage
|
CORSAGE=Corsage
|
||||||
ZIPPER=Zipper
|
ZIPPER=Zipper
|
||||||
POCKET=Pocket
|
POCKET=Pocket
|
||||||
|
|
||||||
|
THICK=Thick Lines
|
||||||
|
MEDIUM=Medium Lines
|
||||||
|
THIN=Thin lines
|
||||||
|
|
||||||
|
GENERATE=Generate Sketch
|
||||||
|
EXTRACT=Extract Sketch
|
||||||
@@ -202,3 +202,10 @@ BELT=腰带
|
|||||||
CORSAGE=胸花
|
CORSAGE=胸花
|
||||||
ZIPPER=拉链
|
ZIPPER=拉链
|
||||||
POCKET=口袋
|
POCKET=口袋
|
||||||
|
|
||||||
|
THICK=粗线条
|
||||||
|
MEDIUM=中线条
|
||||||
|
THIN=细线条
|
||||||
|
|
||||||
|
GENERATE=生成线稿
|
||||||
|
EXTRACT=提取线稿
|
||||||
Reference in New Issue
Block a user