manage: 代码调整

dev_2.1.0
xueqingkun 1 year ago
parent 4647b9d7c3
commit 70ebf659c9

@ -125,7 +125,7 @@ public class MedicalRecManageController {
@ApiOperation("查询病例默认问题")
@PostMapping("/queryMedicalDefaultAnswer")
@GetMapping("/queryMedicalDefaultAnswer")
public List<MedicalRecQaVO> queryMedicalDefaultAnswer(@ApiParam("病例id")
@RequestParam(value = "medicalRecId",required = false) String medicalRecId) {

@ -32,6 +32,9 @@ public class MedicalRecQaVO {
@ApiModelProperty("回答的资源id,新增更新时需要")
private String answerResourceId;
@ApiModelProperty("回答的资源视频名,新增更新时需要")
private String answerResourceName;
@ApiModelProperty("针对病例的特定回答,新增更新时必填")
private String medicalRecAnswer;

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
@ -23,14 +24,18 @@ import com.supervision.vo.manage.AskQuestionLibraryResVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -40,17 +45,16 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryManageService {
@Value("${ask.offline.template.error}")
private String errorTemplateResourceId;
@Value("${ask.offline.template.empty}")
private String emptyTemplateResourceId;
private final ResourceLoader resourceLoader;
private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
private final CommonDicService commonDicService;
private final FileManageService fileManageService;
private final String ASK_QUESTION_LIBRARY_TEMPLATE_ERROR_EXCEL_PATH = "classpath:template/知识导入模板-error.xlsx";
private final String ASK_QUESTION_LIBRARY_TEMPLATE_EXCEL_PATH = "classpath:template/知识导入模板.xlsx";
@Override
public List<AskQuestionLibraryResVo> queryList(AskQuestionLibraryReqVo askQuestionLibraryReqVo) {
@ -164,7 +168,15 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
@Override
public void downloadMedicalAnswerTemplate(HttpServletResponse response) throws Exception {
fileManageService.downloadFile(emptyTemplateResourceId,response);
Resource resource = resourceLoader.getResource(ASK_QUESTION_LIBRARY_TEMPLATE_EXCEL_PATH);
ServletOutputStream outputStream = response.getOutputStream();
File file = resource.getFile();
response.setContentType(FileUtil.getMimeType(file.getPath()));
response.setHeader("Content-Disposition", "attachment;filename=" +
URLEncoder.encode(FileUtil.getName(file), "UTF-8"));
IoUtil.copy(resource.getInputStream(),outputStream);
}
@ -195,7 +207,9 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
.filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())).collect(Collectors.toList());
List<Map<String, Object>> collect = errorList.stream().map(UploadQuestionLibraryDTO::toExcelMap).collect(Collectors.toList());
File templateFile = fileManageService.downloadFile(errorTemplateResourceId);
File templateFile = FileUtil.copy(
resourceLoader.getResource(ASK_QUESTION_LIBRARY_TEMPLATE_ERROR_EXCEL_PATH).getFile(),
FileUtil.createTempFile("导入详情",".xlsx",true), true);
try (ExcelWriter writer = ExcelUtil.getWriter(templateFile)){
writer.setHeaderAlias(UploadQuestionLibraryDTO.WRITE_HEADER_ALIAS);
writer.setOnlyAlias(true);

@ -84,7 +84,7 @@ public class FileManageServiceImpl implements FileManageService {
String contentType = StrUtil.isEmpty(fileResource.getFileType()) ? "application/octet-stream" : fileResource.getFileType();
response.setContentType(contentType);
if (Objects.nonNull(fileResource.getFileName())){
if (StrUtil.isNotEmpty(fileResource.getFileName())){
response.setHeader("Content-Disposition", "attachment;filename=" +
URLEncoder.encode(fileResource.getFileName(), "UTF-8"));
}

@ -2,6 +2,8 @@ package com.supervision.manage.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -20,12 +22,16 @@ import com.supervision.vo.manage.DiseaseTreatmentPlanResVo;
import com.supervision.vo.manage.MedicalRecPageResVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.net.URLEncoder;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -34,9 +40,9 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private final String MEDICAL_ANSWER_EXCEL_PATH = "classpath:template/病历问诊问题导入模板.xlsx";
@Value("${answer.offline.template.empty}")
private String emptyTemplateResourceId;
private final ResourceLoader resourceLoader;
private final DiseaseService diseaseService;
@ -58,7 +64,7 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private final AnswerVideoResourceService answerVideoResourceService;
private final FileManageService fileManageService;
private final MaterialLibraryService materialLibraryService;
public List<Disease> queryDiseaseListByDropList() {
return diseaseService.lambdaQuery().list();
@ -241,6 +247,15 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
Set<Long> dictIdSet = askTemplateQuestionLibraryList.stream().map(AskTemplateQuestionLibrary::getDictId).collect(Collectors.toSet());
Map<Long, CommonDic> dictMap = commonDicService.listByIds(dictIdSet).stream().collect(Collectors.toMap(CommonDic::getId, Function.identity()));
// 获取视频资源名
Set<String> answerResourceIds = medicalRecQaList.stream().map(MedicalRecQaVO::getAnswerResourceId).filter(StrUtil::isNotEmpty).collect(Collectors.toSet());
Map<String, String> videoInfoMaps = new HashMap<>();
if (CollUtil.isNotEmpty(answerResourceIds)){
Map<String, String> videoInfoMapsTmp = materialLibraryService.listByIds(answerResourceIds).stream()
.collect(Collectors.toMap(MaterialLibrary::getId, MaterialLibrary::getMaterialName));
videoInfoMaps.putAll(videoInfoMapsTmp);
}
for (MedicalRecQaVO medicalRecQaVO : medicalRecQaList) {
AskTemplateQuestionLibrary questionLibrary = askQuestionMap.get(medicalRecQaVO.getLibraryQuestionId());
if (ObjectUtil.isNotEmpty(questionLibrary)) {
@ -252,6 +267,8 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
medicalRecQaVO.setDictNamePath(dictMap.getOrDefault(questionLibrary.getDictId(), new CommonDic()).getNameZhPath());
// 默认回答
medicalRecQaVO.setDefaultAnswer(questionLibrary.getDefaultAnswer());
// 回答视频
medicalRecQaVO.setAnswerResourceName(videoInfoMaps.get(medicalRecQaVO.getAnswerResourceId()));
}
}
}
@ -287,6 +304,15 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
if (StrUtil.isNotEmpty(medicalRecId)) {
List<AskPatientAnswer> askPatientAnswerList = askPatientAnswerService.lambdaQuery()
.eq(AskPatientAnswer::getMedicalId, medicalRecId).eq(AskPatientAnswer::getAnswerType, "0").list();
final Map<String, AskTemplateQuestionLibrary> libraryMap = new HashMap<>();
if (CollUtil.isNotEmpty(askPatientAnswerList)){
List<String> questionIds = askPatientAnswerList.stream()
.map(AskPatientAnswer::getLibraryQuestionId).filter(Objects::nonNull).collect(Collectors.toList());
Map<String, AskTemplateQuestionLibrary> libraryMapTemp = askTemplateQuestionLibraryService.listByIds(questionIds)
.stream().collect(Collectors.toMap(AskTemplateQuestionLibrary::getId, Function.identity()));
libraryMap.putAll(libraryMapTemp);
}
return askPatientAnswerList.stream().map(e -> {
MedicalRecQaVO medicalRecQaVO = new MedicalRecQaVO();
medicalRecQaVO.setId(e.getId());
@ -294,6 +320,10 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
medicalRecQaVO.setDictId(systemDicId);
medicalRecQaVO.setDictNamePath(systemDic.getNameZhPath());
medicalRecQaVO.setMedicalRecAnswer(e.getAnswer());
AskTemplateQuestionLibrary askTemplateQuestionLibrary = libraryMap.get(e.getLibraryQuestionId());
if (Objects.nonNull(askTemplateQuestionLibrary)){
medicalRecQaVO.setQuestionList(askTemplateQuestionLibrary.getQuestion());
}
return medicalRecQaVO;
}).collect(Collectors.toList());
}
@ -304,12 +334,20 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
medicalRecQaVO.setDictId(systemDicId);
medicalRecQaVO.setDictNamePath(systemDic.getNameZhPath());
medicalRecQaVO.setMedicalRecAnswer(e.getDefaultAnswer());
medicalRecQaVO.setQuestionList(e.getQuestion());
return medicalRecQaVO;
}).collect(Collectors.toList());
}
@Override
public void downloadMedicalAnswerTemplate(HttpServletResponse response) throws Exception {
fileManageService.downloadFile(emptyTemplateResourceId,response);
Resource resource = resourceLoader.getResource(MEDICAL_ANSWER_EXCEL_PATH);
ServletOutputStream outputStream = response.getOutputStream();
File file = resource.getFile();
response.setContentType(FileUtil.getMimeType(file.getPath()));
response.setHeader("Content-Disposition", "attachment;filename=" +
URLEncoder.encode(FileUtil.getName(file), "UTF-8"));
IoUtil.copy(resource.getInputStream(),outputStream);
}
}

@ -18,7 +18,7 @@ import com.supervision.model.*;
import com.supervision.service.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import java.io.*;
@ -34,8 +34,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
@Value("${answer.offline.template.error}")
private String errorTemplateResourceId;
private final ResourceLoader resourceLoader;
private final AskPatientAnswerService askPatientAnswerService;
@ -46,6 +45,8 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
private final FileManageService fileManageService;
private final CommonDicService commonDicService;
private final String MEDICAL_ANSWER_ERROR_EXCEL_PATH = "classpath:template/病历问诊问题导入模板-error.xlsx";
@Override
public MedicalAnswerVideoResVo preGenerationMedicalAnswerVideo(InputStream inputStream, String medicalId) throws Exception {
@ -74,7 +75,6 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
FileUtil.del(file);
}
return wrapperMedicalAnswerVideoResVo(medicalRecAnswerExcelDTOS,fileResource.getId());
}
@ -100,6 +100,32 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
questionLibraryList,askPatientAnswerList,materialLibraryList,questionTypeDicList));
}
public void updateAskPatientAnswer(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS,String medicalId){
if (CollUtil.isEmpty(medicalRecAnswerExcelDTOS)){
return;
}
for (MedicalRecAnswerExcelDTO dto : medicalRecAnswerExcelDTOS) {
if (CollUtil.isNotEmpty(dto.getErrorCodeEnums())){
// 校验不通过,不进行入库处理
continue;
}
String askPatientAnswerId = dto.getAskPatientAnswerId();
if (StrUtil.isNotEmpty(askPatientAnswerId)){
//更新操作
AskPatientAnswer askPatientAnswer = dto.toAskPatientAnswer();
askPatientAnswerService.lambdaUpdate().eq(AskPatientAnswer::getId,askPatientAnswerId)
.set(AskPatientAnswer::getAnswerResourceId,askPatientAnswer.getAnswerResourceId())
.update();
}else {
//新增操作
AskPatientAnswer askPatientAnswer = dto.toAskPatientAnswer();
askPatientAnswer.setMedicalId(medicalId);
askPatientAnswerService.save(askPatientAnswer);
}
}
}
/**
*
* @param medicalRecAnswerExcelDTOS
@ -121,8 +147,10 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
if (StrUtil.isNotEmpty(dto.getAnswerResourceId())) {
medicalRecQaVO.setDictId(Long.parseLong(dto.getDictId()));
}
medicalRecQaVO.setQuestionList(CollUtil.newArrayList(dto.getQuestion()));
medicalRecQaVO.setDictNamePath(dto.getDictNamePath());
medicalRecQaVO.setAnswerResourceId(dto.getAnswerResourceId());
medicalRecQaVO.setAnswerResourceName(dto.getAnswerVideoName());
medicalRecQaVO.setMedicalRecAnswer(dto.getAnswer());
return medicalRecQaVO;
}).collect(Collectors.toList());
@ -132,39 +160,15 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService {
}
public void updateAskPatientAnswer(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS,String medicalId){
if (CollUtil.isEmpty(medicalRecAnswerExcelDTOS)){
return;
}
for (MedicalRecAnswerExcelDTO dto : medicalRecAnswerExcelDTOS) {
if (CollUtil.isNotEmpty(dto.getErrorCodeEnums())){
// 校验不通过,不进行入库处理
continue;
}
String askPatientAnswerId = dto.getAskPatientAnswerId();
if (StrUtil.isNotEmpty(askPatientAnswerId)){
//更新操作
AskPatientAnswer askPatientAnswer = dto.toAskPatientAnswer();
askPatientAnswerService.lambdaUpdate().eq(AskPatientAnswer::getId,askPatientAnswerId)
.set(AskPatientAnswer::getAnswerResourceId,askPatientAnswer.getAnswerResourceId())
.update();
}else {
//新增操作
AskPatientAnswer askPatientAnswer = dto.toAskPatientAnswer();
askPatientAnswer.setMedicalId(medicalId);
askPatientAnswerService.save(askPatientAnswer);
}
}
}
public File writeExcel(List<MedicalRecAnswerExcelDTO> medicalRecAnswerExcelDTOS) throws Exception {
List<Map<String, Object>> errorList = medicalRecAnswerExcelDTOS.stream()
.filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums()))
.map(MedicalRecAnswerExcelDTO::toExcelMap).collect(Collectors.toList());
File templateFile = fileManageService.downloadFile(errorTemplateResourceId);
File templateFile = FileUtil.copy(
resourceLoader.getResource(MEDICAL_ANSWER_ERROR_EXCEL_PATH).getFile(),
FileUtil.createTempFile("导入详情",".xlsx",true), true);
try (ExcelWriter writer = ExcelUtil.getWriter(templateFile)){
writer.setHeaderAlias(MedicalRecAnswerExcelDTO.WRITE_HEADER_ALIAS);
writer.setOnlyAlias(true);

Loading…
Cancel
Save