NewMatchVideoJob.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.tzld.piaoquan.longarticle.job;
  2. import com.tzld.piaoquan.longarticle.common.enums.NewContentStatusEnum;
  3. import com.tzld.piaoquan.longarticle.common.enums.NewMatchResultStatusEnum;
  4. import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.NewMatchVideoMapper;
  5. import com.tzld.piaoquan.longarticle.model.dto.AuditContentRequest;
  6. import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideo;
  7. import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideoExample;
  8. import com.tzld.piaoquan.longarticle.model.vo.MatchContentItem;
  9. import com.tzld.piaoquan.longarticle.model.vo.MatchContentStatusParam;
  10. import com.tzld.piaoquan.longarticle.service.local.NewMatchVideoService;
  11. import com.tzld.piaoquan.longarticle.service.remote.AigcService;
  12. import com.tzld.piaoquan.longarticle.service.remote.MatchService;
  13. import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
  14. import com.xxl.job.core.biz.model.ReturnT;
  15. import com.xxl.job.core.handler.annotation.XxlJob;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Component;
  19. import org.springframework.util.CollectionUtils;
  20. import java.util.List;
  21. @Slf4j
  22. @Component
  23. public class NewMatchVideoJob {
  24. @Autowired
  25. private NewMatchVideoService newMatchVideoService;
  26. @Autowired
  27. private AigcService aigcService;
  28. @Autowired
  29. private NewMatchVideoMapper newMatchVideoMapper;
  30. @Autowired
  31. private MatchService matchService;
  32. @XxlJob("matchContentJob")
  33. public ReturnT<String> matchContentJob(String param) {
  34. List<MatchContentItem> matchContentItemList = aigcService.getMatchContentItemList();
  35. if (CollectionUtils.isEmpty(matchContentItemList)) {
  36. return ReturnT.SUCCESS;
  37. }
  38. for (MatchContentItem matchContentItem : matchContentItemList) {
  39. NewMatchVideoExample example = new NewMatchVideoExample();
  40. example.createCriteria().andContentIdEqualTo(matchContentItem.getProduceContentId());
  41. List<NewMatchVideo> newMatchVideos = newMatchVideoMapper.selectByExample(example);
  42. if (CollectionUtils.isEmpty(newMatchVideos)) {
  43. newMatchVideoService.addMatchVideo(matchContentItem);
  44. } else {
  45. NewMatchVideo newMatchVideo = newMatchVideos.get(0);
  46. if (NewContentStatusEnum.isSuccess(newMatchVideo.getContentStatus())) {
  47. MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam();
  48. matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId());
  49. matchContentStatusParam.setStatus(NewMatchResultStatusEnum.SUCCESS.getStatusCode());
  50. boolean res = aigcService.updateMatchContentStatus(matchContentStatusParam);
  51. if (res) {
  52. AuditContentRequest auditContentRequest = new AuditContentRequest();
  53. auditContentRequest.setContentId(newMatchVideo.getContentId());
  54. auditContentRequest.setFlowPoolLevel(newMatchVideo.getFlowPoolLevel());
  55. matchService.addAudit(auditContentRequest);
  56. }
  57. }
  58. if (NewContentStatusEnum.isFail(newMatchVideo.getContentStatus())) {
  59. MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam();
  60. matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId());
  61. matchContentStatusParam.setStatus(NewMatchResultStatusEnum.FAIL.getStatusCode());
  62. aigcService.updateMatchContentStatus(matchContentStatusParam);
  63. }
  64. }
  65. }
  66. return ReturnT.SUCCESS;
  67. }
  68. @XxlJob("newKimiContentJob")
  69. public ReturnT<String> kimiContentJob(String param) {
  70. try {
  71. newMatchVideoService.kimiContent();
  72. } catch (Exception e) {
  73. LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  74. log.error("kimiContentJob error", e);
  75. }
  76. return ReturnT.SUCCESS;
  77. }
  78. @XxlJob("newMatchCrawlerVideoJob")
  79. public ReturnT<String> matchCrawlerVideoJob(String param) {
  80. try {
  81. newMatchVideoService.matchCrawlerVideo();
  82. } catch (Exception e) {
  83. LarkRobotUtil.sendMessage("newMatchCrawlerVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  84. log.error("newMatchCrawlerVideoJob error", e);
  85. }
  86. return ReturnT.SUCCESS;
  87. }
  88. @XxlJob("newUploadCrawlerVideoJob")
  89. public ReturnT<String> uploadCrawlerVideoJob(String param) {
  90. try {
  91. newMatchVideoService.uploadCrawlerVideo();
  92. } catch (Exception e) {
  93. LarkRobotUtil.sendMessage("newUploadCrawlerVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  94. log.error("newUploadCrawlerVideoJob error", e);
  95. }
  96. return ReturnT.SUCCESS;
  97. }
  98. }