瀏覽代碼

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

wangjun 4 年之前
父節點
當前提交
34901aa432

+ 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;
	}
}

+ 24 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -451,6 +451,12 @@ public class ImUtil {
		try {
			obj = JSON.parseObject(ret);
			if(obj.getInteger("status") ==200&&sessionId.equals(obj.getString("sessionId"))){
				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);
				}
				re = true;
			}
		} catch (Exception e) {
@ -556,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;
    }
}

+ 7 - 1
server/svr-authentication/src/main/resources/application.yml

@ -11,12 +11,18 @@ spring:
    max-idle: 100 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    connection-timeout: 60000
    validation-timeout: 3000
    max-lifetime: 60000
    login-timeout: 5
    maximum-pool-size: 60
    minimum-idle: 10
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 20000
    idle-timeout: 60000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 100 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除

+ 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);
	}
}

+ 5 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -721,7 +721,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "导诊的咨询对话", notes = "导诊的咨询对话")
	public Envelop getPatientGuaidenceConsult(@ApiParam(name = "patientCode", value = "居民CODE")
	                       @RequestParam(value = "patientCode", required = true)String patientCode) throws Exception {
		String session_id = session_id = patientCode+"_guidance_14";
		String session_id = patientCode+"_guidance_14";
		session_id = imService.getPatientGuaidenceConsult(patientCode,session_id,null);
		return success(session_id);
	}
@ -767,9 +767,11 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "content_type", value = "内容类型", defaultValue = "")
			@RequestParam(value = "content_type", required = true) String content_type,
			@ApiParam(name = "content", value = "消息内容", defaultValue = "")
			@RequestParam(value = "content", required = true) String content
			@RequestParam(value = "content", required = true) String content,
			@ApiParam(name = "type", value = "咨询type", defaultValue = "")
			@RequestParam(value = "type", required = false) String type
	)throws Exception{
		session_id = imService.getPatientGuaidenceConsult(sender_id,session_id,content_type);
		session_id = imService.getPatientGuaidenceConsult(sender_id,session_id,type);
		String result = imService.patientGuaidenceAppend(sender_id,sender_name,session_id,content_type,content,"1");
		return success(result);
	}