Subversion Repositories SmartDukaan

Rev

Rev 4642 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4642 Rev 5320
Line 1... Line 1...
1
'''
1
'''
2
Created on 13-Sep-2010
2
Created on 13-Sep-2010
3
 
3
 
4
@author: rajveer
4
@author: rajveer
5
'''
5
'''
-
 
6
import os
-
 
7
import sys
-
 
8
sys.path.insert(0, os.getcwd())
6
 
9
 
7
from shop2020.clients.LogisticsClient import LogisticsClient
10
from shop2020.clients.LogisticsClient import LogisticsClient
8
from shop2020.thriftpy.logistics.ttypes import *
11
from shop2020.thriftpy.logistics.ttypes import DeliveryType
9
import datetime
12
import datetime
10
from shop2020.logistics.service.impl.DataService import DeliveryEstimate
-
 
11
 
13
 
12
 
14
 
13
client = LogisticsClient().get_client()
-
 
14
 
15
 
15
"""
16
"""
16
now = datetime.datetime.now()
17
now = datetime.datetime.now()
17
test = now.hour
18
test = now.hour
18
print test, now.hour
19
print test, now.hour
Line 40... Line 41...
40
 
41
 
41
# Item = 03 (>5000) Pincode = 201301 (Local) serviced by Both, Provider = 1
42
# Item = 03 (>5000) Pincode = 201301 (Local) serviced by Both, Provider = 1
42
# Item = 15 (<5000) Pincode = 201301 (Local) serviced by Both, Provider = 2
43
# Item = 15 (<5000) Pincode = 201301 (Local) serviced by Both, Provider = 2
43
# Item = 04 (>5000) Pincode = 201307 (Local) serviced by Both,  Provider = 1
44
# Item = 04 (>5000) Pincode = 201307 (Local) serviced by Both,  Provider = 1
44
# Item = 19 (=5000) Pincode = 201307 (Local) serviced by Both,  Provider = 2
45
# Item = 19 (=5000) Pincode = 201307 (Local) serviced by Both,  Provider = 2
-
 
46
def adjust_delivery_time(start_time, delivery_days):
-
 
47
    '''
-
 
48
    Returns the actual no. of days which will pass while 'delivery_days'
-
 
49
    no. of business days will pass since 'order_time'. 
-
 
50
    '''
-
 
51
    start_date = start_time.date()
-
 
52
    end_date = start_date + datetime.timedelta(days = delivery_days)
45
 
53
    
-
 
54
    while start_date <= end_date:
-
 
55
        if start_date.weekday() == 6:
-
 
56
            delivery_days = delivery_days + 1
-
 
57
            end_date = end_date + datetime.timedelta(days = 1)
-
 
58
        start_date = start_date + datetime.timedelta(days = 1)
-
 
59
    
-
 
60
    return delivery_days
46
 
61
 
-
 
62
#print client.getEmptyAWB(1)
47
print client.getLogisticsEstimation(14, "201301", DeliveryType.PREPAID) #Provider = 1
63
#print client.getLogisticsEstimation(14, "201301", DeliveryType.PREPAID) #Provider = 1
-
 
64
starttime = datetime.datetime.now()
-
 
65
for j in range(5):
-
 
66
    client = LogisticsClient().get_client()
-
 
67
    for i in range(200):
-
 
68
        try:
-
 
69
            print client.getLogisticsEstimation(i, "201301", DeliveryType.PREPAID) #Provider = 1
-
 
70
            print client.getLogisticsEstimation(i, "201301", DeliveryType.COD) #Provider = 1
-
 
71
            print client.getLogisticsEstimation(i, "332001", DeliveryType.PREPAID) #Provider = 1
-
 
72
            print client.getLogisticsEstimation(i, "332001", DeliveryType.COD) #Provider = 1
-
 
73
        except:
-
 
74
            print "exception"
-
 
75
endtime = datetime.datetime.now()
-
 
76
print endtime, starttime        
-
 
77
        
-
 
78
#print client.getLogisticsEstimation(26, "201301", DeliveryType.PREPAID) #Provider = 1
48
print client.getLogisticsEstimation(15, "201301", DeliveryType.PREPAID) #Provider = 1
79
#print client.getLogisticsEstimation(15, "201301", DeliveryType.PREPAID) #Provider = 1
-
 
80
#print client.getLogisticsEstimation(16, "110001", DeliveryType.PREPAID) #Provider = 1
-
 
81
#print client.getLogisticsEstimation(17, "332001", DeliveryType.PREPAID) #Provider = 1
-
 
82
 
-
 
83
#logistics_info = client.getLogisticsInfo("201301", 15, DeliveryType.PREPAID)
-
 
84
            
-
 
85
#current_time = datetime.datetime.now()
-
 
86
#print adjust_delivery_time(current_time, logistics_info.deliveryTime)
-
 
87
#print adjust_delivery_time(current_time, logistics_info.shippingTime)
-
 
88
 
-
 
89
#print (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=12, minute=0, second=0)
-
 
90
#print current_time + datetime.timedelta(days=logistics_info.deliveryTime)       
-
 
91
            
49
print client.isCodAllowed("201301")
92
#print client.isCodAllowed("201301")
50
print client.isCodAllowed("3")
93
#print client.isCodAllowed("3")
51
print client.getDestinationCode(1, "201301")
94
#print client.getDestinationCode(1, "201301")
52
print client.getDestinationCode(1, "332001")
95
#print client.getDestinationCode(1, "332001")
53
 
96
 
54
#client.getLogisticsEstimation(02, "125005") #Provider = 1
97
#client.getLogisticsEstimation(02, "125005") #Provider = 1
55
#client.getLogisticsEstimation(19, "123106") #Provider = 2
98
#client.getLogisticsEstimation(19, "123106") #Provider = 2
56
#client.getLogisticsEstimation(01, "123106") #Provider = 2
99
#client.getLogisticsEstimation(01, "123106") #Provider = 2
57
#client.getLogisticsEstimation(14, "834011") #Provider = 2
100
#client.getLogisticsEstimation(14, "834011") #Provider = 2