def firstprovidetime(): args = request.data # print args # print "数据类型", type(args) jsonargs = json.loads(args) re = recommendtime.RECOMDTIME() retime = re.firstGetTime(jsonargs) return retime
def recomtime(): args = request.data # print args # print "数据类型", type(args) jsonargs = json.loads(args) # print jsonargs re = recommendtime.RECOMDTIME() retime = re.getonthecardata(jsonargs) return retime
def incressPickupTime(self, allSchedule, allOrderInfo): from sendtoairport import auxfn re = recommendtime.RECOMDTIME() allcar = self.getScheduleInfo(allSchedule, allOrderInfo) for car in allcar: if len(car) is 1: # 整辆车只有一个订单的情况 if 'pickupTime' not in car[0].keys( ) or car[0]['driver'] is None or car[0]['driver'] is u"": timeandare = self.getpickuptime(car[0]) # unixpickuptime = int(time.mktime((timeandare.pickuptime).timetuple())) car[0]['pickupTime'] = str(timeandare.pickuptime) else: # 整辆车拥有很多订单 orderdisVec = [] for order in car: orderdisVec.append((order['bdlat'], order['bdlng'])) orderVec = re.getOrderLocVec(orderdisVec) disVec = auxfn.calcDistVec(TIANFUSQUIRE, orderVec) distSort = sorted(range(len(disVec)), key=lambda k: disVec[k], reverse=True) firstpktimeandarea = self.getpickuptime(car[distSort[0]]) starttime = firstpktimeandarea.pickuptime currentarea = firstpktimeandarea.area # if 'pickupTime' not in car[0].keys() or car[0]['driver'] is None or car[0]['driver'] is u"": pickuptime = starttime # unixpickuptime = int(time.mktime(pickuptime.timetuple())) car[distSort[0]]['pickupTime'] = str(pickuptime) # else: # pickuptime = self.unixtimeToBjTime(car[0]['pickupTime']) for i in range(1, len(distSort)): nextpktimeandarea = self.getpickuptime(car[distSort[i]]) nextarea = nextpktimeandarea.area # if 'pickupTime' not in car[i].keys() or car[i]['driver'] is None or car[i]['driver'] is u"": areacount = abs(nextarea - currentarea) if areacount is 0: pickuptime += datetime.timedelta( minutes=PICKTIME) + datetime.timedelta( minutes=SAMEDURATION) else: pickuptime += datetime.timedelta( minutes=PICKTIME) + datetime.timedelta( minutes=DIFDURATION * areacount) # unixpickuptime = int(time.mktime(pickuptime.timetuple())) car[distSort[i]]['pickupTime'] = str(pickuptime) # else: # pickuptime = self.unixtimeToBjTime(car[i]['pickupTime']) currentarea = nextarea return allcar