diff --git a/tz/common/common-core/pom.xml b/tz/common/common-core/pom.xml
index b2d7ba5..5dacce2 100644
--- a/tz/common/common-core/pom.xml
+++ b/tz/common/common-core/pom.xml
@@ -33,25 +33,7 @@
3.17
-
-
- com.github.abel533
- ECharts
- 3.0.0.6
-
-
-
- org.jsoup
- jsoup
- 1.14.2
-
-
-
- com.itextpdf
- itextpdf
- 5.5.13.1
-
com.spring4all
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/config/SystemUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/config/SystemUtil.java
index 0ed47c0..22b9767 100644
--- a/tz/common/common-core/src/main/java/com/tz/platform/common/core/config/SystemUtil.java
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/config/SystemUtil.java
@@ -22,6 +22,4 @@ public class SystemUtil {
}
public static final String PIC_PATH = getProperty("pic_path");
-
-
}
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/Constants.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/Constants.java
new file mode 100644
index 0000000..82564d6
--- /dev/null
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/Constants.java
@@ -0,0 +1,45 @@
+package com.tz.platform.common.core.tools;
+
+public class Constants {
+ private Constants() {
+ }
+
+ public final static String ADMIN = "admin";// admin
+ public final static Integer FREEZE = 3;// 冻结状态
+ public final static String REGEX_MOBILE = "^1[0-9]{10}$";
+
+ /**
+ * session
+ *
+ * @author wujing
+ */
+ public interface Session {
+ public final static String BOSS_MENU = "BOSS_MENU";//
+ public final static String USER_NO = "USERNO"; // userno
+ public final static String USER_VO = "USERVO";// 不能使用user,关键词
+ public final static String REAL_NAME = "REALNAME";//
+ }
+
+ /**
+ * cookie
+ *
+ * @author wujing
+ */
+ public interface Cookie {
+ public final static String USER_TOKEN = "USERTOKEN";
+ }
+
+ /**
+ * 日期类型
+ *
+ * @author wujing
+ */
+ public interface DATE {
+ public final static String YYYYMMDD = "yyyyMMdd";
+ public final static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+ public final static String YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";
+ public final static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+ public final static String YYYY_MM_DD = "yyyy-MM-dd";
+ }
+
+}
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/DateUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/DateUtil.java
new file mode 100644
index 0000000..9429157
--- /dev/null
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/DateUtil.java
@@ -0,0 +1,414 @@
+package com.tz.platform.common.core.tools;
+
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateUtil {
+ /**
+ * 此类不需要实例化
+ */
+ private DateUtil() {
+ }
+
+ /**
+ * 时间转换:长整型转换为日期字符型
+ *
+ * @param format 格式化类型:yyyy-MM-dd
+ * @param time 13位有效数字:1380123456789
+ * @return 格式化结果 (yyyy-MM-dd)
+ */
+ public static String formatToString(String format, long time) {
+ if (time == 0) {
+ return "";
+ }
+ return new SimpleDateFormat(format).format(new Date(time));
+ }
+
+ /**
+ * 时间转换:日期字符型转换为长整型
+ *
+ * @param format 格式化类型:yyyy-MM-dd
+ * @return 13位有效数字 (1380123456789)
+ */
+ public static long formatToLong(String format) {
+ SimpleDateFormat f = new SimpleDateFormat(format);
+ return Timestamp.valueOf(f.format(new Date())).getTime();
+ }
+
+ /**
+ * 获取当前年份
+ *
+ * @return yyyy (2016)
+ */
+ public static int getYear() {
+ Calendar cal = Calendar.getInstance();
+ return cal.get(Calendar.YEAR);
+ }
+
+ /**
+ * 获取当前月份
+ *
+ * @return MM (06)
+ */
+ public static String getMonth() {
+ Calendar cal = Calendar.getInstance();
+ return new DecimalFormat("00").format(cal.get(Calendar.MONTH));
+ }
+
+ /**
+ * 功能描述:格式化日期
+ *
+ * @param dateStr String 字符型日期
+ * @param format String 格式
+ * @return Date 日期
+ */
+ public static Date parseDate(String dateStr, String format) {
+ try {
+ DateFormat dateFormat = new SimpleDateFormat(format);
+ String dt = dateStr.replaceAll("-", "/");
+ dt = dateStr;
+ if ((!dt.equals("")) && (dt.length() < format.length())) {
+ dt += format.substring(dt.length()).replaceAll("[YyMmDdHhSs]", "0");
+ }
+ Date date = dateFormat.parse(dt);
+ return date;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * 功能描述:格式化日期
+ *
+ * @param dateStr String 字符型日期:YYYY-MM-DD 格式
+ * @return Date
+ */
+ public static Date parseDate(String dateStr) {
+ return parseDate(dateStr, "yyyy-MM-dd");
+ }
+
+ /**
+ * 功能描述:格式化输出日期
+ *
+ * @param date Date 日期
+ * @param format String 格式
+ * @return 返回字符型日期
+ */
+ public static String format(Date date, String format) {
+ String result = "";
+ try {
+ if (date != null) {
+ DateFormat dateFormat = new SimpleDateFormat(format);
+ result = dateFormat.format(date);
+ }
+ } catch (Exception e) {
+ }
+ return result;
+ }
+
+ /**
+ * 功能描述:
+ *
+ * @param date Date 日期
+ * @return
+ */
+ public static String format(Date date) {
+ return format(date, "yyyy-MM-dd");
+ }
+
+ /**
+ * 功能描述:返回年份
+ *
+ * @param date Date 日期
+ * @return 返回年份
+ */
+ public static int getYear(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.YEAR);
+ }
+
+ /**
+ * 功能描述:返回月份
+ *
+ * @param date Date 日期
+ * @return 返回月份
+ */
+ public static int getMonth(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.MONTH) + 1;
+ }
+
+ /**
+ * 功能描述:返回日份
+ *
+ * @param date Date 日期
+ * @return 返回日份
+ */
+ public static int getDay(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.DAY_OF_MONTH);
+ }
+
+ /**
+ * 功能描述:返回小时
+ *
+ * @param date 日期
+ * @return 返回小时
+ */
+ public static int getHour(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.HOUR_OF_DAY);
+ }
+
+ /**
+ * 功能描述:返回分钟
+ *
+ * @param date 日期
+ * @return 返回分钟
+ */
+ public static int getMinute(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.MINUTE);
+ }
+
+ /**
+ * 返回秒钟
+ *
+ * @param date Date 日期
+ * @return 返回秒钟
+ */
+ public static int getSecond(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(Calendar.SECOND);
+ }
+
+ /**
+ * 功能描述:返回毫秒
+ *
+ * @param date 日期
+ * @return 返回毫秒
+ */
+ public static long getMillis(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.getTimeInMillis();
+ }
+
+ /**
+ * 功能描述:返回字符型日期
+ *
+ * @param date 日期
+ * @return 返回字符型日期 yyyy-MM-dd 格式
+ */
+ public static String getDate(Date date) {
+ return format(date, "yyyy-MM-dd");
+ }
+
+ /**
+ * 功能描述:返回字符型时间
+ *
+ * @param date Date 日期
+ * @return 返回字符型时间 HH:mm:ss 格式
+ */
+ public static String getTime(Date date) {
+ return format(date, "HH:mm:ss");
+ }
+
+ /**
+ * 功能描述:返回字符型日期时间
+ *
+ * @param date Date 日期
+ * @return 返回字符型日期时间 yyyy-MM-dd HH:mm:ss 格式
+ */
+ public static String getDateTime(Date date) {
+ return format(date, "yyyy-MM-dd HH:mm:ss");
+ }
+
+ /**
+ * 功能描述:日期相加
+ *
+ * @param date Date 日期
+ * @param day int 天数
+ * @return 返回相加后的日期
+ */
+ public static Date addDate(Date date, int day) {
+ Calendar calendar = Calendar.getInstance();
+ long millis = getMillis(date) + ((long) day) * 24 * 3600 * 1000;
+ calendar.setTimeInMillis(millis);
+ return calendar.getTime();
+ }
+
+ /**
+ * 当前日期加上年
+ *
+ * @param date
+ * @param year
+ * @return
+ */
+ public static Date addYear(Date date, int year) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.YEAR, 1);
+ return calendar.getTime();
+ }
+
+ /**
+ * 功能描述:日期相加
+ *
+ * @param date yyyy-MM-dd
+ * @param day int 天数
+ * @return 返回相加后的日期
+ * @throws ParseException
+ */
+ public static String add(String date, int day) throws ParseException {
+ SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
+ long d = df.parse(date).getTime();
+ long millis = d + ((long) day) * 24 * 3600 * 1000;
+ return df.format(new Date(millis));
+ }
+
+ /**
+ * 功能描述:日期相减
+ *
+ * @param date Date 日期
+ * @param date1 Date 日期
+ * @return 返回相减后的日期
+ */
+ public static int diffDate(Date date, Date date1) {
+ return (int) ((getMillis(date) - getMillis(date1)) / (24 * 3600 * 1000));
+ }
+
+ /**
+ * 功能描述:取得指定月份的第一天
+ *
+ * @param strdate String 字符型日期
+ * @return String yyyy-MM-dd 格式
+ */
+ public static String getMonthBegin(String strdate) {
+ Date date = parseDate(strdate);
+ return format(date, "yyyy-MM") + "-01";
+ }
+
+ /**
+ * 功能描述:取得指定月份的最后一天
+ *
+ * @param strdate String 字符型日期
+ * @return String 日期字符串 yyyy-MM-dd格式
+ */
+ public static String getMonthEnd(String strdate) {
+ Date date = parseDate(getMonthBegin(strdate));
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(Calendar.MONTH, 2);
+ calendar.add(Calendar.DAY_OF_YEAR, -1);
+ return formatDate(calendar.getTime());
+ }
+
+ /**
+ * 功能描述:常用的格式化日期
+ *
+ * @param date Date 日期
+ * @return String 日期字符串 yyyy-MM-dd格式
+ */
+ public static String formatDate(Date date) {
+ return formatDateByFormat(date, "yyyy-MM-dd");
+ }
+
+ /**
+ * 以指定的格式来格式化日期
+ *
+ * @param date Date 日期
+ * @param format String 格式
+ * @return String 日期字符串
+ */
+ public static String formatDateByFormat(Date date, String format) {
+ String result = "";
+ if (date != null) {
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ result = sdf.format(date);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 计算日期之间的天数
+ *
+ * @param beginDate 开始日期 yyy-MM-dd
+ * @param endDate 结束日期 yyy-MM-dd
+ * @return
+ * @throws ParseException
+ */
+ public static int getDay(String beginDate, String endDate) throws ParseException {
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+ long to = df.parse(endDate).getTime();
+ long from = df.parse(beginDate).getTime();
+ return (int) ((to - from) / (1000 * 60 * 60 * 24));
+ }
+
+ /**
+ * 计算日期之间的年数
+ *
+ * @param startYear 开始日期 yyy-MM-dd
+ * @param endYear 结束日期 yyy-MM-dd
+ * @return
+ */
+ public static int yearDateDiff(String startYear, String endYear) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar startDate = Calendar.getInstance();
+ Calendar endDate = Calendar.getInstance();
+ try {
+ startDate.setTime(sdf.parse(startYear));
+ endDate.setTime(sdf.parse(endYear));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ return (endDate.get(Calendar.YEAR) - startDate.get(Calendar.YEAR));
+ }
+
+ /**
+ * 上个月
+ *
+ * @return 上个月
+ */
+ public static DateTime lastMonth() {
+ return offsetMonth(new DateTime(), -1);
+ }
+
+ /**
+ * 偏移月
+ *
+ * @param date 日期
+ * @param offset 偏移月数,正数向未来偏移,负数向历史偏移
+ * @return 偏移后的日期
+ */
+ public static DateTime offsetMonth(Date date, int offset) {
+ return offset(date, DateField.MONTH, offset);
+ }
+
+ public static DateTime offset(Date date, DateField dateField, int offset) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ cal.add(dateField.getValue(), offset);
+ return new DateTime(cal.getTime());
+ }
+}
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/ExcelUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/ExcelUtil.java
new file mode 100644
index 0000000..2131ae7
--- /dev/null
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/ExcelUtil.java
@@ -0,0 +1,478 @@
+package com.tz.platform.common.core.tools;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+import org.springframework.util.StringUtils;
+
+import java.awt.*;
+import java.awt.Color;
+import java.io.*;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ExcelUtil {
+ private String templatePath ;
+ private String outPath;
+
+ private FileInputStream is;
+ private XSSFWorkbook excel ;
+ //获取第一个sheet
+ private XSSFSheet sheet0 ;
+
+ private Font defaultFont;
+
+ private CellStyle cellStyle;
+
+ private CellStyle numStyle ;
+
+
+ public ExcelUtil(){
+ initNumStyle();
+ }
+
+ public ExcelUtil(String template,String out) throws Exception{
+ this.templatePath = template;
+ is = new FileInputStream(templatePath);
+ excel = new XSSFWorkbook(is);
+ defaultFont = excel.createFont();
+ ((XSSFFont) defaultFont).setColor(new XSSFColor(new Color(0,0,0)));
+ cellStyle = excel.createCellStyle();
+ cellStyle.setFont(defaultFont);
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
+ initNumStyle();
+ //获取第一个sheet
+ sheet0 = excel.getSheetAt(0);
+ outPath = out;
+ }
+
+ public ExcelUtil(InputStream fileInputStream) throws Exception{
+ excel = new XSSFWorkbook(fileInputStream);
+ sheet0 = excel.getSheetAt(0);
+ }
+
+ public int getLastRowNum(){
+ return this.sheet0.getLastRowNum();
+ }
+
+ private void initNumStyle(){
+ if(excel!=null){
+ numStyle = excel.createCellStyle();
+ XSSFDataFormat df = excel.createDataFormat();//此处设置数据格式
+ numStyle.setDataFormat(df.getFormat("#,#0.000")); //小数点后保留两位,可以写contentStyle.setDataFormat(df.getFormat("#,#0.00"));
+ }
+
+ }
+
+ public ExcelUtil(String template,String out,int sheetIndex) throws Exception{
+ this.templatePath = template;
+
+ is = new FileInputStream(templatePath);
+
+ excel = new XSSFWorkbook(is);
+
+ //获取第一个sheet
+ sheet0 = excel.getSheetAt(sheetIndex);
+ outPath = out;
+ }
+
+
+ public void CreateExcel(java.util.List datas, ExcelHeader[] headers, String fileName, String sheetName){
+ if(excel == null){
+ excel = new XSSFWorkbook();
+ }
+ XSSFWorkbook workbook =excel;
+
+ XSSFSheet sheet = workbook.createSheet(sheetName);
+ int rowNum = 0;
+
+// System.out.println("Creating excel");
+
+ int colNum = 0;
+
+ Row rowHeader = sheet.createRow(0);
+
+ for(ExcelHeader header :headers){
+ Cell cell = rowHeader.createCell(colNum++);
+ cell.setCellValue(header.getAliax());
+ }
+
+ rowNum=1;
+ colNum=0;
+ appendDataToExcel(sheet,datas,rowNum,colNum,headers);
+
+ String filePath = fileName;
+ outPath =filePath;
+
+ }
+
+ public Row getRow(int rowNo){
+ Row row = sheet0.getRow(rowNo);
+ if(row==null){
+ row = sheet0.createRow(rowNo);
+ }
+ return row;
+ }
+
+ public Row getRow(XSSFSheet sheet,int rowNo){
+ Row row = sheet.getRow(rowNo);
+ if(row==null){
+ row = sheet.createRow(rowNo);
+ }
+ return row;
+ }
+
+
+
+ public void setRichValue(String location,String value,int start,int end){
+ Cell cell = get("A21");
+ System.out.println(cell.getStringCellValue());
+ Font font = excel.createFont();
+ font.setBold(true);
+ ((XSSFFont) font).setColor(new XSSFColor(new Color(0,0,0)));
+
+ XSSFRichTextString richTextString1 = new XSSFRichTextString(value);
+ richTextString1.applyFont(start,end,font);
+
+ cell.setCellValue(richTextString1);
+
+ }
+
+ public Cell getCell(Row row, int cNo){
+ Cell cell = row.getCell(cNo);
+ if(cell == null ) {
+ cell = row.createCell(cNo);
+ }
+ return cell;
+ }
+
+ public Cell getCell(int rowNo,int colNo){
+ Row row = getRow(rowNo);
+ return getCell(row,colNo);
+ }
+
+ public void setValue(String location,Object value){
+ Cell cell = get(location);
+ setCellValue(cell,value);
+ }
+
+ public void setValue(String location,Object value,String formula){
+ Cell cell = get(location);
+ cell.setCellValue(formula);
+ setCellValue(cell,value);
+
+ }
+
+ public void setFormula(String location,String formula){
+ Cell cell = get(location);
+ cell.setCellFormula(formula);
+ }
+
+ public Cell get(String location){
+ Pattern pattern = Pattern.compile("([A-Z]+)(\\d+)");
+ Matcher matcher = pattern.matcher(location.toUpperCase());
+ if(matcher.matches()){
+ String y = matcher.group(1);
+ String x = matcher.group(2);
+ int rowNum = coverToXIndex(x);
+ int colNum = covertToYIndex(y);
+ Row row = getRow(rowNum);
+ return getCell(row,colNum);
+
+ }
+ return null;
+ }
+
+ private int coverToXIndex(String x){
+ return Integer.parseInt(x)-1;
+ }
+
+ private int covertToYIndex(String y){
+ int result = 0;
+ for(int i = y.length()-1;i>=0;i--){
+ char c = y.charAt(i);
+ int power = ((y.length()-1)-i);
+
+ if(power>0){
+ result +=(c-'A'+1)*Math.pow(26,power);
+ }else{
+ result +=(c-'A');
+ }
+
+ }
+ return result;
+ }
+
+ public void appendDataToExcel(XSSFSheet sheet, java.util.List datas, int rowNo, int colNo, ExcelHeader[] headers){
+ if(sheet==null){
+ return;
+ }
+ try {
+ for(int r = 0;r field.getName().equals(header.name)).findFirst().orElse(null);
+ f.setAccessible(true);
+ Object v = f.get(t);
+ setCellValue(cell, v);
+ }
+ }else{
+ for(int c = 0;c= firstColumn && column <= lastColumn){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public String getMergedRegionValue(int row , int column){
+ int sheetMergeCount = sheet0.getNumMergedRegions();
+
+ for(int i = 0 ; i < sheetMergeCount ; i++){
+ CellRangeAddress ca = sheet0.getMergedRegion(i);
+ int firstColumn = ca.getFirstColumn();
+ int lastColumn = ca.getLastColumn();
+ int firstRow = ca.getFirstRow();
+ int lastRow = ca.getLastRow();
+
+ if(row >= firstRow && row <= lastRow){
+
+ if(column >= firstColumn && column <= lastColumn){
+ Row fRow = sheet0.getRow(firstRow);
+ Cell fCell = fRow.getCell(firstColumn);
+ return getCellValue(fCell) ;
+ }
+ }
+ }
+
+ return null ;
+ }
+
+
+ /**
+ * 获取单元格的值
+ * @param cell
+ * @return
+ */
+ public String getCellValue(Cell cell){
+
+
+ if(cell == null) {return "";}
+
+ if(cell.getCellType() == Cell.CELL_TYPE_STRING){
+
+ return cell.getStringCellValue();
+
+ }else if(cell.getCellType() == Cell.CELL_TYPE_BOOLEAN){
+
+ return String.valueOf(cell.getBooleanCellValue());
+
+ }else if(cell.getCellType() == Cell.CELL_TYPE_FORMULA){
+
+ return cell.getCellFormula() ;
+
+ }else if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC){
+ String dateTime = getDateTime(cell);
+ if(StringUtils.isEmpty(dateTime)){
+ return String.valueOf(cell.getNumericCellValue());
+ }
+ return dateTime;
+ }
+ return "";
+ }
+
+ private String getDateTime(Cell cell){
+
+ String result = "";
+ //1、判断是否是数值格式
+ if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC){
+ short format = cell.getCellStyle().getDataFormat();
+ SimpleDateFormat sdf = null;
+ if(format == 14 || format == 31 || format == 57 || format == 58){
+ //日期
+ sdf = new SimpleDateFormat("yyyy-MM-dd");
+ }else if (format == 20 || format == 32) {
+ //时间
+ sdf = new SimpleDateFormat("HH:mm");
+ }else if(format == 176){
+ sdf =new SimpleDateFormat("yyyy/MM/dd");
+ }else{
+ return "";
+ }
+ double value = cell.getNumericCellValue();
+ Date date = org.apache.poi.ss.usermodel.DateUtil.getJavaDate(value);
+ result = sdf.format(date);
+ }
+ return result;
+ }
+
+
+
+ public boolean save(){
+ if(WriteExcel(excel,outPath)){
+ excel = null;
+ return true;
+ }
+ return false;
+ }
+
+ private boolean WriteExcel(XSSFWorkbook workbook,String filePath){
+ try {
+ if(filePath==null) {return false;}
+ FileOutputStream outputStream = new FileOutputStream(filePath);
+
+ workbook.write(outputStream);
+ workbook.close();
+ outputStream.close();
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private void setCellValue(Cell cell , Object value){
+ cell.setCellStyle(cellStyle);
+ if(value instanceof String){
+ cell.setCellValue((String) value);
+ }else if(value instanceof Integer){
+ cell.setCellValue((Integer)value);
+ }else if(value instanceof Float){
+ cell.setCellValue((Float) value);
+ }else if(value instanceof Double){
+ cell.setCellValue((Double)value);
+ }else if(value instanceof BigDecimal){
+ BigDecimal tmp = ((BigDecimal) value).abs();
+ if(numStyle==null){
+ initNumStyle();
+ }
+ cell.setCellStyle(numStyle);
+ cell.setCellValue(tmp.doubleValue());
+ }
+ }
+
+ public class ExcelHeader{
+ String name;
+ String aliax;
+ ParserValue parserValue;
+
+ public ExcelHeader(String name,String aliax,ParserValue... pv){
+ this.name = name;
+ this.aliax = aliax;
+ if(pv!=null&&pv.length>0){
+ this.parserValue = pv[0];
+ }
+
+ }
+
+
+ /**
+ * 列名
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * 别名
+ * @return
+ */
+ public String getAliax() {
+ return aliax;
+ }
+
+ public void setAliax(String aliax) {
+ this.aliax = aliax;
+ }
+
+ /**
+ * 值解析
+ * @return
+ */
+ public ParserValue getParserValue() {
+ return parserValue;
+ }
+
+ public void setParserValue(ParserValue parserValue) {
+ this.parserValue = parserValue;
+ }
+ }
+
+ @FunctionalInterface
+ public interface ParserValue{
+ String parser(Object object);
+ }
+}
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/JWTUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/JWTUtil.java
index 5ecf0f0..dfa1532 100644
--- a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/JWTUtil.java
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/JWTUtil.java
@@ -14,8 +14,8 @@ import java.util.Date;
public class JWTUtil {
protected static final Logger logger = LoggerFactory.getLogger(JWTUtil.class);
- private static final String TOKEN_SECRET = "eyJhbGciOiJIUzI1NiJ9";
- private static final String ISSUER = "RONCOO";
+ private static final String TOKEN_SECRET = "ekfyJhciOiJfkIUzI1J9";
+ private static final String ISSUER = "TIANZE";
public static final String USERNO = "userNo";
public static final Long DATE = 30 * 24 * 3600 * 1000L; // 1个月
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/NOUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/NOUtil.java
new file mode 100644
index 0000000..cb92b70
--- /dev/null
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/NOUtil.java
@@ -0,0 +1,22 @@
+package com.tz.platform.common.core.tools;
+
+import cn.hutool.core.util.RandomUtil;
+
+import java.util.Date;
+
+public class NOUtil {
+ private NOUtil() {
+ }
+
+ public static Long getOrderNo() {
+ return Long.valueOf(DateUtil.format(new Date(), Constants.DATE.YYYYMMDDHHMMSS) + RandomUtil.randomNumbers(3));
+ }
+
+ public static Long getSerialNumber() {
+ return Long.valueOf(DateUtil.format(new Date(), Constants.DATE.YYYYMMDDHHMMSS) + RandomUtil.randomNumbers(4));
+ }
+
+ public static Long getUserNo() {
+ return Long.valueOf(DateUtil.format(new Date(), Constants.DATE.YYYYMMDDHHMMSS) + RandomUtil.randomNumbers(2));
+ }
+}
diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/StrUtil.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/StrUtil.java
new file mode 100644
index 0000000..fbbf895
--- /dev/null
+++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/tools/StrUtil.java
@@ -0,0 +1,34 @@
+package com.tz.platform.common.core.tools;
+
+import cn.hutool.core.util.IdUtil;
+
+import java.util.Random;
+
+public class StrUtil {
+ private StrUtil() {
+ }
+
+ public static String getSuffix(String fileName) {
+ return fileName.substring(fileName.lastIndexOf(".") + 1);
+ }
+
+ public static String getPrefix(String fileName) {
+ return fileName.substring(0, fileName.lastIndexOf("."));
+ }
+
+ /**
+ * @return
+ */
+ public static String getRandom(int bound) {
+ Random ra = new Random();
+ String result = "";
+ for (int i = 1; i <= bound; i++) {
+ result += ra.nextInt(10);
+ }
+ return result;
+ }
+
+ public static String get32UUID() {
+ return IdUtil.simpleUUID();
+ }
+}
diff --git a/tz/common/common-service/pom.xml b/tz/common/common-service/pom.xml
index 314f312..305f09f 100644
--- a/tz/common/common-service/pom.xml
+++ b/tz/common/common-service/pom.xml
@@ -55,6 +55,18 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
org.springframework.boot
spring-boot-devtools
diff --git a/tz/gateway/src/main/java/com/tz/platform/gateway/filter/TzGlobalFilter.java b/tz/gateway/src/main/java/com/tz/platform/gateway/filter/TzGlobalFilter.java
index 415468d..247ff1b 100644
--- a/tz/gateway/src/main/java/com/tz/platform/gateway/filter/TzGlobalFilter.java
+++ b/tz/gateway/src/main/java/com/tz/platform/gateway/filter/TzGlobalFilter.java
@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
public class TzGlobalFilter implements GlobalFilter {
private static final Logger logger = LoggerFactory.getLogger(TzGlobalFilter.class);
- private static final String TOKEN = "token";
+ private static final String TOKEN = "tz_token";
private static final String USERNO = "userNo";
@Autowired
@@ -93,11 +93,41 @@ public class TzGlobalFilter implements GlobalFilter {
return false;
}
+ private String getRemoteIp(ServerHttpRequest request){
+ HttpHeaders headers = request.getHeaders();
+ String ip = headers.getFirst("x-forwarded-for");
+ if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
+ // 多次反向代理后会有多个ip值,第一个ip才是真实ip
+ if (ip.indexOf(",") != -1) {
+ ip = ip.split(",")[0];
+ }
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = headers.getFirst("Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = headers.getFirst("WL-Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = headers.getFirst("HTTP_CLIENT_IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = headers.getFirst("HTTP_X_FORWARDED_FOR");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = headers.getFirst("X-Real-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddress().getAddress().getHostAddress();
+ }
+ return ip;
+ }
private Mono modifiedBody(ServerWebExchange serverWebExchange, Long userNo) {
MediaType mediaType = serverWebExchange.getRequest().getHeaders().getContentType();
ServerRequest serverRequest = ServerRequest.create(serverWebExchange, HandlerStrategies.withDefaults().messageReaders());
+// String ip = getRemoteIp(serverWebExchange.getRequest());
return serverRequest.bodyToMono(String.class).flatMap(body -> {
JSONObject bodyJson;
if (MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(mediaType)) {
@@ -109,6 +139,7 @@ public class TzGlobalFilter implements GlobalFilter {
if (ObjectUtil.isNotNull(userNo)) {
bodyJson.set(USERNO, userNo);
}
+// bodyJson.set("ip",ip);
return Mono.just(JSONUtil.toJsonStr(bodyJson));
});
}
diff --git a/tz/user/user-service/src/main/java/com/tz/platform/entity/Menu.java b/tz/user/user-service/src/main/java/com/tz/platform/entity/Menu.java
new file mode 100644
index 0000000..54de5dd
--- /dev/null
+++ b/tz/user/user-service/src/main/java/com/tz/platform/entity/Menu.java
@@ -0,0 +1,22 @@
+package com.tz.platform.entity;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+@Data
+public class Menu {
+ @Id
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
+ private Integer id;
+
+ private String title;
+
+ private String icon;
+
+ private Integer parentId;
+}
diff --git a/tz/user/user-service/src/main/java/com/tz/platform/entity/Province.java b/tz/user/user-service/src/main/java/com/tz/platform/entity/Province.java
new file mode 100644
index 0000000..ca22599
--- /dev/null
+++ b/tz/user/user-service/src/main/java/com/tz/platform/entity/Province.java
@@ -0,0 +1,18 @@
+package com.tz.platform.entity;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+@Data
+public class Province {
+ @Id
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
+ private Integer id;
+ private String name;
+ private Integer regionId;
+}
diff --git a/tz/user/user-service/src/main/java/com/tz/platform/entity/Region.java b/tz/user/user-service/src/main/java/com/tz/platform/entity/Region.java
new file mode 100644
index 0000000..95052ee
--- /dev/null
+++ b/tz/user/user-service/src/main/java/com/tz/platform/entity/Region.java
@@ -0,0 +1,18 @@
+package com.tz.platform.entity;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+@Entity
+@Data
+public class Region implements Serializable {
+ @Id
+ @GeneratedValue(strategy= GenerationType.IDENTITY)
+ private Integer id;
+ private String name;
+}
diff --git a/tz/user/user-service/src/main/java/com/tz/platform/entity/User.java b/tz/user/user-service/src/main/java/com/tz/platform/entity/User.java
index c066c7a..0450de7 100644
--- a/tz/user/user-service/src/main/java/com/tz/platform/entity/User.java
+++ b/tz/user/user-service/src/main/java/com/tz/platform/entity/User.java
@@ -1,11 +1,15 @@
package com.tz.platform.entity;
+import lombok.Data;
+
import javax.persistence.*;
+import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "user")
-public class User {
+@Data
+public class User implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@@ -21,81 +25,24 @@ public class User {
private String mobile;
- private String userName;
+ private String username;
private String studentNo;
- private String mobileSalt;
-
- private String mobilePsw;
-
-
- private static final long serialVersionUID = 1L;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Date getGmtCreate() {
- return gmtCreate;
- }
-
- public void setGmtCreate(Date gmtCreate) {
- this.gmtCreate = gmtCreate;
- }
-
- public Date getGmtModified() {
- return gmtModified;
- }
-
- public void setGmtModified(Date gmtModified) {
- this.gmtModified = gmtModified;
- }
-
- public Integer getStatusId() {
- return statusId;
- }
-
- public void setStatusId(Integer statusId) {
- this.statusId = statusId;
- }
-
- public Long getUserNo() {
- return userNo;
- }
-
- public void setUserNo(Long userNo) {
- this.userNo = userNo;
- }
+ private String school;
- public String getMobile() {
- return mobile;
- }
+ private String name;
- public void setMobile(String mobile) {
- this.mobile = mobile == null ? null : mobile.trim();
- }
+ private String mobileSalt;
- public String getMobileSalt() {
- return mobileSalt;
- }
+ private String mobilePsw;
- public void setMobileSalt(String mobileSalt) {
- this.mobileSalt = mobileSalt == null ? null : mobileSalt.trim();
- }
+ private Integer userType;
- public String getMobilePsw() {
- return mobilePsw;
- }
+ private String avatar;
- public void setMobilePsw(String mobilePsw) {
- this.mobilePsw = mobilePsw == null ? null : mobilePsw.trim();
- }
+ private static final long serialVersionUID = 1L;
@Override
public String toString() {
diff --git a/tz/user/user-service/src/main/java/com/tz/platform/repository/MenuDao.java b/tz/user/user-service/src/main/java/com/tz/platform/repository/MenuDao.java
new file mode 100644
index 0000000..2ff84e3
--- /dev/null
+++ b/tz/user/user-service/src/main/java/com/tz/platform/repository/MenuDao.java
@@ -0,0 +1,9 @@
+package com.tz.platform.repository;
+
+import com.tz.platform.entity.Menu;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MenuDao extends JpaRepository