TASK:模块化;
This commit is contained in:
@@ -63,4 +63,6 @@ public interface GenerateService extends IService<Generate> {
|
||||
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
||||
|
||||
List<Map<String, String>> getAllPose();
|
||||
|
||||
void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress);
|
||||
}
|
||||
|
||||
@@ -1798,21 +1798,21 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
public String designCloud(CloudTaskDTO cloudTaskDTO) {
|
||||
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
||||
Long projectId = cloudTaskDTO.getProjectId();
|
||||
Project project = projectService.getById(projectId);
|
||||
project.setParentId(projectId);
|
||||
project.setId(null);
|
||||
project.setName(project.getName() + "_cloud");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
project.setCreateTime(now);
|
||||
project.setUpdateTime(now);
|
||||
projectService.getBaseMapper().insert(project);
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceService.getById(workspaceId);
|
||||
workspace.setProjectId(project.getId());
|
||||
workspace.setId(null);
|
||||
workspaceService.getBaseMapper().insert(workspace);
|
||||
// Project project = projectService.getById(projectId);
|
||||
// project.setParentId(projectId);
|
||||
// project.setId(null);
|
||||
// project.setName(project.getName() + "_cloud");
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// project.setCreateTime(now);
|
||||
// project.setUpdateTime(now);
|
||||
// projectService.getBaseMapper().insert(project);
|
||||
// Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
// Workspace workspace = workspaceService.getById(workspaceId);
|
||||
// workspace.setProjectId(project.getId());
|
||||
// workspace.setId(null);
|
||||
// workspaceService.getBaseMapper().insert(workspace);
|
||||
|
||||
DesignCollectionDTO designDTO = transDesignParam(projectId, project.getId());
|
||||
DesignCollectionDTO designDTO = transDesignParam(projectId);
|
||||
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||
|
||||
@@ -1820,7 +1820,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||
|
||||
//design
|
||||
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, project.getId());
|
||||
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
|
||||
return taskId;
|
||||
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
||||
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||
@@ -2116,7 +2116,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
private DesignCollectionDTO transDesignParam(Long projectId, Long projectIdNew) {
|
||||
private DesignCollectionDTO transDesignParam(Long projectId) {
|
||||
DesignCollectionDTO designCollectionDTO = new DesignCollectionDTO();
|
||||
List<CollectionElement> collectionElementList = collectionElementService.getByProjectId(projectId);
|
||||
if (CollectionUtil.isNotEmpty(collectionElementList)) {
|
||||
@@ -2125,13 +2125,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<DesignCollectionElementDTO> moodBoards = new ArrayList<>();
|
||||
List<CollectionElement> moodboardList = groupedMap.get("Moodboard");
|
||||
for (CollectionElement collectionElement : moodboardList) {
|
||||
collectionElement.setProjectId(projectIdNew);
|
||||
collectionElement.setCollectionId(null);
|
||||
Date date = new Date();
|
||||
collectionElement.setCreateDate(date);
|
||||
collectionElement.setUpdateDate(date);
|
||||
collectionElement.setId(null);
|
||||
collectionElementService.getBaseMapper().insert(collectionElement);
|
||||
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
|
||||
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId()));
|
||||
@@ -2150,13 +2143,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<DesignCollectionPrintElementDTO> printBoards = new ArrayList<>();
|
||||
List<CollectionElement> printBoardList = groupedMap.get("Printboard");
|
||||
for (CollectionElement collectionElement : printBoardList) {
|
||||
collectionElement.setProjectId(projectIdNew);
|
||||
collectionElement.setCollectionId(null);
|
||||
Date date = new Date();
|
||||
collectionElement.setCreateDate(date);
|
||||
collectionElement.setUpdateDate(date);
|
||||
collectionElement.setId(null);
|
||||
collectionElementService.getBaseMapper().insert(collectionElement);
|
||||
DesignCollectionPrintElementDTO dto = new DesignCollectionPrintElementDTO();
|
||||
dto.setId(collectionElement.getId());
|
||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
@@ -2170,13 +2156,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<CollectionColorDTO> colorBoards = new ArrayList<>();
|
||||
List<CollectionElement> colorBoardList = groupedMap.get("Colorboard");
|
||||
for (CollectionElement collectionElement : colorBoardList) {
|
||||
collectionElement.setProjectId(projectIdNew);
|
||||
collectionElement.setCollectionId(null);
|
||||
Date date = new Date();
|
||||
collectionElement.setCreateDate(date);
|
||||
collectionElement.setUpdateDate(date);
|
||||
collectionElement.setId(null);
|
||||
collectionElementService.getBaseMapper().insert(collectionElement);
|
||||
CollectionColorDTO dto = new CollectionColorDTO();
|
||||
String name = collectionElement.getName();
|
||||
if (name.contains("_")) {
|
||||
@@ -2199,13 +2178,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
||||
List<CollectionElement> sketchBoardList = groupedMap.get("Sketchboard");
|
||||
for (CollectionElement collectionElement : sketchBoardList) {
|
||||
collectionElement.setProjectId(projectIdNew);
|
||||
collectionElement.setCollectionId(null);
|
||||
Date date = new Date();
|
||||
collectionElement.setCreateDate(date);
|
||||
collectionElement.setUpdateDate(date);
|
||||
collectionElement.setId(null);
|
||||
collectionElementService.getBaseMapper().insert(collectionElement);
|
||||
CollectionSketchDTO dto = new CollectionSketchDTO();
|
||||
dto.setSketchBoardId(collectionElement.getId());
|
||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||
@@ -2223,7 +2195,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||
}
|
||||
Long workspaceId = workspaceService.getByProjectId(projectIdNew);
|
||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||
Workspace workspace = workspaceService.getById(workspaceId);
|
||||
designCollectionDTO.setSystemScale(
|
||||
BigDecimal.valueOf(workspace.getSystemDesignerPercentage())
|
||||
@@ -2630,6 +2602,27 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
}
|
||||
result.setRelight(results);
|
||||
return result;
|
||||
} else if (query.getBuildType().equals(BuildType.POSE_TRANSFORM.getValue())) {
|
||||
String taskId = query.getTaskId();
|
||||
QueryWrapper<PoseTransformation> poseTransformationQueryWrapper = new QueryWrapper<>();
|
||||
poseTransformationQueryWrapper.lambda().eq(PoseTransformation::getTaskIdBatch, taskId);
|
||||
List<PoseTransformation> poseTransformationList = poseTransformationMapper.selectList(poseTransformationQueryWrapper);
|
||||
List<PoseTransformationVO> voList = new ArrayList<>();
|
||||
for (PoseTransformation poseTransformation : poseTransformationList) {
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO();
|
||||
if (null != poseTransformation.getGifUrl()){
|
||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (null != poseTransformation.getVideoUrl()){
|
||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
if (null != poseTransformation.getFirstFrameUrl()){
|
||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
}
|
||||
voList.add(poseTransformationVO);
|
||||
}
|
||||
result.setPoseTransfer(voList);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -969,6 +969,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
@Resource
|
||||
private PoseTransformationMapper poseTransformationMapper;
|
||||
@Resource
|
||||
private CloudTaskMapper cloudTaskMapper;
|
||||
|
||||
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
||||
// 1、存储模型返回的数据
|
||||
@@ -1202,4 +1204,54 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
return Arrays.asList(resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPoseTransformResultBatch(String taskId, String gifUrl, String videoUrl, String imageUrl, String progress) {
|
||||
// 1、存储模型返回的数据
|
||||
PoseTransformation poseTransformation;
|
||||
QueryWrapper<PoseTransformation> qw = new QueryWrapper<>();
|
||||
qw.eq("unique_id", taskId);
|
||||
List<PoseTransformation> poseTransformations = poseTransformationMapper.selectList(qw);
|
||||
if (poseTransformations != null && poseTransformations.size() > 1){
|
||||
log.warn("通过taskId {} 查询到的PoseTransformation的结果不止一条", taskId);
|
||||
}else if (poseTransformations == null || poseTransformations.isEmpty()){
|
||||
return ;
|
||||
}
|
||||
poseTransformation = poseTransformations.get(0);
|
||||
poseTransformation.setGifUrl(gifUrl);
|
||||
poseTransformation.setVideoUrl(videoUrl);
|
||||
poseTransformation.setFirstFrameUrl(imageUrl);
|
||||
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.updateById(poseTransformation);
|
||||
|
||||
String taskIdBatch = poseTransformation.getTaskIdBatch();
|
||||
QueryWrapper<CloudTask> cloudTaskQueryWrapper = new QueryWrapper<>();
|
||||
cloudTaskQueryWrapper.lambda().eq(CloudTask::getTaskId, taskIdBatch);
|
||||
CloudTask cloudTask = cloudTaskMapper.selectOne(cloudTaskQueryWrapper);
|
||||
if (Objects.nonNull(cloudTask)) {
|
||||
if (cloudTask.getCompletedNum() == null) {
|
||||
cloudTask.setCompletedNum(1);
|
||||
}else {
|
||||
cloudTask.setCompletedNum(cloudTask.getCompletedNum() + 1);
|
||||
}
|
||||
if (progress.equals("OK")) {
|
||||
cloudTask.setStatus(1);
|
||||
cloudTask.setCompletedNum(cloudTask.getNums());
|
||||
}
|
||||
cloudTaskMapper.updateById(cloudTask);
|
||||
}
|
||||
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(
|
||||
poseTransformation.getId(), taskId, gifUrl, videoUrl, imageUrl, (byte) 0, "Success");
|
||||
|
||||
// 2、更新redis
|
||||
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
// 3、执行积分扣除
|
||||
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||
String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||
if (flag) creditsService.updateChangedCredits(accountId, uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user