TASK:调用第三方api,视频生成结束发送站内信
This commit is contained in:
@@ -59,6 +59,8 @@ public interface GenerateService extends IService<Generate> {
|
||||
|
||||
void processPTFailSituation(String taskId);
|
||||
|
||||
void sendSysMsgForPT(PoseTransformation poseTransformation);
|
||||
|
||||
List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like);
|
||||
|
||||
void updatePoseTransferStatus(String taskId, String status, PoseTransformation poseTransformation);
|
||||
|
||||
@@ -2595,7 +2595,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
if (flag) creditsService.updateChangedCredits(accountId, taskId);
|
||||
|
||||
// 发消息
|
||||
sendSysMsgForPT(poseTransformation, true);
|
||||
sendSysMsgForPT(poseTransformation);
|
||||
}
|
||||
|
||||
// 处理PoseTransformation失败的情况
|
||||
@@ -2610,7 +2610,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
poseTransformation.setUpdateTime(LocalDateTime.now());
|
||||
poseTransformationMapper.updateById(poseTransformation);
|
||||
// 发消息
|
||||
sendSysMsgForPT(poseTransformation, false);
|
||||
sendSysMsgForPT(poseTransformation);
|
||||
}
|
||||
|
||||
private PoseTransformation getPoseTransformationByTaskId(String taskId) {
|
||||
@@ -2625,11 +2625,31 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
return poseTransformations.get(0);
|
||||
}
|
||||
|
||||
public void sendSysMsgForPT(PoseTransformation poseTransformation, boolean isSuccess){
|
||||
@Override
|
||||
public void sendSysMsgForPT(PoseTransformation poseTransformation) {
|
||||
// 确认当前任务是否已通知过,是 -> 不再通知;否 -> 通知
|
||||
Boolean elementExistsInSet = redisUtil.isElementExistsInSet(RedisUtil.VIDEO_FINISHED_TASKS, poseTransformation.getUniqueId());
|
||||
if (elementExistsInSet) {
|
||||
// 已通知过,不再通知
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isSuccess;
|
||||
if (!StringUtil.isNullOrEmpty(poseTransformation.getTaskStatus()) && poseTransformation.getTaskStatus().equals("Success")) {
|
||||
isSuccess = true;
|
||||
} else if (!StringUtil.isNullOrEmpty(poseTransformation.getTaskStatus()) && poseTransformation.getTaskStatus().equals("Fail")) {
|
||||
isSuccess = false;
|
||||
} else {
|
||||
// 不通知
|
||||
return;
|
||||
}
|
||||
|
||||
Project project = projectService.getById(poseTransformation.getProjectId());
|
||||
// 发通知
|
||||
if (Objects.nonNull(project) && !StringUtil.isNullOrEmpty(project.getName())) {
|
||||
messageCenterService.videoFinishedMsg(poseTransformation.getAccountId(), project.getName(), isSuccess);
|
||||
// 添加已通知记录到redis
|
||||
redisUtil.addToSet(RedisUtil.VIDEO_FINISHED_TASKS, poseTransformation.getUniqueId(), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3727,6 +3747,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
creditsService.deleteCreditsDeduction(accountId, taskId);
|
||||
}
|
||||
poseTransformationVO.setTaskId(taskId);
|
||||
// 发送提示消息
|
||||
sendSysMsgForPT(poseTransformation);
|
||||
|
||||
return poseTransformationVO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user