Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge
This commit is contained in:
@@ -1950,137 +1950,133 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
moduleChooseVO.setSketchBoard(list);
|
||||
}else if (module.equals(Module.design.name())) {
|
||||
DesignModuleChooseVO vo = new DesignModuleChooseVO();
|
||||
QueryWrapper<CollectionSort> userLikeSortQueryWrapper = new QueryWrapper<>();
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getProjectId, projectDTO.getId());
|
||||
userLikeSortQueryWrapper.lambda().isNull(CollectionSort::getParentId);
|
||||
userLikeSortQueryWrapper.lambda().eq(CollectionSort::getRelationType, CollectionType.DESIGN.getValue());
|
||||
userLikeSortQueryWrapper.lambda().orderByAsc(CollectionSort::getSort);
|
||||
List<CollectionSort> userLikeSortList = collectionSortMapper.selectList(userLikeSortQueryWrapper);
|
||||
|
||||
if (CollectionUtils.isEmpty(userLikeSortList)) {
|
||||
// 使用批量查询获取design模块的所有数据
|
||||
List<String> relationTypes = Arrays.asList(
|
||||
CollectionType.DESIGN.getValue(),
|
||||
CollectionType.TO_PRODUCT_IMAGE.getValue(),
|
||||
CollectionType.RELIGHT.getValue(),
|
||||
CollectionType.POSE_TRANSFORM.getValue()
|
||||
);
|
||||
|
||||
List<Map<String, Object>> moduleContentList = userLikeGroupMapper.getModuleContentBatch(
|
||||
null, projectDTO.getId(), relationTypes);
|
||||
|
||||
if (CollectionUtils.isEmpty(moduleContentList)) {
|
||||
moduleChooseVO.setDesign(vo);
|
||||
}else {
|
||||
} else {
|
||||
// 按parent_id分组处理数据
|
||||
Map<Long, List<Map<String, Object>>> groupedByParent = moduleContentList.stream()
|
||||
.collect(Collectors.groupingBy(item -> {
|
||||
Object parentId = item.get("parent_id");
|
||||
return parentId == null ? 0L : ((Number) parentId).longValue();
|
||||
}));
|
||||
|
||||
List<AllCollectionVO> list = new ArrayList<>();
|
||||
|
||||
for (CollectionSort collectionSort : userLikeSortList) {
|
||||
UserLike userLike = userLikeMapper.selectById(collectionSort.getRelationId());
|
||||
UserLikeVO o = CopyUtil.copyObject(userLike, UserLikeVO.class);
|
||||
TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId());
|
||||
o.setUrl(tDesignPythonOutfit1.getDesignUrl());
|
||||
if (o.getUrl().contains("/")) {
|
||||
int index = o.getUrl().lastIndexOf("/");
|
||||
o.setPictureName(o.getUrl().substring(index + 1));
|
||||
}
|
||||
o.setDesignOutfitUrl(getMinioUrl(o.getUrl()));
|
||||
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
|
||||
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
|
||||
if (CollectionUtil.isNotEmpty(tDesignPythonOutfits)) {
|
||||
TDesignPythonOutfit tDesignPythonOutfit = tDesignPythonOutfits.get(0);
|
||||
o.setDesignOutfitId(tDesignPythonOutfit.getId());
|
||||
}
|
||||
|
||||
o.setSort(collectionSort.getSort());
|
||||
o.setUserLikeSortId(collectionSort.getId());
|
||||
o.setRelationType(collectionSort.getRelationType());
|
||||
o.setCollectionType(CollectionType.DESIGN.getValue());
|
||||
o.setResultType(CollectionType.DESIGN.getValue());
|
||||
QueryWrapper<CollectionSort> childCollectionQw = new QueryWrapper<>();
|
||||
childCollectionQw.lambda().eq(CollectionSort::getParentId, collectionSort.getId());
|
||||
childCollectionQw.lambda().orderByAsc(CollectionSort::getSort);
|
||||
List<CollectionSort> childSortList = collectionSortMapper.selectList(childCollectionQw);
|
||||
List<AllCollectionVO> 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)) {
|
||||
log.warn("toProductRecord不存在,projectId:{}, toProductImageResultId:{}", projectDTO.getId(), toProductImageResult.getId());
|
||||
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)) {
|
||||
log.warn("toProductRecord不存在,projectId:{}, toProductImageResultId:{}", projectDTO.getId(), toProductImageResult.getId());
|
||||
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.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);
|
||||
// 处理顶级design项目(parent_id为null的)
|
||||
List<Map<String, Object>> topLevelDesigns = groupedByParent.get(0L);
|
||||
if (topLevelDesigns != null) {
|
||||
for (Map<String, Object> designData : topLevelDesigns) {
|
||||
if (!CollectionType.DESIGN.getValue().equals(designData.get("relation_type"))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
o.setChildList(childList);
|
||||
|
||||
list.add(o);
|
||||
UserLikeVO o = new UserLikeVO();
|
||||
o.setId(((Number) designData.get("user_like_id")).longValue());
|
||||
o.setDesignItemId(((Number) designData.get("design_item_id")).longValue());
|
||||
o.setDesignOutfitId(((Number) designData.get("design_outfit_id")).longValue());
|
||||
|
||||
String designUrl = (String) designData.get("design_url");
|
||||
o.setUrl(designUrl);
|
||||
if (designUrl != null && designUrl.contains("/")) {
|
||||
int index = designUrl.lastIndexOf("/");
|
||||
o.setPictureName(designUrl.substring(index + 1));
|
||||
}
|
||||
o.setDesignOutfitUrl(getMinioUrl(designUrl));
|
||||
|
||||
o.setSort(((Number) designData.get("sort")).intValue());
|
||||
o.setUserLikeSortId(((Number) designData.get("sort_id")).longValue());
|
||||
o.setRelationType((String) designData.get("relation_type"));
|
||||
o.setCollectionType(CollectionType.DESIGN.getValue());
|
||||
o.setResultType(CollectionType.DESIGN.getValue());
|
||||
|
||||
// 处理子项目
|
||||
List<AllCollectionVO> childList = new ArrayList<>();
|
||||
Long parentSortId = ((Number) designData.get("sort_id")).longValue();
|
||||
List<Map<String, Object>> childItems = groupedByParent.get(parentSortId);
|
||||
|
||||
if (childItems != null) {
|
||||
for (Map<String, Object> childData : childItems) {
|
||||
String relationType = (String) childData.get("relation_type");
|
||||
|
||||
if (CollectionType.TO_PRODUCT_IMAGE.getValue().equals(relationType) ||
|
||||
CollectionType.RELIGHT.getValue().equals(relationType)) {
|
||||
|
||||
// 检查任务状态
|
||||
String status = (String) childData.get("result_status");
|
||||
Object createTimeObj = childData.get("result_create_time");
|
||||
LocalDateTime createTime = createTimeObj != null ?
|
||||
((java.sql.Timestamp) createTimeObj).toLocalDateTime() : null;
|
||||
if (isGenerateTaskFailed(status, createTime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ToProductImageResultVO toProductImageResultVO = new ToProductImageResultVO();
|
||||
toProductImageResultVO.setId(((Number) childData.get("to_product_result_id")).longValue());
|
||||
toProductImageResultVO.setUrl(getMinioUrl((String) childData.get("result_url")));
|
||||
toProductImageResultVO.setElementType((String) childData.get("element_type"));
|
||||
toProductImageResultVO.setElementId(((Number) childData.get("element_id")).longValue());
|
||||
toProductImageResultVO.setPrompt((String) childData.get("prompt"));
|
||||
|
||||
// 设置sourceUrl
|
||||
String elementType = (String) childData.get("element_type");
|
||||
if ("ProductElement".equals(elementType)) {
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl((String) childData.get("element_url")));
|
||||
} else if ("DesignOutfit".equals(elementType)) {
|
||||
toProductImageResultVO.setSourceUrl(getMinioUrl((String) childData.get("design_url")));
|
||||
}
|
||||
|
||||
toProductImageResultVO.setSort(((Number) childData.get("sort")).intValue());
|
||||
toProductImageResultVO.setUserLikeSortId(((Number) childData.get("sort_id")).longValue());
|
||||
toProductImageResultVO.setRelationType(relationType);
|
||||
toProductImageResultVO.setParentId(((Number) childData.get("parent_id")).longValue());
|
||||
childList.add(toProductImageResultVO);
|
||||
|
||||
} else if (CollectionType.POSE_TRANSFORM.getValue().equals(relationType)) {
|
||||
// 检查任务状态
|
||||
String status = (String) childData.get("pose_status");
|
||||
Object createTimeObj = childData.get("pose_create_time");
|
||||
LocalDateTime createTime = createTimeObj != null ?
|
||||
((java.sql.Timestamp) createTimeObj).toLocalDateTime() : null;
|
||||
if (isGenerateTaskFailed(status, createTime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
|
||||
poseTransformationVO.setId(((Number) childData.get("pose_id")).longValue());
|
||||
poseTransformationVO.setTaskId((String) childData.get("pose_unique_id"));
|
||||
poseTransformationVO.setProductImage(getMinioUrl((String) childData.get("pose_product_image")));
|
||||
poseTransformationVO.setGifUrl(getMinioUrl((String) childData.get("pose_gif_url")));
|
||||
poseTransformationVO.setVideoUrl(getMinioUrl((String) childData.get("pose_video_url")));
|
||||
poseTransformationVO.setFirstFrameUrl(getMinioUrl((String) childData.get("pose_first_frame_url")));
|
||||
poseTransformationVO.setIsLiked(((Number) childData.get("pose_is_liked")).byteValue());
|
||||
poseTransformationVO.setCollectionType(CollectionType.POSE_TRANSFORM.getValue());
|
||||
poseTransformationVO.setSort(((Number) childData.get("sort")).intValue());
|
||||
poseTransformationVO.setUserLikeSortId(((Number) childData.get("sort_id")).longValue());
|
||||
poseTransformationVO.setRelationType(relationType);
|
||||
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
||||
poseTransformationVO.setParentId(((Number) childData.get("parent_id")).longValue());
|
||||
poseTransformationVO.setModelName((String) childData.get("pose_model_name"));
|
||||
poseTransformationVO.setPoseId(((Number) childData.get("pose_pose_id")).intValue());
|
||||
poseTransformationVO.setStatus(status);
|
||||
childList.add(poseTransformationVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
o.setChildList(childList);
|
||||
list.add(o);
|
||||
}
|
||||
}
|
||||
vo.setUserLikeDetails(list);
|
||||
}
|
||||
@@ -2126,6 +2122,28 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
// 准备返回对象
|
||||
ToProductOrRelightVO resultVO = new ToProductOrRelightVO();
|
||||
|
||||
// 批量查询ToProductImageRecord数据
|
||||
List<Long> recordIds = allResults.stream()
|
||||
.map(ToProductImageResult::getToProductImageRecordId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<Long, String> recordPromptMap = new HashMap<>();
|
||||
if (!recordIds.isEmpty()) {
|
||||
List<Map<String, Object>> recordData = userLikeGroupMapper.getToProductImageRecordBatch(recordIds);
|
||||
recordPromptMap = recordData.stream()
|
||||
.collect(Collectors.toMap(
|
||||
data -> ((Number) data.get("record_id")).longValue(),
|
||||
data -> {
|
||||
String prompt = (String) data.get("prompt");
|
||||
return prompt != null ? prompt : ""; // 提供默认值
|
||||
},
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// 处理URL转换和分类
|
||||
List<ToProductImageResultVO> likedList = new ArrayList<>();
|
||||
List<ToProductImageResultVO> normalList = new ArrayList<>();
|
||||
@@ -2137,10 +2155,10 @@ 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());
|
||||
// 设置prompt(使用批量查询结果)
|
||||
if (result.getToProductImageRecordId() != null) {
|
||||
String prompt = recordPromptMap.get(result.getToProductImageRecordId());
|
||||
vo.setPrompt(prompt);
|
||||
}
|
||||
vo.setParentId(getUnlikedResultParentId(result, null));
|
||||
// 按isLike分类
|
||||
@@ -2196,12 +2214,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
.collect(Collectors.toList());
|
||||
List<CollectionElementVO> list = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(collectionElements)) {
|
||||
// 批量查询CollectionElementRelModel数据
|
||||
List<Long> collectionElementIds = collectionElements.stream()
|
||||
.map(CollectionElement::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<CollectionElementRelModel> relModels = userLikeGroupMapper.getCollectionElementRelModelBatch(collectionElementIds);
|
||||
Map<Long, CollectionElementRelModel> relModelMap = relModels.stream()
|
||||
.collect(Collectors.toMap(CollectionElementRelModel::getCollectionElementId, rel -> rel));
|
||||
|
||||
for (CollectionElement collectionElement : collectionElements) {
|
||||
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
|
||||
CollectionElementRelModel relModel = getCollectionElementRelModel(collectionElementVO.getId());
|
||||
CollectionElementRelModel relModel = relModelMap.get(collectionElementVO.getId());
|
||||
collectionElementVO.setUrl(getMinioUrl(collectionElementVO.getUrl()));
|
||||
collectionElementVO.setMannequinRelationId(relModel.getRelationId());
|
||||
collectionElementVO.setMannequinRelationType(relModel.getRelationType());
|
||||
if (relModel != null) {
|
||||
collectionElementVO.setMannequinRelationId(relModel.getRelationId());
|
||||
collectionElementVO.setMannequinRelationType(relModel.getRelationType());
|
||||
}
|
||||
collectionElementVO.setCollectionId(collectionElement.getId());
|
||||
list.add(collectionElementVO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user