NewMatchVideoJob.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.tzld.piaoquan.longarticle.job;
  2. import cn.hutool.http.HttpRequest;
  3. import cn.hutool.http.HttpResponse;
  4. import com.tzld.piaoquan.longarticle.common.enums.MatchResultStatusEnum;
  5. import com.tzld.piaoquan.longarticle.common.enums.NewContentStatusEnum;
  6. import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.NewMatchVideoMapper;
  7. import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideo;
  8. import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideoExample;
  9. import com.tzld.piaoquan.longarticle.model.vo.MatchContentItem;
  10. import com.tzld.piaoquan.longarticle.model.vo.MatchContentStatusParam;
  11. import com.tzld.piaoquan.longarticle.service.local.NewMatchVideoService;
  12. import com.tzld.piaoquan.longarticle.service.local.impl.MatchVideoServiceImpl;
  13. import com.tzld.piaoquan.longarticle.service.remote.AigcService;
  14. import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
  15. import com.xxl.job.core.biz.model.ReturnT;
  16. import com.xxl.job.core.handler.annotation.XxlJob;
  17. import lombok.extern.slf4j.Slf4j;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Component;
  20. import org.springframework.util.CollectionUtils;
  21. import java.util.List;
  22. import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_HOST;
  23. import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_PORT;
  24. @Slf4j
  25. @Component
  26. public class NewMatchVideoJob {
  27. @Autowired
  28. private NewMatchVideoService newMatchVideoService;
  29. @Autowired
  30. private AigcService aigcService;
  31. @Autowired
  32. private NewMatchVideoMapper newMatchVideoMapper;
  33. @XxlJob("matchContentJob")
  34. public ReturnT<String> matchContentJob(String param) {
  35. List<MatchContentItem> matchContentItemList = aigcService.getMatchContentItemList();
  36. if (CollectionUtils.isEmpty(matchContentItemList)) {
  37. return ReturnT.SUCCESS;
  38. }
  39. for (MatchContentItem matchContentItem : matchContentItemList) {
  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(MatchResultStatusEnum.SUCCESS.getStatusCode());
  51. aigcService.updateMatchContentStatus(matchContentStatusParam);
  52. }
  53. if (NewContentStatusEnum.isFail(newMatchVideo.getContentStatus())) {
  54. MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam();
  55. matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId());
  56. matchContentStatusParam.setStatus(MatchResultStatusEnum.FAIL.getStatusCode());
  57. aigcService.updateMatchContentStatus(matchContentStatusParam);
  58. }
  59. }
  60. }
  61. return ReturnT.SUCCESS;
  62. }
  63. @XxlJob("newKimiContentJob")
  64. public ReturnT<String> kimiContentJob(String param) {
  65. try {
  66. newMatchVideoService.kimiContent();
  67. } catch (Exception e) {
  68. LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,@薛一鸣");
  69. log.error("kimiContentJob error", e);
  70. }
  71. return ReturnT.SUCCESS;
  72. }
  73. @XxlJob("newMatchCrawlerVideoJob")
  74. public ReturnT<String> matchCrawlerVideoJob(String param) {
  75. try {
  76. newMatchVideoService.matchCrawlerVideo();
  77. } catch (Exception e) {
  78. LarkRobotUtil.sendMessage("newMatchCrawlerVideoJob异常,请及时查看,@薛一鸣");
  79. log.error("newMatchCrawlerVideoJob error", e);
  80. }
  81. return ReturnT.SUCCESS;
  82. }
  83. @XxlJob("newUploadCrawlerVideoJob")
  84. public ReturnT<String> uploadCrawlerVideoJob(String param) {
  85. try {
  86. newMatchVideoService.uploadCrawlerVideo();
  87. } catch (Exception e) {
  88. LarkRobotUtil.sendMessage("newUploadCrawlerVideoJob异常,请及时查看,@薛一鸣");
  89. log.error("newUploadCrawlerVideoJob error", e);
  90. }
  91. return ReturnT.SUCCESS;
  92. }
  93. }