Browse Source

统计代码提交

chenweida 8 years ago
parent
commit
9f5b6e4c99

+ 15 - 48
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -8,7 +8,11 @@ import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -134,54 +138,17 @@ public class HttpUtil {
//		param.put("type", msgType);
//		param.put("title", title);
//		param.put("data", data);
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			String url = SystemConf.getInstance().getMsgPushServer() + "?to_uid=" + receiver + "&content=" + msg + "&type=" + msgType + "&title=" + title + "&data=" + data;
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("GET");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/json");
//			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
//			osw.write(param.toString());
//			osw.flush();
			// 读取返回内容
			StringBuffer buffer = new StringBuffer();
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
			System.out.println(buffer.toString());
			JSONObject json = new JSONObject(buffer.toString());
			if (json.getInt("errno") == 0) {
				// 成功
				return true;
			} else {
				// 失败
				return false;
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		try{
			List<NameValuePair> params = new ArrayList<>();
			params.add(new BasicNameValuePair("to", receiver));
			params.add(new BasicNameValuePair("content", msg));
			params.add(new BasicNameValuePair("contentType", msgType));
			params.add(new BasicNameValuePair("title", title));
			params.add(new BasicNameValuePair("summary", data));
			String response = HttpClientUtil.post(SystemConf.getInstance().getMsgPushServer(), params, "UTF-8");
			return true;
		}catch (Exception e){
			e.printStackTrace();
		}
		return false;
	}

+ 2 - 2
patient-co-wlyy/src/main/resources/system.properties

@ -83,8 +83,8 @@ im_list_get=http://192.168.131.101:3000/
#----------------淏宒遠噫怹數巹キ埮覃蚚諉諳華硊-------------------#
#sign_check_upload=http://59.61.92.90:8072/wlyy_service
im_group_server=http://120.41.252.108:3031/group/sendgroupmsg.im
msg_push_server=http://120.41.252.108:3031/push/sendmsg.im
im_group_server=http://120.41.252.108:3031/api/v1/chats/gm
msg_push_server=http://120.41.252.108:3031/api/v1/chats/sm
weixin_websocket_server = http://172.19.103.76:8000/user/senddata.do
#file upload temp path