manage : fix preGenerationMedicalAnswerVideo

dev_2.1.0
xueqingkun
parent 2b3ed0cfc4
commit dc7c7b1ce7

@ -106,17 +106,24 @@ public class MedicalRecManageController {
}
@ApiOperation("导入疾病问题回答")
@PostMapping("/uploadMedicalAnswer")
@ApiOperation("导入疾病问题回答")
@PostMapping("/preUploadMedicalAnswer")
public MedicalAnswerVideoResVo uploadMedicalAnswer(@ApiParam("文件") @RequestParam("file") MultipartFile multipartFile,
@ApiParam("病例id") @RequestParam("medicalRecId") String medicalRecId) throws Exception {
@ApiParam("病例id") @RequestParam(value = "medicalRecId",required = false) String medicalRecId) throws Exception {
return medicalRecManageService.uploadMedicalAnswer(multipartFile, medicalRecId);
return medicalRecManageService.preUploadMedicalAnswer(multipartFile, medicalRecId);
}
// 下载疾病问题模板
@ApiOperation("查询病例默认问题")
@PostMapping("/queryMedicalDefaultAnswer")
public MedicalAnswerVideoResVo queryMedicalDefaultAnswer(@ApiParam("病例id")
@RequestParam(value = "medicalRecId",required = false) String medicalRecId) {
return medicalRecManageService.queryMedicalDefaultAnswer(medicalRecId);
}
}

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.supervision.model.AskPatientAnswer;
import com.supervision.model.AskTemplateQuestionLibrary;
import com.supervision.model.CommonDic;
import com.supervision.model.MaterialLibrary;
import lombok.Data;
@ -21,7 +22,7 @@ public class MedicalRecAnswerExcelDTO {
private String questionTypeOne;
/**
* 2
* 2 vp_ask_template_question_library dict_id name_zh
*/
@Alias(value = "问诊类目Ⅱ")
private String questionTypeTwo;
@ -55,7 +56,7 @@ public class MedicalRecAnswerExcelDTO {
private String libraryQuestionId;
/**
* id
* id vp_ask_patient_answer id
*/
private String askPatientAnswerId;
@ -64,6 +65,10 @@ public class MedicalRecAnswerExcelDTO {
*/
private String answerResourceId;
private String dictId;
private String dictNamePath;
public static final List<String> READ_ANSWER_VIDEO_TITLE = CollUtil.newArrayList("问诊类目Ⅰ", "问诊类目Ⅱ", "* 知识", "* 回答","* 视频名称");
@ -76,11 +81,13 @@ public class MedicalRecAnswerExcelDTO {
public void doAction(List<AskTemplateQuestionLibrary> questionLibraryList,
List<AskPatientAnswer> askPatientAnswerList,
List<MaterialLibrary> materialLibraryList){
List<MaterialLibrary> materialLibraryList,
List<CommonDic> questionTypeDicList){
this.absentCheck();
this.matchQuestion(questionLibraryList);
this.matchAskPatientAnswer(askPatientAnswerList);
this.matchAnswerResource(materialLibraryList);
this.matchQuestionDicId(questionTypeDicList);
}
public AskPatientAnswer toAskPatientAnswer(){
@ -189,6 +196,24 @@ public class MedicalRecAnswerExcelDTO {
errorCodeEnums.add(ErrorCodeEnum.ANSWER_VIDEO_NAME_NOT_FIND);
}
public void matchQuestionDicId(List<CommonDic> questionTypeDicList){
if (StrUtil.isEmpty(this.questionTypeTwo)){
return;
}
if(CollUtil.isEmpty(questionTypeDicList)){
errorCodeEnums.add(ErrorCodeEnum.DICE_NOT_FIND);
}
for (CommonDic questionTypeDic : questionTypeDicList) {
if (this.questionTypeTwo.equals(questionTypeDic.getNameZh())){
this.dictId = String.valueOf(questionTypeDic.getId());
this.dictNamePath = questionTypeDic.getNameZhPath();
return;
}
}
errorCodeEnums.add(ErrorCodeEnum.ANSWER_VIDEO_NAME_NOT_FIND);
}
private static Map<String,String> getReadAlias(){
Map<String, String> map = new LinkedHashMap<>();
@ -217,7 +242,8 @@ public class MedicalRecAnswerExcelDTO {
ANSWER_EMPTY("0004","回答不能为空"),
ANSWER_VIDEO_NAME_EMPTY("0005","视频名称不能为空"),
QUESTION_NOT_FIND("40001","知识未找到"),
ANSWER_VIDEO_NAME_NOT_FIND("40002","视频不存在");
ANSWER_VIDEO_NAME_NOT_FIND("40002","视频不存在"),
DICE_NOT_FIND("40003","类目字典码值未找到");
private String code;
private String desc;

@ -1,11 +1,19 @@
package com.supervision.manage.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class MedicalAnswerVideoResVo {
@ApiModelProperty("消息内容")
private String message;
@ApiModelProperty("文件id")
private String fileId;
@ApiModelProperty("应答策略")
private List<MedicalRecQaVO> qaList;
}

@ -1,8 +1,5 @@
package com.supervision.manage.service;
import com.supervision.manage.pojo.vo.MedicalAnswerVideoResVo;
import java.io.InputStream;
/**
@ -10,5 +7,5 @@ import java.io.InputStream;
**/
public interface AnswerVideoResourceService {
MedicalAnswerVideoResVo generationMedicalAnswerVideo(InputStream bookStream, String medicalId) throws Exception;
MedicalAnswerVideoResVo preGenerationMedicalAnswerVideo(InputStream bookStream, String medicalId) throws Exception;
}

@ -41,5 +41,7 @@ public interface MedicalRecManageService {
List<Disease> querySingleDiseaseListByDropList();
MedicalAnswerVideoResVo uploadMedicalAnswer(MultipartFile multipartFile, String medicalRecId) throws Exception;
MedicalAnswerVideoResVo preUploadMedicalAnswer(MultipartFile multipartFile, String medicalRecId) throws Exception;
MedicalAnswerVideoResVo queryMedicalDefaultAnswer(String medicalRecId);
}

@ -251,12 +251,15 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
}
@Override
public MedicalAnswerVideoResVo uploadMedicalAnswer(MultipartFile multipartFile, String medicalRecId) throws Exception {
public MedicalAnswerVideoResVo preUploadMedicalAnswer(MultipartFile multipartFile, String medicalRecId) throws Exception {
// 读取上传的文件内容
InputStream inputStream = multipartFile.getInputStream();
return answerVideoResourceService.preGenerationMedicalAnswerVideo(multipartFile.getInputStream(),medicalRecId);
return answerVideoResourceService.generationMedicalAnswerVideo(inputStream,medicalRecId);
}
@Override
public MedicalAnswerVideoResVo queryMedicalDefaultAnswer(String medicalRecId) {
return null;
}
}

@ -11,16 +11,11 @@ import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.supervision.manage.dto.MedicalRecAnswerExcelDTO;
import com.supervision.manage.pojo.vo.MedicalAnswerVideoResVo;
import com.supervision.manage.pojo.vo.MedicalRecQaVO;
import com.supervision.manage.service.AnswerVideoResourceService;
import com.supervision.manage.service.FileManageService;
import com.supervision.model.AskPatientAnswer;
import com.supervision.model.AskTemplateQuestionLibrary;
import com.supervision.model.FileResource;
import com.supervision.model.MaterialLibrary;
import com.supervision.service.AskPatientAnswerService;
import com.supervision.service.AskTemplateQuestionLibraryService;
import com.supervision.service.FileResourceService;
import com.supervision.service.MaterialLibraryService;
import com.supervision.model.*;
import com.supervision.service.*;
import com.supervision.util.MinioUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -56,42 +51,86 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
private final FileManageService fileManageService;
private final CommonDicService commonDicService;
@Override
public MedicalAnswerVideoResVo generationMedicalAnswerVideo(InputStream bookStream, String medicalId) throws Exception {
public MedicalAnswerVideoResVo preGenerationMedicalAnswerVideo(InputStream bookStream, String medicalId) throws Exception {
TimeInterval timer = DateUtil.timer();
ExcelReader reader = ExcelUtil.getReader(bookStream);
log.info("generationMedicalAnswerVideo : 读取文件耗时:{} s" , timer.intervalSecond());
//校验行头
assertTitle(reader);
List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS = reader.readAll(MedicalRecAnswerExcelDTO.class);
//数据合法性校验,填充不要的数据,为进一步处理准备
List<AskTemplateQuestionLibrary> questionLibraryList = askTemplateQuestionLibraryService.list();
List<AskPatientAnswer> askPatientAnswerList = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list();
List<MaterialLibrary> materialLibraryList = materialLibraryService.list();
medicalRecAnswerExcelDTOS.forEach(dto->dto.doAction(questionLibraryList,askPatientAnswerList,materialLibraryList));
// 保存诊断问询数据
updateAskPatientAnswer(medicalRecAnswerExcelDTOS,medicalId);
medicalRecAnswerExcelDoAction(medicalId, medicalRecAnswerExcelDTOS);
timer.restart();
// 生成错误信息excel
File file = writeExcel(medicalRecAnswerExcelDTOS);
log.info("generationMedicalAnswerVideo : 生成错误信息excel耗时{} s" , timer.intervalSecond());
FileResource fileResource = fileManageService.uploadFile(file);
FileUtil.del(file);
//组装返回消息
return wrapperMedicalAnswerVideoResVo(medicalRecAnswerExcelDTOS,fileResource.getId());
}
/**
*
* @param medicalId id
* @param medicalRecAnswerExcelDTOS
*/
private void medicalRecAnswerExcelDoAction(String medicalId, List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS) {
// 查询问题库问题
List<AskTemplateQuestionLibrary> questionLibraryList = askTemplateQuestionLibraryService.list();
// 疾病id为空不查询数据
List<AskPatientAnswer> askPatientAnswerList = StrUtil.isEmpty(medicalId) ?
CollUtil.newArrayList() :
askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalId).list();
// 查询资源库资源
List<MaterialLibrary> materialLibraryList = materialLibraryService.list();
// 查询类目字段
List<CommonDic> questionTypeDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
medicalRecAnswerExcelDTOS.forEach(dto->dto.doAction(
questionLibraryList,askPatientAnswerList,materialLibraryList,questionTypeDicList));
}
/**
*
* @param medicalRecAnswerExcelDTOS
* @param fileId id
* @return MedicalAnswerVideoResVo
*/
private MedicalAnswerVideoResVo wrapperMedicalAnswerVideoResVo(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS,String fileId) {
MedicalAnswerVideoResVo medicalAnswerVideoResVo = new MedicalAnswerVideoResVo();
medicalAnswerVideoResVo.setFileId(fileResource.getId());
String message = StrUtil.format("共导入数据{}条,失败{}条",medicalRecAnswerExcelDTOS.size(),
medicalAnswerVideoResVo.setFileId(fileId);
String message = StrUtil.format("共导入数据{}条,失败{}条。",medicalRecAnswerExcelDTOS.size(),
medicalRecAnswerExcelDTOS.stream().filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())).count());
medicalAnswerVideoResVo.setMessage(message);
List<MedicalRecQaVO> medicalRecQaVOList = medicalRecAnswerExcelDTOS.stream().filter(dto -> CollUtil.isEmpty(dto.getErrorCodeEnums())).map(dto -> {
MedicalRecQaVO medicalRecQaVO = new MedicalRecQaVO();
medicalRecQaVO.setId(dto.getAskPatientAnswerId());
medicalRecQaVO.setLibraryQuestionId(dto.getLibraryQuestionId());
if (StrUtil.isNotEmpty(dto.getAnswerResourceId())) {
medicalRecQaVO.setDictId(Long.parseLong(dto.getDictId()));
}
medicalRecQaVO.setDictNamePath(dto.getDictNamePath());
medicalRecQaVO.setAnswerResourceId(dto.getAnswerResourceId());
medicalRecQaVO.setMedicalRecAnswer(dto.getAnswer());
return medicalRecQaVO;
}).collect(Collectors.toList());
medicalAnswerVideoResVo.setQaList(medicalRecQaVOList);
return medicalAnswerVideoResVo;
}
}
public void updateAskPatientAnswer(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS,String medicalId){
@ -121,13 +160,10 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
public File writeExcel(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS) throws Exception {
if (CollUtil.isEmpty(medicalRecAnswerExcelDTOS)){
return null;
}
List<MedicalRecAnswerExcelDTO> errorList = medicalRecAnswerExcelDTOS.stream()
.filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())).collect(Collectors.toList());
/* List<MedicalRecAnswerExcelDTO> errorList = medicalRecAnswerExcelDTOS.stream()
.filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())).collect(Collectors.toList());*/
List<Map<String, Object>> rowDataList = errorList.stream().map(MedicalRecAnswerExcelDTO::toExcelMap).collect(Collectors.toList());
List<Map<String, Object>> rowDataList = medicalRecAnswerExcelDTOS.stream().map(MedicalRecAnswerExcelDTO::toExcelMap).collect(Collectors.toList());
File templateFile = downLoadTemplate(templateResourceId);
try (ExcelWriter writer = ExcelUtil.getWriter(templateFile)){
writer.setHeaderAlias(MedicalRecAnswerExcelDTO.WRITE_HEADER_ALIAS);
@ -158,6 +194,11 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
}
return tempFile;
}
/**
*
* @param reader
*/
private void assertTitle(ExcelReader reader){
List<Object> titleList = reader.readRow(0);
Assert.notEmpty(titleList,"标题行为空");

@ -83,7 +83,7 @@ class VirtualPatientManageApplicationTests {
BufferedInputStream inputStream = FileUtil.getInputStream("F:\\tmp\\excel\\病历问诊问题导入模板.xlsx");
MedicalAnswerVideoResVo medicalAnswerVideoResVo = answerVideoResourceService.generationMedicalAnswerVideo(inputStream, "1111");
MedicalAnswerVideoResVo medicalAnswerVideoResVo = answerVideoResourceService.preGenerationMedicalAnswerVideo(inputStream, "1111");
System.out.println(JSONUtil.toJsonStr(medicalAnswerVideoResVo));
}

Loading…
Cancel
Save