Subversion Repositories SmartDukaan

Rev

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

Rev 26959 Rev 26961
Line 48... Line 48...
48
import org.springframework.web.bind.annotation.RequestMethod;
48
import org.springframework.web.bind.annotation.RequestMethod;
49
import org.springframework.web.bind.annotation.RequestParam;
49
import org.springframework.web.bind.annotation.RequestParam;
50
import org.springframework.web.bind.annotation.RequestPart;
50
import org.springframework.web.bind.annotation.RequestPart;
51
import org.springframework.web.multipart.MultipartFile;
51
import org.springframework.web.multipart.MultipartFile;
52
 
52
 
-
 
53
import com.google.common.collect.Lists;
53
import com.google.gson.Gson;
54
import com.google.gson.Gson;
54
import com.spice.profitmandi.common.enumuration.MessageType;
55
import com.spice.profitmandi.common.enumuration.MessageType;
55
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
56
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
56
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
57
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
57
import com.spice.profitmandi.common.model.CustomRetailer;
58
import com.spice.profitmandi.common.model.CustomRetailer;
Line 455... Line 456...
455
		headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
456
		headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
456
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
457
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
457
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
458
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
458
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
459
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
459
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
460
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
-
 
461
	}
460
 
462
	
-
 
463
	@RequestMapping(value = "/aging-report", method = RequestMethod.POST)
-
 
464
	public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request) throws ProfitMandiBusinessException {
-
 
465
		
-
 
466
		List<Integer> intervals = Arrays.asList(5,15,30,45);
-
 
467
		List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService.getItemAgingByInterval(intervals)
-
 
468
				.values().stream().flatMap(x->x.stream()).collect(Collectors.toList());
-
 
469
		
-
 
470
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
 
471
		ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
461
		// return
472
		
-
 
473
		final HttpHeaders headers = new HttpHeaders();
-
 
474
		// private static final String CONTENT_TYPE_XLSX =
-
 
475
		// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-
 
476
		headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-
 
477
		// headers.set("Content-Type", "application/vnd.ms-excel");
-
 
478
		headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
462
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
479
		headers.setContentLength(byteArrayOutputStream.toByteArray().length);
-
 
480
		final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-
 
481
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
-
 
482
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
463
	}
483
	}
464
 
484
 
465
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
485
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
466
	public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
486
	public String FeaturePanel(HttpServletRequest request, Model model) throws Exception {
467
 
487