Subversion Repositories SmartDukaan

Rev

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

Rev 10160 Rev 10174
Line 4... Line 4...
4
import in.shop2020.logistics.LogisticsInfo;
4
import in.shop2020.logistics.LogisticsInfo;
5
import in.shop2020.logistics.LogisticsServiceException;
5
import in.shop2020.logistics.LogisticsServiceException;
6
import in.shop2020.model.v1.catalog.CatalogService.Client;
6
import in.shop2020.model.v1.catalog.CatalogService.Client;
7
import in.shop2020.model.v1.catalog.FlipkartItem;
7
import in.shop2020.model.v1.catalog.FlipkartItem;
8
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.catalog.Item;
-
 
9
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
9
import in.shop2020.model.v1.catalog.status;
10
import in.shop2020.model.v1.catalog.status;
10
import in.shop2020.model.v1.inventory.FlipkartInventorySnapshot;
11
import in.shop2020.model.v1.inventory.FlipkartInventorySnapshot;
11
import in.shop2020.model.v1.inventory.InventoryType;
12
import in.shop2020.model.v1.inventory.InventoryType;
12
import in.shop2020.model.v1.inventory.ItemInventory;
13
import in.shop2020.model.v1.inventory.ItemInventory;
13
import in.shop2020.model.v1.inventory.Warehouse;
14
import in.shop2020.model.v1.inventory.Warehouse;
Line 66... Line 67...
66
	static java.text.SimpleDateFormat sdf;
67
	static java.text.SimpleDateFormat sdf;
67
	static String emailFromAddress;
68
	static String emailFromAddress;
68
	static String password;
69
	static String password;
69
	static GmailUtils mailer;
70
	static GmailUtils mailer;
70
	static String sendTo[];
71
	static String sendTo[];
-
 
72
	private static List<SnapdealItemDetails> snapdealItems = new ArrayList<SnapdealItemDetails>();
-
 
73
	private static Map<Long,SnapdealItemDetails> snapdealItemsMap = new HashMap<Long,SnapdealItemDetails>();
71
	static
74
	static
72
	{
75
	{
73
		sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
76
		sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
74
		emailFromAddress = "build@shop2020.in";
77
		emailFromAddress = "build@shop2020.in";
75
		password = "cafe@nes";
78
		password = "cafe@nes";
Line 85... Line 88...
85
		} catch (TTransportException e) {
88
		} catch (TTransportException e) {
86
			e.printStackTrace();
89
			e.printStackTrace();
87
		}
90
		}
88
		try {
91
		try {
89
			flipkartItems = catalogServiceClient.getAllFlipkartItems();
92
			flipkartItems = catalogServiceClient.getAllFlipkartItems();
-
 
93
			snapdealItems = catalogServiceClient.getAllSnapdealItems();
90
		} catch (TException e) {
94
		} catch (TException e) {
91
			e.printStackTrace();
95
			e.printStackTrace();
92
		}
96
		}
93
		for(FlipkartItem flipkartItem:flipkartItems){
97
		for(FlipkartItem flipkartItem:flipkartItems){
94
			if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed())
98
			if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed())
95
				flipkartInventoryItems.add(flipkartItem);
99
				flipkartInventoryItems.add(flipkartItem);
96
		}
100
		}
-
 
101
		for(SnapdealItemDetails snapdealItem:snapdealItems){
-
 
102
			snapdealItemsMap.put(snapdealItem.getItem_id(),snapdealItem);
-
 
103
		}
