后台服务
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

187 Zeilen
7.7 KiB

  1. package com.iformall.schedule;
  2. import com.iformall.domain.po.sm.PhotoSpeakVideo;
  3. import com.iformall.domain.po.sm.UserMouldVideo;
  4. import com.iformall.domain.po.sm.VideoTrans;
  5. import com.iformall.enums.EnumVideoStatus;
  6. import com.iformall.enums.EnumaVideoTransStatus;
  7. import com.iformall.mapper.VideoTransMapper;
  8. import com.iformall.service.sm.PhotoSpeakVideoService;
  9. import com.iformall.service.sm.UserCreateVideoNumService;
  10. import com.iformall.service.sm.UserMouldVideoService;
  11. import com.iformall.utils.DateUtils;
  12. import com.iformall.video.VideoFactory;
  13. import com.iformall.video.entity.VideTransResult;
  14. import com.iformall.video.entity.VideUploadResult;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.context.annotation.Configuration;
  20. import org.springframework.scheduling.annotation.EnableScheduling;
  21. import org.springframework.scheduling.annotation.Scheduled;
  22. import java.util.Date;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.concurrent.Future;
  27. import java.util.stream.Collectors;
  28. @Configuration
  29. @EnableScheduling
  30. public class PhotoSpeakSchedule {
  31. private final Logger logger = LoggerFactory.getLogger(this.getClass());
  32. @Autowired
  33. private PhotoSpeakVideoService photoSpeakVideoService;
  34. @Autowired
  35. VideoFactory videoFactory;
  36. @Autowired
  37. String videoType;
  38. @Autowired
  39. private UserCreateVideoNumService userCreateVideoNumService;
  40. /**
  41. * 生成视频
  42. */
  43. @Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次
  44. public void photoSpeakCreateSchedule() {
  45. logger.info("photoSpeakCreateSchedule :: start");
  46. PhotoSpeakVideo videoUpd = new PhotoSpeakVideo();
  47. videoUpd.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date()));
  48. videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode());
  49. List<PhotoSpeakVideo> list = photoSpeakVideoService.findList(videoUpd);
  50. if (list != null && list.size() > 0) {
  51. for (PhotoSpeakVideo video : list) {
  52. try {
  53. photoSpeakVideoService.createVideo(video);
  54. } catch (Exception e) {
  55. logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  56. }
  57. }
  58. }
  59. }
  60. /**
  61. * 上传阿里云
  62. */
  63. @Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次
  64. public void userVideoUploadSchedule() {
  65. logger.info("userVideoUploadSchedule :: start");
  66. List<PhotoSpeakVideo> videos = photoSpeakVideoService.getNotUploadList();
  67. if (videos != null && videos.size() > 0) {
  68. for (PhotoSpeakVideo video : videos) {
  69. try {
  70. photoSpeakVideoService.uploadVideo(video);
  71. } catch (Exception e) {
  72. logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  73. }
  74. }
  75. }
  76. }
  77. /**
  78. * 获取时长和大小
  79. */
  80. @Scheduled(cron = "0 1/5 * * * *?") // 每五分钟检查一次
  81. public void userVideoDetailSchedule() {
  82. logger.info("userVideoDetailSchedule :: start");
  83. List<PhotoSpeakVideo> videos = photoSpeakVideoService.getNotHaveUrl();
  84. if (videos != null && videos.size() > 0) {
  85. for (PhotoSpeakVideo video : videos) {
  86. try {
  87. VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId(),false);
  88. logger.info("userVideoDetailSchedule" + videoDetail);
  89. if (videoDetail.isSuccess()
  90. && StringUtils.isNotBlank(videoDetail.getDuration())
  91. && !"0.0".equals(videoDetail.getDuration())) {
  92. video.setCoverImg(videoDetail.getCoverURL());
  93. video.setVideoPlayUrl(videoDetail.getVideoUrl());
  94. Double _vt = Double.valueOf(videoDetail.getDuration());
  95. if (null != _vt && _vt > 0) {
  96. video.setVideoTime(videoDetail.getDuration());
  97. }
  98. video.setVideoSize(videoDetail.getSize());
  99. if (video.getVideoStatus() <= 5){
  100. video.setVideoStatus(EnumVideoStatus.upload_success.getCode());
  101. }else {
  102. video.setVideoStatus(EnumVideoStatus.hy_upload_success.getCode());
  103. }
  104. photoSpeakVideoService.updateById(video);
  105. }
  106. } catch (Exception e) {
  107. logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  108. }
  109. }
  110. }
  111. }
  112. /**
  113. * 超分上传阿里云
  114. */
  115. // @Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次
  116. // public void userVideoHyUploadSchedule() {
  117. // List<PhotoSpeakVideo> videos = photoSpeakVideoService.getNotHyUploadList();
  118. // if (videos != null && videos.size() > 0) {
  119. // for (PhotoSpeakVideo video : videos) {
  120. // try {
  121. // photoSpeakVideoService.uploadHyVideo(video);
  122. // } catch (Exception e) {
  123. // logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  124. // }
  125. // }
  126. // }
  127. // }
  128. /**
  129. * 获取超分时长和大小
  130. */
  131. // @Scheduled(cron = "0 1/5 * * * *?") // 每五分钟检查一次
  132. // public void userVideoHyDetailSchedule() {
  133. // List<PhotoSpeakVideo> videos = photoSpeakVideoService.getUpLoadHyIngList();
  134. // if (videos != null && videos.size() > 0) {
  135. // for (PhotoSpeakVideo video : videos) {
  136. // try {
  137. // VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId(),false);
  138. // if (videoDetail.isSuccess()
  139. // && StringUtils.isNotBlank(videoDetail.getDuration())
  140. // && !"0.0".equals(videoDetail.getDuration())) {
  141. // video.setCoverImg(videoDetail.getCoverURL());
  142. // video.setVideoPlayUrl(videoDetail.getVideoUrl());
  143. // video.setVideoTime(videoDetail.getDuration());
  144. // video.setVideoSize(videoDetail.getSize());
  145. // video.setVideoStatus(EnumVideoStatus.hy_upload_success.getCode());
  146. // photoSpeakVideoService.updateById(video);
  147. // }
  148. // } catch (Exception e) {
  149. // logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  150. // }
  151. // }
  152. // }
  153. // }
  154. /**
  155. * 超分生成视频
  156. */
  157. @Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次
  158. public void photoSpeakCreateHySchedule() {
  159. logger.info("photoSpeakCreateHySchedule :: start");
  160. PhotoSpeakVideo videoUpd = new PhotoSpeakVideo();
  161. videoUpd.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date()));
  162. videoUpd.setVideoStatus(EnumVideoStatus.hy_fail.getCode());
  163. List<PhotoSpeakVideo> list = photoSpeakVideoService.findList(videoUpd);
  164. if (list != null && list.size() > 0) {
  165. for (PhotoSpeakVideo video : list) {
  166. try {
  167. photoSpeakVideoService.videoHy(video);
  168. } catch (Exception e) {
  169. logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e);
  170. }
  171. }
  172. }
  173. }
  174. }