diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index 98cd0f4f..bdaeaa12 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -6,6 +6,7 @@ import com.ai.da.common.utils.SendEmailUtil; import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.secondary.AttributeRetrievalMapper; +import com.ai.da.model.enums.StyleEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -220,29 +221,47 @@ public class MyTaskScheduler { private AttributeRetrievalMapper attributeRetrievalMapper; public void addSystemFileStyle() { - ExecutorService executorService = Executors.newFixedThreadPool(5); +// ExecutorService executorService = Executors.newFixedThreadPool(5); - try { - String[] filePaths = { - "C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Blouse style output updated25.6.2024.xlsx", - "C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Dress style output updated25.6.2024.xlsx", - "C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Outerwear style output.xlsx", - "C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Skirt style output .xlsx", - "C:\\Users\\10233\\Documents\\WeChat Files\\wxid_h7l9im0r8ql922\\FileStorage\\File\\2024-06\\style\\Trousers style output.xlsx" - }; +// try { +// String[] filePaths = { +// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx", +// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx", +// "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx" +//// "/workspace/shb/Mens_bottom_style_output.xlsx", +//// "/workspace/shb/Mens_outer_style_output.xlsx", +//// "/workspace/shb/Mens_top_style_output.xlsx" +// }; +// +// for (String filePath : filePaths) { +//// executorService.submit(() -> processExcelFile(filePath)); +// processExcelFile(filePath); +// } +// }catch (Exception e) { +// +// } +// } finally { +// executorService.shutdown(); +// try { +// if (!executorService.awaitTermination(60, TimeUnit.MINUTES)) { +// executorService.shutdownNow(); +// } +// } catch (InterruptedException e) { +// executorService.shutdownNow(); +// } +// } + String[] filePaths = { + "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens bottom style output.xlsx", + "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens outer style output.xlsx", + "C:\\Users\\10233\\Downloads\\OneDrive_1_2024-10-3\\Mens top style output.xlsx" +// "/workspace/shb/Mens_bottom_style_output.xlsx", +// "/workspace/shb/Mens_outer_style_output.xlsx", +// "/workspace/shb/Mens_top_style_output.xlsx" + }; - for (String filePath : filePaths) { - executorService.submit(() -> processExcelFile(filePath)); - } - } finally { - executorService.shutdown(); - try { - if (!executorService.awaitTermination(60, TimeUnit.MINUTES)) { - executorService.shutdownNow(); - } - } catch (InterruptedException e) { - executorService.shutdownNow(); - } + for (String filePath : filePaths) { +// executorService.submit(() -> processExcelFile(filePath)); + processExcelFile(filePath); } } @@ -264,6 +283,37 @@ public class MyTaskScheduler { attributeRetrievalMapper.updateStyleByFileName("X", prefix + fileName, tableName); System.out.println(fileName); } else { +// if (style.equals("Y2K 风")) { +// StyleEnum.COUNTRY_STYLE +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// }else if (style.equals("")) { +// +// } attributeRetrievalMapper.updateStyleByFileName(style, prefix + fileName, tableName); System.out.println(fileName); } @@ -285,6 +335,12 @@ public class MyTaskScheduler { return "female_skirt"; } else if (filePath.contains("Trousers")) { return "female_pants"; + } else if (filePath.contains("bottom")) { + return "male_bottom"; + } else if (filePath.contains("outer")) { + return "male_outwear"; + } else if (filePath.contains("top")) { + return "male_top"; } return ""; } @@ -300,6 +356,12 @@ public class MyTaskScheduler { return "skirt/"; } else if (filePath.contains("Trousers")) { return "trousers/"; + } else if (filePath.contains("bottom")) { + return "bottom/"; + } else if (filePath.contains("outer")) { + return "outer/"; + } else if (filePath.contains("top")) { + return "top/"; } return ""; } diff --git a/src/main/java/com/ai/da/common/utils/ExcelReader.java b/src/main/java/com/ai/da/common/utils/ExcelReader.java index d053b1e9..34d6a4dd 100644 --- a/src/main/java/com/ai/da/common/utils/ExcelReader.java +++ b/src/main/java/com/ai/da/common/utils/ExcelReader.java @@ -1,6 +1,7 @@ package com.ai.da.common.utils; import lombok.Data; +import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -23,9 +24,28 @@ public class ExcelReader { for (int i = 0; i < numberOfColumns; i++) { List columnData = new ArrayList<>(); for (Row row : sheet) { - columnData.add(row.getCell(i).getStringCellValue()); + Cell cell = row.getCell(i); + if (cell != null) { + switch (cell.getCellType()) { + case STRING: + columnData.add(cell.getStringCellValue()); + break; + case NUMERIC: + columnData.add(String.valueOf(cell.getNumericCellValue())); + break; + case BOOLEAN: + columnData.add(String.valueOf(cell.getBooleanCellValue())); + break; + default: + // 跳过空单元格或其他类型(比如错误类型) + break; + } + } + } + // 只有当这一列有数据时,才添加到结果列表中 + if (!columnData.isEmpty()) { + data.add(columnData); } - data.add(columnData); } } return data; 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 772d63df..1c3be31b 100644 --- a/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java +++ b/src/main/java/com/ai/da/mapper/secondary/AttributeRetrievalMapper.java @@ -17,11 +17,11 @@ import java.util.List; public interface AttributeRetrievalMapper { - List getSystemSketchPool(@Param("attributeRetrievalAttrDict") AttributeRetrieval attributeRetrievalAttrDict, @Param("tableName") String tableName, @Param("poolNum") int poolNum, @Param("style") String style, @Param("isFemaleTable") boolean isFemaleTable); + List getSystemSketchPool(@Param("attributeRetrievalAttrDict") AttributeRetrieval attributeRetrievalAttrDict, @Param("tableName") String tableName, @Param("poolNum") int poolNum, @Param("style") String style); - AttributeRetrieval getSystemRandom(String tableName, String style, boolean isFemaleTable); + AttributeRetrieval getSystemRandom(String tableName, String style); - List getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName, String style, boolean isFemaleTable); + List getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName, String style); Long getIdByFileName(String fileName, String tableName); diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 67e2227b..cbdf99ff 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -646,22 +646,18 @@ public class PythonService { AttributeRetrieval attributeRetrievalAttrDict = toAttrDict(attrDictJSON); String tableName; tableName = getTableName(modelSex, styleCategory); - boolean isFemaleTable = false; - if (tableName.contains("female")) { - isFemaleTable = true; - } - List attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style, isFemaleTable); + List attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style); if (CollectionUtil.isEmpty(attributeRetrievalList) || attributeRetrievalList.size() < poolNum) { attributeRetrievalAttrDict.setDesign(null); - attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style, isFemaleTable); + attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style); } if (CollectionUtil.isEmpty(attributeRetrievalList) || attributeRetrievalList.size() < poolNum) { attributeRetrievalAttrDict.setSilhouette(null); - attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style, isFemaleTable); + attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style); } if (CollectionUtil.isEmpty(attributeRetrievalList) || attributeRetrievalList.size() < poolNum) { style = null; - attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style, isFemaleTable); + attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style); } return toColoectionElementList(attributeRetrievalList, styleCategory, modelSex); } @@ -680,10 +676,7 @@ public class PythonService { AttributeRetrieval attributeRetrievalAttrDict = toAttrDict(attrDictJSON); String tableName; tableName = getTableName(modelSex, styleCategory); - boolean isFemaleTable = false; - if (tableName.contains("female")) { - isFemaleTable = true; - } + // 存储非空字段的列表 List nonNullFields = new ArrayList<>(); if (attributeRetrievalAttrDict.getType() != null) { @@ -725,7 +718,7 @@ public class PythonService { } } - List attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style, isFemaleTable); + List attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style); if (CollectionUtil.isEmpty(attributeRetrievalList)) { System.out.println(attributeRetrievalAttrDict); System.out.println(tableName); @@ -733,12 +726,12 @@ public class PythonService { attributeRetrievalAttrDict.setType(null); attributeRetrievalAttrDict.setOpeningType(null); attributeRetrievalAttrDict.setSubtype(null); - attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style, isFemaleTable); + attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style); } if (CollectionUtil.isEmpty(attributeRetrievalList)) { style = null; - attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style, isFemaleTable); + attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style); } } @@ -960,11 +953,7 @@ public class PythonService { Integer randomNum = RandomsUtil.randomSysFile(dressings.size()); String category = dressings.get(randomNum).getStyleCategory(); String tableName = getTableName(validateElementVO.getModelSex(), category); - boolean isFemaleTable = false; - if (tableName.contains("female")) { - isFemaleTable = true; - } - AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle(), isFemaleTable); + AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle()); CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex()); return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO); } @@ -1004,11 +993,8 @@ public class PythonService { Integer randomNum = RandomsUtil.randomSysFile(dressings.size()); String category = dressings.get(randomNum).getStyleCategory(); String tableName = getTableName(validateElementVO.getModelSex(), category); - boolean isFemaleTable = false; - if (tableName.contains("female")) { - isFemaleTable = true; - } - AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle(), isFemaleTable); + + AttributeRetrieval attributeRetrieval = attributeRetrievalMapper.getSystemRandom(tableName, validateElementVO.getStyle()); CollectionElement collectionElement = toCollectionElement(attributeRetrieval, category, validateElementVO.getModelSex()); return coverSketchToDesignPythonItem(null, collectionElement, validateElementVO); } diff --git a/src/main/resources/mapper/secondary/AttributeRetrievalMapper.xml b/src/main/resources/mapper/secondary/AttributeRetrievalMapper.xml index ed6bc6a6..85891d07 100644 --- a/src/main/resources/mapper/secondary/AttributeRetrievalMapper.xml +++ b/src/main/resources/mapper/secondary/AttributeRetrievalMapper.xml @@ -32,9 +32,7 @@ AND style = #{style} - - AND deprecated = 0 - + AND deprecated = 0 ORDER BY RAND() @@ -50,9 +48,7 @@ AND style = #{style} - - AND deprecated = 0 - + AND deprecated = 0 ORDER BY RAND() @@ -77,9 +73,7 @@ AND style = #{style} - - AND deprecated = 0 - + AND deprecated = 0 ORDER BY RAND() @@ -106,6 +100,6 @@ SET style = #{style} WHERE - image_name = #{fileName} + img_name = #{fileName}