陈士柏 пре 2 година
родитељ
комит
f8a4e0b475

+ 165 - 0
src/main/java/com/template/common/utils/AesUtil.java

@@ -0,0 +1,165 @@
+package com.template.common.utils;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
+
+/**
+ * <p>Title: AesUtil</p>
+ * <p>Description: AES加密解密</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class AesUtil {
+
+	/**
+	 * 秘钥
+	 */
+	public static final String PASSWORD_SECRET_KEY = "EasyRailEveryday";
+	
+	/**
+	 * 初始向量
+	 */
+	public static final String INITIAL_VECTOR = "EasyRailEasyRail";
+	
+    /**
+     * 加密
+     * @param content 需要加密的内容
+     * @param password  加密密码
+     * @param keySize 密钥长度16,24,32(密码长度为24和32时需要将local_policy.jar/US_export_policy.jar两个jar包放到JRE目录%jre%/lib/security下)
+     * @return
+     */
+    public static byte[] encrypt(String content, String password, int keySize){
+    	try {                              
+        	//密钥长度不够用0补齐。
+    		SecretKeySpec key = new SecretKeySpec(ZeroPadding(password.getBytes(Base64Util.DEFAULT_CHARSET), keySize), "AES");
+    		//定义加密算法AES、算法模式ECB、补码方式PKCS5Padding
+            //Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+    		//定义加密算法AES 算法模式CBC、补码方式PKCS5Padding
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            //CBC模式模式下初始向量 不足16位用0补齐
+            IvParameterSpec iv = new IvParameterSpec(ZeroPadding(INITIAL_VECTOR.getBytes(Base64Util.DEFAULT_CHARSET),16));
+            byte[] byteContent = content.getBytes();  
+            //初始化加密
+            //ECB
+            //cipher.init(Cipher.ENCRYPT_MODE, key);
+            //CBC 
+			cipher.init(Cipher.ENCRYPT_MODE, key,iv);
+            byte[] result = cipher.doFinal(byteContent);
+            return result; 
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } catch (NoSuchPaddingException e) {
+            e.printStackTrace();
+        } catch (InvalidKeyException e) {
+            e.printStackTrace();
+        } catch (IllegalBlockSizeException e) {
+            e.printStackTrace();
+        } catch (BadPaddingException e) {
+            e.printStackTrace();
+        } catch (InvalidAlgorithmParameterException e) {
+        	e.printStackTrace();
+        } catch (Exception e) {
+        	e.printStackTrace();
+        }
+        return null;
+    }
+    
+    /**解密
+     * @param content  待解密内容
+     * @param password 解密密钥
+     * @param keySize 密钥长度16,24,32(密码长度为24和32时需要将local_policy.jar/US_export_policy.jar两个jar包放到JRE目录%jre%/lib/security下)
+     * @return
+     */
+    public static String decrypt(byte[] content, String password, int keySize) {
+        try { 
+        	//密钥长度不够用0补齐。
+    		SecretKeySpec key = new SecretKeySpec(ZeroPadding(password.getBytes(), keySize), "AES");
+    		//定义加密算法AES、算法模式ECB、补码方式PKCS5Padding
+            //Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+    		//定义加密算法AES 算法模式CBC、补码方式PKCS5Padding
+            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+            //CBC模式模式下初始向量 不足16位用0补齐
+            IvParameterSpec iv = new IvParameterSpec(ZeroPadding(INITIAL_VECTOR.getBytes(Base64Util.DEFAULT_CHARSET),16));
+            // 初始化解密
+            //ECB
+            //cipher.init(Cipher.DECRYPT_MODE, key);
+            //CBC
+            cipher.init(Cipher.DECRYPT_MODE, key,iv);
+            byte[] result = cipher.doFinal(content);
+            return new String(result,Base64Util.DEFAULT_CHARSET); 
+        } catch (NoSuchAlgorithmException e) {
+        	e.printStackTrace();
+        } catch (NoSuchPaddingException e) {
+        	e.printStackTrace();
+        } catch (InvalidKeyException e) {
+        	e.printStackTrace();
+        } catch (IllegalBlockSizeException e) {
+        	e.printStackTrace();
+        } catch (BadPaddingException e) {
+        	e.printStackTrace();
+        } catch (InvalidAlgorithmParameterException e){
+        	e.printStackTrace();
+        } catch (Exception e){
+        	e.printStackTrace();
+        }
+        return null;
+    }
+    
+    /**将二进制转换成16进制
+     * @param buf
+     * @return
+     */
+    public static String parseByte2HexStr(byte buf[]) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < buf.length; i++) {
+            String hex = Integer.toHexString(buf[i] & 0xFF);
+            if (hex.length() == 1) {
+                    hex = '0' + hex;
+            }
+            sb.append(hex.toUpperCase());
+        }
+        return sb.toString();
+    }
+    
+    /**将16进制转换为二进制
+     * @param hexStr
+     * @return
+     */
+    public static byte[] parseHexStr2Byte(String hexStr) {
+        if (hexStr.length() < 1){
+        	return null;
+        }
+        byte[] result = new byte[hexStr.length()/2];
+        for (int i = 0;i< hexStr.length()/2; i++) {
+            int high = Integer.parseInt(hexStr.substring(i*2, i*2+1), 16);
+            int low = Integer.parseInt(hexStr.substring(i*2+1, i*2+2), 16);
+            result[i] = (byte) (high * 16 + low);
+        }
+        return result;
+    }
+    
+    /**
+     * 字符达不到指定长度补0
+     * @param in 字符数组
+     * @param blockSize 长度
+     * @return
+     */
+    public static byte[] ZeroPadding(byte[] in,Integer blockSize){
+    	Integer copyLen = in.length;
+    	if (copyLen > blockSize) {
+			copyLen = blockSize;
+		}
+    	byte[] out = new byte[blockSize];
+    	System.arraycopy(in, 0, out, 0, copyLen);
+    	return out;
+    }
+
+}

