Subversion Repositories SmartDukaan

Rev

Rev 412 | Rev 472 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 412 Rev 442
Line 2... Line 2...
2
Created on 05-Aug-2010
2
Created on 05-Aug-2010
3
 
3
 
4
@author: ashish
4
@author: ashish
5
'''
5
'''
6
from shop2020.thriftpy.logistics.ttypes import Shipment
6
from shop2020.thriftpy.logistics.ttypes import Shipment
-
 
7
from shop2020.logistics.service.impl.DataAccessor import add_empty_AWBs, get_empty_AWB,\
-
 
8
    get_provider, get_shipment_info, get_shipments, get_todays_shipments, initialize,\
-
 
9
    get_providers, create_shipment, update_shipment_status
-
 
10
from shop2020.logistics.service.impl.Converters import to_t_provider,\
-
 
11
    to_t_shipment, to_t_shipmentstatusinfo, to_t_shipmentupdate
-
 
12
 
-
 
13
from shop2020.utils.Utils import log_entry, to_py_date
7
class LogisticsServiceHandler:
14
class LogisticsServiceHandler:
8
    
15
    
-
 
16
    def __init__(self):
-
 
17
        initialize()
-
 
18
        
9
    def addEmptyAWBs(self, numbers, provider_id):
19
    def addEmptyAWBs(self, numbers, provider_id):
10
        """
20
        """
11
        Parameters:
21
        Parameters:
12
         - numbers
22
         - numbers
13
         - provider_id
23
         - provider_id
14
        """
24
        """
15
        pass
25
        add_empty_AWBs(numbers, provider_id)
16
 
26
 
17
    def getEmptyAWB(self, provider_id):
27
    def getEmptyAWB(self, provider_id):
18
        """
28
        """
19
        Parameters:
29
        Parameters:
20
         - provider_id
30
         - provider_id
21
        """
31
        """
22
        pass
32
        return get_empty_AWB(provider_id)
23
    
33
    
24
    def getProviders(self, ):
34
    def getProviders(self):
-
 
35
        """
-
 
36
        Parameters:
25
        pass
37
        """
-
 
38
        log_entry(self, "all providers requested")
-
 
39
        
-
 
40
        providers = get_providers()
-
 
41
        ret_providers = []
-
 
42
        for provider in providers:
-
 
43
            if provider:
-
 
44
                ret_providers.append(to_t_provider(provider))
-
 
45
        return ret_providers
-
 
46
        
26
    
47
    
27
    def getProvider(self, provider_id):
48
    def getProvider(self, provider_id):
28
        """
49
        """
29
        Parameters:
50
        Parameters:
30
         - provider_id
51
         - provider_id
31
        """
52
        """
-
 
53
        return to_t_provider(get_provider(provider_id))
-
 
54
    
-
 
55
    def createShipment(self, shipment):
32
        pass
56
        """
-
 
57
        Parameters:
-
 
58
         - shipment
-
 
59
        """
-
 
60
        return create_shipment(shipment)
33
    
61
    
-
 
62
    
-
 
63
    def updateShipmentStatus(self, awb, shipment_update):
-
 
64
        """
-
 
65
        Parameters:
-
 
66
         - awb
-
 
67
         - shipment_update
-
 
68
        """
-
 
69
        return update_shipment_status(awb, shipment_update)
-
 
70
 
-
 
71
 
34
    def getShipmentInfo(self, awb):
72
    def getShipmentInfo(self, awb):
35
        """
73
        """
36
        Parameters:
74
        Parameters:
37
         - awb
75
         - awb
38
        """
76
        """
39
        pass
77
        return to_t_shipmentstatusinfo(get_shipment_info(awb))
40
    
78
    
41
    def getShipments(self, warehouse_id, from_date, to_date, provider_id):
79
    def getShipments(self, warehouse_id, from_date, to_date, provider_id):
42
        """
80
        """
43
        Parameters:
81
        Parameters:
44
         - warehouse_id
82
         - warehouse_id
45
         - from_date
83
         - from_date
46
         - to_date
84
         - to_date
47
         - provider_id
85
         - provider_id
48
        """
86
        """
-
 
87
        log_entry(self, "all shipments requested")
49
        pass
88
        
-
 
89
        from_datetime = to_py_date(from_date)
-
 
90
        to_datetime = to_py_date(to_date)
-
 
91
        
-
 
92
        shipments = get_shipments(warehouse_id, from_datetime, to_datetime, provider_id)
-
 
93
        ret_shipments = []
-
 
94
        for shipment in shipments:
-
 
95
            if shipment:
-
 
96
                ret_shipments.append(to_t_shipment(shipment))
-
 
97
        return ret_shipments
-
 
98
 
50
 
99
 
51
    def getTodaysShipments(self, warehouse_id, provider_id):
100
    def getTodaysShipments(self, warehouse_id, provider_id):
52
        """
101
        """
53
        Parameters:
102
        Parameters:
54
         - warehouse_id
103
         - warehouse_id
55
         - provider_id
104
         - provider_id
56
        """
105
        """
-
 
106
        
-
 
107
        log_entry(self, "all shipments requested for today")
-
 
108
        
-
 
109
        shipments = get_todays_shipments(warehouse_id, provider_id)
-
 
110
        ret_shipments = []
-
 
111
        for shipment in shipments:
-
 
112
            if shipment:
-
 
113
                ret_shipments.append(to_t_shipment(shipment))
-
 
114
        return ret_shipments
-
 
115
 
-
 
116
'''
57
        shipments = []
117
        shipments = []
58
        i = 0
118
        i = 0
59
        while i < 100:
119
        while i < 100:
60
            shipment = Shipment()
120
            shipment = Shipment()
61
            shipment.warehouse_name = "Seattle"
121
            shipment.warehouse_name = "Seattle"
Line 69... Line 129...
69
            shipment.shipment_contents = "iPhone 4G"
129
            shipment.shipment_contents = "iPhone 4G"
70
            shipment.shipment_weight = "300 gms"
130
            shipment.shipment_weight = "300 gms"
71
            shipments.append(shipment)
131
            shipments.append(shipment)
72
            i = i+1
132
            i = i+1
73
        return shipments
133
        return shipments
-
 
134
'''
-
 
135
        
74
136