| 442 |
rajveer |
1 |
'''
|
|
|
2 |
Created on 13-Sep-2010
|
|
|
3 |
|
|
|
4 |
@author: rajveer
|
|
|
5 |
'''
|
| 5320 |
rajveer |
6 |
import os
|
|
|
7 |
import sys
|
|
|
8 |
sys.path.insert(0, os.getcwd())
|
| 442 |
rajveer |
9 |
|
|
|
10 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 5320 |
rajveer |
11 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType
|
| 442 |
rajveer |
12 |
import datetime
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
| 1504 |
ankur.sing |
16 |
"""
|
| 494 |
rajveer |
17 |
now = datetime.datetime.now()
|
|
|
18 |
test = now.hour
|
|
|
19 |
print test, now.hour
|
| 1504 |
ankur.sing |
20 |
itemlogistics = client.getLogisticsEstimation(1, "332301")
|
| 472 |
rajveer |
21 |
print itemlogistics.warehouseId
|
|
|
22 |
print itemlogistics.availability
|
|
|
23 |
print itemlogistics.shippingTime
|
| 1504 |
ankur.sing |
24 |
"""
|
| 442 |
rajveer |
25 |
|
| 477 |
rajveer |
26 |
|
| 1504 |
ankur.sing |
27 |
"""
|
|
|
28 |
The following test cases are to test if correct provider is being returned. For a destination pincode and a warehouse,
|
|
|
29 |
the provider mapping is defined in PyProj/src/samplesheets/Courier_Logic.xls
|
|
|
30 |
To check the output make modifications in the following function to print provider on the console.
|
|
|
31 |
PyProj/src/shop2020/logistics/service/impl/DataAccessor/get_logistics_estimation
|
|
|
32 |
"""
|
| 477 |
rajveer |
33 |
|
| 1504 |
ankur.sing |
34 |
# Item = 14 (<5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1
|
|
|
35 |
# Item = 02 (>5000) Pincode = 125005 (Non-Local) serviced by Both, Provider = 1
|
|
|
36 |
# Item = 19 (=5000) Pincode = 123106 (Non-Local) serviced by AFL, Provider = 2
|
|
|
37 |
# Item = 01 (>5000) Pincode = 123106 (Non-Local) serviced by AFL, Provider = 2
|
|
|
38 |
# Item = 14 (<5000) Pincode = 834011 (Non-Local) serviced by AFL, Provider = 2
|
|
|
39 |
# Item = 14 (<5000) Pincode = 854305 (Non-Local) serviced by BlueDart, Provider = 1
|
|
|
40 |
# Item = 01 (>5000) Pincode = 854305 (Non-Local) serviced by BlueDart, Provider = 1
|
| 442 |
rajveer |
41 |
|
| 1504 |
ankur.sing |
42 |
# Item = 03 (>5000) Pincode = 201301 (Local) serviced by Both, Provider = 1
|
|
|
43 |
# Item = 15 (<5000) Pincode = 201301 (Local) serviced by Both, Provider = 2
|
|
|
44 |
# Item = 04 (>5000) Pincode = 201307 (Local) serviced by Both, Provider = 1
|
|
|
45 |
# Item = 19 (=5000) Pincode = 201307 (Local) serviced by Both, Provider = 2
|
| 5320 |
rajveer |
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)
|
|
|
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
|
| 442 |
rajveer |
61 |
|
| 5320 |
rajveer |
62 |
#print client.getEmptyAWB(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
|
|
|
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
|
| 442 |
rajveer |
82 |
|
| 5320 |
rajveer |
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)
|
| 442 |
rajveer |
88 |
|
| 5320 |
rajveer |
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 |
|
|
|
92 |
#print client.isCodAllowed("201301")
|
|
|
93 |
#print client.isCodAllowed("3")
|
|
|
94 |
#print client.getDestinationCode(1, "201301")
|
|
|
95 |
#print client.getDestinationCode(1, "332001")
|
|
|
96 |
|
| 3218 |
rajveer |
97 |
#client.getLogisticsEstimation(02, "125005") #Provider = 1
|
|
|
98 |
#client.getLogisticsEstimation(19, "123106") #Provider = 2
|
|
|
99 |
#client.getLogisticsEstimation(01, "123106") #Provider = 2
|
|
|
100 |
#client.getLogisticsEstimation(14, "834011") #Provider = 2
|
|
|
101 |
#client.getLogisticsEstimation(14, "854305") #Provider = 1
|
|
|
102 |
#client.getLogisticsEstimation(1, "854305") #Provider = 1
|
|
|
103 |
#
|
|
|
104 |
#client.getLogisticsEstimation(03, "201301") #Provider = 1
|
|
|
105 |
#client.getLogisticsEstimation(15, "201301") #Provider = 2
|
|
|
106 |
#client.getLogisticsEstimation(04, "201307") #Provider = 1
|
|
|
107 |
#client.getLogisticsEstimation(19, "201307") #Provider = 2
|