Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -11,15 +11,15 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
public enum PoseEnum {
|
||||
|
||||
POSE_1(1L, "aida-sys-image/pose/pose-1.mp4", "aida-sys-image/pose/pose-1.gif", "aida-sys-image/pose/pose-1-first_frame.jpeg", "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j"),
|
||||
POSE_2(2L, "aida-sys-image/pose/pose-2.mp4", "aida-sys-image/pose/pose-2.gif", "aida-sys-image/pose/pose-2-first_frame.jpeg", "AACT.8090e67b.TwJLxEv3EfCbDTI_rjSH-A.IOQZCYhf"),
|
||||
POSE_3(3L, "aida-sys-image/pose/pose-3.mp4", "aida-sys-image/pose/pose-3.gif", "aida-sys-image/pose/pose-3-first_frame.jpeg", "AACT.8090e67b.gd3OCkv4EfCxyZo8eQGF2Q.qMm-a1XI"),
|
||||
POSE_4(4L, "aida-sys-image/pose/pose-4.mp4", "aida-sys-image/pose/pose-4.gif", "aida-sys-image/pose/pose-4-first_frame.jpeg", "AACT.8090e67b.AUDnuEwDEfCEHBaRJeW4dg.rlx36xEY"),
|
||||
POSE_5(5L, "aida-sys-image/pose/pose-5.mp4", "aida-sys-image/pose/pose-5.gif", "aida-sys-image/pose/pose-5-first_frame.jpeg", "AACT.8090e67b.G8BvkEwEEfCxyZo8eQGF2Q.fo4ryrgR"),
|
||||
POSE_6(6L, "aida-sys-image/pose/pose-6.mp4", "aida-sys-image/pose/pose-6.gif", "aida-sys-image/pose/pose-6-first_frame.jpeg", "AACT.8090e67b.yBIPnEwEEfCxyZo8eQGF2Q.boSFwTG9");
|
||||
POSE_1(1, "aida-sys-image/pose/pose-1.mp4", "aida-sys-image/pose/pose-1.gif", "aida-sys-image/pose/pose-1-first_frame.jpeg", "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j"),
|
||||
POSE_2(2, "aida-sys-image/pose/pose-2.mp4", "aida-sys-image/pose/pose-2.gif", "aida-sys-image/pose/pose-2-first_frame.jpeg", "AACT.8090e67b.TwJLxEv3EfCbDTI_rjSH-A.IOQZCYhf"),
|
||||
POSE_3(3, "aida-sys-image/pose/pose-3.mp4", "aida-sys-image/pose/pose-3.gif", "aida-sys-image/pose/pose-3-first_frame.jpeg", "AACT.8090e67b.gd3OCkv4EfCxyZo8eQGF2Q.qMm-a1XI"),
|
||||
POSE_4(4, "aida-sys-image/pose/pose-4.mp4", "aida-sys-image/pose/pose-4.gif", "aida-sys-image/pose/pose-4-first_frame.jpeg", "AACT.8090e67b.AUDnuEwDEfCEHBaRJeW4dg.rlx36xEY"),
|
||||
POSE_5(5, "aida-sys-image/pose/pose-5.mp4", "aida-sys-image/pose/pose-5.gif", "aida-sys-image/pose/pose-5-first_frame.jpeg", "AACT.8090e67b.G8BvkEwEEfCxyZo8eQGF2Q.fo4ryrgR"),
|
||||
POSE_6(6, "aida-sys-image/pose/pose-6.mp4", "aida-sys-image/pose/pose-6.gif", "aida-sys-image/pose/pose-6-first_frame.jpeg", "AACT.8090e67b.yBIPnEwEEfCxyZo8eQGF2Q.boSFwTG9");
|
||||
|
||||
|
||||
private final Long id;
|
||||
private final Integer id;
|
||||
|
||||
private final String videoPath;
|
||||
|
||||
@@ -37,7 +37,7 @@ public enum PoseEnum {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static final Map<Long, PoseEnum> BY_ID = Arrays.stream(values())
|
||||
private static final Map<Integer, PoseEnum> BY_ID = Arrays.stream(values())
|
||||
.collect(Collectors.toMap(PoseEnum::getId, Function.identity()));
|
||||
|
||||
private static final Map<String, PoseEnum> BY_VIDEO_PATH = Arrays.stream(values())
|
||||
@@ -46,7 +46,7 @@ public enum PoseEnum {
|
||||
private static final List<String> VIDEO_PATH = Arrays.stream(values())
|
||||
.map(PoseEnum::getVideoPath).collect(Collectors.toList());
|
||||
|
||||
public static PoseEnum getById(Long id) {
|
||||
public static PoseEnum getById(Integer id) {
|
||||
return BY_ID.get(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,21 +206,24 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
|
||||
// 1、获取当前在积分预扣除区,未来需要预扣除的积分总和
|
||||
// 1、获取预扣除区的积分总和(转为 BigDecimal),未来需要预扣除的积分总和
|
||||
Set<String> keys = redisUtil.getKeysFromString(creditsDeduction + ":" + accountId + ":*");
|
||||
List<String> multiValue = redisUtil.getMultiValue(keys);
|
||||
// 1.1 预扣除区 积分总和
|
||||
int sum = multiValue.stream().mapToInt(Integer::parseInt).sum();
|
||||
// 1.2 加上本次操作需要扣除的积分
|
||||
sum += Integer.parseInt(event.getValue()) * num;
|
||||
BigDecimal sum = multiValue.stream()
|
||||
.map(value -> new BigDecimal(value)) // 将每个 String 转为 BigDecimal
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add); // 累加
|
||||
|
||||
// 2、获取当前积分
|
||||
// 2、加上本次操作的积分(BigDecimal 运算)
|
||||
BigDecimal currentDeduction = new BigDecimal(event.getValue()).multiply(new BigDecimal(num));
|
||||
sum = sum.add(currentDeduction);
|
||||
|
||||
// 3、获取当前积分
|
||||
BigDecimal existingCredits = accountMapper.selectById(accountId).getCredits();
|
||||
BigDecimal subtract = existingCredits.subtract(new BigDecimal(sum));
|
||||
BigDecimal subtract = existingCredits.subtract(sum);
|
||||
|
||||
// 3、判断剩余积分是否够本次操作
|
||||
// 4、判断剩余积分是否够本次操作
|
||||
if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// 3.1 不够,直接返回余额不够,充值
|
||||
// 4.1 不够,直接返回余额不够,充值
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
}
|
||||
|
||||
CreditsEventsEnum creditsEventsEnum = CreditsEventsEnum.OTHER;
|
||||
if (generateThroughImageTextDTO.getModelName().equals("wx")){
|
||||
if (!StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getModelName()) && generateThroughImageTextDTO.getModelName().equals("wx")){
|
||||
String taskId = createAsyncTask(generateThroughImageTextDTO);
|
||||
// String taskId = "e53c86ea-53be-424b-8ac7-3c01c141f4f7";
|
||||
creditsEventsEnum = CreditsEventsEnum.WX_TEXT2IMG;
|
||||
@@ -1141,7 +1141,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
String taskId;
|
||||
Boolean flag = false;
|
||||
PoseTransformation poseTransformation = new PoseTransformation();
|
||||
if (poseTransformDTO.getModelName().equals("wx")){
|
||||
if (!StringUtil.isNullOrEmpty(poseTransformDTO.getModelName()) && poseTransformDTO.getModelName().equals("wx")){
|
||||
taskId = animateAnyone(poseTransformDTO, accountId);
|
||||
if (!StringUtil.isNullOrEmpty(taskId)) flag = true;
|
||||
poseTransformation.setModelName("wx");
|
||||
@@ -1625,20 +1625,16 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
private static final String GET_ASYNC_RESULT = "https://dashscope.aliyuncs.com/api/v1/tasks/";
|
||||
private static final String ANIMATE = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/";
|
||||
public String animateAnyone(PoseTransformDTO poseTransformDTO, Long accountId){
|
||||
|
||||
accountId = 87L;
|
||||
String inputImage = poseTransformDTO.getProductImage();
|
||||
// inputImage = "aida-users/87/product_image/03983c74-741b-4d4d-820a-7c0a98a8f500-0-87.png";
|
||||
String inputImageUrl = minioUtil.getPreSignedUrl(inputImage, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
// 1、输入图片检测
|
||||
checkImage(inputImageUrl);
|
||||
|
||||
// 2、动作模板生成
|
||||
/* 目前只有一个pose,所以不调获取templateId的方法,写死
|
||||
String videoPath = "aida-sys-image/pose/WeChat_20250408175337.mp4";
|
||||
String videoTemplateId = getVideoTemplateId(videoPath);*/
|
||||
String videoTemplateId = "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j";;
|
||||
|
||||
String videoTemplateId = PoseEnum.getById(poseTransformDTO.getPoseId()).getTemplateId();
|
||||
if (StringUtil.isNullOrEmpty(videoTemplateId)){
|
||||
throw new BusinessException("unknown pose");
|
||||
}
|
||||
// 3、生成动图
|
||||
JSONObject requestBody1 = new JSONObject();
|
||||
requestBody1.set("model", "animate-anyone-gen2");
|
||||
|
||||
Reference in New Issue
Block a user