Преглед на файлове

Merge branch 'dev' of lyr/patient-co-management into dev

chenweida преди 8 години
родител
ревизия
4ccb2ff61b

+ 4 - 0
src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -23,6 +23,7 @@ import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.util.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -332,6 +333,9 @@ public class ConsultTeamService extends ConsultService {
				consultTeamDao.increasePatientRead(log.getConsult());
				// 医生有回复
				consultTeamDoctorDao.updateReply(log.getConsult(), teamOrDoctor);
				//shenzaixin v1.2.0 推送消息给患者
				HttpUtil.sendWeixinWebsocketMsg(patient,"data={busiType:'qianyuezixun',msgid:'"+log.getId()+"'}");
			} else if (type == 0 || type == 2) {
				// 查询相关联的医生
				Iterable<ConsultTeamDoctor> iterable = consultTeamDoctorDao.findByConsult(log.getConsult());

+ 89 - 36
src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -22,7 +22,7 @@ public class HttpUtil {
	/**
	 * 向指定URL发送GET方法的请求
	 * 
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
@ -65,7 +65,7 @@ public class HttpUtil {
	/**
	 * 向指定 URL 发送POST方法的请求
	 * 
	 *
	 * @param url
	 *            发送请求的 URL带上参数
	 * @param param
@ -73,38 +73,38 @@ public class HttpUtil {
	 * @return 所代表远程资源的响应结果
	 */
	public static String sendPost(String url, String param) {
					StringBuffer buffer = new StringBuffer();
					PrintWriter out = null;
					BufferedReader in = null;
					HttpURLConnection conn = null;
					try {
						URL realUrl = new URL(url);
						// 打开和URL之间的连接
						conn = (HttpURLConnection) realUrl.openConnection();
						conn.setRequestMethod("POST");
						conn.setDoOutput(true);
						conn.setDoInput(true);
						conn.setUseCaches(false);
						conn.setRequestProperty("Content-Type", "application/text");
						conn.setRequestProperty("accept", "*/*");
						conn.setRequestProperty("connection", "Keep-Alive");
						conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
						OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
						osw.write(param.toString());
						osw.flush();
						// 读取返回内容
						BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
						String temp;
						while ((temp = br.readLine()) != null) {
							buffer.append(temp);
							buffer.append("\n");
						}
					} catch (Exception e) {
						logger.error("push message error:", e);
					} finally {
						try {
							if (out != null) {
		StringBuffer buffer = new StringBuffer();
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("POST");
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/text");
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
			osw.write(param.toString());
			osw.flush();
			// 读取返回内容
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
@ -119,7 +119,7 @@ public class HttpUtil {
	/**
	 * 消息推送
	 * 
	 *
	 * @param receiver 消息接收人
	 * @param msgType 消息类型
	 * @param title 消息标题
@ -185,9 +185,62 @@ public class HttpUtil {
		return false;
	}
	/**
	 * 发送消息到websocket服务器,然后由websocket服务器中转给微信端
	 * @param userid 接收数据的患者id
	 * @param data 内容
	 * @return 推送成功:{"errno":"0","errmsg":""},推送失败:{"errno":"1","errmsg":"User is not online"}
	 * @author shenzaixin
	 */
	public static String sendWeixinWebsocketMsg(String userid,String data){
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			String url = SystemConf.getInstance().getWeixinWebsocketServer() + "?userid=" + userid + "&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);
			}
			System.out.println(buffer.toString());
			JSONObject json = new JSONObject(buffer.toString());
			return json.toString();
		} catch (Exception e) {
			logger.error("push message error:", e);
			return "{\"errno\":\"1\",\"errmsg\":\""+e.getMessage()+"\"}";
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
	}
	/**
	 * 向指定 URL 发送POST方法的请求
	 * 
	 *
	 * @param url 发送请求的 URL带上参数
	 * @param param POST参数。
	 * @param charset 编码格式

+ 8 - 0
src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -21,6 +21,10 @@ public class SystemConf {
	// 消息推送服务器地址
	private static final String MSG_PUSH_SERVER = "msg_push_server";
	//微信端websocket服务地址
	private static final String WEIXIN_WEBSOCKET_SERVER = "weixin_websocket_server";
	// 服务器地址
	private static final String SERVER_URL = "server_url";
	// 图片资源服务器地址
@ -245,6 +249,10 @@ public class SystemConf {
		return getSystemProperties().getProperty(MSG_PUSH_SERVER);
	}
	public String getWeixinWebsocketServer() {
		return getSystemProperties().getProperty(WEIXIN_WEBSOCKET_SERVER);
	}
	public String getServerUrlStr() {
		String temp = getSystemProperties().getProperty(SERVER_URL);
		if (StringUtils.isEmpty(temp)) {

+ 1 - 0
src/main/resources/system.properties

@ -74,6 +74,7 @@ wechat_token=27eb3bb24f149a7760cf1bb154b08040
im_group_server=http://120.41.252.108:3031/group/sendgroupmsg.im
msg_push_server=http://120.41.252.108:3031/push/sendmsg.im
weixin_websocket_server = http://172.19.103.76:8000/user/senddata.do
#file upload temp path
upload_temp_path=/var/local/temp