LAPTOP-KB9HII50\70708 1 рік тому
батько
коміт
2b429adbaa

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

@ -5334,7 +5334,25 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs;
    }
    //发送短信
    public void sendSms(String phone,String content,String type){
        try {
            if("2".equals(type)){
                //新增判断是否给医生发送消息
                WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("isSendDoctorSms").orElse(null);
                if(dictDO==null||"0".equals(dictDO.getDictValue())){
                    //不发送
                    return;
                }
            }
            if(StringUtils.isNotBlank(phone)&&StringUtils.isNotBlank(content)){
               int i= dsyyPrescriptionService.SendSms(phone,content);
               logger.info("phone="+phone+";content="+content+","+i);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 发送微信模板消息  本地无法测试消息是否发送成功
@ -5345,135 +5363,152 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param remindMsg
     */
    public void sendWxTemplateMsg(String wxId, String outpatientId,ConsultTeamDo consultTeam,  String type, String titelType, String remindMsg) {
        if("xm_dsyy_wx".equals(wxId)){
            //三院的先不发模板消息
            return;
        }
        BaseDoctorDO consDoctorDO = new BaseDoctorDO();
        BasePatientDO consPatientDO = new BasePatientDO();
        BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
        //获取咨询的信息
        String msgUrl="";
        if (consultTeam!=null){
            consDoctorDO = baseDoctorDao.findByIdAndDel(consultTeam.getDoctor());
            consPatientDO = basePatientDao.findById(consultTeam.getPatient()).orElse(null);
            List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(consultTeam.getDoctor());
            if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()>=0){
                hospitalDO=doctorHospitalDOS.get(0);
        try {
            BaseDoctorDO consDoctorDO = new BaseDoctorDO();
            BasePatientDO consPatientDO = new BasePatientDO();
            BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
            //获取咨询的信息
            String msgUrl="";
            if (consultTeam!=null){
                consDoctorDO = baseDoctorDao.findByIdAndDel(consultTeam.getDoctor());
                consPatientDO = basePatientDao.findById(consultTeam.getPatient()).orElse(null);
                List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(consultTeam.getDoctor());
                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()>=0){
                    hospitalDO=doctorHospitalDOS.get(0);
                }
            }
        }
        WlyyOutpatientDO outpatientDO = new WlyyOutpatientDO();
        BaseDoctorDO doctorDO = new BaseDoctorDO();
        BasePatientDO patientDO = new BasePatientDO();
        if (StringUtils.isNotEmpty(outpatientId)){
            outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
            doctorDO = baseDoctorDao.findByIdAndDel(outpatientDO.getDoctor());
            patientDO = basePatientDao.findById(outpatientDO.getConsumer()).orElse(null);
        }
        logger.info("titelType:"+titelType+"&&remindMsg:"+remindMsg+"&&type"+type);
        String contentMsg = "";
        String first = "";
        String remark = "";
        if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
            //医生拒绝接诊
            if ("9".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
            }
            if ("16".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
            }
            if ("1".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
            }
            if ("17".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
            }
            logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
            //医生未接诊时患者等待时间过长的模板提示
            contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
            first = outpatientDO.getConsumerName() + ",您好!";
            logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("doctorPick".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "您发起的图文复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊,医生已接诊";
            }
            if ("16".equals(type)) {
                contentMsg =  "您发起的视频复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊,医生已接诊";
            }
            if ("1".equals(type)) {
                contentMsg =  "您发起的图文咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询,医生已接诊";
            }
            if ("17".equals(type)) {
                contentMsg = "您发起的视频咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询,医生已接诊";
            }
            if ("12".equals(type)) {
                contentMsg = "您发起的专科协同已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的专科协同,医生已接诊";
                return;
            }
            if ("15".equals(type)) {
                contentMsg = "您发起的家医咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的家医咨询,医生已接诊";
            }
            logger.info("doctorPick诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("doctorRefund".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊已退号";
            }
            if ("16".equals(type)) {
                contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊已退号";
            WlyyOutpatientDO outpatientDO = new WlyyOutpatientDO();
            BaseDoctorDO doctorDO = new BaseDoctorDO();
            BasePatientDO patientDO = new BasePatientDO();
            if (StringUtils.isNotEmpty(outpatientId)){
                outpatientDO = outpatientDao.findById(outpatientId).orElse(null);
                doctorDO = baseDoctorDao.findByIdAndDel(outpatientDO.getDoctor());
                patientDO = basePatientDao.findById(outpatientDO.getConsumer()).orElse(null);
            }
            if ("1".equals(type)) {
                contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询已退号";
            }
            if ("17".equals(type)) {
                contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询已退号";
            }
            logger.info("doctorRefund:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("patientCancel".equalsIgnoreCase(titelType)) {
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
            if (outpatientDO.getPayStatus()==1){
                if (hospitalSysDictDO!=null){
                    if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                        if ("9".equals(type)) {
                            contentMsg = "您发起的图文复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                        }
                        if ("16".equals(type)) {
                            contentMsg =  "您发起的视频复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                        }
                        if ("1".equals(type)) {
                            contentMsg =  "您发起的图文咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                        }
                        if ("17".equals(type)) {
                            contentMsg = "您发起的视频咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                        }
                        if ("12".equals(type)) {
                            return;
            logger.info("titelType:"+titelType+"&&remindMsg:"+remindMsg+"&&type"+type);
            String patientPhone = patientDO.getMobile();
            String contentMsg = "";
            String first = "";
            String remark = "";
            if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                //医生拒绝接诊
                if ("9".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
                }
                if ("16".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
                }
                if ("1".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
                }
                if ("17".equals(type)) {
                    contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                    first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
                }
                logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
                //医生未接诊时患者等待时间过长的模板提示
                contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
                first = outpatientDO.getConsumerName() + ",您好!";
                logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if("doctorPick".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊,医生已接诊";
                }
                if ("16".equals(type)) {
                    contentMsg =  "您发起的视频复诊已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊,医生已接诊";
                }
                if ("1".equals(type)) {
                    contentMsg =  "您发起的图文咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询,医生已接诊";
                }
                if ("17".equals(type)) {
                    contentMsg = "您发起的视频咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询,医生已接诊";
                }
                if ("12".equals(type)) {
                    contentMsg = "您发起的专科协同已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的专科协同,医生已接诊";
                    return;
                }
                if ("15".equals(type)) {
                    contentMsg = "您发起的家医咨询已被"+outpatientDO.getDoctorName()+"接诊,请留意医生发送的消息。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的家医咨询,医生已接诊";
                }
                logger.info("doctorPick诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("doctorRefund".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                    contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文复诊已退号";
                }
                if ("16".equals(type)) {
                    contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频复诊已退号";
                }
                if ("1".equals(type)) {
                    contentMsg =  "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的图文咨询已退号";
                }
                if ("17".equals(type)) {
                    contentMsg = "金额已退到门诊预交金。如需退款(18元)请到门诊收费处退款。";
                    first = outpatientDO.getConsumerName() + ",您好!您发起的视频咨询已退号";
                }
                logger.info("doctorRefund:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            } else if("patientCancel".equalsIgnoreCase(titelType)) {
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
                if (outpatientDO.getPayStatus()==1){
                    if (hospitalSysDictDO!=null){
                        if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                            }
                            if ("16".equals(type)) {
                                contentMsg =  "您发起的视频复诊已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                            }
                            if ("1".equals(type)) {
                                contentMsg =  "您发起的图文咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                            }
                            if ("17".equals(type)) {
                                contentMsg = "您发起的视频咨询已被您取消。已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                            }
                            if ("12".equals(type)) {
                                return;
                            }
                        }else {
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                            }
                            if ("16".equals(type)) {
                                contentMsg =  "您发起的视频复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                            }
                            if ("1".equals(type)) {
                                contentMsg =  "您发起的图文咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                            }
                            if ("17".equals(type)) {
                                contentMsg = "您发起的视频咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                            }
                            if ("12".equals(type)) {
                                return;
                            }
                        }
                    }else {
                        if ("9".equals(type)) {
@ -5498,62 +5533,51 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                }else {
                    if ("9".equals(type)) {
                        contentMsg = "您发起的图文复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的图文复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                    }
                    if ("16".equals(type)) {
                        contentMsg =  "您发起的视频复诊已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg =  "您发起的视频复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                    }
                    if ("1".equals(type)) {
                        contentMsg =  "您发起的图文咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg =  "您发起的图文咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                    }
                    if ("17".equals(type)) {
                        contentMsg = "您发起的视频咨询已被您取消。请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的视频咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                    }
                    if ("12".equals(type)) {
                        return;
                    }
                }
            }else {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已被您取消,您可重新发起";
                }
                if ("16".equals(type)) {
                    contentMsg =  "您发起的视频复诊已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已被您取消,您可重新发起";
                }
                if ("1".equals(type)) {
                    contentMsg =  "您发起的图文咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已被您取消,您可重新发起";
                }
                if ("17".equals(type)) {
                    contentMsg = "您发起的视频咨询已被您取消。如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已被您取消,您可重新发起";
                }
                if ("12".equals(type)) {
                    return;
                }
            }
            logger.info("patientCancel诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
            //超过24小时未接诊,系统取消
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
            if (outpatientDO.getPayStatus()==1){
                if (hospitalSysDictDO!=null){
                    if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                        if ("9".equals(type)) {
                            contentMsg = "您发起的图文复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                        }
                        if ("16".equals(type)) {
                            contentMsg = "您发起的视频复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                            first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                logger.info("patientCancel诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
                //超过24小时未接诊,系统取消
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("isCloseRefund").orElse(null);
                if (outpatientDO.getPayStatus()==1){
                    if (hospitalSysDictDO!=null){
                        if (hospitalSysDictDO.getDictValue().equalsIgnoreCase("1")){
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                            }
                            if ("16".equals(type)) {
                                contentMsg = "您发起的视频复诊已取消,已支付的18元将原路退回,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                            }
                        }else {
                            if ("9".equals(type)) {
                                contentMsg = "您发起的图文复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                            }
                            if ("16".equals(type)) {
                                contentMsg = "您发起的视频复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                            }
                        }
                    }else {
                        if ("9".equals(type)) {
@ -5567,450 +5591,455 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                }else {
                    if ("9".equals(type)) {
                        contentMsg = "您发起的图文复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的图文复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                    }
                    if ("16".equals(type)) {
                        contentMsg = "您发起的视频复诊已取消,请前往收费窗口进行退款,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        contentMsg = "您发起的视频复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                        first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                    }
                }
            }else {
                if ("9".equals(type)) {
                    contentMsg = "您发起的图文复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超过24小时未接诊已自动取消图文咨询。";
                }
                if ("16".equals(type)) {
                    contentMsg = "您发起的视频复诊已取消,如有问诊需求,可重新发起或到医院门急诊就诊。";
                    first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超过24小时未接诊已自动取消视频咨询。";
                }
            }
            logger.info("系统取消接诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if ("payRemind".equalsIgnoreCase(titelType)) {
            //患者发起时提醒患者支付诊费消息
            if ("9".equals(type)) {
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("图文复诊订单待支付微信消息模板推送开始");
            } else if ("16".equals(type)) {
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("视频复诊订单待支付微信消息模板推送开始");
            }else if ("1".equals(type)) {
                contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                logger.info("系统取消接诊入参:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                logger.info("图文咨询订单待支付微信消息模板推送开始");
            } else if ("17".equals(type)) {
                contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                logger.info("视频咨询订单待支付微信消息模板推送开始");
            }else {
                return;
            }
        } else if ("paySuccess".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "您已成功发起图文复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文复诊";
            }else if ("16".equals(type)) {
                contentMsg =  "您已成功发起视频复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频复诊";
            }else if ("1".equals(type)) {
                contentMsg =  "您已成功发起图文咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文咨询";
            }else if ("17".equals(type)) {
                contentMsg = "您已成功发起视频咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频咨询";
            }else {
                return;
            }
            logger.info("paySuccess诊查费支付成功推送模板消息:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
            //开具处方后向患者发送支付提醒
            first = outpatientDO.getConsumerName() + ",您好! 医生已为您开具处方,请及时支付。";
            contentMsg = "医生已为您开具处方,请及时支付。";
            remark = "点击完成支付,如您已支付请忽略本条信息";
            msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
            logger.info("处方支付微信消息模板推送开始");
        }else if ("diagnoPayRemind".equalsIgnoreCase(titelType)) {
            //开具处方后向患者发送支付提醒
            first = outpatientDO.getConsumerName() + ",您好! 您的问诊已结束,请及时结算费用。";
            contentMsg = "您好! 您的问诊已结束,请及时结算费用。";
            remark = "点击完成支付,如您已支付请忽略本条信息";
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            logger.info("诊查费微信消息模板推送开始");
        } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
            //视频复诊预约提醒
            if ("16".equals(type)) {
                msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                    first = "您的视频复诊已预约成功。";
                    contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                }else {
                    first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
                    contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
                }
                logger.info("视频复诊已预约成功微信消息模板推送开始");
            } else if ("17".equals(type)) {
                if (StringUtils.isNotEmpty(outpatientId)){
                    msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                    if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                        first = "您的视频咨询已预约成功。";
                        contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                    }else{
                        first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
                        contentMsg = "您已预约" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
                    }
                }else{
                    msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                    contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                }
                logger.info("视频咨询已预约成功微信消息模板推送开始");
            }
            remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
        } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
            //服务评价提醒
            if (consultTeam.getType()!=null&&1==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
                logger.info("图文咨询服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&9==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
                logger.info("图文复诊服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&16==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
                logger.info("视频复诊服务评价微信消息模板推送开始");
            }else if (consultTeam.getType()!=null&&17==consultTeam.getType()){
                first = consultTeam.getName() + ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
                logger.info("视频咨询服务评价微信消息模板推送开始");
            }else {
                return;
            }
            contentMsg = "请对" + consDoctorDO.getName() + "医生的服务进行评价";
            msgUrl="/ims-wx/index.html#/fuwupingjia?consultCode="+consultTeam.getConsult();
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)||"sd_tnzyy_wx".equalsIgnoreCase(wxId)) {
            List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
            if (StringUtils.isNotEmpty(outpatientId)){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
            }
            if (consultTeam!=null){
                ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, consultTeam.getPatient());
            }
            if (ps.isEmpty()) {
                logger.info("该用户" + outpatientDO.getConsumerName() + "没有openid,无法推送模版消息,用户ID:" + outpatientDO.getPatient() + "wechatId:" + wxId);
                return;
            }
            String scene = "";
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                //医生拒绝接诊
                scene = "ysqxjz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3( doctorDO.getFee());
                newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 医生拒诊开始");
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("cancel_remind",outpatientDO,null,"","","","");
                /*String res = wxTempalteJPush(outpatientDO.getConsumer(),newConfig.getFirst(),"医生拒绝了你的问诊",type,outpatientDO.getId());
                logger.info("JPUSH res==="+res);*/
            }else if("outPatientTimeOutRemind".equals(titelType)){
                //就诊等待过长提示
                scene="jzddgcts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_timeout_remind", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("就诊等待过长提示");
            } else if ("payRemind".equalsIgnoreCase(titelType)) {
                //诊费支付提示
                scene = "zxzfts";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_jz", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                //患者发起时提醒患者支付诊费消息
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊支付");
                    contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                    first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    logger.info("图文复诊订单待支付微信消息模板推送开始");
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setKeyword1( "视频复诊支付");
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setKeyword1("图文咨询支付");
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setKeyword1("视频咨询支付");
                }
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                logger.info("极光消息推送 就诊支付提醒开始");
                wxTempalteJPush("outpatient_pay",outpatientDO,null,"","","","");
            } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                //诊费支付成功提示
                scene = "zfcgtx";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_success", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊支付");
                    newConfig.setRemark(config.getRemark().replace("key2","图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setRemark(config.getRemark().replace("key2","视频复诊"));
                    newConfig.setKeyword1( "视频复诊支付");
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setRemark(config.getRemark().replace("key2","图文咨询"));
                    newConfig.setKeyword1("图文咨询支付");
                    contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                    first = outpatientDO.getConsumerName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    logger.info("视频复诊订单待支付微信消息模板推送开始");
                }else if ("1".equals(type)) {
                    contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                    logger.info("图文咨询订单待支付微信消息模板推送开始");
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setRemark(config.getRemark().replace("key2","视频咨询"));
                    newConfig.setKeyword1("视频咨询支付");
                }
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
            } else if ("doctorPick".equalsIgnoreCase(titelType)) {
                //诊费支付成功提示
                scene = "ysjzts";
                //就诊支付
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_pick", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    newConfig.setKeyword1( "图文复诊接诊");
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    newConfig.setKeyword1( "视频复诊接诊");
                    contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                    logger.info("视频咨询订单待支付微信消息模板推送开始");
                }else {
                    return;
                }
                if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    newConfig.setKeyword1("图文咨询接诊");
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    newConfig.setKeyword1("视频咨询接诊");
                }
                newConfig.setRemark(config.getRemark().replace("key1",outpatientDO.getDoctorName()));
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
            }else if ("patientCancel".equalsIgnoreCase(titelType)) {
                scene = "hzqxfz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_patient_cancel", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
            } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    contentMsg = "您已成功发起图文复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文复诊";
                }else if ("16".equals(type)) {
                    contentMsg =  "您已成功发起视频复诊,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频复诊";
                }else if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() + URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送");
                    contentMsg =  "您已成功发起图文咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起图文咨询";
                }else if ("17".equals(type)) {
                    contentMsg = "您已成功发起视频咨询,请耐心等待医生接单。如长时间未接诊,建议选择其他医生";
                    first = outpatientDO.getConsumerName() + ",您好!您已成功发起视频咨询";
                }else {
                    return;
                }
                logger.info("paySuccess诊查费支付成功推送模板消息:outpatientId="+outpatientId);
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
            }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
                //处方开具支付提醒
                scene = "cfzfts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                newConfig.setKeyword1( "处方支付");
                newConfig.setKeyword2(outpatientDO.getHospitalName());
                newConfig.setKeyword3(outpatientDO.getDoctorName());
                String path = "returnVisit/preChat?type=16&outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path) );
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 处方支付提醒开始");
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("prescription_pay",outpatientDO,null,"","","",remindMsg);
            }else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                //视频问诊预约提醒
                scene = "spwzyytx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                //开具处方后向患者发送支付提醒
                first = outpatientDO.getConsumerName() + ",您好! 医生已为您开具处方,请及时支付。";
                contentMsg = "医生已为您开具处方,请及时支付。";
                remark = "点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
                logger.info("处方支付微信消息模板推送开始");
            }else if ("diagnoPayRemind".equalsIgnoreCase(titelType)) {
                //开具处方后向患者发送支付提醒
                first = outpatientDO.getConsumerName() + ",您好! 您的问诊已结束,请及时结算费用。";
                contentMsg = "您好! 您的问诊已结束,请及时结算费用。";
                remark = "点击完成支付,如您已支付请忽略本条信息";
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("诊查费微信消息模板推送开始");
            } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                //视频复诊预约提醒
                if ("16".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                    msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                    if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                        first = "您的视频复诊已预约成功。";
                        contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                    }else {
                        first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
                        contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
                    }
                    logger.info("视频复诊已预约成功微信消息模板推送开始");
                } else if ("17".equals(type)) {
                    if (StringUtils.isNotEmpty(outpatientId)){
                        msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                        if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                            first = "您的视频咨询已预约成功。";
                            contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                        }else{
                            first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
                            contentMsg = "您已预约" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
                        }
                    }else{
                        msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                        contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频咨询。请留意微信公众号消息。";
                    }
                    logger.info("视频咨询已预约成功微信消息模板推送开始");
                }
                if ("17".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                }
                newConfig.setKeyword1( outpatientDO.getConsumerName());
                newConfig.setKeyword2( outpatientDO.getDeptName());
                newConfig.setKeyword3( outpatientDO.getDoctorName());
                newConfig.setKeyword4(DateUtil.dateToStrLong(outpatientDO.getRegisterDate()));
                newConfig.setKeyword5(generalDoctorWaitingNumber(doctorDO.getId(), wxId, outpatientId));
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
                remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
            } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
                //服务评价提醒
                scene = "fwqjtx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replaceFirst("key1", consPatientDO.getName()));
                newConfig.setKeyword2(hospitalDO.getOrgName());
                newConfig.setKeyword3(consDoctorDO.getName());
                String path = "fuwupingjia?consultCode="+consultTeam.getConsult();
                newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                logger.info("极光消息推送 医生拒诊开始");
                wxTempalteJPush("give_score",null,consultTeam,"","","","");
                logger.info("眼科微信消息模板推送 服务评价提醒开始");
            } else if ("systemCancelRemind".equalsIgnoreCase(titelType)) {
                //系统24小时取消复诊提醒
                scene = "xtqxfz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_system_cancel", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }else if ("1".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                } else if ("17".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                if (consultTeam.getType()!=null&&1==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
                    logger.info("图文咨询服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&9==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
                    logger.info("图文复诊服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&16==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
                    logger.info("视频复诊服务评价微信消息模板推送开始");
                }else if (consultTeam.getType()!=null&&17==consultTeam.getType()){
                    first = consultTeam.getName() + ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
                    logger.info("视频咨询服务评价微信消息模板推送开始");
                }else {
                    return;
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 系统拒诊开始");
            }
            logger.info("=======setUrl========" + newConfig.getUrl());
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            for (BasePatientWechatDo one : ps) {
                logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
                try {
                    logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
                    logger.info("发送成功");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info("发送失败,error="+e.getMessage());
                contentMsg = "请对" + consDoctorDO.getName() + "医生的服务进行评价";
                msgUrl="/ims-wx/index.html#/fuwupingjia?consultCode="+consultTeam.getConsult();
            }
            if("xm_dsyy_wx".equalsIgnoreCase(wxId)){
                //暂时只发生这些
                Map<String,Integer> patientMap = new HashMap<>();
                patientMap.put("doctorRefuseRemind",1);
                patientMap.put("evaluateRemind",1);
                patientMap.put("doctorPick",1);
                patientMap.put("patientCancel",1);
                patientMap.put("systemCancelRemind",1);
                patientMap.put("prescriptionPayRemind",1);
                patientMap.put("evaluateRemind",1);
                if(patientMap.containsKey(titelType)){
                    sendSms(patientPhone,contentMsg,"1");
                }
            }else if ("xm_ykyy_wx".equalsIgnoreCase(wxId)||"sd_tnzyy_wx".equalsIgnoreCase(wxId)) {
                List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
                if (StringUtils.isNotEmpty(outpatientId)){
                    ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
                }
                if (consultTeam!=null){
                    ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, consultTeam.getPatient());
                }
                //保存发送模板记录,
                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                wxPushLogDO.setCreateTime(new Date());
                wxPushLogDO.setOpenid(one.getOpenid());
                wxPushLogDO.setReceiver(outpatientDO.getPatient());
                wxPushLogDO.setWechatId(wechatId);
                wxPushLogDO.setReceiverName(outpatientDO.getConsumerName());
                wxPushLogDO.setScene(scene);
                wxPushLogDao.save(wxPushLogDO);
            }
                if (ps.isEmpty()) {
                    logger.info("该用户" + outpatientDO.getConsumerName() + "没有openid,无法推送模版消息,用户ID:" + outpatientDO.getPatient() + "wechatId:" + wxId);
                    return;
                }
                String scene = "";
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
                    //医生拒绝接诊
                    scene = "ysqxjz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3( doctorDO.getFee());
                    newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 医生拒诊开始");
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("cancel_remind",outpatientDO,null,"","","","");
                /*String res = wxTempalteJPush(outpatientDO.getConsumer(),newConfig.getFirst(),"医生拒绝了你的问诊",type,outpatientDO.getId());
                logger.info("JPUSH res==="+res);*/
                }else if("outPatientTimeOutRemind".equals(titelType)){
                    //就诊等待过长提示
                    scene="jzddgcts";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_timeout_remind", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setPagepath(newConfig.getPagepath() + "" + outpatientDO.getId());
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("就诊等待过长提示");
                } else if ("payRemind".equalsIgnoreCase(titelType)) {
                    //诊费支付提示
                    scene = "zxzfts";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_jz", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊支付");
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setKeyword1( "视频复诊支付");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setKeyword1("图文咨询支付");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setKeyword1("视频咨询支付");
                    }
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                    logger.info("极光消息推送 就诊支付提醒开始");
                    wxTempalteJPush("outpatient_pay",outpatientDO,null,"","","","");
                } else if ("paySuccess".equalsIgnoreCase(titelType)) {
                    //诊费支付成功提示
                    scene = "zfcgtx";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_success", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊支付");
                        newConfig.setRemark(config.getRemark().replace("key2","图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setRemark(config.getRemark().replace("key2","视频复诊"));
                        newConfig.setKeyword1( "视频复诊支付");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setRemark(config.getRemark().replace("key2","图文咨询"));
                        newConfig.setKeyword1("图文咨询支付");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setRemark(config.getRemark().replace("key2","视频咨询"));
                        newConfig.setKeyword1("视频咨询支付");
                    }
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                } else if ("doctorPick".equalsIgnoreCase(titelType)) {
                    //诊费支付成功提示
                    scene = "ysjzts";
                    //就诊支付
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_doctor_pick", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                        newConfig.setKeyword1( "图文复诊接诊");
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setKeyword1( "视频复诊接诊");
                    }
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setKeyword1("图文咨询接诊");
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setKeyword1("视频咨询接诊");
                    }
                    newConfig.setRemark(config.getRemark().replace("key1",outpatientDO.getDoctorName()));
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                }else if ("patientCancel".equalsIgnoreCase(titelType)) {
                    scene = "hzqxfz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_patient_cancel", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }else if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() + URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送");
                }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
                    //处方开具支付提醒
                    scene = "cfzfts";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    newConfig.setKeyword1( "处方支付");
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    String path = "returnVisit/preChat?type=16&outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path) );
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 处方支付提醒开始");
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("prescription_pay",outpatientDO,null,"","","",remindMsg);
                }else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                    //视频问诊预约提醒
                    scene = "spwzyytx";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    if ("16".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                    }
                    if ("17".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getConsumerName());
                    newConfig.setKeyword2( outpatientDO.getDeptName());
                    newConfig.setKeyword3( outpatientDO.getDoctorName());
                    newConfig.setKeyword4(DateUtil.dateToStrLong(outpatientDO.getRegisterDate()));
                    newConfig.setKeyword5(generalDoctorWaitingNumber(doctorDO.getId(), wxId, outpatientId));
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
                } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
                    //服务评价提醒
                    scene = "fwqjtx";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", consPatientDO.getName()));
                    newConfig.setKeyword2(hospitalDO.getOrgName());
                    newConfig.setKeyword3(consDoctorDO.getName());
                    String path = "fuwupingjia?consultCode="+consultTeam.getConsult();
                    newConfig.setPagepath(newConfig.getPagepath()+URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                    logger.info("极光消息推送 医生拒诊开始");
                    wxTempalteJPush("give_score",null,consultTeam,"","","","");
                    logger.info("眼科微信消息模板推送 服务评价提醒开始");
                } else if ("systemCancelRemind".equalsIgnoreCase(titelType)) {
                    //系统24小时取消复诊提醒
                    scene = "xtqxfz";
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_system_cancel", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                    if ("9".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                    } else if ("16".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                    }else if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                    } else if ("17".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getHospitalName());
                    newConfig.setKeyword2(outpatientDO.getDoctorName());
                    newConfig.setKeyword3(outpatientDO.getFee()==null?"0":outpatientDO.getFee().toString());
                    String path = "returnVisit/record?outpatientId="+outpatientDO.getId();
                    newConfig.setPagepath(newConfig.getPagepath() +URLEncoder.encode(path));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 系统拒诊开始");
                }
                logger.info("=======setUrl========" + newConfig.getUrl());
                WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                for (BasePatientWechatDo one : ps) {
                    logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
                    try {
                        logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
                        logger.info("发送成功");
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info("发送失败,error="+e.getMessage());
                    }
        } else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
            String responseMsg="";
            //String prefix="https://www.xmheart.com";
            String prefix = "https://ih.xmheart.com/hlwyy";
            if(StringUtils.isNotEmpty(outpatientId)){
                responseMsg = xzzxEntranceService.sendMes(wxId,
                        patientDO.getId(),
                        patientDO.getIdcard(),
                        first,
                        contentMsg,
                        remark,
                        prefix+msgUrl);
            }
            if (consultTeam!=null&&consPatientDO!=null){
                responseMsg = xzzxEntranceService.sendMes(wxId,
                        consPatientDO.getId(),
                        consPatientDO.getIdcard(),
                        first,
                        contentMsg,
                        remark,
                        prefix+msgUrl);
            }
            logger.info("url="+prefix+msgUrl);
            String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
            logger.info("发送的信息="+msg);
            logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
        } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            String responseMsg="";
            String prefix="https://hlwyy.xmzsh.com";
            if(StringUtils.isNotEmpty(outpatientId)){
                responseMsg = entranceService.ehospitalNotice(
                        patientDO.getName(),
                        patientDO.getIdcard(),
                        patientDO.getMobile(),
                        first,
                        prefix+msgUrl,
                        contentMsg,
                        remark
                );
                System.out.println("结束发送模板消息");
            }
            if (consultTeam!=null&&consPatientDO!=null){
                responseMsg = entranceService.ehospitalNotice(
                        consPatientDO.getName(),
                        consPatientDO.getIdcard(),
                        consPatientDO.getMobile(),
                        first,
                        prefix+msgUrl,
                        contentMsg,
                        remark
                );
                    //保存发送模板记录,
                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                    wxPushLogDO.setCreateTime(new Date());
                    wxPushLogDO.setOpenid(one.getOpenid());
                    wxPushLogDO.setReceiver(outpatientDO.getPatient());
                    wxPushLogDO.setWechatId(wechatId);
                    wxPushLogDO.setReceiverName(outpatientDO.getConsumerName());
                    wxPushLogDO.setScene(scene);
                    wxPushLogDao.save(wxPushLogDO);
                }
            } else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
                String responseMsg="";
                //String prefix="https://www.xmheart.com";
                String prefix = "https://ih.xmheart.com/hlwyy";
                if(StringUtils.isNotEmpty(outpatientId)){
                    responseMsg = xzzxEntranceService.sendMes(wxId,
                            patientDO.getId(),
                            patientDO.getIdcard(),
                            first,
                            contentMsg,
                            remark,
                            prefix+msgUrl);
                }
                if (consultTeam!=null&&consPatientDO!=null){
                    responseMsg = xzzxEntranceService.sendMes(wxId,
                            consPatientDO.getId(),
                            consPatientDO.getIdcard(),
                            first,
                            contentMsg,
                            remark,
                            prefix+msgUrl);
                }
                logger.info("url="+prefix+msgUrl);
                String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
                logger.info("发送的信息="+msg);
                logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
            } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                String responseMsg="";
                String prefix="https://hlwyy.xmzsh.com";
                if(StringUtils.isNotEmpty(outpatientId)){
                    responseMsg = entranceService.ehospitalNotice(
                            patientDO.getName(),
                            patientDO.getIdcard(),
                            patientDO.getMobile(),
                            first,
                            prefix+msgUrl,
                            contentMsg,
                            remark
                    );
                    System.out.println("结束发送模板消息");
                }
                if (consultTeam!=null&&consPatientDO!=null){
                    responseMsg = entranceService.ehospitalNotice(
                            consPatientDO.getName(),
                            consPatientDO.getIdcard(),
                            consPatientDO.getMobile(),
                            first,
                            prefix+msgUrl,
                            contentMsg,
                            remark
                    );
                }
                logger.info("url="+prefix+msgUrl);
                String msg="first:"+first+"-----contentMsg:"+contentMsg+"-----remark:"+remark;
                logger.info("发送的信息="+msg);
                logger.info("ZSYY_Msg" + titelType + "=" + responseMsg);
            }
            logger.info("url="+prefix+msgUrl);
            String msg="first:"+first+"-----contentMsg:"+contentMsg+"-----remark:"+remark;
            logger.info("发送的信息="+msg);
            logger.info("ZSYY_Msg" + titelType + "=" + responseMsg);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
@ -8952,6 +8981,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String msg = "";
        try {
            JSONObject data = new JSONObject();
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
            String title = "";
            //1.在线复诊2.协同门诊
            if ("2".equals(outpatient.getOutpatientType())) {
                systemMessageDO.setTitle("协同门诊");
@ -8971,7 +9002,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                logger.info("添加模板消息4");
                systemMessageService.saveMessage(systemMessageDO);
                BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                }
@ -8984,11 +9015,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        saveInquirySystemMessage(outpatient,null);
                    }
                    msg="图文咨询";
                    title="图文咨询";
                } else if("3".equals(outpatient.getType())){
                    systemMessageDO.setTitle("家医咨询");
                    systemMessageDO.setType("15");
                    msg="家医咨询";
                    title="家医咨询";
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
@ -8998,6 +9031,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                    title = "视频咨询";
                    msg = "您的视频咨询已预约成功。\n" +
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
@ -9018,10 +9052,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                logger.info("添加模板消息4");
                systemMessageService.saveMessage(systemMessageDO);
                BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                }
                if("xm_dsyy_wx".equalsIgnoreCase(wechatId)){
                    sendSms(patient.getMobile(),"医生您好,患者"+outpatient.getPatientName()+"向您发起了"+title+",请及时查看","2");
                }
            } else if ("1".equals(outpatient.getOutpatientType()))  {        //在线复诊
                //1.图文 2.视频
                if ("1".equals(outpatient.getType())) {
@ -9047,6 +9083,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                                wlyyHttpLogDao.save(wlyyHttpLogDO);
                            }
                        }
                    }else  if("xm_dsyy_wx".equalsIgnoreCase(wechatId)){
                        sendSms(patient.getMobile(),"医生您好,患者"+outpatient.getPatientName()+"向您发起了图文问诊,请及时查看","2");
                    }
                } else {
                    systemMessageDO.setTitle("视频复诊预约成功");
@ -9077,7 +9115,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setData(data.toString());
                systemMessageService.saveMessage(systemMessageDO);
            }
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient()).orElse(null);
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
            }

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDischargeRecordDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/8/31.
 */
