ソースを参照

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java
wangzhinan 4 年 前
コミット
3bbdd2129c

+ 12 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -3061,4 +3061,16 @@ public class ImService {
		logger.info("开始发送"+msg.toJSONString());
		return imUtil.sendMessage(doctor,patientCode,"2",msg.toString());
	}
	public boolean guidanceFinishConsult(String sessionId,String participants){
		boolean flag = false;
		//踢出会员成员
		imUtil.deleteParticipants(sessionId,participants);
		//修改session状态
		imUtil.updateSessionStatus(sessionId,"1");
		flag = true;
		return flag;
	}
}

+ 20 - 6
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -451,15 +451,11 @@ public class ImUtil {
		try {
			obj = JSON.parseObject(ret);
			if(obj.getInteger("status") ==200&&sessionId.equals(obj.getString("sessionId"))){
				String sessionStatus = obj.getString("status");
				if (sessionStatus.equalsIgnoreCase("1")){
				String sessionStatus = obj.getString("sessionId");
				if (StringUtils.isNoneBlank(sessionStatus)){
					String sessionStatusUrl = im_host + "api/v2/sessions/"+sessionId+"/status?status=0&sessionId="+sessionId;
					JSONObject object = new JSONObject();
					String rs = HttpClientUtil.postBody(sessionStatusUrl, object);
					JSONObject jsonObject = JSONObject.parseObject(rs);
					if (jsonObject.getString("status").equalsIgnoreCase("200")){
						System.out.println("session状态更新成功!"+rs);
					}
				}
				re = true;
			}
@ -566,6 +562,24 @@ public class ImUtil {
			throw new RuntimeException("人员更换失败!");
		}
	}
	/**
	 * 删除会话人员
	 * @param sessionId
	 * @param participants
	 * @return
	 */
	public JSONObject deleteParticipants(String sessionId,String participants){
		String url  = im_host+"api/v2/sessions/"+sessionId+"/participants/"+participants;
		String rs = HttpClientUtil.doDelete(url,null,null);
		JSONObject obj = JSONObject.parseObject(rs);
		if (obj.getInteger("status")==-1){
			throw new RuntimeException("删除会话人员失败!");
		}else {
			return obj;
		}
	}
	
	
	/**

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1012,6 +1012,9 @@ public class BaseHospitalRequestMapping {
        //医生端:发送医生取消IM消息
        public static final String sendOutPatientCancle = "sendOutPatientCancle";
        //导诊助手结束咨询
        public static final String guidanceFinishConsult = "guidanceFinishConsult";
    }
    /**

+ 108 - 3
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -4,10 +4,10 @@ import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
@ -336,4 +336,109 @@ public class HttpClientUtil {
        return null;
    }
    /**
     * 原生字符串发送put请求
     *
     * @param url
     * @param token
     * @param jsonStr
     * @return
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static String doPut(String url, String token, String jsonStr) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPut httpPut = new HttpPut(url);
        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
        httpPut.setConfig(requestConfig);
        httpPut.setHeader("Content-type", "application/json");
        httpPut.setHeader("DataEncoding", "UTF-8");
        httpPut.setHeader("token", token);
        CloseableHttpResponse httpResponse = null;
        try {
            httpPut.setEntity(new StringEntity(jsonStr));
            httpResponse = httpClient.execute(httpPut);
            HttpEntity entity = httpResponse.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if (httpResponse != null) {
                try {
                    httpResponse.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (null != httpClient) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
    /**
     * 发送delete请求
     *
     * @param url
     * @param token
     * @param jsonStr
     * @return
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static String doDelete(String url, String token, String jsonStr) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpDelete httpDelete = new HttpDelete(url);
        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
        httpDelete.setConfig(requestConfig);
        httpDelete.setHeader("Content-type", "application/json");
        httpDelete.setHeader("DataEncoding", "UTF-8");
        httpDelete.setHeader("token", token);
        CloseableHttpResponse httpResponse = null;
        try {
            httpResponse = httpClient.execute(httpDelete);
            HttpEntity entity = httpResponse.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if (httpResponse != null) {
                try {
                    httpResponse.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (null != httpClient) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}

+ 16 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -881,4 +881,20 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		return success("操作成功");
	}*/
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.guidanceFinishConsult)
	@ApiOperation(value = "导诊助手结束导诊", notes = "导诊助手结束导诊")
	public ObjEnvelop guidanceFinishConsult(@ApiParam(name = "sessionId", value = "sessionId")
												@RequestParam(value = "sessionId", required = true)String sessionId,
											@ApiParam(name = "userId", value = "userId")
											@RequestParam(value = "userId", required = true)String userId) {
		Boolean flag =false;
		try {
			flag = imService.guidanceFinishConsult(sessionId,userId);
		}catch (Exception e){
			System.out.println("导诊助手结束导诊失败:"+e.getMessage());
		}
		return success(flag);
	}
}