From 72602eb245054d9b36081d7851eee2cf105bca8d Mon Sep 17 00:00:00 2001 From: xupei Date: Fri, 10 Apr 2026 22:51:00 +0800 Subject: [PATCH] BUGFIX --- .../controller/SavedCollectionController.java | 47 +----------- .../impl/UserLikeGroupServiceImpl.java | 71 +------------------ 2 files changed, 2 insertions(+), 116 deletions(-) diff --git a/src/main/java/com/ai/da/controller/SavedCollectionController.java b/src/main/java/com/ai/da/controller/SavedCollectionController.java index 94c247f9..29a4b80f 100644 --- a/src/main/java/com/ai/da/controller/SavedCollectionController.java +++ b/src/main/java/com/ai/da/controller/SavedCollectionController.java @@ -253,32 +253,7 @@ public class SavedCollectionController { @Operation(summary = "relight") @PostMapping("/relight") public Response> relight(@Valid @RequestBody ToProductImageDTO toProductImageDTO) { - log.info("【relight请求】收到relight请求, projectId={}, isDefaultLike={}, taskCount={}", - toProductImageDTO.getProjectId(), - toProductImageDTO.getIsDefaultLike(), - toProductImageDTO.getToProductImageVOList() != null ? toProductImageDTO.getToProductImageVOList().size() : 0); - long startTime = System.currentTimeMillis(); - List 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); + return Response.success(userLikeGroupService.relight(toProductImageDTO)); } @Operation(summary = "转relight元素") @@ -290,27 +265,7 @@ public class SavedCollectionController { @Operation(summary = "获取relight结果") @PostMapping("/relightResult") public Response> getRelightResult(@Valid @RequestBody List taskIdList) { - log.info("【getRelightResult请求】收到获取relight结果请求, taskIdList={}", taskIdList); - long startTime = System.currentTimeMillis(); List 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); } diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index 43a99362..b1472ff3 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -1305,7 +1305,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl result = new ArrayList<>(); @@ -1353,30 +1352,20 @@ public class UserLikeGroupServiceImpl extends ServiceImpl results = new ArrayList<>(); Set collect = new HashSet<>(); taskIdList.forEach(taskId -> { - log.info("【getRelightResult方法】开始处理taskId={}", taskId); QueryWrapper 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 sortQw = new QueryWrapper<>(); - sortQw.lambda().eq(CollectionSort::getRelationId, toProductImageResult.getId()) - .eq(CollectionSort::getRelationType, CollectionType.RELIGHT.getValue()); - List 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); 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); - if (fluxResult.equals("Fail") && toProductImageResult.getIsLike() != null && toProductImageResult.getIsLike() == 1) { - log.info("【getRelightResult方法】isLike=1,准备调用sortRank删除collection_sort记录, resultId={}", toProductImageResult.getId()); + if (toProductImageResult.getIsLike() != null && toProductImageResult.getIsLike() == 1) { 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); @@ -1538,21 +1483,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl 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())) { @@ -1584,9 +1517,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl