Subversion Repositories SmartDukaan

Rev

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

Rev 19988 Rev 19997
Line 602... Line 602...
602
	public String downloadVirtualInventoryForWarehouse() throws NumberFormatException, TException, IOException{
602
	public String downloadVirtualInventoryForWarehouse() throws NumberFormatException, TException, IOException{
603
		try{
603
		try{
604
			InventoryClient inventoryServiceClient = new InventoryClient();
604
			InventoryClient inventoryServiceClient = new InventoryClient();
605
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
605
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
606
			Map<Long, ItemInventory> inventoryMap = inventoryClient.getInventorySnapshot(Long.valueOf(virtualWarehouseId));
606
			Map<Long, ItemInventory> inventoryMap = inventoryClient.getInventorySnapshot(Long.valueOf(virtualWarehouseId));
-
 
607
			List<Long> itemIds = new ArrayList<Long>();
607
			File file = new File("/tmp/currentinventory.xls");
608
			File file = new File("/tmp/currentinventory.xls");
608
			HSSFWorkbook hwb=new HSSFWorkbook();
609
			HSSFWorkbook hwb=new HSSFWorkbook();
609
			HSSFSheet sheet =  hwb.createSheet("Inventory");
610
			HSSFSheet sheet =  hwb.createSheet("Inventory");
610
			HSSFRow rowhead=   sheet.createRow((short)0);
611
			HSSFRow rowhead=   sheet.createRow((short)0);
611
			rowhead.createCell((short) 0).setCellValue("item_id");
612
			rowhead.createCell((short) 0).setCellValue("item_id");
-
 
613
			rowhead.createCell((short) 1).setCellValue("brand");
-
 
614
			rowhead.createCell((short) 2).setCellValue("model_name");
-
 
615
			rowhead.createCell((short) 3).setCellValue("model_number");
-
 
616
			rowhead.createCell((short) 4).setCellValue("color");
612
			rowhead.createCell((short) 1).setCellValue("Availability");
617
			rowhead.createCell((short) 5).setCellValue("Availability");
613
			rowhead.createCell((short) 2).setCellValue("Reserved");
618
			rowhead.createCell((short) 6).setCellValue("Reserved");
614
			rowhead.createCell((short) 3).setCellValue("Held");
619
			rowhead.createCell((short) 7).setCellValue("Held");
615
 
620
 
616
			int iterator= 1;
621
			int iterator= 1;
617
			for (Map.Entry<Long,ItemInventory> entry : inventoryMap.entrySet()) {
622
			for (Map.Entry<Long,ItemInventory> entry : inventoryMap.entrySet()) {
618
				HSSFRow row = sheet.createRow((short)iterator);
623
				HSSFRow row = sheet.createRow((short)iterator);
-
 
624
				itemIds.add(entry.getKey());
619
				row.createCell((short) 0).setCellValue(entry.getKey());
625
				row.createCell((short) 0).setCellValue(entry.getKey());
620
				row.createCell((short) 1).setCellValue(entry.getValue().getAvailability().get(Long.valueOf(virtualWarehouseId)));
626
				row.createCell((short) 5).setCellValue(entry.getValue().getAvailability().get(Long.valueOf(virtualWarehouseId)));
621
				row.createCell((short) 2).setCellValue(entry.getValue().getReserved().get(Long.valueOf(virtualWarehouseId)));
627
				row.createCell((short) 6).setCellValue(entry.getValue().getReserved().get(Long.valueOf(virtualWarehouseId)));
622
				row.createCell((short) 3).setCellValue(entry.getValue().getHeld().get(Long.valueOf(virtualWarehouseId)));
628
				row.createCell((short) 7).setCellValue(entry.getValue().getHeld().get(Long.valueOf(virtualWarehouseId)));
623
				iterator++;
629
				iterator++;
624
			}
630
			}
-
 
631
			Client cc = new CatalogClient().getClient();
-
 
632
			Map<Long, Item> itemMap = cc.getItems(itemIds);
625
 
633
			
-
 
634
			iterator--;
-
 
635
			Item d_item;
-
 
636
			while(iterator!=0){
-
 
637
				long item_id = Long.valueOf(sheet.getRow(iterator).getCell(0).getStringCellValue());
-
 
638
				d_item = itemMap.get(item_id);
-
 
639
				if (d_item == null){
-
 
640
					iterator--;
-
 
641
					continue;
-
 
642
				}
-
 
643
				sheet.getRow(iterator).createCell((short) 1).setCellValue(d_item.getBrand());
-
 
644
				sheet.getRow(iterator).createCell((short) 2).setCellValue(d_item.getModelName());
-
 
645
				sheet.getRow(iterator).createCell((short) 3).setCellValue(d_item.getModelNumber());
-
 
646
				sheet.getRow(iterator).createCell((short) 4).setCellValue(d_item.getColor());
-
 
647
				iterator--;
-
 
648
			}
-
 
649
			
626
			FileOutputStream fileOut = null;
650
			FileOutputStream fileOut = null;
627
			try {
651
			try {
628
				fileOut = new FileOutputStream(file);
652
				fileOut = new FileOutputStream(file);
629
			} catch (FileNotFoundException e) {
653
			} catch (FileNotFoundException e) {
630
				// TODO Auto-generated catch block
654
				// TODO Auto-generated catch block