97
		if(flipkartInventoryItems.size()==0){
104
		if(flipkartInventoryItems.size()==0){
98
			String text = "";
105
			String text = "";
99
			try {
106
			try {
100
				mailer.sendSSLMessage(sendTo,"No items to send inventory ", emailFromAddress, password, text);
107
				mailer.sendSSLMessage(sendTo,"No items to send inventory ", emailFromAddress, password, text);
101
				System.exit(0);
108
				System.exit(0);
Line 171... Line 178...
171
		} catch (TTransportException e) {
178
		} catch (TTransportException e) {
172
			e.printStackTrace();
179
			e.printStackTrace();
173
		}
180
		}
174
		long stock=0;
181
		long stock=0;
175
		int i=0;
182
		int i=0;
176
		long available,reserve,heldforsource,totalheld,allocable,holdinventory,defaultinventory,actualstock,orders,heldorders;
183
		long available,reserve,heldforsource,totalheld,allocable,holdinventory,defaultinventory,actualstock = 0,orders,heldorders,allocation;
177
		StringBuffer inventoryItems =new StringBuffer();
184
		StringBuffer inventoryItems =new StringBuffer();
178
		StringBuffer backInStockItems =new StringBuffer();
185
		StringBuffer backInStockItems =new StringBuffer();
179
		StringBuffer outOfStockItems =new StringBuffer();
186
		StringBuffer outOfStockItems =new StringBuffer();
180
		String tableHeader = "<html><table border=\"1\" align=\"center\"><tr>" 
187
		String tableHeader = "<html><table border=\"1\" align=\"center\"><tr>" 
181
			+ "<td><b>" + "Product Name" +"</b></td>"
188
			+ "<td><b>" + "Product Name" +"</b></td>"
Line 190... Line 197...
190
		String tableFooter = "</table></html>";
197
		String tableFooter = "</table></html>";
191
		Item item;
198
		Item item;
192
		StringBuffer feedResponse=  new StringBuffer();
199
		StringBuffer feedResponse=  new StringBuffer();
193
		List<FlipkartInventorySnapshot> inventorysnapshotlist = new ArrayList<FlipkartInventorySnapshot>();
200
		List<FlipkartInventorySnapshot> inventorysnapshotlist = new ArrayList<FlipkartInventorySnapshot>();
194
		for(Entry<Long, FlipkartInventoryItem> entry:flipkartItemsInventoryMap.entrySet()){
201
		for(Entry<Long, FlipkartInventoryItem> entry:flipkartItemsInventoryMap.entrySet()){
-
 
202
			if(snapdealItemsMap.containsKey(entry.getKey()) && snapdealItemsMap.get(entry.getKey()).isIsListedOnSnapdeal()){
-
 
203
				allocation=1/3;
-
 
204
			}
-
 
205
			else{
-
 
206
				allocation=2/3;
-
 
207
			}
195
			actualstock=0;
208
			actualstock=0;
196
			orders=0;
209
			orders=0;
197
			stock=0;
210
			stock=0;
198
			heldorders=0;
211
			heldorders=0;
199
			available = entry.getValue().getAvailability();
212
			available = entry.getValue().getAvailability();
Line 217... Line 230...
217
					else{
230
					else{
218
						allocable = available - reserve - totalheld - holdinventory;
231
						allocable = available - reserve - totalheld - holdinventory;
219
						if(allocable < 0){
232
						if(allocable < 0){
220
							allocable = 0;
233
							allocable = 0;
221
						}
234
						}
222
						stock = Math.round(allocable*1/3) + heldforsource;
235
						stock = Math.round(allocable*allocation) + heldforsource;
223
					}
236
					}
224
 
237
 
225
				}
238
				}
226
				else{
239
				else{
227
					allocable = available - reserve - totalheld;
240
					allocable = available - reserve - totalheld;
228
					if(allocable < 0){
241
					if(allocable < 0){
229
						allocable = 0;
242
						allocable = 0;
230
					}
243
					}
231
					if((allocable + heldforsource ) > defaultinventory){
244
					if((allocable + heldforsource ) > defaultinventory){
232
						stock = Math.round(allocable*1/3) +  heldforsource;
245
						stock = Math.round(allocable*allocation) +  heldforsource;
233
					}
246
					}
234
					else{
247
					else{
235
						stock = defaultinventory;
248
						stock = defaultinventory;
236
					}
249
					}
237
				}
250
				}