Merge branch 'dev/dev' into dev/dev_xp
# Conflicts: # src/main/java/com/ai/da/service/impl/DesignServiceImpl.java # src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java
This commit is contained in:
@@ -26,9 +26,9 @@ public class MQConfig {
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||
|
||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-local";
|
||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-dev";
|
||||
|
||||
public static final String RELIGHT_RESULT_QUEUE = "Relight-local";
|
||||
public static final String RELIGHT_RESULT_QUEUE = "Relight-dev";
|
||||
public MQConfig() {
|
||||
}
|
||||
|
||||
|
||||
@@ -218,17 +218,17 @@ public class SRConsumer {
|
||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
||||
}
|
||||
|
||||
// @RabbitListener(queues = MQConfig.SR_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void SRConsumer1(Message msg, Channel channel) {
|
||||
// superResolution(msg, channel, "consumer 1");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void SRResultConsumer1(Message msg, Channel channel) {
|
||||
// getSRResult(msg, channel, "consumer 1");
|
||||
// }
|
||||
@RabbitListener(queues = MQConfig.SR_QUEUE)
|
||||
@RabbitHandler
|
||||
public void SRConsumer1(Message msg, Channel channel) {
|
||||
superResolution(msg, channel, "consumer 1");
|
||||
}
|
||||
|
||||
|
||||
@RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
|
||||
@RabbitHandler
|
||||
public void SRResultConsumer1(Message msg, Channel channel) {
|
||||
getSRResult(msg, channel, "consumer 1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.ai.da.common.utils.ExcelReader;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.primary.*;
|
||||
@@ -26,6 +27,9 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@@ -34,6 +38,7 @@ public class MyTaskScheduler {
|
||||
@PostConstruct
|
||||
public void test() {
|
||||
// clearMinio();
|
||||
// addSystemFileStyle();
|
||||
}
|
||||
|
||||
@Resource
|
||||
@@ -214,30 +219,104 @@ public class MyTaskScheduler {
|
||||
private AttributeRetrievalMapper attributeRetrievalMapper;
|
||||
|
||||
public void addSystemFileStyle() {
|
||||
String directoryPath = "C:\\Users\\10233\\Downloads\\blouse done\\blouse done\\废土风";
|
||||
List<String> fileNames = getFileNames(directoryPath);
|
||||
for (String fileName : fileNames) {
|
||||
String tableName = "female_top";
|
||||
String style = "feitufeng";
|
||||
Long idByFileName = attributeRetrievalMapper.getIdByFileName(fileName, tableName);
|
||||
attributeRetrievalMapper.updateStyleById(idByFileName, style, tableName);
|
||||
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"
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getFileNames(String directoryPath) {
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
Path path = Paths.get(directoryPath);
|
||||
private void processExcelFile(String filePath) {
|
||||
System.out.println("线程开始");
|
||||
try {
|
||||
List<List<String>> excelData = ExcelReader.readExcel(filePath);
|
||||
String tableName = getTableNameFromFilePath(filePath);
|
||||
String prefix = getPrefixFromFilePath(filePath);
|
||||
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
|
||||
for (Path entry : stream) {
|
||||
if (Files.isRegularFile(entry)) {
|
||||
fileNames.add(entry.getFileName().toString());
|
||||
for (List<String> columnData : excelData) {
|
||||
String style = columnData.get(0);
|
||||
for (int i = 1; i < columnData.size(); i++) {
|
||||
String fileName = columnData.get(i);
|
||||
if (StringUtils.isBlank(fileName)) {
|
||||
continue;
|
||||
}
|
||||
if ("X".equals(style)) {
|
||||
attributeRetrievalMapper.updateStyleByFileName("X", prefix + fileName, tableName);
|
||||
System.out.println(fileName);
|
||||
} else {
|
||||
attributeRetrievalMapper.updateStyleByFileName(style, prefix + fileName, tableName);
|
||||
System.out.println(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error reading directory: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
private String getTableNameFromFilePath(String filePath) {
|
||||
if (filePath.contains("Blouse")) {
|
||||
return "female_top";
|
||||
} else if (filePath.contains("Dress")) {
|
||||
return "female_dress";
|
||||
} else if (filePath.contains("Outerwear")) {
|
||||
return "female_outwear";
|
||||
} else if (filePath.contains("Skirt")) {
|
||||
return "female_skirt";
|
||||
} else if (filePath.contains("Trousers")) {
|
||||
return "female_pants";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getPrefixFromFilePath(String filePath) {
|
||||
if (filePath.contains("Blouse")) {
|
||||
return "blouse/";
|
||||
} else if (filePath.contains("Dress")) {
|
||||
return "dress/";
|
||||
} else if (filePath.contains("Outerwear")) {
|
||||
return "outwear/";
|
||||
} else if (filePath.contains("Skirt")) {
|
||||
return "skirt/";
|
||||
} else if (filePath.contains("Trousers")) {
|
||||
return "trousers/";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// public static List<String> getFileNames(String directoryPath) {
|
||||
// List<String> fileNames = new ArrayList<>();
|
||||
// Path path = Paths.get(directoryPath);
|
||||
//
|
||||
// try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
|
||||
// for (Path entry : stream) {
|
||||
// if (Files.isRegularFile(entry)) {
|
||||
// fileNames.add(entry.getFileName().toString());
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// System.err.println("Error reading directory: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// return fileNames;
|
||||
// }
|
||||
}
|
||||
|
||||
33
src/main/java/com/ai/da/common/utils/ExcelReader.java
Normal file
33
src/main/java/com/ai/da/common/utils/ExcelReader.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ExcelReader {
|
||||
public static List<List<String>> readExcel(String filePath) throws IOException {
|
||||
List<List<String>> data = new ArrayList<>();
|
||||
try (FileInputStream fis = new FileInputStream(filePath);
|
||||
Workbook workbook = new XSSFWorkbook(fis)) {
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int numberOfColumns = sheet.getRow(0).getLastCellNum();
|
||||
|
||||
for (int i = 0; i < numberOfColumns; i++) {
|
||||
List<String> columnData = new ArrayList<>();
|
||||
for (Row row : sheet) {
|
||||
columnData.add(row.getCell(i).getStringCellValue());
|
||||
}
|
||||
data.add(columnData);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -405,6 +405,22 @@ public class MinioUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public String getPresignedUrl(String path, int expiry, boolean resetCache) {
|
||||
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
|
||||
if (!path.contains("/")) {
|
||||
throw new BusinessException("The path is error!");
|
||||
}
|
||||
int index = path.indexOf("/");
|
||||
String bucketName = path.substring(0, index);
|
||||
String fileName = path.substring(index + 1);
|
||||
String presignedUrl = getPresignedUrl(bucketName, fileName, expiry);
|
||||
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
|
||||
return presignedUrl;
|
||||
} else {
|
||||
return LocalCacheUtils.getPresignedUrlCache(path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将桶名、文件名从url中分离出来
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user