Kaynağa Gözat

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

lyr 8 yıl önce
ebeveyn
işleme
613767a4b7

+ 0 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -24,9 +24,6 @@ public class PatientInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		if(flag){
			return true;
		}
		try {
			if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")){
				return true;

+ 10 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -760,7 +760,7 @@ public class ConsultTeamService extends ConsultService {
        messages.put("senderId",patient);
        messages.put("senderName",tempPatient.getName());
        users.put(patient,0);
        JSONObject obj  = createTopics(patient,consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages);
        JSONObject obj  = createTopics(UUID.randomUUID().toString(),consult.getCode(),"咨询问题:"+consult.getSymptoms(),users,messages,"1");
        if(obj==null){
            throw new RuntimeException("IM消息结束异常!");
        }
@ -771,6 +771,8 @@ public class ConsultTeamService extends ConsultService {
        return 1;
    }
    /**
     * 发送消息给IM
     *
@ -797,14 +799,15 @@ public class ConsultTeamService extends ConsultService {
     * @param topicName  议题名称
     * @param participants 成员
     */
    private JSONObject createTopics(String sessionId, String topicId,String topicName, JSONObject participants,JSONObject messages) {
    private JSONObject createTopics(String sessionId, String topicId,String topicName, JSONObject participants,JSONObject messages,String sessionType) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions/"+sessionId+"/topics";
        JSONObject params = new JSONObject();
        params.put("topicId", topicId);
        params.put("topicName", topicName);
        params.put("topic_id", topicId);
        params.put("topic_name", topicName);
        params.put("participants", participants.toString());
        params.put("messages", messages.toString());
        params.put("sessionId", sessionId);;
        params.put("session_id", sessionId);
        params.put("session_type", sessionType);
        String ret = HttpClientUtil.postBody(imAddr,params);
        JSONObject obj  = null;
        try{
@ -1286,7 +1289,7 @@ public class ConsultTeamService extends ConsultService {
        messages.put("description",consult.getSymptoms());
        messages.put("title",consult.getTitle());
        messages.put("img",consult.getImages());
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),consult.getSymptoms(),jsonObject,messages);
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),consult.getSymptoms(),jsonObject,messages,"2");
        if(obj==null){
            throw new RuntimeException("im消息创建异常!");
        }
@ -1403,7 +1406,7 @@ public class ConsultTeamService extends ConsultService {
        jsonObject.put(ct.getPatient(),0);
        jsonObject.put(ct.getDoctor(),0);
        //设置消息ID
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),"咨询求助:"+doctorTemp.getName(),jsonObject,messages);
        JSONObject obj = createTopics(String.valueOf(jsonObject.hashCode()),consult.getCode(),"咨询求助:"+doctorTemp.getName(),jsonObject,messages,"2");
        if(obj==null){
            throw new RuntimeException("im消息创建异常!");
        }

+ 46 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -132,20 +132,11 @@ public class HttpUtil {
	 * @param data 消息数据
	 */
	public static boolean pushMessage(String receiver, String msgType, String title, String msg, String data) {
//		JSONObject param = new JSONObject();
//		param.put("to_uid", receiver);
//		param.put("content", msg);
//		param.put("type", msgType);
//		param.put("title", title);
//		param.put("data", data);
		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");
			JSONObject sessionObj  = createSession(receiver);
			JSONObject params = new JSONObject();
			sendIM("system","系统通知",String.valueOf(sessionObj.get("id")),msgType, msg);
			return true;
		}catch (Exception e){
			e.printStackTrace();
@ -153,6 +144,48 @@ public class HttpUtil {
		return false;
	}
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	private static String sendIM(String from,String fromName, String sessionId, String contentType, String content) {
		String imAddr = SystemConf.getInstance().getImListGet() + "/api/v2/sessions/"+sessionId+"/messages";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("sender_name", fromName);
		params.put("business_type", contentType);
		params.put("content_type", 1);
		params.put("content", content);
		params.put("sessionId", sessionId);;
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	/**
	 * 创建会话(system)
	 *
	 */
	private static JSONObject createSession(String receiver) {
		String imAddr = SystemConf.getInstance().getImListGet() + "api/v2/sessions";
		String participants[]=new String[]{"system:0",receiver+":"+"0"};
		JSONObject params = new JSONObject();
		params.put("participants", participants);
		params.put("session_name", "系统消息");
		params.put("session_type", 0);
		String ret = HttpClientUtil.postBody(imAddr,params);
		JSONObject obj  = null;
		try{
			obj = new JSONObject(ret);
		}catch (Exception e){
			return null;
		}
		return obj;
	}
	/**
	 * 发送消息到websocket服务器,然后由websocket服务器中转给微信端
	 * @param userid 接收数据的患者id