Преглед на файлове

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

Trick преди 5 години
родител
ревизия
97644ce3b3

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

@ -3164,6 +3164,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
	            }else{
		            outpatient.put("alert_tag",1);//未提醒
	            }
                outpatient.put("online_tag",1);//未提醒
            }
        }
    
@ -3236,7 +3237,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    outpatient.put("alert_tag",1);//未提醒
                }
                
                outpatient.put("online_tag",0);//在线状态
                outpatient.put("online_tag",1);//在线状态
    
                String outpatient_mobile = (String)outpatient.get("outpatient_mobile");
                if(StringUtils.isNoneBlank(outpatient_mobile)){
@ -3289,11 +3290,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    
    /**
     * 复诊图文咨询人数,视频咨询人数, 专家咨询未完成
     * 复诊视频咨询人数, 协同门诊人数
     * @param doctor
     * @param outpatient_type 1复诊 2协同
     * @return
     */
    public Long doctorIndexConsultCount(String doctor) {
    public Long doctorIndexConsultCount(String doctor,String outpatient_type) {
    
    
        String sql ="SELECT " +
@ -3308,9 +3310,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND consult.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.consult_type= 2";
    
                "AND outpatient_type.doctor='"+outpatient_type+"'" +
                "AND room.doctor='"+doctor+"' ";
        if("1".equals(outpatient_type)){
            sql = sql + " AND room.consult_type= 2 ";
        }else if("2".equals(outpatient_type)){
        }else{}
        
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
    
        Long videoOnlineCount = 0l;
@ -3392,25 +3398,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    
    /**
     * 获取候诊居民数量
     * 根据类型获取候诊居民数量
     * @param doctor
     * @param outpatient_type 1复诊  2协同
     * @param type 1图文 2视频
     * @return
     */
    public Long getWaitVideoCount(String doctor) {
    public Long getWaitVideoCount(String doctor,String type,String outpatient_type) {
        String sql ="SELECT " +
                "count(room.outpatient_id) AS total " +
                "count(outpatient.id) AS total " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient " +
                "wlyy_outpatient outpatient," +
                "base_patient patient " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND outpatient.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.reservation_time is not null AND  room.reservation_time >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' " +
                "AND room.consult_type= 2 ";
    
                "outpatient.patient=patient.id " +
                "AND outpatient.status in (0,1) " +
                "AND outpatient.doctor='"+doctor+"' " +
                "AND outpatient.outpatient_type= '"+outpatient_type+"' ";
        if("1".equals(outpatient_type)){//复诊
            sql =  sql + " AND outpatient.type= '"+type+"' ";
            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;

+ 14 - 6
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);
@ -1231,7 +1232,7 @@ public class ImService {
			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
			if (endOperator.equals("admin")) {
				endId = "system";
				endName = "超时,系统自动结束";
				endName = "超时,系统自动";
			} else {
				endId = d.getId();
				endName = d.getName();
@ -2275,13 +2276,20 @@ public class ImService {
					"WHERE op.patient=patient.id " +
					"AND op.doctor='"+doctorCode+"' " +
					"AND op.status in ('0','1') ";
			if("9".equals(type)){//图文复诊
				sql =sql +"AND op.type=1 ";
			if("9".equals(type)){
				//图文复诊
				sql =sql +"AND op.type=1 AND op.outpatient_type=1 ";
			}else if("16".equals(type)){
				//视频复诊
				sql =sql +"AND op.type=2 ";
				sql =sql +"AND op.type=2 AND op.outpatient_type=1 ";
				sql =sql + " AND  op.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
			}else if("12".equals(type)){
				//视频复诊
				sql =sql +"AND op.outpatient_type=2";
				sql =sql + " AND  op.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
			}else{}
			sql =sql +"ORDER BY op.create_time DESC";
			sql =sql +" ORDER BY op.create_time DESC";
		}
		
		List<ConsultVO> result = new ArrayList<>();

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

+ 32 - 52
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -471,36 +471,38 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.doctorIndexConsultCount)
	@ApiOperation(value = "复诊图文咨询人数,视频咨询人数、协同门诊人数,可抢单人数", notes = "复诊图文咨询人数,视频咨询人数、协同门诊人数,可抢单人数")
	@ApiOperation(value = "复诊图文咨询人数,视频咨询人数、协同门诊人数,可抢单人数(已废弃)", notes = "复诊图文咨询人数,视频咨询人数、协同门诊人数,可抢单人数")
	public Envelop doctorIndexConsultCount(@ApiParam(name = "doctor", value = "医生CODE")
	                                       @RequestParam(value = "doctor",required = true) String doctor){
		
		//专家咨询
		Integer zjCount = imService.sessionCountByType(doctor,1,0);
		
		//复诊咨询
		Integer imgCount = imService.sessionCountByType(doctor,9,0);
		
		//正在进行中的视频复诊
		Long _videoOnlineCount = prescriptionService.doctorIndexConsultCount(doctor);
		Integer videoCount = _videoOnlineCount.intValue();
		
		//获取候诊居民数量(包含进行中的)
		Long _waitVideoCount = prescriptionService.getWaitVideoCount(doctor);
		Integer waitVideoCount = _waitVideoCount.intValue();
		
		JSONObject result = new JSONObject();
		result.put("zjCount",zjCount);
		
		imgCount = imgCount - videoCount;
		if(imgCount <=0){
			imgCount = 0;
		}
		
		result.put("zjCount",zjCount);//专家咨询数量
		result.put("imgCount",imgCount);//图文复诊数量
		result.put("videoCount",waitVideoCount+_videoOnlineCount);//视频复诊数量
		result.put("xtCount",0);//协同门诊候诊数量
//		//专家咨询
//		Integer zjCount = imService.sessionCountByType(doctor,1,0);
//
//		//复诊咨询
//		Integer imgCount = imService.sessionCountByType(doctor,9,0);
//
//		//正在进行中的视频复诊
//		Long _videoOnlineCount = prescriptionService.doctorIndexConsultCount(doctor);
//		Integer videoCount = _videoOnlineCount.intValue();
//
//		//获取候诊居民数量(包含进行中的)
//		Long _waitVideoCount = prescriptionService.getWaitVideoCount(doctor);
//		Integer waitVideoCount = _waitVideoCount.intValue();
//
//
//		result.put("zjCount",zjCount);
//
//		imgCount = imgCount - videoCount;
//		if(imgCount <=0){
//			imgCount = 0;
//		}
//
//		result.put("zjCount",zjCount);//专家咨询数量
//		result.put("imgCount",imgCount);//图文复诊数量
//		result.put("videoCount",waitVideoCount+_videoOnlineCount);//视频复诊数量
//		result.put("xtCount",0);//协同门诊候诊数量
		
//		JSONObject resultPick = prescriptionService.findWaitingRoomOutpatientNumberByDoctor(doctor);
//		result.put("imgPickCount",resultPick.getIntValue("twCount"));
@ -525,36 +527,14 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.doctorReviewConsultCount)
	@ApiOperation(value = "医生端:图文复诊、视频复诊咨询数量", notes = "医生端:图文复诊、视频复诊咨询数量")
	@ApiOperation(value = "医生端:图文复诊、视频复诊咨询数量、协同门诊候诊数量", notes = "医生端:图文复诊、视频复诊咨询数量、协同门诊候诊数量")
	public Envelop doctorReviewConsultCount(@ApiParam(name = "doctor", value = "医生CODE")
	                                            @RequestParam(value = "doctor",required = true) String doctor){
		
		logger.info("action:doctorReviewConsultCount--start:"+DateUtil.dateToStrLong(new Date()));
		
		//复诊咨询
		Integer imgCount = imService.sessionCountByType(doctor,9,0);
		logger.info("action:doctorReviewConsultCount--imgCount:"+DateUtil.dateToStrLong(new Date()));
		
		//正在进行中的视频复诊
		Long _videoOnlineCount = prescriptionService.doctorIndexConsultCount(doctor);
		Integer videoCount = _videoOnlineCount.intValue();
		logger.info("action:doctorReviewConsultCount--videoCount:"+DateUtil.dateToStrLong(new Date()));
		
		//获取候诊居民数量(包含进行中的)
		Long _waitVideoCount = prescriptionService.getWaitVideoCount(doctor);
		
		logger.info("action:doctorReviewConsultCount--waitVideoCount:"+DateUtil.dateToStrLong(new Date()));
		Integer waitVideoCount = _waitVideoCount.intValue();
		
		JSONObject result = new JSONObject();
		
		imgCount = imgCount - videoCount;
		if(imgCount <=0){
			imgCount = 0;
		}
		result.put("imgCount",imgCount);//图文复诊数量
		result.put("videoCount",waitVideoCount+_videoOnlineCount);//视频复诊数量
		result.put("xtCount",0);//协同门诊候诊数量
		logger.info("action:doctorReviewConsultCount--start:"+DateUtil.dateToStrLong(new Date()));
		result.put("imgCount",prescriptionService.getWaitVideoCount(doctor,"1","1"));//图文复诊数量
		result.put("videoCount",prescriptionService.getWaitVideoCount(doctor,"2","1"));//视频复诊数量
		result.put("xtCount",prescriptionService.getWaitVideoCount(doctor,"","2"));//协同门诊候诊数量
		logger.info("action:doctorReviewConsultCount--end:"+DateUtil.dateToStrLong(new Date()));
		return success("请求成功",result);
	}

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