diff --git a/.idea/libraries/Maven__commons_io_commons_io_2_5.xml b/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
similarity index 64%
rename from .idea/libraries/Maven__commons_io_commons_io_2_5.xml
rename to .idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
index 9c180e5f..f06fc4b3 100644
--- a/.idea/libraries/Maven__commons_io_commons_io_2_5.xml
+++ b/.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3c563aa3..4fdbe5fd 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,17 +2,23 @@
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
@@ -52,16 +58,19 @@
-
+
+
-
+
+
+
@@ -160,7 +169,7 @@
-
+
@@ -190,7 +199,7 @@
file://$PROJECT_DIR$/src/test/java/com/lz/FumeiaiTest.java
- 190
+ 191
@@ -215,7 +224,7 @@
file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java
- 83
+ 93
@@ -228,11 +237,6 @@
80
-
- file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/controller/StaffController.java
- 191
-
-
diff --git a/lz_management.iml b/lz_management.iml
index 13d0f30d..df5c3c5c 100644
--- a/lz_management.iml
+++ b/lz_management.iml
@@ -124,7 +124,7 @@
-
+
diff --git a/pom.xml b/pom.xml
index 5dd54fe0..5e906214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@
2.5
1.10
1.10
+ 1.3.2
1.4.0
0.7.0
0.0.9
@@ -146,6 +147,11 @@
shiro-spring
${shiro.version}
+
+ org.apache.commons
+ commons-io
+ ${commons.io.version}
+
io.jsonwebtoken
jjwt
diff --git a/src/main/java/com/lz/common/utils/DateUtils.java b/src/main/java/com/lz/common/utils/DateUtils.java
index 31e56627..b604ae28 100644
--- a/src/main/java/com/lz/common/utils/DateUtils.java
+++ b/src/main/java/com/lz/common/utils/DateUtils.java
@@ -27,6 +27,10 @@ public class DateUtils {
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
+ /**
+ * yyyyMMdd
+ */
+ public static final String DEFAULT_PATTERN = "yyyyMMdd";
/**
* 日期格式化 日期格式为:yyyy-MM-dd
diff --git a/src/main/java/com/lz/common/utils/ExcelUtil.java b/src/main/java/com/lz/common/utils/ExcelUtil.java
new file mode 100644
index 00000000..85677fd7
--- /dev/null
+++ b/src/main/java/com/lz/common/utils/ExcelUtil.java
@@ -0,0 +1,1118 @@
+package com.lz.common.utils;
+
+import com.google.common.collect.Lists;
+import com.lz.common.utils.excel.*;
+import com.lz.modules.app.enums.ExcelStaffHeardEnum;
+import com.lz.modules.app.enums.GenderEnum;
+import com.lz.modules.app.enums.MaritalStatusEnum;
+import org.apache.commons.beanutils.BeanComparator;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.ComparatorUtils;
+import org.apache.commons.collections.comparators.ComparableComparator;
+import org.apache.commons.collections.comparators.ComparatorChain;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.lang.reflect.Field;
+import java.text.DecimalFormat;
+import java.text.MessageFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @BelongsProject: ltapi
+ * @BelongsPackage: com.lz.lt.api.common.util
+ * @Author: gui.quanwang
+ * @CreateTime: 2018-11-27 16:38
+ * @Description: excel工具类,支持文件的导入、导出 与 {@link ExcelCell}搭配使用
+ * @注意:本内容仅限于杭州霖梓网络科技有限公司内部传阅,禁止外泄以及用于其他的商业目的
+ */
+public class ExcelUtil {
+
+ private static Logger logger = LoggerFactory.getLogger(ExcelUtil.class);
+ private static final String excel2003L = ".xls";//2003- 版本的excel
+ private static final String excel2007U = ".xlsx";//2007+ 版本的excel
+
+ /**
+ * 用来验证excel与Vo中的类型是否一致
+ * Map<栏位类型,只能是哪些Cell类型>
+ */
+ private static Map, CellType[]> validateMap = new HashMap<>();
+
+ static {
+ validateMap.put(String[].class, new CellType[]{CellType.STRING});
+ validateMap.put(Double[].class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(String.class, new CellType[]{CellType.STRING});
+ validateMap.put(Double.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Date.class, new CellType[]{CellType.NUMERIC, CellType.STRING});
+ validateMap.put(Integer.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Float.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Long.class, new CellType[]{CellType.NUMERIC});
+ validateMap.put(Boolean.class, new CellType[]{CellType.BOOLEAN});
+ }
+
+ /**
+ * 通过class获取对应的字段
+ *
+ * @param clazz 类
+ * @return map
+ */
+ public static Map getHeaderMap(Class clazz) {
+ Map headerMap = new LinkedHashMap<>();
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ headerMap.put(field.getName(), field.getName());
+ }
+ return headerMap;
+ }
+
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
+ * 用于单个sheet
+ *
+ * @param 表示传参有泛型
+ * @param headers 表格属性列名数组
+ * @param dataSet 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
+ * javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ */
+ public static void exportExcel(Map headers, Collection dataSet, OutputStream out) {
+ exportExcel(headers, dataSet, out, null);
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
+ * 用于单个sheet
+ *
+ * @param
+ * @param headers 表格属性列名数组
+ * @param dataSet 需要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的
+ * javabean属性的数据类型有基本数据类型及String,Date,String[],Double[]
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
+ */
+ public static void exportExcel(Map headers, Collection dataSet, OutputStream out,
+ String pattern) {
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ // 生成一个表格
+ HSSFSheet sheet = workbook.createSheet();
+
+ write2Sheet(sheet, headers, dataSet, pattern);
+ try {
+ workbook.write(out);
+ } catch (IOException e) {
+ logger.error(e.toString(), e);
+ }
+ }
+
+ /**
+ * 导出excel文件
+ *
+ * @param datalist 数据列表
+ * @param out 数据流输出
+ */
+ public static void exportExcel(String[][] datalist, OutputStream out) {
+ try {
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ // 生成一个表格
+ HSSFSheet sheet = workbook.createSheet();
+
+ //保存数据
+ for (int i = 0; i < datalist.length; i++) {
+ String[] r = datalist[i];
+ HSSFRow row = sheet.createRow(i);
+ for (int j = 0; j < r.length; j++) {
+ HSSFCell cell = row.createCell(j);
+ //cell max length 32767
+ if (r[j].length() > 32767) {
+ r[j] = "--此字段过长(超过32767),已被截断--" + r[j];
+ r[j] = r[j].substring(0, 32766);
+ }
+ cell.setCellValue(r[j]);
+ }
+ }
+ //自动列宽
+ if (datalist.length > 0) {
+ int colcount = datalist[0].length;
+ for (int i = 0; i < colcount; i++) {
+ sheet.autoSizeColumn(i);
+ }
+ }
+ workbook.write(out);
+ } catch (IOException e) {
+ logger.error(e.toString(), e);
+ }
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
+ * 用于多个sheet
+ *
+ * @param
+ * @param sheetList {@link ExcelSheet}的集合
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ */
+ public static void exportExcel(List> sheetList, OutputStream out) {
+ exportExcel(sheetList, out, null);
+ }
+
+ /**
+ * excel导出并下载
+ *
+ * @param sheetList 数据列表
+ * @param response 回调
+ * @param fileName 下载的文件名称(不需传递 .xls 文件后缀)
+ * @param
+ * @throws IOException
+ */
+ public static void exportExcel(List> sheetList
+ , String fileName, HttpServletResponse response) throws IOException, NullPointerException {
+ if (StringUtil.isEmpty(fileName)) {
+ throw new NullPointerException("文件名不能为空!!");
+ }
+ //设置请求头,同时处理文件名不能出现中文的问题
+ String headStr = "attachment; filename=" + new String(fileName.getBytes(), "iso-8859-1").concat(".xls");
+ response.setContentType("APPLICATION/OCTET-STREAM");
+ response.setHeader("Content-Disposition", headStr);
+ OutputStream outputStream = response.getOutputStream();
+ exportExcel(sheetList, outputStream);
+ }
+
+ /**
+ * 利用JAVA的反射机制,将放置在JAVA集合中并且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上
+ * 用于多个sheet
+ *
+ * @param
+ * @param sheets {@link ExcelSheet}的集合
+ * @param out 与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中
+ * @param pattern 如果有时间数据,设定输出格式。默认为"yyy-MM-dd"
+ */
+ public static void exportExcel(List> sheets, OutputStream out, String pattern) {
+ if (CollectionUtils.isEmpty(sheets)) {
+ return;
+ }
+ // 声明一个工作薄
+ HSSFWorkbook workbook = new HSSFWorkbook();
+ for (ExcelSheet sheet : sheets) {
+ // 生成一个表格
+ HSSFSheet hssfSheet = workbook.createSheet(sheet.getSheetName());
+ write2Sheet(hssfSheet, sheet.getHeaders(), sheet.getDataset(), pattern);
+ }
+ try {
+ workbook.write(out);
+ } catch (IOException e) {
+ logger.error(e.toString(), e);
+ }
+ }
+
+ /**
+ * 根据文件路径解析
+ *
+ * @param clazz 解析类
+ * @param file excel文件
+ * @param pattern 时间转换格式
+ * @param logs 错误日志
+ * @param arrayCount 数值数组
+ * @param sheetName 工作表名称
+ * @param
+ * @return
+ */
+ public static Collection importExcel(Class clazz, File file
+ , String pattern, ExcelLogs logs, String sheetName, Integer... arrayCount) {
+ InputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(file);
+ return importExcel(clazz, inputStream, pattern, logs, sheetName, arrayCount);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ public static List