public interface BasePatientDischargeRecordDao extends PagingAndSortingRepository<BasePatientDischargeRecord, String>, JpaSpecificationExecutor<BasePatientDischargeRecord> {
}

+ 33 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientDischargeRecordService.java

@ -0,0 +1,33 @@
package com.yihu.jw.patient.service;
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BasePatientDischargeRecordDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * 
 * 患者出院记录service
 *
 */
@Service
public class BasePatientDischargeRecordService<T, R extends CrudRepository> extends BaseJpaService<BasePatientDischargeRecord, BasePatientDischargeRecordDao> {
    private static final Logger logger = LoggerFactory.getLogger(BasePatientDischargeRecordService.class);
    @Autowired
    private BasePatientDischargeRecordDao patientDischargeRecordDao;
    public BasePatientDischargeRecord pushPatientInfos(String idcard,String content){
        BasePatientDischargeRecord patientDischargeRecord = new BasePatientDischargeRecord();
        patientDischargeRecord.setIdcard(idcard);
        patientDischargeRecord.setContent(content);
        patientDischargeRecord.setCreateTime(new Date());
        return patientDischargeRecordDao.save(patientDischargeRecord);
    }
}

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

@ -3221,11 +3221,14 @@ public class ImService {
                sender_id = dictDO.getDictCode();
                sender_name = dictDO.getDictValue();
            }
            String msg2 = "医生已完成接诊,您可以点击右上角的【结束咨询】按钮,结束当前候诊";
            if (imUtil.sessionIsExist(session_id26)) {
                imUtil.sendImMsg(sender_id, sender_name, session_id26, "51", json.toJSONString(), "1", null);
                imUtil.sendImMsg(sender_id, sender_name, session_id26, "1", msg2, "1", null);
            }
            if (imUtil.sessionIsExist(session_id27)) {
                imUtil.sendImMsg(sender_id, sender_name, session_id27, "51", json.toJSONString(), "1", null);
                imUtil.sendImMsg(sender_id, sender_name, session_id27, "1", msg2, "1", null);
            }
        } catch (Exception e) {