|
|
@@ -0,0 +1,53 @@ |
|
|
|
package com.iformall.schedule; |
|
|
|
|
|
|
|
import com.iformall.domain.po.sm.UserMouldVideo; |
|
|
|
import com.iformall.domain.po.tt.TtCoupon; |
|
|
|
import com.iformall.mapper.TtCouponMapper; |
|
|
|
import com.iformall.service.sm.UserMouldVideoService; |
|
|
|
import com.iformall.video.VideoFactory; |
|
|
|
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.List; |
|
|
|
|
|
|
|
@Configuration |
|
|
|
@EnableScheduling |
|
|
|
public class VideoSchedule { |
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMouldVideoService userMouldVideoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
VideoFactory videoFactory; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
String videoType; |
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次 |
|
|
|
public void couponVideoSchedule() { |
|
|
|
List<UserMouldVideo> videos = userMouldVideoService.getVideoTimeNullList(); |
|
|
|
if (videos != null && videos.size() > 0) { |
|
|
|
for (UserMouldVideo video : videos) { |
|
|
|
try { |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId()); |
|
|
|
if (videoDetail.isSuccess() && StringUtils.isNotBlank(videoDetail.getDuration()) |
|
|
|
&& !"0.0".equals(videoDetail.getDuration())) { |
|
|
|
video.setVideoTime(videoDetail.getDuration()); |
|
|
|
userMouldVideoService.updateById(video); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |