From e25b09e7c03e255688697076097ca04225cc0d24 Mon Sep 17 00:00:00 2001 From: xueqingkun Date: Thu, 25 Jan 2024 11:40:44 +0800 Subject: [PATCH] manage: test --- virtual-patient-manage/pom.xml | 8 +++- .../VirtualPatientManageApplicationTests.java | 42 ++++++++++++------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/virtual-patient-manage/pom.xml b/virtual-patient-manage/pom.xml index 6ac40deb..1953e7f4 100644 --- a/virtual-patient-manage/pom.xml +++ b/virtual-patient-manage/pom.xml @@ -68,7 +68,13 @@ 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 index 97d26b68..8ecbcd69 100644 --- a/virtual-patient-manage/src/test/java/com/supervision/manage/VirtualPatientManageApplicationTests.java +++ b/virtual-patient-manage/src/test/java/com/supervision/manage/VirtualPatientManageApplicationTests.java @@ -2,8 +2,11 @@ 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; @@ -41,13 +44,20 @@ class VirtualPatientManageApplicationTests { @Test - void generateVideo() throws Exception { + void generateVideo(){ - String medicalId = ""; + String medicalId = "ww"; + String videoPath = "F:\\tmp\\video"; + String indexFile = "标准病人语料库v1.3.xlsx"; - // 获取视频文件,及视频内容 - List> videoFileAndContent = getVideoFileAndContent(null); + // 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() @@ -65,6 +75,7 @@ class VirtualPatientManageApplicationTests { askPatientAnswer.setAnswerResourceId(resourceId); resourceIds.add(resourceId); askPatientAnswerService.updateById(askPatientAnswer); + log.info("update askPatientAnswer:{}", JSONUtil.toJsonStr(askPatientAnswer)); }else { //todo: 获取模板中的数据 } @@ -88,20 +99,21 @@ class VirtualPatientManageApplicationTests { * @return pair.getKey():视频内容 pair.getValue():视频文件对象 */ - List> getVideoFileAndContent(String videoPath) throws IOException { + List> 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())); - org.apache.poi.ss.usermodel.Sheet sheet = reader.getSheet(); - - Pair pair = Pair.of("", new File("")); - return CollUtil.newArrayList(pair); - } - - public static void main(String[] args) throws IOException { - ExcelReader reader = ExcelUtil.getReader(Files.newInputStream(new File("").toPath())); + 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()); + } - List> maps = reader.readAll(); }