This commit is contained in:
2026-04-10 22:21:56 +08:00
parent f2a074b2f6
commit f3aeeb3584
2 changed files with 241 additions and 7 deletions

View File

@@ -253,7 +253,32 @@ public class SavedCollectionController {
@Operation(summary = "relight")
@PostMapping("/relight")
public Response<List<ToProductImageResultVO>> relight(@Valid @RequestBody ToProductImageDTO toProductImageDTO) {
return Response.success(userLikeGroupService.relight(toProductImageDTO));
log.info("【relight请求】收到relight请求, projectId={}, isDefaultLike={}, taskCount={}",
toProductImageDTO.getProjectId(),
toProductImageDTO.getIsDefaultLike(),
toProductImageDTO.getToProductImageVOList() != null ? toProductImageDTO.getToProductImageVOList().size() : 0);
long startTime = System.currentTimeMillis();
List<ToProductImageResultVO> result = userLikeGroupService.relight(toProductImageDTO);
long costTime = System.currentTimeMillis() - startTime;
log.info("【relight请求】relight请求处理完成, projectId={}, 返回结果数={}, 耗时={}ms",
toProductImageDTO.getProjectId(),
result != null ? result.size() : 0,
costTime);
// 打印返回结果中的关键信息,用于追踪 collection_sort 变动
if (result != null) {
for (int i = 0; i < result.size(); i++) {
ToProductImageResultVO vo = result.get(i);
log.info("【relight请求】第{}个结果: id={}, taskId={}, isLike={}, parentId={}, sort={}, status={}",
i + 1,
vo.getId(),
vo.getTaskId(),
vo.getIsLike(),
vo.getParentId(),
vo.getSort(),
vo.getStatus());
}
}
return Response.success(result);
}
@Operation(summary = "转relight元素")
@@ -265,7 +290,27 @@ public class SavedCollectionController {
@Operation(summary = "获取relight结果")
@PostMapping("/relightResult")
public Response<List<MagicToolResultVO>> getRelightResult(@Valid @RequestBody List<String> taskIdList) {
log.info("【getRelightResult请求】收到获取relight结果请求, taskIdList={}", taskIdList);
long startTime = System.currentTimeMillis();
List<MagicToolResultVO> magicToolResultVOList = userLikeGroupService.getRelightResult(taskIdList);
long costTime = System.currentTimeMillis() - startTime;
log.info("【getRelightResult请求】获取relight结果处理完成, taskIdList={}, 返回结果数={}, 耗时={}ms",
taskIdList,
magicToolResultVOList != null ? magicToolResultVOList.size() : 0,
costTime);
// 打印返回结果中的关键信息,用于追踪 collection_sort 变动
if (magicToolResultVOList != null) {
for (int i = 0; i < magicToolResultVOList.size(); i++) {
MagicToolResultVO vo = magicToolResultVOList.get(i);
log.info("【getRelightResult请求】第{}个结果: taskId={}, status={}, id={}, parentId={}, url={}",
i + 1,
vo.getTaskId(),
vo.getStatus(),
vo.getId(),
vo.getParentId(),
vo.getUrl() != null ? (vo.getUrl().length() > 50 ? vo.getUrl().substring(0, 50) + "..." : vo.getUrl()) : null);
}
}
return Response.success(magicToolResultVOList);
}

View File

@@ -905,15 +905,15 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
}
// 将构建好的结果对象添加到返回列表
results.add(magicToolResultVO);
// results.add(magicToolResultVO);
} else if (Objects.isNull(magicToolResultVO)) {
// 如果Redis中没有结果对象创建执行中状态的结果对象
magicToolResultVO = new MagicToolResultVO(taskId, "Executing");
results.add(magicToolResultVO);
} else {
// results.add(magicToolResultVO);
}/* else {
// 如果Redis中有结果对象但URL为空直接添加到返回列表
results.add(magicToolResultVO);
}
}*/
// 收集任务状态用于统计
if (!StringUtil.isNullOrEmpty(magicToolResultVO.getStatus())) collect.add(magicToolResultVO.getStatus());
@@ -1305,6 +1305,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageRecord.setPrompt(toProductImageDTO.getPrompt());
}
toProductImageRecordMapper.insert(toProductImageRecord);
log.info("【relight方法】插入to_product_image_record记录, recordId={}", toProductImageRecord.getId());
List<ToProductImageResultVO> result = new ArrayList<>();
@@ -1352,20 +1353,30 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
toProductImageResult.setStatus("Pending");
toProductImageResultMapper.insert(toProductImageResult);
log.info("【relight方法】插入to_product_image_result记录, resultId={}, taskId={}, elementType={}, elementId={}, isDefaultLike={}, parentId={}",
toProductImageResult.getId(), taskId, toProductImageResult.getElementType(),
toProductImageResult.getElementId(), toProductImageDTO.getIsDefaultLike(), toProductImageVO.getParentId());
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
// 先判断是否需要默认like
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()) {
// 满足条件情况下默认添加到like
log.info("【relight方法】isDefaultLike=true准备添加collection_sort记录, resultId={}, parentId={}, projectId={}",
toProductImageResult.getId(), toProductImageVO.getParentId(), toProductImageDTO.getProjectId());
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
log.info("【relight方法】addToProductLike返回结果, resultId={}, collectionSort={}",
toProductImageResult.getId(), collectionSort != null ? "id=" + collectionSort.getId() + ", sort=" + collectionSort.getSort() : "null");
// 重新排序
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
log.info("【relight方法】rearrangeChildSort返回结果, resultId={}, reSort={}", toProductImageResult.getId(), reSort);
// 将生成结果的排序返回
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
toProductImageResult.setParentId(toProductImageVO.getParentId());
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
} else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())) {
toProductImageResult.setParentId(toProductImageVO.getParentId());
log.info("【relight方法】isDefaultLike存在但不为true不添加collection_sort记录, resultId={}, isDefaultLike={}, parentId={}",
toProductImageResult.getId(), toProductImageDTO.getIsDefaultLike(), toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
// designService.addCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
@@ -1399,20 +1410,30 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
toProductImageResult.setStatus("Pending");
toProductImageResultMapper.insert(toProductImageResult);
log.info("【relight方法】插入to_product_image_result记录, resultId={}, taskId={}, elementType={}, elementId={}, isDefaultLike={}, parentId={}",
toProductImageResult.getId(), taskId, toProductImageResult.getElementType(),
toProductImageResult.getElementId(), toProductImageDTO.getIsDefaultLike(), toProductImageVO.getParentId());
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
// 先判断是否需要默认like
if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && toProductImageDTO.getIsDefaultLike()) {
// 满足条件情况下默认添加到like
log.info("【relight方法】isDefaultLike=true准备添加collection_sort记录, resultId={}, parentId={}, projectId={}",
toProductImageResult.getId(), toProductImageVO.getParentId(), toProductImageDTO.getProjectId());
CollectionSort collectionSort = addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
log.info("【relight方法】addToProductLike返回结果, resultId={}, collectionSort={}",
toProductImageResult.getId(), collectionSort != null ? "id=" + collectionSort.getId() + ", sort=" + collectionSort.getSort() : "null");
// 重新排序
Integer reSort = collectionSortService.rearrangeChildSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(),
toProductImageVO.getParentId(), toProductImageVO.getUserLikeSortId());
log.info("【relight方法】rearrangeChildSort返回结果, resultId={}, reSort={}", toProductImageResult.getId(), reSort);
// 将生成结果的排序返回
toProductImageResult.setSort(Objects.isNull(reSort) ? Objects.isNull(collectionSort) ? null : collectionSort.getSort() : reSort);
toProductImageResult.setParentId(toProductImageVO.getParentId());
toProductImageResult.setUserLikeSortId(Objects.isNull(collectionSort) ? null : collectionSort.getId());
} else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())) {
toProductImageResult.setParentId(toProductImageVO.getParentId());
log.info("【relight方法】isDefaultLike存在但不为true不添加collection_sort记录, resultId={}, isDefaultLike={}, parentId={}",
toProductImageResult.getId(), toProductImageDTO.getIsDefaultLike(), toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
// designService.addCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
@@ -1425,6 +1446,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
// 更新项目更新时间
projectService.modifyProjectUpdateTime(toProductImageDTO.getProjectId());
log.info("【relight方法】relight方法执行完成, projectId={}, 生成结果数量={}", projectId, result.size());
return result;
}
@@ -1433,42 +1455,79 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<MagicToolResultVO> results = new ArrayList<>();
Set<String> collect = new HashSet<>();
taskIdList.forEach(taskId -> {
log.info("【getRelightResult方法】开始处理taskId={}", taskId);
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
if (Objects.isNull(toProductImageResult)) {
log.error("【getRelightResult方法】未找到toProductImageResult记录, taskId={}", taskId);
throw new BusinessException("source.image.does.not.exist");
}
log.info("【getRelightResult方法】找到toProductImageResult记录, id={}, taskId={}, status={}, modelName={}, isLike={}",
toProductImageResult.getId(), taskId, toProductImageResult.getStatus(),
toProductImageResult.getModelName(), toProductImageResult.getIsLike());
// 查询collection_sort记录用于追踪
QueryWrapper<CollectionSort> sortQw = new QueryWrapper<>();
sortQw.lambda().eq(CollectionSort::getRelationId, toProductImageResult.getId())
.eq(CollectionSort::getRelationType, CollectionType.RELIGHT.getValue());
List<CollectionSort> beforeSorts = collectionSortMapper.selectList(sortQw);
log.info("【getRelightResult方法】处理前collection_sort记录数={}, resultId={}", beforeSorts.size(), toProductImageResult.getId());
if (!beforeSorts.isEmpty()) {
for (CollectionSort cs : beforeSorts) {
log.info("【getRelightResult方法】处理前collection_sort记录: id={}, relationId={}, sort={}", cs.getId(), cs.getRelationId(), cs.getSort());
}
}
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
if (Objects.isNull(toProductImageRecord)) {
log.error("【getRelightResult方法】未找到toProductImageRecord记录, recordId={}", toProductImageResult.getToProductImageRecordId());
throw new BusinessException("This task does not exist.");
}
// 判断当任务从哪个模型获取结果
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName())
&& toProductImageResult.getModelName().equals("flux")) {
log.info("【getRelightResult方法】使用flux模型处理, resultId={}", toProductImageResult.getId());
Project project = projectService.getById(toProductImageResult.getProjectId());
if (Objects.isNull(project)) {
log.error("【getRelightResult方法】未找到project记录, projectId={}", toProductImageResult.getProjectId());
throw new BusinessException("unknown project");
}
String fluxResult;
if (toProductImageResult.getStatus().equals("Success") && !StringUtil.isNullOrEmpty(toProductImageResult.getUrl())) {
log.info("【getRelightResult方法】数据库中已有成功结果直接使用, resultId={}", toProductImageResult.getId());
fluxResult = toProductImageResult.getUrl();
} else {
String objectName = project.getAccountId() + "/relight_image/" + taskId + ".png";
log.info("【getRelightResult方法】调用getFluxResult获取结果, resultId={}, objectName={}", toProductImageResult.getId(), objectName);
fluxResult = generateService.getFluxResult(taskId, objectName);
log.info("【getRelightResult方法】getFluxResult返回结果, resultId={}, fluxResult={}", toProductImageResult.getId(), fluxResult);
}
if (StringUtil.isNullOrEmpty(fluxResult)) {
log.warn("【getRelightResult方法】fluxResult为null判定为失败, resultId={}, isLike={}", toProductImageResult.getId(), toProductImageResult.getIsLike());
toProductImageResult.setStatus("Fail");
toProductImageResultMapper.updateById(toProductImageResult);
sortRank(toProductImageResult);
if (toProductImageResult.getIsLike() != null && toProductImageResult.getIsLike() == 1) {
log.info("【getRelightResult方法】isLike=1准备调用sortRank删除collection_sort记录, resultId={}", toProductImageResult.getId());
sortRank(toProductImageResult);
} else {
log.info("【getRelightResult方法】isLike不等于1不删除collection_sort记录, resultId={}, isLike={}", toProductImageResult.getId(), toProductImageResult.getIsLike());
}
results.add(new MagicToolResultVO(taskId, "Fail"));
} else if (fluxResult.equals("Fail") || fluxResult.equals("Pending")) {
log.warn("【getRelightResult方法】fluxResult为{},判定为失败/待处理, resultId={}, isLike={}", fluxResult, toProductImageResult.getId(), toProductImageResult.getIsLike());
toProductImageResult.setStatus(fluxResult);
toProductImageResultMapper.updateById(toProductImageResult);
sortRank(toProductImageResult);
if (toProductImageResult.getIsLike() != null && toProductImageResult.getIsLike() == 1) {
log.info("【getRelightResult方法】isLike=1准备调用sortRank删除collection_sort记录, resultId={}", toProductImageResult.getId());
sortRank(toProductImageResult);
} else {
log.info("【getRelightResult方法】isLike不等于1不删除collection_sort记录, resultId={}, isLike={}", toProductImageResult.getId(), toProductImageResult.getIsLike());
}
results.add(new MagicToolResultVO(taskId, fluxResult));
} else {
log.info("【getRelightResult方法】fluxResult有效调用processFluxResult处理成功结果, resultId={}", toProductImageResult.getId());
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
// 扣积分
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
@@ -1479,9 +1538,21 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
creditsService.deleteCreditsDeduction(project.getAccountId(), taskId);
}
// 处理后查询collection_sort记录用于追踪
List<CollectionSort> afterSorts = collectionSortMapper.selectList(sortQw);
log.info("【getRelightResult方法】处理后collection_sort记录数={}, resultId={}", afterSorts.size(), toProductImageResult.getId());
if (!afterSorts.isEmpty()) {
for (CollectionSort cs : afterSorts) {
log.info("【getRelightResult方法】处理后collection_sort记录: id={}, relationId={}, sort={}", cs.getId(), cs.getRelationId(), cs.getSort());
}
} else if (!beforeSorts.isEmpty()) {
log.warn("【getRelightResult方法】collection_sort记录被删除了! resultId={}, 处理前记录数={}, 处理后记录数=0", toProductImageResult.getId(), beforeSorts.size());
}
return;
}
log.info("【getRelightResult方法】非flux模型从Redis获取结果, resultId={}", toProductImageResult.getId());
String key = relightResultKey + ":" + taskId;
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
@@ -1513,7 +1584,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
if (!StringUtil.isNullOrEmpty(magicToolResultVO.getStatus())) collect.add(magicToolResultVO.getStatus());
results.add(magicToolResultVO);
log.info("【getRelightResult方法】taskId处理完成, taskId={}, 返回结果status={}", taskId, magicToolResultVO.getStatus());
});
log.info("【getRelightResult方法】所有taskId处理完成, 返回结果数={}", results.size());
return results;
}
@@ -2203,10 +2276,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
childCollectionQw.lambda().orderByAsc(CollectionSort::getSort);
List<CollectionSort> childSortList = collectionSortMapper.selectList(childCollectionQw);
List<AllCollectionVO> childList = new ArrayList<>();
// 收集需要删除的失败记录ID用于后续统一清理并重新排序
List<Long> failedSortIds = new ArrayList<>();
for (CollectionSort userLikeSort : childSortList) {
if (userLikeSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())) {
failedSortIds.add(userLikeSort.getId());
log.info("【获取内容】TO_PRODUCT_IMAGE结果失败relationId={}即将从collection_sort中删除", userLikeSort.getRelationId());
continue;
}
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
@@ -2238,6 +2315,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
} else if (userLikeSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())) {
failedSortIds.add(userLikeSort.getId());
log.info("【获取内容】RELIGHT结果失败relationId={}即将从collection_sort中删除", userLikeSort.getRelationId());
continue;
}
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
@@ -2269,6 +2348,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
} else if (userLikeSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
PoseTransformation item = poseTransformationMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(item.getTaskStatus(), item.getCreateTime())) {
failedSortIds.add(userLikeSort.getId());
log.info("【获取内容】POSE_TRANSFORM结果失败relationId={}即将从collection_sort中删除", userLikeSort.getRelationId());
continue;
}
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
@@ -2293,6 +2374,114 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
childList.add(poseTransformationVO);
}
}
// 统一处理失败的记录从collection_sort表中删除失败的记录并重新排序
if (CollectionUtil.isNotEmpty(failedSortIds)) {
Long parentId = collectionSort.getId();
Long projectId = projectDTO.getId();
log.info("【获取内容】检测到{}条失败记录需要清理parentId={}, projectId={}", failedSortIds.size(), parentId, projectId);
for (Long failedSortId : failedSortIds) {
CollectionSort failedRecord = collectionSortMapper.selectById(failedSortId);
if (failedRecord != null) {
String relationType = failedRecord.getRelationType();
Long relationId = failedRecord.getRelationId();
collectionSortService.deleteCollectionSort(relationId, relationType, projectId, parentId);
log.info("【获取内容】已删除失败记录relationId={}, relationType={}", relationId, relationType);
}
}
// 重新查询子列表,获取更新后的排序
childSortList = collectionSortMapper.selectList(childCollectionQw);
// 重新构建childList使用更新后的sort值
childList = new ArrayList<>();
for (CollectionSort userLikeSort : childSortList) {
if (userLikeSort.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())) {
continue;
}
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
ToProductImageResultVO toProductImageResultVO = CopyUtil.copyObject(toProductImageResult, ToProductImageResultVO.class);
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
if (Objects.isNull(toProductImageRecord)) {
continue;
}
toProductImageResultVO.setPrompt(toProductImageRecord.getPrompt());
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductElement.getUrl()));
} else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(tDesignPythonOutfit.getDesignUrl()));
} else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductImageResult1.getUrl()));
}
toProductImageResultVO.setCollectionType(CollectionType.TO_PRODUCT_IMAGE.getValue());
toProductImageResultVO.setSort(userLikeSort.getSort());
toProductImageResultVO.setUserLikeSortId(userLikeSort.getId());
toProductImageResultVO.setRelationType(userLikeSort.getRelationType());
toProductImageResultVO.setParentId(userLikeSort.getParentId());
childList.add(toProductImageResultVO);
} else if (userLikeSort.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(toProductImageResult.getStatus(), toProductImageResult.getCreateTime())) {
continue;
}
toProductImageResult.setUrl(getMinioUrl(toProductImageResult.getUrl()));
ToProductImageResultVO toProductImageResultVO = CopyUtil.copyObject(toProductImageResult, ToProductImageResultVO.class);
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
if (Objects.isNull(toProductImageRecord)) {
continue;
}
toProductImageResultVO.setPrompt(toProductImageRecord.getPrompt());
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductElement.getUrl()));
} else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(tDesignPythonOutfit.getDesignUrl()));
} else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(getMinioUrl(toProductImageResult1.getUrl()));
}
toProductImageResultVO.setCollectionType(CollectionType.RELIGHT.getValue());
toProductImageResultVO.setSort(userLikeSort.getSort());
toProductImageResultVO.setUserLikeSortId(userLikeSort.getId());
toProductImageResultVO.setRelationType(userLikeSort.getRelationType());
toProductImageResultVO.setParentId(userLikeSort.getParentId());
childList.add(toProductImageResultVO);
} else if (userLikeSort.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
PoseTransformation item = poseTransformationMapper.selectById(userLikeSort.getRelationId());
if (isGenerateTaskFailed(item.getTaskStatus(), item.getCreateTime())) {
continue;
}
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
poseTransformationVO.setId(item.getId());
poseTransformationVO.setTaskId(item.getUniqueId());
poseTransformationVO.setProductImage(getMinioUrl(item.getProductImage()));
poseTransformationVO.setLastFrameProductImage(getMinioUrl(item.getLastFrameProductImage()));
poseTransformationVO.setPrompt(item.getPrompt());
poseTransformationVO.setGifUrl(getMinioUrl(item.getGifUrl()));
poseTransformationVO.setVideoUrl(getMinioUrl(item.getVideoUrl()));
poseTransformationVO.setFirstFrameUrl(getMinioUrl(item.getFirstFrameUrl()));
poseTransformationVO.setIsLiked(item.getIsLiked());
poseTransformationVO.setCollectionType(CollectionType.POSE_TRANSFORM.getValue());
poseTransformationVO.setSort(userLikeSort.getSort());
poseTransformationVO.setUserLikeSortId(userLikeSort.getId());
poseTransformationVO.setRelationType(userLikeSort.getRelationType());
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
poseTransformationVO.setParentId(userLikeSort.getParentId());
poseTransformationVO.setModelName(item.getModelName());
poseTransformationVO.setPoseId(item.getPoseId());
poseTransformationVO.setStatus(item.getTaskStatus());
childList.add(poseTransformationVO);
}
}
log.info("【获取内容】失败记录清理完成重新排序后childList.size={}", childList.size());
}
o.setChildList(childList);
list.add(o);