| @@ -39,7 +39,7 @@ public class VideoSchedule { | |||||
| /** | /** | ||||
| * 生成视频 | * 生成视频 | ||||
| */ | */ | ||||
| @Scheduled(cron = "0 20/30 * * * *?") // 每小时检查一次 | |||||
| @Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次 | |||||
| public void userVideoCreateSchedule() { | public void userVideoCreateSchedule() { | ||||
| UserMouldVideo userVideo = new UserMouldVideo(); | UserMouldVideo userVideo = new UserMouldVideo(); | ||||
| userVideo.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date())); | userVideo.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date())); | ||||
| @@ -60,9 +60,9 @@ public class VideoSchedule { | |||||
| /** | /** | ||||
| * 上传阿里云 | * 上传阿里云 | ||||
| */ | */ | ||||
| @Scheduled(cron = "0 */30 * * * *?") // 每小时检查一次 | |||||
| @Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次 | |||||
| public void userVideoUploadSchedule() { | public void userVideoUploadSchedule() { | ||||
| List<UserMouldVideo> videos = userMouldVideoService.getVideoIdNullList(); | |||||
| List<UserMouldVideo> videos = userMouldVideoService.getNotUploadList(); | |||||
| if (videos != null && videos.size() > 0) { | if (videos != null && videos.size() > 0) { | ||||
| for (UserMouldVideo video : videos) { | for (UserMouldVideo video : videos) { | ||||
| try { | try { | ||||
| @@ -77,9 +77,9 @@ public class VideoSchedule { | |||||
| /** | /** | ||||
| * 获取时长和大小 | * 获取时长和大小 | ||||
| */ | */ | ||||
| @Scheduled(cron = "0 15/30 * * * *?") // 每小时检查一次 | |||||
| @Scheduled(cron = "0 15/30 * * * *?") // 每半小时检查一次 | |||||
| public void userVideoDetailSchedule() { | public void userVideoDetailSchedule() { | ||||
| List<UserMouldVideo> videos = userMouldVideoService.getVideoSizeNullList(); | |||||
| List<UserMouldVideo> videos = userMouldVideoService.getUpLoadIngList(); | |||||
| if (videos != null && videos.size() > 0) { | if (videos != null && videos.size() > 0) { | ||||
| for (UserMouldVideo video : videos) { | for (UserMouldVideo video : videos) { | ||||
| try { | try { | ||||
| @@ -89,6 +89,7 @@ public class VideoSchedule { | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | && !"0.0".equals(videoDetail.getDuration())) { | ||||
| video.setVideoTime(videoDetail.getDuration()); | video.setVideoTime(videoDetail.getDuration()); | ||||
| video.setVideoSize(videoDetail.getSize()); | video.setVideoSize(videoDetail.getSize()); | ||||
| video.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| userMouldVideoService.updateById(video); | userMouldVideoService.updateById(video); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -74,19 +74,10 @@ public class UserMouldVideoController extends BaseController { | |||||
| if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){ | if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据"); | ||||
| } | } | ||||
| if(mouldVideo.getPersonMouldId() != null){ | |||||
| mouldVideo.setPersonMould(mouldPatchService.getDetailById(mouldVideo.getPersonMouldId())); | |||||
| } | |||||
| if(mouldVideo.getVoiceMouldId() != null){ | |||||
| mouldVideo.setVoiceMould(mouldPatchService.getDetailById(mouldVideo.getVoiceMouldId())); | |||||
| } | |||||
| if(mouldVideo.getBackgroundMouldId() != null){ | |||||
| mouldVideo.setBackgroundMould(mouldPatchService.getDetailById(mouldVideo.getBackgroundMouldId())); | |||||
| } | |||||
| return new ResultData(mouldVideo); | return new ResultData(mouldVideo); | ||||
| } | } | ||||
| @ApiOperation("根据id查询接口") | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | @GetMapping("/del") | ||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData del(Long id) { | public ResultData del(Long id) { | ||||
| @@ -44,30 +44,82 @@ public class UserMouldVideo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户Id",name="userId") | @io.swagger.annotations.ApiModelProperty(value="用户Id",name="userId") | ||||
| private Long userId; | private Long userId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumMouldVideoType",name="type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumVideoType",name="videoType") | |||||
| private Integer videoType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="人物模板ID",name="personMouldId") | @io.swagger.annotations.ApiModelProperty(value="人物模板ID",name="personMouldId") | ||||
| private Long personMouldId; | private Long personMouldId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="人物模板smId",name="personMouldSmId") | |||||
| private String personMouldSmId; | |||||
| /** | |||||
| * { | |||||
| * "id":, | |||||
| * "videoType":, | |||||
| * "title":, | |||||
| * "mouldSmId":, | |||||
| * "material": | |||||
| * } | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value="人物模板",name="personMouldSm") | |||||
| private String personMouldSm; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private MouldPatch personMould; | |||||
| private PersonMould personMould; | |||||
| @TableField(exist = false) | |||||
| private List<Long> voiceMouldIds; | |||||
| @io.swagger.annotations.ApiModelProperty(value="声音模板ID",name="voiceMouldId") | @io.swagger.annotations.ApiModelProperty(value="声音模板ID",name="voiceMouldId") | ||||
| private Long voiceMouldId; | private Long voiceMouldId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="声音模板smId",name="voiceMouldSmId") | |||||
| private String voiceMouldSmId; | |||||
| /** | |||||
| * { | |||||
| * "title":, | |||||
| * "languages":, | |||||
| * "mouldSmId":, | |||||
| * "personId":, | |||||
| * "personType":, | |||||
| * "speakId":, | |||||
| * "speakType": | |||||
| * } | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value="声音模板",name="voiceMouldSm") | |||||
| private String voiceMouldSm; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private MouldPatch voiceMould; | |||||
| private VoiceMould voiceMould; | |||||
| @io.swagger.annotations.ApiModelProperty(value="文案",name="paperwork") | @io.swagger.annotations.ApiModelProperty(value="文案",name="paperwork") | ||||
| private String paperwork; | private String paperwork; | ||||
| @io.swagger.annotations.ApiModelProperty(value="背景模板ID",name="backgroundMouldId") | |||||
| private Long backgroundMouldId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="背景模板smId",name="backgroundMouldSmId") | |||||
| private String backgroundMouldSmId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumLanguages",name="languages") | |||||
| private Integer languages; | |||||
| @io.swagger.annotations.ApiModelProperty(value="背景模板ID",name="backgroundId") | |||||
| private Long backgroundId; | |||||
| /** | |||||
| * { | |||||
| * "id":, | |||||
| * "title":, | |||||
| * "material": | |||||
| * } | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value="背景模板",name="backgroundSm") | |||||
| private String backgroundSm; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private MouldPatch backgroundMould; | |||||
| private MaterialMould backgroundMould; | |||||
| /** | |||||
| * List<Long> | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value="素材",name="materialIds") | |||||
| private String materialIds; | |||||
| /** | |||||
| * [{ | |||||
| * "id":, | |||||
| * "type":, | |||||
| * "material":, | |||||
| * "x":, | |||||
| * "y":, | |||||
| * "z":, | |||||
| * "w":, | |||||
| * "h": | |||||
| * },... | |||||
| * ] | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value="素材层级",name="materialAllJson") | |||||
| private String materialAllJson; | |||||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="title") | @io.swagger.annotations.ApiModelProperty(value="名称",name="title") | ||||
| private String title; | private String title; | ||||
| @@ -106,5 +158,7 @@ public class UserMouldVideo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @TableField(exist = false) | |||||
| private List<Integer> videoStatuss; | |||||
| } | } | ||||
| @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.common.SortColumn; | import com.iformall.common.SortColumn; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumAgeType; | import com.iformall.enums.EnumAgeType; | ||||
| import com.iformall.enums.EnumPersonaType; | |||||
| import com.iformall.enums.EnumPersonType; | |||||
| import com.iformall.enums.EnumSex; | import com.iformall.enums.EnumSex; | ||||
| import com.iformall.enums.EnumSpeakType; | import com.iformall.enums.EnumSpeakType; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| @@ -132,16 +132,16 @@ public class VoiceMould extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumVoiceType",name="voiceType") | @io.swagger.annotations.ApiModelProperty(value="EnumVoiceType",name="voiceType") | ||||
| private Integer voiceType; | private Integer voiceType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumPersonaType",name="personaType") | |||||
| private Integer personaType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumPersonType",name="personaType") | |||||
| private Integer personType; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String personaTypeStr; | |||||
| private String personTypeStr; | |||||
| public String getPersonaTypeStr(){ | public String getPersonaTypeStr(){ | ||||
| EnumPersonaType anEnum = EnumPersonaType.getEnum(this.personaType); | |||||
| EnumPersonType anEnum = EnumPersonType.getEnum(this.personType); | |||||
| if(anEnum != null){ | if(anEnum != null){ | ||||
| personaTypeStr = anEnum.getMessage(); | |||||
| personTypeStr = anEnum.getMessage(); | |||||
| } | } | ||||
| return personaTypeStr; | |||||
| return personTypeStr; | |||||
| } | } | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumSpeakType",name="speakType") | @io.swagger.annotations.ApiModelProperty(value="EnumSpeakType",name="speakType") | ||||
| @@ -149,7 +149,7 @@ public class VoiceMould extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String speakTypeStr; | private String speakTypeStr; | ||||
| public String getSpeakTypeStr(){ | public String getSpeakTypeStr(){ | ||||
| EnumSpeakType anEnum = EnumSpeakType.getEnum(this.personaType); | |||||
| EnumSpeakType anEnum = EnumSpeakType.getEnum(this.speakType); | |||||
| if(anEnum != null){ | if(anEnum != null){ | ||||
| speakTypeStr = anEnum.getMessage(); | speakTypeStr = anEnum.getMessage(); | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| package com.iformall.enums; | package com.iformall.enums; | ||||
| public enum EnumPersonaType { | |||||
| public enum EnumPersonType { | |||||
| /** | /** | ||||
| * | Boy | 角色风格 | 男孩 | 声音模仿男孩 | | * | Boy | 角色风格 | 男孩 | 声音模仿男孩 | | ||||
| * | Girl | 角色风格 | 女孩 | 声音模仿女孩 | | * | Girl | 角色风格 | 女孩 | 声音模仿女孩 | | ||||
| @@ -25,8 +25,8 @@ public enum EnumPersonaType { | |||||
| YoungAdultMale(8,"男青年","YoungAdultMale"), | YoungAdultMale(8,"男青年","YoungAdultMale"), | ||||
| ; | ; | ||||
| public static EnumPersonaType getEnum(Integer code) { | |||||
| for (EnumPersonaType value : values()) { | |||||
| public static EnumPersonType getEnum(Integer code) { | |||||
| for (EnumPersonType value : values()) { | |||||
| if (value.getCode().equals(code)) { | if (value.getCode().equals(code)) { | ||||
| return value; | return value; | ||||
| } | } | ||||
| @@ -34,7 +34,7 @@ public enum EnumPersonaType { | |||||
| return null; | return null; | ||||
| } | } | ||||
| private EnumPersonaType(Integer code, String message, String type) { | |||||
| private EnumPersonType(Integer code, String message, String type) { | |||||
| this.code = code; | this.code = code; | ||||
| this.message = message; | this.message = message; | ||||
| this.type = type; | this.type = type; | ||||
| @@ -11,8 +11,12 @@ public enum EnumVideoStatus { | |||||
| draft(0, "草稿"), | draft(0, "草稿"), | ||||
| ing(1, "生成视频中"), | ing(1, "生成视频中"), | ||||
| success(2, "生成视频成功"), | |||||
| success(2,"生成视频成功"), | |||||
| fail(3, "生成视频失败"), | fail(3, "生成视频失败"), | ||||
| upload_ing(4,"上传视频中"), | |||||
| upload_success(5,"上传视频成功"), | |||||
| upload_fail(6,"上传视频失败") | |||||
| ; | ; | ||||
| public static EnumVideoStatus getEnum(Integer code) { | public static EnumVideoStatus getEnum(Integer code) { | ||||
| @@ -6,7 +6,7 @@ package com.iformall.enums; | |||||
| public enum EnumVoiceType { | public enum EnumVoiceType { | ||||
| default_0(0, "默认"), | default_0(0, "默认"), | ||||
| persona(1,"角色风格"), | |||||
| person(1,"角色风格"), | |||||
| speak(2, "说话风格"), | speak(2, "说话风格"), | ||||
| ; | ; | ||||
| @@ -21,7 +21,6 @@ public interface UserMouldVideoMapper extends CommonMapper<UserMouldVideo, Long> | |||||
| UserMouldVideo findVideo(@Param("id")Long id); | UserMouldVideo findVideo(@Param("id")Long id); | ||||
| List<UserMouldVideo> getVideoIdNullList(); | |||||
| List<UserMouldVideo> getSortList(UserMouldVideo record); | |||||
| List<UserMouldVideo> getVideoSizeNullList(); | |||||
| } | } | ||||
| @@ -51,9 +51,9 @@ public interface UserMouldVideoService { | |||||
| UserMouldVideo findVideo(Long id); | UserMouldVideo findVideo(Long id); | ||||
| List<UserMouldVideo> getVideoIdNullList(); | |||||
| List<UserMouldVideo> getNotUploadList(); | |||||
| List<UserMouldVideo> getVideoSizeNullList(); | |||||
| List<UserMouldVideo> getUpLoadIngList(); | |||||
| int updateById(UserMouldVideo video); | int updateById(UserMouldVideo video); | ||||
| @@ -1,13 +1,24 @@ | |||||
| package com.iformall.service.sm.impl; | package com.iformall.service.sm.impl; | ||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.sm.MaterialMould; | |||||
| import com.iformall.domain.po.sm.PersonMould; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | import com.iformall.domain.po.sm.UserMouldVideo; | ||||
| import com.iformall.domain.po.sm.VoiceMould; | |||||
| import com.iformall.enums.EnumMouldPatchType; | |||||
| import com.iformall.enums.EnumVideoStatus; | import com.iformall.enums.EnumVideoStatus; | ||||
| import com.iformall.enums.EnumVoiceType; | |||||
| import com.iformall.mapper.UserMouldVideoMapper; | import com.iformall.mapper.UserMouldVideoMapper; | ||||
| import com.iformall.service.sm.MaterialMouldService; | |||||
| import com.iformall.service.sm.PersonMouldService; | |||||
| import com.iformall.service.sm.UserMouldVideoService; | import com.iformall.service.sm.UserMouldVideoService; | ||||
| import com.iformall.service.sm.VoiceMouldService; | |||||
| import com.iformall.sm.AiVideoHelper; | import com.iformall.sm.AiVideoHelper; | ||||
| import com.iformall.sm.AiVideoResult; | import com.iformall.sm.AiVideoResult; | ||||
| import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
| @@ -21,6 +32,7 @@ import org.springframework.scheduling.annotation.AsyncResult; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.concurrent.Future; | import java.util.concurrent.Future; | ||||
| @@ -33,6 +45,15 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| @Autowired | @Autowired | ||||
| UserMouldVideoMapper userMouldVideoMapper; | UserMouldVideoMapper userMouldVideoMapper; | ||||
| @Autowired | |||||
| PersonMouldService personMouldService; | |||||
| @Autowired | |||||
| VoiceMouldService voiceMouldService; | |||||
| @Autowired | |||||
| MaterialMouldService materialMouldService; | |||||
| @Autowired | @Autowired | ||||
| VideoFactory videoFactory; | VideoFactory videoFactory; | ||||
| @@ -62,6 +83,90 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| @Override | @Override | ||||
| public ResultData saveOrUpdate(UserMouldVideo record) { | public ResultData saveOrUpdate(UserMouldVideo record) { | ||||
| if(record.getPersonMouldId() != null){ | |||||
| PersonMould personMould = personMouldService.getById(record.getPersonMouldId()); | |||||
| if(personMould == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到人物模板信息"); | |||||
| } | |||||
| record.setVideoType(personMould.getVideoType()); | |||||
| JSONObject personMouldObject = new JSONObject(); | |||||
| personMouldObject.put("id",personMould.getId()); | |||||
| personMouldObject.put("videoType",personMould.getVideoType()); | |||||
| personMouldObject.put("title",personMould.getTitle()); | |||||
| personMouldObject.put("mouldSmId",personMould.getMouldSmId()); | |||||
| personMouldObject.put("material",personMould.getMaterial()); | |||||
| record.setPersonMouldSm(personMouldObject.toJSONString()); | |||||
| } | |||||
| if(record.getVoiceMouldIds() != null && !record.getVoiceMouldIds().isEmpty()){ | |||||
| if(record.getVoiceMouldIds().size() > 1){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"暂不支持声音模板交叉选择"); | |||||
| } | |||||
| Long voiceMouldId = record.getVoiceMouldIds().get(0); | |||||
| VoiceMould voiceMould = voiceMouldService.getById(voiceMouldId); | |||||
| if(voiceMould == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到声音模板信息"); | |||||
| } | |||||
| record.setLanguages(voiceMould.getLanguages()); | |||||
| if(voiceMould.getParentId().equals(0L)){ | |||||
| record.setVoiceMouldId(voiceMould.getId()); | |||||
| }else{ | |||||
| record.setVoiceMouldId(voiceMould.getParentId()); | |||||
| } | |||||
| JSONObject voiceMouldObject = new JSONObject(); | |||||
| voiceMouldObject.put("title",voiceMould.getTitle()); | |||||
| voiceMouldObject.put("languages",voiceMould.getLanguages()); | |||||
| voiceMouldObject.put("mouldSmId",voiceMould.getMouldSmId()); | |||||
| voiceMouldObject.put("personId",0l); | |||||
| voiceMouldObject.put("personType",0); | |||||
| voiceMouldObject.put("speakId",0l); | |||||
| voiceMouldObject.put("speakType",0); | |||||
| if(EnumVoiceType.person.getCode().equals(voiceMould.getVoiceType())){ | |||||
| voiceMouldObject.put("personId",voiceMould.getId()); | |||||
| voiceMouldObject.put("personType",voiceMould.getPersonType()); | |||||
| }else if(EnumVoiceType.speak.getCode().equals(voiceMould.getVoiceType())){ | |||||
| voiceMouldObject.put("speakId",voiceMould.getId()); | |||||
| voiceMouldObject.put("speakType",voiceMould.getPersonType()); | |||||
| } | |||||
| record.setVoiceMouldSm(voiceMouldObject.toJSONString()); | |||||
| } | |||||
| if(record.getBackgroundId() != null){ | |||||
| MaterialMould background = materialMouldService.getById(record.getBackgroundId()); | |||||
| if(background == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到背景信息"); | |||||
| } | |||||
| JSONObject backgroundObject = new JSONObject(); | |||||
| backgroundObject.put("id",background.getId()); | |||||
| backgroundObject.put("title",background.getTitle()); | |||||
| backgroundObject.put("material",background.getMaterial()); | |||||
| record.setVoiceMouldSm(backgroundObject.toJSONString()); | |||||
| } | |||||
| if(StringUtils.isNotBlank(record.getMaterialAllJson())){ | |||||
| logger.info("MaterialAllJson--->>" + record.getMaterialAllJson()); | |||||
| try{ | |||||
| List<Long> materialIds = new ArrayList<>(); | |||||
| JSONArray materialAllArray = JSONArray.parseArray(record.getMaterialAllJson()); | |||||
| if(materialAllArray != null && !materialAllArray.isEmpty()){ | |||||
| for(int i = 0;i < materialAllArray.size();i++) { | |||||
| JSONObject jsonObject = materialAllArray.getJSONObject(i); | |||||
| Long id = jsonObject.getLong("id"); | |||||
| Integer type = jsonObject.getInteger("type"); | |||||
| if(EnumMouldPatchType.material_mould.getCode().equals(type)){ | |||||
| materialIds.add(id); | |||||
| } | |||||
| String material = jsonObject.getString("material"); | |||||
| Integer x = jsonObject.getInteger("x"); | |||||
| Integer y = jsonObject.getInteger("y"); | |||||
| Integer z = jsonObject.getInteger("z"); | |||||
| Integer w = jsonObject.getInteger("w"); | |||||
| Integer h = jsonObject.getInteger("h"); | |||||
| } | |||||
| } | |||||
| record.setMaterialIds(JSONArray.toJSONString(materialIds)); | |||||
| }catch(Exception e){ | |||||
| e.printStackTrace(); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"素材层级数据错误"); | |||||
| } | |||||
| } | |||||
| Date now = new Date(); | Date now = new Date(); | ||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| @@ -86,35 +191,64 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| @Async | @Async | ||||
| @Override | @Override | ||||
| public Future createVideo(UserMouldVideo mouldVideo) { | public Future createVideo(UserMouldVideo mouldVideo) { | ||||
| boolean isCreate = false; | |||||
| String msg = ""; | |||||
| UserMouldVideo videoUpd = new UserMouldVideo(); | UserMouldVideo videoUpd = new UserMouldVideo(); | ||||
| videoUpd.setId(mouldVideo.getId()); | videoUpd.setId(mouldVideo.getId()); | ||||
| if(StringUtils.isBlank(mouldVideo.getPersonMouldSmId())){ | |||||
| String personMouldSmId = null; | |||||
| if(mouldVideo.getPersonMouldId() == null){ | |||||
| msg = "未选择人物模板"; | |||||
| }else{ | |||||
| try{ | |||||
| JSONObject personMouldObject = JSONObject.parseObject(mouldVideo.getPersonMouldSm()); | |||||
| personMouldSmId = personMouldObject.getString("mouldSmId"); | |||||
| }catch(Exception e){ | |||||
| msg = "参数错误,未找到人物模板数据"; | |||||
| } | |||||
| } | |||||
| if(StringUtils.isBlank(personMouldSmId)){ | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | ||||
| videoUpd.setVideoMsg("未找到人物模板数据"); | |||||
| videoUpd.setVideoMsg(msg); | |||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| return new AsyncResult<>(0); | return new AsyncResult<>(0); | ||||
| } | } | ||||
| if(StringUtils.isBlank(mouldVideo.getPaperwork())){ | |||||
| String voiceMouldSmId = null; | |||||
| if(mouldVideo.getVoiceMouldId() == null){ | |||||
| msg = "未选择声音模板"; | |||||
| }else{ | |||||
| try{ | |||||
| JSONObject personMouldObject = JSONObject.parseObject(mouldVideo.getVoiceMouldSm()); | |||||
| voiceMouldSmId = personMouldObject.getString("mouldSmId"); | |||||
| }catch(Exception e){ | |||||
| msg = "参数错误,未找到声音模板数据"; | |||||
| } | |||||
| } | |||||
| if(StringUtils.isBlank(voiceMouldSmId)){ | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | ||||
| videoUpd.setVideoMsg("未填写视频文案"); | |||||
| videoUpd.setVideoMsg(msg); | |||||
| this.saveOrUpdate(videoUpd); | |||||
| return new AsyncResult<>(0); | |||||
| } | |||||
| String paperwork = mouldVideo.getPaperwork(); | |||||
| if(StringUtils.isBlank(paperwork)){ | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| videoUpd.setVideoMsg("未填写视频文案数据"); | |||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| return new AsyncResult<>(0); | return new AsyncResult<>(0); | ||||
| } | } | ||||
| try{ | try{ | ||||
| AiVideoResult video = AiVideoHelper.createVideo(mouldVideo.getPersonMouldSmId(), mouldVideo.getVoiceMouldSmId(), mouldVideo.getPaperwork()); | |||||
| AiVideoResult video = AiVideoHelper.createVideo(personMouldSmId, voiceMouldSmId, paperwork); | |||||
| 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("success"); | |||||
| videoUpd.setCreateVideoDate(new Date()); | videoUpd.setCreateVideoDate(new Date()); | ||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| videoUpd.setTitle(mouldVideo.getTitle()); | |||||
| this.uploadVideo(videoUpd); | |||||
| return new AsyncResult<>(1); | return new AsyncResult<>(1); | ||||
| } | } | ||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | ||||
| @@ -135,13 +269,14 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| @Override | @Override | ||||
| public void uploadVideo(UserMouldVideo mouldVideo){ | public void uploadVideo(UserMouldVideo mouldVideo){ | ||||
| if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | ||||
| && StringUtils.isBlank(mouldVideo.getVideoId())){ | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ | |||||
| String url = mouldVideo.getVideoPathUri() + mouldVideo.getVideoPath(); | String url = mouldVideo.getVideoPathUri() + mouldVideo.getVideoPath(); | ||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | ||||
| if(result.isSuccess()){ | if(result.isSuccess()){ | ||||
| UserMouldVideo videoUpd = new UserMouldVideo(); | UserMouldVideo videoUpd = new UserMouldVideo(); | ||||
| videoUpd.setId(mouldVideo.getId()); | videoUpd.setId(mouldVideo.getId()); | ||||
| videoUpd.setVideoId(result.getVideoId()); | videoUpd.setVideoId(result.getVideoId()); | ||||
| videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| } | } | ||||
| } | } | ||||
| @@ -153,13 +288,20 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<UserMouldVideo> getVideoIdNullList() { | |||||
| return userMouldVideoMapper.getVideoIdNullList(); | |||||
| public List<UserMouldVideo> getNotUploadList() { | |||||
| UserMouldVideo umVideoQ = new UserMouldVideo(); | |||||
| List<Integer> videoStatuss = new ArrayList<>(); | |||||
| videoStatuss.add(EnumVideoStatus.success.getCode()); | |||||
| videoStatuss.add(EnumVideoStatus.upload_fail.getCode()); | |||||
| umVideoQ.setVideoStatuss(videoStatuss); | |||||
| return userMouldVideoMapper.getSortList(umVideoQ); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<UserMouldVideo> getVideoSizeNullList() { | |||||
| return userMouldVideoMapper.getVideoSizeNullList(); | |||||
| public List<UserMouldVideo> getUpLoadIngList() { | |||||
| UserMouldVideo umVideoQ = new UserMouldVideo(); | |||||
| umVideoQ.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| return userMouldVideoMapper.getSortList(umVideoQ); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -6,14 +6,17 @@ | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | ||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | ||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | <result column="user_id" jdbcType="BIGINT" property="userId"/> | ||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="video_type" jdbcType="INTEGER" property="videoType"/> | |||||
| <result column="person_mould_id" jdbcType="BIGINT" property="personMouldId"/> | <result column="person_mould_id" jdbcType="BIGINT" property="personMouldId"/> | ||||
| <result column="person_mould_sm_id" jdbcType="VARCHAR" property="personMouldSmId"/> | |||||
| <result column="person_mould_sm" jdbcType="VARCHAR" property="personMouldSm"/> | |||||
| <result column="voice_mould_id" jdbcType="BIGINT" property="voiceMouldId"/> | <result column="voice_mould_id" jdbcType="BIGINT" property="voiceMouldId"/> | ||||
| <result column="voice_mould_sm_id" jdbcType="VARCHAR" property="voiceMouldSmId"/> | |||||
| <result column="voice_mould_sm" jdbcType="VARCHAR" property="voiceMouldSm"/> | |||||
| <result column="languages" jdbcType="INTEGER" property="languages"/> | |||||
| <result column="paperwork" jdbcType="VARCHAR" property="paperwork"/> | <result column="paperwork" jdbcType="VARCHAR" property="paperwork"/> | ||||
| <result column="background_mould_id" jdbcType="BIGINT" property="backgroundMouldId"/> | |||||
| <result column="background_mould_sm_id" jdbcType="VARCHAR" property="backgroundMouldSmId"/> | |||||
| <result column="background_id" jdbcType="BIGINT" property="backgroundId"/> | |||||
| <result column="background_sm" jdbcType="VARCHAR" property="backgroundSm"/> | |||||
| <result column="material_ids" jdbcType="VARCHAR" property="materialIds"/> | |||||
| <result column="material_all_json" jdbcType="VARCHAR" property="materialAllJson"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | <result column="title" jdbcType="VARCHAR" property="title"/> | ||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | ||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | <result column="remark" jdbcType="VARCHAR" property="remark"/> | ||||
| @@ -30,8 +33,8 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `parent_tenant_id`, `user_id`, `type`, | |||||
| `person_mould_id`, `person_mould_sm_id`, `voice_mould_id`, `voice_mould_sm_id`, `paperwork`, `background_mould_id`, `background_mould_sm_id`, | |||||
| `id`, `tenant_id`, `parent_tenant_id`, `user_id`, `video_type`, | |||||
| `person_mould_id`, `person_mould_sm`, `voice_mould_id`, `voice_mould_sm`, `languages`, `paperwork`, `background_id`, `background_sm`,`material_ids`,`material_all_json`, | |||||
| `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_time`, `video_size`, `video_status`, `video_msg`, `create_video_date`, `create_date`, `update_date` | `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_time`, `video_size`, `video_status`, `video_msg`, `create_video_date`, `create_date`, `update_date` | ||||
| </sql> | </sql> | ||||
| @@ -53,8 +56,8 @@ | |||||
| and `user_id` = #{userId} | and `user_id` = #{userId} | ||||
| </if> | </if> | ||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| <if test=" null != videoType "> | |||||
| and `video_type` = #{videoType} | |||||
| </if> | </if> | ||||
| <if test=" null != personMouldId "> | <if test=" null != personMouldId "> | ||||
| @@ -66,7 +69,7 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != backgroundMouldId "> | <if test=" null != backgroundMouldId "> | ||||
| and `background_mould_id` = #{backgroundMouldId} | |||||
| and `background_id` = #{backgroundId} | |||||
| </if> | </if> | ||||
| <if test=" null != title and ''!=title"> | <if test=" null != title and ''!=title"> | ||||
| @@ -91,6 +94,13 @@ | |||||
| and create_video_date < #{videoEndDate} | and create_video_date < #{videoEndDate} | ||||
| </if> | </if> | ||||
| <if test=" null != videoStatuss "> | |||||
| and video_status in | |||||
| <foreach collection="videoStatuss" index="index" item="videoStatusItem" open="(" separator="," close=")"> | |||||
| #{videoStatusItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -114,7 +124,7 @@ | |||||
| <select id="findCList" parameterType="com.iformall.domain.po.sm.UserMouldVideo" resultMap="BaseResultMap"> | <select id="findCList" parameterType="com.iformall.domain.po.sm.UserMouldVideo" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| `id`, `type`, | |||||
| `id`, `video_type`, | |||||
| `paperwork`, | `paperwork`, | ||||
| `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_time`, `video_size`, `video_status`, | `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_time`, `video_size`, `video_status`, | ||||
| `create_video_date`, `create_date`, `update_date` | `create_video_date`, `create_date`, `update_date` | ||||
| @@ -125,25 +135,16 @@ | |||||
| <select id="findVideo" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | <select id="findVideo" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| `video_id`, `video_path`, `video_time`, `video_size`, `video_status`, `video_msg` | |||||
| `video_type`,`video_id`, `video_path`, `video_time`, `video_size`, `video_status`, `video_msg` | |||||
| from user_mould_video | from user_mould_video | ||||
| where `id` = #{id} | where `id` = #{id} | ||||
| </select> | </select> | ||||
| <select id="getVideoIdNullList" resultMap="BaseResultMap"> | |||||
| <select id="getSortList" parameterType="com.iformall.domain.po.sm.UserMouldVideo" resultMap="BaseResultMap"> | |||||
| select id,title,video_id,video_path,video_status | select id,title,video_id,video_path,video_status | ||||
| from user_mould_video | from user_mould_video | ||||
| where `is_del` = 0 | |||||
| and video_path is not null and video_path != '' | |||||
| and (video_id is null or video_id = '') | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | </select> | ||||
| <select id="getVideoSizeNullList" resultMap="BaseResultMap"> | |||||
| select id,video_id | |||||
| from user_mould_video | |||||
| where `is_del` = 0 | |||||
| and video_id is not null and video_path != '' | |||||
| and video_size is null | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -23,7 +23,7 @@ | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | <result column="remark" jdbcType="VARCHAR" property="remark"/> | ||||
| <result column="mould_sm_id" jdbcType="VARCHAR" property="mouldSmId"/> | <result column="mould_sm_id" jdbcType="VARCHAR" property="mouldSmId"/> | ||||
| <result column="voice_type" jdbcType="INTEGER" property="voiceType"/> | <result column="voice_type" jdbcType="INTEGER" property="voiceType"/> | ||||
| <result column="persona_type" jdbcType="INTEGER" property="personaType"/> | |||||
| <result column="person_type" jdbcType="INTEGER" property="personType"/> | |||||
| <result column="speak_type" jdbcType="INTEGER" property="speakType"/> | <result column="speak_type" jdbcType="INTEGER" property="speakType"/> | ||||
| <result column="example_video_id" jdbcType="VARCHAR" property="exampleVideoId"/> | <result column="example_video_id" jdbcType="VARCHAR" property="exampleVideoId"/> | ||||
| <result column="status" jdbcType="INTEGER" property="status"/> | <result column="status" jdbcType="INTEGER" property="status"/> | ||||
| @@ -35,7 +35,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `parent_tenant_id`, `parent_id`, `count_sub`, `cover_img`, `cover_picture`, `detail_picture`, | `id`, `tenant_id`, `parent_tenant_id`, `parent_id`, `count_sub`, `cover_img`, `cover_picture`, `detail_picture`, | ||||
| `title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`, | `title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`, | ||||
| `send_type`, `detail`, `remark`, `mould_sm_id`,`voice_type`,`persona_type`,`speak_type`, `example_video_id`, `status`, `puton_date`, `create_date`, `update_date` | |||||
| `send_type`, `detail`, `remark`, `mould_sm_id`,`voice_type`,`person_type`,`speak_type`, `example_video_id`, `status`, `puton_date`, `create_date`, `update_date` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -104,8 +104,8 @@ | |||||
| and `voice_type` = #{voiceType} | and `voice_type` = #{voiceType} | ||||
| </if> | </if> | ||||
| <if test=" null != personaType "> | |||||
| and `persona_type` = #{personaType} | |||||
| <if test=" null != personType "> | |||||
| and `person_type` = #{personType} | |||||
| </if> | </if> | ||||
| <if test=" null != speakType "> | <if test=" null != speakType "> | ||||
| @@ -144,7 +144,7 @@ | |||||
| select | select | ||||
| `id`, `parent_tenant_id`, `parent_id`, `cover_img`, `cover_picture`, | `id`, `parent_tenant_id`, `parent_id`, `cover_img`, `cover_picture`, | ||||
| `title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`, | `title`, `sub_title`, `sex`, `age_type`, `languages`, `scene_sign`, `sale_price`, `price`, | ||||
| `send_type`, `mould_sm_id`,`voice_type`,`persona_type`,`speak_type`, `status`,`example_video_id`, `create_date`, `update_date` | |||||
| `send_type`, `mould_sm_id`,`voice_type`,`person_type`,`speak_type`, `status`,`example_video_id`, `create_date`, `update_date` | |||||
| from voice_mould | from voice_mould | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||