TASK:male sketch style逻辑添加;

This commit is contained in:
shahaibo
2024-10-04 10:40:32 +08:00
parent 6f98f111dd
commit fd12b9e571
5 changed files with 123 additions and 61 deletions

View File

@@ -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 "";
}

View File

@@ -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<String> 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;

View File

@@ -17,11 +17,11 @@ import java.util.List;
public interface AttributeRetrievalMapper {
List<AttributeRetrieval> getSystemSketchPool(@Param("attributeRetrievalAttrDict") AttributeRetrieval attributeRetrievalAttrDict, @Param("tableName") String tableName, @Param("poolNum") int poolNum, @Param("style") String style, @Param("isFemaleTable") boolean isFemaleTable);
List<AttributeRetrieval> 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<AttributeRetrieval> getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName, String style, boolean isFemaleTable);
List<AttributeRetrieval> getSystemSketchPoolBySameCategory(AttributeRetrieval attributeRetrievalAttrDict, String tableName, String style);
Long getIdByFileName(String fileName, String tableName);

View File

@@ -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<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPool(attributeRetrievalAttrDict, tableName, poolNum, style, isFemaleTable);
List<AttributeRetrieval> 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<String> nonNullFields = new ArrayList<>();
if (attributeRetrievalAttrDict.getType() != null) {
@@ -725,7 +718,7 @@ public class PythonService {
}
}
List<AttributeRetrieval> attributeRetrievalList = attributeRetrievalMapper.getSystemSketchPoolBySameCategory(attributeRetrievalAttrDict, tableName, style, isFemaleTable);
List<AttributeRetrieval> 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);
}