def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": list = self.getList(webData) num = len(list) resultJson = {"num": num, "list": []} for item in list: caller = item.copy() caller["workerLimit"] = str2List(caller["workerLimit"]) resultJson["list"].append(caller) return packOutput(resultJson) elif action == "getInfo": caller = self.getInfo(webData) caller["workerLimit"] = str2List(caller["workerLimit"]) return packOutput(caller) elif action == "add": webData["workerLimit"] = list2Str(webData["workerLimit"]) ret = self.add(webData) return packOutput({}) elif action == "edit": webData["workerLimit"] = list2Str(webData["workerLimit"]) id = self.edit(webData) return packOutput({}) elif action == "delete": ret = self.delete(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "setWorkerStatus": ret = self.setWorkerStatus(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) else: return packOutput({}, "500", "unsupport action")
def updateWorkerLimit(self, inputData): stationID = inputData.get("stationID", None) if stationID is None: raise Exception("[ERR]: stationID required") queueID = inputData.get("queueID", None) if queueID is None: raise Exception("[ERR]: queueID required") workers = inputData.get("workers") if not isinstance(workers, list): raise Exception("[ERR]: workers should be a list") queueInfo = DB.DBLocal.select("queueInfo", where="stationID=$stationID AND id=$queueID", vars={"stationID": stationID, "queueID": queueID}) if len(queueInfo) == 0: raise Exception("[ERR]: queue not exists") queue = queueInfo[0] if not queue["workerLimit"]: workerLimit = [] else: workerLimit = str2List(queue["workerLimit"]) try: for worker in workers: if worker in workerLimit: continue else: workerLimit.append(worker) workerLimit_str = list2Str(workerLimit) DB.DBLocal.update("queueInfo", where="stationID=$stationID AND id=$queueID", vars={"stationID": stationID, "queueID": queueID}, workerLimit=workerLimit_str) except: raise else: result = {"result": "success"} return result
def getWorkerLimit(self, inputData): queueInfo = self.getInfo(inputData) workerLimit = str2List(queueInfo["workerLimit"]) departments = [] result = [] if not workerLimit: return result workerInfo = DB.DBLocal.select("workers", where="id IN $workerLimit", vars={"workerLimit": workerLimit}, order="department") workerInfo = workerInfo.list() for item in workerInfo: department = item["department"] if department not in departments: departments.append(department) for d in departments: tmp = {"department": d, "workers": []} for item in workerInfo: if item["department"] == d: id = item["id"] name = item["name"] worker = {"id": id, "name": name} tmp["workers"].append(worker) else: continue result.append(tmp) return result
def makeJson(self, name): # 得到分组 的 信息 gInfo = self.getInfo(name) self.gid = gInfo.get("gid") gJson = { "code": 1005, "name": name, "gid": self.gid, "serial": getSerial(), "device": [] } #得到设备列表信息 devList = gInfo.get("dev_list") devList = str2List(devList) for devName in devList: devInfo = db.select("DEVICE", where={ "devName": devName, "gw": self.gw_mac }).first() if devInfo is not None: gJson["device"].append({ "id": devInfo["id"], "ep": devInfo["ep"] }) print json.dumps(gJson) self.gjson = gJson
def getQueueList(self,inputData): queueList = queueInfo.QueueInfoInterface().getList(inputData) workerID = inputData["id"] matchQueue = [] for queue in queueList: if queue["workerLimit"] == "none": matchQueue.append(queue) else: workerLimit = str2List(queue["workerLimit"]) if (workerID in workerLimit) or (workerID.upper() in workerLimit) or (workerID.lower() in workerLimit): matchQueue.append(queue) ret = {"num": len(matchQueue), "list": []} now = datetime.datetime.now() current_date = now.strftime("%Y-%m-%d") current_time = now.strftime("%p") if current_time == "AM": current_time = 1 else: current_time = 2 for item in matchQueue: info = {} # 判断队列、医生的排班情况 queue = item["filter"] scheduleList = DB.DBLocal.select("schedule", where={"queue": queue, "workDate": current_date, "workTime": current_time}) if len(scheduleList) == 0: state = "not queue" else: schedule = scheduleList[0] onDuty = schedule["onDuty"] schedule_workerLimit = str2List(schedule["workerID"]) if onDuty in (1, 3) and workerID in schedule_workerLimit: state = "queue and worker" elif onDuty in (1, 3) and workerID not in schedule_workerLimit: state = "queue not worker" else: state = "not queue" info["id"] = item["id"] info["name"] = item["name"] info["workerOnline"] = item["workerOnline"] info["tab"] = ["waiting", "finish"] info["state"] = state ret["list"].append(info) return ret
def getSceneInfo(self, inputData): sceneID = inputData.get("sceneID", None) if sceneID is None: raise Exception("[ERR]: sceneID required.") # if can get from Memcached key = "_getSceneInfo_sceneID" + str(sceneID) value = common.func.CachedGetValue(json.dumps(key)) if value != False: return value sceneList = DB.DBLocal.select("scene", where="id=$id", vars={"id": sceneID}) if len(sceneList) == 0: raise Exception("[ERR]: scene not exists.") scene = sceneList[0] if not scene["property"]: scene["property"] = "" property = str2List(scene["property"]) support_property = copy.deepcopy(self.support_property) for item in property: if item in self.callMode: support_property.update({"callMode": item}) else: if item: support_property.update({item: 1}) result = { "id": scene["id"], "name": scene["name"], "descText": scene["descText"], "activeLocal": scene["activeLocal"], "rankWay": scene["rankWay"], "delayTime": scene["delayTime"], "waitNum": scene["waitNum"], "outputText": scene["output"], "passedWaitNum": scene["passedWaitNum"], "reviewWaitNum": scene["reviewWaitNum"], "priorNum": scene["priorNum"], "workDays": scene["workDays"], "InsertPassedSeries": scene["InsertPassedSeries"], "InsertPassedInterval": scene["InsertPassedInterval"], "InsertReviewSeries": scene["InsertReviewSeries"], "InsertReviewInterval": scene["InsertReviewInterval"], "InsertPriorSeries": scene["InsertPriorSeries"], "InsertPriorInterval": scene["InsertPriorInterval"], # "property" : scene["property"] "property": support_property } # 缓存 value common.func.CahedSetValue(json.dumps(key), result, 3) return result
def getCallerInfo(self,inputData): stationID = inputData["stationID"] id = inputData["id"] ipAddr = web.ctx.ip if "localIP" in inputData: ipAddr = inputData["localIP"] print "Login ip: " + ipAddr ret = DB.DBLocal.where('caller', stationID=inputData["stationID"], ip=ipAddr) if len(ret) > 0: callerLogin = ret[0] callerLogin["workerLimit"] = str2List(callerLogin["workerLimit"] ) if id in callerLogin["workerLimit"]: return callerLogin return {}
def getListQuery(self, id): """Query the media box identified by parameter id.""" sql = "SELECT p.id, p.deviceIP as ip, p.stationID, p.speed, p.volume, " \ "p.pitch, p.callerLimit, p.lastDateTime, s.name as stationName " \ "FROM publish as p INNER JOIN stationSet as s ON p.stationID = " \ "s.id WHERE p.id = %s" % id out = DB.query(sql).first() if out: if not out.callerLimit: out.callerLimit = "" out.callerLimit = map(int, str2List(out.callerLimit)) else: raise Exception("[ERR]: mediabox not exists.") return out
def getQueueSchedule(self, data): stationID = data.get("stationID", None) queueID = data.get("queueID", None) if queueID is None: raise Exception("[ERR]: queueID required") startTime = data.get("startTime", None) endTime = data.get("endTime", None) if not startTime or not endTime: raise Exception("[ERR]: startTime or endTime required") if endTime < startTime: raise Exception("[ERR]: endTime should larger than startTime") queueInfo = QueueInfoInterface().getInfo({"stationID": stationID, "id": queueID}) queue = queueInfo["filter"] try: self.autoGenSchedule(startTime, endTime) except: raise scheduleList = DB.DBLocal.select("schedule", where="queue=$queue AND workDate BETWEEN $startTime AND $endTime", vars={"queue": queue, "startTime": startTime, "endTime": endTime}) schedule = [] isExpert = None for item in scheduleList: tmp = {} scheduleTempList = DB.DBLocal.select("schedule_temp", where={"queue": item["queue"], "workDate": item["workDate"].strftime("%Y-%m-%d"), "workTime": item["workTime"]}) if len(scheduleTempList) > 0: schedule_temp = scheduleTempList[0] item = self._cmpOnDuty(item, schedule_temp) tmp["workDate"] = item["workDate"] tmp["workTime"] = item["workTime"] tmp["weekday"] = item["weekday"] tmp["onDuty"] = item["onDuty"] tmp["workerID"] = str2List(item["workerID"]) isExpert = item["isExpert"] schedule.append(tmp) result = {} result["stationID"] = queueInfo["stationID"] result["queueID"] = queueID result["name"] = queueInfo["name"] result["filter"] = queue #TODO: 专家队列信息是否和队列信息放在一起 result["isExpert"] = isExpert result["schedule"] = schedule return result
def getListAll(self, data): sql = "SELECT q.id, q.deviceIP AS ip, q.queueLimit, q.lastDateTime, q.stationID, s.name AS stationName " \ "FROM queue_machine q INNER JOIN stationSet s ON q.stationID = s.id" queue_machine_list = DB.DBLocal.query(sql) num = len(queue_machine_list) result = {"num": num, "list": []} for queue_machine in queue_machine_list: queueLimit = queue_machine["queueLimit"] if queueLimit is None: queue_machine["queueLimit"] = [] else: queue_machine["queueLimit"] = str2List( queue_machine["queueLimit"]) out = self.queueMachineStatus(queue_machine) result["list"].append(out) return result
def getAvaliableQueue(self, data): stationID = data.get("stationID", None) if stationID is None: raise Exception("[ERR]: stationID required") queueList = DB.DBLocal.select("queueInfo", where={"stationID": stationID}, what="id") queueIDList = [] for item in queueList: queueIDList.append(item["id"]) choseQueueList = DB.DBLocal.select("queue_machine", where={"stationID": stationID}, what="queueLimit") choseQueueIDList = [] for item in choseQueueList: queueLimit = str2List(item["queueLimit"]) for queueID in queueLimit: if queueID not in choseQueueIDList: choseQueueIDList.append(queueID) choseQueueIDList = map(int, choseQueueIDList) avaliableQueue = [ item for item in queueIDList if item not in choseQueueIDList ] result = {"list": []} for item in avaliableQueue: try: queueInfo = QueueInfoInterface().getInfo({ "stationID": stationID, "id": item }) except: pass else: result["list"].append({ "queueID": queueInfo["id"], "name": queueInfo["name"] }) result["num"] = len(result["list"]) return result
def getQueueList(self,inputData): queueList = queueInfo.QueueInfoInterface().getList(inputData) workerID = inputData["id"] matchQueue = [] for queue in queueList: if queue["workerLimit"] == "none": matchQueue.append(queue) else: workerLimit = str2List(queue["workerLimit"]) if workerID in workerLimit: matchQueue.append(queue) ret = {"num": len(matchQueue), "list": []} for item in matchQueue: info = {} info["id"] = item["id"] info["name"] = item["name"] info["workerOnline"] = item["workerOnline"] info["tab"] = ["waiting", "finish"] ret["list"].append(info) return ret
def getScheduleByQueue(self, queue_filter): """根据队列关键字获取专家队列的排班信息""" result = {} current_date = datetime.date.today() startTime = ( current_date - datetime.timedelta(current_date.weekday())).strftime("%Y-%m-%d") endTime = (current_date + datetime.timedelta(6 - current_date.weekday()) ).strftime("%Y-%m-%d") # 获取队列基础信息 queue_info = WXQueue( self.hospitalName).getQueueInfoByFilter(queue_filter) if not queue_info: return result # 获取专家信息 workerID = str2List(queue_info.pop("workerLimit"))[0] workerInfo = WXWorker(self.hospitalName).getWorkerInfo(workerID) # 获取队列排班信息 where = "queue=\'%s\' AND workDate BETWEEN \'%s\' AND \'%s\'" % ( queue_filter, startTime, endTime) schedule_list = self.db.select("schedule", where=where) schedule = [] for item in schedule_list: if item["onDuty"] == 1: tmp = { "onDuty": item["onDuty"], "workDate": item["workDate"], "workTime": item["workTime"], "weekday": item["weekday"] } schedule.append(tmp) result.update(queue_info) result.update({"schedule": schedule, "workerInfo": workerInfo}) return result
def getExpertSchedule(self, data): """获取专家队列的上班情况""" stationID = data.get("stationID", None) where = None if stationID: where = {} where.update({"stationID": stationID}) # 判断哪些队列属于专家队列 queueID = data.get("queueID", None) if not queueID: queueID = [] queueList = DB.DBLocal.select("queueInfo", what="id", where=where) for item in queueList: id = item["id"] try: isExpert = self._isExpertQueue(id) except: continue if isExpert: queueID.append(id) if not isinstance(queueID, list): raise Exception("[ERR] queueID must be a list") isExpert = data.get("isExpert", 1) startTime = data.get("startTime", None) endTime = data.get("endTime", None) if not startTime or not endTime: current_date = datetime.datetime.today() startTime = (current_date - datetime.timedelta(current_date.weekday())).strftime("%Y-%m-%d") endTime = (current_date + datetime.timedelta(6 - current_date.weekday())).strftime("%Y-%m-%d") if endTime < startTime: raise Exception("[ERR]: endTime should larger than startTime") data.update({"isExpert": isExpert, "startTime": startTime, "endTime": endTime}) result = {"list":[]} for item in queueID: data.update({"queueID": item}) queueInfo = QueueInfoInterface().getInfo({"stationID":"", "id": item}) queue_schedule = self.getQueueSchedule(data) schedule = queue_schedule.pop("schedule") workerID = None if queueInfo["workerLimit"]: workerID = str2List(queueInfo["workerLimit"])[0] tmp = [] for s in schedule: if s["onDuty"] == 1: s.pop("workerID") tmp.append(s) queue_schedule.update({"schedule": tmp}) if not queue_schedule["schedule"]: continue workerList = DB.DBLocal.select("workers", where={"id": workerID}) workerInfo = {"name": "", "department": "", "title": "", "descText": "", "headPic": "", "speciality": ""} if len(workerList) !=0: worker = workerList[0] for key in workerInfo.keys(): if worker[key]: workerInfo.update({key: worker[key]}) queue_schedule.update({"workerInfo": workerInfo}) if queue_schedule["workerInfo"]["name"]: result["list"].append(queue_schedule) return result
def publishNew(self, inputData, lastOne, nextOne, prepareOne, ret): stationID = inputData["stationID"] queueID = inputData["queueID"] workerID = inputData["id"] # 获得叫号器信息,位置 caller = self.getCallerInfo(inputData) pos = caller["pos"] if prepareOne != {} and lastOne != {}: LogOut.info("caller next req pos " + pos + " last " + lastOne["name"] + " doing " + nextOne["name"]) LogOut.info("parpare One : " + prepareOne["name"]) worker = WorkerInterface().getInfo({"stationID":stationID,"id":workerID}) #记录到呼叫记录表中 record = {} record["stationID"] = stationID record["callerID"] = caller["id"] record["workerID"] = workerID record["queueID"] = queueID record["currentVisitorID"] = nextOne["id"] record["currentVisitorName"] = nextOne["name"] curDateTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) record["dateTime"] = curDateTime record["showCnt"] = 10 callRecordInterface().record(record) key = {"type":"publish","stationID":stationID,"callerID":caller["id"],"action":"getCallerList"} common.func.CachedClearValue(json.dumps(key)) key = {"type": "publish", "stationID": stationID, "callerID": caller["id"], "action": "getStationList"} common.func.CachedClearValue(json.dumps(key)) #更新nextOne和prepareOne的信息 if nextOne: where = {"id": nextOne["id"]} next_visitor = DB.DBLocal.select("visitor_source_data", where=where).first() nextOne.update({"snumber": next_visitor.snumber}) nextOne.update({"cardID": next_visitor.cardID}) if prepareOne: where = {"id": prepareOne["id"]} prepare_visitor = DB.DBLocal.select("visitor_source_data", where=where).first() prepareOne.update({"snumber": prepare_visitor.snumber}) prepareOne.update(({"cardID": prepare_visitor.cardID})) # 转换呼叫音频 cid = str(stationID) + "_" + nextOne["id"] qInfo = queueInfo.QueueInfoInterface().getInfo({"stationID": stationID, "id": queueID}) sceneID = qInfo["sceneID"] scene = SceneInterface().getSceneInfo({"sceneID": sceneID}) # V1.2.1 增加按照名字、序号、卡号等语音播报方式 # V1.2.1 将"请***准备"设置为可配置项 property = scene["property"] callMode = property["callMode"] if callMode == 'callByName': nextOneText = nextOne.get("name") prepareOneText = prepareOne.get("name", "") elif callMode == 'callBySnumber': nextOneText = "%s号" % nextOne.get("snumber") prepareOneText = "%s号" % prepareOne.get("snumber", "") elif callMode == 'callByCardID': nextOneText = nextOne.get("cardID") prepareOneText = prepareOne.get("cardID", "") else: raise Exception("unsupport callMode") text = "请%s到%s%s" % (nextOneText, pos, scene["outputText"]) # TODO: V1.21 scene property add noPrepare if not property["noPrepare"]: if prepareOne != {}: text += ", 请%s准备" % prepareOneText publishDev = PublishDevInterface() mediaBoxInterface = MediaBoxInterface() devList = publishDev.getInfo({"stationID":stationID}) ret["list"] = [] for dev in devList: # 增加语音盒在线判断 mediabox = mediaBoxInterface.mediaBoxStatus(dev) callerLimit = mediabox["callerLimit"] if callerLimit: callerLimit = str2List(callerLimit) if caller["id"] not in callerLimit: continue if mediabox["status"] == "offline": continue ret["list"].append({"soundUrl":dev["deviceIP"] , "text" : text, "id": nextOne["id"]})
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": list = self.getList(webData) num = len(list) resultJson = {"num": num, "list": []} for item in list: queue = item.copy() queue["workerLimit"] = str2List(queue["workerLimit"]) resultJson["list"].append(queue) return packOutput(resultJson) elif action == "getInfo": queueInfo = self.getInfo(webData) queueInfo["workerLimit"] = str2List(queueInfo["workerLimit"]) return packOutput(queueInfo) elif action == "add": webData["workerLimit"] = list2Str(webData["workerLimit"]) ret = self.add(webData) return packOutput({}) elif action == "edit": webData["workerLimit"] = list2Str(webData["workerLimit"]) id = self.edit(webData) return packOutput({}) elif action == "delete": ret = self.delete(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "getSourceQueueList": ret = self.getSourceQueueList(webData) jsonData = {"num": len(ret), "list": ret} return packOutput(jsonData) elif action == "getSceneSupportList": ret = self.getSceneSupportList(webData) list = [] for item in ret: list.append(item) jsonData = {"num": len(ret), "list": list} return packOutput(jsonData) elif action == "getAvgWaitTime": try: result = self.getAvgWaitTime(webData) return packOutput(result) except Exception as errorInfo: return packOutput({}, code="400", errorInfo=str(errorInfo)) else: return packOutput({}, "500", "unsupport action")
def importSchedule(self, config): """导入排班信息 排班信息导入支持导入1周、2周、4周的数据,在导入时需要确认数据源排班信息的周数 是否和选择导入的周数相匹配。 在导入时,导入数据会完全覆盖数据库中对应的数据。 """ db_config = convertDBConfig(**config) if config["DBType"] == 'mssql': DBSource = DB.MSSQLController(config).MSSQLDB else: DBSource = web.database(**db_config) # 导入数据的周数,默认1周,可选1周、2周、4周数据 import_weeks = config.pop("importWeeks", 1) # 数据源连接测试 connect_test = self.testSourceConfig(config) if connect_test["result"] == "failed": raise Exception("[ERR]: import failed, please check the config") else: sql = connect_test["sql"] tmp = DBSource.select(sql, what="MAX(workDate) as MAX_DATE, MIN(workDate) as MIN_DATE")[0] max_date = tmp["MAX_DATE"] min_date = tmp["MIN_DATE"] if not max_date or not min_date: # raise Exception("[ERR]: import failed, please check whether the source has {0} week(s) data".format(import_weeks)) raise Exception("importWeeks error") # MSSQL 查询出来是Unicode,需要进行转换 if isinstance(max_date, str) or isinstance(max_date, unicode): max_date = datetime.datetime.strptime(max_date, "%Y-%m-%d") if isinstance(min_date, str) or isinstance(min_date, unicode): min_date = datetime.datetime.strptime(min_date, "%Y-%m-%d") # 判断是否是最新的数据 current_date = datetime.datetime.today() isNewData = int(datetime.datetime.strftime(current_date, '%W')) - int(datetime.datetime.strftime(min_date, '%W')) if isNewData !=0: raise Exception("importWeeks error") # 判断导入数据的周数和配置的导入周数是否相同 interval = int(datetime.datetime.strftime(max_date, '%W')) - int(datetime.datetime.strftime(min_date, '%W')) count = interval + 1 if count != import_weeks: # raise Exception("[ERR]: import failed, please check whether the source has {0} week(s) data".format(import_weeks)) raise Exception("importWeeks error") # 数据源排班数据 scheduleList = DBSource.select(sql) # 插入到排班表中的排班数据列表,可使用multiple_insert方法实现多条插入 insert_items = [] # 每个队列关键字对应的分诊台ID、队列ID、可登陆医生等信息 queue_workers = [] # 根据循环的次数,生成相应的排班数据 for item in scheduleList: if config["DBType"] == "oracle": item = self.convertItem(item) for i in range(0, self.repeat_count, import_weeks): # 生成排班信息 workDate = item["workDate"] if isinstance(workDate, str) or isinstance(workDate, unicode): workDate = datetime.datetime.strptime(workDate, "%Y-%m-%d") date = workDate + datetime.timedelta(self.repeat_interval*i) item_copy = copy.deepcopy(item) item_copy["workDate"] = date insert_items.append(dict(item_copy)) # 导入数据时也要覆盖临时调班数据 schedule_temp = DB.DBLocal.select("schedule_temp", where={"queue": item_copy["queue"], "workTime": item_copy["workTime"], "workDate": item_copy["workDate"].strftime("%Y-%m-%d")}) if len(schedule_temp) != 0: DB.DBLocal.delete("schedule_temp", where={"queue": item_copy["queue"], "workTime": item_copy["workTime"], "workDate": item_copy["workDate"].strftime("%Y-%m-%d")}) # 生成每个队列的医生数据 workers = str2List(item["workerID"]) queue = item["queue"] try: queueInfo = QueueInfoInterface().getInfoByFilter({"queue": queue}) worker_paras = {"stationID": queueInfo["stationID"], "queueID": queueInfo["id"], "workers": workers} except: continue if not queue_workers: queue_workers.append(worker_paras) else: for item in queue_workers: if item["stationID"] == queueInfo["stationID"] and item["queueID"] == queueInfo["id"]: item["workers"] = list(set(item["workers"] + workers)) break else: queue_workers.append(worker_paras) insert_items = sorted(insert_items, key=lambda value: (value["queue"], value["workDate"])) try: start = time.time() # 批量插入或者更新排班数据 if insert_items: insert_sql = multiple_insert_sql("schedule", insert_items) DB.DBLocal.query(insert_sql) print "Worker: {0}".format(queue_workers) # 更新每个队列可登陆医生 for item in queue_workers: QueueInfoInterface().updateWorkerLimit(item) # 如果导入成功,将import_weeks写入数据库配置中 DB.DBLocal.update("import_config", where={"type": "schedule"}, importWeeks=import_weeks) except: raise else: print "IMPORT TIME COST: {0} ms".format((time.time() - start) * 1000) print "INSERT/UPDATE: {0}".format(len(insert_items)) result = {} result["result"] = "success" result["successCount"] = len(insert_items) result["totalImport"] = len(insert_items) result["failedCount"] = result["totalImport"] - result["successCount"] return result
def getInfo(self, data): """获取某个取号机的详细信息""" stationID = data.get("stationID", None) if stationID is None: raise Exception("[ERR]: stationID required for queue_machine") where = {"stationID": stationID} id = data.get("id", None) if id is None: where.update({"deviceIP": web.ctx.ip}) else: where.update({"id": id}) queue_machine_list = DB.DBLocal.select("queue_machine", where=where) queue_machine = queue_machine_list[0] for key, value in queue_machine.items(): if value is None: queue_machine.update({key: ""}) result = {} # 取号机选择的队列信息 queueLimit = str2List(queue_machine["queueLimit"]) queue_machine["queueLimit"] = [] for queueID in queueLimit: try: queueInfo = QueueInfoInterface().getInfo({ "stationID": stationID, "id": queueID }) except: continue else: queue_machine["queueLimit"].append({ "queueID": queueInfo["id"], "name": queueInfo["name"] }) # 取号机支持的特性 supportFeature = str2List(queue_machine.pop("supportFeature")) queue_machine["supportFeature"] = {} for key, value in self.support_feature.items(): keyword = self.feature_keywords[key] if keyword in supportFeature: queue_machine["supportFeature"].update({key: 1}) else: queue_machine["supportFeature"].update({key: value}) # 取号机打印设置项 printSettings = {} printSettings["title"] = queue_machine.pop("title") printSettings["subtitle"] = queue_machine.pop("subtitle") printSettings["footer1"] = queue_machine.pop("footer1") printSettings["footer2"] = queue_machine.pop("footer2") styleID = queue_machine.pop("styleID", 1) styleList = DB.DBLocal.select("style", where={"id": styleID}) printSettings["styleInfo"] = { "id": "", "name": "", "styleURL": "", "previewURL": "" } for item in styleList: printSettings["styleInfo"] = item queue_machine["printSettings"] = printSettings queue_machine = self.queueMachineStatus(queue_machine) queue_machine.update({"queueNum": len(queue_machine["queueLimit"])}) result.update(queue_machine) return result