Browse Source

add:消息推送

yonge 5 years ago
parent
commit
a5c26ab4ac

+ 28 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPlugin.java

@@ -0,0 +1,28 @@
+package com.ym.mec.thirdparty.message;
+
+import java.io.IOException;
+
+public interface MessageSenderPlugin {
+	
+	/**
+	 * 发送消息至目的地
+	 * @param subject 消息主题
+	 * @param content 消息内容
+	 * @param receiver 收件人
+	 * @param url 链接地址
+	 * @return 是否发送成功
+	 * @throws IOException
+	 */
+	public boolean send(String subject, String content, String receiver, String url) throws IOException;
+
+	/**
+	 * 批量发送消息至目的地
+	 * @param subject 消息主题
+	 * @param content 消息内容
+	 * @param receivers 收件人列表
+	 * @param url 链接地址
+	 * @return 是否发送成功
+	 * @throws IOException
+	 */
+	public boolean batchSend(String subject, String content, String[] receivers, String url) throws IOException;
+}

+ 93 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/MessageSenderPluginContext.java

@@ -0,0 +1,93 @@
+package com.ym.mec.thirdparty.message;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.thirdparty.message.vendors.JiguangPushPlugin;
+import com.ym.mec.thirdparty.message.vendors.MOxintongSMSPlugin;
+import com.ym.mec.thirdparty.message.vendors.ShiyuanSMSPlugin;
+
+@Component
+public class MessageSenderPluginContext implements ApplicationContextAware {
+
+	public enum MessageSender {
+
+		JIGUANG, MOXINGTONG, SHIYUAN;
+	}
+
+	private MessageSenderPlugin messageSenderPlugin;
+
+	private ApplicationContext applicationContext;
+
+	private final Map<String, String> mapper = new HashMap<String, String>() {
+
+		/**
+		 * 
+		 */
+		private static final long serialVersionUID = -3964872523891264522L;
+
+		{
+			put("jiguang", StringUtils.uncapitalize(JiguangPushPlugin.class.getSimpleName()));
+			put("moxingtong", StringUtils.uncapitalize(MOxintongSMSPlugin.class.getSimpleName()));
+			put("shiyuan", StringUtils.uncapitalize(ShiyuanSMSPlugin.class.getSimpleName()));
+		}
+	};
+
+	/**
+	 * 发送消息至目的地
+	 * @param messageSender 消息发送方
+	 * @param subject 消息主题
+	 * @param content 消息内容
+	 * @param receiver 收件人
+	 * @param url 链接地址
+	 * @return 是否发送成功
+	 * @throws IOException
+	 */
+	public boolean send(MessageSender messageSender, String subject, String content, String receiver, String url) throws IOException {
+
+		messageSenderPlugin = getMessageSenderPlugin(messageSender);
+
+		return messageSenderPlugin.send(subject, content, receiver, url);
+	}
+
+	/**
+	 * 批量发送消息至目的地
+	 * @param messageSender 消息发送方
+	 * @param subject 消息主题
+	 * @param content 消息内容
+	 * @param receivers 收件人列表
+	 * @param url 链接地址
+	 * @return 是否发送成功
+	 * @throws IOException
+	 */
+	public boolean batchSend(MessageSender messageSender, String subject, String content, String[] receivers, String url) throws IOException {
+
+		messageSenderPlugin = getMessageSenderPlugin(messageSender);
+
+		return messageSenderPlugin.batchSend(subject, content, receivers, url);
+	}
+
+	@Override
+	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+		this.applicationContext = applicationContext;
+	}
+
+	private MessageSenderPlugin getMessageSenderPlugin(MessageSender messageSender) {
+		String beanId = mapper.get(StringUtils.lowerCase(messageSender.name()));
+
+		if (StringUtils.isBlank(beanId)) {
+			throw new ThirdpartyException("消息发送方不存在");
+		}
+
+		return applicationContext.getBean(beanId, MessageSenderPlugin.class);
+	}
+
+}

+ 195 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/vendors/JiguangPushPlugin.java

