소스 검색

医生排班Bug修复

mengkang 4 년 전
부모
커밋
ea8c3f255c
1개의 변경된 파일116개의 추가작업 그리고 97개의 파일을 삭제
  1. 116 97
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

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

@ -3316,12 +3316,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "9");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), "9", "doctorRefuse",null);
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), "9", "doctorRefuse", null);
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "16");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), "16", "doctorRefuse",null);
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), "16", "doctorRefuse", null);
                }
                data.put("msg", msg);
                messageDO.setData(data.toString());
@ -3458,8 +3458,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
        String contentMsg = "";
        String first = "";
        String remark="";
        if ("doctorRefuseRemind".equalsIgnoreCase(titelType)){
        String remark = "";
        if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "通知内容:您的图文复诊订单已被医生取消,您可重新发起。由于订单取消将不做扣费处理";
                first = outpatientDO.getPatientName() + ",您好!您的图文复诊已取消";
@ -3470,57 +3470,56 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                first = outpatientDO.getPatientName() + ",您好!您的视频复诊已取消";
            }
        } else if ("payRemind".equalsIgnoreCase(titelType)){
        } else if ("payRemind".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "通知内容:您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。";
            }else if ("16".equals(type)) {
            } else if ("16".equals(type)) {
                contentMsg = "通知内容:您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。";
            }else if ("1".equals(type)) {
            } else if ("1".equals(type)) {
                contentMsg = "通知内容:您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
            }else if ("17".equals(type)) {
            } else if ("17".equals(type)) {
                contentMsg = "通知内容:您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
            }
        }else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
            first=  outpatientDO.getPatientName() +",您好! 医生已为您开具处方,请及时支付。";
            contentMsg="通知内容:医生已为您开具处方,请及时支付。";
            remark="备注:点击完成支付,如您已支付请忽略本条信息";
        }else if ("msgRemind".equalsIgnoreCase(titelType)) {
            first=  outpatientDO.getPatientName() +",您好!";
            contentMsg="通知内容:"+remindMsg;
            remark="备注:请您尽快回复";
        }else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)){
            first=  doctorDO.getName()+doctorDO.getJobTitleName() +"医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
        } else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
            first = outpatientDO.getPatientName() + ",您好! 医生已为您开具处方,请及时支付。";
            contentMsg = "通知内容:医生已为您开具处方,请及时支付。";
            remark = "备注:点击完成支付,如您已支付请忽略本条信息";
        } else if ("msgRemind".equalsIgnoreCase(titelType)) {
            first = outpatientDO.getPatientName() + ",您好!";
            contentMsg = "通知内容:" + remindMsg;
            remark = "备注:请您尽快回复";
        } else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)) {
            first = doctorDO.getName() + doctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
            if ("16".equals(type)) {
                contentMsg="通知内容:您的视频复诊已开始,错过将重新排队";
                remark="备注:点击消息进入视频诊室接听视频通话,开始视频咨询。";
            }else  if ("17".equals(type)) {
                contentMsg="通知内容:您的视频咨询已开始,错过将重新排队";
                remark="备注:点击消息进入视频诊室接听视频通话,开始视频复诊。";
                contentMsg = "通知内容:您的视频复诊已开始,错过将重新排队";
                remark = "备注:点击消息进入视频诊室接听视频通话,开始视频咨询。";
            } else if ("17".equals(type)) {
                contentMsg = "通知内容:您的视频咨询已开始,错过将重新排队";
                remark = "备注:点击消息进入视频诊室接听视频通话,开始视频复诊。";
            }
        }else if ("videoOrderRemind".equalsIgnoreCase(titelType)){
        } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
            if ("16".equals(type)) {
                first= "您的视频复诊已预约成功。";
                contentMsg="通知内容:预计"+outpatientDO.getDoctorName()+"医生将于"+outpatientDO.getRegisterDate()+" 与您进行视频复诊。请留意微信公众号消息。";
            }else  if ("17".equals(type)) {
                first= "您的视频咨询已预约成功。";
                contentMsg="通知内容:预计"+outpatientDO.getDoctorName()+"医生将于"+outpatientDO.getRegisterDate()+" 与您进行视频咨询。请留意微信公众号消息。";
                first = "您的视频复诊已预约成功。";
                contentMsg = "通知内容:预计" + outpatientDO.getDoctorName() + "医生将于" + outpatientDO.getRegisterDate() + " 与您进行视频复诊。请留意微信公众号消息。";
            } else if ("17".equals(type)) {
                first = "您的视频咨询已预约成功。";
                contentMsg = "通知内容:预计" + outpatientDO.getDoctorName() + "医生将于" + outpatientDO.getRegisterDate() + " 与您进行视频咨询。请留意微信公众号消息。";
            }
            remark="备注:咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
        }else if ("evaluateRemind".equalsIgnoreCase(titelType)){
            first= outpatientDO.getPatientName()+",您好!您有1条专家咨询已结束,请及时对咨询医生进行评价。";
            contentMsg="通知内容:请对"+outpatientDO.getDoctorName()+"医生的服务进行评价";
            remark = "备注:咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
        } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
            first = outpatientDO.getPatientName() + ",您好!您有1条专家咨询已结束,请及时对咨询医生进行评价。";
            contentMsg = "通知内容:请对" + outpatientDO.getDoctorName() + "医生的服务进行评价";
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
@ -3537,7 +3536,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getPatientName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                }else if ("16".equals(type)) {
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }
                newConfig.setKeyword1(config.getKeyword1() + outpatientDO.getHospitalName());
