From 9e01808b0877527054e0328be62fd465950c9be7 Mon Sep 17 00:00:00 2001 From: haoming06 Date: Tue, 17 Sep 2019 11:23:17 +0800 Subject: [PATCH] =?UTF-8?q?[update]=E8=8E=B7=E5=8F=96=E8=81=8C=E4=BD=8D/?= =?UTF-8?q?=E5=8C=BB=E7=94=9F=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bjguahao.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bjguahao.py b/bjguahao.py index 72629a3..bdf1405 100644 --- a/bjguahao.py +++ b/bjguahao.py @@ -348,30 +348,36 @@ def select_doctor_by_vec(self): if self.config.assign == 'true': for doctor_conf in self.config.doctorName: for doctor in doctors: - if doctor["doctorName"] == doctor_conf and (doctor['totalCount']): - logging.info("选中:" + str(doctor["doctorName"])) + if self.get_doctor_name(doctor) == doctor_conf and (doctor['totalCount']): + logging.info("选中:" + self.get_doctor_name(doctor)) return doctor return "NoDuty" # 按照配置优先级选择医生 for doctor_conf in self.config.doctorName: for doctor in doctors: - if doctor["doctorName"] == doctor_conf and doctor['totalCount']: + if self.get_doctor_name(doctor) == doctor_conf and doctor['totalCount']: return doctor # 若没有合适的医生,默认返回最好的医生 for doctor in doctors: if doctor['totalCount']: - logging.info("选中:" + str(doctor["doctorName"])) + logging.info("选中:" + self.get_doctor_name(doctor)) return doctor return "NoDuty" + def get_doctor_name(self,doctor): + if doctor['doctorName'] is not None: + return str(doctor['doctorName']) + else: + return str(doctor['doctorTitleName']) + def print_doctor(self): logging.info("当前号余量:") x = PrettyTable() x.border = True x.field_names = ["医生姓名", "擅长", "号余量"] for doctor in self.dutys: - x.add_row([doctor["doctorName"], doctor['doctorSkill'], doctor['totalCount']]) + x.add_row([self.get_doctor_name(doctor), doctor['doctorSkill'], doctor['totalCount']]) print(x.get_string()) pass