@@ -0,0 +1,195 @@
+package com.ym.mec.thirdparty.message.vendors;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.thirdparty.message.MessageSenderPlugin;
+import com.ym.mec.util.http.HttpUtil;
+
+/**
+ * 极光推送
+ */
+@Service
+public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean {
+
+	@Value("${push.jiguang.appKey:1}")
+	private String appKey;
+
+	@Value("${push.jiguang.masterSecret:1}")
+	private String masterSecret;
+
+	@Value("${push.jiguang.apns_production:false}")
+	private boolean apns_production; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境
+
+	@Value("${push.jiguang.time_to_live:86400}")
+	private int time_to_live; // 离线保留时长 秒为单位 默认1天 最大10天
+
+	@Value("${push.jiguang.reqURL:1}")
+	private String reqURL;// 请求极光地址
+
+	/**
+	 * 组装推送Json串
+	 *
+	 * @param alias 别名推送
+	 * @param alert 消息
+	 * @param content 消息内容
+	 * @return json对象
+	 */
+	private JSONObject generateJson(String[] alias, String alert, String content, String url) {
+		JSONObject json = new JSONObject();
+		JSONArray platform = new JSONArray();// 平台
+		platform.add("android");
+		platform.add("ios");
+
+		JSONObject audience = new JSONObject();// 推送目标
+		JSONArray aliasJsonArr = new JSONArray();
+		for (String alia : alias) {
+			aliasJsonArr.add(alia);
+		}
+		audience.put("alias", aliasJsonArr);
+
+		JSONObject notification = new JSONObject();// 通知内容
+		JSONObject android = new JSONObject();// android通知内容
+		android.put("alert", alert);
+		android.put("builder_id", 1);
+		JSONObject android_extras = new JSONObject();// android额外参数
+		android_extras.put("type", "infomation");
+		android_extras.put("url", url);
+		android.put("extras", android_extras);
+
+		JSONObject ios = new JSONObject();// ios通知内容
+		ios.put("alert", alert);
+		ios.put("sound", "default");
+		ios.put("badge", "+1");
+		JSONObject ios_extras = new JSONObject();// ios额外参数
+		ios_extras.put("type", "infomation");
+		ios_extras.put("url", url);
+		ios.put("extras", ios_extras);
+		notification.put("android", android);
+		notification.put("ios", ios);
+
+		JSONObject message = new JSONObject();// 通知消息内容
+		message.put("title", alert);
+		message.put("msg_content", content);
+		message.put("content_type", "text");
+
+		JSONObject options = new JSONObject();// 设置参数
+		options.put("time_to_live", this.time_to_live);
+		options.put("apns_production", this.apns_production);
+
+		json.put("platform", platform);
+		json.put("audience", audience);
+		json.put("notification", notification);
+		json.put("options", options);
+		json.put("message", message);
+		return json;
+
+	}
+
+	/**
+	 * 调用极光api
+	 * @param alias 推送对象别名
+	 * @param alert 推送消息
+	 * @param content 推送内容
+	 */
+	private String push(String[] alias, String alert, String content, String url) {
+		String base64_auth_string = encryptBASE64(this.appKey + ":" + this.masterSecret);
+		String authorization = "Basic " + base64_auth_string;
+		return sendPostRequest(generateJson(alias, alert, content, url).toString(), authorization);
+	}
+
+	/**
+	 * 发送Post请求(json格式)
+	 *
+	 * @param data //封装的json串
+	 * @param authorization 验签
+	 * @return result 返回一个json字符串
+	 */
+	private String sendPostRequest(String data, String authorization) {
+		String result = "";
+		HashMap<String, String> reqHeader = new HashMap<>();
+		reqHeader.put("Authorization", authorization.trim());
+		try {
+			result = HttpUtil.postForHttps(this.reqURL, data, reqHeader);
+		} catch (Exception e) {
+			throw new ThirdpartyException("HttpUtil Connection Exception", e);
+		}
+		return result;
+	}
+
+	/**
+	 *     * BASE64加密工具
+	 */
+	private String encryptBASE64(String str) {
+		byte[] key = str.getBytes();
+		String strs = Base64.encodeBase64String(key);
+		return strs;
+	}
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		// 参数检查
+		if (StringUtils.isBlank(appKey)) {
+			throw new RuntimeException("Init parameter [appKey] can not blank");
+		}
+		if (StringUtils.isBlank(masterSecret)) {
+			throw new RuntimeException("Init parameter [masterSecret] can not blank");
+		}
+		if (StringUtils.isBlank(reqURL)) {
+			throw new RuntimeException("Init parameter [reqURL] can not blank");
+		}
+	}
+
+	@Override
+	public boolean send(String subject, String content, String receiver, String url) throws IOException {
+		String[] alias = { receiver };
+		String result = this.push(alias, subject, content, url);
+		JSONObject json = JSONObject.parseObject(result);
+		if (json.containsKey("error")) {
+			JSONObject jsonObject = json.getJSONObject("error");
+			throw new ThirdpartyException(jsonObject.get("message").toString());
+		}
+		return true;
+	}
+
+	@Override
+	public boolean batchSend(String subject, String content, String[] receivers, String url) throws IOException {
+		String result = this.push(receivers, subject, content, url);
+		JSONObject json = JSONObject.parseObject(result);
+		if (json.containsKey("error")) {
+			JSONObject jsonObject = json.getJSONObject("error");
+			throw new ThirdpartyException(jsonObject.get("message").toString());
+		}
+		return true;
+	}
+
+	public void setAppKey(String appKey) {
+		this.appKey = appKey;
+	}
+
+	public void setMasterSecret(String masterSecret) {
+		this.masterSecret = masterSecret;
+	}
+
+	public void setApns_production(boolean apns_production) {
+		this.apns_production = apns_production;
+	}
+
+	public void setTime_to_live(int time_to_live) {
+		this.time_to_live = time_to_live;
+	}
+
+	public void setReqURL(String reqURL) {
+		this.reqURL = reqURL;
+	}
+
+}

+ 110 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/vendors/MOxintongSMSPlugin.java

