|
@@ -0,0 +1,402 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.ExportConceptAllDTO;
|
|
|
+import com.diagbot.dto.ExportConceptModeDTO;
|
|
|
+import com.diagbot.entity.KlConcept;
|
|
|
+import com.diagbot.entity.KlConceptCommon;
|
|
|
+import com.diagbot.entity.KlLexicon;
|
|
|
+import com.diagbot.entity.KlLibraryInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.KlConceptCommonService;
|
|
|
+import com.diagbot.service.KlConceptService;
|
|
|
+import com.diagbot.service.KlDiseaseService;
|
|
|
+import com.diagbot.service.KlDrugService;
|
|
|
+import com.diagbot.service.KlLibraryInfoService;
|
|
|
+import com.diagbot.service.KlLisService;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.Cn2SpellUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ExcelUtils;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.ImportConceptAllVO;
|
|
|
+import com.diagbot.vo.ImportConceptSubVO;
|
|
|
+import org.apache.poi.hssf.usermodel.DVConstraint;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFDataValidation;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.DataFormat;
|
|
|
+import org.apache.poi.ss.usermodel.Name;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangfeng
|
|
|
+ * @Description:
|
|
|
+ * @date 2021-05-31 13:13
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class TermImportFacade {
|
|
|
+ @Autowired
|
|
|
+ KlLibraryInfoFacade klLibraryInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ KlLexiconFacade klLexiconFacade;
|
|
|
+ @Autowired
|
|
|
+ KlConceptFacade klConceptFacade;
|
|
|
+ @Autowired
|
|
|
+ KlConceptCommonFacade klConceptCommonFacade;
|
|
|
+ @Autowired
|
|
|
+ KlLisFacade klLisFacade;
|
|
|
+ @Autowired
|
|
|
+ KlDiseaseFacade klDiseaseFacade;
|
|
|
+ @Autowired
|
|
|
+ KlDrugFacade klDrugFacade;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klConceptServiceImpl")
|
|
|
+ private KlConceptService klConceptService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klLibraryInfoServiceImpl")
|
|
|
+ private KlLibraryInfoService klLibraryInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klConceptCommonServiceImpl")
|
|
|
+ private KlConceptCommonService klConceptCommonService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klDiseaseServiceImpl")
|
|
|
+ private KlDiseaseService klDiseaseService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klDrugServiceImpl")
|
|
|
+ KlDrugService klDrugService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klLisServiceImpl")
|
|
|
+ KlLisService klLisService;
|
|
|
+
|
|
|
+
|
|
|
+ public void exporTermExcelAll(HttpServletResponse response, MultipartFile file) {
|
|
|
+ //导入处理
|
|
|
+ List<ImportConceptAllVO> conceptList = ExcelUtils.importExcelNew(file, 0, 1, ImportConceptAllVO.class);
|
|
|
+ Map<Integer, ImportConceptAllVO> conceptExportMap = conceptList.stream()
|
|
|
+ .collect(Collectors.toMap(ImportConceptAllVO::getRowNum, questionInfo -> questionInfo));
|
|
|
+ //校验数据
|
|
|
+ QueryWrapper<KlLexicon> klLexiconQuer = new QueryWrapper<>();
|
|
|
+ klLexiconQuer.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<KlLexicon> list = klLexiconFacade.list(klLexiconQuer);
|
|
|
+ Map<String, KlLexicon> lexiconMap = list.stream()
|
|
|
+ .collect(Collectors.toMap(KlLexicon::getName, questionInfo -> questionInfo));
|
|
|
+ //问题数据
|
|
|
+ Map<Integer, String> errMsg = new HashMap<Integer, String>();
|
|
|
+ Map<String, Integer> libNameMap = new HashMap<String, Integer>();
|
|
|
+ List<Integer> sexType = Arrays.asList(1, 2, 3);
|
|
|
+ for (Integer row : conceptExportMap.keySet()) {
|
|
|
+ ImportConceptAllVO data = conceptExportMap.get(row);
|
|
|
+ //校验医学标准术语、类型、性别、最小年龄、最大年龄必填
|
|
|
+ if (StringUtil.isBlank(data.getLibName()) ||
|
|
|
+ StringUtil.isBlank(data.getLibName()) ||
|
|
|
+ null == data.getSexType()
|
|
|
+ || null == data.getMinAge()
|
|
|
+ || null == data.getMaxAge()) {
|
|
|
+ errMsg.put(data.getRowNum(), "--医学标准术语、类型、性别、最小年龄、最大年龄必填--");
|
|
|
+ } else {
|
|
|
+ //类型
|
|
|
+ if (lexiconMap.get(data.getTypeName()) == null) {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? "--类型错误--" :
|
|
|
+ errMsg.get(data.getRowNum()) + "--类型错误--");
|
|
|
+ } else {
|
|
|
+ data.setLibType(lexiconMap.get(data.getTypeName()).getCode());
|
|
|
+ data.setIsHasCommon(lexiconMap.get(data.getTypeName()).getIsHasCommon());
|
|
|
+ }
|
|
|
+ //性别123
|
|
|
+ if (!sexType.contains(data.getSexType())) {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? "--性别错误--" :
|
|
|
+ errMsg.get(data.getRowNum()) + "--性别错误--");
|
|
|
+ }
|
|
|
+ if (data.getMinAge() < 0.0) {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? "--最小年龄错误--" :
|
|
|
+ errMsg.get(data.getRowNum()) + "--最小年龄错误--");
|
|
|
+ }
|
|
|
+ if (data.getMaxAge() > 200) {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? "--最大年龄错误--" :
|
|
|
+ errMsg.get(data.getRowNum()) + "--最大年龄错误--");
|
|
|
+ }
|
|
|
+ if (data.getMaxAge() < data.getMinAge()) {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? "--最大年龄小于最小年龄--" :
|
|
|
+ errMsg.get(data.getRowNum()) + "--最大年龄小于最小年龄--");
|
|
|
+ }
|
|
|
+ //标准词数据重复校验
|
|
|
+ Integer integer = libNameMap.get(data.getLibName() + "_" + data.getLibType());
|
|
|
+ if (null == integer) {
|
|
|
+ libNameMap.put(data.getLibName() + "_" + data.getLibType(), data.getRowNum());
|
|
|
+ } else {
|
|
|
+ errMsg.put(data.getRowNum(), errMsg.get(data.getRowNum()) == null ? data.getLibName() + "_重复出现----" :
|
|
|
+ errMsg.get(data.getRowNum()) + data.getLibName() + "_重复出现----");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //拆同义词
|
|
|
+ for (Integer row : conceptExportMap.keySet()) {
|
|
|
+ ImportConceptAllVO termExcelVO = conceptExportMap.get(row);
|
|
|
+ Integer libType = termExcelVO.getLibType();
|
|
|
+ String libName = termExcelVO.getLibName();
|
|
|
+ String synonymName = termExcelVO.getSynonymName();
|
|
|
+ List<ImportConceptSubVO> synonymsList = new ArrayList<>();
|
|
|
+ if (null != synonymName && !synonymName.equals("")) {
|
|
|
+ String[] result = synonymName.split("[\\$]");
|
|
|
+ for (String r : result) {
|
|
|
+ ImportConceptSubVO sub = new ImportConceptSubVO();
|
|
|
+ sub.setLibName(libName);
|
|
|
+ sub.setIsConcept(0);
|
|
|
+ sub.setLibType(libType);
|
|
|
+ sub.setStatus(1);
|
|
|
+ sub.setSynonymName(r.trim());
|
|
|
+ //同义词数据重复校验
|
|
|
+ if (null != r.trim() && null != libType) {
|
|
|
+ Integer integer = libNameMap.get(r.trim() + "_" + libType);
|
|
|
+ if (null == integer) {
|
|
|
+ libNameMap.put(r.trim() + "_" + libType, termExcelVO.getRowNum());
|
|
|
+ } else {
|
|
|
+ errMsg.put(termExcelVO.getRowNum(), errMsg.get(termExcelVO.getRowNum()) == null ? r.trim() + "重复出现--" :
|
|
|
+ errMsg.get(termExcelVO.getRowNum()) + r.trim() + "重复出现--");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ synonymsList.add(sub);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ termExcelVO.setSynonymsList(synonymsList);
|
|
|
+ }
|
|
|
+ Set<String> set = klLibraryInfoFacade.getLibraryNameAlls(); // 加载词库数据
|
|
|
+ for (String libName : libNameMap.keySet()) {
|
|
|
+ Integer integer = libNameMap.get(libName);
|
|
|
+ if (set.contains(libName)) {
|
|
|
+ errMsg.put(integer, errMsg.get(integer) == null ? "--数据库中" + libName + "已存在--" :
|
|
|
+ errMsg.get(integer) + "--数据库中" + libName + "已存在--");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //要导出的数据
|
|
|
+ List<ExportConceptAllDTO> exportConceptAll = new ArrayList<>();
|
|
|
+ List<ImportConceptAllVO> conceptListNew = new ArrayList<>();
|
|
|
+ for (Integer i : errMsg.keySet()) {
|
|
|
+ ImportConceptAllVO importConceptAllVO = conceptExportMap.get(i);
|
|
|
+ ExportConceptAllDTO etx = new ExportConceptAllDTO();
|
|
|
+ BeanUtil.copyProperties(importConceptAllVO, etx);
|
|
|
+ etx.setMsg(errMsg.get(i));
|
|
|
+ exportConceptAll.add(etx);
|
|
|
+ conceptListNew.add(importConceptAllVO);
|
|
|
+ }
|
|
|
+ //要插入数据库的数据
|
|
|
+ List<ImportConceptAllVO> conceptListData = new ArrayList<>();
|
|
|
+ for (Integer row : conceptExportMap.keySet()) {
|
|
|
+ ImportConceptAllVO str1 = conceptExportMap.get(row);
|
|
|
+ if (!conceptListNew.contains(str1)) {
|
|
|
+ conceptListData.add(str1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(conceptListData)) {
|
|
|
+ saveAllImport(conceptListData);
|
|
|
+ }
|
|
|
+ String fileName = "错误结果导出.xls";
|
|
|
+ ExcelUtils.exportExcel(exportConceptAll, null, "sheet1", ExportConceptAllDTO.class, fileName, response, 12.8f);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveAllImport(List<ImportConceptAllVO> conceptList) {
|
|
|
+ List<KlLibraryInfo> libraryInfos = new ArrayList<>();
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ boolean res = false;
|
|
|
+ for (ImportConceptAllVO data : conceptList) {
|
|
|
+ KlLibraryInfo klLibraryInfo = new KlLibraryInfo();
|
|
|
+ klLibraryInfo.setName(data.getLibName());
|
|
|
+ klLibraryInfo.setGmtCreate(now);
|
|
|
+ klLibraryInfo.setGmtModified(now);
|
|
|
+ klLibraryInfo.setRemark("dr");
|
|
|
+ klLibraryInfo.setIsConcept(1);
|
|
|
+ klLibraryInfo.setTypeId(data.getLibType());
|
|
|
+ String spell = "";
|
|
|
+ if (StringUtil.isNotBlank(data.getLibName())) {
|
|
|
+ spell = data.getLibName().replaceAll("[\\pP‘’“”,,]", "");
|
|
|
+ spell = Cn2SpellUtil.converterToFirstSpell(spell);
|
|
|
+ }
|
|
|
+ klLibraryInfo.setSpell(spell);
|
|
|
+ libraryInfos.add(klLibraryInfo);
|
|
|
+ }
|
|
|
+ res = klLibraryInfoService.saveBatch(libraryInfos);
|
|
|
+ List<KlConcept> klConcepts = new ArrayList<>();
|
|
|
+ for (KlLibraryInfo klLibraryInfo : libraryInfos) {
|
|
|
+ KlConcept klConcept = new KlConcept();
|
|
|
+ klConcept.setLibId(klLibraryInfo.getId());
|
|
|
+ klConcept.setLibName(klLibraryInfo.getName());
|
|
|
+ klConcept.setLibType(klLibraryInfo.getTypeId());
|
|
|
+ klConcepts.add(klConcept);
|
|
|
+ }
|
|
|
+ res = klConceptService.saveBatch(klConcepts);
|
|
|
+ Map<Long, KlConcept> map = EntityUtil.makeEntityMap(klConcepts, "libId");
|
|
|
+ for (KlLibraryInfo klLibraryInfo : libraryInfos) {
|
|
|
+ klLibraryInfo.setConceptId(map.get(klLibraryInfo.getId()).getId());
|
|
|
+ }
|
|
|
+ res = klLibraryInfoService.updateBatchById(libraryInfos);
|
|
|
+
|
|
|
+ //增加同义词
|
|
|
+ Map<String, ImportConceptAllVO> conceptListMap = conceptList.stream().collect(Collectors.toMap(r -> r.getLibName(), r -> r));
|
|
|
+
|
|
|
+ Map<String, KlConcept> klConceptsMap = klConcepts.stream().collect(Collectors.toMap(r -> r.getLibName(), r -> r));
|
|
|
+
|
|
|
+ List<KlLibraryInfo> libraryInfosSub = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, KlConcept> klConData : klConceptsMap.entrySet()) {
|
|
|
+ KlConcept value = klConData.getValue();
|
|
|
+ ImportConceptAllVO importConceptAllVOS = conceptListMap.get(value.getLibName());
|
|
|
+ List<ImportConceptSubVO> synonymsList = importConceptAllVOS.getSynonymsList();
|
|
|
+ if (ListUtil.isNotEmpty(synonymsList)) {
|
|
|
+ for (ImportConceptSubVO subVO : synonymsList) {
|
|
|
+ KlLibraryInfo klLibraryInfo = new KlLibraryInfo();
|
|
|
+ klLibraryInfo.setName(subVO.getSynonymName());
|
|
|
+ klLibraryInfo.setIsConcept(0);
|
|
|
+ klLibraryInfo.setConceptId(value.getId());
|
|
|
+ klLibraryInfo.setTypeId(value.getLibType());
|
|
|
+ String spell = "";
|
|
|
+ if (StringUtil.isNotBlank(subVO.getSynonymName())) {
|
|
|
+ spell = subVO.getSynonymName().replaceAll("[\\pP‘’“”]", "");
|
|
|
+ spell = Cn2SpellUtil.converterToFirstSpell(spell);
|
|
|
+ }
|
|
|
+ klLibraryInfo.setSpell(spell);
|
|
|
+ libraryInfosSub.add(klLibraryInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res = klLibraryInfoService.saveBatch(libraryInfosSub);
|
|
|
+ //年龄
|
|
|
+ List<KlConceptCommon> conceptCommonList = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, ImportConceptAllVO> entry : conceptListMap.entrySet()) {
|
|
|
+ ImportConceptAllVO value = entry.getValue();
|
|
|
+ for (Map.Entry<String, KlConcept> entry2 : klConceptsMap.entrySet()) {
|
|
|
+ KlConcept value1 = entry2.getValue();
|
|
|
+ if (value.getLibName().equals(value1.getLibName())) {
|
|
|
+ if (null != value.getIsHasCommon() && value.getIsHasCommon().equals(1)) {
|
|
|
+ KlConceptCommon conceptCommon = new KlConceptCommon();
|
|
|
+ conceptCommon.setSexType(value.getSexType());
|
|
|
+ conceptCommon.setMaxAge(value.getMaxAge());
|
|
|
+ conceptCommon.setMinAge(value.getMinAge());
|
|
|
+ conceptCommon.setConceptId(value1.getId());
|
|
|
+ conceptCommon.setCreator("-2");
|
|
|
+ conceptCommon.setModifier("-2");
|
|
|
+ conceptCommon.setGmtCreate(now);
|
|
|
+ conceptCommon.setGmtModified(now);
|
|
|
+ conceptCommonList.add(conceptCommon);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ res = klConceptCommonService.saveBatch(conceptCommonList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void exportTemplateAll(HttpServletResponse response) {
|
|
|
+ //类型数据
|
|
|
+ QueryWrapper<KlLexicon> klLexiconQuer = new QueryWrapper<>();
|
|
|
+ klLexiconQuer.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ List<KlLexicon> klLexiconList = klLexiconFacade.list(klLexiconQuer);
|
|
|
+ String fileName = "模板.xls";
|
|
|
+ String title = null;
|
|
|
+ // ExcelUtils.exportExcel(new ArrayList<>(), null, "sheet1", ExportConceptAllDTO.class, fileName, response, 12.8f);
|
|
|
+ float height = 12.8f;
|
|
|
+ Boolean havTitle = false;
|
|
|
+ if (StringUtil.isNotBlank(title)) {
|
|
|
+ havTitle = true;
|
|
|
+ }
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, "sheet1"), ExportConceptModeDTO.class, new ArrayList<>());
|
|
|
+ if (workbook != null) {
|
|
|
+ //设置第5,6整列只能是数字
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);//创建Excel工作表的行
|
|
|
+ CellStyle cellStyle = workbook.createCellStyle();//创建单元格样式
|
|
|
+ DataFormat df = workbook.createDataFormat();// 此处设置数据格式
|
|
|
+ cellStyle.setDataFormat(df.getFormat("#,##0.0"));//保留1位小数点
|
|
|
+ sheet.setDefaultColumnStyle(4, cellStyle);
|
|
|
+ sheet.setDefaultColumnStyle(5, cellStyle);
|
|
|
+
|
|
|
+ //设置第3整列只能指定类型下拉选
|
|
|
+ List<String> typeNames = new ArrayList<>();
|
|
|
+ typeNames = klLexiconList.stream().map(ac -> ac.getName()).collect(Collectors.toList());
|
|
|
+ String[] typeName = typeNames.toArray(new String[typeNames.size()]);
|
|
|
+ HSSFWorkbook wbook = new HSSFWorkbook();
|
|
|
+ Sheet hidden = workbook.createSheet("hidden");
|
|
|
+ HSSFCell cell = null;
|
|
|
+ for (int i = 0, length = typeNames.size(); i < length; i++) {
|
|
|
+ String name = typeNames.get(i);
|
|
|
+ Row row = hidden.createRow(i);
|
|
|
+ Cell cell1 = row.createCell(0);
|
|
|
+ cell1.setCellValue(name);
|
|
|
+ }
|
|
|
+ Name namedCell = workbook.createName();
|
|
|
+ namedCell.setNameName("hidden");
|
|
|
+ namedCell.setRefersToFormula("hidden!$A$1:$A$" + typeNames.size());
|
|
|
+ //加载数据,将名称为hidden的
|
|
|
+ DVConstraint constraint = DVConstraint.createFormulaListConstraint("hidden");
|
|
|
+ CellRangeAddressList regions = new CellRangeAddressList(1, 50000, 2, 2);
|
|
|
+ //DVConstraint constraint = DVConstraint.createExplicitListConstraint(typeName);
|
|
|
+ HSSFDataValidation data_validation = new HSSFDataValidation(regions, constraint);
|
|
|
+ if (null != data_validation) {
|
|
|
+ sheet.addValidationData(data_validation);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置第3整列只能下拉选1.2.3
|
|
|
+ String[] strings = { "1", "2", "3" };
|
|
|
+ CellRangeAddressList regions2 = new CellRangeAddressList(1, 50000, 3, 3);
|
|
|
+ DVConstraint constraint2 = DVConstraint.createExplicitListConstraint(strings);
|
|
|
+ HSSFDataValidation data_validation2 = new HSSFDataValidation(regions2, constraint2);
|
|
|
+ sheet.addValidationData(data_validation2);
|
|
|
+
|
|
|
+
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ Row row = sheet.getRow(0);
|
|
|
+ int startRowNum = 1;
|
|
|
+ if (havTitle) {
|
|
|
+ startRowNum = 2;
|
|
|
+ }
|
|
|
+ for (int i = startRowNum; i <= rowNum; i++) {
|
|
|
+ row = sheet.getRow(i);
|
|
|
+ row.setHeightInPoints(height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ response.setHeader("content-Type", "application/vnd.ms-excel");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
|
|
+ workbook.write(response.getOutputStream());
|
|
|
+ } catch (IOException e) {
|
|
|
+ // throw new NormalException(e.getMessage());
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出Excel异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|