def regist(self, data): vInfo = data.get("vInfo") queue = vInfo.get("queue") queueStr = "queue=\'" + queue + '\'' queueInfo = db.select("queueInfo", where={"filter": queueStr}).first() if queueInfo is None: raise Exception("queue {0} Not found".format(queue)) vInfo["stationID"] = queueInfo.get("stationID") vInfo["queueID"] = queueInfo.get("id") print "get_visitor_from_http : ", vInfo ret = db.select("visitor_source_data", where={ "id": vInfo["id"] }).first() if ret is None: print "get_visitor_from_http : new: ", vInfo interface = VisitorSourceInterface(vInfo["stationID"]) interface.add(vInfo) else: print "get_visitor_from_http : update: ", vInfo interface = VisitorSourceInterface(vInfo["stationID"]) interface.edit(vInfo) para = {"stationID": vInfo["stationID"], "queueID": vInfo["queueID"]} QueueDataController().updateVisitor(para) return {"result": "success"}
def visitorActiveSet(self, inputData): stationID = inputData["stationID"] queueID = inputData["queueID"] visitor = {} visitor["id"] = inputData["id"] visitor["stationID"] = stationID if inputData["active"]: activeTime = datetime.datetime.now() visitor["activeLocal"] = 1 visitor["activeLocalTime"] = activeTime queueInfo = QueueInfoInterface().getInfo({ "stationID": stationID, "id": queueID }) sceneID = queueInfo["sceneID"] scene = SceneInterface().getSceneInfo({"sceneID": sceneID}) if scene["delayTime"] == 0: visitor["status"] = "waiting" else: visitor["status"] = "unactivewaiting" else: visitor["activeLocal"] = 0 visitor["status"] = "unactive" VisitorLocalInterface(stationID).edit(visitor) QueueDataController().sortVisitor(stationID, queueID, scene) return
def visitorFuzzySearch(self, inputData): stationID = inputData["stationID"] paraName = inputData["paraName"] paraVal = inputData["paraVal"] searchAllow = ["a.id", "cardID", "personID", "phone"] if paraName not in searchAllow: raise Exception("[ERR]: paraName " + paraName + " not allow.") filter = {"stationID": stationID, str(paraName): str(paraVal)} visitorList = DB.DBLocal.select( "visitor_view_data", where=filter, ) visitorDictList = [] for item in visitorList: item["waitingNum"] = QueueDataController().getWaitingNum({ "stationID": stationID, "queueID": item["queueID"], "id": item["id"] }) item["waitingTime"] = item["waitingNum"] * 15 visitorDictList.append(item) return visitorDictList
def syncLocal(self): self.queueList = self.queueInfo.getList({"stationID": self.stationID}) print("station " + str(self.stationID) + "syncLocal") #scan all queue in a station for queue in self.queueList: para = {"stationID": self.stationID, "queueID": queue["id"]} QueueDataController().updateVisitor(para) print "stationID %d local sync ok" % self.stationID
def setVisitorStatus(self, inputData, action=None): stationID = inputData.get("stationID") queueID = inputData.pop("queueID") # 根据访客所处队列选择的策略信息,获取缓冲人数 queueInfo = QueueInfoInterface().getInfo({ "stationID": stationID, "id": queueID }) sceneID = queueInfo["sceneID"] scene = SceneInterface().getSceneInfo({"sceneID": sceneID}) if action == "pass" or action == "delay": waitNum = scene["passedWaitNum"] elif action == "review": waitNum = scene["reviewWaitNum"] else: # raise Exception("[ERR]: visitor status action not support.") waitNum = 0 # 获取队列访客信息,如果等待队列中已经有过号或者复诊的访客,则调整缓冲人数 workDays, date = QueueInfoInterface().getWorkDays(stationID, queueID) fliter = "stationID=$stationID and queueID=$queueID and status=$status" if cfg.currentDayOnly == "1": fliter += " and registDate >=$date" visitorList = DB.DBLocal.select("visitor_local_data", where=fliter, vars={ "stationID": stationID, "queueID": queueID, "status": "waiting", "date": date }, order="finalScore, originScore") visitorNum = len(visitorList) if action == "pass" or action == "delay": InsertSeries = scene["InsertPassedSeries"] InsertInterval = scene["InsertPassedInterval"] elif action == "review": InsertSeries = scene["InsertReviewSeries"] InsertInterval = scene["InsertReviewInterval"] else: #default val InsertSeries = 2 InsertInterval = 3 destPos, destScore = QueueDataController().getInsertPos( visitor=inputData, vList=visitorList, numNormal=InsertInterval, numHigher=InsertSeries, numWaitting=waitNum) inputData["finalScore"] = destScore return inputData
def callNext(self,inputData,passed = 0): ret = {} stationID = inputData["stationID"] queueID = inputData["queueID"] workerID = inputData["id"] #修改队列最后在线医生 queue = {} queue["id"] = queueID queue["stationID"] = stationID queue["workerOnline"] = workerID queueInfo.QueueInfoInterface().edit(queue) #修改队列进行中人员 且医生为当前医生的 为已完成 doingList = DB.DBLocal.where('visitor_local_data', stationID=inputData["stationID"] ,queueID = inputData["queueID"]\ ,status = "doing", workerOnline = workerID) lastOne = {"id": "","stationID":stationID, "queueID": queueID, "name": "", "status": "finish"} # if passed == 1: # lastOne["status"] = "pass" for item in doingList: lastOne["id"] = item["id"] if passed == 1: lastOne["status"] = "pass" lastOne["name"] = item["name"] lastOne["workEndTime"] = self.getCurrentTime() VisitorLocalInterface(stationID).edit(lastOne) #修改呼叫人员状态改为Doing 呼叫医生改为当前医生 waitList = QueueDataController().getQueueVisitor(inputData) nextOne = parpareOne = {} for item in waitList: if item["locked"] != 1: nextOne = item nextOne["status"] = "doing" nextOne["workerOnline"] = workerID nextOne["workStartTime"] = self.getCurrentTime() VisitorLocalInterface(stationID).edit(nextOne) try: parpareOne = iter(waitList).next() except: parpareOne = {} self.publish(inputData,lastOne,nextOne,parpareOne,ret) break return ret
def visitorFuzzySearch(self, inputData): stationID = inputData["stationID"] paraName = inputData["paraName"] paraVal = inputData["paraVal"] searchAllow = ["a.id", "cardID", "personID", "phone"] if paraName not in searchAllow: raise Exception("[ERR]: paraName " + paraName + " not allow.") joinView = "(select id,activeLocal,activeLocalTime,locked,queueID,vip as localVip,status as localStatus from visitor_local_data where stationID =" + str(stationID) +\ " ) as joinView" LogOut.info("joinView " + joinView) joinSql = "select * from visitor_source_data a inner join " + joinView + " on a.id=joinView.id and a.stationID=" + str( stationID) joinSql += " where " + str(paraName) + " = \'" + str(paraVal) + "\'" visitorList = DB.DBLocal.query(joinSql) visitorDictList = [] for item in visitorList: item["waitingNum"] = QueueDataController().getWaitingNum({ "stationID": stationID, "queueID": item["queueID"], "id": item["id"] }) item["waitingTime"] = item["waitingNum"] * 15 if cfg.currentDayOnly == "1": workDays, dateStr = QueueInfoInterface().getWorkDays( stationID, item["queueID"]) now = datetime.datetime.now() delta = datetime.timedelta(days=(-workDays + 1)) n_days = now + delta if item["registDate"] >= n_days.date(): visitorDictList.append(item) else: visitorDictList.append(item) return visitorDictList
def addVisitor(self, inputData): stationID = inputData.get("stationID", None) queueID = inputData.get("queueID", None) name = inputData.get("name", None) snumber = inputData.get("snumber", None) VIP = inputData.get("VIP", None) descText = inputData.get("descText", None) cardID = inputData.get("cardID", None) if not all((stationID, queueID, name, snumber, descText, cardID)) or VIP is None: raise Exception("[ERR] parameter required.") age = inputData.get("orderType", None) orderType = inputData.get("orderType", 0) personID = inputData.get("personID", None) phone = inputData.get("phone", None) queueInfo = QueueInfoInterface().getInfo({ "stationID": stationID, "id": queueID }) # if not queueInfo: # raise Exception("[ERR]: queue not exists.") filter = queueInfo["filter"] filter = re.findall(r'queue=\'(.*)\'', filter) queue = filter[0] now = datetime.datetime.now() current_date = now.strftime("%Y-%m-%d") current_time = now.strftime("%H:%M:%S") timestamp = int(time.mktime(now.timetuple())) workerID = queueInfo["workerOnline"] workerList = DB.DBLocal.select("workers", where="stationID=$stationID and id=$id", vars={ "stationID": stationID, "id": workerID }) if len(workerList) == 0: workerName = "" department = "" else: worker = workerList[0] workerName = worker["name"] department = worker["department"] if len(cardID) <= 10: id = cardID + str(timestamp) else: id = cardID[-10:] + str(timestamp) values = { "id": id, "stationID": stationID, "queueID": queueID, "name": name, "age": age, "queue": queue, "snumber": snumber, "orderDate": current_date, "orderTime": current_time, "registDate": current_date, "registTime": current_time, "VIP": VIP, "orderType": orderType, "workerID": workerID, "workerName": workerName, "descText": descText, "department": department, "cardID": cardID, "personID": personID, "phone": phone, "status": "护士新增" } try: DB.DBLocal.insert("visitor_source_data", **values) except: raise Exception("[ERR]: insert into visitor_source_data failed.") result = {"result": "success"} para = {"stationID": stationID, "queueID": queueID} QueueDataController().updateVisitor(para) """更新锁定和特性说明""" values = { "id": id, } if "locked" in inputData: values["locked"] = inputData["locked"] if "property" in inputData: values["property"] = list2Str(inputData["property"]) try: DB.DBLocal.update("visitor_local_data", where="id=$id", vars={"id": id}, **values) except: raise Exception("[ERR]: update visitor_local_data failed.") return result
def visitorSearch(self, inputData): visitor = self.getVisitorInfo(inputData) inputData["queueID"] = visitor["queueID"] visitor["waitingNum"] = QueueDataController().getWaitingNum(inputData) visitor["waitingTime"] = visitor["waitingNum"] * 15 return visitor
def visitorMoveby(self, inputData): QueueDataController().visitorMoveby(inputData) return
def visitorMoveto(self, inputData): # TODO 修改BUG:根据传入的参数查找指定的访客,如果查找不到它也会返回success QueueDataController().visitorMoveto(inputData) return
"workerID": workerID, "workerName": workerName, "descText": descText, "department": department, "cardID": cardID, "personID": personID, "phone": phone, "status": status } values = {} for key, value in visitor.items(): if value is not None: values.update({key: value}) if value is None: visitor.update({key: ""}) try: DB.DBLocal.insert("visitor_source_data", **values) except Exception, e: print "Exception : %s " % str(e) raise Exception( "[ERR]: insert into visitor_source_data failed. %s " % str(e)) para = {"stationID": stationID, "queueID": queueID} QueueDataController().updateVisitor(para) # visitorInfo = (id, name, cardID, snumber, waitNum) visitor.update({"waitNum": waitNum}) return visitor