TASK: 生成项目参数 参数变更
This commit is contained in:
@@ -4402,7 +4402,7 @@ public class PythonService {
|
|||||||
throw new BusinessException("poseTransferBatch.interface.exception");
|
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getProjectParam(String prompt, String fileUrl, List<String> imageUrlList) {
|
public JSONObject getProjectParam(String prompt, String fileUrl, List<String> imageUrlList, String process) {
|
||||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
.connectTimeout(30, TimeUnit.SECONDS)
|
||||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||||
@@ -4412,6 +4412,7 @@ public class PythonService {
|
|||||||
MediaType mediaType = MediaType.parse("application/json");
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
Map<String, Object> content = Maps.newHashMap();
|
Map<String, Object> content = Maps.newHashMap();
|
||||||
content.put("prompt", prompt);
|
content.put("prompt", prompt);
|
||||||
|
content.put("process", process);
|
||||||
content.put("image_list", !CollectionUtils.isEmpty(imageUrlList) ? imageUrlList : new ArrayList<>());
|
content.put("image_list", !CollectionUtils.isEmpty(imageUrlList) ? imageUrlList : new ArrayList<>());
|
||||||
content.put("file_list", !StringUtils.isEmpty(fileUrl) ? Collections.singletonList(fileUrl) : new ArrayList<>());
|
content.put("file_list", !StringUtils.isEmpty(fileUrl) ? Collections.singletonList(fileUrl) : new ArrayList<>());
|
||||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -1220,15 +1221,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
if (!StringUtil.isNullOrEmpty(resultJson)){
|
if (!StringUtil.isNullOrEmpty(resultJson)){
|
||||||
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
||||||
if (poseTransformationVO.getStatus().equals("Success")){
|
if (poseTransformationVO.getStatus().equals("Success")){
|
||||||
if (!poseTransformationVO.getGifUrl().equals("None")){
|
// 处理各种URL
|
||||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||||
}
|
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
if (!poseTransformationVO.getVideoUrl().equals("None")){
|
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
||||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
}
|
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
||||||
if (!poseTransformationVO.getFirstFrameUrl().equals("None")){
|
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
||||||
return poseTransformationVO;
|
return poseTransformationVO;
|
||||||
@@ -1242,50 +1241,70 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
List<PoseTransformationVO> vos = new ArrayList<>();
|
List<PoseTransformationVO> vos = new ArrayList<>();
|
||||||
// if (poseTransformations != null && poseTransformations.size() > 1){
|
// if (poseTransformations != null && poseTransformations.size() > 1){
|
||||||
if (!CollectionUtils.isEmpty(poseTransformations)){
|
if (!CollectionUtils.isEmpty(poseTransformations)){
|
||||||
poseTransformations.forEach(item -> {
|
for (PoseTransformation item : poseTransformations) {
|
||||||
String taskId = item.getUniqueId();
|
String taskId = item.getUniqueId();
|
||||||
String key = generateResultKey + ":" + taskId;
|
String key = generateResultKey + ":" + taskId;
|
||||||
String resultJson = redisUtil.getFromString(key);
|
String resultJson = redisUtil.getFromString(key);
|
||||||
|
|
||||||
|
PoseTransformationVO poseTransformationVO;
|
||||||
|
|
||||||
if (!StringUtil.isNullOrEmpty(resultJson)) {
|
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.setId(item.getId());
|
||||||
poseTransformationVO.setIsLiked(item.getIsLiked());
|
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")) {
|
if ("Success".equals(poseTransformationVO.getStatus())) {
|
||||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
poseTransformationVO.setProductImage(
|
||||||
}
|
minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||||
if (!poseTransformationVO.getVideoUrl().equals("None")) {
|
|
||||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
// 处理各种URL
|
||||||
}
|
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||||
if (!poseTransformationVO.getFirstFrameUrl().equals("None")) {
|
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), 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);
|
vos.add(poseTransformationVO);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
PoseTransformationVO poseTransformationVO = CopyUtil.copyObject(item, PoseTransformationVO.class);
|
// 处理Redis中没有缓存的情况
|
||||||
poseTransformationVO.setTaskId(item.getUniqueId());
|
poseTransformationVO = CopyUtil.copyObject(item, PoseTransformationVO.class);
|
||||||
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
// todo 面对没有生成成功的情况 如何处理?
|
||||||
if (!StringUtil.isNullOrEmpty(poseTransformationVO.getGifUrl())) {
|
if (StringUtil.isNullOrEmpty(item.getVideoUrl())){
|
||||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
continue;
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
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);
|
vos.add(poseTransformationVO);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return vos;
|
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){
|
public Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId, Long collectionSortParentId){
|
||||||
PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId);
|
PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId);
|
||||||
Long collectionSortId = null;
|
Long collectionSortId = null;
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ public class LLMServiceImpl implements LLMService {
|
|||||||
@Override
|
@Override
|
||||||
public Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList) {
|
public Long chatCreateProject(String prompt, String process, String fileUrl, List<String> imageUrlList) {
|
||||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||||
JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList);
|
JSONObject jsonObject = pythonService.getProjectParam(prompt, fileUrl, imageUrlList, process);
|
||||||
JSONObject data = jsonObject.getJSONObject("data");
|
JSONObject data = jsonObject.getJSONObject("data");
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user