Browse Source

患者新增IM

chenweida 8 years ago
parent
commit
fb13c42f9c

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

@ -1,6 +1,6 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.service.app.consult;
@ -24,8 +24,12 @@ 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.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -89,7 +93,7 @@ public class ConsultTeamService extends ConsultService {
        if (type == 1) {
            // 查询三师签约信息
            SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
            if(sc == null){
            if (sc == null) {
                throw new Exception("不存在三师签约");
            }
            // 设置健康管理师,三师咨询默认给健康管理师处理
@ -104,7 +108,7 @@ public class ConsultTeamService extends ConsultService {
        } else if (type == 2) {
            // 咨询家庭医生
            SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
            if(sf == null){
            if (sf == null) {
                throw new Exception("不存在家庭签约");
            }
            // 设置健康管理师,家庭医生咨询默认给健康管理师处理
@ -117,7 +121,7 @@ public class ConsultTeamService extends ConsultService {
                member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            }
        }
        if(member == null){
        if (member == null) {
            throw new Exception("找不到签约服务团队医生");
        }
        int count = consultTeamDao.countByPatient(patient, member.getMemberCode());
@ -536,6 +540,8 @@ public class ConsultTeamService extends ConsultService {
    public void reply(List<ConsultTeamLog> logs, String patient) {
        for (ConsultTeamLog log : logs) {
            reply(log, patient, null, log.getType());
            //推送给IM
            sendIM(patient, log.getDoctor(), log.getChatType()+"", log.getContent());
        }
    }
@ -585,6 +591,7 @@ public class ConsultTeamService extends ConsultService {
    }
    /**
     * 患者端
     * 添加三师咨询
     *
     * @param ct      三师咨询对象
@ -672,17 +679,46 @@ public class ConsultTeamService extends ConsultService {
        consultDao.save(consult);
        consultTeamDoctorDao.save(cd);
        // 添加医生咨询日志
        addLogs(ct);
        String content = addLogs(ct);
        //推送给IM文字消息
        sendIM(ct.getPatient(), ct.getDoctor(), "1", content);
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                }
            }
        }
        return 1;
    }
    /**
     * 发送消息给IM
     * @param from 来自
     * @param to
     * @param contentType 1文字 2图片消息
     * @param content 内容
     */
    private void sendIM(String from, String to, String contentType, String content) {
        String imAddr = SystemConf.getInstance().getImListGet() + "api/v1/chats/pm";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("from", from));
        params.add(new BasicNameValuePair("to", to));
        params.add(new BasicNameValuePair("contentType", contentType));
        params.add(new BasicNameValuePair("content", content));
        String response = HttpClientUtil.post(imAddr, params, "UTF-8");
    }
    /**
     * 添加三师咨询日志
     *
     * @param ct
     * @throws Exception
     */
    private void addLogs(ConsultTeam ct) throws Exception {
    private String addLogs(ConsultTeam ct) throws Exception {
        List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
        // 添加问题咨询日志
        String content = "";
@ -751,6 +787,7 @@ public class ConsultTeamService extends ConsultService {
        }
        // 患者提问或追问,给医生发消息
        // sendMessage(ct.getDoctor(), ct.getPatient(), "三师咨询", "您有新的三师咨询消息", ct.getConsult(), 116, 1, 0, 0);
        return content;
    }
    /**
@ -1054,7 +1091,18 @@ public class ConsultTeamService extends ConsultService {
        cd.setTo(ct.getDoctor());
        consultTeamDoctorDao.save(cd);
        // 添加医生咨询日志
        addLogs(ct);
        String content=addLogs(ct);
        //推送给IM文字消息
        sendIM(ct.getPatient(), ct.getDoctor(), "1", content);
        //推送给IM图片
        if (StringUtils.isNotEmpty(ct.getImages())) {
            String[] images = ct.getImages().split(",");
            for (String image : images) {
                if (StringUtils.isNoneEmpty(image)) {
                    sendIM(ct.getPatient(), ct.getDoctor(), "2", image);
                }
            }
        }
    }
    /**

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/DrHealthTeamService.java

@ -263,11 +263,13 @@ public class DrHealthTeamService extends BaseService {
        List<Doctor> zrDoctors=  doctorTeamMemberDao.getTeamZKByQK(doctorCode);
        for(Doctor doctor:zrDoctors){
            //判断是否求助
            doctor.setIsHelp("0");
        }
        //得到医生所在的团队的除了自己的所有人
        List<Doctor> teamDoctors= memberDao.findAllHeathExcludeThis(teamId, doctorCode);
        for(Doctor doctor:teamDoctors){
            //判断是否求助
            doctor.setIsHelp("0");
        }
        returnMap.put("zr",zrDoctors);
        returnMap.put("team",teamDoctors);

+ 12 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -16,6 +16,7 @@ public class SystemConf {
	public static final int NOT_LOGIN = 997;
	private static final String SERVER_IP = "server_ip";
	private static final String IM_LIST_GET = "im_list_get";
	private static final String SERVER_PORT = "server_port";
	private static final String SERVER_DOMAIN = "server_domain";
@ -76,6 +77,8 @@ public class SystemConf {
	private static SystemConf systemConf;
	// 系统配置文件
	private Properties systemProperties;
	//im列表
	private String imListGet;
	public static SystemConf getInstance() {
		if (systemConf == null) {
@ -177,6 +180,15 @@ public class SystemConf {
		return getSystemProperties().getProperty(SERVER_PORT);
	}
	/**
	 * IM地址
	 * @return
     */
	public String getImListGet() {
		return getSystemProperties().getProperty(IM_LIST_GET);
	}
	/**
	 * 获取服务资源名
	 * @return

+ 4 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -8,8 +8,11 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.util.*;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,9 +31,6 @@ import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.DoctorStatisticsTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.WeixinBaseController;
/**
@ -315,6 +315,7 @@ public class ConsultController extends WeixinBaseController {
            if (consult.getType() == 2) {
                DoctorStatisticsTask.getInstance(doctorStatisticsService).put(consult.getDoctor(), 1, 1, 0);
            }
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());