|  |  | @@ -1,5 +1,6 @@ | 
		
	
		
			
			|  |  |  | package com.iformall.service.sm.impl; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | import com.alibaba.fastjson.JSON; | 
		
	
		
			
			|  |  |  | import com.alibaba.fastjson.JSONArray; | 
		
	
		
			
			|  |  |  | import com.alibaba.fastjson.JSONObject; | 
		
	
		
			
			|  |  |  | import com.github.pagehelper.PageHelper; | 
		
	
	
		
			
				|  |  | @@ -7,16 +8,10 @@ import com.github.pagehelper.PageInfo; | 
		
	
		
			
			|  |  |  | import com.iformall.common.ErrorCode; | 
		
	
		
			
			|  |  |  | import com.iformall.common.IdWorker; | 
		
	
		
			
			|  |  |  | 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.VoiceMould; | 
		
	
		
			
			|  |  |  | import com.iformall.domain.po.sm.*; | 
		
	
		
			
			|  |  |  | import com.iformall.enums.*; | 
		
	
		
			
			|  |  |  | 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.VoiceMouldService; | 
		
	
		
			
			|  |  |  | import com.iformall.service.sm.*; | 
		
	
		
			
			|  |  |  | import com.iformall.sm.AiVideoHelper; | 
		
	
		
			
			|  |  |  | import com.iformall.sm.AiVideoParam; | 
		
	
		
			
			|  |  |  | import com.iformall.sm.AiVideoResult; | 
		
	
	
		
			
				|  |  | @@ -33,9 +28,7 @@ import org.springframework.scheduling.annotation.AsyncResult; | 
		
	
		
			
			|  |  |  | import org.springframework.stereotype.Service; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | import java.net.URL; | 
		
	
		
			
			|  |  |  | import java.util.ArrayList; | 
		
	
		
			
			|  |  |  | import java.util.Date; | 
		
	
		
			
			|  |  |  | import java.util.List; | 
		
	
		
			
			|  |  |  | import java.util.*; | 
		
	
		
			
			|  |  |  | import java.util.concurrent.Future; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
				|  |  | @@ -52,6 +45,9 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | 
		
	
		
			
			|  |  |  | @Autowired | 
		
	
		
			
			|  |  |  | VoiceMouldService voiceMouldService; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | @Autowired | 
		
	
		
			
			|  |  |  | VoiceInfoService voiceInfoService; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | @Autowired | 
		
	
		
			
			|  |  |  | MaterialMouldService materialMouldService; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
				|  |  | @@ -148,39 +144,65 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | 
		
	
		
			
			|  |  |  | record.setBackgroundId(personMould.getBackgroundId()); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | if(record.getVoiceMouldIds() != null && !record.getVoiceMouldIds().isEmpty()){ | 
		
	
		
			
			|  |  |  | if(record.getVoiceMouldIds().size() > 1){ | 
		
	
		
			
			|  |  |  | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"暂不支持声音模板交叉选择"); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | if(record.getVoiceMouldId() != null){ | 
		
	
		
			
			|  |  |  | VoiceInfo voiceMould = voiceInfoService.getById(record.getVoiceMouldId()); | 
		
	
		
			
			|  |  |  | if(voiceMould == null){ | 
		
	
		
			
			|  |  |  | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到声音模板信息"); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | Long voiceMouldId = record.getVoiceMouldIds().get(0); | 
		
	
		
			
			|  |  |  | if(voiceMouldId != null){ | 
		
	
		
			
			|  |  |  | VoiceMould voiceMould = voiceMouldService.getById(voiceMouldId); | 
		
	
		
			
			|  |  |  | if(voiceMould == null){ | 
		
	
		
			
			|  |  |  | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到声音模板信息"); | 
		
	
		
			
			|  |  |  | JSONObject voiceMouldObject = new JSONObject(); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("title",voiceMould.getLocalName()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("mouldSmId",voiceMould.getMouldSmId()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("sex",voiceMould.getSex()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personType",0); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personTypeStr","默认"); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakType",0); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakTypeStr","默认"); | 
		
	
		
			
			|  |  |  | EnumSpeakType speakType = null; | 
		
	
		
			
			|  |  |  | if(StringUtils.isNotBlank(record.getSpeakTypeStr())){ | 
		
	
		
			
			|  |  |  | speakType = EnumSpeakType.getEnumByMsg(record.getSpeakTypeStr()); | 
		
	
		
			
			|  |  |  | if(speakType == 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("mouldSmId",voiceMould.getMouldSmId()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personType",0); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personTypeStr","默认"); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakType",0); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakTypeStr","默认"); | 
		
	
		
			
			|  |  |  | if(EnumVoiceType.person.getCode().equals(voiceMould.getVoiceType())){ | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personType",voiceMould.getPersonType()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("personTypeStr",voiceMould.getPersonTypeStr()); | 
		
	
		
			
			|  |  |  | }else if(EnumVoiceType.speak.getCode().equals(voiceMould.getVoiceType())){ | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakType",voiceMould.getSpeakType()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakTypeStr",voiceMould.getSpeakTypeStr()); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | record.setVoiceMouldSm(voiceMouldObject.toJSONString()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakType",speakType.getCode()); | 
		
	
		
			
			|  |  |  | voiceMouldObject.put("speakTypeStr",speakType.getMessage()); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | record.setVoiceMouldSm(voiceMouldObject.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); | 
		
	
		
			
			|  |  |  | //            if(voiceMouldId != null){ | 
		
	
		
			
			|  |  |  | //                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("mouldSmId",voiceMould.getMouldSmId()); | 
		
	
		
			
			|  |  |  | //                voiceMouldObject.put("personType",0); | 
		
	
		
			
			|  |  |  | //                voiceMouldObject.put("personTypeStr","默认"); | 
		
	
		
			
			|  |  |  | //                voiceMouldObject.put("speakType",0); | 
		
	
		
			
			|  |  |  | //                voiceMouldObject.put("speakTypeStr","默认"); | 
		
	
		
			
			|  |  |  | //                if(EnumVoiceType.person.getCode().equals(voiceMould.getVoiceType())){ | 
		
	
		
			
			|  |  |  | //                    voiceMouldObject.put("personType",voiceMould.getPersonType()); | 
		
	
		
			
			|  |  |  | //                    voiceMouldObject.put("personTypeStr",voiceMould.getPersonTypeStr()); | 
		
	
		
			
			|  |  |  | //                }else if(EnumVoiceType.speak.getCode().equals(voiceMould.getVoiceType())){ | 
		
	
		
			
			|  |  |  | //                    voiceMouldObject.put("speakType",voiceMould.getSpeakType()); | 
		
	
		
			
			|  |  |  | //                    voiceMouldObject.put("speakTypeStr",voiceMould.getSpeakTypeStr()); | 
		
	
		
			
			|  |  |  | //                } | 
		
	
		
			
			|  |  |  | //                record.setVoiceMouldSm(voiceMouldObject.toJSONString()); | 
		
	
		
			
			|  |  |  | //            } | 
		
	
		
			
			|  |  |  | //        } | 
		
	
		
			
			|  |  |  | if(record.getBackgroundId() != null){ | 
		
	
		
			
			|  |  |  | MaterialMould background = materialMouldService.getById(record.getBackgroundId()); | 
		
	
		
			
			|  |  |  | if(background == null){ | 
		
	
	
		
			
				|  |  | @@ -266,6 +288,22 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | 
		
	
		
			
			|  |  |  | return new AsyncResult<>(0); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | Map<String,Object> subtitleMap = new HashMap<>(); | 
		
	
		
			
			|  |  |  | if(mouldVideo.getSubtitleEnabled() == null){ | 
		
	
		
			
			|  |  |  | subtitleMap.put("enabled",EnumYesOrNo.NO.getCode()); | 
		
	
		
			
			|  |  |  | }else{ | 
		
	
		
			
			|  |  |  | subtitleMap.put("enabled",mouldVideo.getSubtitleEnabled()); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | if(EnumYesOrNo.YES.getCode().equals(mouldVideo.getSubtitleEnabled())){ | 
		
	
		
			
			|  |  |  | Map titleParams = JSON.parseObject(mouldVideo.getSubtitleParams(),Map.class); | 
		
	
		
			
			|  |  |  | if(titleParams == null || titleParams.isEmpty()){ | 
		
	
		
			
			|  |  |  | subtitleMap.put("enabled",EnumYesOrNo.NO.getCode()); | 
		
	
		
			
			|  |  |  | }else{ | 
		
	
		
			
			|  |  |  | subtitleMap.put("params",titleParams); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | String voiceMouldSmId = null; | 
		
	
		
			
			|  |  |  | String voiceType = "default";//默认 | 
		
	
		
			
			|  |  |  | if(mouldVideo.getVoiceMouldId() == null){ | 
		
	
	
		
			
				|  |  | @@ -314,6 +352,7 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | 
		
	
		
			
			|  |  |  | AiVideoParam videoParam = new AiVideoParam(); | 
		
	
		
			
			|  |  |  | videoParam.setGen_txt(paperwork); | 
		
	
		
			
			|  |  |  | videoParam.setVideo_template_id(personMouldSmId); | 
		
	
		
			
			|  |  |  | videoParam.setSubtitle(subtitleMap); | 
		
	
		
			
			|  |  |  | videoParam.setVoice_id(voiceMouldSmId); | 
		
	
		
			
			|  |  |  | videoParam.setVoice_style(voiceType); | 
		
	
		
			
			|  |  |  | AiVideoParam.VideoFiles videoFiles = new AiVideoParam.VideoFiles(); | 
		
	
	
		
			
				|  |  | 
 |