|
|
@@ -0,0 +1,106 @@ |
|
|
|
package com.iformall.schedule; |
|
|
|
|
|
|
|
import com.iformall.domain.po.sm.PhotoSpeakVideo; |
|
|
|
import com.iformall.domain.po.sm.UserMouldVideo; |
|
|
|
import com.iformall.domain.po.sm.VideoTrans; |
|
|
|
import com.iformall.enums.EnumVideoStatus; |
|
|
|
import com.iformall.enums.EnumaVideoTransStatus; |
|
|
|
import com.iformall.mapper.VideoTransMapper; |
|
|
|
import com.iformall.service.sm.PhotoSpeakVideoService; |
|
|
|
import com.iformall.service.sm.UserMouldVideoService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import com.iformall.video.VideoFactory; |
|
|
|
import com.iformall.video.entity.VideTransResult; |
|
|
|
import com.iformall.video.entity.VideUploadResult; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
@Configuration |
|
|
|
@EnableScheduling |
|
|
|
public class PhotoSpeakSchedule { |
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PhotoSpeakVideoService photoSpeakVideoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
VideoFactory videoFactory; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
String videoType; |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成视频 |
|
|
|
*/ |
|
|
|
@Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次 |
|
|
|
public void photoSpeakCreateSchedule() { |
|
|
|
PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); |
|
|
|
videoUpd.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date())); |
|
|
|
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); |
|
|
|
List<PhotoSpeakVideo> list = photoSpeakVideoService.findList(videoUpd); |
|
|
|
if (list != null && list.size() > 0) { |
|
|
|
for (PhotoSpeakVideo video : list) { |
|
|
|
try { |
|
|
|
Future future = photoSpeakVideoService.createVideo(video); |
|
|
|
future.get(); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上传阿里云 |
|
|
|
*/ |
|
|
|
@Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次 |
|
|
|
public void userVideoUploadSchedule() { |
|
|
|
List<PhotoSpeakVideo> videos = photoSpeakVideoService.getNotUploadList(); |
|
|
|
if (videos != null && videos.size() > 0) { |
|
|
|
for (PhotoSpeakVideo video : videos) { |
|
|
|
try { |
|
|
|
photoSpeakVideoService.uploadVideo(video); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取时长和大小 |
|
|
|
*/ |
|
|
|
@Scheduled(cron = "0 1/5 * * * *?") // 每五分钟检查一次 |
|
|
|
public void userVideoDetailSchedule() { |
|
|
|
List<PhotoSpeakVideo> videos = photoSpeakVideoService.getUpLoadIngList(); |
|
|
|
if (videos != null && videos.size() > 0) { |
|
|
|
for (PhotoSpeakVideo video : videos) { |
|
|
|
try { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId()); |
|
|
|
if (videoDetail.isSuccess() |
|
|
|
&& StringUtils.isNotBlank(videoDetail.getDuration()) |
|
|
|
&& !"0.0".equals(videoDetail.getDuration())) { |
|
|
|
video.setCoverImg(videoDetail.getCoverURL()); |
|
|
|
video.setVideoPlayUrl(videoDetail.getVideoUrl()); |
|
|
|
video.setVideoTime(videoDetail.getDuration()); |
|
|
|
video.setVideoSize(videoDetail.getSize()); |
|
|
|
video.setVideoStatus(EnumVideoStatus.upload_success.getCode()); |
|
|
|
photoSpeakVideoService.updateById(video); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |