design Single接口第一版
This commit is contained in:
@@ -30,8 +30,6 @@ public class TDesignPythonOutfit implements Serializable {
|
||||
@ApiModelProperty(value = "ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long designItemId;
|
||||
/**
|
||||
* designItemId
|
||||
*/
|
||||
|
||||
@@ -51,8 +51,6 @@ public class TDesignPythonOutfitDetail implements Serializable {
|
||||
@ApiModelProperty(value = "图层")
|
||||
private String imageCategory;
|
||||
|
||||
@ApiModelProperty(value = "图层大小")
|
||||
private String imageSize;
|
||||
/**
|
||||
* imageSize
|
||||
*/
|
||||
|
||||
@@ -86,12 +86,13 @@ public class DesignPythonItem {
|
||||
this.image_id = image_id;
|
||||
}
|
||||
|
||||
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long image_id) {
|
||||
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long businessId, Long image_id) {
|
||||
this.type = type;
|
||||
this.path = path;
|
||||
this.color = color;
|
||||
this.print = print;
|
||||
this.icon = icon;
|
||||
this.businessId = businessId;
|
||||
this.image_id = image_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public class DesignPythonItemPrint {
|
||||
* print 绝对路径
|
||||
*/
|
||||
@ApiModelProperty("图片绝对路径")
|
||||
private String singlePath;
|
||||
private String path;
|
||||
|
||||
private List<String> path;
|
||||
private List<String> print_path_list;
|
||||
|
||||
@ApiModelProperty("上传时候对应的类型,一级类型 Printboard ")
|
||||
private String level1Type;
|
||||
@@ -23,7 +23,7 @@ public class DesignPythonItemPrint {
|
||||
* print_scale
|
||||
*/
|
||||
@ApiModelProperty("print_scale")
|
||||
private Float print_scale;
|
||||
private Float scale;
|
||||
|
||||
/**
|
||||
* 是否打点
|
||||
@@ -36,10 +36,10 @@ public class DesignPythonItemPrint {
|
||||
private List<List<Float>> location;
|
||||
|
||||
@ApiModelProperty("print的缩放比例 传 [0.2, 0.2]")
|
||||
private List<Float> scale;
|
||||
private List<Float> print_scale_list;
|
||||
|
||||
@ApiModelProperty("print的旋转角度 传 [0.2, 0.2]")
|
||||
private List<Float> angle;
|
||||
private List<Float> print_angle_list;
|
||||
|
||||
@JSONField(name="IfSingle")
|
||||
public Boolean getIfSingle() {
|
||||
@@ -48,16 +48,16 @@ public class DesignPythonItemPrint {
|
||||
|
||||
// todo
|
||||
public DesignPythonItemPrint(String singlePath, String level1Type, Float scale, Boolean ifSingle) {
|
||||
this.singlePath = singlePath;
|
||||
this.path = singlePath;
|
||||
this.level1Type = level1Type;
|
||||
this.print_scale = scale;
|
||||
this.scale = scale;
|
||||
IfSingle = ifSingle;
|
||||
}
|
||||
|
||||
public DesignPythonItemPrint() {
|
||||
}
|
||||
|
||||
public DesignPythonItemPrint(String singlePath) {
|
||||
this.singlePath = singlePath;
|
||||
public DesignPythonItemPrint(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,7 @@ public interface ITDesignPythonOutfitDetailService extends IService<TDesignPytho
|
||||
List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId);
|
||||
|
||||
DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail);
|
||||
|
||||
void deleteByDesignPythonOutfitId(Long designPythonOutfitId);
|
||||
|
||||
}
|
||||
|
||||
@@ -49,11 +49,4 @@ public interface SysFileService extends IService<SysFile> {
|
||||
* @param urlList
|
||||
*/
|
||||
List<SysFileVO> getByUrlList(List<String> urlList);
|
||||
|
||||
/**
|
||||
* 根据单条url查询
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
SysFileVO getByUrl(String url, String type,String timeZone);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ai.da.common.enums.SingleOverallEnum;
|
||||
import com.ai.da.common.enums.SysFileLevel2TypeEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.DesignItemMapper;
|
||||
import com.ai.da.mapper.entity.*;
|
||||
import com.ai.da.model.dto.DesignSingleDTO;
|
||||
@@ -25,10 +26,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -63,6 +67,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
|
||||
@Resource
|
||||
private PanToneService panToneService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Value("${minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Override
|
||||
public Long saveOne(DesignItem designItem) {
|
||||
@@ -258,7 +266,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
designItemDetail.setIconPath(detail.getIcon());
|
||||
DesignPythonItemPrint printObject = detail.getPrint();
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath());
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
|
||||
designItemDetail.setPrintJson(JSON.toJSONString(printObject));
|
||||
designItemDetails.add(designItemDetail);
|
||||
});
|
||||
@@ -274,7 +282,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
|
||||
private List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects
|
||||
, Long designId,Long designItemId, Long collectionId, AuthPrincipalVo userInfo
|
||||
, JSONObject responseJSONObject, String timeZone){
|
||||
, JSONObject outfit, String timeZone){
|
||||
|
||||
DesignItem designItem = new DesignItem();
|
||||
String url = pythonObjects.getObjects().get(0).getBasic().getSave_name();
|
||||
@@ -306,22 +314,24 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
designItemDetail.setIconPath(detail.getIcon());
|
||||
DesignPythonItemPrint printObject = detail.getPrint();
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath());
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
|
||||
designItemDetail.setPrintJson(JSON.toJSONString(printObject));
|
||||
designItemDetails.add(designItemDetail);
|
||||
});
|
||||
// todo businessId
|
||||
designItemDetailService.saveBatch(designItemDetails);
|
||||
|
||||
// 更新
|
||||
JSONObject data = responseJSONObject.getJSONObject("data");
|
||||
JSONObject outfit = data.getJSONObject("0");
|
||||
// 覆盖designPythonOutfit表中的模特全身图
|
||||
TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit();
|
||||
designPythonOutfit.setUserId(userInfo.getId());
|
||||
designPythonOutfit.setDesignId(designId);
|
||||
designPythonOutfit.setCollectionId(collectionId);
|
||||
designPythonOutfit.setDesignItemId(designItemId);
|
||||
designPythonOutfit.setDesignUrl(outfit.getString("synthesis_url"));
|
||||
designPythonOutfitService.save(designPythonOutfit);
|
||||
designPythonOutfit.setId(designPythonOutfitService.getByDesignItemId(designItemId).getId());
|
||||
designPythonOutfit.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone)));
|
||||
designPythonOutfitService.updateById(designPythonOutfit);
|
||||
|
||||
// 删除designPythonOutfitDetail表中原始的图层信息
|
||||
designPythonOutfitDetailService.deleteByDesignPythonOutfitId(designPythonOutfit.getId());
|
||||
|
||||
// 将新生成的图层信息存入designPythonOutfitDetail表
|
||||
JSONArray layers = outfit.getJSONArray("layers");
|
||||
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId());
|
||||
|
||||
@@ -331,8 +341,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
|
||||
public List<TDesignPythonOutfitDetail> setTDesignPythonOutfitDetailList(JSONArray layers, Long designId, Long designPythonOutfitId, Long userId){
|
||||
|
||||
// 保存图层信息;
|
||||
// 设置图层信息;
|
||||
List<TDesignPythonOutfitDetail> list = new ArrayList<>();
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
JSONObject jsonObject = layers.getJSONObject(i);
|
||||
@@ -381,18 +390,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
|
||||
DesignPythonObjects objects =pythonService.covertDesignSingleParam(
|
||||
designSingleIncludeLayersDTO,design.getSingleOverall(),design.getSwitchCategory(),designLibraryModelPointVO);
|
||||
// JSONObject jsonObject = pythonService.designNew(objects);
|
||||
JSONObject jsonObject = getJsonString();
|
||||
JSONObject jsonObject = pythonService.designNew(objects);
|
||||
// preview -> 不存数据库 submit -> 存数据库
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails;
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
// todo 空指针
|
||||
JSONObject outfit = data.getJSONObject("0");
|
||||
if (!designSingleIncludeLayersDTO.getIsPreview()){
|
||||
// todo 这里要再想想
|
||||
// 更新及保存图层信息
|
||||
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(),
|
||||
design.getCollectionId(), userInfo, jsonObject, designSingleIncludeLayersDTO.getTimeZone());
|
||||
design.getCollectionId(), userInfo, outfit, designSingleIncludeLayersDTO.getTimeZone());
|
||||
}else {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
// todo 空指针
|
||||
JSONObject outfit = data.getJSONObject("0");
|
||||
JSONArray layers = outfit.getJSONArray("layers");
|
||||
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers,designItem.getDesignId(),null,userInfo.getId());
|
||||
}
|
||||
@@ -405,7 +413,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
|
||||
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
|
||||
// todo designPythonOutFit 空指针
|
||||
return assembleDesignSingleResponse(designItem.getId(),designPythonOutfit.getDesignUrl(),
|
||||
return assembleDesignSingleResponse(designItem.getId(),minioUtil.getPresignedUrl(bucketName,designPythonOutfit.getDesignUrl(),5),
|
||||
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),detailsVO);
|
||||
}
|
||||
|
||||
@@ -431,59 +439,4 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
|
||||
return designSingleVO;
|
||||
}
|
||||
|
||||
private JSONObject getJsonString(){
|
||||
return JSONObject.parseObject("{\n" +
|
||||
" \"code\": 200,\n" +
|
||||
" \"data\": {\n" +
|
||||
" \"0\": {\n" +
|
||||
" \"layers\": [\n" +
|
||||
" {\n" +
|
||||
" \"image_category\": \"blouse_back\",\n" +
|
||||
" \"image_size\": [\n" +
|
||||
" 287,\n" +
|
||||
" 477\n" +
|
||||
" ],\n" +
|
||||
" \"image_url\": \"image/image_1694613014.7537637.png\",\n" +
|
||||
" \"mask_url\": \"mask/mask_1694613014.7537637.png\",\n" +
|
||||
" \"position\": [\n" +
|
||||
" 495,\n" +
|
||||
" 714\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"image_category\": \"body\",\n" +
|
||||
" \"image_size\": [\n" +
|
||||
" 1672,\n" +
|
||||
" 1672\n" +
|
||||
" ],\n" +
|
||||
" \"image_url\": \"model_1693218345.2714431.png\",\n" +
|
||||
" \"mask_url\": null,\n" +
|
||||
" \"position\": [\n" +
|
||||
" 0,\n" +
|
||||
" 0\n" +
|
||||
" ]\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"image_category\": \"blouse_front\",\n" +
|
||||
" \"image_size\": [\n" +
|
||||
" 287,\n" +
|
||||
" 477\n" +
|
||||
" ],\n" +
|
||||
" \"image_url\": \"image/image_1694613014.687538.png\",\n" +
|
||||
" \"mask_url\": \"mask/mask_1694613014.687538.png\",\n" +
|
||||
" \"position\": [\n" +
|
||||
" 495,\n" +
|
||||
" 714\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
" ],\n" +
|
||||
" \"synthesis_url\": \"result_1694613014.8975976.png\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"msg\": \"OK!\"\n" +
|
||||
"}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ai.da.python.vo.DesignPythonItem.*;
|
||||
@@ -443,7 +442,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
designItemDetail.setIconPath(detail.getIcon());
|
||||
DesignPythonItemPrint printObject = detail.getPrint();
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath());
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
|
||||
designItemDetails.add(designItemDetail);
|
||||
});
|
||||
designItemDetailService.saveBatch(designItemDetails);
|
||||
@@ -492,7 +491,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
designItemDetail.setIconPath(detail.getIcon());
|
||||
DesignPythonItemPrint printObject = detail.getPrint();
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath());
|
||||
designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath());
|
||||
designItemDetails.add(designItemDetail);
|
||||
});
|
||||
designItemDetailService.saveBatch(designItemDetails);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.SysFileMapper;
|
||||
import com.ai.da.mapper.entity.SysFile;
|
||||
import com.ai.da.model.vo.SysFileVO;
|
||||
import com.ai.da.service.PythonTAllInfoService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -250,26 +251,4 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
||||
queryWrapper.in("url", urlList);
|
||||
return CopyUtil.copyList(sysFileMapper.selectList(queryWrapper),SysFileVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysFileVO getByUrl(String url, String type,String timeZone){
|
||||
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("url", url);
|
||||
SysFile sysFile = sysFileMapper.selectOne(queryWrapper);
|
||||
// 如果当前url不存在,先将其插入表中
|
||||
if (Objects.isNull(sysFile)){
|
||||
sysFile = setSysFileEntity(url,type,timeZone);
|
||||
sysFileMapper.insert(sysFile);
|
||||
}
|
||||
|
||||
return CopyUtil.copyObject(sysFile,SysFileVO.class);
|
||||
}
|
||||
|
||||
private SysFile setSysFileEntity(String url,String type,String timeZone){
|
||||
InputStream originFile = FileUtil.getOriginFile(url);
|
||||
String[] arr = url.split("/");
|
||||
String level1Type = SysFileLevel2TypeEnum.ACCESSORIES_LIST.contains(type) ? SysFileLevel1TypeEnum.ACCESSORIES.getRealName() :
|
||||
SysFileLevel2TypeEnum.IMAGES_LIST.contains(type) ? SysFileLevel1TypeEnum.IMAGES.getRealName() : SysFileLevel1TypeEnum.ICON_C.getRealName();
|
||||
return new SysFile(level1Type, type, arr[arr.length - 1], MD5Utils.encryptFile(originFile), url, DateUtil.getByTimeZone(timeZone));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.TDesignPythonOutfitDetailMapper;
|
||||
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
|
||||
import com.ai.da.model.vo.DesignPythonOutfitVO;
|
||||
@@ -9,9 +10,12 @@ import com.ai.da.service.ITDesignPythonOutfitDetailService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -24,6 +28,10 @@ import java.util.Objects;
|
||||
@Service
|
||||
public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPythonOutfitDetailMapper, TDesignPythonOutfitDetail> implements ITDesignPythonOutfitDetailService {
|
||||
|
||||
@Value("${minio.bucketName2}")
|
||||
private String bucketName2;
|
||||
@Resource
|
||||
private MinioUtil minIoUtil;
|
||||
@Override
|
||||
public IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail) {
|
||||
return page.setRecords(baseMapper.selectTDesignPythonOutfitDetailPage(page, tDesignPythonOutfitDetail));
|
||||
@@ -37,15 +45,6 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail){
|
||||
if (Objects.isNull(detail)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail){
|
||||
if (Objects.isNull(detail)) {
|
||||
@@ -55,7 +54,20 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
|
||||
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail,DesignPythonOutfitVO.class);
|
||||
designPythonOutfitVO.setPosition((List<Long>) JSON.parse(detail.getPosition()));
|
||||
designPythonOutfitVO.setImageSize((List<Long>) JSON.parse(detail.getImageSize()));
|
||||
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.getPresignedUrl(bucketName2,detail.getImageUrl(),5));
|
||||
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(bucketName2,detail.getMaskUrl(),5));
|
||||
return designPythonOutfitVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId){
|
||||
QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("design_python_outfit_id",designPythonOutfitId);
|
||||
|
||||
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
|
||||
tDesignPythonOutfitDetail.setIsDeleted(1);
|
||||
|
||||
baseMapper.update(tDesignPythonOutfitDetail,queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user