TASK:调用第三方api,视频生成结束发送站内信

This commit is contained in:
2025-11-19 16:59:54 +08:00
parent 0f525c6c00
commit 65b17fe109
4 changed files with 40 additions and 28 deletions

View File

@@ -6,12 +6,10 @@ import com.ai.da.mapper.primary.PoseTransformationMapper;
import com.ai.da.mapper.primary.ToProductImageResultMapper;
import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.vo.PoseTransformationVO;
import com.ai.da.service.APIGenerateService;
import com.ai.da.service.CreditsService;
import com.ai.da.service.GenerateService;
import com.ai.da.service.MessageCenterService;
import com.ai.da.service.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -25,19 +23,13 @@ import static com.ai.da.common.enums.CreditsEventsEnum.TO_PRODUCT_IMAGE;
@Slf4j
@Component
@RequiredArgsConstructor
public class GenerateTask {
@Resource
private APIGenerateService apiGenerateService;
@Resource
private CreditsService creditsService;
@Resource
private GenerateService generateService;
@Resource
private MessageCenterService messageCenterService;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private PoseTransformationMapper poseTransformationMapper;
private final APIGenerateService apiGenerateService;
private final CreditsService creditsService;
private final GenerateService generateService;
private final PoseTransformationMapper poseTransformationMapper;
private final ToProductImageResultMapper toProductImageResultMapper;
/*
@@ -106,9 +98,10 @@ public class GenerateTask {
}
// 万相 -> pose transformation 补偿 一小时执行一次
// 万相 -> pose transformation 补偿 当前任务执行完后5分钟再执行一次不会出现任务重叠的情况
@Scheduled(fixedDelay = 5 * 60 * 1000)
public void wxCompensationMechanism(){
log.info("=====万相补偿获取结果开始=====");
List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx");
if (apiGenerates != null && !apiGenerates.isEmpty()){
for (APIGenerate apiGenerate : apiGenerates){
@@ -122,7 +115,6 @@ public class GenerateTask {
PoseTransformationVO animateResult = generateService.getAnimateResult(taskId);
if (animateResult.getStatus().equals("Success")){
log.info("补偿获取结果成功,发送系统消息");
sendSysMsgToUser(poseTransformation.getAccountId(), "您的姿势变换生成任务已完成");
}
} catch (BusinessException e){
log.warn("万相 animation 生成失败,原因:{}", e.getMessage());
@@ -136,19 +128,13 @@ public class GenerateTask {
apiGenerate.setStatus("Fail");
apiGenerate.setUpdateTime(LocalDateTime.now());
apiGenerateService.updateById(apiGenerate);
generateService.sendSysMsgForPT(poseTransformation);
}
}
}
}
public void sendSysMsgToUser(Long accountId, String content){
Notification notification = new Notification();
notification.setType("system");
notification.setReceiverId(accountId);
notification.setContent(content);
messageCenterService.prePushMessage(notification);
}

View File

@@ -97,6 +97,8 @@ public class RedisUtil {
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
public final static String VIDEO_FINISHED_TASKS = "VideoFinishedTasks";
/**
* 将数据放入set缓存
*/