TASK:toProduct relight pose 返回的数据中需包含设置的参数信息
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package com.ai.da.model.vo;
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ApiModel("generate result 响应")
|
@ApiModel("generate result 响应")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -31,6 +34,15 @@ public class MagicToolResultVO {
|
|||||||
|
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
private Double brightenValue;
|
||||||
|
|
||||||
|
private BigDecimal imageStrength;
|
||||||
|
|
||||||
|
private String direction;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户输入的提示词")
|
||||||
|
private String prompt;
|
||||||
|
|
||||||
public MagicToolResultVO(String taskId, String status) {
|
public MagicToolResultVO(String taskId, String status) {
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ public class PoseTransformationVO implements AllCollectionVO{
|
|||||||
|
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
private int poseId;
|
||||||
|
|
||||||
public PoseTransformationVO(Long id, String taskId, String gifUrl, String videoUrl, String firstFrameUrl, byte isLiked, String status) {
|
public PoseTransformationVO(Long id, String taskId, String gifUrl, String videoUrl, String firstFrameUrl, byte isLiked, String status) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.taskId = taskId;
|
this.taskId = taskId;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ai.da.model.vo;
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -11,4 +12,6 @@ public class ToProductImageResultVO extends ToProductImageResult implements AllC
|
|||||||
private Long userLikeSortId;
|
private Long userLikeSortId;
|
||||||
private String relationType;
|
private String relationType;
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
@ApiModelProperty("用户输入的提示词")
|
||||||
|
private String prompt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1309,6 +1309,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
String key = generateResultKey + ":" + taskId;
|
String key = generateResultKey + ":" + taskId;
|
||||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
||||||
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
||||||
|
poseTransformationVO.setPoseId(poseTransformation.getPoseId());
|
||||||
|
poseTransformationVO.setModelName(poseTransformation.getModelName());
|
||||||
|
|
||||||
// 2、更新redis
|
// 2、更新redis
|
||||||
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
@@ -2243,6 +2245,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId).orderByDesc("id"));
|
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId).orderByDesc("id"));
|
||||||
if (!poseTransformations.isEmpty()) {
|
if (!poseTransformations.isEmpty()) {
|
||||||
PoseTransformation poseTransformation = poseTransformations.get(0);
|
PoseTransformation poseTransformation = poseTransformations.get(0);
|
||||||
|
poseTransformationVO = CopyUtil.copyObject(poseTransformation, PoseTransformationVO.class);
|
||||||
// 生成视频的gif和第一帧图片
|
// 生成视频的gif和第一帧图片
|
||||||
processVideo(videoUrl, poseTransformation);
|
processVideo(videoUrl, poseTransformation);
|
||||||
poseTransformationVO.setId(poseTransformation.getId());
|
poseTransformationVO.setId(poseTransformation.getId());
|
||||||
|
|||||||
@@ -749,6 +749,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
if (Objects.isNull(toProductImageResult)) {
|
if (Objects.isNull(toProductImageResult)) {
|
||||||
throw new BusinessException("The source image does not exist.");
|
throw new BusinessException("The source image does not exist.");
|
||||||
}
|
}
|
||||||
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||||
|
if (Objects.isNull(toProductImageRecord)) {
|
||||||
|
throw new BusinessException("This task does not exist.");
|
||||||
|
}
|
||||||
// 判断当任务从哪个模型获取结果
|
// 判断当任务从哪个模型获取结果
|
||||||
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName()) && toProductImageResult.getModelName().equals("flux")){
|
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName()) && toProductImageResult.getModelName().equals("flux")){
|
||||||
Project project = projectService.getById(toProductImageResult.getProjectId());
|
Project project = projectService.getById(toProductImageResult.getProjectId());
|
||||||
@@ -766,7 +770,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResultMapper.updateById(toProductImageResult);
|
toProductImageResultMapper.updateById(toProductImageResult);
|
||||||
results.add(new MagicToolResultVO(taskId, fluxResult));
|
results.add(new MagicToolResultVO(taskId, fluxResult));
|
||||||
} else {
|
} else {
|
||||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
||||||
// 扣积分
|
// 扣积分
|
||||||
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
||||||
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
||||||
@@ -786,6 +790,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
||||||
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
||||||
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
||||||
|
magicToolResultVO.setDirection(toProductImageResult.getDirection());
|
||||||
|
magicToolResultVO.setBrightenValue(toProductImageResult.getBrightenValue());
|
||||||
|
magicToolResultVO.setImageStrength(toProductImageResult.getImageStrength());
|
||||||
|
magicToolResultVO.setPrompt(toProductImageRecord.getPrompt());
|
||||||
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||||
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||||
@@ -845,12 +853,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MagicToolResultVO processFluxResult(String fluxImgMinioPath, ToProductImageResult toProductImageResult, String taskId){
|
private MagicToolResultVO processFluxResult(String fluxImgMinioPath, ToProductImageResult toProductImageResult, String taskId, String prompt){
|
||||||
toProductImageResult.setTaskStatus("Success");
|
toProductImageResult.setTaskStatus("Success");
|
||||||
toProductImageResult.setUrl(fluxImgMinioPath);
|
toProductImageResult.setUrl(fluxImgMinioPath);
|
||||||
toProductImageResultMapper.updateById(toProductImageResult);
|
toProductImageResultMapper.updateById(toProductImageResult);
|
||||||
|
|
||||||
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
MagicToolResultVO magicToolResultVO = CopyUtil.copyObject(toProductImageResult, MagicToolResultVO.class);
|
||||||
magicToolResultVO.setTaskId(taskId);
|
magicToolResultVO.setTaskId(taskId);
|
||||||
magicToolResultVO.setId(toProductImageResult.getId());
|
magicToolResultVO.setId(toProductImageResult.getId());
|
||||||
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(fluxImgMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(fluxImgMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
@@ -858,6 +866,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
||||||
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
||||||
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
||||||
|
magicToolResultVO.setPrompt(prompt);
|
||||||
|
|
||||||
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||||
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||||
@@ -1266,6 +1276,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
if (Objects.isNull(toProductImageResult)) {
|
if (Objects.isNull(toProductImageResult)) {
|
||||||
throw new BusinessException("The source image does not exist.");
|
throw new BusinessException("The source image does not exist.");
|
||||||
}
|
}
|
||||||
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
||||||
|
if (Objects.isNull(toProductImageRecord)) {
|
||||||
|
throw new BusinessException("This task does not exist.");
|
||||||
|
}
|
||||||
// 判断当任务从哪个模型获取结果
|
// 判断当任务从哪个模型获取结果
|
||||||
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName())
|
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName())
|
||||||
&& toProductImageResult.getModelName().equals("flux")){
|
&& toProductImageResult.getModelName().equals("flux")){
|
||||||
@@ -1285,7 +1299,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResultMapper.updateById(toProductImageResult);
|
toProductImageResultMapper.updateById(toProductImageResult);
|
||||||
results.add(new MagicToolResultVO(taskId, fluxResult));
|
results.add(new MagicToolResultVO(taskId, fluxResult));
|
||||||
} else {
|
} else {
|
||||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
||||||
// 扣积分
|
// 扣积分
|
||||||
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
||||||
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
||||||
@@ -1297,6 +1311,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
|
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
|
||||||
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
|
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
|
||||||
String url = magicToolResultVO.getUrl();
|
String url = magicToolResultVO.getUrl();
|
||||||
|
magicToolResultVO.setDirection(toProductImageResult.getDirection());
|
||||||
|
magicToolResultVO.setBrightenValue(toProductImageResult.getBrightenValue());
|
||||||
|
magicToolResultVO.setImageStrength(toProductImageResult.getImageStrength());
|
||||||
|
magicToolResultVO.setPrompt(toProductImageRecord.getPrompt());
|
||||||
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
|
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
|
||||||
magicToolResultVO.setStatus("Invalid");
|
magicToolResultVO.setStatus("Invalid");
|
||||||
} else {
|
} else {
|
||||||
@@ -2096,6 +2114,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
ToProductImageResultVO vo = CopyUtil.copyObject(result, ToProductImageResultVO.class);
|
ToProductImageResultVO vo = CopyUtil.copyObject(result, ToProductImageResultVO.class);
|
||||||
// 设置sourceUrl
|
// 设置sourceUrl
|
||||||
setSourceUrl(vo);
|
setSourceUrl(vo);
|
||||||
|
// 设置prompt
|
||||||
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(result.getToProductImageRecordId());
|
||||||
|
if (Objects.nonNull(toProductImageRecord)){
|
||||||
|
vo.setPrompt(toProductImageRecord.getPrompt());
|
||||||
|
}
|
||||||
// 按isLike分类
|
// 按isLike分类
|
||||||
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
||||||
likedList.add(vo);
|
likedList.add(vo);
|
||||||
|
|||||||
Reference in New Issue
Block a user