Merge branch 'dev/dev' into dev/dev_xp
# Conflicts: # src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java # src/main/java/com/ai/da/python/vo/DesignPythonItem.java
This commit is contained in:
@@ -127,6 +127,11 @@ public class MyTaskScheduler {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null);
|
||||
SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.io.*;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -126,6 +127,26 @@ public class MinioUtil {
|
||||
return names;
|
||||
}
|
||||
|
||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
||||
String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
.stream(in, in.available(), -1)
|
||||
.contentType("image/png") // Set the content type according to your image format
|
||||
.build()
|
||||
);
|
||||
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* description: 上传文件
|
||||
*
|
||||
|
||||
@@ -134,6 +134,7 @@ public class SendEmailUtil {
|
||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
||||
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||
private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
@@ -227,6 +228,39 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendNoExcelEmail(String receiverAddress, String senderAddress) {
|
||||
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 = SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "昨日试用订单数据";
|
||||
template.setTemplateID(NO_TRIAL_ORDER_LIST_ID);
|
||||
|
||||
req.setSubject(subject);
|
||||
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 WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
||||
try {
|
||||
|
||||
@@ -75,6 +75,8 @@ public class CollectionElement implements Serializable {
|
||||
*/
|
||||
private String md5;
|
||||
|
||||
private String gradientString;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
14
src/main/java/com/ai/da/mapper/primary/entity/Gradient.java
Normal file
14
src/main/java/com/ai/da/mapper/primary/entity/Gradient.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Gradient {
|
||||
private List<GradientItem> gradientList;
|
||||
private int angle;
|
||||
private int selectIndex;
|
||||
private boolean gradientShow;
|
||||
private String colorImg;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GradientItem {
|
||||
private RGBA rgba;
|
||||
private String left;
|
||||
}
|
||||
11
src/main/java/com/ai/da/mapper/primary/entity/RGBA.java
Normal file
11
src/main/java/com/ai/da/mapper/primary/entity/RGBA.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.ai.da.mapper.primary.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RGBA {
|
||||
private int r;
|
||||
private int g;
|
||||
private int b;
|
||||
private double a;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Gradient;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -25,4 +26,10 @@ public class CollectionColorDTO {
|
||||
@ApiModelProperty("潘通RGB值")
|
||||
private String rgbValue;
|
||||
|
||||
private Gradient gradient;
|
||||
|
||||
// private String gradientString;
|
||||
|
||||
private String gradientMinioUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.model.dto;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Gradient;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -48,9 +48,9 @@ public class DesignSingleItemDTO {
|
||||
@ApiModelProperty("图层优先级")
|
||||
private Integer priority;
|
||||
|
||||
// @ApiModelProperty("渐变 起始/目标 颜色")
|
||||
// private List<List<Integer>> gradient;
|
||||
//
|
||||
// @ApiModelProperty("渐变角度")
|
||||
// private Float gradient_angle;
|
||||
@ApiModelProperty("渐变 起始/目标 颜色")
|
||||
private String gradient;
|
||||
|
||||
@ApiModelProperty("渐变角度")
|
||||
private Float gradient_angle;
|
||||
}
|
||||
|
||||
@@ -1548,7 +1548,9 @@ public class PythonService {
|
||||
pythonItem.setPath(sysFileVO.getUrl());
|
||||
pythonItem.setBusinessId(sysFileVO.getId());
|
||||
if (SysFileLevel2TypeEnum.SHOES.getRealName().equals(type)) {
|
||||
pythonItem.setColor(getRandomColor(elementVO.getColorBoards()));
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
pythonItem.setColor(randomColor.getRgbValue());
|
||||
pythonItem.setGradient(randomColor.getGradientMinioUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1911,7 +1913,9 @@ public class PythonService {
|
||||
designPythonItemBlouse.setPath(path);
|
||||
//所有的icon都是none
|
||||
designPythonItemBlouse.setIcon("none");
|
||||
designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards()));
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
|
||||
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) {
|
||||
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
|
||||
@@ -1937,7 +1941,9 @@ public class PythonService {
|
||||
designPythonItemBlouse.setPath(collectionElement.getUrl());
|
||||
//所有的icon都是none
|
||||
designPythonItemBlouse.setIcon("none");
|
||||
designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards()));
|
||||
CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards());
|
||||
designPythonItemBlouse.setColor(randomColor.getRgbValue());
|
||||
designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl());
|
||||
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
|
||||
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) {
|
||||
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
|
||||
@@ -2216,14 +2222,14 @@ public class PythonService {
|
||||
return sysFileVo.get(key.intValue());
|
||||
}
|
||||
|
||||
private String getRandomColor(List<CollectionColorDTO> colorBoards) {
|
||||
private CollectionColorDTO getRandomColor(List<CollectionColorDTO> colorBoards) {
|
||||
if (colorBoards.size() == 1) {
|
||||
return colorBoards.get(0).getRgbValue();
|
||||
return colorBoards.get(0);
|
||||
}
|
||||
long maxColor = colorBoards.size();
|
||||
long minColor = 0;
|
||||
Long randomIndex = RandomsUtil.randomSysFile(minColor, maxColor);
|
||||
return colorBoards.get(randomIndex.intValue()).getRgbValue();
|
||||
return colorBoards.get(randomIndex.intValue());
|
||||
}
|
||||
|
||||
private CollectionElement getRandomSketchLibrary(List<CollectionElement> sketchBoardElementOlds, List<String> hasUseMd5List) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -76,6 +77,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
|
||||
@Value("${minio.bucketName.collectionElement}")
|
||||
private String collectionElement;
|
||||
@Value("${minio.bucketName.gradient}")
|
||||
private String gradientBucketName;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@@ -348,7 +351,17 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
@Override
|
||||
public ValidateElementVO validateElement(DesignCollectionDTO designDTO) {
|
||||
ValidateElementVO elementVO = CopyUtil.copyObject(designDTO, ValidateElementVO.class);
|
||||
|
||||
List<CollectionColorDTO> colorBoards = elementVO.getColorBoards();
|
||||
for (CollectionColorDTO colorBoard : colorBoards) {
|
||||
String colorImg = colorBoard.getGradient().getColorImg();
|
||||
String[] parts = colorImg.split(",");
|
||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
||||
String base64Data = parts[1];
|
||||
String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType);
|
||||
colorBoard.setGradientMinioUrl(gradientMinioUrl);
|
||||
colorBoard.getGradient().setColorImg(null);
|
||||
}
|
||||
elementVO.setColorBoards(colorBoards);
|
||||
List<Long> usedElementIds = elementVO.getUsedElementIds();
|
||||
List<CollectionElement> libraryCollectionElements = elementVO.getLibraryCollectionElements();
|
||||
List<CollectionElement> generateCollectionElements = elementVO.getGenerateCollectionElements();
|
||||
@@ -767,7 +780,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
element.setColorRgb(color.getRgbValue());
|
||||
//按时区计算
|
||||
element.setCreateDate(DateUtil.getByTimeZone(timeZone));
|
||||
|
||||
color.getGradient().setColorImg(null);
|
||||
element.setGradientString(JSON.toJSONString(color.getGradient()));
|
||||
elements.add(element);
|
||||
});
|
||||
return elements;
|
||||
|
||||
Reference in New Issue
Block a user