Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -484,6 +484,57 @@ public class MinioUtil {
|
|||||||
return null; // or throw an exception
|
return null; // or throw an exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 MinIO 下载对象到本地路径
|
||||||
|
*
|
||||||
|
* @param bucketName 存储桶名称
|
||||||
|
* @param objectName MinIO 上对象的名称
|
||||||
|
* @param localFilePath 本地文件路径
|
||||||
|
*/
|
||||||
|
public void downloadMinioObjectToLocal(String bucketName, String objectName, String localFilePath) {
|
||||||
|
File localFile = new File(localFilePath);
|
||||||
|
File parentDir = localFile.getParentFile();
|
||||||
|
if (parentDir != null) {
|
||||||
|
parentDir.mkdirs(); // 创建文件夹,确保路径结构与 MinIO 一致
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream stream = minioClient.getObject(
|
||||||
|
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||||
|
FileOutputStream out = new FileOutputStream(localFile)) {
|
||||||
|
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = stream.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
log.info("Downloaded object {} to {}", objectName, localFilePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while downloading object {}: {}", objectName, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从路径中提取存储桶名称
|
||||||
|
*
|
||||||
|
* @param path MinIO 路径
|
||||||
|
* @return 存储桶名称
|
||||||
|
*/
|
||||||
|
public String getBucketNameFromPath(String path) {
|
||||||
|
int index = path.indexOf("/");
|
||||||
|
return path.substring(0, index); // 获取第一级路径作为 bucket 名称
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从路径中提取对象名称
|
||||||
|
*
|
||||||
|
* @param path MinIO 路径
|
||||||
|
* @return 对象名称
|
||||||
|
*/
|
||||||
|
public String getObjectNameFromPath(String path) {
|
||||||
|
int index = path.indexOf("/");
|
||||||
|
return path.substring(index + 1); // 获取路径的其余部分作为对象名称
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -389,20 +389,20 @@ public class SendEmailUtil {
|
|||||||
// 根据邮件类型设置不同的主题和模板
|
// 根据邮件类型设置不同的主题和模板
|
||||||
String subject = "";
|
String subject = "";
|
||||||
Template template = new Template();
|
Template template = new Template();
|
||||||
if (type == 1) {
|
|
||||||
subject = "Upcoming System Upgrade for AiDA 3.0";
|
|
||||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
|
||||||
}else {
|
|
||||||
subject = "即将到来的AiDA 3.0系统升级";
|
|
||||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
|
||||||
}
|
|
||||||
// if (type == 1) {
|
// if (type == 1) {
|
||||||
// subject = "Successful System Upgrade and New Features in AiDA 3.1";
|
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
||||||
// template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
|
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||||
// }else {
|
// }else {
|
||||||
// subject = "系统升级成功和AiDA 3.1新功能";
|
// subject = "即将到来的AiDA 3.0系统升级";
|
||||||
// template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
|
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
||||||
// }
|
// }
|
||||||
|
if (type == 1) {
|
||||||
|
subject = "Successful System Upgrade and New Features in AiDA 3.1";
|
||||||
|
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
|
||||||
|
}else {
|
||||||
|
subject = "系统升级成功和AiDA 3.1新功能";
|
||||||
|
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
|
||||||
|
}
|
||||||
template.setTemplateData(buildAccountData(account));
|
template.setTemplateData(buildAccountData(account));
|
||||||
|
|
||||||
req.setSubject(subject);
|
req.setSubject(subject);
|
||||||
@@ -759,6 +759,47 @@ public class SendEmailUtil {
|
|||||||
req.setSubject(subject);
|
req.setSubject(subject);
|
||||||
req.setTemplate(template);
|
req.setTemplate(template);
|
||||||
|
|
||||||
|
// 发送邮件
|
||||||
|
SendEmailResponse resp = client.SendEmail(req);
|
||||||
|
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
log.info("邮件发送失败###{}", e.toString());
|
||||||
|
throw new BusinessException("failed.to.send.mail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private final static Long SYSTEM_UPGRADE_CN_ID = 131743L;
|
||||||
|
private final static Long SYSTEM_UPGRADE_EN_ID = 131744L;
|
||||||
|
public static void temporaryUpgrade(Account account, String senderAddress, int type) {
|
||||||
|
try {
|
||||||
|
// 实例化一个认证对象
|
||||||
|
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||||
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
|
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||||
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
|
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||||
|
SendEmailRequest req = new SendEmailRequest();
|
||||||
|
if (StringUtils.isEmpty(senderAddress)) {
|
||||||
|
senderAddress = CODE_CREATE_SEND_ADDRESS;
|
||||||
|
}
|
||||||
|
req.setFromEmailAddress(senderAddress);
|
||||||
|
req.setDestination(new String[]{account.getUserEmail()});
|
||||||
|
|
||||||
|
// 根据邮件类型设置不同的主题和模板
|
||||||
|
String subject = "";
|
||||||
|
Template template = new Template();
|
||||||
|
if (type == 1) {
|
||||||
|
subject = "AiDA system upgrade completed";
|
||||||
|
template.setTemplateID(SYSTEM_UPGRADE_EN_ID);
|
||||||
|
}else {
|
||||||
|
subject = "AiDA系统升级完成";
|
||||||
|
template.setTemplateID(SYSTEM_UPGRADE_CN_ID);
|
||||||
|
}
|
||||||
|
template.setTemplateData(buildAccountData(account));
|
||||||
|
|
||||||
|
req.setSubject(subject);
|
||||||
|
req.setTemplate(template);
|
||||||
|
|
||||||
// 发送邮件
|
// 发送邮件
|
||||||
SendEmailResponse resp = client.SendEmail(req);
|
SendEmailResponse resp = client.SendEmail(req);
|
||||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||||
|
|||||||
@@ -261,5 +261,12 @@ public class AccountController {
|
|||||||
return Response.success(true);
|
return Response.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("temporaryUpgrade")
|
||||||
|
@ApiOperation(value = "临时升级")
|
||||||
|
public Response<Boolean> temporaryUpgrade() {
|
||||||
|
accountService.temporaryUpgrade();
|
||||||
|
return Response.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,4 +245,10 @@ public class SavedCollectionController {
|
|||||||
public Response<String> likeHistoryRelSketch() {
|
public Response<String> likeHistoryRelSketch() {
|
||||||
return Response.success(userLikeGroupService.likeHistoryRelSketch());
|
return Response.success(userLikeGroupService.likeHistoryRelSketch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "download")
|
||||||
|
@PostMapping("/download")
|
||||||
|
public Response<String> download() {
|
||||||
|
return Response.success(userLikeGroupService.download());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,15 @@ public class GenerateToPythonDTO {
|
|||||||
|
|
||||||
private String svg;
|
private String svg;
|
||||||
|
|
||||||
public GenerateToPythonDTO(String tasks_id, String prompt, String image_url, String mode, String category, String gender) {
|
private String version;
|
||||||
|
|
||||||
|
public GenerateToPythonDTO(String tasks_id, String prompt, String image_url, String mode, String category, String gender, String version) {
|
||||||
this.image_url = image_url;
|
this.image_url = image_url;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.prompt = prompt;
|
this.prompt = prompt;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.tasks_id = tasks_id;
|
this.tasks_id = tasks_id;
|
||||||
this.gender = gender;
|
this.gender = gender;
|
||||||
|
this.version = version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,4 +186,6 @@ public interface AccountService extends IService<Account> {
|
|||||||
String googleCallback(String code, HttpSession session);
|
String googleCallback(String code, HttpSession session);
|
||||||
|
|
||||||
List<String> getPaidCustomerEmail();
|
List<String> getPaidCustomerEmail();
|
||||||
|
|
||||||
|
void temporaryUpgrade();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,6 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
|||||||
List<MagicToolResultVO> getRelightResult(List<String> taskIdList);
|
List<MagicToolResultVO> getRelightResult(List<String> taskIdList);
|
||||||
|
|
||||||
String likeHistoryRelSketch();
|
String likeHistoryRelSketch();
|
||||||
|
|
||||||
|
String download();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1961,4 +1961,30 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
// return userRepository.save(newUser);
|
// return userRepository.save(newUser);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void temporaryUpgrade() {
|
||||||
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.lambda().ne(Account::getSystemUser, 0);
|
||||||
|
queryWrapper.lambda().isNotNull(Account::getUserEmail);
|
||||||
|
// queryWrapper.lambda().eq(Account::getId, 6);
|
||||||
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
|
int i = 0;
|
||||||
|
for (Account account : accountList) {
|
||||||
|
if (i >= 0) {
|
||||||
|
try {
|
||||||
|
// 判断用户语言,调用相应邮件发送方法
|
||||||
|
if (Language.CHINESE_SIMPLIFIED.name().equals(account.getLanguage())) {
|
||||||
|
SendEmailUtil.temporaryUpgrade(account, null, 0);
|
||||||
|
} else {
|
||||||
|
SendEmailUtil.temporaryUpgrade(account, null, 1);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 捕获单个用户的发送失败异常,记录日志但不中断流程
|
||||||
|
log.error("邮件发送失败,用户邮箱:{},原因:{}", account.getUserEmail(), e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
String port = generateServicePort;
|
String port = generateServicePort;
|
||||||
String jsonString = "";
|
String jsonString = "";
|
||||||
HashMap<String, String> params = new HashMap<>();
|
HashMap<String, String> params = new HashMap<>();
|
||||||
|
String version = null;
|
||||||
|
if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) && generateThroughImageTextDTO.getVersion().equals("high")){
|
||||||
|
version = "high";
|
||||||
|
params.put("version","high");
|
||||||
|
}else if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) && generateThroughImageTextDTO.getVersion().equals("fast")){
|
||||||
|
version = "fast";
|
||||||
|
params.put("version","fast");
|
||||||
|
}
|
||||||
// 3.1 确定不同类型的印花分别调哪个接口
|
// 3.1 确定不同类型的印花分别调哪个接口
|
||||||
if (generateThroughImageTextDTO.getLevel1Type().equals(PRINT_BOARD.getRealName())) {
|
if (generateThroughImageTextDTO.getLevel1Type().equals(PRINT_BOARD.getRealName())) {
|
||||||
switch (generateThroughImageTextDTO.getLevel2Type()) {
|
switch (generateThroughImageTextDTO.getLevel2Type()) {
|
||||||
@@ -171,19 +179,15 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
break;
|
break;
|
||||||
case "Pattern":
|
case "Pattern":
|
||||||
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
||||||
mode, category, generateThroughImageTextDTO.getGender());
|
mode, category, generateThroughImageTextDTO.getGender(), version);
|
||||||
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
||||||
mode, category, generateThroughImageTextDTO.getGender());
|
mode, category, generateThroughImageTextDTO.getGender(), version);
|
||||||
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
||||||
}
|
}
|
||||||
if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) && generateThroughImageTextDTO.getVersion().equals("high")){
|
|
||||||
params.put("version","high");
|
|
||||||
}else if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) && generateThroughImageTextDTO.getVersion().equals("fast")){
|
|
||||||
params.put("version","fast");
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path);
|
Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path);
|
||||||
|
|
||||||
@@ -330,7 +334,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
// generate.setText(text);
|
// generate.setText(text);
|
||||||
break;
|
break;
|
||||||
case "Sketchboard":
|
case "Sketchboard":
|
||||||
text = "clear lines, simple outlines monochrome white vector image of " + translated + ", no background, sketch flat, front view display, best quality, ultra-high resolution 8k";
|
// text = "clear lines, simple outlines monochrome white vector image of " + translated + ", no background, sketch flat, front view display, best quality, ultra-high resolution 8k";
|
||||||
|
text = "a single item of sketch of " + translated + ", 4k, white background";
|
||||||
// generate.setText(text);
|
// generate.setText(text);
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import com.ai.da.model.dto.ToProductImageDTO;
|
|||||||
import com.ai.da.model.vo.*;
|
import com.ai.da.model.vo.*;
|
||||||
import com.ai.da.python.PythonService;
|
import com.ai.da.python.PythonService;
|
||||||
import com.ai.da.service.*;
|
import com.ai.da.service.*;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -30,13 +32,14 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.InputStream;
|
import java.nio.file.Paths;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.hutool.poi.excel.sax.AttributeName.s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
*
|
*
|
||||||
@@ -258,25 +261,47 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
// 翻译
|
// 翻译
|
||||||
String prompt = toProductImageDTO.getPrompt();
|
String prompt = toProductImageDTO.getPrompt();
|
||||||
String s = "";
|
StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image.");
|
||||||
if (!StringUtil.isNullOrEmpty(prompt)) {
|
if (!StringUtil.isNullOrEmpty(prompt)) {
|
||||||
s = pythonService.promptTranslate(prompt);
|
prompt = pythonService.promptTranslate(prompt);
|
||||||
}else {
|
|
||||||
s = "best quality, masterpiece. detailed, high-res, simple background, studio photography, extremely detailed, updo, detailed face, face, close-up, HDR, UHD, 8K realistic, Highly detailed, simple background, Studio lighting";
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// s = "best quality, masterpiece. detailed, high-res, simple background, studio photography, extremely detailed, updo, detailed face, face, close-up, HDR, UHD, 8K realistic, Highly detailed, simple background, Studio lighting";
|
||||||
|
// }
|
||||||
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
|
||||||
String taskId;
|
String taskId;
|
||||||
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
|
||||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
|
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
|
||||||
|
|
||||||
|
Long designItemId = tDesignPythonOutfit.getDesignItemId();
|
||||||
|
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
||||||
|
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemId);
|
||||||
|
designItemDetailQueryWrapper.lambda().ne(DesignItemDetail::getType, "Body");
|
||||||
|
List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
||||||
|
String collect = designItemDetails.stream().map(DesignItemDetail::getType).collect(Collectors.joining(","));
|
||||||
|
|
||||||
Long designId = tDesignPythonOutfit.getDesignId();
|
Long designId = tDesignPythonOutfit.getDesignId();
|
||||||
Design design = designMapper.selectById(designId);
|
Design design = designMapper.selectById(designId);
|
||||||
String productType = "overall";
|
String productType = "overall";
|
||||||
if (design.getSingleOverall().equals("single")) {
|
if (design.getSingleOverall().equals("single")) {
|
||||||
productType = "single";
|
productType = "single";
|
||||||
|
sb.append(collect);
|
||||||
|
}else {
|
||||||
|
if (collect.contains("Tops")) {
|
||||||
|
sb.append("a handsome man,");
|
||||||
|
}else {
|
||||||
|
sb.append("a beautiful women,");
|
||||||
|
}
|
||||||
|
sb.append("wearing ").append(collect);
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(prompt)) {
|
||||||
|
sb.append(",8K realistic,HDR");
|
||||||
|
}else {
|
||||||
|
sb.append(",").append(prompt).append(",8K realistic,HDR");
|
||||||
}
|
}
|
||||||
// 走模型
|
// 走模型
|
||||||
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s, toProductImageDTO.getImageStrength(), productType);
|
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), productType);
|
||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
|
||||||
toProductImageResult.setElementType("DesignOutfit");
|
toProductImageResult.setElementType("DesignOutfit");
|
||||||
@@ -290,10 +315,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
||||||
result.add(toProductImageResult);
|
result.add(toProductImageResult);
|
||||||
}else {
|
}else {
|
||||||
|
if (StringUtils.isEmpty(prompt)) {
|
||||||
|
sb.append(",8K realistic,HDR");
|
||||||
|
}else {
|
||||||
|
sb.append(",").append(prompt).append(",8K realistic,HDR");
|
||||||
|
}
|
||||||
|
|
||||||
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
|
||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||||
// 走模型
|
// 走模型
|
||||||
pythonService.toProductImage(toProductElement.getUrl(), taskId, s, toProductImageDTO.getImageStrength(), "overall");
|
pythonService.toProductImage(toProductElement.getUrl(), taskId, sb.toString(), toProductImageDTO.getImageStrength(), "overall");
|
||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
toProductImageResult.setElementId(toProductElement.getId());
|
toProductImageResult.setElementId(toProductElement.getId());
|
||||||
toProductImageResult.setElementType("ProductElement");
|
toProductImageResult.setElementType("ProductElement");
|
||||||
@@ -611,67 +642,150 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
public String likeHistoryRelSketch() {
|
public String likeHistoryRelSketch() {
|
||||||
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
QueryWrapper<UserLikeGroup> qw = new QueryWrapper<>();
|
||||||
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(qw);
|
List<UserLikeGroup> userLikeGroups = userLikeGroupMapper.selectList(qw);
|
||||||
Map<Long, List<List<Map<String, Object>>>> result = new HashMap<>();
|
List<List<Map<String, Object>>> result = new ArrayList<>();
|
||||||
|
|
||||||
for (UserLikeGroup userLikeGroup : userLikeGroups) {
|
for (UserLikeGroup userLikeGroup : userLikeGroups) {
|
||||||
Long accountId = userLikeGroup.getAccountId();
|
Long accountId = userLikeGroup.getAccountId();
|
||||||
Long collectionId = userLikeGroup.getCollectionId();
|
Long collectionId = userLikeGroup.getCollectionId();
|
||||||
|
|
||||||
QueryWrapper<CollectionElement> collectionElementQueryWrapper = new QueryWrapper<>();
|
// 提前转换为Set以提高contains的效率
|
||||||
collectionElementQueryWrapper.lambda().eq(CollectionElement::getCollectionId, collectionId);
|
List<CollectionElement> collectionElements = getCollectionElementsByCollectionId(collectionId);
|
||||||
collectionElementQueryWrapper.lambda().eq(CollectionElement::getLevel1Type, "Sketchboard");
|
Set<String> urlSet = collectionElements.stream()
|
||||||
List<CollectionElement> collectionElements = collectionElementMapper.selectList(collectionElementQueryWrapper);
|
.map(CollectionElement::getUrl)
|
||||||
List<String> urlList = collectionElements.stream().map(CollectionElement::getUrl).collect(Collectors.toList());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
QueryWrapper<UserLike> userLikeQueryWrapper = new QueryWrapper<>();
|
List<UserLike> userLikes = getUserLikesByGroupId(userLikeGroup.getId());
|
||||||
userLikeQueryWrapper.lambda().eq(UserLike::getUserLikeGroupId, userLikeGroup.getId());
|
|
||||||
List<UserLike> userLikes = userLikeMapper.selectList(userLikeQueryWrapper);
|
|
||||||
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
|
||||||
|
|
||||||
for (UserLike userLike : userLikes) {
|
for (UserLike userLike : userLikes) {
|
||||||
QueryWrapper<DesignItemDetail> designItemDetailQueryWrapper = new QueryWrapper<>();
|
List<Map<String, Object>> userLikeSketchList = new ArrayList<>();
|
||||||
designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, userLike.getDesignItemId());
|
List<DesignItemDetail> designItemDetails = getDesignItemDetails(userLike.getDesignItemId());
|
||||||
designItemDetailQueryWrapper.lambda().ne(DesignItemDetail::getType, "Body");
|
|
||||||
List<DesignItemDetail> designItemDetails = designItemDetailMapper.selectList(designItemDetailQueryWrapper);
|
|
||||||
Map<String, Object> sketch = new HashMap<>();
|
|
||||||
for (DesignItemDetail designItemDetail : designItemDetails) {
|
for (DesignItemDetail designItemDetail : designItemDetails) {
|
||||||
|
Map<String, Object> sketch = new HashMap<>();
|
||||||
String path = designItemDetail.getPath();
|
String path = designItemDetail.getPath();
|
||||||
|
|
||||||
|
// 下载路径到本地
|
||||||
|
// if (!StringUtils.isEmpty(path)) {
|
||||||
|
// String bucketName = minioUtil.getBucketNameFromPath(path);
|
||||||
|
// String objectName = minioUtil.getObjectNameFromPath(path);
|
||||||
|
// String localBasePath = "C:\\workspace\\fileData\\minio";
|
||||||
|
// String localFilePath = Paths.get(localBasePath, path).toString();
|
||||||
|
//
|
||||||
|
// // 检查文件是否已经存在,避免重复下载
|
||||||
|
// File localFile = new File(localFilePath);
|
||||||
|
// if (!localFile.exists()) {
|
||||||
|
// minioUtil.downloadMinioObjectToLocal(bucketName, objectName, localFilePath);
|
||||||
|
// } else {
|
||||||
|
// log.info("File already exists, skipping download: {}", localFilePath);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
Long designId = designItemDetail.getDesignId();
|
||||||
|
Design design = designMapper.selectById(designId);
|
||||||
|
if (null == design) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (design.getSingleOverall().equals("single")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (design.getModelType().equals("System")) {
|
||||||
|
SysFile sysFile = sysFileMapper.selectById(design.getTemplateId());
|
||||||
|
if (null == sysFile) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sketch.put("sex", sysFile.getLevel2Type().equals("Male") ? "Male" : "Female");
|
||||||
|
} else {
|
||||||
|
Library library = libraryMapper.selectById(design.getTemplateId());
|
||||||
|
if (null == library) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sketch.put("sex", library.getLevel2Type().equals("Female") ? "Female" : "Male");
|
||||||
|
}
|
||||||
|
|
||||||
sketch.put("type", designItemDetail.getType());
|
sketch.put("type", designItemDetail.getType());
|
||||||
sketch.put("path", path);
|
sketch.put("path", path);
|
||||||
if (urlList.contains(path)) {
|
sketch.put("beSelected", urlSet.contains(path));
|
||||||
sketch.put("beSelected", true);
|
sketch.put("accountId", accountId);
|
||||||
}else {
|
|
||||||
sketch.put("beSelected", false);
|
|
||||||
}
|
|
||||||
if (path.contains("aida-sys-image/images/")) {
|
if (path.contains("aida-sys-image/images/")) {
|
||||||
String searchPath = new String(path);
|
String replace = path.replace("aida-sys-image/images/", "");
|
||||||
String replace = searchPath.replace("aida-sys-image/images/", "");
|
|
||||||
String style = getStyleByUrl(replace);
|
String style = getStyleByUrl(replace);
|
||||||
if (!StringUtils.isEmpty(style)) {
|
if (!StringUtils.isEmpty(style)) {
|
||||||
sketch.put("style", style);
|
sketch.put("style", style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
userLikeSketchList.add(sketch);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(userLikeSketchList)) {
|
||||||
|
result.add(userLikeSketchList);
|
||||||
}
|
}
|
||||||
list.add(sketch);
|
|
||||||
}
|
|
||||||
if (result.containsKey(accountId)) {
|
|
||||||
result.get(accountId).add(list);
|
|
||||||
}else {
|
|
||||||
List<List<Map<String, Object>>> lists = new ArrayList<>();
|
|
||||||
lists.add(list);
|
|
||||||
result.put(accountId, lists);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(JSONObject.toJSONString(result));
|
|
||||||
|
// 将结果以美观的JSON形式保存到文件中
|
||||||
|
saveResultAsPrettyJson(result, "C:\\Users\\10233\\Desktop\\result.json");
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String download() {
|
||||||
|
// 下载 aida-collection-element bucket 下所有 Sketchboard 文件夹内容
|
||||||
|
// String sketchboardLocalPath = "C:\\workspace\\fileData\\minio";
|
||||||
|
// minioUtil.downloadSketchboardDirectories(sketchboardLocalPath);
|
||||||
|
//
|
||||||
|
// // 下载整个 aida-users bucket
|
||||||
|
// String aidaUsersLocalPath = "C:\\workspace\\fileData\\minio";
|
||||||
|
// minioUtil.downloadEntireBucket("aida-users", aidaUsersLocalPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提取公共方法
|
||||||
|
private List<CollectionElement> getCollectionElementsByCollectionId(Long collectionId) {
|
||||||
|
QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(CollectionElement::getCollectionId, collectionId)
|
||||||
|
.eq(CollectionElement::getLevel1Type, "Sketchboard");
|
||||||
|
return collectionElementMapper.selectList(qw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UserLike> getUserLikesByGroupId(Long groupId) {
|
||||||
|
QueryWrapper<UserLike> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(UserLike::getUserLikeGroupId, groupId);
|
||||||
|
return userLikeMapper.selectList(qw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DesignItemDetail> getDesignItemDetails(Long designItemId) {
|
||||||
|
QueryWrapper<DesignItemDetail> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().eq(DesignItemDetail::getDesignItemId, designItemId)
|
||||||
|
.ne(DesignItemDetail::getType, "Body");
|
||||||
|
return designItemDetailMapper.selectList(qw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveResultAsPrettyJson(List<List<Map<String, Object>>> result, String filePath) {
|
||||||
|
// 使用一个 Map<String, Object> 将结果存储为字符串键
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("data", result);
|
||||||
|
|
||||||
|
try (FileWriter file = new FileWriter(filePath)) {
|
||||||
|
// 使用 JSONObject 将转换后的 Map 转为 JSON
|
||||||
|
JSONObject jsonObject = new JSONObject(resultMap);
|
||||||
|
// 格式化输出为美观的 JSON
|
||||||
|
file.write(JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getStyleByUrl(String replace) {
|
private String getStyleByUrl(String replace) {
|
||||||
String[] split = replace.split("/");
|
String[] split = replace.split("/");
|
||||||
String tableName = getTableName(split);
|
String tableName = getTableName(split);
|
||||||
if (StringUtils.isEmpty(tableName)) {
|
if (StringUtils.isEmpty(tableName)) {
|
||||||
return null;
|
return null;
|
||||||
}else {
|
}else {
|
||||||
|
replace = split[1] + "/" + split[2];
|
||||||
return attributeRetrievalMapper.getStyleByUrl(replace, tableName);
|
return attributeRetrievalMapper.getStyleByUrl(replace, tableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user