getParam() {
+ return paramUpdateSet;
+ }
+
+ @Override
+ protected void renameByParamName() {
+
+ }
+}
diff --git a/common/src/main/java/com/qmrz/mybatis/sql/statement/WhereBlock.java b/common/src/main/java/com/qmrz/mybatis/sql/statement/WhereBlock.java
new file mode 100644
index 0000000..d9550d9
--- /dev/null
+++ b/common/src/main/java/com/qmrz/mybatis/sql/statement/WhereBlock.java
@@ -0,0 +1,18 @@
+package com.qmrz.mybatis.sql.statement;
+
+import com.qmrz.mybatis.sql.BaseWrapper;
+import com.qmrz.mybatis.sql.ConditionCount;
+
+/**
+ * sql: 无,只包装作用
+ */
+public class WhereBlock extends BaseWrapper {
+ /**
+ * @param isConditionAnd
+ * @param index 嵌套时,序号继承到新块
+ */
+ public WhereBlock(boolean isConditionAnd, ConditionCount index, Class> classPO) {
+ super(0, 0, isConditionAnd ? 1 : 2, classPO);
+ this.setConditionsCount(index);
+ }
+}
diff --git a/common/src/main/java/com/qmrz/utils/CacheUtil.java b/common/src/main/java/com/qmrz/utils/CacheUtil.java
new file mode 100644
index 0000000..aba448a
--- /dev/null
+++ b/common/src/main/java/com/qmrz/utils/CacheUtil.java
@@ -0,0 +1,27 @@
+package com.qmrz.utils;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+import java.io.Serializable;
+
+public class CacheUtil {
+ public static Cache getCache() {
+ CacheManager cacheManager = SpringContextUtil.getBean(CacheManager.class);
+ Cache cache = cacheManager.getCache("userCache");
+// CacheConfiguration config = cache.getCacheConfiguration();
+// config.setTimeToIdleSeconds(60);
+// config.setTimeToLiveSeconds(timeToLiveSeconds);
+ return cache;
+ }
+
+ public static Element get(String name) {
+ return getCache().get(name);
+ }
+
+ public static void put(String name, Serializable value, int timeToLive) {
+ Element el = new Element(name, value);
+ el.setTimeToLive(timeToLive);
+ getCache().put(el);
+ }
+}
diff --git a/common/src/main/java/com/qmrz/utils/ConvertUtil.java b/common/src/main/java/com/qmrz/utils/ConvertUtil.java
new file mode 100644
index 0000000..6fb3444
--- /dev/null
+++ b/common/src/main/java/com/qmrz/utils/ConvertUtil.java
@@ -0,0 +1,334 @@
+package com.qmrz.utils;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+
+import java.io.*;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * 功能:转换编码
+ *
+ * @author xiongliang
+ *
+ * mobile enterprise application platform
+ * Version 0.1
+ */
+public class ConvertUtil {
+ public static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
+ /**
+ * 7位ASCII字符,也叫作ISO646-US、Unicode字符集的基本拉丁块
+ */
+ public static final String US_ASCII = "US-ASCII";
+ /**
+ * ISO 拉丁字母表 No.1,也叫作 ISO-LATIN-1
+ */
+ public static final String ISO_8859_1 = "ISO-8859-1";
+ /**
+ * 8 位 UCS 转换格式
+ */
+ public static final String UTF_8 = "UTF-8";
+ /**
+ * 16 位 UCS 转换格式,Big Endian(最低地址存放高位字节)字节顺序
+ */
+ public static final String UTF_16BE = "UTF-16BE";
+ /**
+ * 16 位 UCS 转换格式,Little-endian(最高地址存放低位字节)字节顺序
+ */
+ public static final String UTF_16LE = "UTF-16LE";
+ /**
+ * 16 位 UCS 转换格式,字节顺序由可选的字节顺序标记来标识
+ */
+ public static final String UTF_16 = "UTF-16";
+ /**
+ * 中文超大字符集
+ */
+ public static final String GBK = "GBK";
+ /**
+ * 繁体中文
+ */
+ public static final String BIG_5 = "BIG5";
+
+ /**
+ * 是否是null
+ *
+ * @param term
+ * @return
+ */
+ public static boolean isNull(String term) {
+ return !isNotNull(term);
+ }
+
+ /**
+ * 是否是非null
+ *
+ * @param term
+ * @return
+ */
+ public static boolean isNotNull(String term) {
+ if (term == null) return false;
+ if (term.trim().length() < 1) return false;
+ return true;
+ }
+
+ /**
+ * 字符串编码转换的实现方法
+ *
+ * @param strIn
+ * @param sourceCharset
+ * @param targetCharset
+ * @return
+ */
+ public static String convertCharset(String strIn, String sourceCharset, String targetCharset) {
+ if (isNull(strIn))
+ return strIn;
+ String strOut = null;
+ try {
+ byte[] c = strIn.getBytes(sourceCharset);
+ strOut = new String(c, targetCharset);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return strOut;
+ }
+
+ /**
+ * 获得UTF8编码的字符串
+ *
+ * @param gbkStr
+ * @return
+ */
+ public static String convertGbkToUft8(String gbkStr) {
+ try {
+ return new String(convertGbkToUtf8Bytes(gbkStr), UTF_8);
+ } catch (UnsupportedEncodingException e) {
+ throw new InternalError();
+ }
+ }
+ /**
+ * GBK转UTF-8编码
+ * @param text
+ * @return
+ */
+ /*public static String convertGbkToUft8(String text){
+ String utf = null;
+ try {
+ String iso = new String(text.getBytes(UTF_8),ISO_8859_1);
+ utf = new String(iso.getBytes(ISO_8859_1),UTF_8);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return utf;
+ }*/
+
+ /**
+ * 获得UTF8编码的字节数组
+ *
+ * @param gbkStr
+ * @return
+ */
+ public static byte[] convertGbkToUtf8Bytes(String gbkStr) {
+ int n = gbkStr.length();
+ byte[] utfBytes = new byte[3 * n];
+ int k = 0;
+ for (int i = 0; i < n; i++) {
+ int m = gbkStr.charAt(i);
+ if (m < 128 && m >= 0) {
+ utfBytes[k++] = (byte) m;
+ continue;
+ }
+ utfBytes[k++] = (byte) (0xe0 | (m >> 12));
+ utfBytes[k++] = (byte) (0x80 | ((m >> 6) & 0x3f));
+ utfBytes[k++] = (byte) (0x80 | (m & 0x3f));
+ }
+ if (k < utfBytes.length) {
+ byte[] tmp = new byte[k];
+ System.arraycopy(utfBytes, 0, tmp, 0, k);
+ return tmp;
+ }
+ return utfBytes;
+ }
+
+ /**
+ * 输入流转字符串
+ *
+ * @param is
+ * @return
+ */
+ public static String convertStreamToString(InputStream is) {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + LINE_SEPARATOR);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * 半角转换成全角
+ *
+ * @param input
+ * @return
+ */
+ public static String convertSBC(String input) {
+ // 半角转全角
+ char[] c = input.toCharArray();
+ for (int i = 0; i < c.length; i++) {
+ if (c[i] == 32) {
+ c[i] = (char) 12288;
+ continue;
+ }
+ if (c[i] < 127)
+ c[i] = (char) (c[i] + 65248);
+ }
+ return new String(c);
+ }
+
+ /**
+ * 全角转换成半角
+ *
+ * @param input
+ * @return
+ */
+ public static String convertDBC(String input) {
+ // 全角转 半角
+ char[] c = input.toCharArray();
+ for (int i = 0; i < c.length; i++) {
+ if (c[i] == 12288) {
+ c[i] = (char) 32;
+ continue;
+ }
+ if (c[i] > 65280 && c[i] < 65375)
+ c[i] = (char) (c[i] - 65248);
+ }
+ return new String(c);
+ }
+
+ /**
+ * Hex编码.
+ */
+ public static String convertEncodeHex(byte[] input) {
+ return Hex.encodeHexString(input);
+ }
+
+ /**
+ * Hex解码.
+ */
+ public static byte[] convertDecodeHex(String input) {
+ try {
+ return Hex.decodeHex(input.toCharArray());
+ } catch (DecoderException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Base64编码.
+ */
+ public static String convertEncodeBase64(byte[] input) {
+ return Base64.encodeBase64String(input);
+ }
+
+ /**
+ * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548).
+ */
+ public static String convertEncodeUrlSafeBase64(byte[] input) {
+ return Base64.encodeBase64URLSafeString(input);
+ }
+
+ /**
+ * Base64解码.
+ */
+ public static byte[] convertDecodeBase64(String input) {
+ return Base64.decodeBase64(input);
+ }
+
+ /**
+ * Base62编码。
+ */
+ public static String convertEncodeBase62(byte[] input) {
+ char[] chars = new char[input.length];
+ for (int i = 0; i < input.length; i++) {
+ chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)];
+ }
+ return new String(chars);
+ }
+
+ /**
+ * 输入或读取数据库之前的转换
+ * @param src
+ * @return
+ */
+ public static String toReadStr(Object src) {
+ String s = ""; //$NON-NLS-1$
+ if (src != null) {
+ // 读字符编码转换
+ s = src.toString().trim();
+ s = s.replaceAll("<", "<"); //$NON-NLS-1$ //$NON-NLS-2$
+ s = s.replaceAll(">", ">"); //$NON-NLS-1$ //$NON-NLS-2$
+ s = s.replaceAll("\"", "“"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return s;
+ }
+ /**
+ * 字符串转换成整形
+ * @param src
+ * @return
+ */
+ public static Integer toInteger(Object src) {
+ String s = toReadStr(src);
+ Integer i = 0;
+ if (!"".equals(s)) { //$NON-NLS-1$
+ try {
+ i = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ i = 0;
+ }
+ }
+ return i;
+ }
+ public static boolean isEmpty(Object pObj) {
+ if (pObj == null)
+ return true;
+ if (pObj.equals(""))
+ return true;
+ if (pObj instanceof String) {
+ if (((String) pObj).length() == 0) {
+ return true;
+ }
+ } else if (pObj instanceof Collection) {
+ if (((Collection) pObj).size() == 0) {
+ return true;
+ }
+ } else if (pObj instanceof Map) {
+ if (((Map) pObj).size() == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isEmptyError(Map map,final String... headers) {
+ for (int i = 0; i < headers.length; i++) {
+ if (isEmpty(map.get(headers[i]))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/common/src/main/java/com/qmrz/utils/DBHelper.java b/common/src/main/java/com/qmrz/utils/DBHelper.java
new file mode 100644
index 0000000..d60b598
--- /dev/null
+++ b/common/src/main/java/com/qmrz/utils/DBHelper.java
@@ -0,0 +1,184 @@
+package com.qmrz.utils;
+
+import org.apache.ibatis.cursor.Cursor;
+import org.apache.ibatis.executor.BatchResult;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.ResultHandler;
+import org.apache.ibatis.session.RowBounds;
+import org.apache.ibatis.session.SqlSession;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.sql.Connection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 基于mybatis的数据库操作类,无需mapper接口,直接调用xml的sql
+ */
+@Component
+public class DBHelper implements SqlSession {
+ SqlSessionTemplate sql;
+ private static final String statementPrefix = "com.qmrz.domain.mapper.";
+
+ public String getStatement(String id) {
+ return statementPrefix + id;
+ }
+
+ @Autowired
+ public DBHelper(SqlSessionTemplate sqlSessionTemplate) {
+ this.sql = sqlSessionTemplate;
+ }
+
+ @Override
+ public T selectOne(String statement) {
+ return sql.selectOne(getStatement(statement));
+ }
+
+ @Override
+ public T selectOne(String statement, Object parameter) {
+ return sql.selectOne(getStatement(statement), parameter);
+ }
+
+ @Override
+ public List selectList(String statement) {
+ return sql.selectList(getStatement(statement));
+ }
+
+ @Override
+ public List selectList(String statement, Object parameter) {
+ return sql.selectList(getStatement(statement), parameter);
+ }
+
+ @Override
+ public List selectList(String statement, Object parameter, RowBounds rowBounds) {
+ return sql.selectList(getStatement(statement), parameter, rowBounds);
+ }
+
+ @Override
+ public Map selectMap(String statement, String mapKey) {
+ return sql.selectMap(getStatement(statement), mapKey);
+ }
+
+ @Override
+ public Map selectMap(String statement, Object parameter, String mapKey) {
+ return sql.selectMap(getStatement(statement), parameter, mapKey);
+ }
+
+ @Override
+ public Map selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) {
+ return sql.selectMap(getStatement(statement), parameter, mapKey, rowBounds);
+ }
+
+ @Override
+ public Cursor selectCursor(String statement) {
+ return sql.selectCursor(getStatement(statement));
+ }
+
+ @Override
+ public Cursor selectCursor(String statement, Object parameter) {
+ return sql.selectCursor(getStatement(statement), parameter);
+ }
+
+ @Override
+ public Cursor selectCursor(String statement, Object parameter, RowBounds rowBounds) {
+ return sql.selectCursor(getStatement(statement), parameter, rowBounds);
+ }
+
+ @Override
+ public void select(String statement, Object parameter, ResultHandler handler) {
+ sql.select(getStatement(statement), parameter, handler);
+ }
+
+ @Override
+ public void select(String statement, ResultHandler handler) {
+ sql.select(getStatement(statement), handler);
+ }
+
+ @Override
+ public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
+ sql.select(getStatement(statement), parameter, rowBounds, handler);
+ }
+
+ @Override
+ public int insert(String statement) {
+ return sql.insert(getStatement(statement));
+ }
+
+ @Override
+ public int insert(String statement, Object parameter) {
+ return sql.insert(getStatement(statement), parameter);
+ }
+
+ @Override
+ public int update(String statement) {
+ return sql.update(getStatement(statement));
+ }
+
+ @Override
+ public int update(String statement, Object parameter) {
+ return sql.update(getStatement(statement), parameter);
+ }
+
+ @Override
+ public int delete(String statement) {
+ return sql.delete(getStatement(statement));
+ }
+
+ @Override
+ public int delete(String statement, Object parameter) {
+ return sql.delete(getStatement(statement), parameter);
+ }
+
+ @Override
+ public void commit() {
+ sql.commit();
+ }
+
+ @Override
+ public void commit(boolean force) {
+ sql.commit(force);
+ }
+
+ @Override
+ public void rollback() {
+ sql.rollback();
+ }
+
+ @Override
+ public void rollback(boolean force) {
+ sql.rollback(force);
+ }
+
+ @Override
+ public List flushStatements() {
+ return sql.flushStatements();
+ }
+
+ @Override
+ public void close() {
+ sql.close();
+ }
+
+ @Override
+ public void clearCache() {
+ sql.clearCache();
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return sql.getConfiguration();
+ }
+
+ @Override
+ public T getMapper(Class type) {
+ return sql.getMapper(type);
+ }
+
+ @Override
+ public Connection getConnection() {
+ return sql.getConnection();
+ }
+
+}
diff --git a/common/src/main/java/com/qmrz/utils/DateTimeUtil.java b/common/src/main/java/com/qmrz/utils/DateTimeUtil.java
new file mode 100644
index 0000000..94a0b12
--- /dev/null
+++ b/common/src/main/java/com/qmrz/utils/DateTimeUtil.java
@@ -0,0 +1,145 @@
+package com.qmrz.utils;
+
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAccessor;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class DateTimeUtil {
+ private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ private static final DateTimeFormatter dtfDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ private static ThreadLocal ThreadDateTime = new ThreadLocal();
+
+ //日期时间类型格式
+ private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+ private static final DateTimeFormatter dtfGMT = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
+ .withZone(TimeZone.getTimeZone("GMT").toZoneId());
+
+ public static String format(TemporalAccessor dateTime) {
+ return dtf.format(dateTime);
+ }
+
+ public static String format(TemporalAccessor dateTime, String format) {
+ return DateTimeFormatter.ofPattern(format).format(dateTime);
+ }
+
+ public static String formatDate(TemporalAccessor dateTime) {
+ return dtfDate.format(dateTime);
+ }
+
+ public static String datePlus(String date,int days){
+ //结束日期需要加一天,api同步时不包含结束日期
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ LocalDateTime local = LocalDateTime.from(dtf.parse(date+" 00:00:00")).plusDays(days);
+ return formatDate(local);
+ }
+
+// public static String formatBySecond(long second) {
+// return dtf.format(LocalDateTime.ofEpochSecond(second, 0, ZoneOffset.ofHours(8)));
+// }
+//
+// public static String formatDataBySecond(long second) {
+// return dtfDate.format(LocalDateTime.ofEpochSecond(second, 0, ZoneOffset.ofHours(8)));
+// }
+
+ public static String formatGMTBySecond(long second) {
+ return dtfGMT.format(LocalDateTime.ofEpochSecond(second, 0
+ , ZoneOffset.ofHours(0)));
+ }
+
+ /**
+ * 获取当前日期 毫秒
+ *
+ * @return
+ */
+ public static long getTimeInMillis() {
+ Calendar now = Calendar.getInstance();
+
+ return now.getTimeInMillis();
+ }
+
+ /**
+ * 时间字符串 解析为 时间戳(毫秒)
+ *
+ * @param time 时间,如:2018-08-06 04:52:50 127
+ * @param format 时间格式,如:yyyy-MM-dd HH:mm:ss SSS
+ * @param zone 时区,如:ZoneOffset.ofHours(8)
+ * @return
+ */
+ public static Long getTimeInMillis(String time, String format, ZoneOffset zone) {
+ Instant instant = getInstant(time, format, zone);
+ return instant.toEpochMilli();
+ }
+
+ /**
+ * 获取当前日期 秒
+ *
+ * @return
+ */
+ public static long getTimeInSeconds() {
+ return getTimeInMillis() / 1000L;
+ }
+
+ /**
+ * 时间字符串 解析为 时间戳(秒)
+ *
+ * @param time 时间,如:2018-08-06 04:52:50 127
+ * @param format 时间格式,如:yyyy-MM-dd HH:mm:ss SSS
+ * @param zone 时区,如:ZoneOffset.ofHours(8)
+ * @return
+ */
+ public static Long getTimeInSeconds(String time, String format, ZoneOffset zone) {
+ Instant instant = getInstant(time, format, zone);
+ return instant.getEpochSecond();
+ }
+
+ /**
+ * 时间字符串 解析为 时刻对象
+ *
+ * @param time
+ * @param format
+ * @param zone
+ * @return
+ */
+ public static Instant getInstant(String time, String format, ZoneOffset zone) {
+ DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
+ Instant instant = LocalDateTime.parse(time, df).atZone(zone).toInstant();
+ return instant;
+ }
+
+ /**
+ * 获取时刻 时间戳 转 时刻
+ *
+ * @param timestamp
+ * @return
+ */
+ public static Instant getInstant(long timestamp) {
+ return Instant.ofEpochSecond(timestamp);
+ }
+
+ /**
+ * 获取当前日期时间
+ *
+ * @return 返回当前时间的字符串值
+ */
+ public static String currentDateTime() {
+ return DateTimeInstance().format(new Date());
+ }
+
+ private static SimpleDateFormat DateTimeInstance() {
+ SimpleDateFormat df = ThreadDateTime.get();
+ if (df == null) {
+ df = new SimpleDateFormat(DATETIME_FORMAT);
+ ThreadDateTime.set(df);
+ }
+ return df;
+ }
+
+}
diff --git a/common/src/main/java/com/qmrz/utils/ExportPOIUtils.java b/common/src/main/java/com/qmrz/utils/ExportPOIUtils.java
new file mode 100644
index 0000000..4c0b2ad
--- /dev/null
+++ b/common/src/main/java/com/qmrz/utils/ExportPOIUtils.java
@@ -0,0 +1,191 @@
+package com.qmrz.utils;
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.imageio.ImageIO;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.ibatis.reflection.MetaObject;
+import org.apache.ibatis.reflection.SystemMetaObject;
+import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
+import org.apache.poi.hssf.usermodel.HSSFPatriarch;
+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.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+
+
+public class ExportPOIUtils {
+ //参数说明: fileName:文件名 projects:对象集合 columnNames: 列名 keys: map中的key
+ public static void start_download(HttpServletResponse response, String fileName, List> projects,
+ String[] columnNames, String[] keys) throws IOException {
+
+ //将集合中对象的属性 对应到 List