+ 47 - 0
src/main/java/com/template/common/utils/Base64Util.java

@@ -0,0 +1,47 @@
+package com.template.common.utils;
+
+import org.apache.tomcat.util.codec.binary.Base64;
+
+import java.nio.charset.Charset;
+
+/**
+ * <p>Title: Base64Util</p>
+ * <p>Description: Base64Util工具类 --- 加密和解密</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class Base64Util {
+	
+	public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+	/**
+     * 解密
+     * @param str
+     * @return
+     */
+    public static String decodeStr(String str){
+        if (str == null) {
+			return null;
+		}
+		if (str.length() == 0) {
+			return "";
+		}
+		return new String(Base64.decodeBase64(new String(str).getBytes(DEFAULT_CHARSET)),DEFAULT_CHARSET).trim();
+    }
+
+    /**
+     * 加密
+     * 
+     * @param str
+     * @return
+     */
+    public static String encodeStr(String str){
+        if (str == null) {
+			return null;
+		}
+		if (str.length() == 0) {
+			return "";
+		}
+        return new String(Base64.encodeBase64Chunked(str.getBytes(DEFAULT_CHARSET)),DEFAULT_CHARSET).trim();
+    }
+
+}

+ 9 - 0
src/main/java/com/template/common/utils/DataBliu.java

@@ -0,0 +1,9 @@
+package com.template.common.utils;
+
+public class DataBliu {
+
+    public static double getTwo(double d1){
+        return (double) Math.round(d1 * 100) / 100;
+    }
+
+}

+ 241 - 0
src/main/java/com/template/common/utils/DateUtils.java

