diff --git a/src/main/java/com/ai/da/common/enums/GenerateTypeEnum.java b/src/main/java/com/ai/da/common/enums/GenerateModeEnum.java similarity index 83% rename from src/main/java/com/ai/da/common/enums/GenerateTypeEnum.java rename to src/main/java/com/ai/da/common/enums/GenerateModeEnum.java index 2ccdeafc..0c46e986 100644 --- a/src/main/java/com/ai/da/common/enums/GenerateTypeEnum.java +++ b/src/main/java/com/ai/da/common/enums/GenerateModeEnum.java @@ -3,7 +3,7 @@ package com.ai.da.common.enums; import lombok.Getter; @Getter -public enum GenerateTypeEnum { +public enum GenerateModeEnum { /** * 通过文本生成 @@ -23,7 +23,7 @@ public enum GenerateTypeEnum { private Integer code; private String value; - GenerateTypeEnum(int code,String value) { + GenerateModeEnum(int code, String value) { this.code = code; this.value = value; } diff --git a/src/main/java/com/ai/da/common/enums/SysFileLevel2TypeEnum.java b/src/main/java/com/ai/da/common/enums/SysFileLevel2TypeEnum.java index 824d6e34..47d30518 100644 --- a/src/main/java/com/ai/da/common/enums/SysFileLevel2TypeEnum.java +++ b/src/main/java/com/ai/da/common/enums/SysFileLevel2TypeEnum.java @@ -1,5 +1,6 @@ package com.ai.da.common.enums; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -70,4 +71,21 @@ public enum SysFileLevel2TypeEnum { public static List ofPythonPath(){ return Stream.of(BLOUSE,DRESS,OUTWEAR,SKIRT,TROUSERS).map(SysFileLevel2TypeEnum::getUploadPathName).collect(Collectors.toList()); } + + public static final List ACCESSORIES_LIST = Arrays.asList( + SysFileLevel2TypeEnum.BAG.getRealName(), + SysFileLevel2TypeEnum.EARRINGS.getRealName(), + SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), + SysFileLevel2TypeEnum.SHOES.getRealName(), + SysFileLevel2TypeEnum.BODY.getRealName() + ); + + public static final List IMAGES_LIST = Arrays.asList( + SysFileLevel2TypeEnum.BLOUSE.getRealName(), + SysFileLevel2TypeEnum.DRESS.getRealName(), + SysFileLevel2TypeEnum.OUTWEAR.getRealName(), + SysFileLevel2TypeEnum.SKIRT.getRealName(), + SysFileLevel2TypeEnum.TROUSERS.getRealName() + ); + } diff --git a/src/main/java/com/ai/da/common/utils/MD5Utils.java b/src/main/java/com/ai/da/common/utils/MD5Utils.java index 896dc3ca..c15686ed 100644 --- a/src/main/java/com/ai/da/common/utils/MD5Utils.java +++ b/src/main/java/com/ai/da/common/utils/MD5Utils.java @@ -74,6 +74,16 @@ public class MD5Utils { return md5; } + public static String encryptFile(InputStream inputStream) { + String md5 = null; + try { + md5 = DigestUtils.md5DigestAsHex(inputStream); + } catch (IOException ioException) { + log.error("文件InputStream md5加密异常ioException##{}", ExceptionUtil.getThrowableList(ioException)); + } + return md5; + } + public static void main(String[] args) throws FileNotFoundException, IOException { File file1 = new File("/Users/yanglei/Documents/阳磊日报2019-04-23.numbers"); File file2 = new File("/Users/yanglei/Documents/7777.numbers"); diff --git a/src/main/java/com/ai/da/controller/DesignDetailController.java b/src/main/java/com/ai/da/controller/DesignDetailController.java index b97ff86e..c4dd00e2 100644 --- a/src/main/java/com/ai/da/controller/DesignDetailController.java +++ b/src/main/java/com/ai/da/controller/DesignDetailController.java @@ -1,8 +1,6 @@ package com.ai.da.controller; import com.ai.da.common.response.Response; -import com.ai.da.mapper.entity.CollectionElement; -import com.ai.da.mapper.entity.DesignItem; import com.ai.da.model.dto.*; import com.ai.da.model.vo.*; import com.ai.da.service.DesignItemService; @@ -15,7 +13,6 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; -import java.math.BigDecimal; @Api(tags = "design Detail模块") @@ -46,7 +43,7 @@ public class DesignDetailController { @GetMapping("/getDetail") public Response getDetail(@ApiParam("designItemId") @RequestParam("designItemId") Long designItemId, @ApiParam("designPythonOutfitId") @RequestParam(value = "designPythonOutfitId",required = false) Long designPythonOutfitId) { - return Response.success(designService.detail(designItemId,designItemId)); + return Response.success(designService.detail(designPythonOutfitId,designItemId)); } @ApiOperation(value = "切换系统的element") @@ -58,8 +55,8 @@ public class DesignDetailController { } @ApiOperation(value = "单个design") @PostMapping("/designSingle") - public Response designSingle(@Valid @RequestBody DesignSingleDTO designSingleDTO ) { - return Response.success(designItemService.designSingle(designSingleDTO)); + public Response designSingle(@Valid @RequestBody DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO ) { + return Response.success(designItemService.designSingleIncludeLayers(designSingleIncludeLayersDTO)); } @ApiOperation(value = "print打点") diff --git a/src/main/java/com/ai/da/mapper/entity/SysFile.java b/src/main/java/com/ai/da/mapper/entity/SysFile.java index ce89ffe3..5072ab10 100644 --- a/src/main/java/com/ai/da/mapper/entity/SysFile.java +++ b/src/main/java/com/ai/da/mapper/entity/SysFile.java @@ -66,4 +66,16 @@ public class SysFile implements Serializable { * 更新时间 */ private Date updateDate; + + public SysFile() { + } + + public SysFile(String level1Type, String level2Type, String name, String md5, String url,Date createDate) { + this.level1Type = level1Type; + this.level2Type = level2Type; + this.name = name; + this.md5 = md5; + this.url = url; + this.createDate = createDate; + } } diff --git a/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfit.java b/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfit.java index 0fe1a833..a03655a4 100644 --- a/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfit.java +++ b/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfit.java @@ -30,6 +30,8 @@ public class TDesignPythonOutfit implements Serializable { @ApiModelProperty(value = "ID") @TableId(value = "id", type = IdType.AUTO) private Long id; + + private Long designItemId; /** * 关联的design ID */ diff --git a/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfitDetail.java b/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfitDetail.java index 8b8ee496..d822292f 100644 --- a/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfitDetail.java +++ b/src/main/java/com/ai/da/mapper/entity/TDesignPythonOutfitDetail.java @@ -50,6 +50,9 @@ public class TDesignPythonOutfitDetail implements Serializable { */ @ApiModelProperty(value = "图层") private String imageCategory; + + @ApiModelProperty(value = "图层大小") + private String imageSize; /** * 对应的图片的绝对路径 */ diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleDTO.java index 2eece106..ff033b22 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleDTO.java @@ -26,6 +26,11 @@ public class DesignSingleDTO { @ApiModelProperty("others 元素") private List others; + private DesignSingleItemDTO designSingleItem; + + @ApiModelProperty("preview -> true submit -> false") + private Boolean isPreview; + @NotBlank(message = "timeZone cannot be empty!") @ApiModelProperty("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取") private String timeZone; diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java new file mode 100644 index 00000000..ce229ce7 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java @@ -0,0 +1,26 @@ +package com.ai.da.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; + +@Data +public class DesignSingleIncludeLayersDTO { + + @ApiModelProperty("designItemId") + @NotNull(message = "designItemId cannot be empty!") + private Long designItemId; + + private List designSingleItemDTOList; + + @NotNull(message = "isPreview cannot be null") + @ApiModelProperty("preview -> true submit -> false") + private Boolean isPreview; + + @NotBlank(message = "timeZone cannot be empty!") + @ApiModelProperty("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取") + private String timeZone; +} diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index 97cbd61f..b65c0e44 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -1,6 +1,5 @@ package com.ai.da.model.dto; -import com.ai.da.python.vo.DesignPythonItemPrint; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -25,5 +24,6 @@ public class DesignSingleItemDTO { private String color; @ApiModelProperty("对应的print图片对象") - private DesignPythonItemPrint printObject; +// private DesignPythonItemPrint printObject; + private DesignSinglePrintDTO printObject; } diff --git a/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java b/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java new file mode 100644 index 00000000..d75bc0e4 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java @@ -0,0 +1,23 @@ +package com.ai.da.model.dto; + +import com.ai.da.model.vo.DesignSinglePrint; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel("design single 印花请求信息") +public class DesignSinglePrintDTO { + + @ApiModelProperty("印花url") + private String path; + + @ApiModelProperty("single -> true,overall -> false") + private Boolean ifSingle; + + @ApiModelProperty("印花详细") + private List prints; + +} \ No newline at end of file diff --git a/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java b/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java index f91ce533..62b8d2e0 100644 --- a/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java @@ -3,10 +3,8 @@ package com.ai.da.model.vo; import com.ai.da.python.vo.DesignPythonItemPrint; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; import lombok.Data; -import java.util.Date; import java.util.List; @Data @@ -31,4 +29,7 @@ public class DesignItemClothesDetailVO { @ApiModelProperty("对应的print图片对象") private DesignPythonItemPrint printObject; + + @ApiModelProperty("对应图层信息") + private List layersObject; } diff --git a/src/main/java/com/ai/da/model/vo/DesignItemDetailVO.java b/src/main/java/com/ai/da/model/vo/DesignItemDetailVO.java index 6ae4949b..29605965 100644 --- a/src/main/java/com/ai/da/model/vo/DesignItemDetailVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignItemDetailVO.java @@ -15,7 +15,8 @@ public class DesignItemDetailVO { private Long designItemId; @ApiModelProperty("designItem图片") - private DesignPythonOutfitVO designItemUrl; +// private DesignPythonOutfitVO designItemUrl; + private String designItemUrl; @ApiModelProperty("design高级图片") private String highDesignUrl; diff --git a/src/main/java/com/ai/da/model/vo/DesignItemOthersDetailVO.java b/src/main/java/com/ai/da/model/vo/DesignItemOthersDetailVO.java index 4c84be4d..f68d6081 100644 --- a/src/main/java/com/ai/da/model/vo/DesignItemOthersDetailVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignItemOthersDetailVO.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + @Data @ApiModel("designItem detail others 响应") public class DesignItemOthersDetailVO { @@ -24,4 +26,7 @@ public class DesignItemOthersDetailVO { @ApiModelProperty("对应的print图片的绝对路径") private DesignPythonItemPrint printObject; + + @ApiModelProperty("对应图层信息") + private List layersObject; } diff --git a/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java b/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java index 42f99324..69456abe 100644 --- a/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignPythonOutfitVO.java @@ -1,6 +1,5 @@ package com.ai.da.model.vo; -import com.ai.da.mapper.entity.TDesignPythonOutfitDetail; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -11,14 +10,36 @@ import java.util.List; @ApiModel("designItem detail从python端获取的合成图+各图层响应") public class DesignPythonOutfitVO { - @ApiModelProperty("当前图片无图层信息时,为空") - private Long designPythonOutfitId; + /** + * ID + */ + @ApiModelProperty(value = "ID") + private Long id; - @ApiModelProperty("合成图") - String designPythonOutfitUrl; + /** + * 图层 + */ + @ApiModelProperty(value = "图层名") + private String imageCategory; - // TODO - // 需明确,不需要的数据不要返回 - @ApiModelProperty("各部分图层信息") - List designItemDetailLayers; + /** + * 图层大小 + */ + @ApiModelProperty(value = "图层大小") + private List imageSize; + /** + * 对应的图片的绝对路径 + */ + @ApiModelProperty(value = "对应的图片的绝对路径") + private String imageUrl; + /** + * mask_url + */ + @ApiModelProperty(value = "遮罩") + private String maskUrl; + /** + * 位置 + */ + @ApiModelProperty(value = "位置") + private List position; } diff --git a/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java new file mode 100644 index 00000000..95188172 --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java @@ -0,0 +1,31 @@ +package com.ai.da.model.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.Min; +import java.util.List; + +@Data +@ApiModel("design single 印花详情") +public class DesignSinglePrint { + + @ApiModelProperty("印花位置") + @Range(max = 1L,message = "印花坐标需用大于等于0小于等于1的数表示") + private List location; + + @ApiModelProperty("印花大小") + @Range(max = 1,message = "印花缩放值需用大于等于0小于等于1的数表示") + private Float scale; + + @Range(min = -360,max = 360,message = "印花旋转角度范围为-360° ~ 360°") + @ApiModelProperty("印花角度") + private Float angle; + + @Min(value = 1) + @ApiModelProperty("印花优先级") + private Integer priority; + +} diff --git a/src/main/java/com/ai/da/model/vo/DesignSingleVO.java b/src/main/java/com/ai/da/model/vo/DesignSingleVO.java new file mode 100644 index 00000000..7843cd90 --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/DesignSingleVO.java @@ -0,0 +1,22 @@ +package com.ai.da.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class DesignSingleVO { + + private Long designItemId; + + /** + * 全身图 + */ + private String designItemUrl; + + + @ApiModelProperty("clothes 数组") + private List clothes; + +} diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 260d5df0..2b083c7e 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -6,7 +6,6 @@ import com.ai.da.common.config.FileProperties; import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.enums.*; import com.ai.da.common.utils.*; -import com.ai.da.mapper.entity.Collection; import com.ai.da.mapper.entity.CollectionElement; import com.ai.da.mapper.entity.DesignHistory; import com.ai.da.model.dto.*; @@ -37,7 +36,6 @@ import java.math.BigDecimal; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import java.util.stream.Stream; @Slf4j @Service @@ -796,7 +794,7 @@ public class PythonService { //所有的icon都是none designPythonItemBlouse.setIcon("none"); designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards())); - if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") + if (!elementVO.getDesignPythonItemPrint().getSinglePath().equals("none") && elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) { designPythonItemBlouse.setPrint(CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class)); } else { @@ -999,20 +997,20 @@ public class PythonService { //print 不取library的 只取element的 DesignPythonItemPrint print = new DesignPythonItemPrint(); if (CollectionUtil.isEmpty(elementVO.getPrintBoardElements())) { - print.setPath("none"); + print.setSinglePath("none"); return print; } List printBoardElements = elementVO.getPrintBoardElements() .stream() .filter(f -> !elementVO.getHasUseMd5List().contains(f.getMd5())).collect(Collectors.toList()); if (CollectionUtil.isEmpty(printBoardElements)) { - print.setPath("none"); + print.setSinglePath("none"); return print; } switch (designPrintPictureType) { case NO: //print 已用完 - print.setPath("none"); + print.setSinglePath("none"); return print; case NO_PIN: printBoardElements = printBoardElements.stream().filter(f -> f.getHasPin() == 0).collect(Collectors.toList()); @@ -1024,14 +1022,14 @@ public class PythonService { } if (printBoardElements.size() == 1) { - print.setPath(printBoardElements.get(0).getUrl()); + print.setSinglePath(printBoardElements.get(0).getUrl()); elementVO.getHasUseMd5List().add(printBoardElements.get(0).getMd5()); return print; } long maxPrint = printBoardElements.size(); long minPrint = 0; Long randomIndex = RandomsUtil.randomSysFile(minPrint, maxPrint); - print.setPath(printBoardElements.get(randomIndex.intValue()).getUrl()); + print.setSinglePath(printBoardElements.get(randomIndex.intValue()).getUrl()); elementVO.getHasUseMd5List().add(printBoardElements.get(randomIndex.intValue()).getMd5()); return print; } @@ -1090,7 +1088,7 @@ public class PythonService { log.info("design请求python 参数:####{}", param); RequestBody body = RequestBody.create(mediaType, param); Request request = new Request.Builder() - .url("http://18.167.251.121:9991") + .url("http://18.167.251.121:9991/api/design") // .url(accessPythonIp + ":10200/aifda/api/v1.0/generate") .method("POST", body) .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==") @@ -1270,6 +1268,27 @@ public class PythonService { return designPythonObjects; } + /** + * 组装和计算设计包括图层的单品的参数,不需要priority + * @param designSingleDTO + * @param singleOverall + * @param switchCategory + * @param designLibraryModelPoint + * @return + */ + public DesignPythonObjects covertDesignSingleParam(DesignSingleIncludeLayersDTO designSingleDTO, String singleOverall, + String switchCategory, DesignLibraryModelPointVO designLibraryModelPoint) { + DesignPythonObjects designPythonObjects = new DesignPythonObjects(); + List objects = Lists.newArrayList(); + designPythonObjects.setObjects(objects); + + DesignPythonObject pythonObject = new DesignPythonObject(); + pythonObject.setItems(coverToDesignSinglePythonItem(designSingleDTO, designLibraryModelPoint)); + pythonObject.setBasic(coverToSingleBasic(singleOverall, switchCategory, designLibraryModelPoint)); + objects.add(pythonObject); + return designPythonObjects; + } + private List coverToDesignSinglePythonItem(DesignSingleDTO designSingleDTO, DesignLibraryModelPointVO designLibraryModelPoint) { List designPythonItemDto = designSingleDTO.getClothes(); if (!CollectionUtils.isEmpty(designSingleDTO.getOthers())) { @@ -1292,28 +1311,84 @@ public class PythonService { return response; } - private DesignPythonItemPrint resolveDesignSinglePrint(DesignPythonItemPrint printObject, String clothesPath) { + /** + * 设计包括图层的单品,每次只针对一个单品 + * @param designSingleIncludeLayersDTO + * @param designLibraryModelPoint + * @return + */ + private List coverToDesignSinglePythonItem(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, DesignLibraryModelPointVO designLibraryModelPoint) { + List designSingleItemList = designSingleIncludeLayersDTO.getDesignSingleItemDTOList(); + List response = new ArrayList<>(); + + + designSingleItemList.forEach(designSingleItem -> { + response.add(new DesignPythonItem( + designSingleItem.getType(), + designSingleItem.getPath(), + designSingleItem.getColor(), + resolveDesignSinglePrint(designSingleItem .getPrintObject(), designSingleItem.getPath()), + "none", + sysFileService.getByUrl(designSingleItem.getPath(), designSingleItem.getType(),designSingleIncludeLayersDTO.getTimeZone()).getId())); + }); + + + String bodyPath; + if (Objects.nonNull(designLibraryModelPoint)) { + bodyPath = designLibraryModelPoint.getTemplateUrl(); + } else { +// bodyPath = "/workspace/python_code/Multi-layer-Virtual-Try-on/dataset_for_test/Img_model.png"; + bodyPath = "https://www.aida.com.hk/download/202301/userFile/library/Models/31/845046c7-4f62-4f54-a4a9-c26d49c6969335b5b3a9-d335-4871-a46c-3cc3caf07da259629dfd1f1f555a2e2a9def7e719366.jpeg"; + } + response.add(new DesignPythonItem(SysFileLevel2TypeEnum.BODY.getRealName(),bodyPath,sysFileService.getByUrl(bodyPath, SysFileLevel2TypeEnum.BODY.getRealName(),designSingleIncludeLayersDTO.getTimeZone()).getId())); + return response; + } + + + + private DesignPythonItemPrint resolveDesignSinglePrint(DesignSinglePrintDTO printObject, String clothesPath) { if (Objects.isNull(printObject)) { return null; } DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class); if(StringUtils.isEmpty(printObject.getPath())){ - print.setPath("none"); + print.setPath(new ArrayList<>()); + }else { + print.setPath(Collections.singletonList(printObject.getPath())); } if (StringUtils.isEmpty(clothesPath) || "none".equals(clothesPath) - || CollectionUtils.isEmpty(printObject.getLocation())) { + || CollectionUtils.isEmpty(printObject.getPrints())) { return print; } //图片宽 高 FileVO fileVO = FileUtil.getFileSize(FileUtil.getOriginFile(clothesPath)); - List> locations = printObject.getLocation(); + /* List> locations = printObject.getLocation(); locations.forEach(location -> { location.set(0, location.get(0) * fileVO.getWidth()); location.set(1, location.get(1) * fileVO.getHigh()); - }); + });*/ + + List> location = new ArrayList<>(printObject.getPrints().size()); + List scale = new ArrayList<>(printObject.getPrints().size()); + List angle = new ArrayList<>(printObject.getPrints().size()); + + // 设置印花的位置、大小、旋转角度 + // todo 空指针 + List prints = printObject.getPrints(); + prints.forEach(p -> { + p.getLocation().set(0,p.getLocation().get(0) * fileVO.getWidth()); + p.getLocation().set(1,p.getLocation().get(1) * fileVO.getHigh()); + Integer priority = p.getPriority(); + location.add(priority - 1, p.getLocation()); + scale.add(priority - 1,p.getScale()); + angle.add(priority - 1,p.getAngle()); + log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO)); + }); + print.setLocation(location); + print.setScale(scale); + print.setAngle(angle); - log.info("本次print打点locations###{}###fileVO{}", locations, JSON.toJSONString(fileVO)); return print; } @@ -1337,6 +1412,28 @@ public class PythonService { return basic; } + /** + * 设计包括图层的单品,不用指定save_name和priority + * @param singleOverall + * @param switchCategory + * @param designLibraryModelPoint + * @return + */ + private DesignPythonBasic coverToSingleBasic(String singleOverall, String switchCategory, + DesignLibraryModelPointVO designLibraryModelPoint) { + DesignPythonBasic basic = new DesignPythonBasic(); + basic.setSingle_overall(singleOverall); + basic.setSwitch_category(switchCategory); + basic.setSelf_template(Boolean.FALSE); + if (Objects.nonNull(designLibraryModelPoint)) { + basic.setSelf_template(Boolean.TRUE); + } + basic.setScale_bag(0.7); + basic.setScale_earrings(0.16); + basic.setBody_point_test(getMap(designLibraryModelPoint)); + return basic; + } + /** * 组装和计算designSingle参数 * @@ -1425,12 +1522,13 @@ public class PythonService { .build(); MediaType mediaType = MediaType.parse("application/json"); //关闭FastJson的引用检测 防止出现$ref 现象 -// String param = JSON.toJSONString(designPythonObjects, SerializerFeature.DisableCircularReferenceDetect); - String param = "{\"objects\":[{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/202308/userFile/collection/Sketchboard/42/048419db-38c4-4aee-85a7-33f0666b18d2.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/pythonFile/generatePrint/generatePrint-d7a67a96-83f9-429f-9028-3e1697501088.jpg\"},\"type\":\"Outwear\",\"image_id\":53547},{\"color\":\"137 50 50\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0628001153.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53548},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_242.jpg\",\"type\":\"Hairstyle\",\"image_id\":411},{\"color\":\"31 76 171\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_11.jpg\",\"type\":\"Shoes\",\"image_id\":167},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_12.png\",\"type\":\"Earring\",\"image_id\":93},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"103 74 74\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/dress/0902005000.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/userFile/library/Printboard/42/4ba535c2-a08b-4114-826b-a87885fd3623Fabric-03.png\"},\"type\":\"Dress\",\"image_id\":53549},{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0825000582.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/userFile/library/Printboard/42/4ba535c2-a08b-4114-826b-a87885fd3623Fabric-03.png\"},\"type\":\"Skirt\",\"image_id\":53550},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2529.jpg\",\"type\":\"Hairstyle\",\"image_id\":898},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_15.png\",\"type\":\"Earring\",\"image_id\":96},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"49 127 162\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0628001185.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202308/pythonFile/generatePrint/generatePrint-487e93e6-1e21-46b8-b821-3188251dbdbc.jpg\"},\"type\":\"Outwear\",\"image_id\":53551},{\"color\":\"103 74 74\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/trousers/0628000635.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202308/pythonFile/generatePrint/generatePrint-487e93e6-1e21-46b8-b821-3188251dbdbc.jpg\"},\"type\":\"Trousers\",\"image_id\":53552},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2102.jpg\",\"type\":\"Hairstyle\",\"image_id\":471},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_41.jpg\",\"type\":\"Shoes\",\"image_id\":344},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_5.png\",\"type\":\"Earring\",\"image_id\":87},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"31 76 171\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0902002198.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Outwear\",\"image_id\":53553},{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0916000791.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53554},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2518.jpg\",\"type\":\"Hairstyle\",\"image_id\":887},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_11.png\",\"type\":\"Earring\",\"image_id\":92},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0902000892.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Outwear\",\"image_id\":53555},{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/trousers/0916000460.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Trousers\",\"image_id\":53556},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_204.jpg\",\"type\":\"Hairstyle\",\"image_id\":294},{\"color\":\"49 127 162\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_5.png\",\"type\":\"Earring\",\"image_id\":87},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902002112.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53558},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2186.jpg\",\"type\":\"Hairstyle\",\"image_id\":555},{\"color\":\"204 182 182\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_11.jpg\",\"type\":\"Shoes\",\"image_id\":167},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_12.png\",\"type\":\"Earring\",\"image_id\":93},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"137 50 50\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902002861.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53560},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2128.jpg\",\"type\":\"Hairstyle\",\"image_id\":497},{\"color\":\"49 127 162\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_39.jpg\",\"type\":\"Shoes\",\"image_id\":192},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_4.png\",\"type\":\"Earring\",\"image_id\":86},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"49 127 162\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902000567.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53562},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2357.jpg\",\"type\":\"Hairstyle\",\"image_id\":726},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_6.jpg\",\"type\":\"Shoes\",\"image_id\":163},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_15.png\",\"type\":\"Earring\",\"image_id\":96},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]}]}"; + String param = JSON.toJSONString(designPythonObjects, SerializerFeature.DisableCircularReferenceDetect); +// String param = "{\"objects\":[{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/202308/userFile/collection/Sketchboard/42/048419db-38c4-4aee-85a7-33f0666b18d2.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/pythonFile/generatePrint/generatePrint-d7a67a96-83f9-429f-9028-3e1697501088.jpg\"},\"type\":\"Outwear\",\"image_id\":53547},{\"color\":\"137 50 50\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0628001153.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53548},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_242.jpg\",\"type\":\"Hairstyle\",\"image_id\":411},{\"color\":\"31 76 171\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_11.jpg\",\"type\":\"Shoes\",\"image_id\":167},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_12.png\",\"type\":\"Earring\",\"image_id\":93},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"103 74 74\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/dress/0902005000.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/userFile/library/Printboard/42/4ba535c2-a08b-4114-826b-a87885fd3623Fabric-03.png\"},\"type\":\"Dress\",\"image_id\":53549},{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0825000582.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202304/userFile/library/Printboard/42/4ba535c2-a08b-4114-826b-a87885fd3623Fabric-03.png\"},\"type\":\"Skirt\",\"image_id\":53550},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2529.jpg\",\"type\":\"Hairstyle\",\"image_id\":898},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_15.png\",\"type\":\"Earring\",\"image_id\":96},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"49 127 162\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0628001185.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202308/pythonFile/generatePrint/generatePrint-487e93e6-1e21-46b8-b821-3188251dbdbc.jpg\"},\"type\":\"Outwear\",\"image_id\":53551},{\"color\":\"103 74 74\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/trousers/0628000635.jpg\",\"print\":{\"path\":\"https://www.aida.com.hk/download/202308/pythonFile/generatePrint/generatePrint-487e93e6-1e21-46b8-b821-3188251dbdbc.jpg\"},\"type\":\"Trousers\",\"image_id\":53552},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2102.jpg\",\"type\":\"Hairstyle\",\"image_id\":471},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_41.jpg\",\"type\":\"Shoes\",\"image_id\":344},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_5.png\",\"type\":\"Earring\",\"image_id\":87},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"31 76 171\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0902002198.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Outwear\",\"image_id\":53553},{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0916000791.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53554},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2518.jpg\",\"type\":\"Hairstyle\",\"image_id\":887},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_11.png\",\"type\":\"Earring\",\"image_id\":92},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/outwear/0902000892.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Outwear\",\"image_id\":53555},{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/trousers/0916000460.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Trousers\",\"image_id\":53556},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_204.jpg\",\"type\":\"Hairstyle\",\"image_id\":294},{\"color\":\"49 127 162\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_15.png\",\"type\":\"Shoes\",\"image_id\":171},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_5.png\",\"type\":\"Earring\",\"image_id\":87},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"50 187 147\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902002112.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53558},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2186.jpg\",\"type\":\"Hairstyle\",\"image_id\":555},{\"color\":\"204 182 182\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_11.jpg\",\"type\":\"Shoes\",\"image_id\":167},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_12.png\",\"type\":\"Earring\",\"image_id\":93},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"137 50 50\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902002861.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53560},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2128.jpg\",\"type\":\"Hairstyle\",\"image_id\":497},{\"color\":\"49 127 162\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_39.jpg\",\"type\":\"Shoes\",\"image_id\":192},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_4.png\",\"type\":\"Earring\",\"image_id\":86},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]},{\"basic\":{\"body_point_test\":{\"shoulder_left\":[755,519],\"toe_right\":[850,1355],\"ear_point_left\":[802,439],\"shoulder_right\":[912,519],\"waistband_right\":[891,725],\"hand_point_right\":[915,886],\"waistband_left\":[777,725],\"hand_point_left\":[754,886],\"head_point_left\":[804,424],\"head_point_right\":[864,424],\"ear_point_right\":[865,438],\"toe_left\":[817,1355],\"foot_length\":[784,1336,825,1336],\"head_point_up\":[834,390]},\"scale_bag\":0.7,\"scale_earrings\":0.16,\"self_template\":false,\"single_overall\":\"overall\",\"switch_category\":\"\"},\"items\":[{\"color\":\"204 182 182\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/blouse/0902002193.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Blouse\",\"image_id\":53557},{\"color\":\"49 127 162\",\"icon\":\"none\",\"path\":\"https://www.aida.com.hk/download/sys/images/skirt/0902000567.jpg\",\"print\":{\"path\":\"none\"},\"type\":\"Skirt\",\"image_id\":53562},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/hairstyle/hairstyle_p2357.jpg\",\"type\":\"Hairstyle\",\"image_id\":726},{\"color\":\"137 50 50\",\"path\":\"https://www.aida.com.hk/download/sys/accessories/shoes/shoes_6.jpg\",\"type\":\"Shoes\",\"image_id\":163},{\"path\":\"https://www.aida.com.hk/download/sys/accessories/earring/earrings_15.png\",\"type\":\"Earring\",\"image_id\":96},{\"body_path\":\"model_1693218345.2714431.png\",\"type\":\"Body\",\"image_id\":0}]}]}"; log.info("design请求python 参数:####{}", param); RequestBody body = RequestBody.create(mediaType, param); Request request = new Request.Builder() - .url("http://18.167.251.121:9991") + .url("http://18.167.251.121:9991/api/design") +// .url("http://18.167.251.121:9991") // .url(accessPythonIp + ":10200/aifda/api/v1.0/generate") .method("POST", body) .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==") @@ -1515,7 +1613,7 @@ public class PythonService { throw new BusinessException("system error!"); } - public String generateSketchOrPrint(String url, String text, int mode, String modelName) { + public List generateSketchOrPrint(Long userId,String url,String category, String text, int mode, String modelName) { //限流校验 AccessLimitUtils.validate("generateSketchOrPrint",5); OkHttpClient client = new OkHttpClient().newBuilder() @@ -1526,13 +1624,16 @@ public class PythonService { .build(); MediaType mediaType = MediaType.parse("application/json"); Map content = Maps.newHashMap(); - content.put("img_url", url); + content.put("user_id", userId); + content.put("image_url", url); + content.put("category", category); + content.put("mode",mode); // content.put("str", text); - content.put("mode",mode); content.put("version",modelName); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); Request request = new Request.Builder() - .url(accessPythonIp + ":2828/aida/diffusion") +// .url(accessPythonIp + ":2828/aida/diffusion") + .url("http://18.167.251.121:9992") .method("POST", body) .addHeader("Authorization", "Basic YWlkbGFiOjEyMw==") .addHeader("Content-Type", "application/json") @@ -1555,7 +1656,7 @@ public class PythonService { JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(response)); Boolean result = jsonObject.getBoolean("successful"); if (result) { - return bodyString; + return setGenerateImageList(jsonObject.getJSONObject("date")); } log.info("generateSketchOrPrintPrint失败###{}", jsonObject); //生成失败 @@ -1589,4 +1690,15 @@ public class PythonService { } return bodyString; } + + private static List setGenerateImageList(JSONObject jsonObject){ + if (Objects.isNull(jsonObject.getJSONObject("list"))){ + log.error("PythonService##generateSketchOrPrint异常###{}","diffusion response list is null"); + + // todo 如果这里返回为空,是判断出错还是返回给前端空 + throw new BusinessException("Some errors occurred, please try again later"); + } + + return JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("list")), String.class); + } } diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java index 5cbba4b8..90c60ba3 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java @@ -53,6 +53,11 @@ public class DesignPythonItem { */ private String body_mask_path; + /** + * url在t_sys_file中的id + */ + private Long image_id; + public static List OUTWEAR_DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.DRESS.getRealName(),CollectionLevel2TypeEnum.BLOUSE.getRealName()); @@ -67,4 +72,22 @@ public class DesignPythonItem { public static List SYS_HAIRSTYLE_SHOES = Arrays.asList( SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), SysFileLevel2TypeEnum.SHOES.getRealName(), SysFileLevel2TypeEnum.EARRINGS.getRealName()); + + public DesignPythonItem() { + } + + public DesignPythonItem(String type, String bodyPath, Long image_id) { + this.type = type; + this.body_path = bodyPath; + this.image_id = image_id; + } + + public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long image_id) { + this.type = type; + this.path = path; + this.color = color; + this.print = print; + this.icon = icon; + this.image_id = image_id; + } } diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItemPrint.java b/src/main/java/com/ai/da/python/vo/DesignPythonItemPrint.java index 40ca5ab8..688ff9cb 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItemPrint.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItemPrint.java @@ -12,7 +12,9 @@ public class DesignPythonItemPrint { * print 绝对路径 */ @ApiModelProperty("图片绝对路径") - private String path; + private String singlePath; + + private List path; @ApiModelProperty("上传时候对应的类型,一级类型 Printboard ") private String level1Type; @@ -21,35 +23,41 @@ public class DesignPythonItemPrint { * print_scale */ @ApiModelProperty("print_scale") - private Float scale; + private Float print_scale; /** * 是否打点 */ - @ApiModelProperty("是否打点 是传true 否则false") private Boolean IfSingle; - @ApiModelProperty("打点的位置 传 [[0.2, 0.2]]") + @ApiModelProperty("print的位置 传 [[0.2, 0.2]]") private List> location; + @ApiModelProperty("print的缩放比例 传 [0.2, 0.2]") + private List scale; + + @ApiModelProperty("print的旋转角度 传 [0.2, 0.2]") + private List angle; + @JSONField(name="IfSingle") public Boolean getIfSingle() { return IfSingle; } - public DesignPythonItemPrint(String path, String level1Type, Float scale, Boolean ifSingle) { - this.path = path; + // todo + public DesignPythonItemPrint(String singlePath, String level1Type, Float scale, Boolean ifSingle) { + this.singlePath = singlePath; this.level1Type = level1Type; - this.scale = scale; + this.print_scale = scale; IfSingle = ifSingle; } public DesignPythonItemPrint() { } - public DesignPythonItemPrint(String path) { - this.path = path; + public DesignPythonItemPrint(String singlePath) { + this.singlePath = singlePath; } } diff --git a/src/main/java/com/ai/da/service/DesignItemService.java b/src/main/java/com/ai/da/service/DesignItemService.java index 766625bb..4a1525f2 100644 --- a/src/main/java/com/ai/da/service/DesignItemService.java +++ b/src/main/java/com/ai/da/service/DesignItemService.java @@ -2,10 +2,8 @@ package com.ai.da.service; import com.ai.da.mapper.entity.DesignItem; import com.ai.da.model.dto.DesignSingleDTO; -import com.ai.da.model.vo.DesignCollectionItemVO; -import com.ai.da.model.vo.DesignCollectionVO; -import com.ai.da.model.vo.DesignItemOthersDetailVO; -import com.ai.da.model.vo.GetNextSysElementVO; +import com.ai.da.model.dto.DesignSingleIncludeLayersDTO; +import com.ai.da.model.vo.*; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -47,4 +45,6 @@ public interface DesignItemService extends IService { */ String printDot(DesignSingleDTO designSingleDTO); + DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO); + } diff --git a/src/main/java/com/ai/da/service/ITDesignPythonOutfitDetailService.java b/src/main/java/com/ai/da/service/ITDesignPythonOutfitDetailService.java index 9bb8be53..de5e9889 100644 --- a/src/main/java/com/ai/da/service/ITDesignPythonOutfitDetailService.java +++ b/src/main/java/com/ai/da/service/ITDesignPythonOutfitDetailService.java @@ -2,6 +2,7 @@ package com.ai.da.service; import com.ai.da.mapper.entity.TDesignPythonOutfitDetail; +import com.ai.da.model.vo.DesignPythonOutfitVO; import com.ai.da.model.vo.TDesignPythonOutfitDetailVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -31,4 +32,6 @@ public interface ITDesignPythonOutfitDetailService extends IService getDetailByDesignPythonOutfitId(Long designPythonOutfitId); + + DesignPythonOutfitVO convertToDesignPythonOutfitVO(TDesignPythonOutfitDetail detail); } diff --git a/src/main/java/com/ai/da/service/ITDesignPythonOutfitService.java b/src/main/java/com/ai/da/service/ITDesignPythonOutfitService.java index 0df44dd0..e012ee0e 100644 --- a/src/main/java/com/ai/da/service/ITDesignPythonOutfitService.java +++ b/src/main/java/com/ai/da/service/ITDesignPythonOutfitService.java @@ -22,4 +22,5 @@ public interface ITDesignPythonOutfitService extends IService selectTDesignPythonOutfitPage(IPage page, TDesignPythonOutfitVO tDesignPythonOutfit); + TDesignPythonOutfit getByDesignItemId(Long designItemId); } diff --git a/src/main/java/com/ai/da/service/SysFileService.java b/src/main/java/com/ai/da/service/SysFileService.java index c676a4a8..13c97a98 100644 --- a/src/main/java/com/ai/da/service/SysFileService.java +++ b/src/main/java/com/ai/da/service/SysFileService.java @@ -1,7 +1,6 @@ package com.ai.da.service; import com.ai.da.mapper.entity.SysFile; -import com.ai.da.model.vo.LibraryVo; import com.ai.da.model.vo.SysFileVO; import com.baomidou.mybatisplus.extension.service.IService; @@ -50,4 +49,11 @@ public interface SysFileService extends IService { * @param urlList */ List getByUrlList(List urlList); + + /** + * 根据单条url查询 + * @param url + * @return + */ + SysFileVO getByUrl(String url, String type,String timeZone); } 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 d6c4ae56..327a1632 100644 --- a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java @@ -3,7 +3,6 @@ package com.ai.da.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.context.UserContext; -import com.ai.da.common.enums.CollectionLevel1TypeEnum; import com.ai.da.common.enums.SingleOverallEnum; import com.ai.da.common.enums.SysFileLevel2TypeEnum; import com.ai.da.common.utils.CopyUtil; @@ -11,6 +10,7 @@ import com.ai.da.common.utils.DateUtil; import com.ai.da.mapper.DesignItemMapper; import com.ai.da.mapper.entity.*; import com.ai.da.model.dto.DesignSingleDTO; +import com.ai.da.model.dto.DesignSingleIncludeLayersDTO; import com.ai.da.model.dto.DesignSingleItemDTO; import com.ai.da.model.vo.*; import com.ai.da.python.PythonService; @@ -19,21 +19,17 @@ import com.ai.da.python.vo.DesignPythonItemPrint; import com.ai.da.python.vo.DesignPythonObjects; import com.ai.da.service.*; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; -import com.mysql.cj.jdbc.result.UpdatableResultSet; import lombok.extern.slf4j.Slf4j; -import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -61,6 +57,12 @@ public class DesignItemServiceImpl extends ServiceImpl saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects + , Long designId,Long designItemId, Long collectionId, AuthPrincipalVo userInfo + , JSONObject responseJSONObject, String timeZone){ + + DesignItem designItem = new DesignItem(); + String url = pythonObjects.getObjects().get(0).getBasic().getSave_name(); + designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone)); + designItem.setDesignUrl(url); + designItem.setId(designItemId); + + //更新item + updateById(designItem); + //删除itemDetail + designItemDetailService.deleteByDesignItemId(designItemId); + + List designItemDetails = Lists.newArrayList(); + // 保存designItem + pythonObjects.getObjects().get(0).getItems().forEach(detail ->{ + if(null == detail){ + return; + } + DesignItemDetail designItemDetail = CopyUtil.copyObject(detail,DesignItemDetail.class); + designItemDetail.setAccountId(userInfo.getId()); + designItemDetail.setDesignId(designId); + designItemDetail.setDesignItemId(designItemId); + designItemDetail.setCollectionElementId(detail.getElementId()); + designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); + if(SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())){ + designItemDetail.setPath(detail.getBody_path()); + //BODY不关联businessId + designItemDetail.setBusinessId(0L); + } + designItemDetail.setIconPath(detail.getIcon()); + DesignPythonItemPrint printObject = detail.getPrint(); + designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath()); + designItemDetail.setPrintJson(JSON.toJSONString(printObject)); + designItemDetails.add(designItemDetail); + }); + designItemDetailService.saveBatch(designItemDetails); + + // 更新 + JSONObject data = responseJSONObject.getJSONObject("data"); + JSONObject outfit = data.getJSONObject("0"); + 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); + JSONArray layers = outfit.getJSONArray("layers"); + List list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId()); + + designPythonOutfitDetailService.saveBatch(list); + + return list; + } + + public List setTDesignPythonOutfitDetailList(JSONArray layers, Long designId, Long designPythonOutfitId, Long userId){ + + // 保存图层信息; + List list = new ArrayList<>(); + for (int i = 0; i < layers.size(); i++) { + JSONObject jsonObject = layers.getJSONObject(i); + TDesignPythonOutfitDetail designPythonOutfitDetail = new TDesignPythonOutfitDetail(); + designPythonOutfitDetail.setDesignId(designId); + designPythonOutfitDetail.setDesignPythonOutfitId(designPythonOutfitId); + designPythonOutfitDetail.setPosition(jsonObject.getString("position")); + designPythonOutfitDetail.setImageUrl(jsonObject.getString("image_url")); + designPythonOutfitDetail.setImageSize(jsonObject.getString("image_size")); + designPythonOutfitDetail.setImageCategory(jsonObject.getString("image_category")); + designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url")); + designPythonOutfitDetail.setUserId(userId); + list.add(designPythonOutfitDetail); + } + return list; + } + private DesignItem selectById(Long id) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("id", id); @@ -281,4 +361,129 @@ public class DesignItemServiceImpl extends ServiceImpl 不存数据库 submit -> 存数据库 + List tDesignPythonOutfitDetails; + if (!designSingleIncludeLayersDTO.getIsPreview()){ + // todo 这里要再想想 + tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(), + design.getCollectionId(), userInfo, jsonObject, 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()); + } + + List detailsVO = new ArrayList<>(); + + tDesignPythonOutfitDetails.forEach(detail -> { + detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail)); + }); + + TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId()); + // todo designPythonOutFit 空指针 + return assembleDesignSingleResponse(designItem.getId(),designPythonOutfit.getDesignUrl(), + designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),detailsVO); + } + + private DesignSingleVO assembleDesignSingleResponse(Long designItemId,String designItemUrl, + List designSingleItemDTOList, + List layersObject){ + + DesignSingleVO designSingleVO = new DesignSingleVO(); + ArrayList clothes = new ArrayList<>(); + designSingleVO.setDesignItemId(designItemId); + designSingleVO.setDesignItemUrl(designItemUrl); + designSingleVO.setClothes(clothes); + + designSingleItemDTOList.forEach(singleItem -> { + DesignItemClothesDetailVO designItemClothesDetailVO = new DesignItemClothesDetailVO(); + designItemClothesDetailVO.setType(singleItem.getType()); + designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor())); + designItemClothesDetailVO.setPrintObject(new DesignPythonItemPrint(singleItem.getPrintObject().getPath())); + designItemClothesDetailVO.setLayersObject(layersObject.stream().filter( + layers -> singleItem.getType().toLowerCase().equals(layers.getImageCategory().split("_")[0])).collect(Collectors.toList())); + clothes.add(designItemClothesDetailVO); + }); + + 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" + + "}"); + } + + } diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index b606f01c..c0c6af60 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -350,7 +350,7 @@ public class DesignServiceImpl extends ServiceImpl impleme } designItemDetail.setIconPath(detail.getIcon()); DesignPythonItemPrint printObject = detail.getPrint(); - designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath()); + designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath()); designItemDetails.add(designItemDetail); }); designItemDetailService.saveBatch(designItemDetails); @@ -423,7 +423,7 @@ public class DesignServiceImpl extends ServiceImpl impleme } designItemDetail.setIconPath(detail.getIcon()); DesignPythonItemPrint printObject = detail.getPrint(); - designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getPath()); + designItemDetail.setPrintPath(Objects.isNull(printObject)? "" :printObject.getSinglePath()); designItemDetails.add(designItemDetail); }); designItemDetailService.saveBatch(designItemDetails); @@ -682,7 +682,8 @@ public class DesignServiceImpl extends ServiceImpl impleme })); //single 和 Models(模特)时候 系统元素为空 List filterDetail2 =designItemDetails.stream() - .filter(f -> SYS_HAIRSTYLE_SHOES.contains(f.getType()) ) +// .filter(f -> SYS_HAIRSTYLE_SHOES.contains(f.getType()) ) + .filter(f -> SYS_HAIRSTYLE_SHOES_BODY.contains(f.getType()) ) .collect(Collectors.toList()); response.setOthers(CopyUtil.copyList(filterDetail2,DesignItemOthersDetailVO.class,(o,d)->{ d.setId(o.getBusinessId()); @@ -728,12 +729,6 @@ public class DesignServiceImpl extends ServiceImpl impleme return design.getId(); } - /** - * - * @param designItemDetails - * @param designItemDetailVO - * @return - */ private DesignItemDetailVO editResponseColor(List designItemDetails,DesignItemDetailVO designItemDetailVO){ /*designItemDetails.forEach(d -> { if (!StringUtil.isNullOrEmpty(d.getColor())){ @@ -778,25 +773,40 @@ public class DesignServiceImpl extends ServiceImpl impleme } - private DesignItemDetailVO editDesignItemLayer(Boolean flag,TDesignPythonOutfit designPythonOutfit,String designItemId,DesignItemDetailVO designItemDetailVO){ - DesignPythonOutfitVO designPythonOutfitVO = new DesignPythonOutfitVO(); + private DesignItemDetailVO editDesignItemLayer(Boolean flag,TDesignPythonOutfit designPythonOutfit,String designItemUrl,DesignItemDetailVO designItemDetailVO){ + ArrayList detailsVO = new ArrayList<>(); if (flag){ // 1、判断designPythonOutfitId查出的图层信息是否为空(不允许为空,系统内部错误) List details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId()); Assert.notEmpty(details,"Some errors occurred, please restart the design"); + details.forEach(detail -> { + detailsVO.add(designPythonOutfitDetailService.convertToDesignPythonOutfitVO(detail)); + }); // 2、将查询出的图层信息填充到designItemDetailVO中 - designPythonOutfitVO.setDesignPythonOutfitId(designPythonOutfit.getId()); - designPythonOutfitVO.setDesignPythonOutfitUrl(designPythonOutfit.getDesignUrl()); - designPythonOutfitVO.setDesignItemDetailLayers(details); - }else{ - designPythonOutfitVO.setDesignPythonOutfitUrl(designItemId); - } + designItemDetailVO.setDesignItemUrl(designPythonOutfit.getDesignUrl()); + // 2.1 填充clothes + designItemDetailVO.getClothes().forEach(c -> { + String type = c.getType().toLowerCase(); + List outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") || + detail.getImageCategory().equals(type + "_front")).collect(Collectors.toList()); - designItemDetailVO.setDesignItemUrl(designPythonOutfitVO); + c.setLayersObject(outfitVOS); + }); + // 2.2 填充others + designItemDetailVO.getOthers().forEach(o -> { + String type = o.getType().toLowerCase(); + List outfitVOS = detailsVO.stream().filter(detail -> detail.getImageCategory().equals(type + "_back") || + detail.getImageCategory().equals(type + "_front") || + detail.getImageCategory().equals("body")).collect(Collectors.toList()); + + o.setLayersObject(outfitVOS); + }); + }else{ + designItemDetailVO.setDesignItemUrl(designItemUrl); + } return designItemDetailVO; } - } diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 59372af1..8dd79cf9 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -3,7 +3,7 @@ package com.ai.da.service.impl; import cn.hutool.core.lang.Assert; import com.ai.da.common.context.UserContext; import com.ai.da.common.enums.CollectionLevel1TypeEnum; -import com.ai.da.common.enums.GenerateTypeEnum; +import com.ai.da.common.enums.GenerateModeEnum; import com.ai.da.common.enums.ModelNameEnum; import com.ai.da.common.utils.DateUtil; import com.ai.da.common.utils.MD5Utils; @@ -83,10 +83,12 @@ public class GenerateServiceImpl extends ServiceImpl im save(generate); // 4、向模型发起请求 - int mode = GenerateTypeEnum.TEXT.getValue().equals(generate.getGenerateType()) ? GenerateTypeEnum.TEXT.getCode() : GenerateTypeEnum.TEXT_IMAGE.getCode(); -// String generatedSketchUrl = pythonService.generateSketchOrPrint(collectionElement.getUrl(),text,mode,generateThroughImageTextDTO.getVersion()); + int mode = GenerateModeEnum.TEXT.getValue().equals(generate.getGenerateType()) ? GenerateModeEnum.TEXT.getCode() : GenerateModeEnum.TEXT_IMAGE.getCode(); + String category = generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()) ? "sketch" : + generateThroughImageTextDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()) ? "print" : "moodboard"; + List generatedSketchUrl = pythonService.generateSketchOrPrint(accountId,collectionElement.getUrl(),category,text,mode,generateThroughImageTextDTO.getVersion()); - List generatedSketchUrl = Arrays.asList("testUrl1","testUrl2","testUrl3","testUrl4"); +// List generatedSketchUrl = Arrays.asList("testUrl1","testUrl2","testUrl3","testUrl4"); // 5、处理模型返回的数据 // 5.1 将相应的url保存到数据库 diff --git a/src/main/java/com/ai/da/service/impl/SysFileServiceImpl.java b/src/main/java/com/ai/da/service/impl/SysFileServiceImpl.java index c9f3dc3b..edd14df0 100644 --- a/src/main/java/com/ai/da/service/impl/SysFileServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/SysFileServiceImpl.java @@ -5,18 +5,9 @@ import com.ai.da.common.config.FileProperties; import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.enums.SysFileLevel1TypeEnum; import com.ai.da.common.enums.SysFileLevel2TypeEnum; -import com.ai.da.common.response.PageBaseResponse; -import com.ai.da.common.response.Response; -import com.ai.da.common.utils.CopyUtil; -import com.ai.da.common.utils.FileUtil; -import com.ai.da.common.utils.LocalCacheUtils; -import com.ai.da.common.utils.MD5Utils; +import com.ai.da.common.utils.*; import com.ai.da.mapper.SysFileMapper; -import com.ai.da.mapper.entity.Collection; -import com.ai.da.mapper.entity.Library; import com.ai.da.mapper.entity.SysFile; -import com.ai.da.mapper.entity.UserLikeGroup; -import com.ai.da.model.vo.LibraryVo; import com.ai.da.model.vo.SysFileVO; import com.ai.da.service.SysFileService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -26,7 +17,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; -import org.bouncycastle.est.CACertsResponse; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -36,6 +26,7 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -259,4 +250,26 @@ public class SysFileServiceImpl extends ServiceImpl impl queryWrapper.in("url", urlList); return CopyUtil.copyList(sysFileMapper.selectList(queryWrapper),SysFileVO.class); } + + @Override + public SysFileVO getByUrl(String url, String type,String timeZone){ + QueryWrapper 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)); + } } diff --git a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java index c4b48285..40f14898 100644 --- a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitDetailServiceImpl.java @@ -1,15 +1,19 @@ package com.ai.da.service.impl; +import com.ai.da.common.utils.CopyUtil; import com.ai.da.mapper.TDesignPythonOutfitDetailMapper; import com.ai.da.mapper.entity.TDesignPythonOutfitDetail; +import com.ai.da.model.vo.DesignPythonOutfitVO; import com.ai.da.model.vo.TDesignPythonOutfitDetailVO; 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 org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import java.util.List; +import java.util.Objects; /** * design item详情表 服务实现类 @@ -31,7 +35,18 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl) JSON.parse(detail.getPosition())); + designPythonOutfitVO.setImageSize((List) JSON.parse(detail.getImageSize())); + return designPythonOutfitVO; } } diff --git a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitServiceImpl.java b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitServiceImpl.java index 174e56ae..5e91acf2 100644 --- a/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/TDesignPythonOutfitServiceImpl.java @@ -4,6 +4,7 @@ import com.ai.da.mapper.TDesignPythonOutfitMapper; import com.ai.da.mapper.entity.TDesignPythonOutfit; import com.ai.da.model.vo.TDesignPythonOutfitVO; import com.ai.da.service.ITDesignPythonOutfitService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -22,4 +23,12 @@ public class TDesignPythonOutfitServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("design_item_id",designItemId); + + return getOne(queryWrapper); + } + } diff --git a/src/main/resources/mapper/TDesignPythonOutfitDetailMapper.xml b/src/main/resources/mapper/TDesignPythonOutfitDetailMapper.xml index 79ac4aa1..aaa38b35 100644 --- a/src/main/resources/mapper/TDesignPythonOutfitDetailMapper.xml +++ b/src/main/resources/mapper/TDesignPythonOutfitDetailMapper.xml @@ -9,6 +9,7 @@ +