Merge remote-tracking branch 'origin/dev_2.0.0' into dev_2.0.0

dev_2.0.0
xueqingkun 1 year ago
commit 20bdd4dda2

@ -30,7 +30,7 @@ public class MinioUtil {
*
*/
public static String uploadFile(InputStream stream, String objectName) throws Exception {
ObjectWriteResponse objectWriteResponse = minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(objectName).contentType("video/mp4")
ObjectWriteResponse objectWriteResponse = minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(objectName)
.stream(stream, -1, 10485760).build());
return objectWriteResponse.object();
}

@ -36,6 +36,8 @@ public class AskPatientAnswer extends Model<AskPatientAnswer> implements Seriali
@ApiModelProperty(" 问题库问题ID")
private String libraryQuestionId;
private String code;
/**
*
*/

@ -50,6 +50,8 @@ public class AskTemplateQuestionLibrary implements Serializable {
*/
private String defaultAnswer;
private String defaultAnswerCode;
private String defaultAnswerResourceId;
/**

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
/**
@ -14,7 +16,7 @@ import lombok.Data;
*/
@TableName(value ="vp_file_resource")
@Data
public class FileResource implements Serializable {
public class FileResource extends Model<FileResource> implements Serializable {
/**
* id
*/

@ -9,6 +9,7 @@
<result property="medicalId" column="medical_id" jdbcType="VARCHAR"/>
<result property="libraryQuestionId" column="library_question_id" jdbcType="VARCHAR"/>
<result property="answer" column="answer" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="answerResourceId" column="answer_resources_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@ -17,7 +18,7 @@
</resultMap>
<sql id="Base_Column_List">
id,medical_id,library_question_id,
id,medical_id,library_question_id,code,
answer,answer_resources_id,create_user_id,
create_time,update_user_id,update_time
</sql>

@ -12,6 +12,7 @@
<result property="question" column="question" jdbcType="ARRAY"
typeHandler="com.supervision.handler.StringListTypeHandler"/>
<result property="defaultAnswer" column="default_answer" jdbcType="VARCHAR"/>
<result property="defaultAnswerCode" column="default_answer_code" jdbcType="VARCHAR"/>
<result property="defaultAnswerResourceId" column="default_answer_resources_id" jdbcType="VARCHAR"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@ -22,7 +23,7 @@
<sql id="Base_Column_List">
id
,dict_id,code,description,
question,default_answer,default_answer_resources_id,create_user_id,
question,default_answer,default_answer_code,default_answer_resources_id,create_user_id,
create_time,update_user_id,update_time
</sql>

@ -24,6 +24,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.supervision</groupId>
<artifactId>virtual-patient-common</artifactId>
@ -57,21 +59,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>

@ -42,12 +42,5 @@ public class AskController {
}
@ApiOperation("获取本地视频的文件流")
@GetMapping("/downloadTalkVideo")
public void downloadTalkVideo(String fileResourceId, HttpServletResponse response) {
askService.downloadTalkVideo(fileResourceId, response);
response.setContentType("video/mp4");
}
}

@ -29,9 +29,6 @@ public class TalkResultResVO {
@ApiModelProperty("type='2' 是否需要检查部位 0否 1是")
private Integer requireLocation;
@ApiModelProperty("视频预览URL,本地视频的形式需要")
private String videoUrl;
@ApiModelProperty("视频base64位编码")
private String videoBase64;

@ -20,7 +20,5 @@ public interface AskService {
TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) throws IOException;
void downloadTalkVideo(String fileResourceId, HttpServletResponse response);
}

@ -49,13 +49,6 @@ public class AskServiceImpl implements AskService {
@Value("${answer.defaultNoMatchId}")
private String defaultNoMatchId;
@Value("${answer.video.basePath}")
private String videoPath;
@Value("${video-url}")
private String videoUrl;
@Override
public String receiveVoiceFile(MultipartFile file) {
if (file.getSize() <= 0) {
@ -203,7 +196,7 @@ public class AskServiceImpl implements AskService {
}
@Override
public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) throws IOException {
public TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) {
// 根据processId找到对应的病人
Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程"));
// 调用rasa获取文字内容
@ -212,8 +205,7 @@ public class AskServiceImpl implements AskService {
TalkResultResVO talkResultResVO = new TalkResultResVO();
// 如果rasa没有识别出来,则返回默认值
if (StrUtil.isBlank(rasaResult)) {
talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId);
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId,null));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId));
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么");
}
@ -234,8 +226,7 @@ public class AskServiceImpl implements AskService {
AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult);
if (ObjectUtil.isEmpty(library)) {
log.info("{}:未从问题库中找到,回答未识别语句", rasaResult);
talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId);
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId,null));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId));
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么");
} else {
AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId())
@ -246,16 +237,13 @@ public class AskServiceImpl implements AskService {
// 首先看看default里面是不是存在,如果存在,就从default里面去找
if (StrUtil.isNotEmpty(library.getDefaultAnswer()) && StrUtil.isNotBlank(library.getDefaultAnswerResourceId())) {
String resText = library.getDefaultAnswer();
talkResultResVO.setVideoUrl(videoUrl + library.getDefaultAnswerResourceId());
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId(),null));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId()));
// 保存记录
saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText);
log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText());
} else {
log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult);
talkResultResVO.setVideoUrl(videoUrl + (StrUtil.isEmpty(library.getDefaultAnswerResourceId()) ? defaultNoMatchId
:library.getDefaultAnswerResourceId()));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId(),defaultNoMatchId));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId()));
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么");
}
} else {
@ -265,22 +253,19 @@ public class AskServiceImpl implements AskService {
String resText = library.getDefaultAnswer();
log.info("{}:病历配置的回答:{}:为空不为空不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText);
// 这里返回视频
talkResultResVO.setVideoUrl(videoUrl + library.getDefaultAnswerResourceId());
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId(),defaultNoMatchId));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(library.getDefaultAnswerResourceId()));
// 保存记录
saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText);
} else {
log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId());
talkResultResVO.setVideoUrl(videoUrl + defaultNoMatchId);
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId,null));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(defaultNoMatchId));
saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么");
}
} else {
String resText = askPatientAnswer.getAnswer();
log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText);
talkResultResVO.setVideoUrl(videoUrl + askPatientAnswer.getAnswerResourceId());
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(askPatientAnswer.getAnswerResourceId(),defaultNoMatchId));
talkResultResVO.setVideoBase64(getAnswerVideoBase64OrDefault(askPatientAnswer.getAnswerResourceId()));
// 保存记录
saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText);
}
@ -292,37 +277,28 @@ public class AskServiceImpl implements AskService {
return talkResultResVO;
}
@Override
public void downloadTalkVideo(String fileResourceId, HttpServletResponse response) {
/**
* base64
*
* @param fileResourceId id
* @return base64
*/
private String getAnswerVideoBase64OrDefault(String fileResourceId) {
if (StrUtil.isBlank(fileResourceId)) {
fileResourceId = defaultNoMatchId;
}
FileResource fileResource = fileResourceService.getById(fileResourceId);
if (ObjectUtil.isEmpty(fileResource)) {
throw new BusinessException("未找到回复视频");
log.info("未找到视频,走默认视频");
fileResource = fileResourceService.getById(defaultNoMatchId);
}
try (InputStream inputStream = MinioUtil.download(fileResource.getMinioId())) {
IoUtil.copy(inputStream, response.getOutputStream());
return Base64Encoder.encode(IoUtil.readBytes(inputStream));
} catch (Exception e) {
log.error("获取视频失败", e);
throw new BusinessException("未找到回复视频");
}
}
/**
* base64
* @param answerId id
* @param defaultValue id
* @return base64
*/
private String getAnswerVideoBase64OrDefault(String answerId, String defaultValue) {
Props props = new Props(videoPath + File.separator + "index");
String fileName = "";
if (StrUtil.isNotEmpty(answerId) && StrUtil.isNotEmpty(props.getStr(answerId))){
fileName = props.getStr(answerId);
}else if (StrUtil.isNotEmpty(defaultValue)){
fileName = props.getStr(defaultValue);
}
if (StrUtil.isEmpty(fileName)){
return null;
}
return Base64Encoder.encode(FileUtil.readBytes(videoPath + File.separator + fileName));
}
}

