Subversion Repositories SmartDukaan

Rev

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

Rev 4990 Rev 5210
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
3
import in.shop2020.model.v1.catalog.InventoryService.Client;
3
import in.shop2020.model.v1.catalog.InventoryService.Client;
-
 
4
import in.shop2020.model.v1.catalog.Item;
-
 
5
import in.shop2020.model.v1.catalog.ItemType;
-
 
6
import in.shop2020.model.v1.catalog.VendorItemMapping;
4
import in.shop2020.model.v1.catalog.Warehouse;
7
import in.shop2020.model.v1.catalog.Warehouse;
5
import in.shop2020.support.models.BillingUpdate;
8
import in.shop2020.support.models.BillingUpdate;
6
import in.shop2020.support.models.InventoryUpdate;
9
import in.shop2020.support.models.InventoryUpdate;
7
import in.shop2020.support.models.PLBDetails;
10
import in.shop2020.support.models.PLBDetails;
8
import in.shop2020.support.models.Update;
11
import in.shop2020.support.models.Update;
Line 36... Line 39...
36
	private InventoryUpdate inventoryUpdate = new InventoryUpdate();
39
	private InventoryUpdate inventoryUpdate = new InventoryUpdate();
37
	private String timestampAndItemIds;
40
	private String timestampAndItemIds;
38
	
41
	
39
	private int errorCode = 0;
42
	private int errorCode = 0;
40
	private String errorMessage;
43
	private String errorMessage;
41
	
-
 
-
 
44
	private boolean fullPlbSync = false;
42
	private String id;
45
	private String id;
43
	
46
	
44
	
47
	
45
	public UpdatesController(){
48
	public UpdatesController(){
46
		
49
		
Line 60... Line 63...
60
			catalogServiceClient = new CatalogClient();
63
			catalogServiceClient = new CatalogClient();
61
			client = catalogServiceClient.getClient();
64
			client = catalogServiceClient.getClient();
62
			long warehouseId = Long.parseLong(getId());
65
			long warehouseId = Long.parseLong(getId());
63
			Warehouse warehouse = client.getWarehouse(warehouseId);
66
			Warehouse warehouse = client.getWarehouse(warehouseId);
64
			timestampAndItemIds = warehouse.getVendorString();
67
			timestampAndItemIds = warehouse.getVendorString();
65
			
68
 
66
			List<String> itemKeys = client.getItemKeysToBeProcessed(warehouseId);
69
			List<String> itemKeys = client.getItemKeysToBeProcessed(warehouseId);
-
 
70
			if (fullPlbSync) {
-
 
71
			    itemKeys = new ArrayList<String>();
-
 
72
			    List<Item> items = client.getAllItems(true);
-
 
73
			    for (Item item : items) {
-
 
74
			        if (ItemType.NON_SERIALIZED.equals(item.getType())) {
-
 
75
			            continue;
-
 
76
			        }
-
 
77
 
-
 
78
			        List<VendorItemMapping> mappings = client.getVendorItemMappings(item.getId());
-
 
79
			        if (mappings != null) {
-
 
80
			            for (VendorItemMapping mapping : mappings) {
-
 
81
			                if (mapping.getVendorId() == 1) {
-
 
82
			                    itemKeys.add(mapping.getItemKey());
-
 
83
			                    break;
-
 
84
			                }
-
 
85
			            }
-
 
86
			        }
-
 
87
			    }
-
 
88
			}
-
 
89
 
67
			if (!itemKeys.isEmpty()) {
90
			if (!itemKeys.isEmpty()) {
68
			    for (String itemKey : itemKeys) {
91
			    for (String itemKey : itemKeys) {
69
			        timestampAndItemIds += FIELD_DELIMITER + itemKey;
92
			        timestampAndItemIds += FIELD_DELIMITER + itemKey;
70
			    }
93
			    }
71
			}
94
			}
Line 172... Line 195...
172
		this.timestampAndItemIds = timestampAndItemIds;
195
		this.timestampAndItemIds = timestampAndItemIds;
173
	}
196
	}
174
 
197
 
175
	public String getTimestampAndItemIds() {
198
	public String getTimestampAndItemIds() {
176
		return timestampAndItemIds;
199
		return timestampAndItemIds;
177
	}	
200
	}
-
 
201
 
-
 
202
    public boolean isFullPlbSync() {
-
 
203
        return fullPlbSync;
-
 
204
    }
-
 
205
 
-
 
206
    public void setFullPlbSync(boolean fullPlbSync) {
-
 
207
        this.fullPlbSync = fullPlbSync;
-
 
208
    }	
178
}
209
}