TASK: video生成成功后添加站内信通知
This commit is contained in:
@@ -27,4 +27,6 @@ public interface MessageCenterService extends IService<Notification> {
|
||||
void setReadAll(String type);
|
||||
|
||||
void publishSystemNotification(PublishSysNotificationDTO message);
|
||||
|
||||
void videoFinishedMsg(Long userId, String projectName, boolean isSuccess);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.volcengine.ark.runtime.model.images.generation.ImagesResponse;
|
||||
import com.volcengine.ark.runtime.service.ArkService;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -84,58 +85,35 @@ import static com.ai.da.common.enums.WangXiangTaskStatusEnum.UNKNOWN_W;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> implements GenerateService {
|
||||
|
||||
@Resource
|
||||
private CollectionElementMapper collectionElementMapper;
|
||||
@Resource
|
||||
private GenerateDetailMapper generateDetailMapper;
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
@Resource
|
||||
private PythonService pythonService;
|
||||
@Resource
|
||||
private CollectionElementService collectionElementService;
|
||||
@Resource
|
||||
private CreditsService creditsService;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private RabbitMQService rabbitMQService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private GenerateCancelMapper generateCancelMapper;
|
||||
@Resource
|
||||
private SketchReconstructionMapper sketchReconstructionMapper;
|
||||
@Resource
|
||||
private SendRequestUtil sendRequestUtil;
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
@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;
|
||||
private final CollectionElementMapper collectionElementMapper;
|
||||
private final GenerateDetailMapper generateDetailMapper;
|
||||
private final LibraryService libraryService;
|
||||
private final PythonService pythonService;
|
||||
private final CollectionElementService collectionElementService;
|
||||
private final CreditsService creditsService;
|
||||
private final MinioUtil minioUtil;
|
||||
private final RabbitMQService rabbitMQService;
|
||||
private final RedisUtil redisUtil;
|
||||
private final GenerateCancelMapper generateCancelMapper;
|
||||
private final SketchReconstructionMapper sketchReconstructionMapper;
|
||||
private final SendRequestUtil sendRequestUtil;
|
||||
private final ProjectService projectService;
|
||||
private final CollectionSortService collectionSortService;
|
||||
private final CloudTaskService cloudTaskService;
|
||||
private final APIGenerateMapper apiGenerateMapper;
|
||||
private final CollectionSortMapper collectionSortMapper;
|
||||
private final SysFileService sysFileService;
|
||||
private final LibraryModelPointService libraryModelPointService;
|
||||
private final PoseTransformationMapper poseTransformationMapper;
|
||||
private final CloudTaskMapper cloudTaskMapper;
|
||||
private final ToProductImageResultMapper toProductImageResultMapper;
|
||||
private final AccountService accountService;
|
||||
private final APIGenerateService apiGenerateService;
|
||||
private final UserLikeGroupService userLikeGroupService;
|
||||
private final MessageCenterService messageCenterService;
|
||||
|
||||
@Value("${redis.key.orderForGenerate}")
|
||||
private String consumptionOrderKey;
|
||||
@@ -2581,7 +2559,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
if (Objects.nonNull(poseTransformDTO.getParentId())
|
||||
&& !poseTransformDTO.getParentId().equals(0L)) {
|
||||
return disOrLikePose(poseTransformationId, "like",
|
||||
poseTransformDTO.getProjectId(), poseTransformDTO.getUserLikeSortId());
|
||||
poseTransformDTO.getProjectId(), poseTransformDTO.getParentId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -2619,6 +2597,12 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// String uuid = taskId.substring(0, taskId.lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(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) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.ai.da.mapper.primary.entity.Portfolio;
|
||||
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
|
||||
import com.ai.da.model.dto.GetNotificationDTO;
|
||||
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.service.AccountService;
|
||||
import com.ai.da.service.MessageCenterService;
|
||||
@@ -97,9 +98,18 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
if (!StringUtils.isNullOrEmpty(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);
|
||||
|
||||
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
|
||||
@@ -378,4 +388,31 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user