@@ -0,0 +1,110 @@
+package com.ym.mec.thirdparty.message.vendors;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.thirdparty.message.MessageSenderPlugin;
+import com.ym.mec.util.http.HttpUtil;
+
+/**
+ * MO信通短信验证码接口
+ */
+@Service
+public class MOxintongSMSPlugin implements MessageSenderPlugin, InitializingBean {
+
+	private static ObjectMapper MAPPER = new ObjectMapper();
+
+	@Value("${Moxintong.username:1}")
+	private String username;
+	
+	@Value("${Moxintong.pwd:1}")
+	private String pwd;
+	
+	@Value("${Moxintong.reqUrl:1}")
+	private String reqUrl;
+
+	@Override
+	public boolean send(String subject, String content, String receiver, String url) throws IOException {
+		Map<String, Object> reqParams = new HashMap<String, Object>();
+		reqParams.put("username", username);
+		reqParams.put("pwd", pwd);
+		reqParams.put("mobile", receiver);
+		reqParams.put("content", "【袋鼠卡】" + content);
+
+		String result = "";
+		try {
+			result = HttpUtil.postForHttps(reqUrl, reqParams);
+		} catch (Exception e) {
+			throw new ThirdpartyException("短信发送失败!", e);
+		}
+		HashMap jsonObject = MAPPER.readValue(result, HashMap.class);
+		if (jsonObject.get("code").toString().equals("0")) {
+			return true;
+		} else {
+			throw new ThirdpartyException(jsonObject.get("msg").toString());
+		}
+	}
+
+	@Override
+	public boolean batchSend(String subject, String content, String[] receivers, String url) throws IOException {
+		StringBuilder stringBuilder = new StringBuilder();
+		for (int i = 0; i < receivers.length - 1; i++) {
+			stringBuilder.append(receivers[i]).append(",");
+		}
+		stringBuilder.append(receivers[receivers.length - 1]);
+
+		Map<String, Object> reqParams = new HashMap<String, Object>();
+		reqParams.put("username", username);
+		reqParams.put("pwd", pwd);
+		reqParams.put("mobile", stringBuilder.toString());
+		reqParams.put("content", "【兰鲸分期】" + content);
+
+		String result = "";
+		try {
+			result = HttpUtil.postForHttps(reqUrl, reqParams);
+		} catch (Exception e) {
+			throw new ThirdpartyException("短信发送失败!", e);
+		}
+		HashMap jsonObject = MAPPER.readValue(result, HashMap.class);
+		if (jsonObject.get("code").toString().equals("0")) {
+			return true;
+		} else {
+			throw new ThirdpartyException(jsonObject.get("msg").toString());
+		}
+	}
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		// 参数检查
+		if (StringUtils.isBlank(reqUrl)) {
+			throw new RuntimeException("Init parameter [reqUrl] can not blank");
+		}
+		if (StringUtils.isBlank(username)) {
+			throw new RuntimeException("Init parameter [username] can not blank");
+		}
+		if (StringUtils.isBlank(pwd)) {
+			throw new RuntimeException("Init parameter [pwd] can not blank");
+		}
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public void setPwd(String pwd) {
+		this.pwd = pwd;
+	}
+
+	public void setReqUrl(String reqUrl) {
+		this.reqUrl = reqUrl;
+	}
+
+}

+ 120 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/message/vendors/ShiyuanSMSPlugin.java

