manage: test

dev_2.1.0
xueqingkun 1 year ago
parent 45b111c658
commit e25b09e7c0

@ -68,7 +68,13 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>

@ -2,8 +2,11 @@ package com.supervision.manage;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Pair; import cn.hutool.core.lang.Pair;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.Log; import cn.hutool.log.Log;
import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelUtil;
@ -41,13 +44,20 @@ class VirtualPatientManageApplicationTests {
@Test @Test
void generateVideo() throws Exception { void generateVideo(){
String medicalId = ""; String medicalId = "ww";
String videoPath = "F:\\tmp\\video";
String indexFile = "标准病人语料库v1.3.xlsx";
// 获取视频文件,及视频内容 // 1. 获取视频文件,及视频内容
List<Pair<String, File>> videoFileAndContent = getVideoFileAndContent(null); List<Pair<String, File>> videoFileAndContent = getVideoFileAndContent(videoPath,indexFile,".mp4");
if (CollUtil.isEmpty(videoFileAndContent)){
log.info("getVideoFileAndContent result is empty");
return;
}
//填充数据库中疾病问诊的资源id //填充数据库中疾病问诊的资源id
Map<String, AskPatientAnswer> patientAnserMap = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list() Map<String, AskPatientAnswer> patientAnserMap = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list()
@ -65,6 +75,7 @@ class VirtualPatientManageApplicationTests {
askPatientAnswer.setAnswerResourceId(resourceId); askPatientAnswer.setAnswerResourceId(resourceId);
resourceIds.add(resourceId); resourceIds.add(resourceId);
askPatientAnswerService.updateById(askPatientAnswer); askPatientAnswerService.updateById(askPatientAnswer);
log.info("update askPatientAnswer:{}", JSONUtil.toJsonStr(askPatientAnswer));
}else { }else {
//todo: 获取模板中的数据 //todo: 获取模板中的数据
} }
@ -88,20 +99,21 @@ class VirtualPatientManageApplicationTests {
* @return pair.getKey(): pair.getValue() * @return pair.getKey(): pair.getValue()
*/ */
List<Pair<String, File>> getVideoFileAndContent(String videoPath) throws IOException { List<Pair<String, File>> getVideoFileAndContent(String videoPath,String indexFileName,String videoSuffix){
try (ExcelReader reader = ExcelUtil.getReader(FileUtil.file(String.join(File.separator,videoPath,indexFileName)))){
ExcelReader reader = ExcelUtil.getReader(Files.newInputStream(new File("").toPath())); return reader.readAll().stream().map(map -> {
org.apache.poi.ss.usermodel.Sheet sheet = reader.getSheet(); String answerText = MapUtil.getStr(map, "Aanswer");
String fileName = MapUtil.getStr(map, "知识库A-ID\n[病征]");
Pair<String, File> pair = Pair.of("", new File("")); if (StrUtil.isEmpty(answerText) || StrUtil.isEmpty(fileName)) {
return CollUtil.newArrayList(pair); log.info("文件内容不完整:answerText:{},fileName:{}", answerText, fileName);
} return null;
}
public static void main(String[] args) throws IOException { return Pair.of(answerText, FileUtil.file(String.join(File.separator,videoPath,fileName)+videoSuffix));
ExcelReader reader = ExcelUtil.getReader(Files.newInputStream(new File("").toPath())); }).filter(Objects::nonNull).collect(Collectors.toList());
}
List<Map<String, Object>> maps = reader.readAll();
} }

Loading…
Cancel
Save