Rev 477 | Rev 494 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 05-Aug-2010@author: ashish'''from shop2020.thriftpy.logistics.ttypes import Shipment, LogisticsInfofrom shop2020.logistics.service.impl.DataAccessor import add_empty_AWBs, get_empty_AWB,\get_provider, get_shipment_info, get_shipments, get_todays_shipments, initialize,\get_providers, create_shipment, update_shipment_status, get_logistics_estimation, add_delivery_estimate,\add_pincode_warehouse_mapping, get_logistics_infofrom shop2020.logistics.service.impl.Converters import to_t_provider,\to_t_shipment, to_t_shipmentstatusinfo, to_t_shipmentupdate, to_t_itemLogisticsfrom shop2020.utils.Utils import log_entry, to_py_dateclass LogisticsServiceHandler:def __init__(self):initialize()def getLogisticsInfo(self, destination_pincode, sku_id):"""Parameters:- destination_pincode- sku_id"""warehouse_id, provider_id, airway_billno, delivery_time = get_logistics_info(destination_pincode, sku_id)logistics_info = LogisticsInfo()logistics_info.airway_billno = airway_billnologistics_info.warehouse_id = warehouse_idlogistics_info.delivery_estimate = delivery_timelogistics_info.provider_id = provider_idreturn logistics_infodef addEmptyAWBs(self, numbers, provider_id):"""Parameters:- numbers- provider_id"""add_empty_AWBs(numbers, provider_id)def getEmptyAWB(self, provider_id):"""Parameters:- provider_id"""return get_empty_AWB(provider_id)def getProviders(self):"""Parameters:"""log_entry(self, "all providers requested")providers = get_providers()ret_providers = []for provider in providers:if provider:ret_providers.append(to_t_provider(provider))return ret_providersdef getProvider(self, provider_id):"""Parameters:- provider_id"""return to_t_provider(get_provider(provider_id))def createShipment(self, shipment):"""Parameters:- shipment"""return create_shipment(shipment)def updateShipmentStatus(self, awb, shipment_update):"""Parameters:- awb- shipment_update"""return update_shipment_status(awb, shipment_update)def getShipmentInfo(self, awb):"""Parameters:- awb"""return to_t_shipmentstatusinfo(get_shipment_info(awb))def getShipments(self, warehouse_id, from_date, to_date, provider_id):"""Parameters:- warehouse_id- from_date- to_date- provider_id"""log_entry(self, "all shipments requested")from_datetime = to_py_date(from_date)to_datetime = to_py_date(to_date)shipments = get_shipments(warehouse_id, from_datetime, to_datetime, provider_id)ret_shipments = []for shipment in shipments:if shipment:ret_shipments.append(to_t_shipment(shipment))return ret_shipmentsdef getLogisticsEstimation(self, itemId, destination_pin, provider_id):"""Parameters:- itemId- destination_pin"""delivery_estimate, warehouse_id = get_logistics_estimation(itemId, destination_pin, provider_id)items_in_inventory = 100return to_t_itemLogistics(delivery_estimate, items_in_inventory, warehouse_id)def addDeliveryEstimate(self, warahouse_id, destination_pin, provider_id, delivery_time, reliability):"""Parameters:- warahouse_id- destination_pin- provider_id- delivery_time"""add_delivery_estimate(warahouse_id, destination_pin, provider_id, delivery_time, reliability)def addPincodeWarehouseMapping(self, pincode, warehouse_id, warehouse_pin):"""Parameters:- pincode- warehouse_id- warehouse_name"""add_pincode_warehouse_mapping(pincode, warehouse_id, warehouse_pin)def getTodaysShipments(self, warehouse_id, provider_id):"""Parameters:- warehouse_id- provider_id"""log_entry(self, "all shipments requested for today")shipments = get_todays_shipments(warehouse_id, provider_id)ret_shipments = []for shipment in shipments:if shipment:ret_shipments.append(to_t_shipment(shipment))return ret_shipments'''shipments = []i = 0while i < 100:shipment = Shipment()shipment.warehouse_name = "Seattle"shipment.awb="1234"+str(i)shipment.destination="JP"shipment.origin = "US"shipment.recepient_address = "1, Microsoft Way, Redmond"shipment.recepient_name = "Steve Balmer"shipment.recepient_phone = "+14356368790"shipment.recepient_pincode = "110001"shipment.shipment_contents = "iPhone 4G"shipment.shipment_weight = "300 gms"shipments.append(shipment)i = i+1return shipments'''