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 f505796e..6e443ba9 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -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); } } } diff --git a/src/main/java/com/ai/da/common/utils/MinioUtil.java b/src/main/java/com/ai/da/common/utils/MinioUtil.java index 352b4d79..14e9e2fb 100644 --- a/src/main/java/com/ai/da/common/utils/MinioUtil.java +++ b/src/main/java/com/ai/da/common/utils/MinioUtil.java @@ -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: 上传文件 * diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 6653c7da..7b5462dd 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -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 { diff --git a/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java b/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java index b15b9418..fa3a6df0 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java @@ -75,6 +75,8 @@ public class CollectionElement implements Serializable { */ private String md5; + private String gradientString; + /** * 创建时间 */ diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java new file mode 100644 index 00000000..e8d40d3b --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java @@ -0,0 +1,14 @@ +package com.ai.da.mapper.primary.entity; + +import lombok.Data; + +import java.util.List; + +@Data +public class Gradient { + private List gradientList; + private int angle; + private int selectIndex; + private boolean gradientShow; + private String colorImg; +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java new file mode 100644 index 00000000..37a8c8ca --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java @@ -0,0 +1,9 @@ +package com.ai.da.mapper.primary.entity; + +import lombok.Data; + +@Data +public class GradientItem { + private RGBA rgba; + private String left; +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java new file mode 100644 index 00000000..9ee98a71 --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java @@ -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; +} diff --git a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java index f569182f..9de66e9c 100644 --- a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java +++ b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java @@ -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; + } diff --git a/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java b/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java index 73fa47d5..68ad0914 100644 --- a/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java +++ b/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java @@ -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; diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index 099708e5..d0d2c6ab 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -48,9 +48,9 @@ public class DesignSingleItemDTO { @ApiModelProperty("图层优先级") private Integer priority; -// @ApiModelProperty("渐变 起始/目标 颜色") -// private List> gradient; -// -// @ApiModelProperty("渐变角度") -// private Float gradient_angle; + @ApiModelProperty("渐变 起始/目标 颜色") + private String gradient; + + @ApiModelProperty("渐变角度") + private Float gradient_angle; } diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index eaa1c786..8821c024 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -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 colorBoards) { + private CollectionColorDTO getRandomColor(List 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 sketchBoardElementOlds, List hasUseMd5List) { diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index fc1455ec..86c7a212 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -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 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 usedElementIds = elementVO.getUsedElementIds(); List libraryCollectionElements = elementVO.getLibraryCollectionElements(); List generateCollectionElements = elementVO.getGenerateCollectionElements(); @@ -767,7 +780,8 @@ public class CollectionElementServiceImpl extends ServiceImpl