@ -3582,7 +3581,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getPatientName()));
                newConfig.setKeyword1(config.getKeyword1() + remindMsg);
                newConfig.setKeyword2(config.getKeyword2() + DateUtil.getStringDate());
            }else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)){
            } else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)) {
                scene = "mzxxtx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
@ -3594,29 +3593,29 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                newConfig.setKeyword3(config.getKeyword3() + outpatientDO.getDeptName());
                newConfig.setKeyword4(config.getKeyword4() + outpatientDO.getIcd10Name());
                if ("16".equals(type)) {
                    newConfig.setRemark(config.getRemark().replaceFirst("key1","视频复诊"));
                }else  if ("17".equals(type)) {
                    newConfig.setRemark(config.getRemark().replaceFirst("key1","视频咨询"));
                    newConfig.setRemark(config.getRemark().replaceFirst("key1", "视频复诊"));
                } else if ("17".equals(type)) {
                    newConfig.setRemark(config.getRemark().replaceFirst("key1", "视频咨询"));
                }
            }else if ("videoOrderRemind".equalsIgnoreCase(titelType)){
            } 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","视频复诊"));
                }else  if ("17".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1","视频咨询"));
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                } else if ("17".equals(type)) {
                    newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                }
                newConfig.setKeyword1(config.getKeyword1() + outpatientDO.getPatientName());
                newConfig.setKeyword2(config.getKeyword2() + outpatientDO.getDeptName());
                newConfig.setKeyword3(config.getKeyword3() + outpatientDO.getDoctorName());
                newConfig.setKeyword4(config.getKeyword4() + outpatientDO.getRegisterDate());
                newConfig.setKeyword5(config.getKeyword5() +generalDoctorWaitingNumber(doctorDO.getId(),wxId,outpatientId));
            }else if ("evaluateRemind".equalsIgnoreCase(titelType)){
                newConfig.setKeyword5(config.getKeyword5() + generalDoctorWaitingNumber(doctorDO.getId(), wxId, outpatientId));
            } 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",outpatientDO.getPatientName()));
                newConfig.setFirst(config.getFirst().replaceFirst("key1", outpatientDO.getPatientName()));
                newConfig.setKeyword1(config.getKeyword1() + outpatientDO.getHospitalName());
                newConfig.setKeyword2(config.getKeyword2() + outpatientDO.getDoctorName());
            }
