浏览代码

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

huangwenjie 5 年之前
父节点
当前提交
0bc5f99118

+ 3 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3415,8 +3415,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if("2".equals(type)){//视频复诊才需要判断时间,
                sql =  sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
            }
        }else if("2".equals(outpatient_type)){
            //协同门诊也需要判断时间
            sql =  sql + " AND outpatient.register_date is not null AND  outpatient.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
        }
    
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
    
        Long waitVideoCount = 0l;

+ 2 - 1
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -42,6 +42,7 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.apache.http.NameValuePair;
@ -440,7 +441,7 @@ public class ImService {
		
		for (ConsultTeamLogDo log : logs) {
//                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
			String response = imUtil.sendTopicIM(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),null);
			String response = imUtil.sendTopicIM(patientcode, patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),null,patient.getName(),patient.getSex(), IdCardUtil.getAgeForIdcard(patient.getIdcard()));
			
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(response)) {
				JSONObject resObj = JSON.parseObject(response);

+ 5 - 1
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -3,6 +3,7 @@ package com.yihu.jw.im.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -301,11 +302,14 @@ public class ImUtil {
	 * @param contentType 1文字 2图片消息
	 * @param content     内容
	 */
	public String sendTopicIM(String from, String fromName, String topicId, String contentType, String content, String agent) {
	public String sendTopicIM(String from, String fromName, String topicId, String contentType, String content, String agent,String patient_name,int patient_sex,int patient_age) {
		String url = im_host + "api/v2/sessions/topic/" + topicId + "/messages";
		JSONObject params = new JSONObject();
		params.put("sender_id", from);
		params.put("sender_name", fromName);
		params.put("patient_name", patient_name);
		params.put("patient_sex", patient_sex);
		params.put("patient_age", patient_age);
		params.put("content_type", contentType);
		params.put("content", content);
		params.put("topic_id", topicId);

+ 36 - 0
common/common-util/src/main/java/com/yihu/jw/util/idcard/IdCardUtil.java

@ -179,4 +179,40 @@ public class IdCardUtil {
        }
        return sex;
    }
    
    /**
     * 根据身份证的号码算出当前身份证持有者的性别,返回性别文字
     * 1 男 2 女 3未知
     *
     * @return
     * @throws Exception
     */
    public static String getSexForIdcardReturnName(String CardCode)
            throws Exception {
        String sex = "未知";
        try {
            if (CardCode.length() == 18) {
                if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
                    // modifid by lyr 2016-09-29
                    sex = "女";
                    // modifid by lyr 2016-09-29
                } else {
                    // modifid by lyr 2016-09-29
                    sex = "男";
                    // modifid by lyr 2016-09-29
                }
            } else if (CardCode.length() == 15) {
                String usex = CardCode.substring(14, 15);// 用户的性别
                if (Integer.parseInt(usex) % 2 == 0) {
                    sex = "女";
                } else {
                    sex = "男";
                }
            }
            return sex;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sex;
    }
}

+ 10 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -260,6 +260,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO);
        //发送IM消息
        hospitalSystemMessageService.sendImMessage(systemMessageDO);
        
        //发送医生抢单消息
        if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
            hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
        }
    
        return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
    }
@ -590,6 +595,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        //发送系统消息
        hospitalSystemMessageService.sendImMessage(systemMessageDO);
    
        //发送医生抢单消息
        if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
            hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
        }
    
        return success(wlyyOutpatientDO);
    }

+ 44 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/SystemMessage/HospitalSystemMessageService.java

@ -1,14 +1,23 @@
package com.yihu.jw.hospital.service.SystemMessage;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.idcard.IdCardUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * 互联网医院系统消息业务层
@ -24,9 +33,15 @@ public class HospitalSystemMessageService  {
	@Autowired
	private SystemMessageService systemMessageService;
	
	@Autowired
	private BasePatientDao basePatientDao;
	
	@Autowired
	private ImService imService;
	
	@Autowired
	private PrescriptionService prescriptionService;
	
	/**
	 * 保存系统消息&发送IM外层刷新事件的消息
	 * @param systemMessageDO
@ -60,5 +75,34 @@ public class HospitalSystemMessageService  {
		}
	}
	
	/**
	 * 通知医生抢单消息
	 * @param wlyyOutpatientDO
	 */
	@Async
	public void sendImPichCheckMessage(WlyyOutpatientDO wlyyOutpatientDO) throws Exception {
		BasePatientDO basePatientDO =basePatientDao.findById(wlyyOutpatientDO.getPatient());
		String tagMsg = "";
		JSONObject object = new JSONObject();
		object.put("socket_sms_type",12);//抢单事件
		if("1".equals(wlyyOutpatientDO.getOutpatientType())&&"1".equals(wlyyOutpatientDO.getType())){//图文复诊
			object.put("relation_code","1:"+wlyyOutpatientDO.getId());
			tagMsg = "图文复诊";
		}else if ("1".equals(wlyyOutpatientDO.getOutpatientType())&&"2".equals(wlyyOutpatientDO.getType())){//视频复诊
			object.put("relation_code","3:"+wlyyOutpatientDO.getId());
			tagMsg = "视频复诊";
		}else if ("2".equals(wlyyOutpatientDO.getOutpatientType())){//协同门诊
			object.put("relation_code","3:"+wlyyOutpatientDO.getId());
			tagMsg = "协同门诊";
		}else{}
		
		object.put("msg",basePatientDO.getName()+"("+ IdCardUtil.getSexForIdcardReturnName(basePatientDO.getIdcard())+" "
				+ IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())+"岁)发起了随机邀请"+tagMsg+",问题:"+wlyyOutpatientDO.getDescription());
		
//		List<Map<String,Object>> doctorlist = prescriptionService.findDoctorByHospitalAndDept();
		
//		imService.sendWaiSocketMessage(wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getDoctor(),object.toString(),"1");
	}
}