From b86f3c9f7eb42d247db80d07ed89b15e1742be45 Mon Sep 17 00:00:00 2001 From: litianxiang Date: Thu, 20 Nov 2025 10:48:36 +0800 Subject: [PATCH] =?UTF-8?q?1.fix=EF=BC=9A=E9=AB=98=E7=BA=A7=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=BD=AC=E4=BA=A7=E5=93=81=E5=9B=BE=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E4=B9=9F=E6=B2=A1=E6=9C=89ageGroup=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8A=A5=E9=94=99=202.=E4=B8=8A=E4=BC=A0sket?= =?UTF-8?q?ch=E6=A8=A1=E6=9D=BF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/WorkspaceController.java | 4 +- .../secondary/AttributeRetrievalMapper.java | 2 + .../impl/UserLikeGroupServiceImpl.java | 6 +- .../da/service/impl/WorkspaceServiceImpl.java | 140 +++++++++++++++++- .../secondary/AttributeRetrievalMapper.xml | 4 + 5 files changed, 149 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ai/da/controller/WorkspaceController.java b/src/main/java/com/ai/da/controller/WorkspaceController.java index cf3f6ae4..ea2a8df1 100644 --- a/src/main/java/com/ai/da/controller/WorkspaceController.java +++ b/src/main/java/com/ai/da/controller/WorkspaceController.java @@ -118,11 +118,11 @@ public class WorkspaceController { return Response.success(true); } - @PostMapping("maleDataInsert") + @GetMapping("/maleDataInsert") @ApiOperationSupport(order = 8) @ApiOperation(value = "男装数据入库入minio") public Response maleDataInsert() throws FileNotFoundException { - workspaceService.maleDataInsert(); +// workspaceService.maleDataInsert(); return Response.success(true); } diff --git a/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java b/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java index d7881a10..05e160d8 100644 --- a/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java +++ b/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java @@ -34,4 +34,6 @@ public interface AttributeRetrievalMapper { Integer getCountByStyle(String tableName, String style); String getOneSystemSketchRadom(String tableName, String style, Integer randomNum); + + void insertSketch(AttributeRetrieval attributeRetrievalAttrDict, String tableName); } 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 9506e816..7bba89b7 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -3360,7 +3360,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl pngFiles = getPNGFiles(directoryPath); + for (File pngFile : pngFiles) { + String category = Paths.get(directoryPath).getFileName().toString(); + String fileName = category + "_2_" + pngFile.getName(); + String tableName = null; + SysFile sysFile = new SysFile(); + sysFile.setName(fileName); + sysFile.setLevel1Type("Images"); + + AttributeRetrieval attributeRetrievalAttrDict = new AttributeRetrieval(); + + attributeRetrievalAttrDict.setStyle("POST_APOCALYPTIC"); + String absolutePath = pngFile.getAbsolutePath(); + StringBuilder sb = new StringBuilder(); + sb.append("aida-sys-image/images"); + if (absolutePath.contains("Coat_Jacket") || absolutePath.contains("coat_jacket")) { + if (absolutePath.contains("\\male")) { + tableName = "male_outwear"; + sb.append("/male/outwear/"); + sysFile.setLevel3Type("Male"); + } else if (absolutePath.contains("\\female")) { + tableName = "female_outwear"; + sb.append("/female/outwear/"); + sysFile.setLevel3Type("Female"); + } else if (absolutePath.contains("\\unisex")) { + tableName = "female_outwear"; + sb.append("/female/outwear/"); + sysFile.setLevel3Type("Female"); + } + sysFile.setLevel2Type("Outwear"); + attributeRetrievalAttrDict.setImgName("outwear/" + fileName); + } + if (absolutePath.contains("Pants") || absolutePath.contains("pants")) { + if (absolutePath.contains("\\male")) { + tableName = "male_bottoms"; + sb.append("/male/bottoms/"); + sysFile.setLevel3Type("Male"); + } else if (absolutePath.contains("\\female")) { + tableName = "female_trousers"; + sb.append("/female/trousers/"); + sysFile.setLevel3Type("Female"); + } else if (absolutePath.contains("\\unisex")) { + tableName = "female_trousers"; + sb.append("/female/trousers/"); + sysFile.setLevel3Type("Female"); + } + sysFile.setLevel2Type("Trousers"); + attributeRetrievalAttrDict.setImgName("trousers/" + fileName); + } + if (absolutePath.contains("Top_Shirt") || absolutePath.contains("top_shirt")) { + if (absolutePath.contains("\\male")) { + tableName = "male_tops"; + sb.append("/male/tops/"); + sysFile.setLevel3Type("Male"); + } else if (absolutePath.contains("\\female")) { + tableName = "female_blouse"; + sb.append("/female/blouse/"); + sysFile.setLevel3Type("Female"); + } else if (absolutePath.contains("\\unisex")) { + tableName = "female_blouse"; + sb.append("/female/blouse/"); + sysFile.setLevel3Type("Female"); + } + sysFile.setLevel2Type("Blouse"); + attributeRetrievalAttrDict.setImgName("blouse/" + fileName); + } + if (absolutePath.contains("Dress") || absolutePath.contains("dress")) { + tableName = "female_dress"; + sb.append("/female/dress/"); + sysFile.setLevel2Type("Dress"); + sysFile.setLevel3Type("Female"); + attributeRetrievalAttrDict.setImgName("dress/" + fileName); + } + if (absolutePath.contains("skirt") || absolutePath.contains("Skirt")) { + tableName = "female_skirt"; + sb.append("/female/skirt/"); + sysFile.setLevel2Type("Skirt"); + sysFile.setLevel3Type("Female"); + attributeRetrievalAttrDict.setImgName("skirt/" + fileName); + } + sb.append(fileName); + String url = sb.toString(); + sysFile.setUrl(url); + sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile))); + attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName); + sysFile.setCreateDate(new Date()); + sysFile.setId(null); + sysFileMapper.insert(sysFile); + FileItem a = getMultipartFile(pngFile, fileName); + MultipartFile multipartFile = new CommonsMultipartFile(a); + minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, ""); + System.out.println("上传成功url:" + url); + if (absolutePath.contains("unisex")) { + if (tableName.equals("female_outwear")) { + tableName = "male_outwear"; + url = url.replace("/female/outwear/", "/male/outwear/"); + } else if (tableName.equals("female_blouse")) { + tableName = "male_tops"; + attributeRetrievalAttrDict.setImgName("tops/" + fileName); + sysFile.setLevel2Type("Tops"); + url = url.replace("/female/blouse/", "/male/tops/"); + } else if (tableName.equals("female_trousers")) { + tableName = "male_bottoms"; + attributeRetrievalAttrDict.setImgName("bottoms/" + fileName); + sysFile.setLevel2Type("Bottoms"); + url = url.replace("/female/trousers/", "/male/bottoms/"); + } + minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, ""); + sysFile.setLevel3Type("Male"); + sysFile.setId(null); + sysFile.setUrl(url); + sysFileMapper.insert(sysFile); + attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName); + System.out.println("上传成功url:" + url); + } + + } + System.out.println("结束"); + } + + //上传衣服 + + public void maleDataInsert1() throws FileNotFoundException { + String directoryPath = "C:\\Users\\39093\\Desktop\\generated_sketch_gemini_updated_regendered"; List pngFiles = getPNGFiles(directoryPath); for (File pngFile : pngFiles) { SysFile sysFile = new SysFile(); @@ -732,7 +864,7 @@ public class WorkspaceServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper().eq(CollectionElement::getProjectId, projectId) .eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName()) .eq(CollectionElement::getLevel3Type, workspaceNew.getSex()); - if (collectionElementMapper.selectCount(queryWrapper) == 0){ + if (collectionElementMapper.selectCount(queryWrapper) == 0) { CollectionElement collectionElement = new CollectionElement(); collectionElement.setAccountId(userInfo.getId()); collectionElement.setProjectId(projectId); @@ -793,7 +925,7 @@ public class WorkspaceServiceImpl extends ServiceImpl + + INSERT INTO ${tableName} (img_name, style) + VALUES (#{attributeRetrievalAttrDict.imgName}, #{attributeRetrievalAttrDict.style}) +