| Line 92... |
Line 92... |
| 92 |
return "authfail";
|
92 |
return "authfail";
|
| 93 |
}
|
93 |
}
|
| 94 |
return "edit";
|
94 |
return "edit";
|
| 95 |
}
|
95 |
}
|
| 96 |
|
96 |
|
| 97 |
|
97 |
|
| 98 |
public String show() {
|
98 |
public String show() {
|
| 99 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
99 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
| 100 |
return "authfail";
|
100 |
return "authfail";
|
| 101 |
}
|
101 |
}
|
| 102 |
logger.info("Inside show for "+id);
|
102 |
logger.info("Inside show for "+id);
|
| 103 |
|
103 |
|
| 104 |
if (StringUtils.equals(id, "bulk-add-options")){
|
104 |
if (StringUtils.equals(id, "bulk-add-options")){
|
| 105 |
return "bulk-add-options";
|
105 |
return "bulk-add-options";
|
| 106 |
}
|
106 |
}
|
| 107 |
return "id";
|
107 |
return "id";
|
| 108 |
}
|
108 |
}
|
| 109 |
|
109 |
|
| 110 |
public String loadVendorDiv(){
|
110 |
public String loadVendorDiv(){
|
| 111 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
111 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 112 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
112 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 113 |
return "authfail";
|
113 |
return "authfail";
|
| 114 |
}
|
114 |
}
|
| 115 |
return "vendor-item-pricing-upload";
|
115 |
return "vendor-item-pricing-upload";
|
| 116 |
}
|
116 |
}
|
| 117 |
|
117 |
|
| 118 |
public String loadVirtualDiv(){
|
118 |
public String loadVirtualDiv(){
|
| 119 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
119 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 120 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
120 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 121 |
return "authfail";
|
121 |
return "authfail";
|
| 122 |
}
|
122 |
}
|
| 123 |
return "virtual-bulk-add";
|
123 |
return "virtual-bulk-add";
|
| 124 |
}
|
124 |
}
|
| 125 |
|
125 |
|
| 126 |
public String loadCatalogDiv(){
|
126 |
public String loadCatalogDiv(){
|
| 127 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
127 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 128 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
128 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 129 |
return "authfail";
|
129 |
return "authfail";
|
| 130 |
}
|
130 |
}
|
| 131 |
return "catalog-bulk-add";
|
131 |
return "catalog-bulk-add";
|
| 132 |
}
|
132 |
}
|
| 133 |
|
133 |
|
| 134 |
public String loadDtrDiv(){
|
134 |
public String loadDtrDiv(){
|
| 135 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
135 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 136 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
136 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 137 |
return "authfail";
|
137 |
return "authfail";
|
| 138 |
}
|
138 |
}
|
| 139 |
return "dtr-bulk-add";
|
139 |
return "dtr-bulk-add";
|
| 140 |
}
|
140 |
}
|
| 141 |
|
141 |
|
| 142 |
public String uploadItemsDtr() throws IOException, CatalogServiceException, TException{
|
142 |
public String uploadItemsDtr() throws IOException, CatalogServiceException, TException{
|
| 143 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
143 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 144 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
144 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 145 |
return "authfail";
|
145 |
return "authfail";
|
| 146 |
}
|
146 |
}
|
| 147 |
File fileToCreate = new File("/tmp/", "dtr-items.xls");
|
147 |
File fileToCreate = new File("/tmp/", "dtr-items.xls");
|
| 148 |
FileUtils.copyFile(this.file, fileToCreate);
|
148 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 149 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
149 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 150 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
150 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 151 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
151 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 152 |
|
152 |
|
| 153 |
List<BulkItems> bulkItemsList= new ArrayList<BulkItems>();
|
153 |
List<BulkItems> bulkItemsList= new ArrayList<BulkItems>();
|
| 154 |
|
154 |
|
| 155 |
List<Long> items = new ArrayList<Long>();
|
155 |
List<Long> items = new ArrayList<Long>();
|
| 156 |
|
156 |
|
| 157 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
157 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 158 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
158 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 159 |
items.add(item_id);
|
159 |
items.add(item_id);
|
| Line 169... |
Line 169... |
| 169 |
sb.append("Item is not valid "+itemId+"\n");
|
169 |
sb.append("Item is not valid "+itemId+"\n");
|
| 170 |
continue;
|
170 |
continue;
|
| 171 |
}
|
171 |
}
|
| 172 |
BulkItems b = new BulkItems();
|
172 |
BulkItems b = new BulkItems();
|
| 173 |
b.setItem_id(itemId);
|
173 |
b.setItem_id(itemId);
|
| - |
|
174 |
|
| - |
|
175 |
if (checkEmptyString(sheet.getRow(iterator).getCell(1))){
|
| - |
|
176 |
b.setShowMrpFlag(false);
|
| - |
|
177 |
}
|
| - |
|
178 |
else{
|
| 174 |
int show_mrp_flag = (int) sheet.getRow(iterator).getCell(1).getNumericCellValue();
|
179 |
int show_mrp_flag = (int) sheet.getRow(iterator).getCell(1).getNumericCellValue();
|
| 175 |
b.setShowMrpFlag(show_mrp_flag ==1 ? true : false);
|
180 |
b.setShowMrpFlag(show_mrp_flag ==1 ? true : false);
|
| - |
|
181 |
}
|
| - |
|
182 |
if (checkEmptyString(sheet.getRow(iterator).getCell(2))){
|
| - |
|
183 |
b.setTagline("");
|
| - |
|
184 |
}
|
| - |
|
185 |
else{
|
| 176 |
String tagline = sheet.getRow(iterator).getCell(2).getStringCellValue().toString();
|
186 |
String tagline = sheet.getRow(iterator).getCell(2).getStringCellValue();
|
| 177 |
b.setTagline(tagline);
|
187 |
b.setTagline(tagline);
|
| - |
|
188 |
}
|
| - |
|
189 |
if (checkEmptyString(sheet.getRow(iterator).getCell(3))){
|
| - |
|
190 |
b.setOffer("");
|
| - |
|
191 |
}
|
| - |
|
192 |
else{
|
| 178 |
String offer = sheet.getRow(iterator).getCell(3).getStringCellValue().toString();
|
193 |
String offer = sheet.getRow(iterator).getCell(3).getStringCellValue();
|
| 179 |
b.setOffer(offer);
|
194 |
b.setOffer(offer);
|
| - |
|
195 |
}
|
| 180 |
long category_id = (long) sheet.getRow(iterator).getCell(4).getNumericCellValue();
|
196 |
long category_id = (long) sheet.getRow(iterator).getCell(4).getNumericCellValue();
|
| 181 |
if (category_id!=6L){
|
197 |
if (category_id!=6L){
|
| 182 |
sb.append("Category Id is not valid "+itemId+"\n");
|
198 |
sb.append("Category Id is not valid "+itemId+"\n");
|
| 183 |
}
|
199 |
}
|
| 184 |
b.setCategory_id(category_id);
|
200 |
b.setCategory_id(category_id);
|
| Line 218... |
Line 234... |
| 218 |
}else{
|
234 |
}else{
|
| 219 |
setResult("Items added successfully");
|
235 |
setResult("Items added successfully");
|
| 220 |
}
|
236 |
}
|
| 221 |
return "item-details-json";
|
237 |
return "item-details-json";
|
| 222 |
}
|
238 |
}
|
| 223 |
|
239 |
|
| 224 |
public String updateVirtualInventory() throws IOException, CatalogServiceException, TException, InventoryServiceException{
|
240 |
public String updateVirtualInventory() throws IOException, CatalogServiceException, TException, InventoryServiceException{
|
| 225 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
241 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 226 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
242 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 227 |
return "authfail";
|
243 |
return "authfail";
|
| 228 |
}
|
244 |
}
|
| 229 |
|
245 |
|
| 230 |
File fileToCreate = new File("/tmp/", "vendor-inventory.xls");
|
246 |
File fileToCreate = new File("/tmp/", "vendor-inventory.xls");
|
| 231 |
FileUtils.copyFile(this.file, fileToCreate);
|
247 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 232 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
248 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 233 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
249 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 234 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
250 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 235 |
|
251 |
|
| 236 |
List<BulkAddInventory> vendorInventory= new ArrayList<BulkAddInventory>();
|
252 |
List<BulkAddInventory> vendorInventory= new ArrayList<BulkAddInventory>();
|
| 237 |
|
253 |
|
| 238 |
List<Long> items = new ArrayList<Long>();
|
254 |
List<Long> items = new ArrayList<Long>();
|
| 239 |
|
255 |
|
| 240 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
256 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 241 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
257 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 242 |
items.add(item_id);
|
258 |
items.add(item_id);
|
| 243 |
}
|
259 |
}
|
| 244 |
Client cc = new CatalogClient().getClient();
|
260 |
Client cc = new CatalogClient().getClient();
|
| 245 |
Map<Long, Item> itemMap = cc.getItems(items);
|
261 |
Map<Long, Item> itemMap = cc.getItems(items);
|
| 246 |
|
262 |
|
| 247 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
263 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 248 |
long itemId = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
264 |
long itemId = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 249 |
if (itemMap.get(itemId)==null){
|
265 |
if (itemMap.get(itemId)==null){
|
| 250 |
continue;
|
266 |
continue;
|
| 251 |
}
|
267 |
}
|
| Line 255... |
Line 271... |
| 255 |
b.setWarehouse_id(warehouseId);
|
271 |
b.setWarehouse_id(warehouseId);
|
| 256 |
long inventory = (long) sheet.getRow(iterator).getCell(2).getNumericCellValue();
|
272 |
long inventory = (long) sheet.getRow(iterator).getCell(2).getNumericCellValue();
|
| 257 |
b.setInventory(inventory);
|
273 |
b.setInventory(inventory);
|
| 258 |
vendorInventory.add(b);
|
274 |
vendorInventory.add(b);
|
| 259 |
}
|
275 |
}
|
| 260 |
|
276 |
|
| 261 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
277 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 262 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
278 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 263 |
inventoryClient.addInventoryInBulk(vendorInventory);
|
279 |
inventoryClient.addInventoryInBulk(vendorInventory);
|
| 264 |
setResult("Inventory updated successfully");
|
280 |
setResult("Inventory updated successfully");
|
| 265 |
return "item-details-json";
|
281 |
return "item-details-json";
|
| 266 |
}
|
282 |
}
|
| 267 |
|
283 |
|
| 268 |
public String addVendorItemPricing() throws IOException, TException, CatalogServiceException{
|
284 |
public String addVendorItemPricing() throws IOException, TException, CatalogServiceException{
|
| 269 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
285 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 270 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
286 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 271 |
return "authfail";
|
287 |
return "authfail";
|
| 272 |
}
|
288 |
}
|
| 273 |
File fileToCreate = new File("/tmp/", "vendor-pricing.xls");
|
289 |
File fileToCreate = new File("/tmp/", "vendor-pricing.xls");
|
| 274 |
FileUtils.copyFile(this.file, fileToCreate);
|
290 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 275 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
291 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 276 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
292 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 277 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
293 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 278 |
|
294 |
|
| 279 |
List<VendorItemPricing> vendorItemPricingList= new ArrayList<VendorItemPricing>();
|
295 |
List<VendorItemPricing> vendorItemPricingList= new ArrayList<VendorItemPricing>();
|
| 280 |
List<Long> items = new ArrayList<Long>();
|
296 |
List<Long> items = new ArrayList<Long>();
|
| 281 |
|
297 |
|
| 282 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
298 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 283 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
299 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 284 |
items.add(item_id);
|
300 |
items.add(item_id);
|
| 285 |
}
|
301 |
}
|
| 286 |
Client cc = new CatalogClient().getClient();
|
302 |
Client cc = new CatalogClient().getClient();
|
| 287 |
Map<Long, Item> itemMap = cc.getItems(items);
|
303 |
Map<Long, Item> itemMap = cc.getItems(items);
|
| 288 |
|
304 |
|
| 289 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
305 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 290 |
long itemId = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
306 |
long itemId = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 291 |
if (itemMap.get(itemId)==null){
|
307 |
if (itemMap.get(itemId)==null){
|
| 292 |
continue;
|
308 |
continue;
|
| 293 |
}
|
309 |
}
|
| Line 302... |
Line 318... |
| 302 |
double tp = (double) sheet.getRow(iterator).getCell(4).getNumericCellValue();
|
318 |
double tp = (double) sheet.getRow(iterator).getCell(4).getNumericCellValue();
|
| 303 |
v.setTransferPrice(tp);
|
319 |
v.setTransferPrice(tp);
|
| 304 |
double nlc = (double) sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
320 |
double nlc = (double) sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
| 305 |
v.setNlc(nlc);
|
321 |
v.setNlc(nlc);
|
| 306 |
vendorItemPricingList.add(v);
|
322 |
vendorItemPricingList.add(v);
|
| 307 |
}
|
323 |
}
|
| 308 |
|
324 |
|
| 309 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
325 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 310 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
326 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 311 |
List<Long> notUpdated = inventoryClient.addVendorItemPricingInBulk(vendorItemPricingList);
|
327 |
List<Long> notUpdated = inventoryClient.addVendorItemPricingInBulk(vendorItemPricingList);
|
| 312 |
|
328 |
|
| 313 |
if (notUpdated.size() > 0){
|
329 |
if (notUpdated.size() > 0){
|
| 314 |
StringBuilder sb = new StringBuilder();
|
330 |
StringBuilder sb = new StringBuilder();
|
| 315 |
for (Long x : notUpdated){
|
331 |
for (Long x : notUpdated){
|
| 316 |
sb.append("Vendor Pricing not updated for "+x+"\n");
|
332 |
sb.append("Vendor Pricing not updated for "+x+"\n");
|
| 317 |
}
|
333 |
}
|
| Line 320... |
Line 336... |
| 320 |
else{
|
336 |
else{
|
| 321 |
setResult("Vendor item pricing updated.");
|
337 |
setResult("Vendor item pricing updated.");
|
| 322 |
}
|
338 |
}
|
| 323 |
return "item-details-json";
|
339 |
return "item-details-json";
|
| 324 |
}
|
340 |
}
|
| 325 |
|
341 |
|
| 326 |
public String updateItemPricing() throws IOException, CatalogServiceException, TException{
|
342 |
public String updateItemPricing() throws IOException, CatalogServiceException, TException{
|
| 327 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
343 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 328 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
344 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 329 |
return "authfail";
|
345 |
return "authfail";
|
| 330 |
}
|
346 |
}
|
| 331 |
File fileToCreate = new File("/tmp/", "item-pricing.xls");
|
347 |
File fileToCreate = new File("/tmp/", "item-pricing.xls");
|
| 332 |
FileUtils.copyFile(this.file, fileToCreate);
|
348 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 333 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
349 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 334 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
350 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| 335 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
351 |
HSSFSheet sheet = workbook.getSheetAt(0);
|
| 336 |
|
352 |
|
| 337 |
List<ItemPricing> itemPricingList= new ArrayList<ItemPricing>();
|
353 |
List<ItemPricing> itemPricingList= new ArrayList<ItemPricing>();
|
| 338 |
List<Long> items = new ArrayList<Long>();
|
354 |
List<Long> items = new ArrayList<Long>();
|
| 339 |
|
355 |
|
| 340 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
356 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 341 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
357 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 342 |
items.add(item_id);
|
358 |
items.add(item_id);
|
| 343 |
}
|
359 |
}
|
| 344 |
Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
360 |
Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 345 |
Map<Long, Item> itemMap = cc.getItems(items);
|
361 |
Map<Long, Item> itemMap = cc.getItems(items);
|
| 346 |
|
362 |
|
| 347 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
363 |
for (int iterator=sheet.getFirstRowNum()+1;iterator<=sheet.getLastRowNum();iterator++){
|
| 348 |
ItemPricing i = new ItemPricing();
|
364 |
ItemPricing i = new ItemPricing();
|
| 349 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
365 |
long item_id = (long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
|
| 350 |
i.setItem_id(item_id);
|
366 |
i.setItem_id(item_id);
|
| 351 |
if (itemMap.get(item_id)!=null){
|
367 |
if (itemMap.get(item_id)!=null){
|
| Line 382... |
Line 398... |
| 382 |
}
|
398 |
}
|
| 383 |
else{
|
399 |
else{
|
| 384 |
double weight = (double) sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
400 |
double weight = (double) sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
| 385 |
i.setWeight(weight);
|
401 |
i.setWeight(weight);
|
| 386 |
}
|
402 |
}
|
| 387 |
itemPricingList.add(i);
|
403 |
itemPricingList.add(i);
|
| 388 |
}
|
404 |
}
|
| 389 |
}
|
405 |
}
|
| 390 |
boolean res = cc.updateItemPricing(itemPricingList);
|
406 |
boolean res = cc.updateItemPricing(itemPricingList);
|
| 391 |
if (res){
|
407 |
if (res){
|
| 392 |
setResult("Pricing updated successfully");
|
408 |
setResult("Pricing updated successfully");
|
| Line 394... |
Line 410... |
| 394 |
else{
|
410 |
else{
|
| 395 |
setResult("Unable to update pricing");
|
411 |
setResult("Unable to update pricing");
|
| 396 |
}
|
412 |
}
|
| 397 |
return "item-details-json";
|
413 |
return "item-details-json";
|
| 398 |
}
|
414 |
}
|
| 399 |
|
415 |
|
| 400 |
public String downloadVendors() throws TException, IOException{
|
416 |
public String downloadVendors() throws TException, IOException{
|
| 401 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
417 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 402 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
418 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 403 |
return "authfail";
|
419 |
return "authfail";
|
| 404 |
}
|
420 |
}
|
| 405 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
421 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 406 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
422 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 407 |
List<Vendor> vendors = inventoryClient.getAllVendors();
|
423 |
List<Vendor> vendors = inventoryClient.getAllVendors();
|
| 408 |
|
424 |
|
| 409 |
File file = new File("/tmp/vendors.xls");
|
425 |
File file = new File("/tmp/vendors.xls");
|
| 410 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
426 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
| 411 |
HSSFSheet sheet = hwb.createSheet("Vendors");
|
427 |
HSSFSheet sheet = hwb.createSheet("Vendors");
|
| 412 |
HSSFRow rowhead= sheet.createRow((short)0);
|
428 |
HSSFRow rowhead= sheet.createRow((short)0);
|
| 413 |
rowhead.createCell((short) 0).setCellValue("VENDOR_ID");
|
429 |
rowhead.createCell((short) 0).setCellValue("VENDOR_ID");
|
| 414 |
rowhead.createCell((short) 1).setCellValue("VENDOR_NAME");
|
430 |
rowhead.createCell((short) 1).setCellValue("VENDOR_NAME");
|
| 415 |
|
431 |
|
| 416 |
int iterator= 1;
|
432 |
int iterator= 1;
|
| 417 |
for (Vendor v : vendors){
|
433 |
for (Vendor v : vendors){
|
| 418 |
HSSFRow row = sheet.createRow((short)iterator);
|
434 |
HSSFRow row = sheet.createRow((short)iterator);
|
| 419 |
row.createCell((short) 0).setCellValue(v.getId());
|
435 |
row.createCell((short) 0).setCellValue(v.getId());
|
| 420 |
row.createCell((short) 1).setCellValue(v.getName());
|
436 |
row.createCell((short) 1).setCellValue(v.getName());
|
| 421 |
iterator++;
|
437 |
iterator++;
|
| 422 |
}
|
438 |
}
|
| 423 |
|
439 |
|
| 424 |
FileOutputStream fileOut = null;
|
440 |
FileOutputStream fileOut = null;
|
| 425 |
try {
|
441 |
try {
|
| 426 |
fileOut = new FileOutputStream(file);
|
442 |
fileOut = new FileOutputStream(file);
|
| 427 |
} catch (FileNotFoundException e) {
|
443 |
} catch (FileNotFoundException e) {
|
| 428 |
// TODO Auto-generated catch block
|
444 |
// TODO Auto-generated catch block
|
| Line 468... |
Line 484... |
| 468 |
} catch (IOException e) {
|
484 |
} catch (IOException e) {
|
| 469 |
System.out.println("Unable to stream the manifest file");
|
485 |
System.out.println("Unable to stream the manifest file");
|
| 470 |
}
|
486 |
}
|
| 471 |
setResult("Vendor Streaming done");
|
487 |
setResult("Vendor Streaming done");
|
| 472 |
return "item-details-json";
|
488 |
return "item-details-json";
|
| 473 |
|
489 |
|
| 474 |
}
|
490 |
}
|
| 475 |
|
491 |
|
| 476 |
public String downloadWarehouses() throws TException, IOException{
|
492 |
public String downloadWarehouses() throws TException, IOException{
|
| 477 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
493 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
|
| 478 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
494 |
logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
|
| 479 |
return "authfail";
|
495 |
return "authfail";
|
| 480 |
}
|
496 |
}
|
| 481 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
497 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 482 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
498 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 483 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(null, null, 0, 0, 0);
|
499 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(null, null, 0, 0, 0);
|
| 484 |
|
500 |
|
| 485 |
File file = new File("/tmp/warehouses.xls");
|
501 |
File file = new File("/tmp/warehouses.xls");
|
| 486 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
502 |
HSSFWorkbook hwb=new HSSFWorkbook();
|
| 487 |
HSSFSheet sheet = hwb.createSheet("Warehouses");
|
503 |
HSSFSheet sheet = hwb.createSheet("Warehouses");
|
| 488 |
HSSFRow rowhead= sheet.createRow((short)0);
|
504 |
HSSFRow rowhead= sheet.createRow((short)0);
|
| 489 |
rowhead.createCell((short) 0).setCellValue("warehouse_id");
|
505 |
rowhead.createCell((short) 0).setCellValue("warehouse_id");
|
| Line 493... |
Line 509... |
| 493 |
rowhead.createCell((short) 4).setCellValue("vendor_name");
|
509 |
rowhead.createCell((short) 4).setCellValue("vendor_name");
|
| 494 |
rowhead.createCell((short) 5).setCellValue("inventory_type");
|
510 |
rowhead.createCell((short) 5).setCellValue("inventory_type");
|
| 495 |
rowhead.createCell((short) 6).setCellValue("warehouse_type");
|
511 |
rowhead.createCell((short) 6).setCellValue("warehouse_type");
|
| 496 |
rowhead.createCell((short) 7).setCellValue("logistics_location");
|
512 |
rowhead.createCell((short) 7).setCellValue("logistics_location");
|
| 497 |
rowhead.createCell((short) 8).setCellValue("state_id");
|
513 |
rowhead.createCell((short) 8).setCellValue("state_id");
|
| 498 |
|
514 |
|
| 499 |
int iterator= 1;
|
515 |
int iterator= 1;
|
| 500 |
for (Warehouse w : warehouses){
|
516 |
for (Warehouse w : warehouses){
|
| 501 |
HSSFRow row = sheet.createRow((short)iterator);
|
517 |
HSSFRow row = sheet.createRow((short)iterator);
|
| 502 |
row.createCell((short) 0).setCellValue(w.getId());
|
518 |
row.createCell((short) 0).setCellValue(w.getId());
|
| 503 |
row.createCell((short) 1).setCellValue(w.getDisplayName());
|
519 |
row.createCell((short) 1).setCellValue(w.getDisplayName());
|
| Line 508... |
Line 524... |
| 508 |
row.createCell((short) 6).setCellValue(w.getWarehouseType().toString());
|
524 |
row.createCell((short) 6).setCellValue(w.getWarehouseType().toString());
|
| 509 |
row.createCell((short) 7).setCellValue(w.getLogisticsLocation().toString());
|
525 |
row.createCell((short) 7).setCellValue(w.getLogisticsLocation().toString());
|
| 510 |
row.createCell((short) 7).setCellValue(w.getStateId());
|
526 |
row.createCell((short) 7).setCellValue(w.getStateId());
|
| 511 |
iterator++;
|
527 |
iterator++;
|
| 512 |
}
|
528 |
}
|
| 513 |
|
529 |
|
| 514 |
FileOutputStream fileOut = null;
|
530 |
FileOutputStream fileOut = null;
|
| 515 |
try {
|
531 |
try {
|
| 516 |
fileOut = new FileOutputStream(file);
|
532 |
fileOut = new FileOutputStream(file);
|
| 517 |
} catch (FileNotFoundException e) {
|
533 |
} catch (FileNotFoundException e) {
|
| 518 |
// TODO Auto-generated catch block
|
534 |
// TODO Auto-generated catch block
|
| Line 558... |
Line 574... |
| 558 |
} catch (IOException e) {
|
574 |
} catch (IOException e) {
|
| 559 |
System.out.println("Unable to stream the manifest file");
|
575 |
System.out.println("Unable to stream the manifest file");
|
| 560 |
}
|
576 |
}
|
| 561 |
setResult("Warehouse Streaming done");
|
577 |
setResult("Warehouse Streaming done");
|
| 562 |
return "item-details-json";
|
578 |
return "item-details-json";
|
| 563 |
|
579 |
|
| 564 |
}
|
580 |
}
|
| 565 |
|
581 |
|
| 566 |
|
582 |
|
| 567 |
public boolean checkEmptyString(Cell cell){
|
583 |
public boolean checkEmptyString(Cell cell){
|
| 568 |
if (cell==null || cell.getCellType() == Cell.CELL_TYPE_BLANK){
|
584 |
if (cell==null || cell.getCellType() == Cell.CELL_TYPE_BLANK){
|
| 569 |
return true;
|
585 |
return true;
|
| 570 |
}
|
586 |
}
|
| 571 |
return false;
|
587 |
return false;
|
| 572 |
}
|
588 |
}
|
| 573 |
|
589 |
|
| 574 |
public String getItemDetails(){
|
590 |
public String getItemDetails(){
|
| 575 |
return result;
|
591 |
return result;
|
| 576 |
}
|
592 |
}
|
| 577 |
|
593 |
|
| 578 |
public void setId(String id) {
|
594 |
public void setId(String id) {
|
| Line 614... |
Line 630... |
| 614 |
|
630 |
|
| 615 |
public void setContext(ServletContext context) {
|
631 |
public void setContext(ServletContext context) {
|
| 616 |
this.context = context;
|
632 |
this.context = context;
|
| 617 |
}
|
633 |
}
|
| 618 |
|
634 |
|
| 619 |
|
635 |
|
| 620 |
public void setServletRequest(HttpServletRequest req) {
|
636 |
public void setServletRequest(HttpServletRequest req) {
|
| 621 |
this.request = req;
|
637 |
this.request = req;
|
| 622 |
this.session = req.getSession();
|
638 |
this.session = req.getSession();
|
| 623 |
}
|
639 |
}
|
| 624 |
|
640 |
|
| Line 628... |
Line 644... |
| 628 |
}
|
644 |
}
|
| 629 |
|
645 |
|
| 630 |
public void setServletResponse(HttpServletResponse response) {
|
646 |
public void setServletResponse(HttpServletResponse response) {
|
| 631 |
this.response = response;
|
647 |
this.response = response;
|
| 632 |
}
|
648 |
}
|
| 633 |
|
649 |
|
| 634 |
public String getResult() {
|
650 |
public String getResult() {
|
| 635 |
return result;
|
651 |
return result;
|
| 636 |
}
|
652 |
}
|
| 637 |
|
653 |
|
| 638 |
public void setResult(String result) {
|
654 |
public void setResult(String result) {
|
| 639 |
this.result = result;
|
655 |
this.result = result;
|
| 640 |
}
|
656 |
}
|
| 641 |
|
657 |
|
| 642 |
public File getFile() {
|
658 |
public File getFile() {
|
| 643 |
return file;
|
659 |
return file;
|
| 644 |
}
|
660 |
}
|
| 645 |
|
661 |
|
| 646 |
public void setFile(File file) {
|
662 |
public void setFile(File file) {
|
| 647 |
this.file = file;
|
663 |
this.file = file;
|
| 648 |
}
|
664 |
}
|
| 649 |
|
665 |
|
| 650 |
|
666 |
|
| 651 |
}
|
667 |
}
|
| 652 |
|
668 |
|