manage: test

dev_2.1.0
xueqingkun 1 year ago
parent 0c00c70f4a
commit 45b111c658

@ -4,6 +4,9 @@ package com.supervision.manage;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil;
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;
@ -12,14 +15,20 @@ 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 {
@ -40,27 +49,36 @@ class VirtualPatientManageApplicationTests {
// 获取视频文件,及视频内容
List<Pair<String, File>> videoFileAndContent = getVideoFileAndContent(null);
//填充数据库中的资源id
//填充数据库中疾病问诊的资源id
Map<String, AskPatientAnswer> patientAnserMap = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list()
.stream().collect(Collectors.toMap(answer -> StrUtil.trim(answer.getAnswer()), answer -> answer));
// 问诊模板数据
List<AskTemplateQuestionLibrary> askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().list();
for (Pair<String, File> pair : videoFileAndContent) {
AskPatientAnswer askPatientAnswer = patientAnserMap.get(pair.getKey());
if (Objects.isNull(askPatientAnswer)){
AskPatientAnswer answer = new AskPatientAnswer();
answer.setCode(null);
answer.setAnswer(pair.getKey());
answer.setMedicalId(medicalId);
String resourceId = MinioUtil.uploadFile(null);
answer.setAnswerResourceId(resourceId);
List<String> resourceIds = new ArrayList<>();
try {
for (Pair<String, File> 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);
}else {
//todo: 获取模板中的数据
}
}
} catch (Exception e) {
// 文件处理过程中出现异常,删除文件
for (String resourceId : resourceIds) {
try {
MinioUtil.deleteObject(resourceId);
} catch (Exception ex) {
log.info("删除资源失败:{}", resourceId);
}
}
}
}
@ -70,12 +88,22 @@ class VirtualPatientManageApplicationTests {
* @return pair.getKey(): pair.getValue()
*/
List<Pair<String, File>> getVideoFileAndContent(String videoPath) {
List<Pair<String, File>> getVideoFileAndContent(String videoPath) throws IOException {
ExcelReader reader = ExcelUtil.getReader(Files.newInputStream(new File("").toPath()));
org.apache.poi.ss.usermodel.Sheet sheet = reader.getSheet();
Pair<String, File> 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()));
List<Map<String, Object>> maps = reader.readAll();
}

Loading…
Cancel
Save