NewMatchVideoJob.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. try {
  40. NewMatchVideoExample example = new NewMatchVideoExample();
  41. example.createCriteria().andContentIdEqualTo(matchContentItem.getProduceContentId());
  42. List<NewMatchVideo> newMatchVideos = newMatchVideoMapper.selectByExample(example);
  43. if (CollectionUtils.isEmpty(newMatchVideos)) {
  44. newMatchVideoService.addMatchVideo(matchContentItem);
  45. } else {
  46. NewMatchVideo newMatchVideo = newMatchVideos.get(0);
  47. if (NewContentStatusEnum.isSuccess(newMatchVideo.getContentStatus())) {
  48. MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam();
  49. matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId());
  50. matchContentStatusParam.setStatus(NewMatchResultStatusEnum.SUCCESS.getStatusCode());
  51. boolean res = aigcService.updateMatchContentStatus(matchContentStatusParam);
  52. if (res) {
  53. AuditContentRequest auditContentRequest = new AuditContentRequest();
  54. auditContentRequest.setContentId(newMatchVideo.getContentId());
  55. auditContentRequest.setFlowPoolLevel(newMatchVideo.getFlowPoolLevel());
  56. matchService.addAudit(auditContentRequest);
  57. }
  58. }
  59. if (NewContentStatusEnum.isFail(newMatchVideo.getContentStatus())) {
  60. MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam();
  61. matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId());
  62. matchContentStatusParam.setStatus(NewMatchResultStatusEnum.FAIL.getStatusCode());
  63. aigcService.updateMatchContentStatus(matchContentStatusParam);
  64. }
  65. }
  66. } catch (Exception e) {
  67. LarkRobotUtil.sendMessage("matchContentJob异常,contentId:"+matchContentItem.getProduceContentId()+", 请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  68. log.error("matchContentJob error:{}", e.getMessage());
  69. }
  70. }
  71. return ReturnT.SUCCESS;
  72. }
  73. @XxlJob("newKimiContentJob")
  74. public ReturnT<String> kimiContentJob(String param) {
  75. try {
  76. newMatchVideoService.kimiContent();
  77. } catch (Exception e) {
  78. LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  79. log.error("kimiContentJob error:{}", e.getMessage());
  80. }
  81. return ReturnT.SUCCESS;
  82. }
  83. @XxlJob("newMatchCrawlerVideoJob")
  84. public ReturnT<String> matchCrawlerVideoJob(String param) {
  85. try {
  86. newMatchVideoService.matchCrawlerVideo();
  87. } catch (Exception e) {
  88. LarkRobotUtil.sendMessage("newMatchCrawlerVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  89. log.error("newMatchCrawlerVideoJob error:{}", e.getMessage());
  90. }
  91. return ReturnT.SUCCESS;
  92. }
  93. @XxlJob("newUploadCrawlerVideoJob")
  94. public ReturnT<String> uploadCrawlerVideoJob(String param) {
  95. try {
  96. newMatchVideoService.uploadCrawlerVideo();
  97. } catch (Exception e) {
  98. LarkRobotUtil.sendMessage("newUploadCrawlerVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  99. log.error("newUploadCrawlerVideoJob error:{}", e.getMessage());
  100. }
  101. return ReturnT.SUCCESS;
  102. }
  103. @XxlJob("vectorMatchVideoJob")
  104. public ReturnT<String> vectorMatchVideoJob(String param) {
  105. try {
  106. newMatchVideoService.vectorMatchVideo();
  107. } catch (Exception e) {
  108. LarkRobotUtil.sendMessage("vectorMatchVideoJob异常,请及时查看,<at user_id=\"g6732afb\">王云鹏</at>");
  109. log.error("vectorMatchVideoJob error:{}", e.getMessage());
  110. }
  111. return ReturnT.SUCCESS;
  112. }
  113. }