package com.tzld.piaoquan.longarticle.job; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import com.tzld.piaoquan.longarticle.common.enums.MatchResultStatusEnum; import com.tzld.piaoquan.longarticle.common.enums.NewContentStatusEnum; import com.tzld.piaoquan.longarticle.dao.mapper.longarticle.NewMatchVideoMapper; import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideo; import com.tzld.piaoquan.longarticle.model.po.longarticle.NewMatchVideoExample; import com.tzld.piaoquan.longarticle.model.vo.MatchContentItem; import com.tzld.piaoquan.longarticle.model.vo.MatchContentStatusParam; import com.tzld.piaoquan.longarticle.service.local.NewMatchVideoService; import com.tzld.piaoquan.longarticle.service.local.impl.MatchVideoServiceImpl; import com.tzld.piaoquan.longarticle.service.remote.AigcService; import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.List; import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_HOST; import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_PORT; @Slf4j @Component public class NewMatchVideoJob { @Autowired private NewMatchVideoService newMatchVideoService; @Autowired private AigcService aigcService; @Autowired private NewMatchVideoMapper newMatchVideoMapper; @XxlJob("matchContentJob") public ReturnT matchContentJob(String param) { List matchContentItemList = aigcService.getMatchContentItemList(); if (CollectionUtils.isEmpty(matchContentItemList)) { return ReturnT.SUCCESS; } for (MatchContentItem matchContentItem : matchContentItemList) { NewMatchVideoExample example = new NewMatchVideoExample(); example.createCriteria().andContentIdEqualTo(matchContentItem.getProduceContentId()); List newMatchVideos = newMatchVideoMapper.selectByExample(example); if (CollectionUtils.isEmpty(newMatchVideos)) { newMatchVideoService.addMatchVideo(matchContentItem); } else { NewMatchVideo newMatchVideo = newMatchVideos.get(0); if (NewContentStatusEnum.isSuccess(newMatchVideo.getContentStatus())) { MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam(); matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId()); matchContentStatusParam.setStatus(MatchResultStatusEnum.SUCCESS.getStatusCode()); aigcService.updateMatchContentStatus(matchContentStatusParam); } if (NewContentStatusEnum.isFail(newMatchVideo.getContentStatus())) { MatchContentStatusParam matchContentStatusParam = new MatchContentStatusParam(); matchContentStatusParam.setProduceContentId(newMatchVideo.getContentId()); matchContentStatusParam.setStatus(MatchResultStatusEnum.FAIL.getStatusCode()); aigcService.updateMatchContentStatus(matchContentStatusParam); } } } return ReturnT.SUCCESS; } @XxlJob("newKimiContentJob") public ReturnT kimiContentJob(String param) { try { newMatchVideoService.kimiContent(); } catch (Exception e) { LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,@薛一鸣"); log.error("kimiContentJob error", e); } return ReturnT.SUCCESS; } @XxlJob("newMatchCrawlerVideoJob") public ReturnT matchCrawlerVideoJob(String param) { try { newMatchVideoService.matchCrawlerVideo(); } catch (Exception e) { LarkRobotUtil.sendMessage("newMatchCrawlerVideoJob异常,请及时查看,@薛一鸣"); log.error("newMatchCrawlerVideoJob error", e); } return ReturnT.SUCCESS; } @XxlJob("newUploadCrawlerVideoJob") public ReturnT uploadCrawlerVideoJob(String param) { try { newMatchVideoService.uploadCrawlerVideo(); } catch (Exception e) { LarkRobotUtil.sendMessage("newUploadCrawlerVideoJob异常,请及时查看,@薛一鸣"); log.error("newUploadCrawlerVideoJob error", e); } return ReturnT.SUCCESS; } }