TASK:design 渐变色;

This commit is contained in:
shahaibo
2024-05-10 17:17:28 +08:00
parent e2697aa407
commit b86f168fe8
17 changed files with 210 additions and 83 deletions

View File

@@ -154,63 +154,63 @@ public class GenerateConsumer {
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer1(Message msg, Channel channel) {
generate(msg, channel, "consumer 1");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer2(Message msg, Channel channel) {
generate(msg, channel, "consumer 2");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer3(Message msg, Channel channel) {
generate(msg, channel, "consumer 3");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer4(Message msg, Channel channel) {
generate(msg, channel, "consumer 4");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer5(Message msg, Channel channel) {
generate(msg, channel, "consumer 5");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer6(Message msg, Channel channel) {
generate(msg, channel, "consumer 6");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer7(Message msg, Channel channel) {
generate(msg, channel, "consumer 7");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer8(Message msg, Channel channel) {
generate(msg, channel, "consumer 8");
}
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
@RabbitHandler
public void generateConsumer9(Message msg, Channel channel) {
generate(msg, channel, "consumer 9");
}
@RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
@RabbitHandler
public void getGenerateResult(Message msg, Channel channel) {
processGenerateResult(msg, channel);
}
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer1(Message msg, Channel channel) {
// generate(msg, channel, "consumer 1");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer2(Message msg, Channel channel) {
// generate(msg, channel, "consumer 2");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer3(Message msg, Channel channel) {
// generate(msg, channel, "consumer 3");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer4(Message msg, Channel channel) {
// generate(msg, channel, "consumer 4");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer5(Message msg, Channel channel) {
// generate(msg, channel, "consumer 5");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer6(Message msg, Channel channel) {
// generate(msg, channel, "consumer 6");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer7(Message msg, Channel channel) {
// generate(msg, channel, "consumer 7");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer8(Message msg, Channel channel) {
// generate(msg, channel, "consumer 8");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
// @RabbitHandler
// public void generateConsumer9(Message msg, Channel channel) {
// generate(msg, channel, "consumer 9");
// }
//
// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
// @RabbitHandler
// public void getGenerateResult(Message msg, Channel channel) {
// processGenerateResult(msg, channel);
// }
}

View File

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

View File

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

View File

@@ -23,7 +23,7 @@ public class PaypalTask {
@Resource
private PayPalCheckoutService payPalCheckoutService;
@Scheduled(cron = "0/30 * * * * ?")
// @Scheduled(cron = "0/30 * * * * ?")
public void orderConfirm() throws SerializeException {
log.info("PayPal orderConfirm 被执行......");

View File

@@ -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: 上传文件
*

View File

@@ -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 {

View File

@@ -75,6 +75,8 @@ public class CollectionElement implements Serializable {
*/
private String md5;
private String gradientString;
/**
* 创建时间
*/

View 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;
}

View File

@@ -0,0 +1,9 @@
package com.ai.da.mapper.primary.entity;
import lombok.Data;
@Data
public class GradientItem {
private RGBA rgba;
private String left;
}

View 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;
}

View File

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

View File

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

View File

@@ -49,7 +49,7 @@ public class DesignSingleItemDTO {
private Integer priority;
@ApiModelProperty("渐变 起始/目标 颜色")
private List<List<Integer>> gradient;
private String gradient;
@ApiModelProperty("渐变角度")
private Float gradient_angle;

View File

@@ -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) {

View File

@@ -28,6 +28,8 @@ public class DesignPythonItem {
*/
private String color;
private String gradient;
/**
* 对应的print图片的绝对路径
*/
@@ -74,7 +76,7 @@ public class DesignPythonItem {
*/
private Integer priority;
private List<List<Integer>> gradient;
// private List<List<Integer>> gradient;
private Float gradient_angle;
@@ -126,7 +128,7 @@ public class DesignPythonItem {
this.priority = priority;
}
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List<Long> offset, Float resize_scale,Integer priority, List<List<Integer>> gradient, Float gradient_angle) {
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List<Long> offset, Float resize_scale,Integer priority, String gradient, Float gradient_angle) {
this.type = type;
this.path = path;
this.color = color;

View File

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