manage: 代码调整

dev_2.1.0
xueqingkun 1 year ago
parent cab4c4e492
commit d209b856fd

@ -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<AskQuestionLibraryResVo> 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<Map<String, Object>> 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);

@ -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);
}

@ -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);

Loading…
Cancel
Save