@ -3643,15 +3642,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            String MsgUrl = "https://www.xmheart.com/ims-wx/index.html#/returnVisit/record?outpatientId=" + outpatientDO.getPatient();
                String responseMsg = xzzxEntranceService.sendXCXMes(wxId,
                        patientDO.getId(),
                        patientDO.getIdcard(),
                        first,
                        contentMsg,
                        remark,
                        MsgUrl,
                        "wx53f6bb4ac081d840");
                logger.info("XZZX_Msg_"+titelType+"=" + responseMsg);
            String responseMsg = xzzxEntranceService.sendXCXMes(wxId,
                    patientDO.getId(),
                    patientDO.getIdcard(),
                    first,
                    contentMsg,
                    remark,
                    MsgUrl,
                    "wx53f6bb4ac081d840");
            logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
        } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            String MsgUrl = "https://hlwyy.xmzsh.com/ims-wx/index.html#/returnVisit/record?outpatientId=" + outpatientDO.getPatient();
@ -3663,7 +3662,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    contentMsg,
                    remark
            );
            logger.info("ZSYY_Msg"+titelType+"=" + responseMsg);
            logger.info("ZSYY_Msg" + titelType + "=" + responseMsg);
        }
    }
@ -4420,8 +4419,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.id in (" + sqlCode(codes) + ")";
        List<Map<String, Object>> doctors = jdbcTemplate.queryForList(sql);
        List<WlyyDoctorWorkTimeDO> workTimeDOs = makeDoctorWorkTimeDOList(doctors, wlyyDoctorWorkTimeDOs);
        doctorSaveWorkTime(workTimeDOs, date, doctors);
        return true;
        return doctorSaveWorkTime(workTimeDOs);
    }
    /**
@ -4456,35 +4455,35 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.id in (" + sqlCode(codes) + ")";
        List<Map<String, Object>> doctors = jdbcTemplate.queryForList(sql);
        List<WlyyDoctorWorkTimeDO> workTimeDOs = makeDoctorWorkTimeDOList(doctors, wlyyDoctorWorkTimeDOs);
        for (WlyyDoctorWorkTimeDO workTimeDO : workTimeDOs) {
            if (workTimeDO.getStartTime().before(DateUtil.getNowDate())||workTimeDO.getEndTime().before(DateUtil.getNowDate())){
                throw new Exception("您选择的时间小于系统时间,请重新选择!");
            }
            List<WlyyDoctorWorkTimeDO> workTimeDOList = doctorWorkTimeDao.findDoctorWorkTime(workTimeDO.getDoctor(),1);
            for (WlyyDoctorWorkTimeDO one : workTimeDOList) {
                try {
                    if (one.getCreateUserType()==1){
                        //与医院排班比较  是否冲突  第一组最后时间小于等于第二组最前时间 || 第一组最前时间大于等于第二组最后时间
                        if (one.getEndTime().before(workTimeDO.getStartTime())||one.getStartTime().after(workTimeDO.getEndTime())){
                            doctorWorkTimeDao.save(workTimeDO);
                        }else {
                            throw new Exception("您选择的时间与“开始时间-结束时间”的医院排班/自己排班冲突,请重新选择!");
                        }
                    }else {
                        doctorWorkTimeDao.save(workTimeDO);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    return false ;
                }
            }
        }
        return true;
//        for (WlyyDoctorWorkTimeDO workTimeDO : workTimeDOs) {
//
//            if (workTimeDO.getStartTime().before(DateUtil.getNowDate()) || workTimeDO.getEndTime().before(DateUtil.getNowDate())) {
//                throw new Exception("您选择的时间小于系统时间,请重新选择!");
//            }
//
//            List<WlyyDoctorWorkTimeDO> workTimeDOList = doctorWorkTimeDao.findDoctorWorkTime(workTimeDO.getDoctor(), 1);
//            for (WlyyDoctorWorkTimeDO one : workTimeDOList) {
//                try {
//
//                    if (one.getCreateUserType() == 1) {
//                        //与医院排班比较  是否冲突  第一组最后时间小于等于第二组最前时间 || 第一组最前时间大于等于第二组最后时间
//                        if (one.getEndTime().before(workTimeDO.getStartTime()) || one.getStartTime().after(workTimeDO.getEndTime())) {
//                            doctorWorkTimeDao.save(workTimeDO);
//                        } else {
//                            throw new Exception("您选择的时间与“开始时间-结束时间”的医院排班/自己排班冲突,请重新选择!");
//                        }
//                    } else {
//                        doctorWorkTimeDao.save(workTimeDO);
//                    }
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    return false;
//                }
//
//            }
//
//        }
        return doctorSaveWorkTime(workTimeDOs);
    }
@ -4588,19 +4587,40 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param workTimeDOs
     * @return
     */
    public boolean doctorSaveWorkTime(List<WlyyDoctorWorkTimeDO> workTimeDOs, String date, List<Map<String, Object>> doctors) {
    public boolean doctorSaveWorkTime(List<WlyyDoctorWorkTimeDO> workTimeDOs) throws Exception {
        for (WlyyDoctorWorkTimeDO workTimeDO : workTimeDOs) {
            List<WlyyDoctorWorkTimeDO> workTimeDOList = doctorWorkTimeDao.findDoctorWorkTime(workTimeDO.getDoctor(), workTimeDO.getStartTime(), workTimeDO.getEndTime());
            if (workTimeDOList != null && workTimeDOList.size() != 0) {
            if (workTimeDO.getStartTime().before(DateUtil.getNowDate()) || workTimeDO.getEndTime().before(DateUtil.getNowDate())) {
                throw new Exception("您选择的时间小于系统时间,请重新选择!");
            }
            String dateShort = DateUtil.dateToStrShort(workTimeDO.getStartTime());
//            StringBuilder sql=new StringBuilder("SELECT * FROM wlyy_doctor_work_time c WHERE ");
//            sql.append(" c.start_time >=  '"+dateShort+" 00:00:00 '").append(" and c.end_time <= '").append(dateShort+" 59:59:59 '");
//            sql.append(" AND c.doctor= '").append(workTimeDO.getDoctor());
//            sql.append("' order by c.start_time asc");
//            logger.info("sql="+sql.toString());
//            List<WlyyDoctorWorkTimeDO> workTimeDOList = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyDoctorWorkTimeDO.class));
            List<WlyyDoctorWorkTimeDO> workTimeDOList = doctorWorkTimeDao.findDoctorWorkTimeByTime(workTimeDO.getDoctor(), DateUtil.stringToDate(dateShort + " 00:00:00", "yyyy-MM-dd HH:mm:ss"), DateUtil.stringToDate(dateShort + " 23:59:59", "yyyy-MM-dd HH:mm:ss"));
            for (WlyyDoctorWorkTimeDO one : workTimeDOList) {
                if (one.getId().equalsIgnoreCase(workTimeDO.getId())){
                    continue;
                }
                try {
                    throw new Exception("您选择的时间与“开始时间-结束时间”的医院排班/自己排班冲突,请重新选择!");
                    //与医院与自己排班比较  是否冲突  第一组最后时间小于等于第二组最前时间 || 第一组最前时间大于等于第二组最后时间
                    if (one.getEndTime().before(workTimeDO.getStartTime()) || one.getStartTime().after(workTimeDO.getEndTime())) {
                    } else {
                        throw new Exception("您选择的时间与“开始时间-结束时间”的医院排班/自己排班冲突,请重新选择!");
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                }
            } else {
                doctorWorkTimeDao.save(workTimeDO);
            }
            doctorWorkTimeDao.save(workTimeDO);
        }
        return true;
    }
@ -5365,12 +5385,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                    }
                    sendWxTemplateMsg(wechatId,outpatient.getId(),"17","videoOrderRemind",null);
                    sendWxTemplateMsg(wechatId, outpatient.getId(), "17", "videoOrderRemind", null);
                }
            }
        } catch (Exception e) {
            logger.error("sendOutPatientMes :" + e.toString());
            return null;
@ -5415,7 +5434,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
            ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
        }
        sendWxTemplateMsg(wechatId,outpatient.getId(),type,"payRemind",null);
        sendWxTemplateMsg(wechatId, outpatient.getId(), type, "payRemind", null);
    }
@ -6464,7 +6483,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
            }
            sendWxTemplateMsg(wxId,outpatientDO.getId(),"","prescriptionPayRemind",null);
            sendWxTemplateMsg(wxId, outpatientDO.getId(), "", "prescriptionPayRemind", null);
        } else {
            wlyyPrescriptionDO.setId(prescriptionId);