@@ -0,0 +1,241 @@
+package com.template.common.utils;
+
+import org.springframework.stereotype.Component;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ * <p>Title: DateUtils</p>
+ * <p>Description:日期工具类 </p>
+ * 
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+@Component // 加此注解是把此类实例化spring容器中
+public class DateUtils {
+
+	/**
+	 * 默认日期格式
+	 */
+	public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+	/**
+	 * 如2018 0901 232211(年月日时分秒)
+	 * 
+	 * @return
+	 */
+	public String yyyyMMddHHmmss() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如20180901
+	 * 
+	 * @return
+	 */
+	public static String getYYYYMMdd() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如180901
+	 * @return
+	 */
+	public String getYYMMdd() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如201809
+	 * @return
+	 */
+	public String getYYYYMM() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryEndDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryStartDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -30);
+		return sdf.format(cal.getTime());
+	}
+
+	/**
+	 * 如 2018/02/11 12:30:00
+	 * @return
+	 */
+	public static String getQueryEndTime() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		return sdf.format(Calendar.getInstance().getTime());
+	}
+
+	/**
+	 * 如 2018/02/11
+	 * @return
+	 */
+	public String getQueryStartTime() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -30);
+		return sdf.format(cal.getTime());
+	}
+
+	public String getQueryTwoAgoDate() {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Calendar cal = Calendar.getInstance();
+		cal.add(Calendar.DAY_OF_YEAR, -2);
+		return sdf.format(cal.getTime());
+	}
+
+	/**
+	 * 字符串转换成日期
+	 * 
+	 * @param str 字符串
+	 * @param format 日期格式
+	 * @return 日期
+	 */
+	public static Date str2Date(String str, String format) {
+		if (null == str || "".equals(str)) {
+			return null;
+		}
+		// 如果没有指定字符串转换的格式,则用默认格式进行转换
+		if (null == format || "".equals(format)) {
+			format = DEFAULT_FORMAT;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		Date date = null;
+		try {
+			date = sdf.parse(str);
+			return date;
+		} catch (ParseException e) {
+		}
+		return null;
+	}
+
+	/**
+	 * @param date 日期
+	 * @param format 日期格式
+	 * @return 字符串
+	 */
+	public static String date2Str(Date date, String format) {
+		if (null == date) {
+			return null;
+		}
+		SimpleDateFormat sdf = new SimpleDateFormat(format);
+		return sdf.format(date);
+	}
+
+	/**
+	 * 时间戳转换为字符串
+	 * @param time
+	 * @return
+	 */
+	public static String timestamp2Str(Timestamp time) {
+		Date date = new Date(time.getTime());
+		return date2Str(date, DEFAULT_FORMAT);
+	}
+
+	/**
+	 * 字符串转换为时间
+	 * @param str
+	 * @return
+	 */
+	public static Timestamp str2Timestamp(String str) {
+		Date date = str2Date(str, DEFAULT_FORMAT);
+		return new Timestamp(date.getTime());
+	}
+
+	/**
+	 * 字符串转换为时间
+	 * @param str
+	 * @return
+	 */
+	public static Timestamp str2Timestamp(String str, String formatStr) {
+		if (null == str) {
+			return null;
+		}
+		Date date = str2Date(str, formatStr);
+		return new Timestamp(date.getTime());
+	}
+
+	/**
+	 * 获取某年第一天日期
+	 * @param year 年份
+	 * @return Date
+	 */
+	public static Date getYearFirst(int year) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.clear();
+		calendar.set(Calendar.YEAR, year);
+		Date currYearFirst = calendar.getTime();
+		return currYearFirst;
+	}
+
+	/**
+	 * 获取某年最后一天日期
+	 * @param year  年份
+	 * @return Date
+	 */
+	public static Date getYearLast(int year) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.clear();
+		calendar.set(Calendar.YEAR, year);
+		calendar.roll(Calendar.DAY_OF_YEAR, -1);
+		Date currYearLast = calendar.getTime();
+
+		return currYearLast;
+	}
+
+	@SuppressWarnings("static-access")
+	public static Date getnextLast(String datetime, int year) {
+		Calendar calendar = new GregorianCalendar();
+		Date date = null;
+		if (datetime.length() > 7) {
+			date = str2Date(datetime, "yyyy-MM-dd");
+		} else {
+			date = str2Date(datetime, "yyyy-MM");
+		}
+		calendar.setTime(date);
+		calendar.add(calendar.YEAR, year);// 把日期往后增加一年.整数往后推,负数往前移动
+		date = calendar.getTime();
+		return date;
+
+	}
+
+	public static String getrightDate(String datetime, int year) {
+		String date = "";
+		String years = datetime.substring(0, 4);
+		String dates = datetime.substring(4, datetime.length());
+		Integer s = new Integer(years) + year;
+		date = s + dates;
+		return date;
+	}
+
+	public static void main(String[] args) {
+		System.out.println(getrightDate("2018-09", 4));
+		System.out.println(date2Str(getnextLast("2018-09", 4), "yyyy-MM"));
+	}
+
+}

+ 241 - 0
src/main/java/com/template/common/utils/HttpClientUtils.java

