TASK: 生成项目参数 参数变更
This commit is contained in:
@@ -60,6 +60,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -1220,15 +1221,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
if (!StringUtil.isNullOrEmpty(resultJson)){
|
||||
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
||||
if (poseTransformationVO.getStatus().equals("Success")){
|
||||
if (!poseTransformationVO.getGifUrl().equals("None")){
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!poseTransformationVO.getVideoUrl().equals("None")){
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!poseTransformationVO.getFirstFrameUrl().equals("None")){
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
// 处理各种URL
|
||||
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
}
|
||||
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
||||
return poseTransformationVO;
|
||||
@@ -1242,50 +1241,70 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
List<PoseTransformationVO> vos = new ArrayList<>();
|
||||
// if (poseTransformations != null && poseTransformations.size() > 1){
|
||||
if (!CollectionUtils.isEmpty(poseTransformations)){
|
||||
poseTransformations.forEach(item -> {
|
||||
for (PoseTransformation item : poseTransformations) {
|
||||
String taskId = item.getUniqueId();
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
String resultJson = redisUtil.getFromString(key);
|
||||
|
||||
PoseTransformationVO poseTransformationVO;
|
||||
|
||||
if (!StringUtil.isNullOrEmpty(resultJson)) {
|
||||
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
||||
// 从Redis获取并转换数据
|
||||
poseTransformationVO = new Gson().fromJson(resultJson, PoseTransformationVO.class);
|
||||
poseTransformationVO.setId(item.getId());
|
||||
poseTransformationVO.setIsLiked(item.getIsLiked());
|
||||
if (poseTransformationVO.getStatus().equals("Success")) {
|
||||
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
if (!poseTransformationVO.getGifUrl().equals("None")) {
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!poseTransformationVO.getVideoUrl().equals("None")) {
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!poseTransformationVO.getFirstFrameUrl().equals("None")) {
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
|
||||
// 处理成功状态的数据
|
||||
if ("Success".equals(poseTransformationVO.getStatus())) {
|
||||
poseTransformationVO.setProductImage(
|
||||
minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
|
||||
// 处理各种URL
|
||||
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
}
|
||||
if (!poseTransformationVO.getStatus().equals("Invalid") && !poseTransformationVO.getStatus().equals("Failed")) {
|
||||
|
||||
// 添加有效数据到结果列表
|
||||
if (!"Invalid".equals(poseTransformationVO.getStatus()) && !"Failed".equals(poseTransformationVO.getStatus())) {
|
||||
vos.add(poseTransformationVO);
|
||||
}
|
||||
}else {
|
||||
PoseTransformationVO poseTransformationVO = CopyUtil.copyObject(item, PoseTransformationVO.class);
|
||||
poseTransformationVO.setTaskId(item.getUniqueId());
|
||||
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
if (!StringUtil.isNullOrEmpty(poseTransformationVO.getGifUrl())) {
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(poseTransformationVO.getVideoUrl())) {
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(poseTransformationVO.getFirstFrameUrl())) {
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
} else {
|
||||
// 处理Redis中没有缓存的情况
|
||||
poseTransformationVO = CopyUtil.copyObject(item, PoseTransformationVO.class);
|
||||
// todo 面对没有生成成功的情况 如何处理?
|
||||
if (StringUtil.isNullOrEmpty(item.getVideoUrl())){
|
||||
continue;
|
||||
}
|
||||
poseTransformationVO.setTaskId(taskId);
|
||||
poseTransformationVO.setProductImage(
|
||||
minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
|
||||
// 处理各种URL
|
||||
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||
|
||||
vos.add(poseTransformationVO);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
// 辅助方法:处理URL
|
||||
private void processUrl(String url, Consumer<String> processor) {
|
||||
if (!StringUtil.isNullOrEmpty(url) && !"None".equals(url)) {
|
||||
processor.accept(url);
|
||||
}
|
||||
}
|
||||
|
||||
public Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId, Long collectionSortParentId){
|
||||
PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId);
|
||||
Long collectionSortId = null;
|
||||
|
||||
@@ -515,7 +515,7 @@ public class LLMServiceImpl implements LLMService {
|
||||
@Override
|
||||
public Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList);
|
||||
JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList, process);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
Project project = new Project();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
Reference in New Issue
Block a user