|
|
@ -7,6 +7,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
import com.supervision.enums.EnumMedicalRec;
|
|
|
|
import com.supervision.enums.EnumMedicalRec;
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
import com.supervision.manage.dto.HumanGenerateDTO;
|
|
|
|
import com.supervision.manage.dto.HumanGenerateDTO;
|
|
|
@ -16,6 +17,7 @@ import com.supervision.manage.service.HumanManageService;
|
|
|
|
import com.supervision.manage.service.MaterialLibraryManageService;
|
|
|
|
import com.supervision.manage.service.MaterialLibraryManageService;
|
|
|
|
import com.supervision.model.*;
|
|
|
|
import com.supervision.model.*;
|
|
|
|
import com.supervision.service.AskPatientAnswerService;
|
|
|
|
import com.supervision.service.AskPatientAnswerService;
|
|
|
|
|
|
|
|
import com.supervision.service.DirectoryInfoService;
|
|
|
|
import com.supervision.service.HumanService;
|
|
|
|
import com.supervision.service.HumanService;
|
|
|
|
import com.supervision.service.MedicalRecService;
|
|
|
|
import com.supervision.service.MedicalRecService;
|
|
|
|
import com.supervision.util.UserUtil;
|
|
|
|
import com.supervision.util.UserUtil;
|
|
|
@ -24,6 +26,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -49,6 +52,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
private final AskPatientAnswerService askPatientAnswerService;
|
|
|
|
private final AskPatientAnswerService askPatientAnswerService;
|
|
|
|
private final MaterialLibraryManageService mediaLibraryManageService;
|
|
|
|
private final MaterialLibraryManageService mediaLibraryManageService;
|
|
|
|
private final DirectoryInfoManageService directoryInfoManageService;
|
|
|
|
private final DirectoryInfoManageService directoryInfoManageService;
|
|
|
|
|
|
|
|
private final DirectoryInfoService directoryInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 创建一个线程池,本意是用来异步调用数字人使用的
|
|
|
|
* 创建一个线程池,本意是用来异步调用数字人使用的
|
|
|
@ -75,18 +79,25 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
Human human = humanService.getOptById(humanId).orElseThrow(() -> new BusinessException("数字人形象不存在"));
|
|
|
|
Human human = humanService.getOptById(humanId).orElseThrow(() -> new BusinessException("数字人形象不存在"));
|
|
|
|
|
|
|
|
|
|
|
|
File imageFile = fileManageService.downloadFile(human.getImageFileId());
|
|
|
|
File imageFile = fileManageService.downloadFile(human.getImageFileId());
|
|
|
|
// 创建一个图片临时文件
|
|
|
|
|
|
|
|
log.info("提交文件生成,文件名:{}", FileUtil.getName(imageFile));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询疾病信息
|
|
|
|
// 查询疾病信息
|
|
|
|
Map<String, String> dissesInfoByMedicalRecId = medicalRecService.queryDissesInfoByMedicalRecId(medicalId);
|
|
|
|
Map<String, String> dissesInfoByMedicalRecId = medicalRecService.queryDissesInfoByMedicalRecId(medicalId);
|
|
|
|
|
|
|
|
|
|
|
|
// 保存视频到素材中心
|
|
|
|
// 保存视频到素材中心
|
|
|
|
// 1.创建病例文件夹
|
|
|
|
// 1.创建病例文件夹
|
|
|
|
DirectoryInfo directoryInfo = new DirectoryInfo();
|
|
|
|
String directoryId;
|
|
|
|
directoryInfo.setDirectoryDesc(dissesInfoByMedicalRecId.get("diseaseNameAlias"));
|
|
|
|
LambdaQueryChainWrapper<DirectoryInfo> diseaseName = directoryInfoService.lambdaQuery()
|
|
|
|
directoryInfo.setDirectoryName(dissesInfoByMedicalRecId.get("diseaseName"));
|
|
|
|
.eq(DirectoryInfo::getDirectoryName, dissesInfoByMedicalRecId.get("diseaseName"));
|
|
|
|
String directoryId = directoryInfoManageService.addDirectory(directoryInfo);
|
|
|
|
if (diseaseName.count() == 0) {
|
|
|
|
|
|
|
|
DirectoryInfo directoryInfo = new DirectoryInfo();
|
|
|
|
|
|
|
|
directoryInfo.setDirectoryDesc(dissesInfoByMedicalRecId.get("diseaseNameAlias"));
|
|
|
|
|
|
|
|
directoryInfo.setDirectoryName(dissesInfoByMedicalRecId.get("diseaseName"));
|
|
|
|
|
|
|
|
directoryId = directoryInfoManageService.addDirectory(directoryInfo);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DirectoryInfo one = diseaseName.one();
|
|
|
|
|
|
|
|
directoryId = one.getId();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2.上传视频素材到文件夹
|
|
|
|
// 2.上传视频素材到文件夹
|
|
|
|
// 静态
|
|
|
|
// 静态
|
|
|
@ -202,7 +213,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
silentDTOGetStatus = silentDTOGet.getStatus();
|
|
|
|
silentDTOGetStatus = silentDTOGet.getStatus();
|
|
|
|
} while (!silentDTOGetStatus.equals("completed"));
|
|
|
|
} while (!silentDTOGetStatus.equals("completed"));
|
|
|
|
|
|
|
|
|
|
|
|
FileResource fileResource = convertBase64ToFile("silent", FileUtil.getName(imageFile), silentDTOGet.getVideo());
|
|
|
|
FileResource fileResource = convertBase64ToFile("silent", human.getImageName(), silentDTOGet.getVideo());
|
|
|
|
human.setSilentVideoFileId(fileResource.getId());
|
|
|
|
human.setSilentVideoFileId(fileResource.getId());
|
|
|
|
human.setImageName(fileResource.getFileName());
|
|
|
|
human.setImageName(fileResource.getFileName());
|
|
|
|
|
|
|
|
|
|
|
@ -255,7 +266,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void generateDynamic(Human human, File imageFile, String medicalId, String directoryId) throws Exception {
|
|
|
|
private void generateDynamic(Human human, File imageFile, String medicalId, String directoryId) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
log.info("提交文件生成动态视频,文件名:{}", imageFile.getPath());
|
|
|
|
log.info("提交文件生成动态视频,文件名:{}", FileUtil.getName(imageFile));
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isAllBlank(human.getDynamicVideoFileId(), human.getDynamicTaskUid())) {
|
|
|
|
if (StrUtil.isAllBlank(human.getDynamicVideoFileId(), human.getDynamicTaskUid())) {
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
@ -279,7 +290,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
FileResource fileResource = convertBase64ToFile("dynamic", FileUtil.getName(imageFile), dynamicDTOGet.getVideo());
|
|
|
|
FileResource fileResource = convertBase64ToFile("dynamic", human.getImageName(), dynamicDTOGet.getVideo());
|
|
|
|
human.setDynamicVideoFileId(fileResource.getId());
|
|
|
|
human.setDynamicVideoFileId(fileResource.getId());
|
|
|
|
human.setImageName(fileResource.getFileName());
|
|
|
|
human.setImageName(fileResource.getFileName());
|
|
|
|
|
|
|
|
|
|
|
@ -303,7 +314,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
patientAnswerError.setAnswer("异常");
|
|
|
|
patientAnswerError.setAnswer("异常");
|
|
|
|
askPatientAnswerList.add(patientAnswerError);
|
|
|
|
askPatientAnswerList.add(patientAnswerError);
|
|
|
|
|
|
|
|
|
|
|
|
askPatientAnswerService.updateBatchById(askPatientAnswerList);
|
|
|
|
askPatientAnswerService.updateBatchById(askPatientAnswerList);
|
|
|
|
|
|
|
|
|
|
|
|
// 完成
|
|
|
|
// 完成
|
|
|
|
MedicalRec medicalRec1 = new MedicalRec();
|
|
|
|
MedicalRec medicalRec1 = new MedicalRec();
|
|
|
@ -328,10 +339,12 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
String prefix = FileUtil.getPrefix(imageFileName);
|
|
|
|
String prefix = FileUtil.getPrefix(imageFileName);
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个图片临时文件
|
|
|
|
// 创建一个图片临时文件
|
|
|
|
File tempFile = FileUtil.createTempFile(prefixName + "_" + prefix, ".mp4", true);
|
|
|
|
File tempFile = new File(prefixName + "_" + prefix + ".mpf");
|
|
|
|
|
|
|
|
// File tempFile = FileUtil.createTempFile(prefixName + "_" + prefix, ".mp4", true);
|
|
|
|
Base64.decodeToFile(base64, tempFile);
|
|
|
|
Base64.decodeToFile(base64, tempFile);
|
|
|
|
return fileManageService.uploadFile(tempFile);
|
|
|
|
FileResource fileResource = fileManageService.uploadFile(tempFile);
|
|
|
|
|
|
|
|
tempFile.delete();
|
|
|
|
|
|
|
|
return fileResource;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|