TASK:模块化;
This commit is contained in:
@@ -386,9 +386,9 @@ public class GenerateConsumer {
|
|||||||
String url = null;
|
String url = null;
|
||||||
if (!StringUtils.isEmpty(result)) {
|
if (!StringUtils.isEmpty(result)) {
|
||||||
url = result.getString(0);
|
url = result.getString(0);
|
||||||
}
|
|
||||||
String taskId = generateResult.getString("task_id");
|
String taskId = generateResult.getString("task_id");
|
||||||
userLikeGroupService.relightBatch(taskId, url, progress);
|
userLikeGroupService.relightBatch(taskId, url, progress);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 修改redis中的数据状态为exception
|
// 修改redis中的数据状态为exception
|
||||||
String key = relightResultKey + ":" + generateResult.get("task_id");
|
String key = relightResultKey + ":" + generateResult.get("task_id");
|
||||||
@@ -422,6 +422,59 @@ public class GenerateConsumer {
|
|||||||
log.info("============ProcessRelightBatchResult End listening==========");
|
log.info("============ProcessRelightBatchResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processPoseTransformBatchResult(Message msg, Channel channel) {
|
||||||
|
log.info("============ProcessPoseTransformBatchResult listening==========");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
JSONObject generateResult = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
||||||
|
log.info("PoseTransformationBatch response : {}", generateResult);
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
|
JSONArray result = generateResult.getJSONArray("result");
|
||||||
|
if (!StringUtils.isEmpty(result)) {
|
||||||
|
JSONObject jsonObject = result.getJSONObject(0);
|
||||||
|
String gifUrl = jsonObject.getString("gif_url");
|
||||||
|
String taskId = generateResult.getString("task_id");
|
||||||
|
String videoUrl = jsonObject.getString("video_url");
|
||||||
|
String imageUrl = jsonObject.getString("first_image_url");
|
||||||
|
String progress = generateResult.getString("progress");
|
||||||
|
generateService.processPoseTransformResultBatch(taskId, gifUrl, videoUrl, imageUrl, progress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 修改redis中的数据状态为exception
|
||||||
|
String key = generateResultKey + ":" + generateResult.getString("task_id");
|
||||||
|
redisUtil.addToString(key, new Gson().toJson(new PoseTransformationVO(null, generateResult.getString("task_id"),null, null, null, (byte)0, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
// 将异常信息存到exception中
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("message"));
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
try {
|
||||||
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
|
} catch (IOException exception) {
|
||||||
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
|
}
|
||||||
|
// 将入参和错误信息存入数据库
|
||||||
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
|
" Exception message : " + e.getMessage();
|
||||||
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
|
exceptionInfo.put(generateResult.getString("task_id"), exceptionMessage);
|
||||||
|
// 存redis
|
||||||
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
||||||
|
log.info("============ProcessPoseTransformResult End listening==========");
|
||||||
|
}
|
||||||
|
|
||||||
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.generate}")
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
public void generateConsumer1(Message msg, Channel channel) {
|
public void generateConsumer1(Message msg, Channel channel) {
|
||||||
@@ -515,4 +568,10 @@ public class GenerateConsumer {
|
|||||||
public void getRelightBatchResult(Message msg, Channel channel) {
|
public void getRelightBatchResult(Message msg, Channel channel) {
|
||||||
processRelightBatchResult(msg, channel);
|
processRelightBatchResult(msg, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.poseTransformBatch}")
|
||||||
|
@RabbitHandler
|
||||||
|
public void getPoseTransformBatchResult(Message msg, Channel channel) {
|
||||||
|
processPoseTransformBatchResult(msg, channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class RabbitMQProperties {
|
|||||||
private String designBatch;
|
private String designBatch;
|
||||||
private String relightBatch;
|
private String relightBatch;
|
||||||
private String toProductImageBatch;
|
private String toProductImageBatch;
|
||||||
|
private String poseTransformBatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ public class CloudTaskResultVO {
|
|||||||
private List<DesignCollectionItemVO> design;
|
private List<DesignCollectionItemVO> design;
|
||||||
private List<MagicToolResultVO> toProductImage;
|
private List<MagicToolResultVO> toProductImage;
|
||||||
private List<MagicToolResultVO> relight;
|
private List<MagicToolResultVO> relight;
|
||||||
|
private List<PoseTransformationVO> poseTransfer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4365,40 +4365,17 @@ public class PythonService {
|
|||||||
.addHeader("Content-Type", "application/json")
|
.addHeader("Content-Type", "application/json")
|
||||||
.build();
|
.build();
|
||||||
Response response = null;
|
Response response = null;
|
||||||
String bodyString;
|
|
||||||
try {
|
try {
|
||||||
log.info("poseTransformation请求入参content###{}", JSON.toJSONString(content));
|
|
||||||
response = client.newCall(request).execute();
|
response = client.newCall(request).execute();
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
log.error("PythonService##poseTransformation异常###{}", ExceptionUtil.getThrowableList(ioException));
|
log.error("PythonService##poseTransferBatch异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||||
throw new BusinessException(ioException.getMessage());
|
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||||
}
|
}
|
||||||
|
if (response.isSuccessful()) {
|
||||||
// 判断是否生成失败
|
|
||||||
if (Objects.isNull(response.body())) {
|
|
||||||
log.error("PythonService##poseTransformation异常###{}", "response or body is empty!");
|
|
||||||
throw new BusinessException("PythonService##poseTransformation异常###: response or body is empty!");
|
|
||||||
} else if (response.code() != HttpURLConnection.HTTP_OK) {
|
|
||||||
log.error("PythonService##poseTransformation异常###{}", "Response error!Response code ## " + response.code() + " ##");
|
|
||||||
throw new BusinessException("PythonService##poseTransformation异常### Response error!Response code ## " + response.code() + " ##");
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
bodyString = response.body().string();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new BusinessException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSONObject jsonObject = JSON.parseObject(bodyString);
|
|
||||||
Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful");
|
|
||||||
|
|
||||||
if (result && jsonObject.get("code").equals(200)) {
|
|
||||||
log.info("poseTransformation##responseObject###{}", jsonObject);
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
} else {
|
}
|
||||||
log.info("poseTransformation失败###{}", jsonObject);
|
log.error("PythonService##poseTransferBatch异常response###{}", response);
|
||||||
log.info("poseTransformation Exception! Code : {}", jsonObject.get("code"));
|
//生成失败
|
||||||
return Boolean.FALSE;
|
throw new BusinessException("poseTransferBatch.interface.exception");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,6 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
||||||
|
|
||||||
List<Map<String, String>> getAllPose();
|
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) {
|
public String designCloud(CloudTaskDTO cloudTaskDTO) {
|
||||||
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
|
||||||
Long projectId = cloudTaskDTO.getProjectId();
|
Long projectId = cloudTaskDTO.getProjectId();
|
||||||
Project project = projectService.getById(projectId);
|
// Project project = projectService.getById(projectId);
|
||||||
project.setParentId(projectId);
|
// project.setParentId(projectId);
|
||||||
project.setId(null);
|
// project.setId(null);
|
||||||
project.setName(project.getName() + "_cloud");
|
// project.setName(project.getName() + "_cloud");
|
||||||
LocalDateTime now = LocalDateTime.now();
|
// LocalDateTime now = LocalDateTime.now();
|
||||||
project.setCreateTime(now);
|
// project.setCreateTime(now);
|
||||||
project.setUpdateTime(now);
|
// project.setUpdateTime(now);
|
||||||
projectService.getBaseMapper().insert(project);
|
// projectService.getBaseMapper().insert(project);
|
||||||
Long workspaceId = workspaceService.getByProjectId(projectId);
|
// Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
Workspace workspace = workspaceService.getById(workspaceId);
|
// Workspace workspace = workspaceService.getById(workspaceId);
|
||||||
workspace.setProjectId(project.getId());
|
// workspace.setProjectId(project.getId());
|
||||||
workspace.setId(null);
|
// workspace.setId(null);
|
||||||
workspaceService.getBaseMapper().insert(workspace);
|
// workspaceService.getBaseMapper().insert(workspace);
|
||||||
|
|
||||||
DesignCollectionDTO designDTO = transDesignParam(projectId, project.getId());
|
DesignCollectionDTO designDTO = transDesignParam(projectId);
|
||||||
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
designDTO.setDesignNum(cloudTaskDTO.getNums());
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||||
|
|
||||||
@@ -1820,7 +1820,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
|
||||||
|
|
||||||
//design
|
//design
|
||||||
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, project.getId());
|
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
|
||||||
return taskId;
|
return taskId;
|
||||||
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
|
||||||
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
|
||||||
@@ -2116,7 +2116,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DesignCollectionDTO transDesignParam(Long projectId, Long projectIdNew) {
|
private DesignCollectionDTO transDesignParam(Long projectId) {
|
||||||
DesignCollectionDTO designCollectionDTO = new DesignCollectionDTO();
|
DesignCollectionDTO designCollectionDTO = new DesignCollectionDTO();
|
||||||
List<CollectionElement> collectionElementList = collectionElementService.getByProjectId(projectId);
|
List<CollectionElement> collectionElementList = collectionElementService.getByProjectId(projectId);
|
||||||
if (CollectionUtil.isNotEmpty(collectionElementList)) {
|
if (CollectionUtil.isNotEmpty(collectionElementList)) {
|
||||||
@@ -2125,13 +2125,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<DesignCollectionElementDTO> moodBoards = new ArrayList<>();
|
List<DesignCollectionElementDTO> moodBoards = new ArrayList<>();
|
||||||
List<CollectionElement> moodboardList = groupedMap.get("Moodboard");
|
List<CollectionElement> moodboardList = groupedMap.get("Moodboard");
|
||||||
for (CollectionElement collectionElement : moodboardList) {
|
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) {
|
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
|
||||||
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
|
||||||
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(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<DesignCollectionPrintElementDTO> printBoards = new ArrayList<>();
|
||||||
List<CollectionElement> printBoardList = groupedMap.get("Printboard");
|
List<CollectionElement> printBoardList = groupedMap.get("Printboard");
|
||||||
for (CollectionElement collectionElement : printBoardList) {
|
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();
|
DesignCollectionPrintElementDTO dto = new DesignCollectionPrintElementDTO();
|
||||||
dto.setId(collectionElement.getId());
|
dto.setId(collectionElement.getId());
|
||||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
@@ -2170,13 +2156,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<CollectionColorDTO> colorBoards = new ArrayList<>();
|
List<CollectionColorDTO> colorBoards = new ArrayList<>();
|
||||||
List<CollectionElement> colorBoardList = groupedMap.get("Colorboard");
|
List<CollectionElement> colorBoardList = groupedMap.get("Colorboard");
|
||||||
for (CollectionElement collectionElement : colorBoardList) {
|
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();
|
CollectionColorDTO dto = new CollectionColorDTO();
|
||||||
String name = collectionElement.getName();
|
String name = collectionElement.getName();
|
||||||
if (name.contains("_")) {
|
if (name.contains("_")) {
|
||||||
@@ -2199,13 +2178,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
|
||||||
List<CollectionElement> sketchBoardList = groupedMap.get("Sketchboard");
|
List<CollectionElement> sketchBoardList = groupedMap.get("Sketchboard");
|
||||||
for (CollectionElement collectionElement : sketchBoardList) {
|
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();
|
CollectionSketchDTO dto = new CollectionSketchDTO();
|
||||||
dto.setSketchBoardId(collectionElement.getId());
|
dto.setSketchBoardId(collectionElement.getId());
|
||||||
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
|
||||||
@@ -2223,7 +2195,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
designCollectionDTO.setColorBoards(new ArrayList<>());
|
designCollectionDTO.setColorBoards(new ArrayList<>());
|
||||||
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
designCollectionDTO.setSketchBoards(new ArrayList<>());
|
||||||
}
|
}
|
||||||
Long workspaceId = workspaceService.getByProjectId(projectIdNew);
|
Long workspaceId = workspaceService.getByProjectId(projectId);
|
||||||
Workspace workspace = workspaceService.getById(workspaceId);
|
Workspace workspace = workspaceService.getById(workspaceId);
|
||||||
designCollectionDTO.setSystemScale(
|
designCollectionDTO.setSystemScale(
|
||||||
BigDecimal.valueOf(workspace.getSystemDesignerPercentage())
|
BigDecimal.valueOf(workspace.getSystemDesignerPercentage())
|
||||||
@@ -2630,6 +2602,27 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
|||||||
}
|
}
|
||||||
result.setRelight(results);
|
result.setRelight(results);
|
||||||
return result;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -969,6 +969,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PoseTransformationMapper poseTransformationMapper;
|
private PoseTransformationMapper poseTransformationMapper;
|
||||||
|
@Resource
|
||||||
|
private CloudTaskMapper cloudTaskMapper;
|
||||||
|
|
||||||
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
public void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl){
|
||||||
// 1、存储模型返回的数据
|
// 1、存储模型返回的数据
|
||||||
@@ -1202,4 +1204,54 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
return Arrays.asList(resp);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ rabbitmq.exchange.generate=generate-exchange
|
|||||||
rabbitmq.queues.designBatch=DesignBatch-dev
|
rabbitmq.queues.designBatch=DesignBatch-dev
|
||||||
rabbitmq.queues.relightBatch=BatchRelight-dev
|
rabbitmq.queues.relightBatch=BatchRelight-dev
|
||||||
rabbitmq.queues.toProductImageBatch=BatchToProductImage-dev
|
rabbitmq.queues.toProductImageBatch=BatchToProductImage-dev
|
||||||
|
rabbitmq.queues.poseTransformBatch=BatchPoseTransform-dev
|
||||||
|
|
||||||
orderList.link=https://develop.aida.com.hk/home/homePage?order=
|
orderList.link=https://develop.aida.com.hk/home/homePage?order=
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user