Subversion Repositories SmartDukaan

Rev

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

Rev 30122 Rev 30250
Line 652... Line 652...
652
		model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
652
		model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
653
		model.addAttribute("partnerCode", fs.getCode());
653
		model.addAttribute("partnerCode", fs.getCode());
654
		return "price-circular-detail";
654
		return "price-circular-detail";
655
	}
655
	}
656
 
656
 
-
 
657
 
-
 
658
	@RequestMapping(value = "/downloadNlcByBrand")
-
 
659
	public ResponseEntity<ByteArrayResource> downloadNlcByBrand(HttpServletRequest request,
-
 
660
																@RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId) throws Exception {
-
 
661
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
662
		if (fofoId > 0 && roleManager.isAdmin(loginDetails.getRoleIds())) {
-
 
663
		} else {
-
 
664
			fofoId = loginDetails.getFofoId();
-
 
665
		}
-
 
666
		PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
-
 
667
		List<PartnerType> partnerTypes = new ArrayList<>();
-
 
668
		partnerTypes.add(partnerType);
-
 
669
		partnerTypes.add(PartnerType.ALL);
-
 
670
		PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, brand);
-
 
671
		ByteArrayOutputStream baos = getNlcBaos(brand, priceCircular);
-
 
672
		final HttpHeaders headers = new HttpHeaders();
-
 
673
		headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
-
 
674
		headers.set("Content-disposition", "inline; filename=\"" + brand + ".csv\"");
-
 
675
		byte[] byteArray = baos.toByteArray();
-
 
676
		headers.setContentLength(byteArray.length);
-
 
677
		return new ResponseEntity<>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
-
 
678
	}
-
 
679
 
-
 
680
	private ByteArrayOutputStream getNlcBaos(String brand, PriceCircularModel priceCircular) throws Exception {
-
 
681
		List<List<?>> rows = new ArrayList<>();
-
 
682
		for (PriceCircularItemModel priceCircularItemModel : priceCircular.getPriceCircularItemModels()) {
-
 
683
			List<Serializable> row = new ArrayList<>();
-
 
684
			row.add(priceCircularItemModel.getCatalogId());
-
 
685
			row.add(brand);
-
 
686
			row.add(priceCircularItemModel.getModelName());
-
 
687
			row.add(priceCircularItemModel.getModelNumber());
-
 
688
			row.add(priceCircularItemModel.getNetPrice());
-
 
689
			rows.add(row);
-
 
690
		}
-
 
691
		return FileUtil.getCSVByteStream(Arrays.asList("Model Id", "Brand", "Model Name", "Model Number", "Partner Landing"), rows);
-
 
692
	}
-
 
693
 
657
	@RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
694
	@RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
658
	public String selectPriceDropStatus(HttpServletRequest request,
695
	public String selectPriceDropStatus(HttpServletRequest request,
659
										@RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
696
										@RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
660
										Model model) throws Exception {
697
										Model model) throws Exception {
661
 
698