From d209b856fd28d8a599114ffbe4a976b5e66dff9b Mon Sep 17 00:00:00 2001 From: xueqingkun Date: Sun, 4 Feb 2024 16:38:04 +0800 Subject: [PATCH] =?UTF-8?q?manage:=20=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AskQuestionLibraryManageServiceImpl.java | 16 +++++++--------- .../impl/MedicalRecManageServiceImpl.java | 11 ++++------- .../impl/OfflineAnswerVideoResource.java | 6 +++--- ....xlsx => ask_question_library_template.xlsx} | Bin ...=> ask_question_library_template_error.xlsx} | Bin ...模板.xlsx => medical_answer_template.xlsx} | Bin ....xlsx => medical_answer_template_error.xlsx} | Bin 7 files changed, 14 insertions(+), 19 deletions(-) rename virtual-patient-manage/src/main/resources/template/{知识导入模板.xlsx => ask_question_library_template.xlsx} (100%) rename virtual-patient-manage/src/main/resources/template/{知识导入模板-error.xlsx => ask_question_library_template_error.xlsx} (100%) rename virtual-patient-manage/src/main/resources/template/{病历问诊问题导入模板.xlsx => medical_answer_template.xlsx} (100%) rename virtual-patient-manage/src/main/resources/template/{病历问诊问题导入模板-error.xlsx => medical_answer_template_error.xlsx} (100%) diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/AskQuestionLibraryManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/AskQuestionLibraryManageServiceImpl.java index fb466a9f..d7f98578 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/AskQuestionLibraryManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/AskQuestionLibraryManageServiceImpl.java @@ -23,7 +23,6 @@ import com.supervision.vo.manage.AskQuestionLibraryReqVo; 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; @@ -53,8 +52,8 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa 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"; + private final String ASK_QUESTION_LIBRARY_TEMPLATE_ERROR_EXCEL_PATH = "classpath:template/ask_question_library_template_error.xlsx"; + private final String ASK_QUESTION_LIBRARY_TEMPLATE_EXCEL_PATH = "classpath:template/ask_question_library_template.xlsx"; @Override public List queryList(AskQuestionLibraryReqVo askQuestionLibraryReqVo) { @@ -171,11 +170,9 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa 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.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment;filename=" + - URLEncoder.encode(FileUtil.getName(file), "UTF-8")); - + URLEncoder.encode("知识导入模板.xlsx", "UTF-8")); IoUtil.copy(resource.getInputStream(),outputStream); } @@ -207,9 +204,10 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa .filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())).collect(Collectors.toList()); List> collect = errorList.stream().map(UploadQuestionLibraryDTO::toExcelMap).collect(Collectors.toList()); - File templateFile = FileUtil.copy( - resourceLoader.getResource(ASK_QUESTION_LIBRARY_TEMPLATE_ERROR_EXCEL_PATH).getFile(), + File templateFile = FileUtil.writeFromStream( + resourceLoader.getResource(ASK_QUESTION_LIBRARY_TEMPLATE_ERROR_EXCEL_PATH).getInputStream(), FileUtil.createTempFile("导入详情",".xlsx",true), true); + try (ExcelWriter writer = ExcelUtil.getWriter(templateFile)){ writer.setHeaderAlias(UploadQuestionLibraryDTO.WRITE_HEADER_ALIAS); writer.setOnlyAlias(true); diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java index 955f8719..576193af 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/MedicalRecManageServiceImpl.java @@ -2,7 +2,6 @@ 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; @@ -30,7 +29,6 @@ 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; @@ -40,7 +38,7 @@ import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class MedicalRecManageServiceImpl implements MedicalRecManageService { - private final String MEDICAL_ANSWER_EXCEL_PATH = "classpath:template/病历问诊问题导入模板.xlsx"; + private final String MEDICAL_ANSWER_TEMPLATE_EXCEL_PATH = "classpath:template/medical_answer_template.xlsx"; private final ResourceLoader resourceLoader; @@ -341,12 +339,11 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService { @Override public void downloadMedicalAnswerTemplate(HttpServletResponse response) throws Exception { - Resource resource = resourceLoader.getResource(MEDICAL_ANSWER_EXCEL_PATH); + Resource resource = resourceLoader.getResource(MEDICAL_ANSWER_TEMPLATE_EXCEL_PATH); ServletOutputStream outputStream = response.getOutputStream(); - File file = resource.getFile(); - response.setContentType(FileUtil.getMimeType(file.getPath())); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment;filename=" + - URLEncoder.encode(FileUtil.getName(file), "UTF-8")); + URLEncoder.encode("病历问诊问题导入模板.xlsx", "UTF-8")); IoUtil.copy(resource.getInputStream(),outputStream); } diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/OfflineAnswerVideoResource.java b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/OfflineAnswerVideoResource.java index d11b2bda..23a01bbe 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/OfflineAnswerVideoResource.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/service/impl/OfflineAnswerVideoResource.java @@ -45,7 +45,7 @@ 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"; + private final String MEDICAL_ANSWER_TEMPLATE_ERROR_EXCEL_PATH = "classpath:template/medical_answer_template_error.xlsx"; @Override @@ -166,8 +166,8 @@ public class OfflineAnswerVideoResource implements AnswerVideoResourceService { .filter(dto -> CollUtil.isNotEmpty(dto.getErrorCodeEnums())) .map(MedicalRecAnswerExcelDTO::toExcelMap).collect(Collectors.toList()); - File templateFile = FileUtil.copy( - resourceLoader.getResource(MEDICAL_ANSWER_ERROR_EXCEL_PATH).getFile(), + File templateFile = FileUtil.writeFromStream( + resourceLoader.getResource(MEDICAL_ANSWER_TEMPLATE_ERROR_EXCEL_PATH).getInputStream(), FileUtil.createTempFile("导入详情",".xlsx",true), true); try (ExcelWriter writer = ExcelUtil.getWriter(templateFile)){ writer.setHeaderAlias(MedicalRecAnswerExcelDTO.WRITE_HEADER_ALIAS); diff --git a/virtual-patient-manage/src/main/resources/template/知识导入模板.xlsx b/virtual-patient-manage/src/main/resources/template/ask_question_library_template.xlsx similarity index 100% rename from virtual-patient-manage/src/main/resources/template/知识导入模板.xlsx rename to virtual-patient-manage/src/main/resources/template/ask_question_library_template.xlsx diff --git a/virtual-patient-manage/src/main/resources/template/知识导入模板-error.xlsx b/virtual-patient-manage/src/main/resources/template/ask_question_library_template_error.xlsx similarity index 100% rename from virtual-patient-manage/src/main/resources/template/知识导入模板-error.xlsx rename to virtual-patient-manage/src/main/resources/template/ask_question_library_template_error.xlsx diff --git a/virtual-patient-manage/src/main/resources/template/病历问诊问题导入模板.xlsx b/virtual-patient-manage/src/main/resources/template/medical_answer_template.xlsx similarity index 100% rename from virtual-patient-manage/src/main/resources/template/病历问诊问题导入模板.xlsx rename to virtual-patient-manage/src/main/resources/template/medical_answer_template.xlsx diff --git a/virtual-patient-manage/src/main/resources/template/病历问诊问题导入模板-error.xlsx b/virtual-patient-manage/src/main/resources/template/medical_answer_template_error.xlsx similarity index 100% rename from virtual-patient-manage/src/main/resources/template/病历问诊问题导入模板-error.xlsx rename to virtual-patient-manage/src/main/resources/template/medical_answer_template_error.xlsx