Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -71,6 +71,11 @@ public class TDesignPythonOutfitDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "位置")
|
@ApiModelProperty(value = "位置")
|
||||||
private String position;
|
private String position;
|
||||||
|
/**
|
||||||
|
* 偏移量
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "偏移量")
|
||||||
|
private String offset;
|
||||||
/**
|
/**
|
||||||
* 图层缩放大小
|
* 图层缩放大小
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ public class DesignPythonOutfitVO {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "位置")
|
@ApiModelProperty(value = "位置")
|
||||||
private List<Long> position;
|
private List<Long> position;
|
||||||
|
/**
|
||||||
|
* 偏移量
|
||||||
|
*/
|
||||||
@ApiModelProperty(value = "偏移量")
|
@ApiModelProperty(value = "偏移量")
|
||||||
private List<Long> offset;
|
private List<Long> offset;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
|
|||||||
*/
|
*/
|
||||||
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
|
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
|
||||||
|
|
||||||
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail,List<Long> type);
|
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail,List<Long> offset);
|
||||||
|
|
||||||
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
|
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
|
||||||
|
|
||||||
|
|||||||
@@ -334,14 +334,19 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
|
|
||||||
// 7、将新生成的图层信息存入designPythonOutfitDetail表
|
// 7、将新生成的图层信息存入designPythonOutfitDetail表
|
||||||
JSONArray layers = outfit.getJSONArray("layers");
|
JSONArray layers = outfit.getJSONArray("layers");
|
||||||
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId());
|
// 需要将request中的offset也存入数据库,通过type与image_category将sketch与layers关联
|
||||||
|
Map<String, List<Long>> typeOffset = designSingleItemDTOList.stream()
|
||||||
|
.collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
|
||||||
|
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId(),typeOffset);
|
||||||
|
|
||||||
designPythonOutfitDetailService.saveBatch(list);
|
designPythonOutfitDetailService.saveBatch(list);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TDesignPythonOutfitDetail> setTDesignPythonOutfitDetailList(JSONArray layers, Long designId, Long designPythonOutfitId, Long userId){
|
public List<TDesignPythonOutfitDetail> setTDesignPythonOutfitDetailList(JSONArray layers, Long designId,
|
||||||
|
Long designPythonOutfitId, Long userId,
|
||||||
|
Map<String, List<Long>> typeOffset){
|
||||||
// 设置图层信息;
|
// 设置图层信息;
|
||||||
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
|
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
|
||||||
for (int i = 0; i < layers.size(); i++) {
|
for (int i = 0; i < layers.size(); i++) {
|
||||||
@@ -356,6 +361,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
|
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
|
||||||
designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale"));
|
designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale"));
|
||||||
designPythonOutfitDetail.setUserId(userId);
|
designPythonOutfitDetail.setUserId(userId);
|
||||||
|
designPythonOutfitDetail.setOffset(String.valueOf(typeOffset.get(jsonObject.getString("image_category").split("_")[0])));
|
||||||
list.add(designPythonOutfitDetail);
|
list.add(designPythonOutfitDetail);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@@ -422,20 +428,21 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
|||||||
throw new BusinessException("python response data is null");
|
throw new BusinessException("python response data is null");
|
||||||
}
|
}
|
||||||
JSONObject outfit = data.getJSONObject("0");
|
JSONObject outfit = data.getJSONObject("0");
|
||||||
|
// 通过type将offset关联到layers
|
||||||
|
Map<String, List<Long>> typeOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
|
||||||
|
.collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
|
||||||
if (!designSingleIncludeLayersDTO.getIsPreview()){
|
if (!designSingleIncludeLayersDTO.getIsPreview()){
|
||||||
// 更新及保存图层信息
|
// 更新及保存图层信息
|
||||||
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(),
|
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(),
|
||||||
userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone(),designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
|
userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone(),designSingleIncludeLayersDTO.getDesignSingleItemDTOList());
|
||||||
}else {
|
}else {
|
||||||
JSONArray layers = outfit.getJSONArray("layers");
|
JSONArray layers = outfit.getJSONArray("layers");
|
||||||
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers,designItem.getDesignId(),null,userInfo.getId());
|
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers,designItem.getDesignId(),null,userInfo.getId(),typeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DesignPythonOutfitVO> detailsVO = new ArrayList<>();
|
List<DesignPythonOutfitVO> detailsVO = new ArrayList<>();
|
||||||
|
|
||||||
tDesignPythonOutfitDetails.forEach(detail -> {
|
tDesignPythonOutfitDetails.forEach(detail -> {
|
||||||
Map<String, List<Long>> typeOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
|
|
||||||
.collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset));
|
|
||||||
String type = detail.getImageCategory().split("_")[0];
|
String type = detail.getImageCategory().split("_")[0];
|
||||||
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail,typeOffset.get(type)));
|
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail,typeOffset.get(type)));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -992,7 +992,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
|
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
|
||||||
Assert.notEmpty(details, "Some errors occurred, please restart the design");
|
Assert.notEmpty(details, "Some errors occurred, please restart the design");
|
||||||
details.forEach(detail -> {
|
details.forEach(detail -> {
|
||||||
detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail,null));
|
List<Long> offset = new ArrayList<>();
|
||||||
|
if (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,offset));
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2、将查询出的图层信息填充到designItemDetailVO中
|
// 2、将查询出的图层信息填充到designItemDetailVO中
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.ai.da.service.impl;
|
package com.ai.da.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.ai.da.common.utils.CopyUtil;
|
import com.ai.da.common.utils.CopyUtil;
|
||||||
import com.ai.da.common.utils.MinioUtil;
|
import com.ai.da.common.utils.MinioUtil;
|
||||||
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
|
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
|
||||||
import com.ai.da.mapper.entity.DesignItemDetail;
|
|
||||||
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
|
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
|
||||||
import com.ai.da.model.vo.DesignPythonOutfitVO;
|
import com.ai.da.model.vo.DesignPythonOutfitVO;
|
||||||
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
||||||
@@ -13,16 +13,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import io.netty.util.internal.StringUtil;
|
import io.netty.util.internal.StringUtil;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* design item详情表 服务实现类
|
* design item详情表 服务实现类
|
||||||
@@ -62,7 +59,7 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
|||||||
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getMaskUrl(),480));
|
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.splitThenGetPreviewUrl(detail.getMaskUrl(),480));
|
||||||
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
|
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
|
||||||
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
|
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
|
||||||
designPythonOutfitVO.setOffset(offset);
|
designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L,0L) : offset);
|
||||||
|
|
||||||
/*if (!StringUtil.isNullOrEmpty(detail.getImageSize())){
|
/*if (!StringUtil.isNullOrEmpty(detail.getImageSize())){
|
||||||
List<Long> size = Arrays.stream(detail.getImageSize().replaceAll("\\[|\\]", "").split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
List<Long> size = Arrays.stream(detail.getImageSize().replaceAll("\\[|\\]", "").split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
|
||||||
|
|||||||
Reference in New Issue
Block a user