去除autopoi,引入easypoi
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+10
-25
@@ -11,12 +11,12 @@ import com.jero.common.util.oConvertUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.view.EasypoiSingleExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -70,13 +70,10 @@ public class JeroController<T, S extends IService<T>> {
|
||||
}
|
||||
|
||||
// Step.3 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
ModelAndView mv = new ModelAndView(new EasypoiSingleExcelView());
|
||||
mv.addObject(FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
|
||||
mv.addObject(CLASS, clazz);
|
||||
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
|
||||
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
|
||||
exportParams.setImageBasePath(upLoadPath);
|
||||
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
|
||||
mv.addObject(PARAMS,exportParams);
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
return mv;
|
||||
@@ -89,11 +86,10 @@ public class JeroController<T, S extends IService<T>> {
|
||||
* @param object 实体类
|
||||
* @param clazz 实体类class
|
||||
* @param title 标题
|
||||
* @param exportFields 导出字段自定义
|
||||
* @param pageNum 每个sheet的数据条数
|
||||
* @param request
|
||||
*/
|
||||
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields,Integer pageNum) {
|
||||
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title,Integer pageNum) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
@@ -116,7 +112,7 @@ public class JeroController<T, S extends IService<T>> {
|
||||
exportList = records;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,upLoadPath);
|
||||
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i);
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
//map.put("title",exportParams);//表格Title
|
||||
map.put(PARAMS,exportParams);//表格Title
|
||||
@@ -125,23 +121,12 @@ public class JeroController<T, S extends IService<T>> {
|
||||
listMap.add(map);
|
||||
}
|
||||
// Step.4 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
ModelAndView mv = new ModelAndView(new EasypoiSingleExcelView());
|
||||
mv.addObject(FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
|
||||
mv.addObject(NormalExcelConstants.MAP_LIST, listMap);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据权限导出excel,传入导出字段参数
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields) {
|
||||
ModelAndView mv = this.exportXls(request,object,clazz,title);
|
||||
mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields);
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象ID
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.jero.common.system.base.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
|
||||
+2
-2
@@ -1,5 +1,6 @@
|
||||
package com.jero.common.system.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -7,7 +8,6 @@ import com.jero.common.aspect.annotation.Dict;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@@ -58,7 +58,7 @@ public class SysDictItemCore implements Serializable {
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15,type=4)
|
||||
@Excel(name = "排序", width = 15, type=4)
|
||||
private Integer sortOrder;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -11,6 +11,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import cn.afterturn.easypoi.util.PoiPublicUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
@@ -18,7 +19,6 @@ import com.jero.common.constant.DataBaseConstant;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.filter.FileTypeFilter;
|
||||
import com.jero.common.util.oss.OssBootUtil;
|
||||
import org.jeecgframework.poi.util.PoiPublicUtil;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
+28
-28
@@ -1,28 +1,28 @@
|
||||
package com.jero.config;
|
||||
|
||||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: Scott
|
||||
* @Date: 2018/2/7
|
||||
* @description: autopoi 配置类
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class AutoPoiConfig {
|
||||
|
||||
/**
|
||||
* excel注解字典参数支持(导入导出字典值,自动翻译)
|
||||
* 举例: @Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
* 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
|
||||
* 2、导入的时候,会把男、女翻译成1,2存进数据库;
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ApplicationContextUtil applicationContextUtil() {
|
||||
return new org.jeecgframework.core.util.ApplicationContextUtil();
|
||||
}
|
||||
|
||||
}
|
||||
//package com.jero.config;
|
||||
//
|
||||
//import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * @Author: Scott
|
||||
// * @Date: 2018/2/7
|
||||
// * @description: autopoi 配置类
|
||||
// */
|
||||
//
|
||||
//@Configuration
|
||||
//public class AutoPoiConfig {
|
||||
//
|
||||
// /**
|
||||
// * excel注解字典参数支持(导入导出字典值,自动翻译)
|
||||
// * 举例: @Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
// * 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
|
||||
// * 2、导入的时候,会把男、女翻译成1,2存进数据库;
|
||||
// * @return
|
||||
// */
|
||||
// @Bean
|
||||
// public ApplicationContextUtil applicationContextUtil() {
|
||||
// return new org.jeecgframework.core.util.ApplicationContextUtil();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
+65
-65
@@ -1,65 +1,65 @@
|
||||
package com.jero.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.api.CommonAPI;
|
||||
import com.jero.common.system.vo.DictModel;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import org.jeecgframework.dict.service.AutoPoiDictServiceI;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述:AutoPoi Excel注解支持字典参数设置
|
||||
* 举例: @Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
* 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
|
||||
* 2、导入的时候,会把男、女翻译成1,2存进数据库;
|
||||
*
|
||||
* @Author:scott
|
||||
* @since:2019-04-09
|
||||
* @Version:1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
||||
@Lazy
|
||||
@Resource
|
||||
private CommonAPI commonAPI;
|
||||
|
||||
/**
|
||||
* 通过字典查询easypoi,所需字典文本
|
||||
*
|
||||
* @Author:scott
|
||||
* @since:2019-04-09
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String[] queryDict(String dicTable, String dicCode, String dicText) {
|
||||
List<String> dictReplaces = new ArrayList<>();
|
||||
List<DictModel> dictList = null;
|
||||
// step.1 如果没有字典表则使用系统字典表
|
||||
if (oConvertUtils.isEmpty(dicTable)) {
|
||||
dictList = commonAPI.queryDictItemsByCode(dicCode);
|
||||
} else {
|
||||
try {
|
||||
dicText = oConvertUtils.getString(dicText, dicCode);
|
||||
dictList = commonAPI.queryTableDictItemsByCode(dicTable, dicText, dicCode);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
for (DictModel t : dictList) {
|
||||
if(t!=null){
|
||||
dictReplaces.add(t.getText() + "_" + t.getValue());
|
||||
}
|
||||
}
|
||||
if (!dictReplaces.isEmpty()) {
|
||||
log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
|
||||
return dictReplaces.toArray(new String[dictReplaces.size()]);
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
//package com.jero.config;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import com.jero.common.api.CommonAPI;
|
||||
//import com.jero.common.system.vo.DictModel;
|
||||
//import com.jero.common.util.oConvertUtils;
|
||||
//import org.jeecgframework.dict.service.AutoPoiDictServiceI;
|
||||
//import org.springframework.context.annotation.Lazy;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 描述:AutoPoi Excel注解支持字典参数设置
|
||||
// * 举例: @Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
// * 1、导出的时候会根据字典配置,把值1,2翻译成:男、女;
|
||||
// * 2、导入的时候,会把男、女翻译成1,2存进数据库;
|
||||
// *
|
||||
// * @Author:scott
|
||||
// * @since:2019-04-09
|
||||
// * @Version:1.0
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Service
|
||||
//public class AutoPoiDictConfig implements AutoPoiDictServiceI {
|
||||
// @Lazy
|
||||
// @Resource
|
||||
// private CommonAPI commonAPI;
|
||||
//
|
||||
// /**
|
||||
// * 通过字典查询easypoi,所需字典文本
|
||||
// *
|
||||
// * @Author:scott
|
||||
// * @since:2019-04-09
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public String[] queryDict(String dicTable, String dicCode, String dicText) {
|
||||
// List<String> dictReplaces = new ArrayList<>();
|
||||
// List<DictModel> dictList = null;
|
||||
// // step.1 如果没有字典表则使用系统字典表
|
||||
// if (oConvertUtils.isEmpty(dicTable)) {
|
||||
// dictList = commonAPI.queryDictItemsByCode(dicCode);
|
||||
// } else {
|
||||
// try {
|
||||
// dicText = oConvertUtils.getString(dicText, dicCode);
|
||||
// dictList = commonAPI.queryTableDictItemsByCode(dicTable, dicText, dicCode);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(),e);
|
||||
// }
|
||||
// }
|
||||
// for (DictModel t : dictList) {
|
||||
// if(t!=null){
|
||||
// dictReplaces.add(t.getText() + "_" + t.getValue());
|
||||
// }
|
||||
// }
|
||||
// if (!dictReplaces.isEmpty()) {
|
||||
// log.info("---AutoPoi--Get_DB_Dict------"+ dictReplaces.toString());
|
||||
// return dictReplaces.toArray(new String[dictReplaces.size()]);
|
||||
// }
|
||||
// return new String[0];
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user