TASK: video生成成功后添加站内信通知

This commit is contained in:
2025-11-17 16:55:45 +08:00
parent f239c8c02b
commit f36e0488ea
5 changed files with 80 additions and 57 deletions

View File

@@ -87,9 +87,9 @@ public class PaymentTask {
// !!关闭此定时器,改为提前三天站内信提醒!! // !!关闭此定时器,改为提前三天站内信提醒!!
// 提前7天向用户发送提醒邮件,每天早上8点执行 // 提前7天向用户发送提醒邮件,每天早上8点执行
// @Scheduled(cron = "0 0 8 * * ?") // @Scheduled(cron = "0 0 8 * * ?")
public void subscriptionReminder(){ // public void subscriptionReminder(){
stripeService.subscriptionReminder(); // stripeService.subscriptionReminder();
} // }
// 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件 // 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件

View File

@@ -29,7 +29,7 @@ public class PoseTransformDTO {
@ApiModelProperty("design结果在collectionSort中的id") @ApiModelProperty("design结果在collectionSort中的id")
private Long parentId; private Long parentId;
@ApiModelProperty("子集中的元素作为父元素") @ApiModelProperty("子集中的元素作为父元素,用于重新排序")
private Long userLikeSortId; private Long userLikeSortId;
@ApiModelProperty("是否默认喜欢") @ApiModelProperty("是否默认喜欢")

View File

@@ -27,4 +27,6 @@ public interface MessageCenterService extends IService<Notification> {
void setReadAll(String type); void setReadAll(String type);
void publishSystemNotification(PublishSysNotificationDTO message); void publishSystemNotification(PublishSysNotificationDTO message);
void videoFinishedMsg(Long userId, String projectName, boolean isSuccess);
} }

View File

@@ -44,6 +44,7 @@ import com.volcengine.ark.runtime.model.images.generation.ImagesResponse;
import com.volcengine.ark.runtime.service.ArkService; import com.volcengine.ark.runtime.service.ArkService;
import io.minio.errors.MinioException; import io.minio.errors.MinioException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@@ -84,58 +85,35 @@ import static com.ai.da.common.enums.WangXiangTaskStatusEnum.UNKNOWN_W;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> implements GenerateService { public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> implements GenerateService {
@Resource private final CollectionElementMapper collectionElementMapper;
private CollectionElementMapper collectionElementMapper; private final GenerateDetailMapper generateDetailMapper;
@Resource private final LibraryService libraryService;
private GenerateDetailMapper generateDetailMapper; private final PythonService pythonService;
@Resource private final CollectionElementService collectionElementService;
private LibraryService libraryService; private final CreditsService creditsService;
@Resource private final MinioUtil minioUtil;
private PythonService pythonService; private final RabbitMQService rabbitMQService;
@Resource private final RedisUtil redisUtil;
private CollectionElementService collectionElementService; private final GenerateCancelMapper generateCancelMapper;
@Resource private final SketchReconstructionMapper sketchReconstructionMapper;
private CreditsService creditsService; private final SendRequestUtil sendRequestUtil;
@Resource private final ProjectService projectService;
private MinioUtil minioUtil; private final CollectionSortService collectionSortService;
@Resource private final CloudTaskService cloudTaskService;
private RabbitMQService rabbitMQService; private final APIGenerateMapper apiGenerateMapper;
@Resource private final CollectionSortMapper collectionSortMapper;
private RedisUtil redisUtil; private final SysFileService sysFileService;
@Resource private final LibraryModelPointService libraryModelPointService;
private GenerateCancelMapper generateCancelMapper; private final PoseTransformationMapper poseTransformationMapper;
@Resource private final CloudTaskMapper cloudTaskMapper;
private SketchReconstructionMapper sketchReconstructionMapper; private final ToProductImageResultMapper toProductImageResultMapper;
@Resource private final AccountService accountService;
private SendRequestUtil sendRequestUtil; private final APIGenerateService apiGenerateService;
@Resource private final UserLikeGroupService userLikeGroupService;
private ProjectService projectService; private final MessageCenterService messageCenterService;
@Resource
private CollectionSortService collectionSortService;
@Resource
private CloudTaskService cloudTaskService;
@Resource
private APIGenerateMapper apiGenerateMapper;
@Resource
private CollectionSortMapper collectionSortMapper;
@Resource
private SysFileService sysFileService;
@Resource
private LibraryModelPointService libraryModelPointService;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Resource
private CloudTaskMapper cloudTaskMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private AccountService accountService;
@Resource
private APIGenerateService apiGenerateService;
@Resource
private UserLikeGroupService userLikeGroupService;
@Value("${redis.key.orderForGenerate}") @Value("${redis.key.orderForGenerate}")
private String consumptionOrderKey; private String consumptionOrderKey;
@@ -2581,7 +2559,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
if (Objects.nonNull(poseTransformDTO.getParentId()) if (Objects.nonNull(poseTransformDTO.getParentId())
&& !poseTransformDTO.getParentId().equals(0L)) { && !poseTransformDTO.getParentId().equals(0L)) {
return disOrLikePose(poseTransformationId, "like", return disOrLikePose(poseTransformationId, "like",
poseTransformDTO.getProjectId(), poseTransformDTO.getUserLikeSortId()); poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
} }
return null; return null;
} }
@@ -2619,6 +2597,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
// String uuid = taskId.substring(0, taskId.lastIndexOf("-")); // String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), taskId); Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), taskId);
if (flag) creditsService.updateChangedCredits(accountId, taskId); if (flag) creditsService.updateChangedCredits(accountId, taskId);
Project project = projectService.getById(poseTransformation.getProjectId());
// 发通知
if (Objects.nonNull(project) && !StringUtil.isNullOrEmpty(project.getName())) {
messageCenterService.videoFinishedMsg(poseTransformation.getAccountId(), project.getName() , true);
}
} }
public List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like) { public List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like) {

View File

@@ -17,6 +17,7 @@ import com.ai.da.mapper.primary.entity.Portfolio;
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus; import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
import com.ai.da.model.dto.GetNotificationDTO; import com.ai.da.model.dto.GetNotificationDTO;
import com.ai.da.model.dto.PublishSysNotificationDTO; import com.ai.da.model.dto.PublishSysNotificationDTO;
import com.ai.da.model.enums.Language;
import com.ai.da.model.vo.NotificationVO; import com.ai.da.model.vo.NotificationVO;
import com.ai.da.service.AccountService; import com.ai.da.service.AccountService;
import com.ai.da.service.MessageCenterService; import com.ai.da.service.MessageCenterService;
@@ -97,9 +98,18 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) { if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) {
queryWrapper.eq("type", getNotificationDTO.getType()); queryWrapper.eq("type", getNotificationDTO.getType());
} }
if (!getNotificationDTO.getType().equals("system")){
queryWrapper.eq("receiver_id", accountId); if (getNotificationDTO.getType().equals("system")){
queryWrapper.lambda().eq(Notification::getType, "system")
.and(wrapper -> wrapper
.isNull(Notification::getReceiverId)
.or()
.eq(Notification::getReceiverId, accountId)
);
} else {
queryWrapper.lambda().eq(Notification::getReceiverId, accountId);
} }
Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper); Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper);
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId); List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
@@ -378,4 +388,31 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return PageBaseResponse.success(convert); return PageBaseResponse.success(convert);
} }
public void videoFinishedMsg(Long userId, String projectName, boolean isSuccess) {
Account account = accountService.getById(userId);
String language = account.getLanguage();
Notification notification = new Notification();
notification.setType("system");
notification.setReceiverId(userId);
if (isSuccess) {
if (language.equals(Language.ENGLISH.name())) {
notification.setContent("Your video generation task in Project " + projectName + " is ready!");
} else {
notification.setContent("您在项目 " + projectName + " 中创建的视频生成任务已完成!");
}
} else {
if (language.equals(Language.ENGLISH.name())) {
notification.setContent("Your video generation task in Project " + projectName + " has failed.");
} else {
notification.setContent("视频生成任务失败。");
}
}
notification.setIsRead(0);
notification.setCreateTime(LocalDateTime.now());
save(notification);
pushMessage("system", userId);
}
} }