| @@ -94,9 +94,9 @@ public class VideoController extends BaseController { | |||||
| title = multiReq.getOriginalFilename().substring(0,dot); | title = multiReq.getOriginalFilename().substring(0,dot); | ||||
| } | } | ||||
| } | } | ||||
| // if(!fileFormat.endsWith("mp4")){ | |||||
| // return new ResultData(ErrorCode.PICTURE_ENDWIDTH_ERROR); | |||||
| // } | |||||
| if(!fileFormat.endsWith("mp4") || !fileFormat.endsWith("mp3")){ | |||||
| return new ResultData(ErrorCode.PICTURE_ENDWIDTH_ERROR); | |||||
| } | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoStream(title, multiReq.getInputStream(),fileFormat); | VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoStream(title, multiReq.getInputStream(),fileFormat); | ||||
| result.setSize(String.valueOf(size)); | result.setSize(String.valueOf(size)); | ||||
| return new ResultData(result); | return new ResultData(result); | ||||
| @@ -148,4 +148,18 @@ public class VideoController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @GetMapping(value = "/videoDetial") | |||||
| @ApiOperation("视频详情") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData videoDetial(String videoId) { | |||||
| try { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(videoId); | |||||
| return new ResultData(videoDetail); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -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); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -80,7 +80,7 @@ public class UserMouldVideo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoPath") | @io.swagger.annotations.ApiModelProperty(value="",name="videoPath") | ||||
| private String videoPath; | private String videoPath; | ||||
| @io.swagger.annotations.ApiModelProperty(value="视频时长",name="videoTime") | @io.swagger.annotations.ApiModelProperty(value="视频时长",name="videoTime") | ||||
| private float videoTime; | |||||
| private String videoTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumVideoStatus 视频状态",name="videoStatus") | @io.swagger.annotations.ApiModelProperty(value="EnumVideoStatus 视频状态",name="videoStatus") | ||||
| private Integer videoStatus; | private Integer videoStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="生成视频信息",name="videoMsg") | @io.swagger.annotations.ApiModelProperty(value="生成视频信息",name="videoMsg") | ||||
| @@ -20,4 +20,6 @@ public interface UserMouldVideoMapper extends CommonMapper<UserMouldVideo, Long> | |||||
| List<UserMouldVideo> findCList(UserMouldVideo record); | List<UserMouldVideo> findCList(UserMouldVideo record); | ||||
| UserMouldVideo findVideo(@Param("id")Long id); | UserMouldVideo findVideo(@Param("id")Long id); | ||||
| List<UserMouldVideo> getVideoTimeNullList(); | |||||
| } | } | ||||
| @@ -5,6 +5,8 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.MouldPatch; | import com.iformall.domain.po.sm.MouldPatch; | ||||
| import com.iformall.domain.po.sm.UserMouldVideo; | import com.iformall.domain.po.sm.UserMouldVideo; | ||||
| import java.util.List; | |||||
| public interface UserMouldVideoService { | public interface UserMouldVideoService { | ||||
| /** | /** | ||||
| @@ -43,4 +45,8 @@ public interface UserMouldVideoService { | |||||
| void createVideo(UserMouldVideo mouldVideo); | void createVideo(UserMouldVideo mouldVideo); | ||||
| UserMouldVideo findVideo(Long id); | UserMouldVideo findVideo(Long id); | ||||
| List<UserMouldVideo> getVideoTimeNullList(); | |||||
| int updateById(UserMouldVideo video); | |||||
| } | } | ||||
| @@ -18,6 +18,7 @@ import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| @Service | @Service | ||||
| @@ -90,7 +91,7 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| AiVideoResult video = AiVideoHelper.createVideo(mouldVideo.getPersonMouldSmId(), mouldVideo.getVoiceMouldSmId(), mouldVideo.getPaperwork()); | AiVideoResult video = AiVideoHelper.createVideo(mouldVideo.getPersonMouldSmId(), mouldVideo.getVoiceMouldSmId(), mouldVideo.getPaperwork()); | ||||
| if(video.isSuccess()){ | if(video.isSuccess()){ | ||||
| videoUpd.setVideoPath(video.getUrl()); | videoUpd.setVideoPath(video.getUrl()); | ||||
| videoUpd.setVideoTime(video.getDuration()); | |||||
| videoUpd.setVideoTime(video.getDuration()+""); | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.success.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.success.getCode()); | ||||
| videoUpd.setVideoMsg(video.getMsg()); | videoUpd.setVideoMsg(video.getMsg()); | ||||
| videoUpd.setCreateVideoDate(new Date()); | videoUpd.setCreateVideoDate(new Date()); | ||||
| @@ -117,4 +118,14 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| return userMouldVideoMapper.findVideo(id); | return userMouldVideoMapper.findVideo(id); | ||||
| } | } | ||||
| @Override | |||||
| public List<UserMouldVideo> getVideoTimeNullList() { | |||||
| return userMouldVideoMapper.getVideoTimeNullList(); | |||||
| } | |||||
| @Override | |||||
| public int updateById(UserMouldVideo video) { | |||||
| return userMouldVideoMapper.updateById(video); | |||||
| } | |||||
| } | } | ||||
| @@ -40,7 +40,7 @@ public class AiVideoHelper { | |||||
| params.put("gen_txt",gen_txt); | params.put("gen_txt",gen_txt); | ||||
| String response = doPost(uri+"/gen_dh_video", params); | String response = doPost(uri+"/gen_dh_video", params); | ||||
| log.info("服务端预下单 request:"+params.toString()+" response:"+response); | |||||
| log.info("生成视频 request:"+params.toString()+" response:"+response); | |||||
| AiVideoResult result = new AiVideoResult(); | AiVideoResult result = new AiVideoResult(); | ||||
| @@ -18,7 +18,7 @@ | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | <result column="remark" jdbcType="VARCHAR" property="remark"/> | ||||
| <result column="video_id" jdbcType="VARCHAR" property="videoId"/> | <result column="video_id" jdbcType="VARCHAR" property="videoId"/> | ||||
| <result column="video_path" jdbcType="VARCHAR" property="videoPath"/> | <result column="video_path" jdbcType="VARCHAR" property="videoPath"/> | ||||
| <result column="video_time" jdbcType="FLOAT" property="videoTime"/> | |||||
| <result column="video_time" jdbcType="VARCHAR" property="videoTime"/> | |||||
| <result column="video_status" jdbcType="INTEGER" property="videoStatus"/> | <result column="video_status" jdbcType="INTEGER" property="videoStatus"/> | ||||
| <result column="video_msg" jdbcType="VARCHAR" property="videoMsg"/> | <result column="video_msg" jdbcType="VARCHAR" property="videoMsg"/> | ||||
| @@ -121,5 +121,10 @@ | |||||
| where `id` = #{id} | where `id` = #{id} | ||||
| </select> | </select> | ||||
| <select id="getVideoTimeNullList" resultMap="BaseResultMap"> | |||||
| select id,video_id videoId | |||||
| from user_mould_video | |||||
| where video_id is not null and video_time is null | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||