@@ -0,0 +1,120 @@
+package com.ym.mec.thirdparty.message.vendors;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.thirdparty.message.MessageSenderPlugin;
+import com.ym.mec.util.http.HttpUtil;
+
+/**
+ * 示远短信验证码接口
+ */
+@Service
+public class ShiyuanSMSPlugin implements MessageSenderPlugin, InitializingBean {
+	/**
+	 * 示远请求地址
+	 */
+	@Value("${sms.shiyuan.reqURL:1}")
+	private String reqURL;
+	/**
+	 * 示远账号
+	 */
+	@Value("${sms.shiyuan.account:1}")
+	private String account;
+	/**
+	 * 示远密码
+	 */
+	@Value("${sms.shiyuan.pwd:1}")
+	private String pswd;
+
+	// private boolean needstatus = true;//是否需要状态报告,需要true,不需要false
+	// private String product = "";//产品ID(不用填写)
+	// private String extno = "";//扩展码(不用填写)
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		// 参数检查
+		if (StringUtils.isBlank(reqURL)) {
+			throw new RuntimeException("Init parameter [reqURL] can not blank");
+		}
+		if (StringUtils.isBlank(account)) {
+			throw new RuntimeException("Init parameter [account] can not blank");
+		}
+		if (StringUtils.isBlank(pswd)) {
+			throw new RuntimeException("Init parameter [pswd] can not blank");
+		}
+	}
+
+	public void setReqURL(String reqURL) {
+		this.reqURL = reqURL;
+	}
+
+	public void setAccount(String account) {
+		this.account = account;
+	}
+
+	public void setPswd(String pswd) {
+		this.pswd = pswd;
+	}
+
+	@Override
+	public boolean send(String subject, String content, String receiver, String url) throws IOException {
+		try {
+			Map<String, Object> reqParams = new HashMap<String, Object>();
+			reqParams.put("account", account);
+			reqParams.put("pswd", pswd);
+			reqParams.put("mobile", receiver);
+			reqParams.put("msg", content);
+			reqParams.put("needstatus", true);
+			reqParams.put("product", "");
+			reqParams.put("extno", "");
+			reqParams.put("resptype", "json");
+			String resultParams = HttpUtil.postForHttp(reqURL, reqParams);
+			JSONObject jsonObject = JSONObject.parseObject(resultParams);
+			if (jsonObject.get("result").equals("0")) {
+				return true;
+			}
+		} catch (Exception e) {
+			throw new ThirdpartyException("Failed to invoke shiyuan service", e);
+		}
+		return false;
+	}
+
+	@Override
+	public boolean batchSend(String subject, String content, String[] receivers, String url) throws IOException {
+		StringBuilder stringBuilder = new StringBuilder("");
+		for (int i = 0; i < receivers.length - 1; i++) {
+			stringBuilder.append(receivers[i]).append(",");
+		}
+		stringBuilder.append(receivers[receivers.length - 1]);
+		try {
+			Map<String, Object> reqParams = new HashMap<>();
+			reqParams.put("account", account);
+			reqParams.put("pswd", pswd);
+			reqParams.put("mobile", stringBuilder.toString().trim());
+			reqParams.put("msg", content);
+			reqParams.put("needstatus", true);
+			reqParams.put("product", "");
+			reqParams.put("extno", "");
+			reqParams.put("resptype", "json");
+			// 发起请求
+			String resultParams = HttpUtil.postForHttp(reqURL, reqParams);
+			JSONObject jsonObject = JSONObject.parseObject(resultParams);
+			if (jsonObject.get("result").equals("0")) {
+				return true;
+			}
+			throw new ThirdpartyException("示远科技短信验证码发送失败");
+		} catch (Exception e) {
+			throw new ThirdpartyException("Failed to invoke shiyuan service", e);
+		}
+	}
+
+}

+ 19 - 9
mec-util/pom.xml

@@ -19,20 +19,30 @@
 			<groupId>org.apache.commons</groupId>
 			<artifactId>commons-lang3</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>commons-beanutils</groupId>
 			<artifactId>commons-beanutils</artifactId>
 		</dependency>
 
-			<dependency>
-				<groupId>com.google.zxing</groupId>
-				<artifactId>core</artifactId>
-			</dependency>
+		<dependency>
+			<groupId>com.google.zxing</groupId>
+			<artifactId>core</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.zxing</groupId>
+			<artifactId>javase</artifactId>
+		</dependency>
 
-			<dependency>
-				<groupId>com.google.zxing</groupId>
-				<artifactId>javase</artifactId>
-			</dependency>
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpclient</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.httpcomponents</groupId>
+			<artifactId>httpmime</artifactId>
+		</dependency>
 	</dependencies>
 </project>

+ 0 - 53
mec-util/src/main/java/com/ym/mec/util/codec/MD5Util.java

@@ -1,53 +0,0 @@
-package com.ym.mec.util.codec;
-
-import java.security.MessageDigest;
-
-public class MD5Util {
-
-	private static String byteArrayToHexString(byte b[]) {
-		StringBuffer resultSb = new StringBuffer();
-		for (int i = 0; i < b.length; i++)
-			resultSb.append(byteToHexString(b[i]));
-
-		return resultSb.toString();
-	}
-
-	private static String byteToHexString(byte b) {
-		int n = b;
-		if (n < 0)
-			n += 256;
-		int d1 = n / 16;
-		int d2 = n % 16;
-		return hexDigits[d1] + hexDigits[d2];
-	}
-
-	public static String encode(String origin) {
-		String resultString = null;
-		try {
-			resultString = new String(origin);
-			MessageDigest md = MessageDigest.getInstance("MD5");
-			resultString = byteArrayToHexString(md.digest(resultString.getBytes("UTF-8")));
-		} catch (Exception exception) {
-		}
-		return resultString;
-	}
-	
-	public static String encode(byte[] origin) {
-		String resultString = null;
-		try {
-			MessageDigest md = MessageDigest.getInstance("MD5");
-			resultString = byteArrayToHexString(md.digest(origin));
-		} catch (Exception exception) {
-		}
-		return resultString;
-	}
-
-	
-
-	private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
-	
-	public static void main(String[] args) {
-		System.out.println(byteArrayToHexString("123456".getBytes()));
-	}
-
-}

+ 1 - 1
mec-util/src/main/java/com/yqh/p2p/utils/codec/NumEncodeUtil.java → mec-util/src/main/java/com/ym/mec/util/codec/NumEncodeUtil.java

