Browse Source

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 1 year ago
parent
commit
299343078b

+ 34 - 20
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -481,21 +481,23 @@ public class ImService {
     * @param wechat_appid 微信公众号appid
     * @return
     */
    public List<String> append(String consult, String content, Integer type, Integer times, String patientcode, String wechat_appid, String agent) throws Exception {
    public List<String> append(String consult, String content, Integer type, Integer times, String patientcode, String wechat_appid, String agent,String sessionType) throws Exception {
        List<ConsultTeamLogDo> logs = new ArrayList<ConsultTeamLogDo>();
        ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
        if (consultModel == null) {
            throw new Exception("咨询记录不存在!");
        }
        try {
            if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
                prescriptionService.wxTempalteJPush("consult_remind_doctor", null, consultModel, content, "", "", "");
        if ("1".equals(sessionType)) {
            ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
            if (consultModel == null) {
                throw new Exception("咨询记录不存在!");
            }
            try {
                if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
                    prescriptionService.wxTempalteJPush("consult_remind_doctor", null, consultModel, content, "", "", "");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (consultModel.getEndMsgId() != null) {
                throw new Exception("咨询已结束!");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (consultModel.getEndMsgId() != null) {
            throw new Exception("咨询已结束!");
        }
        String[] arr = null;
@ -537,14 +539,26 @@ public class ImService {
        List<String> failed = new ArrayList<>();
        for (ConsultTeamLogDo log : logs) {
            String response = imUtil.sendTopicIM(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(), agent, patient.getName(), Integer.parseInt(IdCardUtil.getSexForIdcard_new(patient.getIdcard())), IdCardUtil.getAgeForIdcard(patient.getIdcard()));
            if (org.apache.commons.lang3.StringUtils.isNotEmpty(response)) {
                JSONObject resObj = JSON.parseObject(response);
                if (resObj.getInteger("status") == -1) {
                    throw new Exception("追问失败!" + resObj.getString("message"));
            String response = "";
            if ("1".equals(sessionType)){
                response = imUtil.sendTopicIM(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(), agent, patient.getName(), Integer.parseInt(IdCardUtil.getSexForIdcard_new(patient.getIdcard())), IdCardUtil.getAgeForIdcard(patient.getIdcard()));
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = JSON.parseObject(response);
                    if (resObj.getInteger("status") == -1) {
                        throw new Exception("追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                }
            }
            else {
                response = imUtil.sendImMsgAgent(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(), "2", null,agent);
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = JSON.parseObject(response);
                    if (resObj.getInteger("count") == -1) {
                        throw new Exception("追问失败!" + resObj.getString("messages"));
                    }
                    failed.add(resObj.getJSONArray("messages").get(0).toString());
                }
                failed.add(String.valueOf(resObj.get("data")));
            }
        }
        return failed;

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

@ -295,6 +295,29 @@ public class ImUtil {
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	/**
	 * 发送消息给IM
	 *
	 * @param from        来自
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendImMsgAgent(String from, String fromName, String sessionId, String contentType, String content, String businessType,String extend,String agent) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
		System.out.println("im地址"+imAddr);
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("sender_name", fromName);
		params.put("content_type", contentType);
		params.put("content", content);
		params.put("session_id", sessionId);
		params.put("business_type", businessType);
		params.put("extend",extend);
		params.put("agent",agent);
		String response = HttpClientUtil.postBody(imAddr, params);
		return response;
	}
	
	/**
	 * 更新会话状态

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -428,7 +428,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "times", value = "")
			@RequestParam(value = "times",required = false) Integer times,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = false) String patientCode){
			@RequestParam(value = "patientCode",required = false) String patientCode,
			@ApiParam(name = "sessionType", value = "1咨询会话、2:P2P会话")
			@RequestParam(value = "sessionType",defaultValue = "1",required = false) String sessionType){
		try {
			List<String> failed = new ArrayList<>();
			//处理语音文件
@ -453,7 +455,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				}
			}else{}
			String agent = getAgentUID();
			failed = imService.append(consult,content,type,times,patientCode,wechat_appid,agent);
			failed = imService.append(consult,content,type,times,patientCode,wechat_appid,agent,sessionType);
			return success(failed);
		}catch (Exception e){
			return failedListEnvelopException2(e);