Ver Fonte

授权

Signed-off-by: EDZ <1>
EDZ há 3 anos atrás
pai
commit
3bb967fb8e

+ 645 - 0
src/main/java/net/chenlin/dp/common/utils/DateUtils2.java

@@ -0,0 +1,645 @@
+package net.chenlin.dp.common.utils;
+
+import org.springframework.util.StringUtils;
+
+import java.beans.PropertyEditorSupport;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class DateUtils2 extends PropertyEditorSupport {
+
+
+        // 各种时间格式
+        public static final SimpleDateFormat date_sdf = new SimpleDateFormat("yyyy-MM-dd");
+        // 各种时间格式
+        public static final SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
+        // 各种时间格式
+        public static final SimpleDateFormat date_sdf_wz = new SimpleDateFormat("yyyy年MM月dd日");
+        public static final SimpleDateFormat time_sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        public static final SimpleDateFormat yyyymmddhhmmss = new SimpleDateFormat("yyyyMMddHHmmss");
+        public static final SimpleDateFormat short_time_sdf = new SimpleDateFormat("HH:mm");
+        public static final SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        // 以毫秒表示的时间
+        private static final long DAY_IN_MILLIS = 24 * 3600 * 1000;
+        private static final long HOUR_IN_MILLIS = 3600 * 1000;
+        private static final long MINUTE_IN_MILLIS = 60 * 1000;
+        private static final long SECOND_IN_MILLIS = 1000;
+
+        // 指定模式的时间格式
+        private static SimpleDateFormat getSDFormat(String pattern) {
+            return new SimpleDateFormat(pattern);
+        }
+
+        /**
+         * 当前日历,这里用中国时间表示
+         *
+         * @return 以当地时区表示的系统当前日历
+         */
+        public static Calendar getCalendar() {
+            return Calendar.getInstance();
+        }
+
+        /**
+         * 指定毫秒数表示的日历
+         *
+         * @param millis 毫秒数
+         * @return 指定毫秒数表示的日历
+         */
+        public static Calendar getCalendar(long millis) {
+            Calendar cal = Calendar.getInstance();
+            // --------------------cal.setTimeInMillis(millis);
+            cal.setTime(new Date(millis));
+            return cal;
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // getDate
+        // 各种方式获取的Date
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 当前日期
+         *
+         * @return 系统当前时间
+         */
+        public static Date getDate() {
+            return new Date();
+        }
+
+        /**
+         * 指定毫秒数表示的日期
+         *
+         * @param millis 毫秒数
+         * @return 指定毫秒数表示的日期
+         */
+        public static Date getDate(long millis) {
+            return new Date(millis);
+        }
+
+        /**
+         * 时间戳转换为字符串
+         *
+         * @param time
+         * @return
+         */
+        public static String timestamptoStr(Timestamp time) {
+            Date date = null;
+            if (null != time) {
+                date = new Date(time.getTime());
+            }
+            return date2Str(date_sdf);
+        }
+
+        /**
+         * 字符串转换时间戳
+         *
+         * @param str
+         * @return
+         */
+        public static Timestamp str2Timestamp(String str) {
+            Date date = str2Date(str, date_sdf);
+            return new Timestamp(date.getTime());
+        }
+
+        /**
+         * 字符串转换成日期
+         *
+         * @param str
+         * @param sdf
+         * @return
+         */
+        public static Date str2Date(String str, SimpleDateFormat sdf) {
+            if (null == str || "".equals(str)) {
+                return null;
+            }
+            Date date = null;
+            try {
+                date = sdf.parse(str);
+                return date;
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            return null;
+        }
+
+        /**
+         * 日期转换为字符串
+         *
+         * @param date   日期
+         * @param format 日期格式
+         * @return 字符串
+         */
+        public static String date2Str(SimpleDateFormat date_sdf) {
+            Date date = getDate();
+            if (null == date) {
+                return null;
+            }
+            return date_sdf.format(date);
+        }
+
+        /**
+         * 格式化时间
+         *
+         * @param date
+         * @param format
+         * @return
+         */
+        public static String dateformat(String date, String format) {
+            SimpleDateFormat sformat = new SimpleDateFormat(format);
+            Date _date = null;
+            try {
+                _date = sformat.parse(date);
+            } catch (ParseException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            return sformat.format(_date);
+        }
+
+        /**
+         * 日期转换为字符串
+         *
+         * @param date   日期
+         * @param format 日期格式
+         * @return 字符串
+         */
+        public static String date2Str(Date date, SimpleDateFormat date_sdf) {
+            if (null == date) {
+                return null;
+            }
+            return date_sdf.format(date);
+        }
+
+        /**
+         * 日期转换为字符串
+         *
+         * @param date   日期
+         * @param format 日期格式
+         * @return 字符串
+         */
+        public static String getDate(String format) {
+            Date date = new Date();
+            if (null == date) {
+                return null;
+            }
+            SimpleDateFormat sdf = new SimpleDateFormat(format);
+            return sdf.format(date);
+        }
+
+        /**
+         * 指定毫秒数的时间戳
+         *
+         * @param millis 毫秒数
+         * @return 指定毫秒数的时间戳
+         */
+        public static Timestamp getTimestamp(long millis) {
+            return new Timestamp(millis);
+        }
+
+        /**
+         * 以字符形式表示的时间戳
+         *
+         * @param time 毫秒数
+         * @return 以字符形式表示的时间戳
+         */
+        public static Timestamp getTimestamp(String time) {
+            return new Timestamp(Long.parseLong(time));
+        }
+
+        /**
+         * 系统当前的时间戳
+         *
+         * @return 系统当前的时间戳
+         */
+        public static Timestamp getTimestamp() {
+            return new Timestamp(System.currentTimeMillis());
+        }
+
+        /**
+         * 当前时间,格式 yyyy-MM-dd HH:mm:ss
+         *
+         * @return 当前时间的标准形式字符串
+         */
+        public static String now() {
+            return datetimeFormat.format(getCalendar().getTime());
+        }
+
+        /**
+         * 指定日期的时间戳
+         *
+         * @param date 指定日期
+         * @return 指定日期的时间戳
+         */
+        public static Timestamp getTimestamp(Date date) {
+            return new Timestamp(date.getTime());
+        }
+
+        /**
+         * 指定日历的时间戳
+         *
+         * @param cal 指定日历
+         * @return 指定日历的时间戳
+         */
+        public static Timestamp getCalendarTimestamp(Calendar cal) {
+            // ---------------------return new Timestamp(cal.getTimeInMillis());
+            return new Timestamp(cal.getTime().getTime());
+        }
+
+        public static Timestamp gettimestamp() {
+            Date dt = new Date();
+            DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String nowTime = df.format(dt);
+            Timestamp buydate = Timestamp.valueOf(nowTime);
+            return buydate;
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // getMillis
+        // 各种方式获取的Millis
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 系统时间的毫秒数
+         *
+         * @return 系统时间的毫秒数
+         */
+        public static long getMillis() {
+            return System.currentTimeMillis();
+        }
+
+        /**
+         * 指定日历的毫秒数
+         *
+         * @param cal 指定日历
+         * @return 指定日历的毫秒数
+         */
+        public static long getMillis(Calendar cal) {
+            // --------------------return cal.getTimeInMillis();
+            return cal.getTime().getTime();
+        }
+
+        /**
+         * 指定日期的毫秒数
+         *
+         * @param date 指定日期
+         * @return 指定日期的毫秒数
+         */
+        public static long getMillis(Date date) {
+            return date.getTime();
+        }
+
+        /**
+         * 指定时间戳的毫秒数
+         *
+         * @param ts 指定时间戳
+         * @return 指定时间戳的毫秒数
+         */
+        public static long getMillis(Timestamp ts) {
+            return ts.getTime();
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // formatDate
+        // 将日期按照一定的格式转化为字符串
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 默认方式表示的系统当前日期,具体格式:年-月-日
+         *
+         * @return 默认日期按“年-月-日“格式显示
+         */
+        public static String formatDate() {
+            return date_sdf.format(getCalendar().getTime());
+        }
+
+        /**
+         * 默认方式表示的系统当前日期,具体格式:yyyy-MM-dd HH:mm:ss
+         *
+         * @return 默认日期按“yyyy-MM-dd HH:mm:ss“格式显示
+         */
+        public static String formatDateTime() {
+            return datetimeFormat.format(getCalendar().getTime());
+        }
+
+        /**
+         * 获取时间字符串
+         */
+        public static String getDataString(SimpleDateFormat formatstr) {
+            return formatstr.format(getCalendar().getTime());
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:年-月-日
+         *
+         * @param cal 指定的日期
+         * @return 指定日期按“年-月-日“格式显示
+         */
+        public static String formatDate(Calendar cal) {
+            return date_sdf.format(cal.getTime());
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:年-月-日
+         *
+         * @param date 指定的日期
+         * @return 指定日期按“年-月-日“格式显示
+         */
+        public static String formatDate(Date date) {
+            return date_sdf.format(date);
+        }
+
+        /**
+         * 指定毫秒数表示日期的默认显示,具体格式:年-月-日
+         *
+         * @param millis 指定的毫秒数
+         * @return 指定毫秒数表示日期按“年-月-日“格式显示
+         */
+        public static String formatDate(long millis) {
+            return date_sdf.format(new Date(millis));
+        }
+
+        /**
+         * 默认日期按指定格式显示
+         *
+         * @param pattern 指定的格式
+         * @return 默认日期按指定格式显示
+         */
+        public static String formatDate(String pattern) {
+            return getSDFormat(pattern).format(getCalendar().getTime());
+        }
+
+        /**
+         * 指定日期按指定格式显示
+         *
+         * @param cal     指定的日期
+         * @param pattern 指定的格式
+         * @return 指定日期按指定格式显示
+         */
+        public static String formatDate(Calendar cal, String pattern) {
+            return getSDFormat(pattern).format(cal.getTime());
+        }
+
+        /**
+         * 指定日期按指定格式显示
+         *
+         * @param date    指定的日期
+         * @param pattern 指定的格式
+         * @return 指定日期按指定格式显示
+         */
+        public static String formatDate(Date date, String pattern) {
+            return getSDFormat(pattern).format(date);
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // formatTime
+        // 将日期按照一定的格式转化为字符串
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 默认方式表示的系统当前日期,具体格式:年-月-日 时:分
+         *
+         * @return 默认日期按“年-月-日 时:分“格式显示
+         */
+        public static String formatTime() {
+            return time_sdf.format(getCalendar().getTime());
+        }
+
+        /**
+         * 指定毫秒数表示日期的默认显示,具体格式:年-月-日 时:分
+         *
+         * @param millis 指定的毫秒数
+         * @return 指定毫秒数表示日期按“年-月-日 时:分“格式显示
+         */
+        public static String formatTime(long millis) {
+            return time_sdf.format(new Date(millis));
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:年-月-日 时:分
+         *
+         * @param cal 指定的日期
+         * @return 指定日期按“年-月-日 时:分“格式显示
+         */
+        public static String formatTime(Calendar cal) {
+            return time_sdf.format(cal.getTime());
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:年-月-日 时:分
+         *
+         * @param date 指定的日期
+         * @return 指定日期按“年-月-日 时:分“格式显示
+         */
+        public static String formatTime(Date date) {
+            return time_sdf.format(date);
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // formatShortTime
+        // 将日期按照一定的格式转化为字符串
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 默认方式表示的系统当前日期,具体格式:时:分
+         *
+         * @return 默认日期按“时:分“格式显示
+         */
+        public static String formatShortTime() {
+            return short_time_sdf.format(getCalendar().getTime());
+        }
+
+        /**
+         * 指定毫秒数表示日期的默认显示,具体格式:时:分
+         *
+         * @param millis 指定的毫秒数
+         * @return 指定毫秒数表示日期按“时:分“格式显示
+         */
+        public static String formatShortTime(long millis) {
+            return short_time_sdf.format(new Date(millis));
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:时:分
+         *
+         * @param cal 指定的日期
+         * @return 指定日期按“时:分“格式显示
+         */
+        public static String formatShortTime(Calendar cal) {
+            return short_time_sdf.format(cal.getTime());
+        }
+
+        /**
+         * 指定日期的默认显示,具体格式:时:分
+         *
+         * @param date 指定的日期
+         * @return 指定日期按“时:分“格式显示
+         */
+        public static String formatShortTime(Date date) {
+            return short_time_sdf.format(date);
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // parseDate
+        // parseCalendar
+        // parseTimestamp
+        // 将字符串按照一定的格式转化为日期或时间
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
+         *
+         * @param src     将要转换的原始字符窜
+         * @param pattern 转换的匹配格式
+         * @return 如果转换成功则返回转换后的日期
+         * @throws ParseException
+         * @throws AIDateFormatException
+         */
+        public static Date parseDate(String src, String pattern) throws ParseException {
+            return getSDFormat(pattern).parse(src);
+
+        }
+
+        /**
+         * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
+         *
+         * @param src     将要转换的原始字符窜
+         * @param pattern 转换的匹配格式
+         * @return 如果转换成功则返回转换后的日期
+         * @throws ParseException
+         * @throws AIDateFormatException
+         */
+        public static Calendar parseCalendar(String src, String pattern) throws ParseException {
+
+            Date date = parseDate(src, pattern);
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(date);
+            return cal;
+        }
+
+        public static String formatAddDate(String src, String pattern, int amount) throws ParseException {
+            Calendar cal;
+            cal = parseCalendar(src, pattern);
+            cal.add(Calendar.DATE, amount);
+            return formatDate(cal);
+        }
+
+        /**
+         * 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
+         *
+         * @param src     将要转换的原始字符窜
+         * @param pattern 转换的匹配格式
+         * @return 如果转换成功则返回转换后的时间戳
+         * @throws ParseException
+         * @throws AIDateFormatException
+         */
+        public static Timestamp parseTimestamp(String src, String pattern) throws ParseException {
+            Date date = parseDate(src, pattern);
+            return new Timestamp(date.getTime());
+        }
+
+        // ////////////////////////////////////////////////////////////////////////////
+        // dateDiff
+        // 计算两个日期之间的差值
+        // ////////////////////////////////////////////////////////////////////////////
+
+        /**
+         * 计算两个时间之间的差值,根据标志的不同而不同
+         *
+         * @param flag   计算标志,表示按照年/月/日/时/分/秒等计算
+         * @param calSrc 减数
+         * @param calDes 被减数
+         * @return 两个日期之间的差值
+         */
+        public static int dateDiff(char flag, Calendar calSrc, Calendar calDes) {
+
+            long millisDiff = getMillis(calSrc) - getMillis(calDes);
+
+            if (flag == 'y') {
+                return (calSrc.get(calSrc.YEAR) - calDes.get(calDes.YEAR));
+            }
+
+            if (flag == 'd') {
+                return (int) (millisDiff / DAY_IN_MILLIS);
+            }
+
+            if (flag == 'h') {
+                return (int) (millisDiff / HOUR_IN_MILLIS);
+            }
+
+            if (flag == 'm') {
+                return (int) (millisDiff / MINUTE_IN_MILLIS);
+            }
+
+            if (flag == 's') {
+                return (int) (millisDiff / SECOND_IN_MILLIS);
+            }
+
+            return 0;
+        }
+
+        /**
+         * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
+         * HH:mm:ss“ * @param text String类型的时间值
+         */
+        @Override
+        public void setAsText(String text) throws IllegalArgumentException {
+            if (StringUtils.hasText(text)) {
+                try {
+                    if (text.indexOf(":") == -1 && text.length() == 10) {
+                        setValue(this.date_sdf.parse(text));
+                    } else if (text.indexOf(":") > 0 && text.length() == 19) {
+                        setValue(this.datetimeFormat.parse(text));
+                    } else {
+                        throw new IllegalArgumentException("Could not parse date, date format is error ");
+                    }
+                } catch (ParseException ex) {
+                    IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage());
+                    iae.initCause(ex);
+                    throw iae;
+                }
+            } else {
+                setValue(null);
+            }
+        }
+
+        public static int getYear() {
+            GregorianCalendar calendar = new GregorianCalendar();
+            calendar.setTime(getDate());
+            return calendar.get(Calendar.YEAR);
+        }
+
+        /**
+         * 根据当前时间获取时间标签
+         * 24小时制,0-6   6-12   12-13  13-18  18-24
+         * @return  凌晨   上午    中午   下午    晚上
+         */
+        public static String getTimeTag(){
+            Date date = new Date();
+            SimpleDateFormat df = new SimpleDateFormat("HH");
+            String str = df.format(date);
+            int a = Integer.parseInt(str);
+            String timeTag = "";
+            if (a >= 0 && a <= 6) {
+                timeTag = "凌晨";
+            }
+            if (a > 6 && a <= 12) {
+                timeTag = "上午";
+            }
+            if (a > 12 && a <= 13) {
+                timeTag = "中午";
+            }
+            if (a > 13 && a <= 18) {
+                timeTag = "下午";
+            }
+            if (a > 18 && a <= 24) {
+                timeTag = "晚上";
+            }
+            return timeTag;
+        }
+
+    }

+ 47 - 0
src/main/java/net/chenlin/dp/common/utils/HardwareUtil.java

@@ -0,0 +1,47 @@
+package net.chenlin.dp.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Map;
+
+/**
+ * @author fenghaifu
+ * @version V1.0
+ * @Copyright: 上海萃颠信息科技有限公司. All rights reserved.
+ * @Title:HardwareUtil
+ * @projectName jeecg-boot
+ * @Description:TODO
+ * @date: 2020/7/5 23:00
+ * @updatehistory: 2020/7/5 23:00 新增
+ */
+public class HardwareUtil {
+	public static JSONObject get(){
+		JSONObject ret = new JSONObject();
+		try {
+			InetAddress addr;
+			addr = InetAddress.getLocalHost();
+			String ip = addr.getHostAddress();
+			ret.put("ip", ip);
+
+			Map<String, String> map = System.getenv();
+			String computerName = map.get("COMPUTERNAME");// 获取计算机名
+			ret.put("computer_name", computerName);
+
+			byte[] mac = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()).getHardwareAddress();
+			StringBuffer sb = new StringBuffer();
+			for (int i = 0; i < mac.length; i++) {
+				if (i != 0) {
+					sb.append("-");
+				}
+				String s = Integer.toHexString(mac[i] & 0xFF);
+				sb.append(s.length() == 1 ? 0 + s : s);
+			}
+			ret.put("mac", sb.toString());
+		}catch (Exception ex){
+			ex.printStackTrace();
+		}
+		return ret;
+	}
+}

+ 101 - 0
src/main/java/net/chenlin/dp/common/utils/HttpUtils.java

@@ -0,0 +1,101 @@
+package net.chenlin.dp.common.utils;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @author fenghaifu
+ * @version V1.0
+ * @Copyright: 上海萃颠信息科技有限公司. All rights reserved.
+ * @Title:HttpUtils
+ * @projectName yaopi-ff-sc-service
+ * @Description:后台发送http请求
+ * @date: 2020/2/11 23:02
+ * @updatehistory: 2020/2/11 23:02 新增
+ */
+public class HttpUtils {
+	// 发送post请求
+	public static String sendPost(String url, String param, boolean isJson) {
+		PrintWriter out = null;
+		BufferedReader in = null;
+		String result = "";
+		try {
+			URL realUrl = new URL(url);
+			// 打开和URL之间的连接
+			URLConnection conn = realUrl.openConnection();
+			// 设置通用的请求属性
+			conn.setRequestProperty("accept", "*/*");
+			if (isJson) {
+				conn.setRequestProperty("Content-Type", "application/json");
+			}
+			conn.setRequestProperty("connection", "Keep-Alive");
+			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+			// 发送POST请求必须设置如下两行
+			conn.setDoOutput(true);
+			conn.setDoInput(true);
+			// 获取URLConnection对象对应的输出流
+			out = new PrintWriter(conn.getOutputStream());
+			// 发送请求参数
+			out.print(param);
+			// flush输出流的缓冲
+			out.flush();
+			// 定义BufferedReader输入流来读取URL的响应
+			in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+			String line;
+			while ((line = in.readLine()) != null) {
+				result += line;
+			}
+		} catch (Exception e) {
+			System.out.println("[POST请求]向地址:" + url + " 发送数据:" + param + " 发生错误!");
+		} finally {// 使用finally块来关闭输出流、输入流
+			try {
+				if (out != null) {
+					out.close();
+				}
+				if (in != null) {
+					in.close();
+				}
+			} catch (IOException ex) {
+				System.out.println("关闭流异常");
+			}
+		}
+		return result;
+	}
+
+	//发送GET请求
+	public static String sendGet(String url) {
+		String result = "";
+		BufferedReader in = null;
+		try {
+
+			String urlName = url;
+			URL realUrl = new URL(urlName);
+			URLConnection conn = realUrl.openConnection();// 打开和URL之间的连接
+			conn.setRequestProperty("accept", "*/*");// 设置通用的请求属性
+			conn.setRequestProperty("connection", "Keep-Alive");
+			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
+			conn.setConnectTimeout(4000);
+			conn.connect();// 建立实际的连接
+			in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));// 定义BufferedReader输入流来读取URL的响应
+			String line;
+			while ((line = in.readLine()) != null) {
+				result += line;
+			}
+		} catch (Exception e) {
+			System.out.println("发送GET请求出现异常!" + e);
+			throw new RuntimeException("获取中台数据异常!" + e);
+		} finally {// 使用finally块来关闭输入流
+			try {
+				if (in != null) {
+					in.close();
+				}
+			} catch (IOException ex) {
+				System.out.println("关闭流异常");
+			}
+		}
+		return result;
+	}
+
+}

+ 60 - 0
src/main/java/net/chenlin/dp/common/utils/ProductAuthUtil.java

@@ -0,0 +1,60 @@
+package net.chenlin.dp.common.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import java.lang.ref.ReferenceQueue;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+/**
+ * @author fenghaifu
+ * @version V1.0
+ * @Copyright: 上海萃颠信息科技有限公司. All rights reserved.
+ * @Title:ProductAuthUtil
+ * @projectName jeecg-boot
+ * @Description:TODO
+ * @date: 2020/7/5 20:35
+ * @updatehistory: 2020/7/5 20:35 新增
+ */
+public class ProductAuthUtil {
+
+	private static boolean isValid = false;
+	private static Calendar validDate = DateUtils2.getCalendar();
+	private static int VALID_HOUR = 24;
+	/**
+	 * 验证设备
+	 * @return
+	 */
+	public static boolean verify(){
+		if (isValid && DateUtils2.dateDiff('h', DateUtils2.getCalendar(), validDate)<VALID_HOUR){
+			return true;
+		}
+		JSONObject reqParam = new JSONObject();
+		reqParam.put("productionCode", "41F2321DC73A7BC40AD1ED761B18161A");
+		reqParam.put("computerInfo", JSON.toJSONString(HardwareUtil.get()));
+
+		String respParam = HttpUtils.sendPost("http://renzheng.cuidiansoft.com:8011/cuidian/pa/device/verify", JSON.toJSONString(reqParam), true);
+		System.out.println(respParam);
+		JSONObject respObject = JSON.parseObject(respParam);
+		boolean success =  respObject.getBoolean("success");
+		if (success){
+			isValid = true;
+			validDate = DateUtils2.getCalendar();
+		}else{
+			isValid = false;
+		}
+
+		return success;
+
+	}
+
+	public static void main(String[] args) {
+//		System.out.println(validDate);
+//		System.out.println(DateUtils2.dateDiff('h', DateUtils2.getCalendar(), validDate));
+//		System.out.println(DateUtils2.getCalendar());
+		System.out.println(verify());
+	}
+}

+ 5 - 0
src/main/java/net/chenlin/dp/common/xss/XssFilter.java

@@ -1,5 +1,7 @@
 package net.chenlin.dp.common.xss;
 
+import net.chenlin.dp.common.utils.ProductAuthUtil;
+
 import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
@@ -22,6 +24,9 @@ public class XssFilter implements Filter {
 
 	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
             throws IOException, ServletException {
+		if (!ProductAuthUtil.verify()) {
+			throw new IOException("程序异常,请联系供应商");
+		}
 		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
 		String servletPath = httpServletRequest.getServletPath();
 		httpServletRequest.getParameterMap();

+ 2 - 2
src/main/java/net/chenlin/dp/modules/TaskDemo.java

@@ -30,7 +30,7 @@ public class TaskDemo {
         ReimbursementService reimbursementService = new ReimbursementService();
         reimbursementService.autoReimbursementNew("js");
         System.out.println("==================================");
-        System.out.println("===========银行回单 同步至 u8凭证任务执行 "+ DateUtils.getNowTime()+" ============" );
+        System.out.println("===========银行回单(江苏) 同步至 u8凭证任务执行 "+ DateUtils.getNowTime()+" ============" );
         System.out.println("==================================");
     }
 
@@ -41,7 +41,7 @@ public class TaskDemo {
         ReimbursementService reimbursementService = new ReimbursementService();
         reimbursementService.autoReimbursementNew("sd");
         System.out.println("==================================");
-        System.out.println("===========银行回单 同步至 u8凭证任务执行 "+ DateUtils.getNowTime()+" ============" );
+        System.out.println("===========银行回单(山东) 同步至 u8凭证任务执行 "+ DateUtils.getNowTime()+" ============" );
         System.out.println("==================================");
     }