@ -86,8 +86,3 @@ ws:
answer:
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1739173836351885313
video:
basePath: /data/vp/video #最后一级不需要加分割符
# 视频预览,NGINX的地址,https的地址
video-url: https://124.220.94.55:8025/virtual-patient/ask/downloadTalkVideo?fileResourceId=

@ -86,8 +86,4 @@ ws:
nginx-port: 443
answer:
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1739173836351885313
video:
basePath: F:\supervision\doc\数字人视频\final_video\final_video
# 视频预览
video-url: http://192.168.10.138:8899/virtual-patient/ask/downloadTalkVideo?fileResourceId=
defaultNoMatchId: 1739173836351885313

@ -74,8 +74,4 @@ human:
talk-status: /talkStatus
answer:
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1739173836351885313
video:
basePath: /data/vp/video #最后一级不需要加分割符
# 视频预览,NGINX的地址,https的地址
video-url: https://124.220.94.55:8025/virtual-patient/ask/downloadTalkVideo?fileResourceId=
defaultNoMatchId: 1739173836351885313

@ -52,6 +52,12 @@ spring:
port: 6379
password: 123456
minio:
url: http://192.168.10.138:9002
accessKey: admin
secretKey: 12345678
bucketName: virtual-patient-bucket-test
mybatis-plus:
mapper-locations: classpath*:mapper/**/*.xml
configuration:
@ -79,8 +85,4 @@ ws:
nginx-port: 443
answer:
# 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID
defaultNoMatchId: 1739173836351885313
video:
basePath: /data/vp/video #最后一级不需要加分割符
# 视频预览,NGINX的地址,https的地址
video-url: https://124.220.94.55:8025/virtual-patient/ask/downloadTalkVideo?fileResourceId=
defaultNoMatchId: 1739173836351885313