@@ -1,4 +1,4 @@
-package com.yqh.p2p.utils.codec;
+package com.ym.mec.util.codec;
 
 /**
  * 62进制数字

+ 160 - 0
mec-util/src/main/java/com/ym/mec/util/compress/GZipUtil.java

@@ -0,0 +1,160 @@
+package com.ym.mec.util.compress;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * 工具类,GZIP解压缩工具 <br>
+ * Copyright <a href="http://www.erayt.com/" target="_blank">erayt.com</a>(c)<br>
+ * 
+ * @author GuoZheyong
+ * @version 2011-7-15
+ */
+public class GZipUtil {
+	/**
+	 * 数组初始长度
+	 */
+	private static final int BYTE_ARRAY_INITIAL_SIZE = 1024;
+
+	/**
+	 * 压缩
+	 * 
+	 * @param data
+	 *            原始数据
+	 * @return 压缩后数据
+	 * @throws IOException
+	 *             如果发生 I/O 错误
+	 */
+	public static byte[] gzipBytes(byte[] data) throws IOException {
+		ByteArrayOutputStream baos = null;
+		GZIPOutputStream gos = null;
+		try {
+			baos = new ByteArrayOutputStream(BYTE_ARRAY_INITIAL_SIZE);
+			// 建立gzip压缩输出流
+			gos = new GZIPOutputStream(baos);
+			// 压缩数据
+			gos.write(data);
+			gos.finish();
+			// 返回压缩字节流
+			return baos.toByteArray();
+		} finally {
+			if (gos != null) {
+				gos.close();
+			}
+			if (baos != null) {
+				baos.close();
+			}
+		}
+	}
+
+	/**
+	 * 解压
+	 * 
+	 * @param data
+	 *            压缩数据
+	 * @return 解压后数据
+	 * @throws IOException
+	 *             如果发生 I/O 错误
+	 */
+	public static byte[] gunzipBytes(byte[] data) throws IOException {
+		if (data == null || data.length == 0) {
+			return null;
+		}
+		ByteArrayInputStream bais = null;
+		GZIPInputStream gis = null;
+		ByteArrayOutputStream bos = null;
+		try {
+			bais = new ByteArrayInputStream(data);
+			// 建立gzip压缩输入流
+			gis = new GZIPInputStream(bais);
+			// 返回解压字节流
+			bos = new ByteArrayOutputStream();
+			byte[] buffer = new byte[BYTE_ARRAY_INITIAL_SIZE];
+			int n = 0;
+			while (-1 != (n = gis.read(buffer))) {
+				bos.write(buffer, 0, n);
+			}
+			return bos.toByteArray();
+		} finally {
+			if (bos != null) {
+				bos.close();
+			}
+			if (gis != null) {
+				gis.close();
+			}
+			if (bais != null) {
+				bais.close();
+			}
+		}
+	}
+
+	public static byte[] File2byte(String filePath) {
+		byte[] buffer = null;
+		try {
+			File file = new File(filePath);
+			FileInputStream fis = new FileInputStream(file);
+			ByteArrayOutputStream bos = new ByteArrayOutputStream();
+			byte[] b = new byte[1024];
+			int n;
+			while ((n = fis.read(b)) != -1) {
+				bos.write(b, 0, n);
+			}
+			fis.close();
+			bos.close();
+			buffer = bos.toByteArray();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return buffer;
+	}
+
+	public static void byte2File(byte[] buf, String filePath, String fileName) {
+		BufferedOutputStream bos = null;
+		FileOutputStream fos = null;
+		File file = null;
+		try {
+			File dir = new File(filePath);
+			if (!dir.exists() && dir.isDirectory()) {
+				dir.mkdirs();
+			}
+			file = new File(filePath + File.separator + fileName);
+			fos = new FileOutputStream(file);
+			bos = new BufferedOutputStream(fos);
+			bos.write(buf);
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			if (bos != null) {
+				try {
+					bos.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if (fos != null) {
+				try {
+					fos.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+
+	public static void main(String[] args) throws Exception{
+		byte[] fileBytes = File2byte("D:\\anypipe\\anypipe20150714.zip");
+		byte[] gzipBytes = gunzipBytes(fileBytes);
+		byte2File(gzipBytes,"D:\test","test");
+	}
+
+}

+ 214 - 0
mec-util/src/main/java/com/ym/mec/util/compress/ZipUtil.java

@@ -0,0 +1,214 @@
+/**
+ * 
+ */
+package com.ym.mec.util.compress;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.ym.mec.util.exception.UtilException;
+
+/**
+ * 工具类,Zip解压缩类 <br>
+ * Copyright <a href="http://www.erayt.com/" target="_blank">erayt.com</a>(c)<br>
+ * 
+ * @author GuoZheyong
+ * @version 2011-7-15
+ */
+public final class ZipUtil {
+
+	private final static Logger LOGGER = LoggerFactory.getLogger(ZipUtil.class);
+
+	private static final int BUFFER = 2048;
+
+	private static ZipUtil util = new ZipUtil();
+
+	/**
+	 * 获取ZipUtil单例
+	 * 
+	 * @return 实例
+	 */
+	public static ZipUtil getInstance() {
+		return util;
+	}
+
+	private ZipOutputStream out;
+
+	private ZipUtil() {
+	}
+
+	/**
+	 * 压缩单个文件或文件夹
+	 * 
+	 * @param fromFile
+	 *            待压缩文件,fromFile是绝对路径
+	 * @param toFile
+	 *            压缩文件,toFile是绝对路径
+	 * @throws IOException
+	 *             如果发生 I/O 错误
+	 */
+	public void zipDirectoryOrFile(String fromFile, String toFile) throws IOException {
+		try {
+			init(toFile);
+			File file = new File(fromFile);
+			writeEntry(out, file, "");
+		} finally {
+			destroy();
+		}
+	}
+
+	/**
+	 * 压缩多个文件或文件夹
+	 * 
+	 * @param fromFile
+	 *            待压缩文件数组
+	 * @param toFile
+	 *            压缩文件
+	 * @throws IOException
+	 *             如果发生 I/O 错误
+	 */
+	public void zipMultiFile(String fromFile[], String toFile) throws IOException {
+		try {
+			init(toFile);
+			File file = null;
+			for (int i = 0; i < fromFile.length; i++) {
+				file = new File(fromFile[i]);
+				writeEntry(out, file, "");
+			}
+		} finally {
+			destroy();
+		}
+	}
+
+	private void init(String toFile) {
+		try {
+			LOGGER.info("compress " + toFile);
+			FileOutputStream fos = new FileOutputStream(toFile);
+			out = new ZipOutputStream(new BufferedOutputStream(fos));
+		} catch (FileNotFoundException e) {
+			LOGGER.warn("初始化得到zip文件异常", e);
+			throw new UtilException(e.getMessage(), e);
+		}
+	}
+
+	private void destroy() throws IOException {
+		if (out != null) {
+			out.close();
+		}
+	}
+
+	private void writeEntry(ZipOutputStream zos, File srcFile, String baseURL) throws IOException {
+
+		baseURL = baseURL == null || baseURL.length() == 0 ? srcFile.getName() : baseURL + "/" + srcFile.getName();
+		if (srcFile.isDirectory()) {
+			File[] files = srcFile.listFiles();
+			if (files != null && files.length > 0) {
+				for (File f : files) {
+					writeEntry(zos, f, baseURL);
+				}
+			} else {
+				zos.putNextEntry(new ZipEntry(baseURL + "/"));
+			}
+		} else {
+			zos.putNextEntry(new ZipEntry(baseURL));
+
+			FileInputStream fileInputStream = null;
+			try {
+				// 读数据
+				fileInputStream = new FileInputStream(srcFile);
+				byte[] bytes = new byte[BUFFER];
+				int length = -1;
+				while ((length = fileInputStream.read(bytes)) != -1) {
+					zos.write(bytes, 0, length);
+				}
+			} finally {
+				if (fileInputStream != null) {
+					fileInputStream.close();
+				}
+			}
+		}
+	}
+
+	/**
+	 * 解压zip包
+	 * @param inputStream
+	 * @param outputFolder
+	 * @return
+	 * @throws IOException
+	 */
+	public static List<File> unCompressZipFile(InputStream inputStream, String outputFolder) {
+		List<File> files = new ArrayList<File>();
+		ZipInputStream zis = null;
+		try {
+			Charset utf = Charset.forName("utf-8");
+			zis = new ZipInputStream(inputStream, utf);
+			ZipEntry entry;
+			while ((entry = zis.getNextEntry()) != null) {
+				String encoding = System.getProperty("file.encoding");
+				String fileName = new String(entry.getName().getBytes("GBK"), encoding);
+				File entryFile = new File(outputFolder, fileName);
+				if (entry.isDirectory()) {
+					if (entryFile.exists()) {
+						throw new UtilException("目录已存在", entryFile);
+					} else {
+						entryFile.mkdirs();
+					}
+				} else {
+					if (entryFile.getParentFile() != null && !entryFile.getParentFile().exists()) {
+						entryFile.getParentFile().mkdirs();
+					}
+					if (!entryFile.exists()) {
+						entryFile.createNewFile();
+					}
+					OutputStream os = null;
+					try {
+						os = new FileOutputStream(entryFile);
+						IOUtils.copy(zis, os);
+					} finally {
+						IOUtils.closeQuietly(os);
+						zis.closeEntry();
+					}
+				}
+				files.add(entryFile);
+			}
+		} catch (Exception e) {
+			throw new UtilException("解压失败", e);
+		} finally {
+			IOUtils.closeQuietly(zis);
+		}
+		return files;
+	}
+
+	 public static void main(String [] args) throws IOException
+	 {
+	 final String INPUT_ZIP_FILE = "d:/anypipe/测试.zip";
+	 String OUTPUT_FOLDER = "d:/test-gzip/anypipe";
+	
+	 File file = new File(INPUT_ZIP_FILE);
+	 InputStream inputStream = new FileInputStream(file);
+	
+	 OUTPUT_FOLDER += File.separator + file.getName();
+	
+	 unCompressZipFile(inputStream, OUTPUT_FOLDER);
+	
+	 /*File file = new File(OUTPUT_FOLDER);
+	 FileUtil.deleteFolder(file);*/
+	 }
+
+}

+ 436 - 0
mec-util/src/main/java/com/ym/mec/util/http/HttpUtil.java

@@ -0,0 +1,436 @@
+package com.ym.mec.util.http;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+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 com.ym.mec.util.compress.ZipUtil;
+
+public class HttpUtil {
+
+	/**
+	 * POST请求http url
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 */
+	public static String postForHttp(String url, Map<String, Object> parameterMap) throws IOException {
+		String result = null;
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpPost httpPost = new HttpPost(url);
+		try {
+			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						nameValuePairs.add(new BasicNameValuePair(name, value));
+					}
+				}
+			}
+			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * POST请求https url
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 * @throws NoSuchAlgorithmException 
+	 * @throws KeyManagementException 
+	 * @throws KeyStoreException 
+	 */
+	public static String postForHttps(String url, Map<String, Object> parameterMap) throws IOException, NoSuchAlgorithmException, KeyManagementException,
+			KeyStoreException {
+		String result = null;
+		CloseableHttpClient httpClient = SimpleHttpsClient.getInstance();
+
+		HttpPost httpPost = new HttpPost(url);
+		try {
+			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						nameValuePairs.add(new BasicNameValuePair(name, value));
+					}
+				}
+			}
+			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * POST请求https url
+	 * 
+	 * @param url
+	 *            URL
+	 * @param json
+	 *            请求参数
+	 * @param headers
+	 *            请求头参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 * @throws NoSuchAlgorithmException 
+	 * @throws KeyManagementException 
+	 * @throws KeyStoreException 
+	 */
+	public static String postForHttps(String url, String json, Map<String, String> headers) throws IOException, NoSuchAlgorithmException,
+			KeyManagementException, KeyStoreException {
+		String result = null;
+		CloseableHttpClient httpClient = SimpleHttpsClient.getInstance();
+
+		HttpPost httpPost = new HttpPost(url);
+		if (headers != null && headers.size() > 0) {
+			for (Entry<String, String> entry : headers.entrySet()) {
+				httpPost.setHeader(entry.getKey(), entry.getValue());
+			}
+		}
+		try {
+			httpPost.setEntity(new StringEntity(json, "UTF-8"));
+
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * 带附件的方法
+	 * @param url
+	 * @param parameterMap
+	 * @param filePath
+	 * @return
+	 * @throws IOException
+	 * @throws NoSuchAlgorithmException
+	 * @throws KeyManagementException
+	 * @throws KeyStoreException
+	 */
+	public static String postForHttps(String url, Map<String, Object> parameterMap, String filePath) throws IOException, NoSuchAlgorithmException,
+			KeyManagementException, KeyStoreException {
+		File file = new File(filePath);
+		String result = null;
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpPost httpPost = new HttpPost(url);
+		MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+		try {
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						builder.addTextBody(name, value);
+					}
+				}
+			}
+			builder.addBinaryBody(file.getName(), file, ContentType.create("application/zip"), file.getName() + ".zip");
+			httpPost.setEntity(builder.build());
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * post请求
+	 * @param url 请求地址
+	 * @param parameter 参数
+	 * @param headers 头信息
+	 * @param fileMap 附件
+	 * @param contentType 附件的类型
+	 * @return
+	 * @throws IOException
+	 * @throws NoSuchAlgorithmException
+	 * @throws KeyManagementException
+	 * @throws KeyStoreException
+	 */
+	public static String postForHttps(String url, Map<String, Object> parameterMap, Map<String, String> headers, Map<String, File> fileMap,
+			ContentType contentType) throws IOException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
+		String result = null;
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpPost httpPost = new HttpPost(url);
+		if (headers != null && headers.size() > 0) {
+			for (Entry<String, String> entry : headers.entrySet()) {
+				httpPost.setHeader(entry.getKey(), entry.getValue());
+			}
+		}
+		MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+		try {
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
+						builder.addTextBody(name, value, ContentType.create("text/plain", Charset.forName("UTF-8")));
+					}
+				}
+			}
+
+			File file = null;
+			if (fileMap != null && fileMap.size() > 0) {
+				for (Entry<String, File> entry : fileMap.entrySet()) {
+					file = entry.getValue();
+					if (file != null) {
+						builder.addBinaryBody(entry.getKey(), file, contentType, file.getName());
+					}
+				}
+			}
+			httpPost.setEntity(builder.build());
+
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * GET请求
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 */
+	public static String get(String url, Map<String, Object> parameterMap) throws IOException {
+		return get(url, parameterMap, null);
+	}
+
+	/**
+	 * GET请求
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @param headers
+	 *            请求头
+	 * @return 返回结果
+	 * @throws IOException 
+	 */
+	public static String get(String url, Map<String, Object> parameterMap, Map<String, String> headers) throws IOException {
+		String result = null;
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+		HttpGet httpGet = null;
+		try {
+			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						nameValuePairs.add(new BasicNameValuePair(name, value));
+					}
+				}
+			}
+			httpGet = new HttpGet(url + (StringUtils.contains(url, "?") ? "&" : "?") + EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")));
+			if (headers != null && headers.size() > 0) {
+				for (Entry<String, String> entry : headers.entrySet()) {
+					httpGet.setHeader(entry.getKey(), entry.getValue());
+				}
+			}
+			HttpResponse httpResponse = httpClient.execute(httpGet);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			result = EntityUtils.toString(httpEntity, "UTF-8");
+			EntityUtils.consume(httpEntity);
+		} finally {
+			if (httpGet != null) {
+				httpGet.releaseConnection();
+			}
+			httpClient.close();
+		}
+		return result;
+	}
+
+	/**
+	 * POST请求https url
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 * @throws NoSuchAlgorithmException 
+	 * @throws KeyManagementException 
+	 * @throws KeyStoreException 
+	 */
+	public static boolean downLoadPostForHttps(String url, Map<String, String> headerMap, Map<String, Object> parameterMap, String filePath)
+			throws IOException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+
+		HttpPost httpPost = new HttpPost(url);
+		if (headerMap != null) {
+			for (Entry<String, String> entry : headerMap.entrySet()) {
+				httpPost.addHeader(entry.getKey(), entry.getValue());
+			}
+		}
+		try {
+			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						nameValuePairs.add(new BasicNameValuePair(name, value));
+					}
+				}
+			}
+			httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
+			HttpResponse httpResponse = httpClient.execute(httpPost);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			InputStream is = httpEntity.getContent();
+
+			File file = new File(filePath);
+			file.getParentFile().mkdirs();
+
+			FileOutputStream fileout = new FileOutputStream(file);
+
+			IOUtils.copy(is, fileout);
+			is.close();
+			fileout.flush();
+			fileout.close();
+
+			EntityUtils.consume(httpEntity);
+		} finally {
+			httpPost.releaseConnection();
+			httpClient.close();
+		}
+		return true;
+	}
+
+	/**
+	 * POST请求https url
+	 * 
+	 * @param url
+	 *            URL
+	 * @param parameterMap
+	 *            请求参数
+	 * @return 返回结果
+	 * @throws IOException 
+	 * @throws NoSuchAlgorithmException 
+	 * @throws KeyManagementException 
+	 * @throws KeyStoreException 
+	 */
+	public static boolean downLoadZipGetForHttps(String url, Map<String, String> headerMap, Map<String, Object> parameterMap, String filePath)
+			throws IOException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
+		CloseableHttpClient httpClient = HttpClients.createDefault();
+
+		HttpGet httpGet = null;
+		try {
+			List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
+			if (parameterMap != null) {
+				for (Entry<String, Object> entry : parameterMap.entrySet()) {
+					String name = entry.getKey();
+					String value = ConvertUtils.convert(entry.getValue());
+					if (StringUtils.isNotEmpty(name)) {
+						nameValuePairs.add(new BasicNameValuePair(name, value));
+					}
+				}
+			}
+			httpGet = new HttpGet(url + (StringUtils.contains(url, "?") ? "&" : "?") + EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")));
+			if (headerMap != null) {
+				for (Entry<String, String> entry : headerMap.entrySet()) {
+					httpGet.addHeader(entry.getKey(), entry.getValue());
+				}
+			}
+			HttpResponse httpResponse = httpClient.execute(httpGet);
+			HttpEntity httpEntity = httpResponse.getEntity();
+			InputStream is = httpEntity.getContent();
+
+			File file = new File(filePath);
+			file.getParentFile().mkdirs();
+
+			List<File> files = ZipUtil.unCompressZipFile(is, file.getParent());
+			List<String> listFile = new ArrayList<String>();
+			for (File f : files) {
+				listFile.add(f.getPath());
+			}
+
+			ZipUtil zipUtil = ZipUtil.getInstance();
+			zipUtil.zipMultiFile(listFile.toArray(new String[listFile.size()]), filePath);
+
+			EntityUtils.consume(httpEntity);
+
+			for (File f : files) {
+				FileUtils.deleteQuietly(f);
+			}
+		} finally {
+			if (httpGet != null) {
+				httpGet.releaseConnection();
+			}
+			httpClient.close();
+		}
+		return true;
+	}
+}

+ 38 - 0
mec-util/src/main/java/com/ym/mec/util/http/SimpleHttpsClient.java

@@ -0,0 +1,38 @@
+package com.ym.mec.util.http;
+
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.TrustStrategy;
+
+public class SimpleHttpsClient {
+
+	public static CloseableHttpClient getInstance() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
+		SSLContextBuilder builder = new SSLContextBuilder();
+		builder.useProtocol("TLSv1.2");
+
+		builder.loadTrustMaterial(null, new TrustStrategy() {
+
+			@Override
+			public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+				return true;
+			}
+		});
+
+		SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), NoopHostnameVerifier.INSTANCE);
+
+		CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(new BasicCookieStore()).setSSLSocketFactory(sslsf).build();
+
+		return httpClient;
+	}
+
+}

+ 1 - 1
mec-util/src/main/java/com/ym/mec/util/upload/UploadUtil.java

@@ -13,8 +13,8 @@ import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 
+import com.ym.mec.util.codec.NumEncodeUtil;
 import com.ym.mec.util.exception.UtilException;
-import com.yqh.p2p.utils.codec.NumEncodeUtil;
 
 /** 
  * @author sunzl