Переглянути джерело

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

叶仕杰 3 роки тому
батько
коміт
fadddfe7e4

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

@ -454,6 +454,85 @@ public class ImService {
	}
	}
	/**
	 * 居民咨询发消息(追问接口)
	 * @param consult 咨询标识-咨询CODE
	 * @param content 消息内容
	 * @param type 消息类型
	 * @param times 次数
	 * @param patientcode 发送的居民CODE
	 * @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 {
		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,"","","");
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		if (consultModel.getEndMsgId() != null) {
			throw new Exception("咨询已结束!");
		}
		String[] arr = null;
		if (type == 3) {//语音文件处理
			ConsultTeamLogDo log = new ConsultTeamLogDo();
			log.setConsult(consult);
			log.setContent(content);
			log.setDel("1");
			log.setChatType(type);
			log.setType(type);
			logs.add(log);
		} else if (type == 2) {
//			// 图片消息
			String[] images = content.split(",");
			for (String image : images) {
				ConsultTeamLogDo log = new ConsultTeamLogDo();
				log.setConsult(consult);
				log.setContent(image);
				log.setDel("1");
				log.setChatType(type);
				log.setType(type);
				logs.add(log);
			}
		} else {
			ConsultTeamLogDo log = new ConsultTeamLogDo();
			log.setConsult(consult);
			log.setContent(content);
			log.setDel("1");
			log.setChatType(type);
			log.setType(type);
			logs.add(log);
			arr = new String[]{content};
		}
//            Patient patient = patientDao.findByCode(getUID());
		BasePatientDO patient = basePatientDao.findById(patientcode);
		int i = 0;
		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"));
				}
				failed.add(String.valueOf(resObj.get("data")));
			}
		}
		return failed;
	}
	/**
	/**
	 * 居民咨询发消息(追问接口)
	 * 居民咨询发消息(追问接口)
	 * @param consult 咨询标识-咨询CODE
	 * @param consult 咨询标识-咨询CODE

+ 19 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -9,7 +9,6 @@ import com.yihu.jw.restmodel.exception.dao.BaseExceptionDictDao;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -19,7 +18,6 @@ import javax.servlet.http.HttpServletResponse;
import java.beans.PropertyDescriptor;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
@ -483,6 +481,25 @@ public abstract class EnvelopRestEndpoint extends Exception {
        }
        }
    }
    }
    /**
     * 获取代理人的code
     * 老人亲属
     * @return
     */
    public String getAgentUID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("agent");
        } catch (Exception e) {
            return null;
        }
    }
    public String getUNAME(){
    public String getUNAME(){
        try {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

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

@ -168,6 +168,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			if (type == null) {
			if (type == null) {
				type = 23;
				type = 23;
			}
			}
			String agent = getAgentUID();
			ConsultTeamDo consult = new ConsultTeamDo();
			ConsultTeamDo consult = new ConsultTeamDo();
			// 设置咨询类型:23 在线咨询 24老人在线咨询
			// 设置咨询类型:23 在线咨询 24老人在线咨询
			consult.setType(type);
			consult.setType(type);
@ -182,7 +184,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			// 保存到数据库
			// 保存到数据库
			synchronized (patient.intern()){//新增同步方法
			synchronized (patient.intern()){//新增同步方法
				JSONObject re = null;
				JSONObject re = null;
				re = consultService.addTeamConsult(consult, patient,doctor,source);
				re = consultService.addTeamConsult(consult, patient,doctor,source,agent);
				//发送系统消息
				//发送系统消息
				SystemMessageDO systemMessageDO = new SystemMessageDO();
				SystemMessageDO systemMessageDO = new SystemMessageDO();
				systemMessageDO.setTitle("新增在线咨询");
				systemMessageDO.setTitle("新增在线咨询");
@ -342,8 +344,8 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
					content = fileUploadService.uploadWxImage(imagepath);
					content = fileUploadService.uploadWxImage(imagepath);
				}
				}
			}else{}
			}else{}
			failed = imService.append(consult,content,type,times,patientCode,wechat_appid);
			String agent = getAgentUID();
			failed = imService.append(consult,content,type,times,patientCode,wechat_appid,agent);
			return success(failed);
			return success(failed);
		}catch (Exception e){
		}catch (Exception e){
			return failedListEnvelopException2(e);
			return failedListEnvelopException2(e);

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

@ -2,7 +2,6 @@ package com.yihu.jw.care.service.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -12,7 +11,6 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
@ -498,7 +496,7 @@ public class ConsultService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor, String source) throws Exception {
    public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor, String source,String agent) throws Exception {
        JSONObject re = new JSONObject();
        JSONObject re = new JSONObject();
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor,ct.getType()));
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor,ct.getType()));
        logger.info("boo"+boo);
        logger.info("boo"+boo);
@ -558,7 +556,7 @@ public class ConsultService {
        jsonObject.put("name",tempPatient.getName());
        jsonObject.put("name",tempPatient.getName());
        //推送给IM去创建议题,取得成员消息
        //推送给IM去创建议题,取得成员消息
        JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), jsonObject.toJSONString(), consult.getImages(), doctor);
        JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), jsonObject.toJSONString(), consult.getImages(), agent);
        users.put(patient, 0);
        users.put(patient, 0);
        users.put(doctor, 0);
        users.put(doctor, 0);
        String session_type = ct.getType()+"";//SESSION_TYPE
        String session_type = ct.getType()+"";//SESSION_TYPE