TASK:toProduct relight pose 返回的数据中需包含设置的参数信息
This commit is contained in:
@@ -1309,6 +1309,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
||||
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
||||
poseTransformationVO.setPoseId(poseTransformation.getPoseId());
|
||||
poseTransformationVO.setModelName(poseTransformation.getModelName());
|
||||
|
||||
// 2、更新redis
|
||||
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"));
|
||||
if (!poseTransformations.isEmpty()) {
|
||||
PoseTransformation poseTransformation = poseTransformations.get(0);
|
||||
poseTransformationVO = CopyUtil.copyObject(poseTransformation, PoseTransformationVO.class);
|
||||
// 生成视频的gif和第一帧图片
|
||||
processVideo(videoUrl, poseTransformation);
|
||||
poseTransformationVO.setId(poseTransformation.getId());
|
||||
|
||||
@@ -749,6 +749,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (Objects.isNull(toProductImageResult)) {
|
||||
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")){
|
||||
Project project = projectService.getById(toProductImageResult.getProjectId());
|
||||
@@ -766,7 +770,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
results.add(new MagicToolResultVO(taskId, fluxResult));
|
||||
} else {
|
||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
||||
// 扣积分
|
||||
Boolean flag = creditsService.taskCreditsDeduction(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.setElementId(toProductImageResult.getElementId());
|
||||
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")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||
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.setUrl(fluxImgMinioPath);
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
|
||||
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
||||
MagicToolResultVO magicToolResultVO = CopyUtil.copyObject(toProductImageResult, MagicToolResultVO.class);
|
||||
magicToolResultVO.setTaskId(taskId);
|
||||
magicToolResultVO.setId(toProductImageResult.getId());
|
||||
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.setElementId(toProductImageResult.getElementId());
|
||||
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
||||
magicToolResultVO.setPrompt(prompt);
|
||||
|
||||
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
||||
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
||||
@@ -1266,6 +1276,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (Objects.isNull(toProductImageResult)) {
|
||||
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")){
|
||||
@@ -1285,7 +1299,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
results.add(new MagicToolResultVO(taskId, fluxResult));
|
||||
} else {
|
||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
||||
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
||||
// 扣积分
|
||||
Boolean flag = creditsService.taskCreditsDeduction(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);
|
||||
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(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")) {
|
||||
magicToolResultVO.setStatus("Invalid");
|
||||
} else {
|
||||
@@ -2096,6 +2114,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
ToProductImageResultVO vo = CopyUtil.copyObject(result, ToProductImageResultVO.class);
|
||||
// 设置sourceUrl
|
||||
setSourceUrl(vo);
|
||||
// 设置prompt
|
||||
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(result.getToProductImageRecordId());
|
||||
if (Objects.nonNull(toProductImageRecord)){
|
||||
vo.setPrompt(toProductImageRecord.getPrompt());
|
||||
}
|
||||
// 按isLike分类
|
||||
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
||||
likedList.add(vo);
|
||||
|
||||
Reference in New Issue
Block a user