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