You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.3 KiB
Java
114 lines
4.3 KiB
Java
package com.supervision;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.file.PathUtil;
|
|
import com.supervision.model.AskPatientAnswer;
|
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
|
import com.supervision.model.FileResource;
|
|
import com.supervision.pojo.vo.TalkResultResVO;
|
|
import com.supervision.pojo.vo.TalkVideoReqVO;
|
|
import com.supervision.service.AskPatientAnswerService;
|
|
import com.supervision.service.AskService;
|
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
|
import com.supervision.service.FileResourceService;
|
|
import com.supervision.util.MinioUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
|
import java.io.BufferedInputStream;
|
|
import java.io.File;
|
|
import java.util.List;
|
|
|
|
@Slf4j
|
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
|
public class VideoUpdateTest {
|
|
|
|
@Autowired
|
|
private FileResourceService fileResourceService;
|
|
|
|
@Autowired
|
|
private AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
|
|
|
|
@Autowired
|
|
private AskPatientAnswerService askPatientAnswerService;
|
|
|
|
private String filePath = "/Users/flevance/Desktop/虚拟病人/语料库/h264_new/";
|
|
|
|
@Test
|
|
public void saveDefaultAnswerVideo() throws Exception {
|
|
List<AskTemplateQuestionLibrary> list = askTemplateQuestionLibraryService.list();
|
|
for (AskTemplateQuestionLibrary library : list) {
|
|
String defaultAnswerCode = library.getDefaultAnswerCode();
|
|
File file = FileUtil.file(filePath + defaultAnswerCode + ".mp4");
|
|
if (FileUtil.exist(file)) {
|
|
FileResource fileResource = new FileResource();
|
|
|
|
fileResource.setFileName(FileUtil.getName(file));
|
|
fileResource.setFileType(FileUtil.getType(file));
|
|
|
|
BufferedInputStream inputStream = FileUtil.getInputStream(file);
|
|
fileResource.setFileSize((long) inputStream.available());
|
|
String minioId = MinioUtil.uploadFile(inputStream);
|
|
fileResource.setMinioId(minioId);
|
|
fileResource.insert();
|
|
askTemplateQuestionLibraryService.lambdaUpdate()
|
|
.set(AskTemplateQuestionLibrary::getDefaultAnswerResourceId, fileResource.getId())
|
|
.eq(AskTemplateQuestionLibrary::getId, library.getId()).update();
|
|
} else {
|
|
log.info("视频不存在:{}", defaultAnswerCode);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void saveDiseaseVideo() throws Exception {
|
|
List<AskPatientAnswer> list = askPatientAnswerService.list();
|
|
for (AskPatientAnswer answer : list) {
|
|
String code = answer.getCode();
|
|
File file = FileUtil.file(filePath + code.replace("-", "") + ".mp4");
|
|
if (FileUtil.exist(file)) {
|
|
FileResource fileResource = new FileResource();
|
|
|
|
fileResource.setFileName(FileUtil.getName(file));
|
|
fileResource.setFileType(FileUtil.getType(file));
|
|
|
|
BufferedInputStream inputStream = FileUtil.getInputStream(file);
|
|
fileResource.setFileSize((long) inputStream.available());
|
|
String minioId = MinioUtil.uploadFile(inputStream);
|
|
fileResource.setMinioId(minioId);
|
|
fileResource.insert();
|
|
askPatientAnswerService.lambdaUpdate()
|
|
.set(AskPatientAnswer::getAnswerResourceId, fileResource.getId())
|
|
.eq(AskPatientAnswer::getId, answer.getId()).update();
|
|
} else {
|
|
log.info("视频不存在:{}", code);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
@Autowired
|
|
private AskService askService;
|
|
@Test
|
|
public void talkTest() throws Exception {
|
|
|
|
TalkVideoReqVO talkVideoReqVO = new TalkVideoReqVO();
|
|
talkVideoReqVO.setProcessId("1748165303767572481");
|
|
talkVideoReqVO.setText("你哪里不舒服");
|
|
|
|
TalkResultResVO talkResultResVO = askService.talkByVideo(talkVideoReqVO);
|
|
|
|
System.out.println(talkResultResVO.getAnswerMessage());
|
|
|
|
|
|
}
|
|
}
|