diff --git a/virtual-patient-manage/pom.xml b/virtual-patient-manage/pom.xml
index d104417f..1953e7f4 100644
--- a/virtual-patient-manage/pom.xml
+++ b/virtual-patient-manage/pom.xml
@@ -62,7 +62,19 @@
lombok
provided
-
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.apache.poi
+ poi-ooxml
+ 4.1.2
+ test
+
+
diff --git a/virtual-patient-manage/src/test/java/com/supervision/manage/VirtualPatientManageApplicationTests.java b/virtual-patient-manage/src/test/java/com/supervision/manage/VirtualPatientManageApplicationTests.java
new file mode 100644
index 00000000..8ecbcd69
--- /dev/null
+++ b/virtual-patient-manage/src/test/java/com/supervision/manage/VirtualPatientManageApplicationTests.java
@@ -0,0 +1,122 @@
+package com.supervision.manage;
+
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.Pair;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.Log;
+import cn.hutool.poi.excel.ExcelReader;
+import cn.hutool.poi.excel.ExcelUtil;
+import com.supervision.manage.service.AskQuestionLibraryManageService;
+import com.supervision.manage.service.DiseasePhysicalManageService;
+import com.supervision.model.AskPatientAnswer;
+import com.supervision.model.AskTemplateQuestionLibrary;
+import com.supervision.service.AskPatientAnswerService;
+import com.supervision.service.AskTemplateQuestionLibraryService;
+import com.supervision.util.MinioUtil;
+import com.supervision.vo.manage.DiseasePhysicalLocationNodeVo;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@SpringBootTest
+class VirtualPatientManageApplicationTests {
+
+ @Autowired
+ private AskPatientAnswerService askPatientAnswerService;;
+
+ @Autowired
+ private AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
+
+
+
+ @Test
+ void generateVideo(){
+
+ String medicalId = "ww";
+
+ String videoPath = "F:\\tmp\\video";
+ String indexFile = "标准病人语料库v1.3.xlsx";
+
+ // 1. 获取视频文件,及视频内容
+ List> videoFileAndContent = getVideoFileAndContent(videoPath,indexFile,".mp4");
+
+ if (CollUtil.isEmpty(videoFileAndContent)){
+ log.info("getVideoFileAndContent result is empty");
+ return;
+ }
+
+ //填充数据库中疾病问诊的资源id
+ Map patientAnserMap = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list()
+ .stream().collect(Collectors.toMap(answer -> StrUtil.trim(answer.getAnswer()), answer -> answer));
+
+ // 问诊模板数据
+ List askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().list();
+
+ List resourceIds = new ArrayList<>();
+ try {
+ for (Pair pair : videoFileAndContent) {
+ AskPatientAnswer askPatientAnswer = patientAnserMap.get(pair.getKey());
+ if (Objects.nonNull(askPatientAnswer)){
+ String resourceId = MinioUtil.uploadFile(Files.newInputStream(pair.getValue().toPath()));
+ askPatientAnswer.setAnswerResourceId(resourceId);
+ resourceIds.add(resourceId);
+ askPatientAnswerService.updateById(askPatientAnswer);
+ log.info("update askPatientAnswer:{}", JSONUtil.toJsonStr(askPatientAnswer));
+ }else {
+ //todo: 获取模板中的数据
+ }
+ }
+ } catch (Exception e) {
+ // 文件处理过程中出现异常,删除文件
+ for (String resourceId : resourceIds) {
+ try {
+ MinioUtil.deleteObject(resourceId);
+ } catch (Exception ex) {
+ log.info("删除资源失败:{}", resourceId);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * 获取视频文件及内容
+ * @param videoPath 视频存放路径
+ * @return pair.getKey():视频内容 pair.getValue():视频文件对象
+ */
+
+ List> getVideoFileAndContent(String videoPath,String indexFileName,String videoSuffix){
+
+ try (ExcelReader reader = ExcelUtil.getReader(FileUtil.file(String.join(File.separator,videoPath,indexFileName)))){
+
+ return reader.readAll().stream().map(map -> {
+ String answerText = MapUtil.getStr(map, "A(answer)");
+ String fileName = MapUtil.getStr(map, "知识库A-ID\n[病征]");
+ if (StrUtil.isEmpty(answerText) || StrUtil.isEmpty(fileName)) {
+ log.info("文件内容不完整:answerText:{},fileName:{}", answerText, fileName);
+ return null;
+ }
+ return Pair.of(answerText, FileUtil.file(String.join(File.separator,videoPath,fileName)+videoSuffix));
+ }).filter(Objects::nonNull).collect(Collectors.toList());
+ }
+
+ }
+
+
+
+
+}