Subversion Repositories SmartDukaan

Rev

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

Rev 490 Rev 616
Line 46... Line 46...
46
			client = catalogServiceClient.getClient();
46
			client = catalogServiceClient.getClient();
47
			long warehouseId = Long.parseLong(getId());
47
			long warehouseId = Long.parseLong(getId());
48
			Warehouse warehouse = client.getWarehouse(warehouseId);
48
			Warehouse warehouse = client.getWarehouse(warehouseId);
49
			setTimestamp(warehouse.getVendorString());
49
			setTimestamp(warehouse.getVendorString());
50
		} catch (Exception e) {
50
		} catch (Exception e) {
51
			// TODO Auto-generated catch block
-
 
52
			e.printStackTrace();
51
			e.printStackTrace();
53
		}
52
		}
54
		return new DefaultHttpHeaders("lsuccess");
53
		return new DefaultHttpHeaders("lsuccess");
55
	}
54
	}
56
	
55
	
Line 66... Line 65...
66
			Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
65
			Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
67
			String timestamp = inventoryUpdate.getCurrentTimestamp();
66
			String timestamp = inventoryUpdate.getCurrentTimestamp();
68
			Map<String, Long> availability = new HashMap<String, Long>();
67
			Map<String, Long> availability = new HashMap<String, Long>();
69
			List<Update> updates = inventoryUpdate.getUpdates();
68
			List<Update> updates = inventoryUpdate.getUpdates();
70
			for(Update update: updates){
69
			for(Update update: updates){
71
				String skuId = update.getSkuId();
70
				String brand = update.getBrand().trim();
-
 
71
				String model = update.getModel().trim();
-
 
72
				String color = update.getColor().trim();
-
 
73
				String key = brand + ";" + model + ";" + color;
72
				long quantity = (long) Double.parseDouble(update.getQuantity());
74
				long quantity = (long) Double.parseDouble(update.getQuantity());
73
				if(availability.containsKey(skuId)){
75
				if(availability.containsKey(key)){
74
					quantity = quantity + availability.get(skuId);
76
					quantity = quantity + availability.get(key);
75
				}
77
				}
76
				availability.put(skuId, quantity);
78
				availability.put(key, quantity);
77
			}
79
			}
78
			client.updateInventory(warehouseId, timestamp, availability);
80
			client.updateInventory(warehouseId, timestamp, availability);
79
			
81
			
80
		} catch (Exception e) {
82
		} catch (Exception e) {
81
			// TODO Auto-generated catch block
-
 
82
			e.printStackTrace();
83
			e.printStackTrace();
83
		}
84
		}
84
		
85
		
85
		return new DefaultHttpHeaders("psuccess");
86
		return new DefaultHttpHeaders("psuccess");
86
 
87
 
Line 114... Line 115...
114
		this.timestamp = timestamp;
115
		this.timestamp = timestamp;
115
	}
116
	}
116
 
117
 
117
	public String getTimestamp() {
118
	public String getTimestamp() {
118
		return timestamp;
119
		return timestamp;
119
	}
120
	}	
120
	
-
 
121
}
121
}