@@ -0,0 +1,241 @@
+package com.template.common.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.util.PublicSuffixMatcher;
+import org.apache.http.conn.util.PublicSuffixMatcherLoader;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>Title: HttpClientUtils</p>
+ * <p>Description: httpClient 工具类</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class HttpClientUtils {
+	
+	/**
+	 * 默认参数设置
+	 * setConnectTimeout:设置连接超时时间,单位毫秒。
+	 * setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒。
+	 * setSocketTimeout:请求获取数据的超时时间,单位毫秒。访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 暂时定义15分钟
+	 */
+	private RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(600000).setConnectTimeout(600000).setConnectionRequestTimeout(600000).build();
+	
+	/**
+	 * 静态内部类---作用:单例产生类的实例
+	 * @author Administrator
+	 *
+	 */
+	private static class LazyHolder {    
+       private static final HttpClientUtils INSTANCE = new HttpClientUtils();    
+       
+    }  
+	private HttpClientUtils(){}
+	public static HttpClientUtils getInstance(){
+		return LazyHolder.INSTANCE;    
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 */
+	public String sendHttpPost(String httpUrl) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 * @param params 参数(格式:key1=value1&key2=value2)
+	 */
+	public String sendHttpPost(String httpUrl, String params) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		try {
+			//设置参数
+			StringEntity stringEntity = new StringEntity(params, "UTF-8");
+			stringEntity.setContentType("application/x-www-form-urlencoded");
+			httpPost.setEntity(stringEntity);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送 post请求
+	 * @param httpUrl 地址
+	 * @param maps 参数
+	 */
+	public String sendHttpPost(String httpUrl, Map<String, String> maps) {
+		HttpPost httpPost = new HttpPost(httpUrl);// 创建httpPost  
+		// 创建参数队列  
+		List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+		for (String key : maps.keySet()) {
+			nameValuePairs.add(new BasicNameValuePair(key, maps.get(key)));
+		}
+		try {
+			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sendHttpPost(httpPost);
+	}
+	
+	/**
+	 * 发送Post请求
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpPost(HttpPost httpPost) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例
+			httpClient = HttpClients.createDefault();
+			httpPost.setConfig(requestConfig);
+			// 执行请求
+			long execStart = System.currentTimeMillis();
+			response = httpClient.execute(httpPost);
+			long execEnd = System.currentTimeMillis();
+			System.out.println("=================执行post请求耗时:"+(execEnd-execStart)+"ms");
+			long getStart = System.currentTimeMillis();
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+			long getEnd = System.currentTimeMillis();
+			System.out.println("=================获取响应结果耗时:"+(getEnd-getStart)+"ms");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+
+	/**
+	 * 发送 get请求
+	 * @param httpUrl
+	 */
+	public String sendHttpGet(String httpUrl) {
+		HttpGet httpGet = new HttpGet(httpUrl);// 创建get请求
+		return sendHttpGet(httpGet);
+	}
+	
+	/**
+	 * 发送 get请求Https
+	 * @param httpUrl
+	 */
+	public String sendHttpsGet(String httpUrl) {
+		HttpGet httpGet = new HttpGet(httpUrl);// 创建get请求
+		return sendHttpsGet(httpGet);
+	}
+	
+	/**
+	 * 发送Get请求
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpGet(HttpGet httpGet) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例.
+
+			
+			httpClient = HttpClients.createDefault();
+
+			httpGet.setConfig(requestConfig);
+			// 执行请求
+			response = httpClient.execute(httpGet);
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+	
+	/**
+	 * 发送Get请求Https
+	 * @param httpPost
+	 * @return
+	 */
+	private String sendHttpsGet(HttpGet httpGet) {
+		CloseableHttpClient httpClient = null;
+		CloseableHttpResponse response = null;
+		HttpEntity entity = null;
+		String responseContent = null;
+		try {
+			// 创建默认的httpClient实例.
+			PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new URL(httpGet.getURI().toString()));
+			DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher);
+			httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build();
+			httpGet.setConfig(requestConfig);
+			// 执行请求
+			response = httpClient.execute(httpGet);
+			entity = response.getEntity();
+			responseContent = EntityUtils.toString(entity, "UTF-8");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				// 关闭连接,释放资源
+				if (response != null) {
+					response.close();
+				}
+				if (httpClient != null) {
+					httpClient.close();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return responseContent;
+	}
+	
+	
+	
+}

+ 99 - 0
src/main/java/com/template/common/utils/PropertiesUtil.java

@@ -0,0 +1,99 @@
+package com.template.common.utils;
+
+import java.io.*;
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * <p>Title: PropertiesUtil</p>
+ * <p>Description: properties资源文件解析工具</p>
+ * @author fengyong
+ * @date 2018年9月7日
+ */
+public class PropertiesUtil {
+
+	private static Properties props = null;
+	private static URI uri;
+	private static String fileName = "/application.properties";
+	
+	private static InputStream in = null;
+
+	static {
+		try {
+			props = new Properties();
+			InputStream fis = PropertiesUtil.class.getResourceAsStream(fileName);
+			props.load(fis);
+			uri = PropertiesUtil.class.getResource(fileName).toURI();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 获取某个属性
+	 */
+	public static String getProperty(String key) {
+		try {
+			props.load(PropertiesUtil.class.getResourceAsStream(fileName));
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return props.getProperty(key);
+	}
+
+	/**
+	 * 获取所有属性,返回一个map,不常用 可以试试props.putAll(t)
+	 */
+	@SuppressWarnings("rawtypes")
+	public static Map<String, String> getAllProperty() {
+		Map<String, String> map = new HashMap<String, String>();
+		Enumeration enu = props.propertyNames();
+		while (enu.hasMoreElements()) {
+			String key = (String) enu.nextElement();
+			String value = props.getProperty(key);
+			map.put(key, value);
+		}
+		return map;
+	}
+
+	/**
+	 * 在控制台上打印出所有属性,调试时用。
+	 */
+	public static void printProperties() {
+		props.list(System.out);
+	}
+
+	/**
+	 * 写入properties信息
+	 */
+	public static void writeProperties(String key, String value) {
+		try {
+			OutputStream fos = new FileOutputStream(new File(uri));
+			props.setProperty(key, value);
+			// 将此 Properties 表中的属性列表(键和元素对)写入输出流
+			props.store(fos, "『comments』Update key:" + key);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 取默认key的value
+	 * */
+	public static String getValue(String key){
+		String value = null;
+		props = new Properties();
+		in = PropertiesUtil.class.getResourceAsStream(fileName);
+		try {
+			props.load(in);
+		} catch (IOException e) {
+//			e.printStackTrace();
+		}
+		value = (String) props.get(key);
+		return value;
+	}
+
+}

+ 32 - 0
src/main/java/com/template/common/utils/RandomTrackAlgorithm.java

@@ -0,0 +1,32 @@
+package com.template.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+public class RandomTrackAlgorithm {
+
+    public static BigDecimal makeRandom(float max, float min, int scale){
+        BigDecimal cha = new BigDecimal(Math.random() * (max-min) + min);
+        return cha.setScale(scale,BigDecimal.ROUND_HALF_UP);//保留 scale 位小数,并四舍五入
+    }
+
+    public static List<List<BigDecimal>> getPosition(){
+        List<List<BigDecimal>> all = new ArrayList<>();
+        // 生成随机坐标点
+        BigDecimal x = null;
+        BigDecimal y = null;
+        for (int i = 0; i < 10; i++) {
+            List<BigDecimal> list = new LinkedList<>();
+            // 114.449557,28.109357
+            x = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(114.449557));
+            y = makeRandom(0.001f,0.000001f,6).add(BigDecimal.valueOf(28.109357));
+            list.add(x);
+            list.add(y);
+            all.add(list);
+        }
+        return all;
+    }
+
+}

+ 617 - 0
src/main/java/com/template/common/utils/TimeExchange2.java

@@ -0,0 +1,617 @@
+package com.template.common.utils;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 时间转化工具 date转为时间戳 时间戳转date 互相与String的转换
+ * 所有出现的String time 格式都必须为(yyyy-MM-dd HH:mm:ss),否则出错
+ * @author 赵仁杰
+ *
+ */
+public class TimeExchange2 {
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss) 转 Date
+     *
+     * @param time
+     * @return
+     * @throws ParseException
+     */
+    // String date = "2010/05/04 12:34:23";
+    public static Date StringToDate(String time) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    public static Date StringToDate2(String time) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss) 转 Date
+     *
+     * @param time
+     * @return
+     * @throws ParseException
+     */
+    // String date = "2010/05/04 12:34:23";
+    public static Date StringToDate(String time, String formatStr) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatStr);
+        try {
+            date = dateFormat.parse(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+
+    /**
+     * Date转为String(yyyy-MM-dd HH:mm:ss)
+     *
+     * @param time
+     * @return
+     */
+    public static String DateToString(Date time) {
+        String dateStr = "";
+        Date date = new Date();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH/mm/ss");
+        try {
+            dateStr = dateFormat.format(time);
+            System.out.println(dateStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    public static String ToSimpleMonth(Date time) {
+        String dateStr = "";
+        DateFormat dateFormat = new SimpleDateFormat("M");
+        try {
+            dateStr = dateFormat.format(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    /**
+     * String(yyyy-MM-dd HH:mm:ss)转10位时间戳
+     * @param time
+     * @return
+     */
+    public static Integer StringToTimestamp(String time){
+
+        int times = 0;
+        try {
+            times = (int) ((Timestamp.valueOf(time).getTime())/1000);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if(times==0){
+            System.out.println("String转10位时间戳失败");
+        }
+        return times;
+
+    }
+    /**
+     * 10位int型的时间戳转换为String(yyyy-MM-dd HH:mm:ss)
+     * @param time
+     * @return
+     */
+    public static String timestampToString(Integer time){
+        //int转long时,先进行转型再进行计算,否则会是计算结束后在转型
+        long temp = (long)time*1000;
+        Timestamp ts = new Timestamp(temp);
+        String tsStr = "";
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            //方法一
+            tsStr = dateFormat.format(ts);
+            System.out.println(tsStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return tsStr;
+    }
+    /**
+     * 10位时间戳转Date
+     * @param time
+     * @return
+     */
+    public static Date TimestampToDate(Integer time){
+        long temp = (long)time*1000;
+        Timestamp ts = new Timestamp(temp);
+        Date date = new Date();
+        try {
+            date = ts;
+            //System.out.println(date);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+    /**
+     * Date类型转换为10位时间戳
+     * @param time
+     * @return
+     */
+    public static Integer DateToTimestamp(Date time){
+        Timestamp ts = new Timestamp(time.getTime());
+
+        return (int) ((ts.getTime())/1000);
+    }
+
+    // 当前时间减1小时
+    public static String TimeDesH(String time) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.HOUR, -1);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 最近两天
+    public static String getLastTwo() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, -2);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 当前时间加2分钟
+    public static String TimeRangeI10(String time,int m) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.SECOND, m);//10分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 当前时间加多少分钟
+    public static String TimeRangeM(String time,int m) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate2(time));
+        nowTime2.add(Calendar.MINUTE, m);//10分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+
+    // 当前时间减5分钟
+    public static String TimeRangeD(String time) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time));
+        nowTime2.add(Calendar.MINUTE, -300);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取当前日期
+    public static String getDateStr(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
+        return sp.format(new Date());
+    }
+
+    // 获取当前日期
+    public static String getDate(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    // 获取前天
+    public static String getQianDay() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, -5);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取明天
+    public static String getTomorrow() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, 1);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    // 获取昨天
+    public static String getYesturday()  {
+        try {
+            Calendar nowTime2 = Calendar.getInstance();
+            nowTime2.setTime(StringToDate(getTime()));
+            nowTime2.add(Calendar.DATE, -1);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            return simpleDateFormat.format(nowTime2.getTime());
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    // 获取最近7个月
+    public static List<String> getLastSevenMonth() throws ParseException {
+        List<String> ls = new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
+        for (int i = -6; i <= 0; i++) {
+            Calendar nowTime2 = Calendar.getInstance();
+            nowTime2.setTime(StringToDate(getTime()));
+            nowTime2.add(Calendar.MONTH, i);//5分钟前的时间
+            ls.add(simpleDateFormat.format(nowTime2.getTime()));
+        }
+        return ls;
+    }
+
+    public static String getTomorrowTime() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.DATE, 1);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    public static String getWeek(String sdate) throws ParseException {
+        // 再转换为时间
+        Date date = StringToDate(sdate,"yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        // int hour=c.get(Calendar.DAY_OF_WEEK);
+        // hour中存的就是星期几了,其范围 1~7
+        // 1=星期日 7=星期六,其他类推
+        return new SimpleDateFormat("EEEE").format(c.getTime());
+    }
+
+    // 今天星期几
+    public static String getWeek() throws ParseException {
+        String[] weeks = {"7","1","2","3","4","5","6"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(getTime()));
+        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if(week_index<0){
+            week_index = 0;
+        }
+        return weeks[week_index];
+    }
+
+    // 明天星期几
+    public static String getTomorrowWeek() throws ParseException {
+        String[] weeks = {"7","1","2","3","4","5","6"};
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(getTomorrowTime()));
+        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if(week_index<0){
+            week_index = 0;
+        }
+        return weeks[week_index];
+    }
+
+    // 获取当前时间
+    public static String getTime(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return sp.format(new Date());
+    }
+
+    public static String getOnlyMM(){
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm");
+        return sp.format(new Date());
+    }
+
+    public static String getOnlyDesMM() throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(getTime()));
+        nowTime2.add(Calendar.MINUTE, -5);//5分钟前的时间
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    public static String getYear(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy");
+        return sp.format(new Date());
+    }
+
+    public static String getMonth(){
+        SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM");
+        return sp.format(new Date());
+    }
+
+    // 获取当前时间
+    public static String getOnlyTime(){
+        SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
+        return sp.format(new Date());
+    }
+    /**
+     * 计算两个日期的时间差
+     * @param time1
+     * @param time2
+     * @return
+     */
+    public static double getTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours=(double) ((t2 - t1)/3600000);
+        double minutes=(double) (((t2 - t1)/1000-hours*3600)/60/60);
+        return hours+minutes;
+    }
+
+    public static double getOnlyTimeDifference(String time1, String time2) {
+        SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
+        long t1 = 0L;
+        long t2 = 0L;
+        try {
+            t1 = timeformat.parse(time1).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        try {
+            t2 = timeformat.parse(time2).getTime();
+        } catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        //因为t1-t2得到的是毫秒级,所以要初3600000得出小时.算天数或秒同理
+        double hours=(double) ((t2 - t1)/3600000);
+        double minutes=(double) (((t2 - t1)/1000-hours*3600)/60/60);
+        return hours+minutes;
+    }
+
+    public static double getDiff(String str1, String str2){
+        return str2.compareTo(str1);
+    }
+
+    /**
+     * String 转 Date
+     * @param time 时间
+     * @param formatStr 自定义时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static Date ShortStringToDate(String time, String formatStr) throws ParseException {
+
+        Date date = new Date();
+        // 注意format的格式要与日期String的格式相匹配
+        DateFormat dateFormat = new SimpleDateFormat(formatStr);
+        try {
+            date = dateFormat.parse(time);
+            System.out.println(date.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return date;
+    }
+
+    /**
+     * 获取指定月份有多少天
+     *
+     * @param month
+     * @return
+     */
+    public static int getMonthDays(String date, int month) {
+        int year = Integer.valueOf(date.substring(0, 4));
+        int[] arr = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+        int day = arr[month - 1];//天数对应=数组-1
+        if (month == 2 && year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
+            day = 29;
+        }
+
+        return day;
+
+    }
+
+    /**
+     * Date转为String
+     * @param time 时间
+     * @param FormatStr 自定义时间格式
+     * @return
+     */
+    public static String DateToString(Date time, String FormatStr) {
+        String dateStr = "";
+        DateFormat dateFormat = new SimpleDateFormat(FormatStr);
+        try {
+            dateStr = dateFormat.format(time);
+            System.out.println(dateStr);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateStr;
+    }
+
+    /**
+     * 比较时间1是否小于时间2
+     * 如果时间1小于时间2,接口返回true
+     * 如果时间1大于时间2,接口返回false
+     * @param dateOne 时间1
+     * @param dateTwo 时间2
+     * @return
+     * @throws ParseException
+     */
+    public static boolean CompareDate(String dateOne, String dateTwo) throws ParseException {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date sd1=df.parse(dateOne);
+        Date sd2=df.parse(dateTwo);
+        return sd1.before(sd2);
+    }
+
+    /**
+     * 比较时间1是否小于时间2
+     * 如果时间1小于时间2,接口返回true
+     * 如果时间1大于时间2,接口返回false
+     *
+     * @param dateOne 时间1
+     * @param dateTwo 时间2
+     * @param Forma   时间格式
+     * @return
+     * @throws ParseException
+     */
+    public static boolean CompareDate(String dateOne, String dateTwo, String Forma) throws ParseException {
+        SimpleDateFormat df = new SimpleDateFormat(Forma);
+        Date sd1 = df.parse(dateOne);
+        Date sd2 = df.parse(dateTwo);
+        return sd1.before(sd2);
+    }
+
+    /**
+     * 时间加减天数
+     *
+     * @param time   时间
+     * @param amount 天数 负的为减多少天 正的为加多少天
+     * @return
+     * @throws ParseException
+     */
+    public static String TimeDesD(String time, int amount) throws ParseException {
+        Calendar nowTime2 = Calendar.getInstance();
+        nowTime2.setTime(StringToDate(time, "yyyy-MM-dd"));
+        nowTime2.add(Calendar.DATE, amount);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        return simpleDateFormat.format(nowTime2.getTime());
+    }
+
+    /**
+     * 相差的天数
+     */
+    public static int daysBetween(String smdate, String bdate) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(sdf.parse(smdate));
+        long time1 = cal.getTimeInMillis();
+        cal.setTime(sdf.parse(bdate));
+        long time2 = cal.getTimeInMillis();
+        long between_days = (time2 - time1) / (1000 * 3600 * 24);
+
+        return Integer.parseInt(String.valueOf(between_days));
+    }
+
+    /**
+     * 获取一周的开始时间和结束时间
+     * 获取本周星期一作为一周的第一天的起始时间和结束时间
+     *
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentWeekTimeFrame() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+8"));
+        //start of the week
+        if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+            calendar.add(Calendar.DAY_OF_YEAR,-1);
+        }
+        calendar.add(Calendar.DAY_OF_WEEK, -(calendar.get(Calendar.DAY_OF_WEEK) - 2));
+        //给0的时候查不出数据
+//        calendar.set(Calendar.HOUR_OF_DAY, 0);
+//        calendar.set(Calendar.MINUTE, 0);
+//        calendar.set(Calendar.SECOND, 0);
+//        calendar.set(Calendar.MILLISECOND, 0);
+
+        String startTime = DateToString(calendar.getTime(), "yyyy-MM-dd");
+        //end of the week
+        calendar.add(Calendar.DAY_OF_WEEK, 6);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 999);
+        String endTime = DateToString(calendar.getTime());
+        return new String[]{startTime, endTime};
+    }
+
+    /**
+     * 获取指定月份的第一天和最后一天
+     * @param DateStr 指定月份
+     * @return 返回的数据中第一个是开始时间 第二个是结束时间
+     */
+    public static String[] getCurrentMonthTimeFrame(String DateStr) {
+        Calendar c = Calendar.getInstance();//获取Calendar实例
+        c.set(Calendar.YEAR, Integer.parseInt(DateStr.substring(0, 4)));
+        c.set(Calendar.MONTH, Integer.parseInt(DateStr.substring(5, 7).replace("-", "")) - 1);
+
+        c.set(Calendar.DAY_OF_MONTH, 1);
+
+        String startDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+
+        int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
+        c.set(Calendar.DAY_OF_MONTH, lastDay);
+        String endDate = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+
+        return new String[]{startDate, endDate};
+    }
+
+    public static List<String> getHighTime(){
+        String year = getYear();
+        return Arrays.asList(year+"-"+"08-30",year+"-"+"08-31",year+"-"+"09-01",year+"-"+"09-02",year+"-"+"09-03",year+"-"+"09-04");
+    }
+
+    public static List<String> getDays(String startTime, String endTime) {
+        // 返回的日期集合
+        List<String> days = new ArrayList<String>();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date start = dateFormat.parse(startTime);
+            Date end = dateFormat.parse(endTime);
+            Calendar tempStart = Calendar.getInstance();
+            tempStart.setTime(start);
+
+            Calendar tempEnd = Calendar.getInstance();
+            tempEnd.setTime(end);
+            tempEnd.add(Calendar.DATE, 0);// 日期加1(包含结束)
+            while (tempStart.before(tempEnd)) {
+                days.add(dateFormat.format(tempStart.getTime()));
+                tempStart.add(Calendar.DAY_OF_YEAR, 1);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return days;
+    }
+
+
+    public static void main(String[] args) throws ParseException {
+        System.out.println(ToSimpleMonth(StringToDate("2023-11","yyyy-MM")));
+    }
+
+}
+

+ 41 - 0
src/main/java/com/template/common/utils/TreeRecordsUtil.java

@@ -0,0 +1,41 @@
+package com.template.common.utils;
+
+import com.template.model.pojo.SmartAuthorGroup;
+import com.template.model.weixin.AuthorListGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TreeRecordsUtil {
+
+    public static List<AuthorListGroup> queryCommentTreeRecords(Integer pid, List<SmartAuthorGroup> lists) {
+        List<AuthorListGroup> newTrees = new ArrayList<>();
+
+        List<SmartAuthorGroup> datas = lists.stream().filter(e -> e.getParentId().equals(pid)).collect(Collectors.toList());
+
+        for (SmartAuthorGroup data : datas) {
+            AuthorListGroup item = AuthorListGroup.builder()
+                    .id(data.getId())
+                    .parentId(data.getParentId())
+                    .name(data.getName())
+                    .userId(data.getUserId())
+                    .applyId(data.getApplyId())
+                    .updateTime(data.getUpdateTime())
+                    .createUser(data.getCreateUser())
+                    .updateUser(data.getUpdateUser())
+                    .deleted(data.getDeleted())
+                    .build();
+            List<AuthorListGroup> news = queryCommentTreeRecords(item.getId(), lists);
+            if (news == null || news.size() == 0) {
+                newTrees.add(item);
+                continue;
+            } else {
+                item.setAuthorListGroups(news);
+                newTrees.add(item);
+            }
+        }
+
+        return newTrees;
+    }
+}

+ 25 - 0
src/main/java/com/template/common/utils/UUIDUtil.java

@@ -0,0 +1,25 @@
+package com.template.common.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+public class UUIDUtil {
+
+    public static long generateID(){
+
+        Random r = new Random();
+        long numbers = 1000000000L + (long)(r.nextDouble() * 999999999L);
+
+        return numbers;
+    }
+
+    public static String getNewDate(){
+        Date nowDate = new Date();// 取当前时间
+        SimpleDateFormat dateFormat = new SimpleDateFormat(
+                "yyyy-MM-dd HH:mm:ss"); // 转换时间格式
+        String date = dateFormat.format(nowDate);
+        return date;
+    }
+
+}