diff --git a/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java index e861d2d3..ed52c386 100644 --- a/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java +++ b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java @@ -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") diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 779528a2..aa21b11d 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -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(); diff --git a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java index b0db2e67..626b88b5 100644 --- a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java @@ -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 不存数据库 submit -> 存数据库 List 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 convertToOutfitDetailPythonItemList(List layers) { List composeLayerPythonItem = Arrays.asList(new OutfitDetailPythonItem[layers.size()]); layers.forEach(layer -> { diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index d861e515..65c4a843 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -2407,7 +2407,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl