BUGFIX: 1、singleDesign使用generate的印花没有传minio导致出现错误
2、项目中没有保存生成和上传的印花的类型
This commit is contained in:
@@ -19,7 +19,7 @@ public class DesignSinglePrint implements Serializable {
|
||||
@ApiModelProperty("印花的类型 Slogan || Logo || Pattern")
|
||||
private String level2Type;
|
||||
|
||||
@ApiModelProperty("印花是用户上传的还是从library中选的 collection/library")
|
||||
@ApiModelProperty("印花是用户上传的还是从library中选的 collection/library/Generate")
|
||||
private String designType;
|
||||
|
||||
@ApiModelProperty("印花url")
|
||||
|
||||
@@ -44,6 +44,8 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -2924,6 +2926,7 @@ public class PythonService {
|
||||
p.getLocation().set(0, p.getLocation().get(0));
|
||||
p.getLocation().set(1, p.getLocation().get(1));
|
||||
Integer priority = p.getPriority();
|
||||
setUriToMinioPath(p);
|
||||
// todo 下标越界问题
|
||||
if (p.getIfSingle()){
|
||||
locationS.set(priority - 1, p.getLocation());
|
||||
@@ -2959,6 +2962,25 @@ public class PythonService {
|
||||
return printToPython;
|
||||
}
|
||||
|
||||
// 对印花类型为Generate的图片路径进行特殊处理
|
||||
private void setUriToMinioPath(DesignSinglePrint print){
|
||||
if (print.getDesignType().equals("Generate")){
|
||||
if (!StringUtil.isNullOrEmpty(print.getPath())){
|
||||
try {
|
||||
URI uri = new URI(print.getPath());
|
||||
String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png
|
||||
String substring = path.substring(1);
|
||||
print.setMinIOPath(substring);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("designType为Generate的印花path传值为空 :{}", print.getPath());
|
||||
throw new BusinessException("The path for the print is empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveDesignElement(DesignSinglePrintDTO trims, PrintToPython printToPython) {
|
||||
// 没有design element 时的参数设置
|
||||
DesignPythonItemElement element = new DesignPythonItemElement();
|
||||
|
||||
@@ -37,6 +37,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@@ -91,6 +93,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
private String clothingBucket;
|
||||
@Value("${minio.bucketName.partialDesign}")
|
||||
private String partialDesignBucket;
|
||||
@Value("${minio.endpoint}")
|
||||
private String minioEndpoint;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
@@ -583,7 +587,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
// preview -> 不存数据库 submit -> 存数据库
|
||||
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails;
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data == null) {
|
||||
if (data == null || data.toJSONString().equals("{}") ) {
|
||||
throw new BusinessException("python response data is null");
|
||||
}
|
||||
JSONObject outfit = data.getJSONObject("0");
|
||||
@@ -911,6 +915,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
// 2.2 否:先删除原始印花,再添加新印花信息
|
||||
designItemDetailPrintService.deleteByDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getPriority()));
|
||||
}
|
||||
setUriToMinioPath(print);
|
||||
|
||||
DesignItemDetailPrint designItemDetailPrint = new DesignItemDetailPrint();
|
||||
designItemDetailPrint.setDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getPriority()));
|
||||
designItemDetailPrint.setPrintType(printType);
|
||||
@@ -928,6 +934,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
}
|
||||
}
|
||||
|
||||
// 对印花类型为Generate的图片路径进行特殊处理
|
||||
private void setUriToMinioPath(DesignSinglePrint print){
|
||||
if (print.getDesignType().equals("Generate")){
|
||||
if (!StringUtil.isNullOrEmpty(print.getPath())){
|
||||
try {
|
||||
URI uri = new URI(print.getPath());
|
||||
String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png
|
||||
String substring = path.substring(1);
|
||||
print.setMinIOPath(substring);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.error("designType为Generate的印花path传值为空 :{}", print.getPath());
|
||||
throw new BusinessException("The path for the print is empty.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<OutfitDetailPythonItem> convertToOutfitDetailPythonItemList(List<DesignPythonOutfitVO> layers) {
|
||||
List<OutfitDetailPythonItem> composeLayerPythonItem = Arrays.asList(new OutfitDetailPythonItem[layers.size()]);
|
||||
layers.forEach(layer -> {
|
||||
|
||||
@@ -2407,7 +2407,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
collectionElement.setAccountId(accountId);
|
||||
collectionElement.setProjectId(projectId);
|
||||
collectionElement.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
// collectionElement.setName(generateDetail.get());
|
||||
collectionElement.setUrl(generateDetail.getUrl());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
@@ -2417,7 +2417,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}else {
|
||||
if (old.contains(board.getId())) {
|
||||
CollectionElement collectionElement = collectionElementMapper.selectById(board.getId());
|
||||
// collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setLevel2Type(board.getLevel2Type());
|
||||
collectionElement.setHasPin(board.getIsPin());
|
||||
collectionElement.setUpdateDate(new Date());
|
||||
collectionElementMapper.updateById(collectionElement);
|
||||
|
||||
Reference in New Issue
Block a user