|
|
|
@ -10,16 +10,14 @@ import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.supervision.enums.EnumMedicalRec;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.manage.dto.HumanGenerateDTO;
|
|
|
|
|
import com.supervision.manage.service.DirectoryInfoManageService;
|
|
|
|
|
import com.supervision.manage.service.FileManageService;
|
|
|
|
|
import com.supervision.manage.service.HumanManageService;
|
|
|
|
|
import com.supervision.model.AskPatientAnswer;
|
|
|
|
|
import com.supervision.model.FileResource;
|
|
|
|
|
import com.supervision.model.Human;
|
|
|
|
|
import com.supervision.model.MedicalRec;
|
|
|
|
|
import com.supervision.manage.service.MaterialLibraryManageService;
|
|
|
|
|
import com.supervision.model.*;
|
|
|
|
|
import com.supervision.service.AskPatientAnswerService;
|
|
|
|
|
import com.supervision.service.HumanService;
|
|
|
|
|
import com.supervision.service.MedicalRecService;
|
|
|
|
|
import com.supervision.util.OkHttpUtils;
|
|
|
|
|
import com.supervision.util.UserUtil;
|
|
|
|
|
import com.supervision.vo.manage.HumanReqVo;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
@ -49,6 +47,9 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
private final FileManageService fileManageService;
|
|
|
|
|
private final MedicalRecService medicalRecService;
|
|
|
|
|
private final AskPatientAnswerService askPatientAnswerService;
|
|
|
|
|
private final MaterialLibraryManageService mediaLibraryManageService;
|
|
|
|
|
private final DirectoryInfoManageService directoryInfoManageService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个线程池,本意是用来异步调用数字人使用的
|
|
|
|
|
* 核心线程数:2
|
|
|
|
@ -76,9 +77,22 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
File imageFile = fileManageService.downloadFile(human.getImageFileId());
|
|
|
|
|
// 创建一个图片临时文件
|
|
|
|
|
log.info("提交文件生成,文件名:{}", FileUtil.getName(imageFile));
|
|
|
|
|
generateSilent(human, imageFile, medicalId);
|
|
|
|
|
generateDynamic(human, imageFile, medicalId);
|
|
|
|
|
|
|
|
|
|
// 查询疾病信息
|
|
|
|
|
Map<String, String> dissesInfoByMedicalRecId = medicalRecService.queryDissesInfoByMedicalRecId(medicalId);
|
|
|
|
|
|
|
|
|
|
// 保存视频到素材中心
|
|
|
|
|
// 1.创建病例文件夹
|
|
|
|
|
DirectoryInfo directoryInfo = new DirectoryInfo();
|
|
|
|
|
directoryInfo.setDirectoryDesc(dissesInfoByMedicalRecId.get("diseaseNameAlias"));
|
|
|
|
|
directoryInfo.setDirectoryName(dissesInfoByMedicalRecId.get("diseaseName"));
|
|
|
|
|
String directoryId = directoryInfoManageService.addDirectory(directoryInfo);
|
|
|
|
|
|
|
|
|
|
// 2.上传视频素材到文件夹
|
|
|
|
|
// 静态
|
|
|
|
|
generateSilent(human, imageFile, medicalId, directoryId);
|
|
|
|
|
// 动态
|
|
|
|
|
generateDynamic(human, imageFile, medicalId, directoryId);
|
|
|
|
|
humanService.updateById(human);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -156,7 +170,20 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
return humanService.removeById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateSilent(Human human, File imageFile, String medicalId) throws Exception {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成静态视频
|
|
|
|
|
*
|
|
|
|
|
* @param human 数字人
|
|
|
|
|
* @param imageFile 数字人图片
|
|
|
|
|
* @param medicalId 病例id
|
|
|
|
|
* @param directoryId 目录id
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private void generateSilent(Human human, File imageFile, String medicalId, String directoryId) throws Exception {
|
|
|
|
|
|
|
|
|
|
log.info("提交文件生成静态视频,文件名:{}", FileUtil.getName(imageFile));
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isAllBlank(human.getSilentVideoFileId(), human.getSilentTaskUid())) {
|
|
|
|
|
HumanGenerateDTO silentDTO;
|
|
|
|
|
try {
|
|
|
|
@ -203,13 +230,33 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
medicalRecService.updateById(medicalRec1);
|
|
|
|
|
human.setSilentTaskUid(silentDTO.getUid());
|
|
|
|
|
|
|
|
|
|
// 上传视频素材
|
|
|
|
|
List<MaterialLibrary> materialLibraryList = new ArrayList<>();
|
|
|
|
|
MaterialLibrary mediaLibrarySilent = new MaterialLibrary();
|
|
|
|
|
mediaLibrarySilent.setDirectoryId(directoryId);
|
|
|
|
|
mediaLibrarySilent.setFileResourceId(fileResource.getId());
|
|
|
|
|
mediaLibrarySilent.setMaterialType(1);
|
|
|
|
|
materialLibraryList.add(mediaLibrarySilent);
|
|
|
|
|
mediaLibraryManageService.uploadMaterial(materialLibraryList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 生成动态视频
|
|
|
|
|
*
|
|
|
|
|
* @param human 数字人
|
|
|
|
|
* @param imageFile 数字人图片
|
|
|
|
|
* @param medicalId 病例id
|
|
|
|
|
* @param directoryId
|
|
|
|
|
* @return 动态视频资源
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private void generateDynamic(Human human, File imageFile, String medicalId, String directoryId) throws Exception {
|
|
|
|
|
|
|
|
|
|
log.info("提交文件生成动态视频,文件名:{}", imageFile.getPath());
|
|
|
|
|
|
|
|
|
|
private void generateDynamic(Human human, File imageFile, String medicalId) throws Exception {
|
|
|
|
|
if (StrUtil.isAllBlank(human.getDynamicVideoFileId(), human.getDynamicTaskUid())) {
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
@ -264,9 +311,17 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
medicalRec1.setId(medicalId);
|
|
|
|
|
medicalRecService.updateById(medicalRec1);
|
|
|
|
|
human.setDynamicTaskUid(dynamicDTO.getUid());
|
|
|
|
|
|
|
|
|
|
// 视频上传素材
|
|
|
|
|
List<MaterialLibrary> materialLibraryList = new ArrayList<>();
|
|
|
|
|
MaterialLibrary mediaLibraryDynamic = new MaterialLibrary();
|
|
|
|
|
mediaLibraryDynamic.setDirectoryId(directoryId);
|
|
|
|
|
mediaLibraryDynamic.setFileResourceId(fileResource.getId());
|
|
|
|
|
mediaLibraryDynamic.setMaterialType(1);
|
|
|
|
|
materialLibraryList.add(mediaLibraryDynamic);
|
|
|
|
|
mediaLibraryManageService.uploadMaterial(materialLibraryList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FileResource convertBase64ToFile(String prefixName, String imageFileName, String base64) throws Exception {
|
|
|
|
@ -297,6 +352,14 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
// 上传图片
|
|
|
|
|
FileResource fileResource = fileManageService.uploadFile(imageFile, imageFile.getContentType());
|
|
|
|
|
|
|
|
|
|
// 上传照片素材(目前导入中上传素材有且仅有一个图片)
|
|
|
|
|
List<MaterialLibrary> materialLibraryList = new ArrayList<>();
|
|
|
|
|
MaterialLibrary mediaLibrary = new MaterialLibrary();
|
|
|
|
|
mediaLibrary.setFileResourceId(fileResource.getId());
|
|
|
|
|
mediaLibrary.setMaterialType(0);
|
|
|
|
|
materialLibraryList.add(mediaLibrary);
|
|
|
|
|
mediaLibraryManageService.uploadMaterial(materialLibraryList);
|
|
|
|
|
|
|
|
|
|
// 生成数字人
|
|
|
|
|
Human human = new Human();
|
|
|
|
|
human.setImageFileId(fileResource.getId());
|
|
|
|
|