@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: test

@ -13,7 +13,7 @@
</springProfile>
<!-- 测试环境,生产环境 -->
<springProfile name="test,prod">
<springProfile name="prod">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.supervision" level="INFO"/>

@ -0,0 +1,122 @@
package com.supervision;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.supervision.model.AskPatientAnswer;
import com.supervision.model.AskTemplateQuestionLibrary;
import com.supervision.model.CommonDic;
import com.supervision.service.AskPatientAnswerService;
import com.supervision.service.AskTemplateQuestionLibraryService;
import com.supervision.service.CommonDicService;
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.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringJUnit4ClassRunner.class)
public class AskTemplateIdTest {
@Autowired
private AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
@Autowired
private AskPatientAnswerService askPatientAnswerService;
@Autowired
private CommonDicService commonDicService;
@Test
public void creatAskId() {
Object o = new Object();
DefaultIdentifierGenerator defaultIdentifierGenerator = new DefaultIdentifierGenerator();
List<AskTemplateQuestionLibrary> list = askTemplateQuestionLibraryService.list();
for (AskTemplateQuestionLibrary askTemplateQuestionLibrary : list) {
askTemplateQuestionLibraryService.lambdaUpdate()
.set(AskTemplateQuestionLibrary::getId, String.valueOf(defaultIdentifierGenerator.nextId(o)))
.eq(AskTemplateQuestionLibrary::getId, askTemplateQuestionLibrary.getId()).update();
}
}
@Test
public void creatAnswerId() {
Object o = new Object();
DefaultIdentifierGenerator defaultIdentifierGenerator = new DefaultIdentifierGenerator();
List<AskPatientAnswer> list = askPatientAnswerService.list();
for (AskPatientAnswer answer : list) {
askPatientAnswerService.lambdaUpdate()
.set(AskPatientAnswer::getId, String.valueOf(defaultIdentifierGenerator.nextId(o)))
.eq(AskPatientAnswer::getId, answer.getId()).update();
}
}
@Test
public void insertDict() {
ExcelReader reader = ExcelUtil.getReader("/Users/flevance/Desktop/虚拟病人/语料库/标准病人语料1226-2.xlsx");
List<List<Object>> read = reader.read(1, 86);
for (List<Object> objects : read) {
String pathOne = String.valueOf(objects.get(0));
String pathTwo = String.valueOf(objects.get(1));
CommonDic dic = commonDicService.lambdaQuery().eq(CommonDic::getNameZhPath, pathOne + "/" + pathTwo).last("limit 1").one();
if (ObjectUtil.isNotEmpty(dic)) {
String code = String.valueOf(objects.get(5));
askTemplateQuestionLibraryService.lambdaUpdate().set(AskTemplateQuestionLibrary::getDictId, dic.getId())
.eq(AskTemplateQuestionLibrary::getCode, code).update();
}
}
}
@Test
public void generateQuestion() {
// 使用文心一言,这里是付费的,不要随便用哦,注意数量
String post = HttpUtil.get("https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=8VdV7Hm4ZmPVzRovCQXaH8nN&client_secret=Bte6UKtrexydMuhWrbqciolzYzS8rEYm");
System.out.println(post);
JSONObject parse = JSONUtil.parseObj(post);
String accessToken = parse.getStr("access_token");
List<AskTemplateQuestionLibrary> list = askTemplateQuestionLibraryService.list();
for (AskTemplateQuestionLibrary ask : list) {
try {
String description = ask.getDescription();
Map<String, Object> map = new HashMap<>();
map.put("role", "user");
map.put("content", "请把下面这句话以20种不同的方式提问以JSONARRAY的形式输出:" + description);
HashMap<String, Object> param = new HashMap<>();
param.put("messages", CollUtil.newArrayList(map));
String askAnswer = HttpUtil.post("https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=" + accessToken, JSONUtil.toJsonStr(param));
JSONObject answerJSON = JSONUtil.parseObj(askAnswer);
String result = answerJSON.getStr("result");
String s = ReUtil.get("\\[(.*?)\\]", result, 0);
List<String> question = JSONUtil.toList(s, String.class);
question.add(0, description);
askTemplateQuestionLibraryService.lambdaUpdate().set(AskTemplateQuestionLibrary::getQuestion, JSONUtil.toJsonStr(question)).eq(AskTemplateQuestionLibrary::getId, ask.getId()).update();
} catch (Exception e) {
log.error("{}生成错误", ask.getDescription(), e);
}
}
}
}

