Explorar o código

居民聊一聊结束咨询同时结束im

wangjun %!s(int64=4) %!d(string=hai) anos
pai
achega
8efa74c267

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

@ -1684,7 +1684,132 @@ public class ImService {
		return 1;
	}
	/**
	 * 居民取消复诊
	 * @param consult 咨询CODE
	 * @param endOperator 操作人
	 * @param endType 1居民 2医生
	 * @return
	 */
	public int cancelRevisit(String consult, String endOperator, int endType) {
		ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
		ConsultDo cons = consultDao.findOne(consult);
		if (consultTeam.getStatus() == 1) {
			return -1;
		}
		String name = "";
		String returnJson = "";
		/**
		 * 发送评价消息
		 */
		BaseDoctorDO doctor = baseDoctorDao.findById(consultTeam.getDoctor());
		BasePatientDO patient = basePatientDao.findById(consultTeam.getPatient());
		/*JSONObject evalueContent = new JSONObject();
		evalueContent.put("patientCode",consultTeam.getPatient());
		evalueContent.put("patientName",patient.getName());
		evalueContent.put("doctorCode",consultTeam.getDoctor());
		evalueContent.put("doctorName",doctor.getName());
		evalueContent.put("doctorPhoto",doctor.getPhoto());
		evalueContent.put("consultCode",consult);*/
//		returnJson = imUtil.sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "28", evalueContent.toString());
//		String response = imUtil.sendTopicIM(consultTeam.getDoctor(), doctor.getName(), consult, "28", evalueContent.toString(),null);
//		String response = imUtil.sendImMsg(consultTeam.getDoctor(), doctor.getName(), session_id, "28", evalueContent.toString(),null);
		//保存系统消息服务评价
		//systemMsgEvaluation(doctor,patient,cons,consultTeam,consult,wxId);
		String endName = "";
		String endId = "";
		JSONObject obj = new JSONObject();
		//结束咨询才发送推送给IM文字消息
		if (endType == 1) {
			BasePatientDO p = basePatientDao.findById(endOperator);
			endName = p.getName();
			endId = p.getId();
			obj = imUtil.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
		} else {
			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
			if (endOperator.equals("admin")) {
				endId = "system";
				endName = "超时,系统自动";
			} else {
				endId = d.getId();
				endName = d.getName();
			}
			obj = imUtil.endTopics(consultTeam.getDoctor(), endId, endName, consultTeam.getConsult());
		}
		if (obj == null) {
			throw new RuntimeException("IM消息结束异常!");
		}
		if (obj.getInteger("status") == -1) {
			throw new RuntimeException(String.valueOf(obj.get("message")));
		}
		consultTeam.setEndMsgId(obj.getString("id"));
		cons.setEndTime(new Date());
		consultTeam.setEndTime(new Date());
		consultTeam.setStatus(1);
		consultDao.save(cons);
		consultTeamDao.save(consultTeam);
		//判断是否是在线复诊
		/*if(cons.getRelationCode() != null){
			WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(cons.getRelationCode());
			if(wlyyOutpatientDO != null && wlyyOutpatientDO.getId() != null){
				if (wlyyOutpatientDO.getStatus().equalsIgnoreCase("0")){
					wlyyOutpatientDO.setStatus("-1");
				}else {
					wlyyOutpatientDO.setStatus("3");
				}
				outpatientDao.save(wlyyOutpatientDO);
			}
			List<WlyyHospitalWaitingRoomDO> wlyyHospitalWaitingRoomDOS = hospitalWaitingRoomDao.findByOutpatientId(cons.getRelationCode());
			if(!wlyyHospitalWaitingRoomDOS.isEmpty()){
				for (WlyyHospitalWaitingRoomDO wlyyHospitalWaitingRoomDO:wlyyHospitalWaitingRoomDOS){
					wlyyHospitalWaitingRoomDO.setVisitStatus(2);
					hospitalWaitingRoomDao.save(wlyyHospitalWaitingRoomDO);
				}
			}
		}*/
		if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
			if (!flag){
				BusinessOrderDO businessOrderDO = new BusinessOrderDO();
				if(cons.getRelationCode() != null){
					businessOrderDO  = businessOrderDao.selectByRelationCode(cons.getRelationCode());
				}else {
					businessOrderDO  = businessOrderDao.selectByRelationCode(consult);
				}
				if (businessOrderDO!=null){
					String sql ="SELECT * FROM topics t where " +
							"t.id='"+consult+"' and t.reply_user is null and t.reply is null and t.status IN(0,1) ";
					List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
					System.out.println("sql+-----"+sql);
					if (null!=mapList&&mapList.size()>0&&mapList.size()==1){
						//医生没回复的话要把状态改为关闭 status=?
						System.out.println("-------------------进入未回复状态同步--------------------");
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"3");
					}else {
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"4");
					}
				}
			}
		}
		return 1;
	}
	public void systemMsgEvaluation(BaseDoctorDO doctor,BasePatientDO patient,ConsultDo cons,ConsultTeamDo consultTeam ,String consult,String wxId){
		SystemMessageDO messageDO = new SystemMessageDO();

+ 1 - 2
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -164,9 +164,8 @@ public class DateUtil {
    }
    public static String getYyyymmddhhmmss(Date date) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDDHHMMSS);
        return formatter.format(currentTime);
        return formatter.format(date);
    }
    /**

+ 82 - 82
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -101,9 +101,10 @@ public class TimeoutOverDueService {
                            try {
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)){
                                    imService.finish(consultCode,"admin",2);
                                    //医生未回复可以退费
                                if(StringUtils.isNoneBlank(consultCode)) {
                                    imService.cancelRevisit(consultCode, "admin", 2);
                                }
                                    /*//医生未回复可以退费
                                    businessOrderService.consultRefund(consultCode,wechatId);
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
@ -111,90 +112,89 @@ public class TimeoutOverDueService {
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                }else{
                                    //判断医生是否接诊
                                    List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                                    if (roomDOs != null && roomDOs.size() > 0) {
                                        for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                            if (roomDO.getVisitStatus() == 2) {
                                                logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                            } else {
                                                roomDO.setVisitStatus(-1);
                                                logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                                hospitalWaitingRoomDao.save(roomDO);
                                            }
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");*/
                                //判断医生是否接诊
                                List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                                if (roomDOs != null && roomDOs.size() > 0) {
                                    for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                        if (roomDO.getVisitStatus() == 2) {
                                            logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                        } else {
                                            roomDO.setVisitStatus(-1);
                                            logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                            hospitalWaitingRoomDao.save(roomDO);
                                        }
                                    }
                                    //更改门诊状态
                                    wlyyOutpatientDO.setStatus("-1");
                                    String description = null;
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
                                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    description = cancelValue;
                                    //系统消息
                                    SystemMessageDO messageDO = new SystemMessageDO();
                                    messageDO.setTitle("超时订单系统自动取消");
                                    messageDO.setType("13");
                                    messageDO.setSender(wlyyOutpatientDO.getDoctor());
                                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                    messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                    data.put("name", wlyyOutpatientDO.getPatientName());
                                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                                    String msg = "";
                                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "9");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                                    }
                                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "16");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                                    }
                                    data.put("msg", msg);
                                    messageDO.setData(data.toString());
                                    systemMessageService.saveMessage(messageDO);
                                    //推送消息到眼科通
                                    BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                        logger.info("推送消息到眼科通");
                                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                                    }
                                    //删除门诊号源
                                    List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                    if (list != null && list.size() > 0) {
                                        patientRegisterTimeDao.delete(list);
                                    }
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                    if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                        businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                        //眼科接诊时更新眼科通状态
                                        if (businessOrderDO!=null){
                                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                        }
                                    } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                                }
                                //更改门诊状态
                                wlyyOutpatientDO.setStatus("-1");
                                String description = null;
                                wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                wlyyOutpatientDO.setDoctorCancelType("6");
                                wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                wlyyOutpatientDO.setEndTime(new Date());
                                wlyyOutpatientDO.setOperator("system");
                                description = cancelValue;
                                //系统消息
                                SystemMessageDO messageDO = new SystemMessageDO();
                                messageDO.setTitle("超时订单系统自动取消");
                                messageDO.setType("13");
                                messageDO.setSender(wlyyOutpatientDO.getDoctor());
                                messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                                messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                data.put("name", wlyyOutpatientDO.getPatientName());
                                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("question", wlyyOutpatientDO.getIcd10Name());
                                String msg = "";
                                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                    data.put("type", "9");
                                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                                }
                                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                    data.put("type", "16");
                                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                                }
                                data.put("msg", msg);
                                messageDO.setData(data.toString());
                                systemMessageService.saveMessage(messageDO);
                                //推送消息到眼科通
                                BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                    logger.info("推送消息到眼科通");
                                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                                }
                                //删除门诊号源
                                List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                if (list != null && list.size() > 0) {
                                    patientRegisterTimeDao.delete(list);
                                }
                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                    businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                    //眼科接诊时更新眼科通状态
                                    if (businessOrderDO!=null){
                                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                    }
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
    /*
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                                }
                            }catch(Exception e)  {
                                e.printStackTrace();
                                logger.info("自动结束咨询报错 consultCode: "+consultCode);
                            }
                                outpatientDao.save(wlyyOutpatientDO);
                                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        }
                                }catch(Exception e)  {
                                    e.printStackTrace();
                                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                                }
                            }
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");

+ 5 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -997,7 +997,9 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            WlyyPrescriptionExpressageDO wlyyPrescriptionExpressageDO = expressList.get(0);
            if (null!=wlyyPrescriptionExpressageDO&&wlyyPrescriptionExpressageDO.getOneselfPickupFlg()==1){
                //同步his写入自取信息
                String updatesql = "update v_ms_dd01 t set t.PSFS = 0 ,t.FKZT=1 where t.JZXH = '"+wlyyPrescriptionDO.getAdmNo()+"' and t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                String updatesql = "update v_ms_dd01 t set t.PSFS = 0 ,t.FKZT=1 ," +
                        " t.YFSB = '"+wlyyPrescriptionExpressageDO.getHospitalCode()+"'"+
                        "where t.JZXH = '"+wlyyPrescriptionDO.getAdmNo()+"' and t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                ykyyEntranceService.updateHisStatus(updatesql);
                logger.info("自取写入更新his");
            }else {
@ -1021,7 +1023,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                    logger.info("---获取订单号为:"+sfOrder);
                    String updatesql = "update v_ms_dd01 t set t.PSFS = 1 ,t.FKZT=1 ,t.KDDH ='"+sfOrder+"',t.SJR = '"+wlyyPrescriptionExpressageDO.getName()+"' ," +
                            " t.SJRDH = '"+wlyyPrescriptionExpressageDO.getMobile()+"' ,"+
                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"'"+
                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"' ,"+
                            " t.YFSB = 6"+
                            " where t.JZXH = '"+admNo+"' and t.CFSB ='"+realOrder+"'";
                    ykyyEntranceService.updateHisStatus(updatesql);
                    logger.info("更新his成功");

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

@ -695,14 +695,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        //修改consult门诊状态
        //修改consult门诊状态
        ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
        /*ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
        if (null!=consultDo){
            ConsultTeamDo consultTeamDo = consultTeamDao.findByConsult(consultDo.getId());
            if (null!=consultTeamDo){
                consultTeamDo.setStatus(-1);
                consultTeamDao.save(consultTeamDo);
            }
        }*/
        try {
            String consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
            System.out.println("consultCode"+consultCode);
            if(StringUtils.isNoneBlank(consultCode)) {
                imService.cancelRevisit(consultCode, "admin", 2);
            }
        }catch (Exception e){
            System.out.println("居民取消复诊失败");
        }
        return success(prescriptionService.cancelOutPatient(outPatientId,cancelType,cancelValue,cancelRemark,1,wxId));
    }