|
|
|
@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
import com.supervision.config.SadTalkerProperties;
|
|
|
|
|
import com.supervision.enums.EnumMedicalRec;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.manage.dto.HumanGenerateDTO;
|
|
|
|
@ -27,6 +28,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -64,14 +66,9 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
60L, TimeUnit.MILLISECONDS,
|
|
|
|
|
new LinkedBlockingQueue<>(20), ThreadUtil.newNamedThreadFactory("human", true),
|
|
|
|
|
new ThreadPoolExecutor.CallerRunsPolicy());
|
|
|
|
|
@Value("${humanGenerate.baseUrl}")
|
|
|
|
|
private String humanBaseUrl;
|
|
|
|
|
@Value("${humanGenerate.silent}")
|
|
|
|
|
private String silent;
|
|
|
|
|
@Value("${humanGenerate.dynamic}")
|
|
|
|
|
private String dynamic;
|
|
|
|
|
@Value("${humanGenerate.status}")
|
|
|
|
|
private String status;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SadTalkerProperties sadTalkerProperties;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@ -198,7 +195,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
if (StrUtil.isAllBlank(human.getSilentVideoFileId(), human.getSilentTaskUid())) {
|
|
|
|
|
HumanGenerateDTO silentDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + silent, Map.of("image", imageFile));
|
|
|
|
|
String post = HttpUtil.post(sadTalkerProperties.getBaseUrl() + sadTalkerProperties.getSilent(), Map.of("image", imageFile));
|
|
|
|
|
silentDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人静态视频异常");
|
|
|
|
@ -208,7 +205,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
HumanGenerateDTO silentDTOGet;
|
|
|
|
|
String silentDTOGetStatus = "";
|
|
|
|
|
do {
|
|
|
|
|
String post = HttpUtil.get(humanBaseUrl + status + "/" + silentDTO.getUid());
|
|
|
|
|
String post = HttpUtil.get(sadTalkerProperties.getBaseUrl() + sadTalkerProperties.getStatus() + "/" + silentDTO.getUid());
|
|
|
|
|
silentDTOGet = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
silentDTOGetStatus = silentDTOGet.getStatus();
|
|
|
|
|
} while (!silentDTOGetStatus.equals("completed"));
|
|
|
|
@ -271,7 +268,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
if (StrUtil.isAllBlank(human.getDynamicVideoFileId(), human.getDynamicTaskUid())) {
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + dynamic, Map.of("image", imageFile));
|
|
|
|
|
String post = HttpUtil.post(sadTalkerProperties.getBaseUrl() + sadTalkerProperties.getDynamic(), Map.of("image", imageFile));
|
|
|
|
|
dynamicDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人动态视频异常");
|
|
|
|
@ -283,7 +280,7 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
HumanGenerateDTO dynamicDTOGet;
|
|
|
|
|
String dynamicDTOGetStatus = "";
|
|
|
|
|
do {
|
|
|
|
|
String post = HttpUtil.get(humanBaseUrl + status + "/" + dynamicDTO.getUid());
|
|
|
|
|
String post = HttpUtil.get(sadTalkerProperties.baseUrl + sadTalkerProperties.getStatus() + "/" + dynamicDTO.getUid());
|
|
|
|
|
dynamicDTOGet = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
dynamicDTOGetStatus = dynamicDTOGet.getStatus();
|
|
|
|
|
} while (!dynamicDTOGetStatus.equals("completed"));
|
|
|
|
|