@ -1,15 +1,15 @@
package com.supervision;
import cn.hutool.core.codec.Base64Encoder;
import cn.hutool.core.io.FileUtil;
import cn.hutool.setting.dialect.Props;
import com.supervision.config.MinioProperties;
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.service.AskPatientAnswerService;
import com.supervision.service.AskTemplateQuestionLibraryService;
import com.supervision.service.FileResourceService;
import com.supervision.util.MinioUtil;
import io.minio.MinioClient;
import io.minio.StatObjectArgs;
import io.minio.StatObjectResponse;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,11 +17,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.UUID;
import java.io.File;
import java.util.List;
@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringJUnit4ClassRunner.class)
public class VideoUpdateTest {
@ -30,101 +29,67 @@ public class VideoUpdateTest {
private FileResourceService fileResourceService;
@Autowired
private MinioProperties minioProperties;
private AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
@Autowired
private MinioClient minioClient;
@Test
public void contextLoads() throws Exception {
String m = "1 你好,医生\n" +
"2 我最近感觉心跳特别快,喘不上气。\n" +
"3 感觉心跳特别快,喘不上气,活动后更严重\n" +
"4 比较严重\n" +
"5 觉得手抖、怕热,容易出汗,胃口很好,吃很多还总觉得饿,紧张,特别容易发脾气,还拉肚子,瘦了一些\n" +
"6 最近半年吧\n" +
"7 夏天很怕热,晚上也会睡不着\n" +
"8 活动后会加重,双腿还会没劲\n" +
"9 影响到我的工作和生活了\n" +
"10 没有注意到\n" +
"11 我不知道\n" +
"12 头痛,发烧\n" +
"13 感觉是全头疼\n" +
"14 基本上天天出现\n" +
"15 似乎是比之前掉的多了\n" +
"16 是的我每天大约3次稀便\n" +
"17 之前没有\n" +
"18 体力好像比之前差了一些,最近这些天我经常喘不过气来,并且活动后感觉双腿乏力,感觉到非常虚弱\n" +
"19 没有\n" +
"20 之前身体很好,没吃过什么药\n" +
"21 胃口很好,总感觉饿\n" +
"22 主要是尿多,口干,喝水也多\n" +
"23 大约有三个月\n" +
"24 老是觉得饿,比以前吃得多,人反而瘦了\n" +
"25 是的\n" +
"26 次数多了,特别是晚上以前从来不起夜现在要起来3、4次\n" +
"27 3个月瘦了7kg\n" +
"28 没有了\n" +
"29 还可以\n" +
"30 5年前得过胆结石把胆囊切掉了。\n" +
"31 一直都比较正常。\n" +
"32 有,对青霉素过敏。\n" +
"33 是高中时,因扁桃体化脓,医生本来要给用青霉素,但做了皮试是阳性。\n" +
"34 应该做过,记不清了。\n" +
"35 喜欢抽烟,10多年了每天1包\n" +
"36 我母亲身体不太好50岁得时候体检发现有糖尿病一直在吃药。\n" +
"37 天气寒冷时酸痛症状可加重,热敷可缓解\n" +
"38 正常\n" +
"39 腹部偶尔也会觉得疼痛\n" +
"40 说不清楚\n" +
"41 正常不闷,晚上睡觉向左侧睡,左胸有时闷。\n" +
"42 没有,有时过饱有胀满感觉\n";
String[] split = m.split("\n");
HashMap<Integer, String> codeMap = new HashMap<>();
for (int i = 0; i < split.length; i++) {
String s = split[i];
String[] split1 = s.split(" ");
System.out.println("---" + split1[0] +"----"+split1[1]);
codeMap.put(Integer.valueOf(split1[0]),split1[1]);
}
// 读取文件 0-41
// 读取文件名 1-42
FileResource fileResource = new FileResource();
fileResource.setFileType("mp4");
private AskPatientAnswerService askPatientAnswerService;
for (int i = 0; i < 42; i++) {
fileResource.setFileName(codeMap.get(i+1));
fileResource.setMinioId(UUID.randomUUID().toString());
BufferedInputStream inputStream = FileUtil.getInputStream("F:\\supervision\\doc\\数字人视频\\final_video\\final_video\\"+i+".mp4");
MinioUtil.uploadFile(inputStream, fileResource.getMinioId());
System.out.println("---------------------上传文件:"+fileResource.getFileName());
@Test
public void saveDefaultAnswerVideo() throws Exception {
String filePath = "/Users/flevance/Desktop/虚拟病人/语料库/video_texts/";
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(inputStream.available());
String minioId = MinioUtil.uploadFile(inputStream, defaultAnswerCode);
fileResource.setMinioId(minioId);
fileResource.insert();
askTemplateQuestionLibraryService.lambdaUpdate()
.set(AskTemplateQuestionLibrary::getDefaultAnswerResourceId, fileResource.getId())
.eq(AskTemplateQuestionLibrary::getId, library.getId()).update();
} else {
log.info("视频不存在:{}", defaultAnswerCode);
}
StatObjectResponse response = minioClient.statObject(StatObjectArgs.builder().bucket(minioProperties.getBucketName()).object(fileResource.getMinioId()).build());
fileResource.setFileSize(Integer.valueOf(String.valueOf(response.size())));
fileResourceService.save(fileResource);
fileResource.setId(null);
}
}
public static void main(String[] args) throws FileNotFoundException {
long l = System.currentTimeMillis();
byte[] bytes = FileUtil.readBytes("F:\\supervision\\doc\\数字人视频\\final_video\\final_video\\0.mp4");
String encode = Base64Encoder.encode(bytes);
long l1 = System.currentTimeMillis() - l;
System.out.println(l1);
@Test
public void saveDiseaseVideo() throws Exception {
String filePath = "/Users/flevance/Desktop/虚拟病人/语料库/video_texts/";
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(inputStream.available());
String minioId = MinioUtil.uploadFile(inputStream, code);
fileResource.setMinioId(minioId);
fileResource.insert();
askPatientAnswerService.lambdaUpdate()
.set(AskPatientAnswer::getAnswerResourceId, fileResource.getId())
.eq(AskPatientAnswer::getId, answer.getId()).update();
} else {
log.info("视频不存在:{}", code);
}
Props props = new Props("F:\\supervision\\doc\\数字人视频\\final_video\\final_video\\index");
Object o = props.get("a");
System.out.println(o);
}
}
}

Loading…
Cancel
Save